Commit e699f678 authored by Max Kellermann's avatar Max Kellermann

decoder_control: rename to DecoderControl

parent 5f13c1cd
...@@ -41,7 +41,7 @@ decoder_initialized(Decoder &decoder, ...@@ -41,7 +41,7 @@ decoder_initialized(Decoder &decoder,
const AudioFormat audio_format, const AudioFormat audio_format,
bool seekable, float total_time) bool seekable, float total_time)
{ {
decoder_control &dc = decoder.dc; DecoderControl &dc = decoder.dc;
struct audio_format_string af_string; struct audio_format_string af_string;
assert(dc.state == DecoderState::START); assert(dc.state == DecoderState::START);
...@@ -81,7 +81,7 @@ gcc_pure ...@@ -81,7 +81,7 @@ gcc_pure
static bool static bool
decoder_prepare_initial_seek(Decoder &decoder) decoder_prepare_initial_seek(Decoder &decoder)
{ {
const decoder_control &dc = decoder.dc; const DecoderControl &dc = decoder.dc;
assert(dc.pipe != nullptr); assert(dc.pipe != nullptr);
if (dc.state != DecoderState::DECODE) if (dc.state != DecoderState::DECODE)
...@@ -128,7 +128,7 @@ gcc_pure ...@@ -128,7 +128,7 @@ gcc_pure
static DecoderCommand static DecoderCommand
decoder_get_virtual_command(Decoder &decoder) decoder_get_virtual_command(Decoder &decoder)
{ {
const decoder_control &dc = decoder.dc; const DecoderControl &dc = decoder.dc;
assert(dc.pipe != nullptr); assert(dc.pipe != nullptr);
if (decoder_prepare_initial_seek(decoder)) if (decoder_prepare_initial_seek(decoder))
...@@ -146,7 +146,7 @@ decoder_get_command(Decoder &decoder) ...@@ -146,7 +146,7 @@ decoder_get_command(Decoder &decoder)
void void
decoder_command_finished(Decoder &decoder) decoder_command_finished(Decoder &decoder)
{ {
decoder_control &dc = decoder.dc; DecoderControl &dc = decoder.dc;
dc.Lock(); dc.Lock();
...@@ -190,7 +190,7 @@ decoder_command_finished(Decoder &decoder) ...@@ -190,7 +190,7 @@ decoder_command_finished(Decoder &decoder)
double decoder_seek_where(gcc_unused Decoder & decoder) double decoder_seek_where(gcc_unused Decoder & decoder)
{ {
const decoder_control &dc = decoder.dc; const DecoderControl &dc = decoder.dc;
assert(dc.pipe != nullptr); assert(dc.pipe != nullptr);
...@@ -206,7 +206,7 @@ double decoder_seek_where(gcc_unused Decoder & decoder) ...@@ -206,7 +206,7 @@ double decoder_seek_where(gcc_unused Decoder & decoder)
void decoder_seek_error(Decoder & decoder) void decoder_seek_error(Decoder & decoder)
{ {
decoder_control &dc = decoder.dc; DecoderControl &dc = decoder.dc;
assert(dc.pipe != nullptr); assert(dc.pipe != nullptr);
...@@ -236,7 +236,7 @@ decoder_check_cancel_read(const Decoder *decoder) ...@@ -236,7 +236,7 @@ decoder_check_cancel_read(const Decoder *decoder)
if (decoder == nullptr) if (decoder == nullptr)
return false; return false;
const decoder_control &dc = decoder->dc; const DecoderControl &dc = decoder->dc;
if (dc.command == DecoderCommand::NONE) if (dc.command == DecoderCommand::NONE)
return false; return false;
...@@ -356,7 +356,7 @@ decoder_data(Decoder &decoder, ...@@ -356,7 +356,7 @@ decoder_data(Decoder &decoder,
const void *data, size_t length, const void *data, size_t length,
uint16_t kbit_rate) uint16_t kbit_rate)
{ {
decoder_control &dc = decoder.dc; DecoderControl &dc = decoder.dc;
DecoderCommand cmd; DecoderCommand cmd;
assert(dc.state == DecoderState::DECODE); assert(dc.state == DecoderState::DECODE);
...@@ -464,7 +464,7 @@ DecoderCommand ...@@ -464,7 +464,7 @@ DecoderCommand
decoder_tag(Decoder &decoder, InputStream *is, decoder_tag(Decoder &decoder, InputStream *is,
Tag &&tag) Tag &&tag)
{ {
gcc_unused const decoder_control &dc = decoder.dc; gcc_unused const DecoderControl &dc = decoder.dc;
DecoderCommand cmd; DecoderCommand cmd;
assert(dc.state == DecoderState::DECODE); assert(dc.state == DecoderState::DECODE);
...@@ -543,7 +543,7 @@ decoder_replay_gain(Decoder &decoder, ...@@ -543,7 +543,7 @@ decoder_replay_gain(Decoder &decoder,
void void
decoder_mixramp(Decoder &decoder, MixRampInfo &&mix_ramp) decoder_mixramp(Decoder &decoder, MixRampInfo &&mix_ramp)
{ {
decoder_control &dc = decoder.dc; DecoderControl &dc = decoder.dc;
dc.SetMixRamp(std::move(mix_ramp)); dc.SetMixRamp(std::move(mix_ramp));
} }
...@@ -26,13 +26,13 @@ ...@@ -26,13 +26,13 @@
#include <assert.h> #include <assert.h>
decoder_control::decoder_control() DecoderControl::DecoderControl()
:state(DecoderState::STOP), :state(DecoderState::STOP),
command(DecoderCommand::NONE), command(DecoderCommand::NONE),
song(nullptr), song(nullptr),
replay_gain_db(0), replay_gain_prev_db(0) {} replay_gain_db(0), replay_gain_prev_db(0) {}
decoder_control::~decoder_control() DecoderControl::~DecoderControl()
{ {
ClearError(); ClearError();
...@@ -41,7 +41,7 @@ decoder_control::~decoder_control() ...@@ -41,7 +41,7 @@ decoder_control::~decoder_control()
} }
bool bool
decoder_control::IsCurrentSong(const Song &_song) const DecoderControl::IsCurrentSong(const Song &_song) const
{ {
switch (state) { switch (state) {
case DecoderState::STOP: case DecoderState::STOP:
...@@ -58,7 +58,7 @@ decoder_control::IsCurrentSong(const Song &_song) const ...@@ -58,7 +58,7 @@ decoder_control::IsCurrentSong(const Song &_song) const
} }
void void
decoder_control::Start(Song *_song, DecoderControl::Start(Song *_song,
unsigned _start_ms, unsigned _end_ms, unsigned _start_ms, unsigned _end_ms,
MusicBuffer &_buffer, MusicPipe &_pipe) MusicBuffer &_buffer, MusicPipe &_pipe)
{ {
...@@ -78,7 +78,7 @@ decoder_control::Start(Song *_song, ...@@ -78,7 +78,7 @@ decoder_control::Start(Song *_song,
} }
void void
decoder_control::Stop() DecoderControl::Stop()
{ {
Lock(); Lock();
...@@ -96,7 +96,7 @@ decoder_control::Stop() ...@@ -96,7 +96,7 @@ decoder_control::Stop()
} }
bool bool
decoder_control::Seek(double where) DecoderControl::Seek(double where)
{ {
assert(state != DecoderState::START); assert(state != DecoderState::START);
assert(where >= 0.0); assert(where >= 0.0);
...@@ -113,7 +113,7 @@ decoder_control::Seek(double where) ...@@ -113,7 +113,7 @@ decoder_control::Seek(double where)
} }
void void
decoder_control::Quit() DecoderControl::Quit()
{ {
assert(thread.IsDefined()); assert(thread.IsDefined());
...@@ -124,7 +124,7 @@ decoder_control::Quit() ...@@ -124,7 +124,7 @@ decoder_control::Quit()
} }
void void
decoder_control::CycleMixRamp() DecoderControl::CycleMixRamp()
{ {
previous_mix_ramp = std::move(mix_ramp); previous_mix_ramp = std::move(mix_ramp);
mix_ramp.Clear(); mix_ramp.Clear();
......
...@@ -54,7 +54,7 @@ enum class DecoderState : uint8_t { ...@@ -54,7 +54,7 @@ enum class DecoderState : uint8_t {
ERROR, ERROR,
}; };
struct decoder_control { struct DecoderControl {
/** /**
* The handle of the decoder thread. * The handle of the decoder thread.
*/ */
...@@ -143,8 +143,8 @@ struct decoder_control { ...@@ -143,8 +143,8 @@ struct decoder_control {
MixRampInfo mix_ramp, previous_mix_ramp; MixRampInfo mix_ramp, previous_mix_ramp;
decoder_control(); DecoderControl();
~decoder_control(); ~DecoderControl();
/** /**
* Locks the object. * Locks the object.
...@@ -170,7 +170,7 @@ struct decoder_control { ...@@ -170,7 +170,7 @@ struct decoder_control {
} }
/** /**
* Waits for a signal on the #decoder_control object. This function * Waits for a signal on the #DecoderControl object. This function
* is only valid in the decoder thread. The object must be locked * is only valid in the decoder thread. The object must be locked
* prior to calling this function. * prior to calling this function.
*/ */
...@@ -336,8 +336,8 @@ public: ...@@ -336,8 +336,8 @@ public:
* *
* @param song the song to be decoded; the given instance will be * @param song the song to be decoded; the given instance will be
* owned and freed by the decoder * owned and freed by the decoder
* @param start_ms see #decoder_control * @param start_ms see #DecoderControl
* @param end_ms see #decoder_control * @param end_ms see #DecoderControl
* @param pipe the pipe which receives the decoded chunks (owned by * @param pipe the pipe which receives the decoded chunks (owned by
* the caller) * the caller)
*/ */
......
...@@ -42,7 +42,7 @@ Decoder::~Decoder() ...@@ -42,7 +42,7 @@ Decoder::~Decoder()
* one. * one.
*/ */
static DecoderCommand static DecoderCommand
need_chunks(decoder_control &dc, bool do_wait) need_chunks(DecoderControl &dc, bool do_wait)
{ {
if (dc.command == DecoderCommand::STOP || if (dc.command == DecoderCommand::STOP ||
dc.command == DecoderCommand::SEEK) dc.command == DecoderCommand::SEEK)
...@@ -61,7 +61,7 @@ need_chunks(decoder_control &dc, bool do_wait) ...@@ -61,7 +61,7 @@ need_chunks(decoder_control &dc, bool do_wait)
struct music_chunk * struct music_chunk *
decoder_get_chunk(Decoder &decoder) decoder_get_chunk(Decoder &decoder)
{ {
decoder_control &dc = decoder.dc; DecoderControl &dc = decoder.dc;
DecoderCommand cmd; DecoderCommand cmd;
if (decoder.chunk != nullptr) if (decoder.chunk != nullptr)
...@@ -90,7 +90,7 @@ decoder_get_chunk(Decoder &decoder) ...@@ -90,7 +90,7 @@ decoder_get_chunk(Decoder &decoder)
void void
decoder_flush_chunk(Decoder &decoder) decoder_flush_chunk(Decoder &decoder)
{ {
decoder_control &dc = decoder.dc; DecoderControl &dc = decoder.dc;
assert(decoder.chunk != nullptr); assert(decoder.chunk != nullptr);
......
...@@ -24,12 +24,12 @@ ...@@ -24,12 +24,12 @@
#include "pcm/PcmConvert.hxx" #include "pcm/PcmConvert.hxx"
#include "ReplayGainInfo.hxx" #include "ReplayGainInfo.hxx"
struct decoder_control; struct DecoderControl;
struct InputStream; struct InputStream;
struct Tag; struct Tag;
struct Decoder { struct Decoder {
decoder_control &dc; DecoderControl &dc;
PcmConvert conv_state; PcmConvert conv_state;
...@@ -83,7 +83,7 @@ struct Decoder { ...@@ -83,7 +83,7 @@ struct Decoder {
*/ */
unsigned replay_gain_serial; unsigned replay_gain_serial;
Decoder(decoder_control &_dc, bool _initial_seek_pending, Tag *_tag) Decoder(DecoderControl &_dc, bool _initial_seek_pending, Tag *_tag)
:dc(_dc), :dc(_dc),
timestamp(0), timestamp(0),
initial_seek_pending(_initial_seek_pending), initial_seek_pending(_initial_seek_pending),
......
...@@ -44,10 +44,10 @@ static constexpr Domain decoder_thread_domain("decoder_thread"); ...@@ -44,10 +44,10 @@ static constexpr Domain decoder_thread_domain("decoder_thread");
* Marks the current decoder command as "finished" and notifies the * Marks the current decoder command as "finished" and notifies the
* player thread. * player thread.
* *
* @param dc the #decoder_control object; must be locked * @param dc the #DecoderControl object; must be locked
*/ */
static void static void
decoder_command_finished_locked(decoder_control &dc) decoder_command_finished_locked(DecoderControl &dc)
{ {
assert(dc.command != DecoderCommand::NONE); assert(dc.command != DecoderCommand::NONE);
...@@ -68,7 +68,7 @@ decoder_command_finished_locked(decoder_control &dc) ...@@ -68,7 +68,7 @@ decoder_command_finished_locked(decoder_control &dc)
* received, nullptr on error * received, nullptr on error
*/ */
static InputStream * static InputStream *
decoder_input_stream_open(decoder_control &dc, const char *uri) decoder_input_stream_open(DecoderControl &dc, const char *uri)
{ {
Error error; Error error;
...@@ -237,7 +237,7 @@ decoder_run_stream_fallback(Decoder &decoder, InputStream &is) ...@@ -237,7 +237,7 @@ decoder_run_stream_fallback(Decoder &decoder, InputStream &is)
static bool static bool
decoder_run_stream(Decoder &decoder, const char *uri) decoder_run_stream(Decoder &decoder, const char *uri)
{ {
decoder_control &dc = decoder.dc; DecoderControl &dc = decoder.dc;
InputStream *input_stream; InputStream *input_stream;
bool success; bool success;
...@@ -285,7 +285,7 @@ decoder_load_replay_gain(Decoder &decoder, const char *path_fs) ...@@ -285,7 +285,7 @@ decoder_load_replay_gain(Decoder &decoder, const char *path_fs)
static bool static bool
decoder_run_file(Decoder &decoder, const char *path_fs) decoder_run_file(Decoder &decoder, const char *path_fs)
{ {
decoder_control &dc = decoder.dc; DecoderControl &dc = decoder.dc;
const char *suffix = uri_get_suffix(path_fs); const char *suffix = uri_get_suffix(path_fs);
const struct DecoderPlugin *plugin = nullptr; const struct DecoderPlugin *plugin = nullptr;
...@@ -333,7 +333,7 @@ decoder_run_file(Decoder &decoder, const char *path_fs) ...@@ -333,7 +333,7 @@ decoder_run_file(Decoder &decoder, const char *path_fs)
} }
static void static void
decoder_run_song(decoder_control &dc, decoder_run_song(DecoderControl &dc,
const Song *song, const char *uri) const Song *song, const char *uri)
{ {
Decoder decoder(dc, dc.start_ms > 0, Decoder decoder(dc, dc.start_ms > 0,
...@@ -376,7 +376,7 @@ decoder_run_song(decoder_control &dc, ...@@ -376,7 +376,7 @@ decoder_run_song(decoder_control &dc,
} }
static void static void
decoder_run(decoder_control &dc) decoder_run(DecoderControl &dc)
{ {
dc.ClearError(); dc.ClearError();
...@@ -402,7 +402,7 @@ decoder_run(decoder_control &dc) ...@@ -402,7 +402,7 @@ decoder_run(decoder_control &dc)
static void static void
decoder_task(void *arg) decoder_task(void *arg)
{ {
decoder_control &dc = *(decoder_control *)arg; DecoderControl &dc = *(DecoderControl *)arg;
dc.Lock(); dc.Lock();
...@@ -436,7 +436,7 @@ decoder_task(void *arg) ...@@ -436,7 +436,7 @@ decoder_task(void *arg)
} }
void void
decoder_thread_start(decoder_control &dc) decoder_thread_start(DecoderControl &dc)
{ {
assert(!dc.thread.IsDefined()); assert(!dc.thread.IsDefined());
......
...@@ -20,9 +20,9 @@ ...@@ -20,9 +20,9 @@
#ifndef MPD_DECODER_THREAD_HXX #ifndef MPD_DECODER_THREAD_HXX
#define MPD_DECODER_THREAD_HXX #define MPD_DECODER_THREAD_HXX
struct decoder_control; struct DecoderControl;
void void
decoder_thread_start(decoder_control &dc); decoder_thread_start(DecoderControl &dc);
#endif #endif
...@@ -53,7 +53,7 @@ enum class CrossFadeState : int8_t { ...@@ -53,7 +53,7 @@ enum class CrossFadeState : int8_t {
class Player { class Player {
player_control &pc; player_control &pc;
decoder_control &dc; DecoderControl &dc;
MusicBuffer &buffer; MusicBuffer &buffer;
...@@ -130,7 +130,7 @@ class Player { ...@@ -130,7 +130,7 @@ class Player {
float elapsed_time; float elapsed_time;
public: public:
Player(player_control &_pc, decoder_control &_dc, Player(player_control &_pc, DecoderControl &_dc,
MusicBuffer &_buffer) MusicBuffer &_buffer)
:pc(_pc), dc(_dc), buffer(_buffer), :pc(_pc), dc(_dc), buffer(_buffer),
buffering(false), buffering(false),
...@@ -1095,7 +1095,7 @@ Player::Run() ...@@ -1095,7 +1095,7 @@ Player::Run()
} }
static void static void
do_play(player_control &pc, decoder_control &dc, do_play(player_control &pc, DecoderControl &dc,
MusicBuffer &buffer) MusicBuffer &buffer)
{ {
Player player(pc, dc, buffer); Player player(pc, dc, buffer);
...@@ -1107,7 +1107,7 @@ player_task(void *arg) ...@@ -1107,7 +1107,7 @@ player_task(void *arg)
{ {
player_control &pc = *(player_control *)arg; player_control &pc = *(player_control *)arg;
decoder_control dc; DecoderControl dc;
decoder_thread_start(dc); decoder_thread_start(dc);
MusicBuffer buffer(pc.buffer_chunks); MusicBuffer buffer(pc.buffer_chunks);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment