MPD 0.20.6

- Main Page
- Namespaces
- Data Structures
- Files

- Data Structures
- Class Hierarchy
- Data Fields

Public Member Functions | Data Fields
DecoderBridge Class Referencefinal

A bridge between the DecoderClient interface and the MPD core (DecoderControl, MusicPipe etc.). More...

`#include <Bridge.hxx>`

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

## Public Member Functions
| DecoderBridge (DecoderControl &_dc, bool _initial_seek_pending, Tag *_tag)
| ~DecoderBridge ()
gcc_pure bool | CheckCancelRead () const
| Should be read operation be cancelled? That is the case when the player thread has sent a command such as "STOP". More...
MusicChunk * | GetChunk ()
| Returns the current chunk the decoder writes to, or allocates a new chunk if there is none. More...
void | FlushChunk ()
| Flushes the current chunk. More...
void | Ready (AudioFormat audio_format, bool seekable, SignedSongTime duration) override
| Notify the client that it has finished initialization and that it has read the song's meta data. More...
DecoderCommand | GetCommand () override
| Determines the pending decoder command. More...
void | CommandFinished () override
| Called by the decoder when it has performed the requested command (dc->command). More...
SongTime | GetSeekTime () override
| Call this when you have received the DecoderCommand::SEEK command. More...
uint64_t | GetSeekFrame () override
| Call this when you have received the DecoderCommand::SEEK command. More...
void | SeekError () override
| Call this instead of CommandFinished() when seeking has failed. More...
InputStreamPtr | OpenUri (const char *uri) override
| Open a new InputStream and wait until it's ready. More...
size_t | Read (InputStream &is, void *buffer, size_t length) override
| Blocking read from the input stream. More...
void | SubmitTimestamp (double t) override
| Sets the time stamp for the next data chunk [seconds]. More...
DecoderCommand | SubmitData (InputStream *is, const void *data, size_t length, uint16_t kbit_rate) override
| This function is called by the decoder plugin when it has successfully decoded block of input data. More...
DecoderCommand | SubmitTag (InputStream *is, Tag &&tag) override
| This function is called by the decoder plugin when it has successfully decoded a tag. More...
void | SubmitReplayGain (const ReplayGainInfo *replay_gain_info) override
| Set replay gain values for the following chunks. More...
void | SubmitMixRamp (MixRampInfo &&mix_ramp) override
| Store MixRamp tags. More...
Public Member Functions inherited from DecoderClient
DecoderCommand | SubmitData (InputStream &is, const void *data, size_t length, uint16_t kbit_rate)
DecoderCommand | SubmitTag (InputStream &is, Tag &&tag)

## Data Fields
DecoderControl & | dc
PcmConvert * | convert = nullptr
| For converting input data to the configured audio format. More...
double | timestamp = 0
| The time stamp of the next data chunk, in seconds. More...
bool | initial_seek_pending
| Is the initial seek (to the start position of the sub-song) pending, or has it been performed already? More...
bool | initial_seek_running = false
| Is the initial seek currently running? During this time, the decoder command is SEEK. More...
bool | seeking = false
| This flag is set by GetSeekTime(), and checked by CommandFinished(). More...
Tag * | song_tag
| The tag from the song object. More...
Tag * | stream_tag = nullptr
| the last tag received from the stream More...
Tag * | decoder_tag = nullptr
| the last tag received from the decoder plugin More...
MusicChunk * | current_chunk = nullptr
| the chunk currently being written to More...
ReplayGainInfo | replay_gain_info
unsigned | replay_gain_serial = 0
| A positive serial number for checking if replay gain info has changed since the last check. More...
std::exception_ptr | error
| An error has occurred (in DecoderAPI.cxx), and the plugin will be asked to stop. More...

## Detailed Description

A bridge between the DecoderClient interface and the MPD core (DecoderControl, MusicPipe etc.).

Definition at line 37 of file Bridge.hxx.

## Constructor & Destructor Documentation

DecoderBridge::DecoderBridge | ( | DecoderControl & | _dc,
|  | bool | _initial_seek_pending,
|  | Tag * | _tag
| ) |  |
| inline

Definition at line 102 of file Bridge.hxx.

DecoderBridge::~DecoderBridge | ( |  | ) |

## Member Function Documentation

gcc_pure bool DecoderBridge::CheckCancelRead | ( |  | ) | const

Should be read operation be cancelled? That is the case when the player thread has sent a command such as "STOP".

Caller must lock the DecoderControl object.

void DecoderBridge::CommandFinished | ( |  | ) |
| override virtual

Called by the decoder when it has performed the requested command (dc->command).

This function resets dc->command and wakes up the player thread.

Implements DecoderClient.

void DecoderBridge::FlushChunk | ( |  | ) |

Flushes the current chunk.

Caller must not lock the DecoderControl object.

MusicChunk* DecoderBridge::GetChunk | ( |  | ) |

Returns the current chunk the decoder writes to, or allocates a new chunk if there is none.

Returns
  the chunk, or NULL if we have received a decoder command

DecoderCommand DecoderBridge::GetCommand | ( |  | ) |
| override virtual

Determines the pending decoder command.

Returns
  the current command, or DecoderCommand::NONE if there is no command pending

Implements DecoderClient.

uint64_t DecoderBridge::GetSeekFrame | ( |  | ) |
| override virtual

Call this when you have received the DecoderCommand::SEEK command.

Returns
  the destination position for the seek in frames

