added disclaimer

This commit is contained in:
AlexandreRouma 2023-04-10 22:52:50 +02:00
parent 961cd3f133
commit 48e9708d74
3 changed files with 49 additions and 14 deletions

View File

@ -73,7 +73,7 @@ int AudioStream::addSink(const std::string& type) {
// Create sink instance // Create sink instance
int id = sinks.size(); int id = sinks.size();
auto sink = manager->providers[type]->createSink(this); auto sink = manager->providers[type]->createSink(this, id);
// Check that the sink was created succesfully // Check that the sink was created succesfully
if (!sink) { if (!sink) {
@ -82,7 +82,7 @@ int AudioStream::addSink(const std::string& type) {
} }
// Create and save entry // Create and save entry
sinks.push_back(SinkEntry(std::move(sink))); sinks.push_back(std::make_shared<SinkEntry>(std::move(sink)));
return id; return id;
} }
@ -97,14 +97,13 @@ void AudioStream::removeSink(int index) {
} }
// TODO: Free stuff // TODO: Free stuff
} }
const std::vector<SinkEntry>& AudioStream::getSinks() { const std::vector<std::shared_ptr<SinkEntry>>& AudioStream::getSinks() {
return sinks; return sinks;
} }
std::shared_ptr<AudioStream> StreamManager::registerStream(const std::string& name, dsp::stream<dsp::stereo_t>* stream, double samplerate) { std::shared_ptr<AudioStream> StreamManager::createStream(const std::string& name, dsp::stream<dsp::stereo_t>* stream, double samplerate) {
std::lock_guard<std::recursive_mutex> lck(mtx); std::lock_guard<std::recursive_mutex> lck(mtx);
// Check that an audio stream that name doesn't already exist // Check that an audio stream that name doesn't already exist
@ -117,7 +116,7 @@ std::shared_ptr<AudioStream> StreamManager::registerStream(const std::string& na
streams[name] = std::make_shared<AudioStream>(this, stream, samplerate); streams[name] = std::make_shared<AudioStream>(this, stream, samplerate);
} }
void StreamManager::unregisterStream(const std::string& name) { void StreamManager::destroyStream(const std::string& name) {
std::lock_guard<std::recursive_mutex> lck(mtx); std::lock_guard<std::recursive_mutex> lck(mtx);
// Check that stream exists // Check that stream exists

View File

@ -24,6 +24,7 @@ private:
class SinkEntry { class SinkEntry {
public: public:
SinkEntry(std::unique_ptr<Sink> sink); SinkEntry(std::unique_ptr<Sink> sink);
~SinkEntry();
float getVolume(); float getVolume();
void setVolume(float volume); void setVolume(float volume);
@ -34,6 +35,7 @@ public:
float getPanning(); float getPanning();
void setPanning(float panning); void setPanning(float panning);
private: private:
dsp::stream<dsp::stereo_t> stream;
dsp::audio::Volume volumeAdjust; dsp::audio::Volume volumeAdjust;
dsp::multirate::RationalResampler<dsp::stereo_t> resamp; dsp::multirate::RationalResampler<dsp::stereo_t> resamp;
@ -51,8 +53,16 @@ class AudioStream {
public: public:
AudioStream(StreamManager* manager, const std::string& name, dsp::stream<dsp::stereo_t>* stream, double samplerate); AudioStream(StreamManager* manager, const std::string& name, dsp::stream<dsp::stereo_t>* stream, double samplerate);
/**
* Set DSP stream input.
* @param stream DSP stream.
*/
void setInput(dsp::stream<dsp::stereo_t>* stream); void setInput(dsp::stream<dsp::stereo_t>* stream);
/**
* Get the name of the stream.
* @return Name of the stream.
*/
const std::string& getName(); const std::string& getName();
void bindStream(dsp::stream<dsp::stereo_t>* stream); void bindStream(dsp::stream<dsp::stereo_t>* stream);
@ -64,7 +74,7 @@ public:
int addSink(const std::string& type); int addSink(const std::string& type);
void setSinkType(int index, const std::string& type); void setSinkType(int index, const std::string& type);
void removeSink(int index); void removeSink(int index);
const std::vector<SinkEntry>& getSinks(); const std::vector<std::shared_ptr<SinkEntry>>& getSinks();
private: private:
void setSinkInputSamplerate(Sink* sink, double samplerate); void setSinkInputSamplerate(Sink* sink, double samplerate);
@ -74,12 +84,22 @@ private:
std::string name; std::string name;
double samplerate; double samplerate;
dsp::routing::Splitter<dsp::stereo_t> split; dsp::routing::Splitter<dsp::stereo_t> split;
std::vector<SinkEntry> sinks; std::vector<std::shared_ptr<SinkEntry>> sinks;
}; };
class SinkProvider { class SinkProvider {
public: public:
/**
* Create a sink instance.
* @param name Name of the audio stream.
* @param index Index of the sink in the menu. Should be use to keep settings.
*/
std::unique_ptr<Sink> createSink(const std::string& name, int index); std::unique_ptr<Sink> createSink(const std::string& name, int index);
/**
* Destroy a sink instance. This function is so that the provide knows at all times how many instances there are.
* @param sink Instance of the sink.
*/
void destroySink(std::unique_ptr<Sink> sink); void destroySink(std::unique_ptr<Sink> sink);
}; };
@ -87,23 +107,37 @@ class StreamManager {
friend AudioStream; friend AudioStream;
public: public:
/** /**
* Register an audio stream. * Create an audio stream.
* @param name Name of the stream. * @param name Name of the stream.
* @param stream DSP stream that outputs the audio. * @param stream DSP stream that outputs the audio.
* @param samplerate Samplerate of the audio data. * @param samplerate Samplerate of the audio data.
* @return Audio stream instance. * @return Audio stream instance.
*/ */
std::shared_ptr<AudioStream> registerStream(const std::string& name, dsp::stream<dsp::stereo_t>* stream, double samplerate); std::shared_ptr<AudioStream> createStream(const std::string& name, dsp::stream<dsp::stereo_t>* stream, double samplerate);
/** /**
* Unregister an audio stream. * Destroy an audio stream.
* * @param name Name of the stream.
*/ */
void unregisterStream(const std::string& name); void destroyStream(const std::string& name);
/**
* Register a sink provider.
* @param name Name of the sink type.
* @param provider Sink provider instance.
*/
void registerSinkProvider(const std::string& name, SinkProvider* provider); void registerSinkProvider(const std::string& name, SinkProvider* provider);
/**
* Unregister a sink provider.
* @param name Name of the sink type.
*/
void unregisterSinkProvider(const std::string& name); void unregisterSinkProvider(const std::string& name);
/**
* Get a list of streams and their associated names.
* @return Map of names to stream instance.
*/
const std::map<std::string, std::shared_ptr<AudioStream>>& getStreams(); const std::map<std::string, std::shared_ptr<AudioStream>>& getStreams();
private: private:

View File

@ -52,7 +52,9 @@ If `libvolk2-dev` is not available, use `libvolk1-dev`.
### Arch-based ### Arch-based
Install the latest release from the [sdrpp-git](https://aur.archlinux.org/packages/sdrpp-git/) AUR package Install from source following the instructions below.
**WARNING: The sdrpp-git AUR package is no longer official, it is not recommended to use it.**
### Other ### Other