41 AudioDeviceManagerSingleton *AudioDeviceManagerSingleton::m_pInstance = NULL;
51 juce::String preferred_audio_device = juce::String(
Settings::Instance()->PLAYBACK_AUDIO_DEVICE_NAME.c_str());
59 preferred_audio_device );
62 if (audio_error.isNotEmpty()) {
69 for (
int i = 0; i < m_pInstance->
audioDeviceManager.getAvailableDeviceTypes().size(); ++i)
71 const AudioIODeviceType* t = m_pInstance->
audioDeviceManager.getAvailableDeviceTypes()[i];
72 const juce::StringArray deviceNames = t->getDeviceNames ();
74 for (
int j = 0; j < deviceNames.size (); ++j )
76 juce::String deviceName = deviceNames[j];
77 juce::String typeName = t->getTypeName();
97 AudioPlaybackThread::AudioPlaybackThread()
98 : juce::Thread(
"audio-playback")
107 , time_thread(
"audio-buffer")
112 AudioPlaybackThread::~AudioPlaybackThread()
119 source->Reader(reader);
123 source->setLooping(
true);
138 std::shared_ptr<openshot::Frame> AudioPlaybackThread::getFrame()
140 if (source)
return source->getFrame();
141 return std::shared_ptr<openshot::Frame>();
145 int64_t AudioPlaybackThread::getCurrentFramePosition()
147 return source ? source->getEstimatedFrame() : 0;
151 void AudioPlaybackThread::Seek(int64_t new_position)
153 source->Seek(new_position);
157 void AudioPlaybackThread::Play() {
163 void AudioPlaybackThread::Stop() {
169 void AudioPlaybackThread::run()
171 while (!threadShouldExit())
173 if (source && !transport.isPlaying() && is_playing) {
180 time_thread.startThread();
189 transport.setPosition(0);
190 transport.setGain(1.0);
193 mixer.addInputSource(&transport,
false);
194 player.setSource(&mixer);
199 while (!threadShouldExit() && transport.isPlaying() && is_playing)
200 std::this_thread::sleep_for(std::chrono::milliseconds(2));
207 transport.setSource(NULL);
209 player.setSource(NULL);
217 time_thread.stopThread(-1);
static AudioDeviceManagerSingleton * Instance()
Override with no channels and no preferred audio device.
juce::AudioDeviceManager audioDeviceManager
Public device manager property.
void CloseAudioDevice()
Close audio device.
This abstract class is the base class, used by all readers in libopenshot.
Source file for AudioPlaybackThread class.
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)