MPD 0.20.6

- Main Page
- Namespaces
- Data Structures
- Files

- Data Structures
- Class Hierarchy
- Data Fields

Public Member Functions | Data Fields
PlayerControl Struct Referencefinal

`#include <Control.hxx>`

Inheritance diagram for PlayerControl:
[legend]
Collaboration diagram for PlayerControl:
[legend]

## Public Member Functions
| PlayerControl (PlayerListener &_listener, MultipleOutputs &_outputs, unsigned buffer_chunks, unsigned buffered_before_play, AudioFormat _configured_audio_format, const ReplayGainConfig &_replay_gain_config)
| ~PlayerControl ()
void | Lock () const
| Locks the object. More...
void | Unlock () const
| Unlocks the object. More...
void | Signal ()
| Signals the object. More...
void | LockSignal ()
| Signals the object. More...
void | Wait ()
| Waits for a signal on the object. More...
void | ClientSignal ()
| Wake up the client waiting for command completion. More...
void | ClientWait ()
| The client calls this method to wait for command completion. More...
void | CommandFinished ()
| A command has been finished. More...
void | LockCommandFinished ()
bool | WaitOutputConsumed (unsigned threshold)
| Checks if the size of the MusicPipe is below the #threshold. More...
bool | LockWaitOutputConsumed (unsigned threshold)
void | Play (DetachedSong *song)
| Throws std::runtime_error or #Error on error. More...
void | LockCancel ()
| see PlayerCommand::CANCEL More...
void | LockSetPause (bool pause_flag)
void | LockPause ()
void | LockSetBorderPause (bool border_pause)
| Set the player's border_pause flag. More...
bool | ApplyBorderPause ()
bool | LockApplyBorderPause ()
void | Kill ()
gcc_pure player_status | LockGetStatus ()
PlayerState | GetState () const
void | SetError (PlayerError type, std::exception_ptr &&_error)
| Set the error. More...
void | SetOutputError (std::exception_ptr &&_error)
| Set the error and set state to PlayerState::PAUSE. More...
void | LockSetOutputError (std::exception_ptr &&_error)
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 | LockClearError ()
PlayerError | GetErrorType () const
void | LockSetTaggedSong (const DetachedSong &song)
| Set the tagged_song attribute to a newly allocated copy of the given DetachedSong. More...
void | ClearTaggedSong ()
DetachedSong * | ReadTaggedSong ()
| Read and clear the tagged_song attribute. More...
DetachedSong * | LockReadTaggedSong ()
| Like ReadTaggedSong(), but locks and unlocks the object. More...
void | LockStop ()
void | LockUpdateAudio ()
void | LockEnqueueSong (DetachedSong *song)
void | LockSeek (DetachedSong *song, SongTime t)
| Makes the player thread seek the specified song to a position. More...
void | SetCrossFade (float cross_fade_seconds)
float | GetCrossFade () const
void | SetMixRampDb (float mixramp_db)
float | GetMixRampDb () const
void | SetMixRampDelay (float mixramp_delay_seconds)
float | GetMixRampDelay () const
void | LockSetReplayGainMode (ReplayGainMode _mode)
double | GetTotalPlayTime () const
void | ChunksConsumed () override
| Notify the client that we have consumed a few chunks. More...
void | ApplyEnabled () override
| The AudioOutput has modified the "enabled" flag, and the client shall make the AudioOutput apply this new setting. More...

## Data Fields
PlayerListener & | listener
MultipleOutputs & | outputs
const unsigned | buffer_chunks
const unsigned | buffered_before_play
const AudioFormat | configured_audio_format
| The "audio_output_format" setting. More...
Thread | thread
| The handle of the player thread. More...
Mutex | mutex
| This lock protects command, state, error, tagged_song. More...
Cond | cond
| Trigger this object after you have modified command. More...
Cond | client_cond
| This object gets signalled when the player thread has finished the command. More...
PlayerCommand | command = PlayerCommand::NONE
PlayerState | state = PlayerState::STOP
PlayerError | error_type = PlayerError::NONE
std::exception_ptr | error
| The error that occurred in the player thread. More...
DetachedSong * | tagged_song = nullptr
| A copy of the current DetachedSong after its tags have been updated by the decoder (for example, a radio stream that has sent a new tag after switching to the next song). More...
uint16_t | bit_rate
AudioFormat | audio_format
SignedSongTime | total_time
SongTime | elapsed_time
DetachedSong * | next_song = nullptr
| The next queued song. More...
SongTime | seek_time
CrossFadeSettings | cross_fade
const ReplayGainConfig | replay_gain_config
ReplayGainMode | replay_gain_mode = ReplayGainMode::OFF
double | total_play_time = 0
bool | border_pause = false
| If this flag is set, then the player will be auto-paused at the end of the song, before the next song starts to play. More...

## Detailed Description

Definition at line 100 of file Control.hxx.

## Constructor & Destructor Documentation

PlayerControl::PlayerControl | ( | PlayerListener & | _listener,
|  | MultipleOutputs & | _outputs,
|  | unsigned | buffer_chunks,
|  | unsigned | buffered_before_play,
|  | AudioFormat | _configured_audio_format,
|  | const ReplayGainConfig & | _replay_gain_config
| ) |  |

