Debian Codegraph @

modules/lsp-audio-pipewire-lib/include/lsp-plug.in/audio/pipewire/ringbuffer.h

raw
1 /*
2 * Copyright (C) 2026 Linux Studio Plugins Project <https://lsp-plug.in/>
3 * (C) 2026 Vladimir Sadovnikov <[email protected]>
4 *
5 * This file is part of lsp-audio-pipewire-lib
6 * Created on: 7 мая 2026 г.
7 *
8 * lsp-audio-pipewire-lib is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * any later version.
12 *
13 * lsp-audio-pipewire-lib is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with lsp-audio-pipewire-lib. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22 #ifndef LSP_PLUG_IN_AUDIO_PIPEWIRE_RINGBUFFER_H_
23 #define LSP_PLUG_IN_AUDIO_PIPEWIRE_RINGBUFFER_H_
24
25 #include <lsp-plug.in/audio/pipewire/version.h>
26
27 #include <lsp-plug.in/common/status.h>
28 #include <lsp-plug.in/common/types.h>
29
30 #include <pw-headers/pipewire/loop.h>
31 #include <pw-headers/spa/support/loop.h>
32 #include <pw-headers/spa/utils/ringbuffer.h>
33
34 namespace lsp
35 {
36 namespace audio
37 {
38 namespace pipewire
39 {
40 /**
41 * Ring buffer for data exchange between RT and Context threads.
42 */
43 typedef struct ringbuffer
44 {
45 protected:
46 pw_loop *pLoop;
47 spa_source *pEvent;
48 uint8_t *vBuffer;
49 spa_ringbuffer sRing;
50 uint32_t nSize;
51
52 public:
53 ringbuffer() noexcept;
54 ringbuffer(const ringbuffer &) = delete;
55 ringbuffer(ringbuffer &&) = delete;
56 ~ringbuffer() noexcept;
57
58 ringbuffer & operator = (const ringbuffer &) = delete;
59 ringbuffer & operator = (ringbuffer &&) = delete;
60
61 void construct() noexcept;
62 void destroy() noexcept;
63
64 public:
65 status_t init(
66 pw_loop * loop, uint32_t size,
67 spa_source_event_func_t handler, void *data) noexcept;
68
69 ssize_t read(void *dst, uint32_t count) noexcept;
70 status_t write(const void *src, uint32_t count) noexcept;
71
72 } ringbuffer;
73 } /* namespace pipewire */
74 } /* namespace audio */
75 } /* namespace lsp */
76
77
78 #endif /* LSP_PLUG_IN_AUDIO_PIPEWIRE_RINGBUFFER_H_ */