#ifndef PIPEMINI_H #define PIPEMINI_H #include #include #include #include // Simple PipeWire audio output interface. // Calls a user-provided callback once per sample at the configured sample rate. // The callback writes one 16-bit stereo sample (left, right). class PipeMini { public: using Callback = std::function; PipeMini(); ~PipeMini(); // Start the stream with the given callback. // sample_rate is typically 48000. bool start(const Callback& cb, int sample_rate = 48000); void stop(); public: static void on_process(void* userdata); void teardown(); private: pw_main_loop* loop_ = nullptr; pw_stream* stream_ = nullptr; pw_core* core_ = nullptr; pw_context* context_ = nullptr; spa_hook stream_listener_ = {}; Callback callback_; int sample_rate_ = 48000; bool running_ = false; struct PipeMiniData* data_ = nullptr; }; #endif // PIPEMINI_H