20#define AUD_BUILD_PLUGIN
29#include <condition_variable>
31#include <pipewire/pipewire.h>
32#include <spa/utils/ringbuffer.h>
46 PipeWireDevice* m_device;
47 bool m_playing =
false;
48 bool m_get_tick_start =
false;
49 int64_t m_tick_start = 0.0f;
50 double m_seek_pos = 0.0f;
53 PipeWireSynchronizer(PipeWireDevice* device);
55 void updateTickStart();
58 virtual void seek(std::shared_ptr<IHandle> handle,
double time);
59 virtual double getPosition(std::shared_ptr<IHandle> handle);
63 PipeWireSynchronizer m_synchronizer;
68 bool m_fill_ringbuffer;
71 pw_thread_loop* m_thread;
72 std::unique_ptr<pw_stream_events> m_events;
77 std::thread m_mixingThread;
78 bool m_run_mixing_thread;
83 std::mutex m_mixingLock;
88 spa_ringbuffer m_ringbuffer;
90 std::condition_variable m_mixingCondition;
92 AUD_LOCAL static void handleStateChanged(
void* device_ptr,
enum pw_stream_state old,
enum pw_stream_state state,
const char* error);
103 AUD_LOCAL static void mixAudioBuffer(
void* device_ptr);
106 PipeWireDevice(
const PipeWireDevice&) =
delete;
107 PipeWireDevice& operator=(
const PipeWireDevice&) =
delete;
#define AUD_DEFAULT_BUFFER_SIZE
The default playback buffer size of a device.
Definition Audaspace.h:103
#define AUD_NAMESPACE_END
Closes the audaspace namespace aud.
Definition Audaspace.h:119
#define AUD_LOCAL
Used for hiding symbols from export in the shared library.
Definition Audaspace.h:80
#define AUD_NAMESPACE_BEGIN
Opens the audaspace namespace aud.
Definition Audaspace.h:116
#define AUD_PLUGIN_API
Used for exporting symbols in the shared library.
Definition Audaspace.h:94
The SoftwareDevice class.
This class is a simple buffer in RAM which is 32 Byte aligned and provides resize functionality.
Definition Buffer.h:34
This class is a default ISynchronizer implementation that actually does no synchronization and is int...
Definition DefaultSynchronizer.h:34
This class enables global synchronization of several audio applications if supported.
Definition ISynchronizer.h:39
PipeWireDevice(const std::string &name, DeviceSpecs specs, int buffersize=AUD_DEFAULT_BUFFER_SIZE)
Opens the PipeWire audio device for playback.
static void registerPlugin()
Registers this plugin.
virtual ~PipeWireDevice()
Closes the PipeWire audio device.
virtual void playing(bool playing)
This function tells the device, to start or pause playback.
virtual ISynchronizer * getSynchronizer()
Retrieves the synchronizer for this device, which enables accurate synchronization between audio play...
virtual std::shared_ptr< IHandle > play(std::shared_ptr< IReader > reader, bool keep=false)
Plays a sound source.
SoftwareDevice()
Empty default constructor.
Specification of a sound device.
Definition Specification.h:129