32 #include "../../include/Qt/AudioPlaybackThread.h"
38 AudioDeviceManagerSingleton *AudioDeviceManagerSingleton::m_pInstance = NULL;
48 juce::String preferred_audio_device = juce::String(
Settings::Instance()->PLAYBACK_AUDIO_DEVICE_NAME.c_str());
56 preferred_audio_device );
59 if (audio_error.isNotEmpty()) {
66 for (
int i = 0; i < m_pInstance->
audioDeviceManager.getAvailableDeviceTypes().size(); ++i)
68 const AudioIODeviceType* t = m_pInstance->
audioDeviceManager.getAvailableDeviceTypes()[i];
69 const juce::StringArray deviceNames = t->getDeviceNames ();
71 for (
int j = 0; j < deviceNames.size (); ++j )
73 juce::String deviceName = deviceNames[j];
74 juce::String typeName = t->getTypeName();
94 AudioPlaybackThread::AudioPlaybackThread()
95 : juce::Thread(
"audio-playback")
104 , time_thread(
"audio-buffer")
109 AudioPlaybackThread::~AudioPlaybackThread()
119 source =
new AudioReaderSource(reader, 1, buffer_size);
135 std::shared_ptr<openshot::Frame> AudioPlaybackThread::getFrame()
137 if (source)
return source->
getFrame();
138 return std::shared_ptr<openshot::Frame>();
142 int64_t AudioPlaybackThread::getCurrentFramePosition()
148 void AudioPlaybackThread::Seek(int64_t new_position)
150 source->
Seek(new_position);
154 void AudioPlaybackThread::Play() {
160 void AudioPlaybackThread::Stop() {
166 void AudioPlaybackThread::run()
168 while (!threadShouldExit())
170 if (source && !transport.isPlaying() && is_playing) {
177 time_thread.startThread();
186 transport.setPosition(0);
187 transport.setGain(1.0);
190 mixer.addInputSource(&transport,
false);
191 player.setSource(&mixer);
196 while (!threadShouldExit() && transport.isPlaying() && is_playing)
204 transport.setSource(NULL);
206 player.setSource(NULL);
214 time_thread.stopThread(-1);
Singleton wrapper for AudioDeviceManager (to prevent multiple instances).
AudioDeviceManager audioDeviceManager
Public device manager property.
void CloseAudioDevice()
Close audio device.
std::vector< openshot::AudioDeviceInfo > audio_device_names
List of valid audio device names.
static AudioDeviceManagerSingleton * Instance()
Override with no channels and no preferred audio device.
std::string initialise_error
Error found during JUCE initialise method.
void Seek(int64_t new_position)
Seek to a specific frame.
int64_t getEstimatedFrame() const
Get the estimate frame that is playing at this moment.
void Reader(ReaderBase *audio_reader)
Set Reader.
std::shared_ptr< Frame > getFrame() const
Return the current frame object.
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.
openshot::ReaderInfo info
Information about the current media file.
static Settings * Instance()
Create or get an instance of this logger singleton (invoke the class with this method)
This namespace is the default namespace for all code in the openshot library.
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)