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) {
87 source->Reader(reader);
91 source->setLooping(
true);
106 std::shared_ptr<Frame> AudioPlaybackThread::getFrame()
108 if (source)
return source->getFrame();
109 return std::shared_ptr<Frame>();
113 int64_t AudioPlaybackThread::getCurrentFramePosition()
115 return source ? source->getEstimatedFrame() : 0;
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)
176 transport.setSource(NULL);
178 player.setSource(NULL);
186 time_thread.stopThread(-1);
void CloseAudioDevice()
Close audio device.
AudioDeviceManager audioDeviceManager
Public device manager property.
This abstract class is the base class, used by all readers in libopenshot.
ReaderInfo info
Information about the current media file.
This class is used to expose any ReaderBase derived class as an AudioSource in JUCE.
This namespace is the default namespace for all code in the openshot library.
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)
int channels
The number of audio channels used in the audio stream.
int sample_rate
The number of audio samples per second (44100 is a common sample rate)