PlayerControl::~PlayerControl | ( |  | ) |

## Member Function Documentation

bool PlayerControl::ApplyBorderPause | ( |  | ) |
| inline

Definition at line 372 of file Control.hxx.

void PlayerControl::ApplyEnabled | ( |  | ) |
| inline override virtual

The AudioOutput has modified the "enabled" flag, and the client shall make the AudioOutput apply this new setting.

This is called from any thread, one which can't send an AudioOutput::Command to the output thread; only the client can do that safely.

Implements AudioOutputClient.

Definition at line 537 of file Control.hxx.

void PlayerControl::CheckRethrowError | ( |  | ) | const
| inline

Checks whether an error has occurred, and if so, rethrows it.

Caller must lock the object.

Definition at line 423 of file Control.hxx.

void PlayerControl::ChunksConsumed | ( |  | ) |
| inline override virtual

Notify the client that we have consumed a few chunks.

This is called from within the output thread. The client may perform actions to refill the MusicPipe.

Implements AudioOutputClient.

Definition at line 533 of file Control.hxx.

void PlayerControl::ClearTaggedSong | ( |  | ) |

void PlayerControl::ClientSignal | ( |  | ) |
| inline

Wake up the client waiting for command completion.

Caller must lock the object.

Definition at line 247 of file Control.hxx.

void PlayerControl::ClientWait | ( |  | ) |
| inline

The client calls this method to wait for command completion.

Caller must lock the object.

Definition at line 259 of file Control.hxx.

void PlayerControl::CommandFinished | ( |  | ) |
| inline

A command has been finished.

This method clears the command and signals the client.

To be called from the player thread. Caller must lock the object.

Definition at line 272 of file Control.hxx.

float PlayerControl::GetCrossFade | ( |  | ) | const
| inline

Definition at line 507 of file Control.hxx.

PlayerError PlayerControl::GetErrorType | ( |  | ) | const
| inline

Definition at line 438 of file Control.hxx.

float PlayerControl::GetMixRampDb | ( |  | ) | const
| inline

Definition at line 513 of file Control.hxx.

float PlayerControl::GetMixRampDelay | ( |  | ) | const
| inline

Definition at line 519 of file Control.hxx.

PlayerState PlayerControl::GetState | ( |  | ) | const
| inline

Definition at line 388 of file Control.hxx.

double PlayerControl::GetTotalPlayTime | ( |  | ) | const
| inline

Definition at line 528 of file Control.hxx.

void PlayerControl::Kill | ( |  | ) |

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

Locks the object.

Definition at line 203 of file Control.hxx.

bool PlayerControl::LockApplyBorderPause | ( |  | ) |
| inline

Definition at line 378 of file Control.hxx.

void PlayerControl::LockCancel | ( |  | ) |

see PlayerCommand::CANCEL

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

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

Definition at line 431 of file Control.hxx.

void PlayerControl::LockClearError | ( |  | ) |

void PlayerControl::LockCommandFinished | ( |  | ) |
| inline

Definition at line 279 of file Control.hxx.

void PlayerControl::LockEnqueueSong | ( | DetachedSong * | song | ) |

Parameters

  song | the song to be queued; the given instance will be owned and freed by the player

gcc_pure player_status PlayerControl::LockGetStatus | ( |  | ) |

void PlayerControl::LockPause | ( |  | ) |

DetachedSong* PlayerControl::LockReadTaggedSong | ( |  | ) |
| inline

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

Definition at line 464 of file Control.hxx.

void PlayerControl::LockSeek | ( | DetachedSong * | song,
|  | SongTime | t
| ) |  |

Makes the player thread seek the specified song to a position.

Throws std::runtime_error or #Error on error.

Parameters

  song | the song to be queued; the given instance will be owned and freed by the player

void PlayerControl::LockSetBorderPause | ( | bool | border_pause | ) |

Set the player's border_pause flag.

void PlayerControl::LockSetOutputError | ( | std::exception_ptr && | _error | ) |
| inline

Definition at line 412 of file Control.hxx.

void PlayerControl::LockSetPause | ( | bool | pause_flag | ) |

void PlayerControl::LockSetReplayGainMode | ( | ReplayGainMode | _mode | ) |
| inline

Definition at line 523 of file Control.hxx.

void PlayerControl::LockSetTaggedSong | ( | const DetachedSong & | song | ) |

Set the tagged_song attribute to a newly allocated copy of the given DetachedSong.

Locks and unlocks the object.

void PlayerControl::LockSignal | ( |  | ) |
| inline

Signals the object.

The object is temporarily locked by this function.

Definition at line 226 of file Control.hxx.

void PlayerControl::LockStop | ( |  | ) |

void PlayerControl::LockUpdateAudio | ( |  | ) |

bool PlayerControl::LockWaitOutputConsumed | ( | unsigned | threshold | ) |
| inline

Definition at line 296 of file Control.hxx.

void PlayerControl::Play | ( | DetachedSong * | song | ) |

Throws std::runtime_error or #Error on error.

Parameters

  song | the song to be queued; the given instance will be owned and freed by the player

