#pragma once #include #include #include #include #include #include #include class SinkManager { public: SinkManager(); class Sink { public: virtual void menuHandler() = 0; }; class Stream { public: Stream(dsp::stream* in, const Event::EventHandler& srChangeHandler, float sampleRate); void setInput(dsp::stream* in); dsp::stream* bindStream(); void unbindStream(dsp::stream* stream); friend SinkManager; friend SinkManager::Sink; Event srChange; private: void setSampleRate(float sampleRate); dsp::stream* _in; dsp::Splitter splitter; SinkManager::Sink* sink; std::mutex ctrlMtx; float _sampleRate; }; struct SinkProvider { SinkManager::Sink* (*create)(SinkManager::Stream* stream, void* ctx); void* ctx; }; void registerSinkProvider(std::string name, SinkProvider provider); void registerStream(std::string name, Stream* stream); void unregisterStream(std::string name); dsp::stream* bindStream(std::string name); void unbindStream(std::string name, dsp::stream* stream); void showMenu(); private: // TODO: Replace with std::unordered_map std::map providers; std::map streams; };