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()
116 source->Reader(reader);
120 source->setLooping(
true);
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()
144 return source ? source->getEstimatedFrame() : 0;
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);
static AudioDeviceManagerSingleton * Instance()
Override with no channels and no preferred audio device.
void CloseAudioDevice()
Close audio device.
AudioDeviceManager audioDeviceManager
Public device manager property.
This abstract class is the base class, used by all readers in libopenshot.
std::string initialise_error
Error found during JUCE initialise method.
std::vector< openshot::AudioDeviceInfo > audio_device_names
List of valid audio device names.
openshot::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 Settings * Instance()
Create or get an instance of this logger 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)