diff --git a/core/src/signal_path/stream.cpp b/core/src/signal_path/stream.cpp index f486bb23..b24ba2a9 100644 --- a/core/src/signal_path/stream.cpp +++ b/core/src/signal_path/stream.cpp @@ -73,7 +73,7 @@ int AudioStream::addSink(const std::string& type) { // Create sink instance 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 if (!sink) { @@ -82,7 +82,7 @@ int AudioStream::addSink(const std::string& type) { } // Create and save entry - sinks.push_back(SinkEntry(std::move(sink))); + sinks.push_back(std::make_shared(std::move(sink))); return id; } @@ -97,14 +97,13 @@ void AudioStream::removeSink(int index) { } // TODO: Free stuff - } -const std::vector& AudioStream::getSinks() { +const std::vector>& AudioStream::getSinks() { return sinks; } -std::shared_ptr StreamManager::registerStream(const std::string& name, dsp::stream* stream, double samplerate) { +std::shared_ptr StreamManager::createStream(const std::string& name, dsp::stream* stream, double samplerate) { std::lock_guard lck(mtx); // Check that an audio stream that name doesn't already exist @@ -117,7 +116,7 @@ std::shared_ptr StreamManager::registerStream(const std::string& na streams[name] = std::make_shared(this, stream, samplerate); } -void StreamManager::unregisterStream(const std::string& name) { +void StreamManager::destroyStream(const std::string& name) { std::lock_guard lck(mtx); // Check that stream exists diff --git a/core/src/signal_path/stream.h b/core/src/signal_path/stream.h index ba2eaeab..0b07bf88 100644 --- a/core/src/signal_path/stream.h +++ b/core/src/signal_path/stream.h @@ -24,6 +24,7 @@ private: class SinkEntry { public: SinkEntry(std::unique_ptr sink); + ~SinkEntry(); float getVolume(); void setVolume(float volume); @@ -34,6 +35,7 @@ public: float getPanning(); void setPanning(float panning); private: + dsp::stream stream; dsp::audio::Volume volumeAdjust; dsp::multirate::RationalResampler resamp; @@ -51,8 +53,16 @@ class AudioStream { public: AudioStream(StreamManager* manager, const std::string& name, dsp::stream* stream, double samplerate); + /** + * Set DSP stream input. + * @param stream DSP stream. + */ void setInput(dsp::stream* stream); + /** + * Get the name of the stream. + * @return Name of the stream. + */ const std::string& getName(); void bindStream(dsp::stream* stream); @@ -64,7 +74,7 @@ public: int addSink(const std::string& type); void setSinkType(int index, const std::string& type); void removeSink(int index); - const std::vector& getSinks(); + const std::vector>& getSinks(); private: void setSinkInputSamplerate(Sink* sink, double samplerate); @@ -74,12 +84,22 @@ private: std::string name; double samplerate; dsp::routing::Splitter split; - std::vector sinks; + std::vector> sinks; }; class SinkProvider { 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 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); }; @@ -87,23 +107,37 @@ class StreamManager { friend AudioStream; public: /** - * Register an audio stream. + * Create an audio stream. * @param name Name of the stream. * @param stream DSP stream that outputs the audio. * @param samplerate Samplerate of the audio data. * @return Audio stream instance. */ - std::shared_ptr registerStream(const std::string& name, dsp::stream* stream, double samplerate); + std::shared_ptr createStream(const std::string& name, dsp::stream* 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); + + /** + * Unregister a sink provider. + * @param name Name of the sink type. + */ 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>& getStreams(); private: diff --git a/readme.md b/readme.md index 558c1917..902d3b80 100644 --- a/readme.md +++ b/readme.md @@ -52,7 +52,9 @@ If `libvolk2-dev` is not available, use `libvolk1-dev`. ### 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