Skip to content

Commit 2fb90b7

Browse files
committed
Release 1.0.22
* Implemented shared catalog class. * Implemented shared audio stream class. * Updated module versions in dependencies.
2 parents c85895d + b1d0002 commit 2fb90b7

File tree

14 files changed

+2250
-17
lines changed

14 files changed

+2250
-17
lines changed

.cproject

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
<option id="gnu.cpp.link.option.flags.1996842112" name="Linker flags" superClass="gnu.cpp.link.option.flags" useByScannerDiscovery="false" value="$(shell pkg-config --libs sndfile)" valueType="string"/>
5656
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.link.option.libs.1754094703" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" useByScannerDiscovery="false" valueType="libs">
5757
<listOptionValue builtIn="false" value="dl"/>
58+
<listOptionValue builtIn="false" value="rt"/>
5859
<listOptionValue builtIn="false" value="pthread"/>
5960
</option>
6061
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1016670562" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
@@ -81,7 +82,7 @@
8182
</fileInfo>
8283
<fileInfo id="cdt.managedbuild.config.gnu.exe.debug.942206677.1407716864" name="avx512.cpp" rcbsApplicability="disable" resourcePath="modules/lsp-dsp-lib/src/main/x86/avx512.cpp" toolsToInvoke="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.962442605.1769343050">
8384
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.962442605.1769343050" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.962442605">
84-
<option id="gnu.cpp.compiler.option.other.other.271659202" superClass="gnu.cpp.compiler.option.other.other" useByScannerDiscovery="false" value="-c -fmessage-length=0 -mavx512f -mavx512vl" valueType="string"/>
85+
<option id="gnu.cpp.compiler.option.other.other.271659202" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" useByScannerDiscovery="false" value="-c -fmessage-length=0 -mavx512f -mavx512vl" valueType="string"/>
8586
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.906926982" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
8687
</tool>
8788
</fileInfo>
@@ -110,7 +111,7 @@
110111
</tool>
111112
</fileInfo>
112113
<sourceEntries>
113-
<entry excluding="modules/lsp-lltl-lib/src/test/main.cpp|modules/lsp-dsp-lib/src/test/main.cpp|modules/lsp-test-fw/src/test/main.cpp|modules/lsp-runtime-lib/src/test/main.cpp|modules/lsp-common-lib/src/test/main.cpp" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
114+
<entry excluding="modules/lsp-dsp-lib/src/test/main.cpp|modules/lsp-test-fw/src/test/main.cpp|modules/lsp-common-lib/src/test/main.cpp|modules/lsp-lltl-lib/src/test/main.cpp|modules/lsp-runtime-lib/src/test/main.cpp" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
114115
</sourceEntries>
115116
</configuration>
116117
</storageModule>
@@ -171,7 +172,7 @@
171172
</fileInfo>
172173
<fileInfo id="cdt.managedbuild.config.gnu.exe.release.1561532595.964658198" name="avx512.cpp" rcbsApplicability="disable" resourcePath="modules/lsp-dsp-lib/src/main/x86/avx512.cpp" toolsToInvoke="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.209063002.650062259">
173174
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.209063002.650062259" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.209063002">
174-
<option id="gnu.cpp.compiler.option.other.other.104173302" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0 -mavx512f -mavx512vl" valueType="string"/>
175+
<option id="gnu.cpp.compiler.option.other.other.104173302" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0 -mavx512f -mavx512vl" valueType="string"/>
175176
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.774577752" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
176177
</tool>
177178
</fileInfo>
@@ -200,7 +201,7 @@
200201
</tool>
201202
</fileInfo>
202203
<sourceEntries>
203-
<entry excluding="modules/lsp-lltl-lib/src/test/main.cpp|modules/lsp-dsp-lib/src/test/main.cpp|modules/lsp-test-fw/src/test/main.cpp|modules/lsp-runtime-lib/src/test/main.cpp|modules/lsp-common-lib/src/test/main.cpp" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
204+
<entry excluding="modules/lsp-dsp-lib/src/test/main.cpp|modules/lsp-test-fw/src/test/main.cpp|modules/lsp-common-lib/src/test/main.cpp|modules/lsp-lltl-lib/src/test/main.cpp|modules/lsp-runtime-lib/src/test/main.cpp" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
204205
</sourceEntries>
205206
</configuration>
206207
</storageModule>
@@ -286,7 +287,7 @@
286287
</fileInfo>
287288
<fileInfo id="cdt.managedbuild.config.gnu.exe.debug.942206677.501860306.1835706701" name="avx512.cpp" rcbsApplicability="disable" resourcePath="modules/lsp-dsp-lib/src/main/x86/avx512.cpp" toolsToInvoke="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.1871125847.1573394045">
288289
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.1871125847.1573394045" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.1871125847">
289-
<option id="gnu.cpp.compiler.option.other.other.1458611367" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0 -mavx512f -mavx512vl" valueType="string"/>
290+
<option id="gnu.cpp.compiler.option.other.other.1458611367" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0 -mavx512f -mavx512vl" valueType="string"/>
290291
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.315399002" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
291292
</tool>
292293
</fileInfo>
@@ -315,7 +316,7 @@
315316
</tool>
316317
</fileInfo>
317318
<sourceEntries>
318-
<entry excluding="modules/lsp-lltl-lib/src/test/main.cpp|modules/lsp-dsp-lib/src/test/main.cpp|modules/lsp-test-fw/src/test/main.cpp|modules/lsp-runtime-lib/src/test/main.cpp|modules/lsp-common-lib/src/test/main.cpp" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
319+
<entry excluding="modules/lsp-dsp-lib/src/test/main.cpp|modules/lsp-test-fw/src/test/main.cpp|modules/lsp-common-lib/src/test/main.cpp|modules/lsp-lltl-lib/src/test/main.cpp|modules/lsp-runtime-lib/src/test/main.cpp" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
319320
</sourceEntries>
320321
</configuration>
321322
</storageModule>

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
* RECENT CHANGES
33
*******************************************************************************
44

