29 #include "../../include/Qt/AudioPlaybackThread.h"
65 AudioPlaybackThread::AudioPlaybackThread()
66 : Thread(
"audio-playback")
75 , time_thread(
"audio-buffer")
80 AudioPlaybackThread::~AudioPlaybackThread()
85 void AudioPlaybackThread::Reader(
ReaderBase *reader) {
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.
This abstract class is the base class, used by all readers in libopenshot.
void Seek(int64_t new_position)
Seek to a specific frame.
void Reader(ReaderBase *audio_reader)
Set Reader.
ReaderInfo info
Information about the current media file.
This class is used to expose any ReaderBase derived class as an AudioSource in JUCE.
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.
int64_t getEstimatedFrame() const
Get the estimate frame that is playing at this moment.
int sample_rate
The number of audio samples per second (44100 is a common sample rate)