Implements DecoderClient.

SongTime DecoderBridge::GetSeekTime | ( |  | ) |
| override virtual

Call this when you have received the DecoderCommand::SEEK command.

Returns
  the destination position for the seek in milliseconds

Implements DecoderClient.

InputStreamPtr DecoderBridge::OpenUri | ( | const char * | uri | ) |
| override virtual

Open a new InputStream and wait until it's ready.

Throws StopDecoder if DecoderCommand::STOP was received.

Throws std::runtime_error on error.

Implements DecoderClient.

size_t DecoderBridge::Read | ( | InputStream & | is,
|  | void * | buffer,
|  | size_t | length
| ) |  |
| override virtual

Blocking read from the input stream.

Parameters

  is | the input stream to read from
  buffer | the destination buffer
  length | the maximum number of bytes to read

Returns
  the number of bytes read, or 0 if one of the following occurs: end of file; error; command (like SEEK or STOP).

Implements DecoderClient.

void DecoderBridge::Ready | ( | AudioFormat | audio_format,
|  | bool | seekable,
|  | SignedSongTime | duration
| ) |  |
| override virtual

Notify the client that it has finished initialization and that it has read the song's meta data.

Parameters

  audio_format | the audio format which is going to be sent to SubmitData()
  seekable | true if the song is seekable
  duration | the total duration of this song; negative if unknown

Implements DecoderClient.

void DecoderBridge::SeekError | ( |  | ) |
| override virtual

Call this instead of CommandFinished() when seeking has failed.

Implements DecoderClient.

DecoderCommand DecoderBridge::SubmitData | ( | InputStream * | is,
|  | const void * | data,
|  | size_t | length,
|  | uint16_t | kbit_rate
| ) |  |
| override virtual

This function is called by the decoder plugin when it has successfully decoded block of input data.

Parameters

  is | an input stream which is buffering while we are waiting for the player
  data | the source buffer
  length | the number of bytes in the buffer

Returns
  the current command, or DecoderCommand::NONE if there is no command pending

Implements DecoderClient.

void DecoderBridge::SubmitMixRamp | ( | MixRampInfo && | mix_ramp | ) |
| override virtual

Store MixRamp tags.

Implements DecoderClient.

void DecoderBridge::SubmitReplayGain | ( | const ReplayGainInfo * | replay_gain_info | ) |
| override virtual

Set replay gain values for the following chunks.

Parameters

  replay_gain_info | the replay_gain_info object; may be nullptr to invalidate the previous replay gain values

Implements DecoderClient.

DecoderCommand DecoderBridge::SubmitTag | ( | InputStream * | is,
|  | Tag && | tag
| ) |  |
| override virtual

This function is called by the decoder plugin when it has successfully decoded a tag.

Parameters

  is | an input stream which is buffering while we are waiting for the player
  tag | the tag to send

Returns
  the current command, or DecoderCommand::NONE if there is no command pending

Implements DecoderClient.

void DecoderBridge::SubmitTimestamp | ( | double | t | ) |
| override virtual

Sets the time stamp for the next data chunk [seconds].

The MPD core automatically counts it up, and a decoder plugin only needs to use this function if it thinks that adding to the time stamp based on the buffer size won't work.

Implements DecoderClient.

## Field Documentation

PcmConvert* DecoderBridge::convert = nullptr

For converting input data to the configured audio format.

nullptr means no conversion necessary.

Definition at line 45 of file Bridge.hxx.

MusicChunk* DecoderBridge::current_chunk = nullptr

the chunk currently being written to

Definition at line 86 of file Bridge.hxx.

DecoderControl& DecoderBridge::dc

Definition at line 39 of file Bridge.hxx.

Tag* DecoderBridge::decoder_tag = nullptr

the last tag received from the decoder plugin

Definition at line 83 of file Bridge.hxx.

std::exception_ptr DecoderBridge::error

An error has occurred (in DecoderAPI.cxx), and the plugin will be asked to stop.

Definition at line 100 of file Bridge.hxx.

bool DecoderBridge::initial_seek_pending

Is the initial seek (to the start position of the sub-song) pending, or has it been performed already?

Definition at line 56 of file Bridge.hxx.

bool DecoderBridge::initial_seek_running = false

Is the initial seek currently running? During this time, the decoder command is SEEK.

This flag is set by decoder_get_virtual_command(), when the virtual SEEK command is generated for the first time.

Definition at line 64 of file Bridge.hxx.

ReplayGainInfo DecoderBridge::replay_gain_info

Definition at line 88 of file Bridge.hxx.

unsigned DecoderBridge::replay_gain_serial = 0

A positive serial number for checking if replay gain info has changed since the last check.

Definition at line 94 of file Bridge.hxx.

bool DecoderBridge::seeking = false

This flag is set by GetSeekTime(), and checked by CommandFinished().

It is used to clean up after seeking.

Definition at line 70 of file Bridge.hxx.

Tag* DecoderBridge::song_tag

The tag from the song object.

This is only used for local files, because we expect the stream server to send us a new tag each time we play it.

Definition at line 77 of file Bridge.hxx.

Tag* DecoderBridge::stream_tag = nullptr

the last tag received from the stream

Definition at line 80 of file Bridge.hxx.

double DecoderBridge::timestamp = 0

The time stamp of the next data chunk, in seconds.

Definition at line 50 of file Bridge.hxx.

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

- decoder/Bridge.hxx