![]() |
Miam-Player
0.8.0
A nice music player
|
#include <AudioOutput.h>
Public Types | |
enum | DeviceFeature { NoFeature = 0, SetVolume = 1, SetMute = 1 << 1, SetSampleRate = 1 << 2 } |
DeviceFeature Feature enum features supported by the audio playback api (we call device or backend here) More... | |
Signals | |
void | volumeChanged (qreal) |
void | muteChanged (bool) |
void | deviceFeaturesChanged () |
void | backendsChanged () |
Public Member Functions | |
AudioOutput (QObject *parent=0) | |
AudioOutput Audio format set to preferred sample format and channel layout. More... | |
virtual | ~AudioOutput () |
void | setBackends (const QStringList &backendNames=QStringList()) |
setBackends set the given backends. More... | |
QStringList | backends () const |
QString | backend () const |
backend backend name currently in use More... | |
void | flush () |
flush Play the buffered audio data More... | |
void | clear () |
clear Clear audio buffers and set time to 0. More... | |
bool | open () |
bool | close () |
bool | isOpen () const |
bool | play (const QByteArray &data, qreal pts=0.0) |
play Play out the given audio data. More... | |
void | setAudioFormat (const AudioFormat &format) |
TODO: requestAudioFormat(): check support after open, use the nearest format if not supported. Or use suitableFormat(AudioFormat requestedFmt) if requestedFmt is not supported. More... | |
AudioFormat & | audioFormat () |
const AudioFormat & | audioFormat () const |
void | setSampleRate (int rate) |
int | sampleRate () const |
void | setChannels (int channels) |
int | channels () const |
void | setVolume (qreal value) |
setVolume Set volume level. More... | |
qreal | volume () const |
void | setMute (bool value=true) |
setMute If SetMute feature is not set or not supported, software implemention will be used. More... | |
bool | isMute () const |
void | setSpeed (qreal speed) |
setSpeed set audio playing speed Currently only store the value and does nothing else in audio output. More... | |
qreal | speed () const |
bool | isSupported (const AudioFormat &format) const |
isSupported check isSupported(format.sampleFormat()) and isSupported(format.channelLayout()) More... | |
bool | isSupported (AudioFormat::SampleFormat sampleFormat) const |
bool | isSupported (AudioFormat::ChannelLayout channelLayout) const |
AudioFormat::SampleFormat | preferredSampleFormat () const |
preferredSampleFormat More... | |
AudioFormat::ChannelLayout | preferredChannelLayout () const |
preferredChannelLayout More... | |
int | bufferSamples () const |
bufferSamples Number of samples that audio output accept in 1 buffer. More... | |
void | setBufferSamples (int value) |
int | bufferSize () const |
int | bufferCount () const |
bufferSamples()*bytesPerSample More... | |
void | setBufferCount (int value) |
int | bufferSizeTotal () const |
void | setDeviceFeatures (DeviceFeatures value) |
setDeviceFeatures Unsupported features will not be set. More... | |
DeviceFeatures | deviceFeatures () const |
deviceFeatures More... | |
DeviceFeatures | supportedDeviceFeatures () const |
supportedDeviceFeatures Supported features of the backend, defined by AudioOutput(DeviceFeatures,AudioOutput&,QObject*) in a backend ctor More... | |
qreal | timestamp () const |
![]() | |
AVOutput () | |
virtual | ~AVOutput () |
bool | isAvailable () const |
void | pause (bool p) |
bool | isPaused () const |
QList< Filter * > & | filters () |
bool | installFilter (Filter *filter, int index=0x7fffffff) |
installFilter Insert a filter at position 'index' of current filter list. More... | |
bool | uninstallFilter (Filter *filter) |
Static Public Member Functions | |
static QStringList | backendsAvailable () |
backendsAvailable All registered backends in default priority order More... | |
Protected Member Functions | |
bool | receiveData (const QByteArray &data, qreal pts=0.0) |
virtual bool | waitForNextBuffer () |
waitForNextBuffer wait until you can feed more data More... | |
![]() | |
AVOutput (AVOutputPrivate &d) | |
Q_DECL_DEPRECATED bool | tryPause () |
void | addOutputSet (OutputSet *set) |
void | removeOutputSet (OutputSet *set) |
void | attach (OutputSet *set) |
void | detach (OutputSet *set=0) |
void | hanlePendingTasks () |
Properties | |
qreal | volume |
bool | mute |
DeviceFeatures | deviceFeatures |
QStringList | backends |
Friends | |
class | AudioOutputBackend |
QtAV::AudioOutput::AudioOutput | ( | QObject * | parent = 0 | ) |
AudioOutput Audio format set to preferred sample format and channel layout.
|
virtual |
AudioFormat& QtAV::AudioOutput::audioFormat | ( | ) |
const AudioFormat& QtAV::AudioOutput::audioFormat | ( | ) | const |
QString QtAV::AudioOutput::backend | ( | ) | const |
backend backend name currently in use
QStringList QtAV::AudioOutput::backends | ( | ) | const |
|
static |
backendsAvailable All registered backends in default priority order
|
signal |
int QtAV::AudioOutput::bufferCount | ( | ) | const |
bufferSamples()*bytesPerSample
bufferCount Total buffer count. If it's not large enough, playing high sample rate audio may be poor. The default value is 16. TODO: depending on audio format(sample rate?) Some backends(OpenAL) are affected significantly by this property
int QtAV::AudioOutput::bufferSamples | ( | ) | const |
bufferSamples Number of samples that audio output accept in 1 buffer.
Feed the audio output this size of data every time. Smaller buffer samples gives more buffers for a given data to avoid stutter. But if it's too small, the duration of 1 buffer will be too small to play, for example 1ms. Currently the default value is 512. Some backends(OpenAL) are affected significantly by this property
int QtAV::AudioOutput::bufferSize | ( | ) | const |
|
inline |
int QtAV::AudioOutput::channels | ( | ) | const |
void QtAV::AudioOutput::clear | ( | ) |
clear Clear audio buffers and set time to 0.
The default behavior is flush and reset time
bool QtAV::AudioOutput::close | ( | ) |
DeviceFeatures QtAV::AudioOutput::deviceFeatures | ( | ) | const |
deviceFeatures
|
signal |
void QtAV::AudioOutput::flush | ( | ) |
flush Play the buffered audio data
bool QtAV::AudioOutput::isMute | ( | ) | const |
bool QtAV::AudioOutput::isOpen | ( | ) | const |
bool QtAV::AudioOutput::isSupported | ( | const AudioFormat & | format | ) | const |
isSupported check isSupported(format.sampleFormat()) and isSupported(format.channelLayout())
format |
bool QtAV::AudioOutput::isSupported | ( | AudioFormat::SampleFormat | sampleFormat | ) | const |
bool QtAV::AudioOutput::isSupported | ( | AudioFormat::ChannelLayout | channelLayout | ) | const |
|
signal |
bool QtAV::AudioOutput::open | ( | ) |
bool QtAV::AudioOutput::play | ( | const QByteArray & | data, |
qreal | pts = 0.0 |
||
) |
play Play out the given audio data.
It may block current thread until the data can be written to audio device for async playback backend, or until the data is completely played for blocking playback backend.
data | Audio data to play |
pts | Timestamp for this data. Useful if need A/V sync. Ignore it if only play audio |
AudioFormat::ChannelLayout QtAV::AudioOutput::preferredChannelLayout | ( | ) | const |
preferredChannelLayout
AudioFormat::SampleFormat QtAV::AudioOutput::preferredSampleFormat | ( | ) | const |
preferredSampleFormat
|
protected |
int QtAV::AudioOutput::sampleRate | ( | ) | const |
void QtAV::AudioOutput::setAudioFormat | ( | const AudioFormat & | format | ) |
TODO: requestAudioFormat(): check support after open, use the nearest format if not supported. Or use suitableFormat(AudioFormat requestedFmt) if requestedFmt is not supported.
void QtAV::AudioOutput::setBackends | ( | const QStringList & | backendNames = QStringList() | ) |
setBackends set the given backends.
Old backend instance and backend() is updated soon if backendsChanged. It is called internally with a default backend names when AudioOutput is created.
void QtAV::AudioOutput::setBufferCount | ( | int | value | ) |
void QtAV::AudioOutput::setBufferSamples | ( | int | value | ) |
void QtAV::AudioOutput::setChannels | ( | int | channels | ) |
void QtAV::AudioOutput::setDeviceFeatures | ( | DeviceFeatures | value | ) |
setDeviceFeatures Unsupported features will not be set.
You can call this in a backend ctor.
void QtAV::AudioOutput::setMute | ( | bool | value = true | ) |
setMute If SetMute feature is not set or not supported, software implemention will be used.
Call this after open(), because it will call backend api if SetMute feature is enabled
void QtAV::AudioOutput::setSampleRate | ( | int | rate | ) |
void QtAV::AudioOutput::setSpeed | ( | qreal | speed | ) |
setSpeed set audio playing speed Currently only store the value and does nothing else in audio output.
You may change sample rate to get the same effect. The speed affects the playing only if audio is available and clock type is audio clock. For example, play a video contains audio without special configurations. To change the playing speed in other cases, use AVPlayer::setSpeed(qreal)
speed | linear. > 0 TODO: resample internally |
void QtAV::AudioOutput::setVolume | ( | qreal | value | ) |
setVolume Set volume level.
If SetVolume feature is not set or not supported, software implemention will be used. Call this after open(), because it will call backend api if SetVolume feature is enabled
volume | linear. 1.0: original volume. |
qreal QtAV::AudioOutput::speed | ( | ) | const |
DeviceFeatures QtAV::AudioOutput::supportedDeviceFeatures | ( | ) | const |
supportedDeviceFeatures Supported features of the backend, defined by AudioOutput(DeviceFeatures,AudioOutput&,QObject*) in a backend ctor
qreal QtAV::AudioOutput::timestamp | ( | ) | const |
qreal QtAV::AudioOutput::volume | ( | ) | const |
|
signal |
|
protectedvirtual |
waitForNextBuffer wait until you can feed more data
|
friend |
|
readwrite |
|
readwrite |
|
readwrite |
|
readwrite |