OpenShot Library | libopenshot
1.1.1
Toggle main menu visibility
Loading...
Searching...
No Matches
AudioPlaybackThread.h
Go to the documentation of this file.
1
9
10
// Copyright (c) 2008-2019 OpenShot Studios, LLC
11
//
12
// SPDX-License-Identifier: LGPL-3.0-or-later
13
14
#ifndef OPENSHOT_AUDIO_PLAYBACK_THREAD_H
15
#define OPENSHOT_AUDIO_PLAYBACK_THREAD_H
16
17
#include "
ReaderBase.h
"
18
#include "
RendererBase.h
"
19
#include "
AudioReaderSource.h
"
20
#include "
AudioDevices.h
"
21
#include "
AudioReaderSource.h
"
22
#include "
Qt/VideoCacheThread.h
"
23
24
#include <OpenShotAudio.h>
25
#include <AppConfig.h>
26
#include <juce_audio_basics/juce_audio_basics.h>
27
#include <juce_audio_devices/juce_audio_devices.h>
28
29
namespace
openshot
30
{
31
32
// Forward decls
33
class
ReaderBase
;
34
class
Frame
;
35
class
PlayerPrivate
;
36
class
QtPlayer
;
37
38
42
class
AudioDeviceManagerSingleton {
43
private
:
45
AudioDeviceManagerSingleton(){
initialise_error
=
""
; };
46
48
static
AudioDeviceManagerSingleton* m_pInstance;
49
50
public
:
52
std::string
initialise_error
;
53
55
double
defaultSampleRate
;
56
58
AudioDeviceInfo
currentAudioDevice
;
59
61
static
AudioDeviceManagerSingleton*
Instance
();
62
65
static
AudioDeviceManagerSingleton*
Instance
(
int
rate,
int
channels);
66
68
juce::AudioDeviceManager
audioDeviceManager
;
69
71
void
CloseAudioDevice
();
72
};
73
77
class
AudioPlaybackThread : juce::Thread
78
{
79
juce::AudioSourcePlayer player;
80
juce::AudioTransportSource transport;
81
juce::MixerAudioSource mixer;
82
AudioReaderSource
*source;
83
double
sampleRate;
84
int
numChannels;
85
juce::WaitableEvent play;
86
std::atomic<bool> is_playing;
87
juce::TimeSliceThread time_thread;
88
openshot::VideoCacheThread
*videoCache;
89
std::mutex transportMutex;
90
std::condition_variable transportCondition;
91
93
AudioPlaybackThread(
openshot::VideoCacheThread
* cache);
95
~AudioPlaybackThread();
96
98
void
NotifyTransportStateChanged();
99
101
void
Reader(
openshot::ReaderBase
*reader);
102
104
std::shared_ptr<openshot::Frame> getFrame();
105
107
void
Play();
108
110
void
Seek(int64_t new_position);
111
113
void
Stop();
114
116
void
run();
117
119
void
setSpeed(
int
new_speed) {
if
(source) source->setSpeed(new_speed); }
120
122
int
getSpeed()
const
{
if
(source)
return
source->getSpeed();
else
return
1; }
123
125
std::string getError()
126
{
127
return
AudioDeviceManagerSingleton::Instance
()->
initialise_error
;
128
}
129
131
double
getDefaultSampleRate()
132
{
133
return
AudioDeviceManagerSingleton::Instance
()->
defaultSampleRate
;
134
}
135
137
AudioDeviceInfo
getCurrentAudioDevice()
138
{
139
return
AudioDeviceManagerSingleton::Instance
()->
currentAudioDevice
;
140
}
141
143
AudioDeviceList
getAudioDeviceNames()
144
{
145
AudioDevices
devs;
146
return
devs.
getNames
();
147
};
148
149
friend
struct
AudioPlaybackThreadTestAccess
;
150
friend
class
PlayerPrivate
;
151
friend
class
QtPlayer
;
152
};
153
154
}
// namespace openshot
155
156
#endif
// OPENSHOT_AUDIO_PLAYBACK_THREAD_H
AudioDevices.h
Header file for Audio Device Info struct.
AudioReaderSource.h
Header file for AudioReaderSource class.
ReaderBase.h
Header file for ReaderBase class.
RendererBase.h
Header file for RendererBase class.
VideoCacheThread.h
Header file for VideoCacheThread class.
openshot::AudioDeviceManagerSingleton::defaultSampleRate
double defaultSampleRate
Default sample rate (as detected).
Definition
AudioPlaybackThread.h:55
openshot::AudioDeviceManagerSingleton::CloseAudioDevice
void CloseAudioDevice()
Close audio device.
Definition
AudioPlaybackThread.cpp:178
openshot::AudioDeviceManagerSingleton::Instance
static AudioDeviceManagerSingleton * Instance()
Override with default sample rate & channels (44100, 2) and no preferred audio device.
Definition
AudioPlaybackThread.cpp:39
openshot::AudioDeviceManagerSingleton::audioDeviceManager
juce::AudioDeviceManager audioDeviceManager
Public device manager property.
Definition
AudioPlaybackThread.h:68
openshot::AudioDeviceManagerSingleton::currentAudioDevice
AudioDeviceInfo currentAudioDevice
Current open audio device (or last attempted device - if none were successful).
Definition
AudioPlaybackThread.h:58
openshot::AudioDeviceManagerSingleton::initialise_error
std::string initialise_error
Error found during JUCE initialise method.
Definition
AudioPlaybackThread.h:52
openshot::AudioDevices
A class which probes the available audio devices.
Definition
AudioDevices.h:46
openshot::AudioDevices::getNames
AudioDeviceList getNames()
Definition
AudioDevices.cpp:21
openshot::AudioPlaybackThread::QtPlayer
friend class QtPlayer
Definition
AudioPlaybackThread.h:151
openshot::AudioPlaybackThread::AudioPlaybackThreadTestAccess
friend struct AudioPlaybackThreadTestAccess
Definition
AudioPlaybackThread.h:149
openshot::AudioPlaybackThread::PlayerPrivate
friend class PlayerPrivate
Definition
AudioPlaybackThread.h:150
openshot::AudioReaderSource
This class is used to expose any ReaderBase derived class as an AudioSource in JUCE.
Definition
AudioReaderSource.h:35
openshot::Frame
This class represents a single frame of video (i.e. image & audio data).
Definition
Frame.h:90
openshot::PlayerPrivate
The private part of QtPlayer class, which contains an audio thread and video thread,...
Definition
PlayerPrivate.h:33
openshot::QtPlayer
This class is used to playback a video from a reader.
Definition
QtPlayer.h:36
openshot::ReaderBase
This abstract class is the base class, used by all readers in libopenshot.
Definition
ReaderBase.h:76
openshot::VideoCacheThread
Handles prefetching and caching of video/audio frames for smooth playback.
Definition
VideoCacheThread.h:39
openshot
This namespace is the default namespace for all code in the openshot library.
Definition
AnimatedCurve.h:24
openshot::AudioDeviceList
std::vector< std::pair< std::string, std::string > > AudioDeviceList
Definition
AudioDevices.h:42
openshot::AudioDeviceInfo
This struct hold information about Audio Devices.
Definition
AudioDevices.h:27
Qt
AudioPlaybackThread.h
Generated by
1.17.0