DetachedSong* PlayerControl::ReadTaggedSong | ( |  | ) |
| inline

Read and clear the tagged_song attribute.

Caller must lock the object.

Definition at line 455 of file Control.hxx.

void PlayerControl::SetCrossFade | ( | float | cross_fade_seconds | ) |

void PlayerControl::SetError | ( | PlayerError | type,
|  | std::exception_ptr && | _error
| ) |  |

Set the error.

Discards any previous error condition.

Caller must lock the object.

Parameters

  type | the error type; must not be PlayerError::NONE

void PlayerControl::SetMixRampDb | ( | float | mixramp_db | ) |

void PlayerControl::SetMixRampDelay | ( | float | mixramp_delay_seconds | ) |

void PlayerControl::SetOutputError | ( | std::exception_ptr && | _error | ) |
| inline

Set the error and set state to PlayerState::PAUSE.

Definition at line 404 of file Control.hxx.

void PlayerControl::Signal | ( |  | ) |
| inline

Signals the object.

The object should be locked prior to calling this function.

Definition at line 218 of file Control.hxx.

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

Unlocks the object.

Definition at line 210 of file Control.hxx.

void PlayerControl::Wait | ( |  | ) |
| inline

Waits for a signal on the object.

This function is only valid in the player thread. The object must be locked prior to calling this function.

Definition at line 236 of file Control.hxx.

bool PlayerControl::WaitOutputConsumed | ( | unsigned | threshold | ) |

Checks if the size of the MusicPipe is below the #threshold.

If not, it attempts to synchronize with all output threads, and waits until another MusicChunk is finished.

Caller must lock the mutex.

Parameters

  threshold | the maximum number of chunks in the pipe

Returns
  true if there are less than #threshold chunks in the pipe

## Field Documentation

AudioFormat PlayerControl::audio_format

Definition at line 162 of file Control.hxx.

uint16_t PlayerControl::bit_rate

Definition at line 161 of file Control.hxx.

bool PlayerControl::border_pause = false

If this flag is set, then the player will be auto-paused at the end of the song, before the next song starts to play.

This is a copy of the queue's "single" flag most of the time.

Definition at line 190 of file Control.hxx.

const unsigned PlayerControl::buffer_chunks

Definition at line 105 of file Control.hxx.

const unsigned PlayerControl::buffered_before_play

Definition at line 107 of file Control.hxx.

Cond PlayerControl::client_cond

This object gets signalled when the player thread has finished the command.

It wakes up the client that waits (i.e. the main thread).

Definition at line 134 of file Control.hxx.

PlayerCommand PlayerControl::command = PlayerCommand::NONE

Definition at line 136 of file Control.hxx.

Cond PlayerControl::cond

Trigger this object after you have modified command.

Definition at line 127 of file Control.hxx.

const AudioFormat PlayerControl::configured_audio_format

The "audio_output_format" setting.

Definition at line 112 of file Control.hxx.

CrossFadeSettings PlayerControl::cross_fade

Definition at line 176 of file Control.hxx.

SongTime PlayerControl::elapsed_time

Definition at line 164 of file Control.hxx.

std::exception_ptr PlayerControl::error

The error that occurred in the player thread.

This attribute is only valid if error_type is not PlayerError::NONE. The object must be freed when this object transitions back to PlayerError::NONE.

Definition at line 147 of file Control.hxx.

PlayerError PlayerControl::error_type = PlayerError::NONE

Definition at line 139 of file Control.hxx.

PlayerListener& PlayerControl::listener

Definition at line 101 of file Control.hxx.

Mutex PlayerControl::mutex
| mutable

This lock protects command, state, error, tagged_song.

Definition at line 122 of file Control.hxx.

DetachedSong* PlayerControl::next_song = nullptr

The next queued song.

This is a duplicate, and must be freed when this attribute is cleared.

Definition at line 172 of file Control.hxx.

MultipleOutputs& PlayerControl::outputs

Definition at line 103 of file Control.hxx.

const ReplayGainConfig PlayerControl::replay_gain_config

Definition at line 178 of file Control.hxx.

ReplayGainMode PlayerControl::replay_gain_mode = ReplayGainMode::OFF

Definition at line 179 of file Control.hxx.

SongTime PlayerControl::seek_time

Definition at line 174 of file Control.hxx.

PlayerState PlayerControl::state = PlayerState::STOP

Definition at line 137 of file Control.hxx.

DetachedSong* PlayerControl::tagged_song = nullptr

A copy of the current DetachedSong after its tags have been updated by the decoder (for example, a radio stream that has sent a new tag after switching to the next song).

This shall be used by PlayerListener::OnPlayerTagModified() to update the current DetachedSong in the queue.

Protected by mutex. Set by the PlayerThread and consumed by the main thread.

Definition at line 159 of file Control.hxx.

Thread PlayerControl::thread

The handle of the player thread.

Definition at line 117 of file Control.hxx.

double PlayerControl::total_play_time = 0

Definition at line 181 of file Control.hxx.

SignedSongTime PlayerControl::total_time

Definition at line 163 of file Control.hxx.

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

- player/Control.hxx