MPD
Functions
decoder_api.h File Reference

The MPD Decoder API. More...

#include "check.h"
#include "decoder_command.h"
#include "decoder_plugin.h"
#include "input_stream.h"
#include "replay_gain_info.h"
#include "tag.h"
#include "audio_format.h"
#include "conf.h"
#include <stdbool.h>

Go to the source code of this file.

Functions

void decoder_initialized (struct decoder *decoder, const struct audio_format *audio_format, bool seekable, float total_time)
 Notify the player thread that it has finished initialization and that it has read the song's meta data.
 
enum decoder_command decoder_get_command (struct decoder *decoder)
 Determines the pending decoder command.
 
void decoder_command_finished (struct decoder *decoder)
 Called by the decoder when it has performed the requested command (dc->command).
 
double decoder_seek_where (struct decoder *decoder)
 Call this when you have received the DECODE_COMMAND_SEEK command.
 
void decoder_seek_error (struct decoder *decoder)
 Call this right before decoder_command_finished() when seeking has failed.
 
size_t decoder_read (struct decoder *decoder, struct input_stream *is, void *buffer, size_t length)
 Blocking read from the input stream.
 
void decoder_timestamp (struct decoder *decoder, double t)
 Sets the time stamp for the next data chunk [seconds].
 
enum decoder_command decoder_data (struct decoder *decoder, struct input_stream *is, const void *data, size_t length, uint16_t kbit_rate)
 This function is called by the decoder plugin when it has successfully decoded block of input data.
 
enum decoder_command decoder_tag (struct decoder *decoder, struct input_stream *is, const struct tag *tag)
 This function is called by the decoder plugin when it has successfully decoded a tag.
 
float decoder_replay_gain (struct decoder *decoder, const struct replay_gain_info *replay_gain_info)
 Set replay gain values for the following chunks.
 
void decoder_mixramp (struct decoder *decoder, float replay_gain_db, char *mixramp_start, char *mixramp_end)
 Store MixRamp tags.
 

Detailed Description

The MPD Decoder API.

This is the public API which is used by decoder plugins to communicate with the mpd core.

Definition in file decoder_api.h.

Function Documentation

void decoder_command_finished ( struct decoder decoder)

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

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

Parameters
decoderthe decoder object
enum decoder_command decoder_data ( struct decoder decoder,
struct input_stream is,
const void *  data,
size_t  length,
uint16_t  kbit_rate 
)

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

Parameters
decoderthe decoder object
isan input stream which is buffering while we are waiting for the player
datathe source buffer
lengththe number of bytes in the buffer
Returns
the current command, or DECODE_COMMAND_NONE if there is no command pending
enum decoder_command decoder_get_command ( struct decoder decoder)

Determines the pending decoder command.

Parameters
decoderthe decoder object
Returns
the current command, or DECODE_COMMAND_NONE if there is no command pending
void decoder_initialized ( struct decoder decoder,
const struct audio_format audio_format,
bool  seekable,
float  total_time 
)

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

Parameters
decoderthe decoder object
audio_formatthe audio format which is going to be sent to decoder_data()
seekabletrue if the song is seekable
total_timethe total number of seconds in this song; -1 if unknown
void decoder_mixramp ( struct decoder decoder,
float  replay_gain_db,
char *  mixramp_start,
char *  mixramp_end 
)

Store MixRamp tags.

Parameters
decoderthe decoder object
replay_gain_dbthe ReplayGain adjustment used for this song
mixramp_startthe mixramp_start tag; may be NULL to invalidate
mixramp_endthe mixramp_end tag; may be NULL to invalidate
size_t decoder_read ( struct decoder decoder,
struct input_stream is,
void *  buffer,
size_t  length 
)

Blocking read from the input stream.

Parameters
decoderthe decoder object
isthe input stream to read from
bufferthe destination buffer
lengththe 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).
float decoder_replay_gain ( struct decoder decoder,
const struct replay_gain_info replay_gain_info 
)

Set replay gain values for the following chunks.

Parameters
decoderthe decoder object
rgithe replay_gain_info object; may be NULL to invalidate the previous replay gain values
Returns
the replay gain adjustment used
void decoder_seek_error ( struct decoder decoder)

Call this right before decoder_command_finished() when seeking has failed.

Parameters
decoderthe decoder object
double decoder_seek_where ( struct decoder decoder)

Call this when you have received the DECODE_COMMAND_SEEK command.

Parameters
decoderthe decoder object
Returns
the destination position for the week
enum decoder_command decoder_tag ( struct decoder decoder,
struct input_stream is,
const struct tag tag 
)

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

Parameters
decoderthe decoder object
isan input stream which is buffering while we are waiting for the player
tagthe tag to send
Returns
the current command, or DECODE_COMMAND_NONE if there is no command pending
void decoder_timestamp ( struct decoder decoder,
double  t 
)

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.