29 #include "../../include/Qt/AudioPlaybackThread.h"
35 AudioDeviceManagerSingleton *AudioDeviceManagerSingleton::m_pInstance = NULL;
65 AudioPlaybackThread::AudioPlaybackThread()
66 : Thread(
"audio-playback")
75 , time_thread(
"audio-buffer")
80 AudioPlaybackThread::~AudioPlaybackThread()
85 void AudioPlaybackThread::Reader(ReaderBase *reader) {
90 source =
new AudioReaderSource(reader, 1, buffer_size);
95 sampleRate = reader->info.sample_rate;
96 numChannels = reader->info.channels;
106 std::shared_ptr<Frame> AudioPlaybackThread::getFrame()
108 if (source)
return source->
getFrame();
109 return std::shared_ptr<Frame>();
113 int64_t AudioPlaybackThread::getCurrentFramePosition()
119 void AudioPlaybackThread::Seek(int64_t new_position)
121 source->
Seek(new_position);
125 void AudioPlaybackThread::Play() {
131 void AudioPlaybackThread::Stop() {
137 void AudioPlaybackThread::run()
139 while (!threadShouldExit())
141 if (source && !transport.isPlaying() && is_playing) {
148 time_thread.startThread();
157 transport.setPosition(0);
158 transport.setGain(1.0);
161 mixer.addInputSource(&transport,
false);
162 player.setSource(&mixer);
167 while (!threadShouldExit() && transport.isPlaying() && is_playing)
175 transport.setSource(NULL);
177 player.setSource(NULL);
185 time_thread.stopThread(-1);
void CloseAudioDevice()
Close audio device.
std::shared_ptr< Frame > getFrame() const
Return the current frame object.
AudioDeviceManager audioDeviceManager
Public device manager property.
void setLooping(bool shouldLoop)
Set if this audio source should repeat when it reaches the end.
void Seek(int64_t new_position)
Seek to a specific frame.
void Reader(ReaderBase *audio_reader)
Set Reader.
Singleton wrapper for AudioDeviceManager (to prevent multiple instances).
static AudioDeviceManagerSingleton * Instance(int numChannels)
Create or get an instance of this singleton (invoke the class with this method)
int64_t getEstimatedFrame() const
Get the estimate frame that is playing at this moment.