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()
122 source =
new AudioReaderSource(reader, 1, buffer_size);
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()
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);
Source file for AudioPlaybackThread class.
Singleton wrapper for AudioDeviceManager (to prevent multiple instances).
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.
juce::AudioDeviceManager audioDeviceManager
Public device manager property.
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)