5+
=== 1.0.22 ===
6+
* Implemented shared catalog class.
7+
* Implemented shared audio stream class.
8+
* Updated module versions in dependencies.
9+
510
=== 1.0.21 ===
611
* Implemented safer algorithm of loading sample when the underlying stream
712
does not know the actual number of frames in the stream.
Lines changed: 238 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
1+
/*
2+
* Copyright (C) 2024 Linux Studio Plugins Project <https://lsp-plug.in/>
3+
* (C) 2024 Vladimir Sadovnikov <sadko4u@gmail.com>
4+
*
5+
* This file is part of lsp-dsp-units
6+
* Created on: 8 мая 2024 г.
7+
*
8+
* lsp-dsp-units 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-dsp-units 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-dsp-units. If not, see <https://www.gnu.org/licenses/>.
20+
*/
21+
22+
#ifndef LSP_PLUG_IN_DSP_UNITS_SHARED_AUDIOSTREAM_H_
23+
#define LSP_PLUG_IN_DSP_UNITS_SHARED_AUDIOSTREAM_H_
24+
25+
#include <lsp-plug.in/dsp-units/version.h>
26+
27+
#include <lsp-plug.in/common/status.h>
28+
#include <lsp-plug.in/common/types.h>
29+
#include <lsp-plug.in/ipc/SharedMem.h>
30+
#include <lsp-plug.in/runtime/LSPString.h>
31+
32+
namespace lsp
33+
{
34+
namespace dspu
35+
{
36+
/**
37+
* Shared audio stream FIFO with single producer and multiple consumers.
38+
*/
39+
class LSP_DSP_UNITS_PUBLIC AudioStream
40+
{
41+
protected:
42+
enum stream_flags_t
43+
{
44+
SS_INITIALIZED = 0x000000c3,
45+
SS_UPDATED = 0x00009600,
46+
SS_TERMINATED = 0x005a0000,
47+
48+
SS_INIT_MASK = 0x000000ff,
49+
SS_UPD_MASK = 0x0000ff00,
50+
SS_TERM_MASK = 0x00ff0000
51+
};
52+
53+
typedef struct alloc_params_t
54+
{
55+
size_t nChannels;
56+
size_t nHdrBytes;
57+
size_t nChannelBytes;
58+
size_t nSegmentBytes;
59+
} alloc_params_t;
60+
61+
typedef struct sh_header_t
62+
{
63+
uint32_t nMagic; // Magic number
64+
uint32_t nVersion; // Version of the buffer
65+
uint32_t nFlags; // Stream flags
66+
uint32_t nChannels; // Number of channels
67+
uint32_t nLength; // Number of samples per channel
68+
volatile uint32_t nMaxBlkSize; // Maximum block size written
69+
volatile uint32_t nHead; // Position of the head of the buffer
70+
volatile uint32_t nCounter; // Auto-incrementing counter for each change
71+
} sh_header_t;
72+
73+
typedef struct channel_t
74+
{
75+
uint32_t nPosition; // Read/Write position
76+
uint32_t nCount; // Number of samples read/written
77+
float *pData; // Pointer to channel data
78+
} channel_t;
79+
80+
protected:
81+
ipc::SharedMem hMem; // Shared memory descriptor
82+
sh_header_t *pHeader; // Header of the shared buffer
83+
channel_t *vChannels; // Pointer to channel descriptions
84+
uint32_t nChannels; // Number of channels
85+
uint32_t nHead; // Head position
86+
uint32_t nAvail; // Number of samples available
87+
uint32_t nBlkSize; // Block size
88+
uint32_t nCounter; // Counter
89+
bool bWriteMode; // Stream is opened for writing
90+
bool bIO; // I/O mode (begin() called)
91+
bool bUnderrun; // Underrun detected
92+
93+
protected:
94+
bool check_channels_synchronized();
95+
status_t open_internal();
96+
status_t create_internal(size_t channels, const alloc_params_t *params);
97+
98+
protected:
99+
static bool calc_params(alloc_params_t *params, size_t channels, size_t length);
100+
101+
public:
102+
AudioStream();
103+
AudioStream(const AudioStream &) = delete;
104+
AudioStream(AudioStream &&) = delete;
105+
~AudioStream();
106+
107+
AudioStream & operator = (const AudioStream &) = delete;
108+
AudioStream & operator = (AudioStream &&) = delete;
109+
110+
/** Construct object
111+
*
112+
*/
113+
void construct();
114+
115+
/** Destroy object
116+
*
117+
*/
118+
void destroy();
119+
120+
121+
public:
122+
/**
123+
* Open named audio stream for reading
124+
* @param id identifier of the named audio stream
125+
* @return status of operation
126+
*/
127+
status_t open(const char *id);
128+
129+
/**
130+
* Open named audio stream for reading
131+
* @param id identifier of the named audio stream
132+
* @return status of operation
133+
*/
134+
status_t open(const LSPString *id);
135+
136+
/**
137+
* Create and open named audio stream for writing
138+
* @param id identifier of the named audio stream
139+
* @param channels number of audio channels
140+
* @param length length of each channel
141+
* @param persist use persistent shared memory segment
142+
* @return status of operation
143+
*/
144+
status_t create(const char *id, size_t channels, size_t length);
145+
146+
/**
147+
* Create and open named audio stream for writing
148+
* @param id identifier of the named audio stream
149+
* @param channels number of audio channels
150+
* @param length length of each channel
151+
* @param persit use persistent shared memory segment
152+
* @return status of operation
153+
*/
154+
status_t create(const LSPString *id, size_t channels, size_t length);
155+
156+
/**
157+
* Create and open named audio stream for writing
158+
* @param name pointer to store the name of the shared segment
159+
* @param postfix postfix for the shared segment to add
160+
* @param channels number of audio channels
161+
* @param length length of each channel
162+
* @param persit use persistent shared memory segment
163+
* @return status of operation
164+
*/
165+
status_t allocate(LSPString *name, const char *postfix, size_t channels, size_t length);
166+
167+
/**
168+
* Create and open named audio stream for writing
169+
* @param name pointer to store the name of the shared segment
170+
* @param postfix postfix for the shared segment to add
171+
* @param channels number of audio channels
172+
* @param length length of each channel
173+
* @param persit use persistent shared memory segment
174+
* @return status of operation
175+
*/
176+
status_t allocate(LSPString *name, const LSPString *postfix, size_t channels, size_t length);
177+
178+
/**
179+
* Close
180+
* @return status of operation
181+
*/
182+
status_t close();
183+
184+
public:
185+
/**
186+
* Return number of channels
187+
* @return number of channels
188+
*/
189+
size_t channels() const;
190+
191+
/**
192+
* Get number of samples per channel
193+
* @return number of samples per channel
194+
*/
195+
size_t length() const;
196+
197+
/**
198+
* Begin I/O operation on the stream
199+
* @param block_size the desired block size that will be read or written, zero value means infinite block size
200+
* @return status of operation
201+
*/
202+
status_t begin(ssize_t block_size = 0);
203+
204+
/**
205+
* Read contents of specific channel
206+
* Should be called between begin() and end() calls
207+
*
208+
* @param channel number of channel
209+
* @param dst destination buffer to store data
210+
* @param samples number of samples to read
211+
* @return status of operation
212+
*/
213+
status_t read(size_t channel, float *dst, size_t samples);
214+
215+
/**
216+
* Read contents of specific channel
217+
* Should be called between begin() and end() calls
218+
*
219+
* @param channel number of channel
220+
* @param dst destination buffer to store data
221+
* @param samples number of samples to read
222+
* @return status of operation
223+
*/
224+
status_t write(size_t channel, const float *src, size_t samples);
225+
226+
/**
227+
* End I/O operations on the stream
228+
* @return status of operation
229+
*/
230+
status_t end();
231+
};
232+
233+
} /* namespace dspu */
234+
} /* namespace lsp */
235+
236+
237+
238+
#endif /* LSP_PLUG_IN_DSP_UNITS_SHARED_SHAREDAUDIOSTREAM_H_ */

0 commit comments

Comments
 (0)