libpromeki 1.0.0-alpha
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
sdlaudiooutput.h
Go to the documentation of this file.
1
8#pragma once
9
10#include <promeki/namespace.h>
11#include <promeki/objectbase.h>
12#include <promeki/clock.h>
13#include <promeki/clockdomain.h>
14#include <promeki/audiodesc.h>
16
17struct SDL_AudioStream;
18
19PROMEKI_NAMESPACE_BEGIN
20
64class SDLAudioOutput : public ObjectBase {
65 PROMEKI_OBJECT(SDLAudioOutput, ObjectBase)
66 public:
68 explicit SDLAudioOutput(ObjectBase *parent = nullptr);
69
70 ~SDLAudioOutput() override;
71
82 bool configure(const AudioDesc &desc);
83
94 bool open();
95
99 void close();
100
104 bool isOpen() const { return _open; }
105
115 bool pushAudio(const PcmAudioPayload &payload);
116
127 virtual int queuedBytes() const;
128
132 const AudioDesc &desc() const { return _desc; }
133
146 virtual int64_t totalBytesPushed() const { return _totalBytesPushed; }
147
158 virtual ClockDomain clockDomain() const { return _clockDomain; }
159
174 virtual Error setPaused(bool paused);
175
181 virtual bool isPaused() const;
182
197 Clock *createClock();
198
199 private:
200 SDL_AudioStream *_stream = nullptr;
201 AudioDesc _desc;
202 ClockDomain _clockDomain;
203 bool _configured = false;
204 bool _open = false;
205 int64_t _totalBytesPushed = 0;
206};
207
208PROMEKI_NAMESPACE_END
Manages an SDL3 audio output device for playback.
Definition sdlaudiooutput.h:64
virtual bool isPaused() const
Returns the current pause state.
Clock * createClock()
Returns a Clock whose time is driven by this output's consumed-byte counter.
bool isOpen() const
Returns true if the device is open and playing.
Definition sdlaudiooutput.h:104
SDLAudioOutput(ObjectBase *parent=nullptr)
Constructs an SDLAudioOutput.
virtual ClockDomain clockDomain() const
Returns the ClockDomain registered for the open SDL device.
Definition sdlaudiooutput.h:158
bool pushAudio(const PcmAudioPayload &payload)
Pushes uncompressed audio samples to the output stream.
virtual Error setPaused(bool paused)
Pauses or resumes the underlying SDL audio device.
bool open()
Opens the SDL audio device and starts playback.
virtual int64_t totalBytesPushed() const
Returns total float32 bytes pushed since open.
Definition sdlaudiooutput.h:146
void close()
Closes the audio device and frees resources.
const AudioDesc & desc() const
Returns the configured audio descriptor.
Definition sdlaudiooutput.h:132
virtual int queuedBytes() const
Returns the number of bytes currently queued.
bool configure(const AudioDesc &desc)
Configures the audio output format.