MPD
0.20.15
|
#include <DecoderControl.hxx>
Public Member Functions | |
DecoderControl (Mutex &_mutex, Cond &_client_cond, const AudioFormat _configured_audio_format, const ReplayGainConfig &_replay_gain_config) | |
~DecoderControl () | |
void | Lock () const |
Locks the object. More... | |
void | Unlock () const |
Unlocks the object. More... | |
void | Signal () |
Signals the object. More... | |
void | Wait () |
Waits for a signal on the DecoderControl object. More... | |
void | WaitForDecoder () |
Waits for a signal from the decoder thread. More... | |
bool | IsIdle () const |
gcc_pure bool | LockIsIdle () const noexcept |
bool | IsStarting () const noexcept |
gcc_pure bool | LockIsStarting () const noexcept |
bool | HasFailed () const noexcept |
gcc_pure bool | LockHasFailed () const noexcept |
void | SetReady (const AudioFormat audio_format, bool _seekable, SignedSongTime _duration) |
Transition this obejct from DecoderState::START to DecoderState::DECODE. More... | |
void | CheckRethrowError () const |
Checks whether an error has occurred, and if so, rethrows it. More... | |
void | LockCheckRethrowError () const |
Like CheckRethrowError(), but locks and unlocks the object. More... | |
void | ClearError () |
Clear the error condition and free the #Error object (if any). More... | |
gcc_pure bool | IsCurrentSong (const DetachedSong &_song) const noexcept |
Check if the specified song is currently being decoded. More... | |
gcc_pure bool | LockIsCurrentSong (const DetachedSong &_song) const noexcept |
void | CommandFinishedLocked () |
Marks the current command as "finished" and notifies the client (= player thread). More... | |
void | Start (DetachedSong *song, SongTime start_time, SongTime end_time, MusicBuffer &buffer, MusicPipe &pipe) |
Start the decoder. More... | |
void | Stop () |
void | Seek (SongTime t) |
Throws #std::runtime_error on error. More... | |
void | Quit () |
const char * | GetMixRampStart () const |
const char * | GetMixRampEnd () const |
const char * | GetMixRampPreviousEnd () const |
void | SetMixRamp (MixRampInfo &&new_value) |
void | CycleMixRamp () |
Move mixramp_end to mixramp_prev_end and clear mixramp_start/mixramp_end. More... | |
Data Fields | |
Thread | thread |
The handle of the decoder thread. More... | |
Mutex & | mutex |
This lock protects state and command. More... | |
Cond | cond |
Trigger this object after you have modified command. More... | |
Cond & | client_cond |
The trigger of this object's client. More... | |
DecoderState | state = DecoderState::STOP |
DecoderCommand | command = DecoderCommand::NONE |
std::exception_ptr | error |
The error that occurred in the decoder thread. More... | |
bool | quit |
bool | client_is_waiting = false |
Is the client currently waiting for the DecoderThread? If false, the DecoderThread may omit invoking Cond::signal(), reducing the number of system calls. More... | |
bool | seek_error |
bool | seekable |
SongTime | seek_time |
const AudioFormat | configured_audio_format |
The "audio_output_format" setting. More... | |
AudioFormat | in_audio_format |
the format of the song file More... | |
AudioFormat | out_audio_format |
the format being sent to the music pipe More... | |
DetachedSong * | song = nullptr |
The song currently being decoded. More... | |
SongTime | start_time |
The initial seek position, e.g. More... | |
SongTime | end_time |
The decoder will stop when it reaches this position. More... | |
SignedSongTime | total_time |
MusicBuffer * | buffer |
the MusicChunk allocator More... | |
MusicPipe * | pipe |
The destination pipe for decoded chunks. More... | |
const ReplayGainConfig | replay_gain_config |
ReplayGainMode | replay_gain_mode = ReplayGainMode::OFF |
float | replay_gain_db = 0 |
float | replay_gain_prev_db = 0 |
MixRampInfo | mix_ramp |
MixRampInfo | previous_mix_ramp |
Definition at line 63 of file DecoderControl.hxx.
DecoderControl::DecoderControl | ( | Mutex & | _mutex, |
Cond & | _client_cond, | ||
const AudioFormat | _configured_audio_format, | ||
const ReplayGainConfig & | _replay_gain_config | ||
) |
_mutex | see mutex |
_client_cond | see client_cond |
DecoderControl::~DecoderControl | ( | ) |
|
inline |
Checks whether an error has occurred, and if so, rethrows it.
Caller must lock the object.
Definition at line 272 of file DecoderControl.hxx.
|
inline |
Clear the error condition and free the #Error object (if any).
Caller must lock the object.
Definition at line 293 of file DecoderControl.hxx.
|
inline |
Marks the current command as "finished" and notifies the client (= player thread).
To be called from the decoder thread. Caller must lock the mutex.
Definition at line 368 of file DecoderControl.hxx.
void DecoderControl::CycleMixRamp | ( | ) |
Move mixramp_end to mixramp_prev_end and clear mixramp_start/mixramp_end.
|
inline |
Definition at line 401 of file DecoderControl.hxx.
|
inline |
Definition at line 405 of file DecoderControl.hxx.
|
inline |
Definition at line 397 of file DecoderControl.hxx.
|
inlinenoexcept |
Definition at line 245 of file DecoderControl.hxx.
|
noexcept |
Check if the specified song is currently being decoded.
If the decoder is not running currently (or being started), then this function returns false in any case.
Caller must lock the object.
|
inline |
Definition at line 224 of file DecoderControl.hxx.
|
inlinenoexcept |
Definition at line 235 of file DecoderControl.hxx.
|
inline |
Locks the object.
Definition at line 186 of file DecoderControl.hxx.
|
inline |
Like CheckRethrowError(), but locks and unlocks the object.
Definition at line 283 of file DecoderControl.hxx.
|
inlinenoexcept |
Definition at line 252 of file DecoderControl.hxx.
|
inlinenoexcept |
Definition at line 311 of file DecoderControl.hxx.
|
inlinenoexcept |
Definition at line 230 of file DecoderControl.hxx.
|
inlinenoexcept |
Definition at line 240 of file DecoderControl.hxx.
void DecoderControl::Quit | ( | ) |
void DecoderControl::Seek | ( | SongTime | t | ) |
Throws #std::runtime_error on error.
|
inline |
Definition at line 409 of file DecoderControl.hxx.
void DecoderControl::SetReady | ( | const AudioFormat | audio_format, |
bool | _seekable, | ||
SignedSongTime | _duration | ||
) |
Transition this obejct from DecoderState::START to DecoderState::DECODE.
Caller must lock the object.
|
inline |
Signals the object.
This function is only valid in the player thread. The object should be locked prior to calling this function.
Definition at line 202 of file DecoderControl.hxx.
void DecoderControl::Start | ( | DetachedSong * | song, |
SongTime | start_time, | ||
SongTime | end_time, | ||
MusicBuffer & | buffer, | ||
MusicPipe & | pipe | ||
) |
Start the decoder.
song | the song to be decoded; the given instance will be owned and freed by the decoder |
start_time | see DecoderControl |
end_time | see DecoderControl |
pipe | the pipe which receives the decoded chunks (owned by the caller) |
void DecoderControl::Stop | ( | ) |
|
inline |
Unlocks the object.
Definition at line 193 of file DecoderControl.hxx.
|
inline |
Waits for a signal on the DecoderControl object.
This function is only valid in the decoder thread. The object must be locked prior to calling this function.
Definition at line 211 of file DecoderControl.hxx.
void DecoderControl::WaitForDecoder | ( | ) |
Waits for a signal from the decoder thread.
This object must be locked prior to calling this function. This method is only valid in the player thread.
Caller must hold the lock.
MusicBuffer* DecoderControl::buffer |
the MusicChunk allocator
Definition at line 158 of file DecoderControl.hxx.
Cond& DecoderControl::client_cond |
The trigger of this object's client.
It is signalled whenever an event occurs.
This is usually a reference to PlayerControl::cond.
Definition at line 92 of file DecoderControl.hxx.
bool DecoderControl::client_is_waiting = false |
Is the client currently waiting for the DecoderThread? If false, the DecoderThread may omit invoking Cond::signal(), reducing the number of system calls.
Definition at line 112 of file DecoderControl.hxx.
DecoderCommand DecoderControl::command = DecoderCommand::NONE |
Definition at line 95 of file DecoderControl.hxx.
Cond DecoderControl::cond |
Trigger this object after you have modified command.
This is also used by the decoder thread to notify the caller when it has finished a command.
Definition at line 84 of file DecoderControl.hxx.
const AudioFormat DecoderControl::configured_audio_format |
The "audio_output_format" setting.
Definition at line 121 of file DecoderControl.hxx.
SongTime DecoderControl::end_time |
The decoder will stop when it reaches this position.
0 means don't stop before the end of the file.
This attribute is set by Start().
Definition at line 153 of file DecoderControl.hxx.
std::exception_ptr DecoderControl::error |
The error that occurred in the decoder thread.
This attribute is only valid if state is DecoderState::ERROR. The object must be freed when this object transitions to any other state (usually DecoderState::START).
Definition at line 103 of file DecoderControl.hxx.
AudioFormat DecoderControl::in_audio_format |
the format of the song file
Definition at line 124 of file DecoderControl.hxx.
MixRampInfo DecoderControl::mix_ramp |
Definition at line 172 of file DecoderControl.hxx.
Mutex& DecoderControl::mutex |
This lock protects state and command.
This is usually a reference to PlayerControl::mutex, so that both player thread and decoder thread share a mutex. This simplifies synchronization with cond and client_cond.
Definition at line 77 of file DecoderControl.hxx.
AudioFormat DecoderControl::out_audio_format |
the format being sent to the music pipe
Definition at line 127 of file DecoderControl.hxx.
MusicPipe* DecoderControl::pipe |
The destination pipe for decoded chunks.
The caller thread owns this object, and is responsible for freeing it.
Definition at line 164 of file DecoderControl.hxx.
MixRampInfo DecoderControl::previous_mix_ramp |
Definition at line 172 of file DecoderControl.hxx.
bool DecoderControl::quit |
Definition at line 105 of file DecoderControl.hxx.
const ReplayGainConfig DecoderControl::replay_gain_config |
Definition at line 166 of file DecoderControl.hxx.
float DecoderControl::replay_gain_db = 0 |
Definition at line 169 of file DecoderControl.hxx.
ReplayGainMode DecoderControl::replay_gain_mode = ReplayGainMode::OFF |
Definition at line 167 of file DecoderControl.hxx.
float DecoderControl::replay_gain_prev_db = 0 |
Definition at line 170 of file DecoderControl.hxx.
bool DecoderControl::seek_error |
Definition at line 114 of file DecoderControl.hxx.
SongTime DecoderControl::seek_time |
Definition at line 116 of file DecoderControl.hxx.
bool DecoderControl::seekable |
Definition at line 115 of file DecoderControl.hxx.
DetachedSong* DecoderControl::song = nullptr |
The song currently being decoded.
This attribute is set by the player thread, when it sends the DecoderCommand::START command.
This is a duplicate, and must be freed when this attribute is cleared.
Definition at line 137 of file DecoderControl.hxx.
SongTime DecoderControl::start_time |
The initial seek position, e.g.
to the start of a sub-track described by a CUE file.
This attribute is set by Start().
Definition at line 145 of file DecoderControl.hxx.
DecoderState DecoderControl::state = DecoderState::STOP |
Definition at line 94 of file DecoderControl.hxx.
Thread DecoderControl::thread |
The handle of the decoder thread.
Definition at line 67 of file DecoderControl.hxx.
SignedSongTime DecoderControl::total_time |
Definition at line 155 of file DecoderControl.hxx.