29 #include "../../include/Qt/AudioPlaybackThread.h"
34 AudioPlaybackThread::AudioPlaybackThread()
35 : Thread(
"audio-playback")
36 , audioDeviceManager()
45 , time_thread(
"audio-buffer")
50 AudioPlaybackThread::~AudioPlaybackThread()
55 void AudioPlaybackThread::Reader(ReaderBase *reader) {
60 source =
new AudioReaderSource(reader, 1, buffer_size);
65 sampleRate = reader->info.sample_rate;
66 numChannels = reader->info.channels;
76 tr1::shared_ptr<Frame> AudioPlaybackThread::getFrame()
78 if (source)
return source->
getFrame();
79 return tr1::shared_ptr<Frame>();
83 int AudioPlaybackThread::getCurrentFramePosition()
89 void AudioPlaybackThread::Seek(
int new_position)
91 source->
Seek(new_position);
95 void AudioPlaybackThread::Play() {
101 void AudioPlaybackThread::Stop() {
107 void AudioPlaybackThread::run()
109 while (!threadShouldExit())
111 if (source && !transport.isPlaying() && is_playing) {
115 audioDeviceManager.initialise (
122 audioDeviceManager.addAudioCallback(&player);
125 time_thread.startThread();
134 transport.setPosition(0);
135 transport.setGain(1.0);
138 mixer.addInputSource(&transport,
false);
139 player.setSource(&mixer);
144 while (!threadShouldExit() && transport.isPlaying() && is_playing)
153 transport.setSource(NULL);
155 player.setSource(NULL);
156 audioDeviceManager.removeAudioCallback(&player);
157 audioDeviceManager.closeAudioDevice();
158 audioDeviceManager.removeAllChangeListeners();
159 audioDeviceManager.dispatchPendingMessages();
166 time_thread.stopThread(-1);
int getEstimatedFrame() const
Get the estimate frame that is playing at this moment.
void setLooping(bool shouldLoop)
Set if this audio source should repeat when it reaches the end.
void Reader(ReaderBase *audio_reader)
Set Reader.
tr1::shared_ptr< Frame > getFrame() const
Return the current frame object.
void Seek(int64 new_position)
Seek to a specific frame.