MPD 0.20.6

- Main Page
- Namespaces
- Data Structures
- Files

- Data Structures
- Class Hierarchy
- Data Fields

Public Member Functions | Data Fields
DecoderControl Struct Reference

`#include <DecoderControl.hxx>`

Collaboration diagram for DecoderControl:
[legend]

## 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
bool | IsStarting () const
gcc_pure bool | LockIsStarting () const
bool | HasFailed () const
gcc_pure bool | LockHasFailed () const
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
| Check if the specified song is currently being decoded. More...
gcc_pure bool | LockIsCurrentSong (const DetachedSong &_song) const
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

## Detailed Description

Definition at line 63 of file DecoderControl.hxx.

## Constructor & Destructor Documentation

DecoderControl::DecoderControl | ( | Mutex & | _mutex,
|  | Cond & | _client_cond,
|  | const AudioFormat | _configured_audio_format,
|  | const ReplayGainConfig & | _replay_gain_config
| ) |  |

Parameters

  _mutex | see mutex
  _client_cond | see client_cond

DecoderControl::~DecoderControl | ( |  | ) |

## Member Function Documentation

void DecoderControl::CheckRethrowError | ( |  | ) | const
| 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.

void DecoderControl::ClearError | ( |  | ) |
| 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.

void DecoderControl::CommandFinishedLocked | ( |  | ) |
| 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.

const char* DecoderControl::GetMixRampEnd | ( |  | ) | const
| inline

Definition at line 401 of file DecoderControl.hxx.

const char* DecoderControl::GetMixRampPreviousEnd | ( |  | ) | const
| inline

Definition at line 405 of file DecoderControl.hxx.

const char* DecoderControl::GetMixRampStart | ( |  | ) | const
| inline

Definition at line 397 of file DecoderControl.hxx.

bool DecoderControl::HasFailed | ( |  | ) | const
| inline

Definition at line 245 of file DecoderControl.hxx.

gcc_pure bool DecoderControl::IsCurrentSong | ( | const DetachedSong & | _song | ) | const

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.

bool DecoderControl::IsIdle | ( |  | ) | const
| inline

Definition at line 224 of file DecoderControl.hxx.

bool DecoderControl::IsStarting | ( |  | ) | const
| inline

Definition at line 235 of file DecoderControl.hxx.

void DecoderControl::Lock | ( |  | ) | const
| inline

Locks the object.

Definition at line 186 of file DecoderControl.hxx.

void DecoderControl::LockCheckRethrowError | ( |  | ) | const
| inline

Like CheckRethrowError(), but locks and unlocks the object.

Definition at line 283 of file DecoderControl.hxx.

gcc_pure bool DecoderControl::LockHasFailed | ( |  | ) | const
| inline

Definition at line 252 of file DecoderControl.hxx.

gcc_pure bool DecoderControl::LockIsCurrentSong | ( | const DetachedSong & | _song | ) | const
| inline

Definition at line 311 of file DecoderControl.hxx.

gcc_pure bool DecoderControl::LockIsIdle | ( |  | ) | const
| inline

Definition at line 230 of file DecoderControl.hxx.

gcc_pure bool DecoderControl::LockIsStarting | ( |  | ) | const
| inline

Definition at line 240 of file DecoderControl.hxx.

void DecoderControl::Quit | ( |  | ) |

void DecoderControl::Seek | ( | SongTime | t | ) |

Throws #std::runtime_error on error.

void DecoderControl::SetMixRamp | ( | MixRampInfo && | new_value | ) |
| 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.

void DecoderControl::Signal | ( |  | ) |
| 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.

Parameters

  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 | ( |  | ) |

void DecoderControl::Unlock | ( |  | ) | const
| inline

Unlocks the object.

Definition at line 193 of file DecoderControl.hxx.

void DecoderControl::Wait | ( |  | ) |
| 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.

## Field Documentation

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.

The documentation for this struct was generated from the following file:

- decoder/DecoderControl.hxx