aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2013-04-23 16:23:31 +0200
committerAnton Khirnov <anton@khirnov.net>2015-02-20 09:18:30 +0100
commit0b12de447dbefa76c740f4b87da6e0882b735e62 (patch)
treeb576eb6fe7fb69a501ddd0e67c9399171487ecde
parenta71d20c96adca437f15c6f0d4884d29f3344a441 (diff)
decoder_control: rename struct decoder_control to DecoderControl
-rw-r--r--src/decoder/decoder_api.c20
-rw-r--r--src/decoder/decoder_control.c28
-rw-r--r--src/decoder/decoder_control.h44
-rw-r--r--src/decoder/decoder_internal.c4
-rw-r--r--src/decoder/decoder_internal.h6
-rw-r--r--src/decoder/decoder_thread.c16
-rw-r--r--src/decoder/decoder_thread.h5
-rw-r--r--src/player_control.c2
-rw-r--r--src/player_control.h5
-rw-r--r--src/player_thread.c20
10 files changed, 74 insertions, 76 deletions
diff --git a/src/decoder/decoder_api.c b/src/decoder/decoder_api.c
index 662b9d8e..619f581d 100644
--- a/src/decoder/decoder_api.c
+++ b/src/decoder/decoder_api.c
@@ -43,7 +43,7 @@ void decoder_initialized(struct decoder *decoder,
const struct audio_format *audio_format,
bool seekable, float total_time)
{
- struct decoder_control *dc = decoder->dc;
+ DecoderControl *dc = decoder->dc;
struct audio_format_string af_string;
assert(dc->state == DECODE_STATE_START);
@@ -84,7 +84,7 @@ void decoder_initialized(struct decoder *decoder,
*/
static bool decoder_prepare_initial_seek(struct decoder *decoder)
{
- const struct decoder_control *dc = decoder->dc;
+ const DecoderControl *dc = decoder->dc;
assert(dc->pipe != NULL);
if (dc->state != DECODE_STATE_DECODE)
@@ -129,7 +129,7 @@ static bool decoder_prepare_initial_seek(struct decoder *decoder)
*/
static enum decoder_command decoder_get_virtual_command(struct decoder *decoder)
{
- const struct decoder_control *dc = decoder->dc;
+ const DecoderControl *dc = decoder->dc;
assert(dc->pipe != NULL);
if (decoder_prepare_initial_seek(decoder))
@@ -145,7 +145,7 @@ enum decoder_command decoder_get_command(struct decoder *decoder)
void decoder_command_finished(struct decoder *decoder)
{
- struct decoder_control *dc = decoder->dc;
+ DecoderControl *dc = decoder->dc;
decoder_lock(dc);
@@ -181,7 +181,7 @@ void decoder_command_finished(struct decoder *decoder)
double decoder_seek_where(struct decoder * decoder)
{
- const struct decoder_control *dc = decoder->dc;
+ const DecoderControl *dc = decoder->dc;
assert(dc->pipe != NULL);
@@ -197,7 +197,7 @@ double decoder_seek_where(struct decoder * decoder)
void decoder_seek_error(struct decoder * decoder)
{
- struct decoder_control *dc = decoder->dc;
+ DecoderControl *dc = decoder->dc;
assert(dc->pipe != NULL);
@@ -225,7 +225,7 @@ static inline bool decoder_check_cancel_read(const struct decoder *decoder)
if (decoder == NULL)
return false;
- const struct decoder_control *dc = decoder->dc;
+ const DecoderControl *dc = decoder->dc;
if (dc->command == DECODE_COMMAND_NONE)
return false;
@@ -336,7 +336,7 @@ enum decoder_command decoder_data(struct decoder *decoder,
AVFrame *frame,
uint16_t kbit_rate)
{
- struct decoder_control *dc = decoder->dc;
+ DecoderControl *dc = decoder->dc;
enum decoder_command cmd = DECODE_COMMAND_NONE;
int nb_samples = frame->nb_samples;
struct music_chunk *chunk;
@@ -424,7 +424,7 @@ finish:
enum decoder_command decoder_tag(struct decoder *decoder, struct input_stream *is,
const struct tag *tag)
{
- const struct decoder_control *dc = decoder->dc;
+ const DecoderControl *dc = decoder->dc;
enum decoder_command cmd;
assert(dc->state == DECODE_STATE_DECODE);
@@ -496,7 +496,7 @@ void decoder_mixramp(struct decoder *decoder, float replay_gain_db,
char *mixramp_start, char *mixramp_end)
{
assert(decoder != NULL);
- struct decoder_control *dc = decoder->dc;
+ DecoderControl *dc = decoder->dc;
assert(dc != NULL);
dc->replay_gain_db = replay_gain_db;
diff --git a/src/decoder/decoder_control.c b/src/decoder/decoder_control.c
index ec9b9791..48782531 100644
--- a/src/decoder/decoder_control.c
+++ b/src/decoder/decoder_control.c
@@ -28,9 +28,9 @@
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "decoder_control"
-struct decoder_control *dc_new(GCond *client_cond)
+DecoderControl *dc_new(GCond *client_cond)
{
- struct decoder_control *dc = av_mallocz(sizeof(*dc));
+ DecoderControl *dc = av_mallocz(sizeof(*dc));
dc->mutex = g_mutex_new();
dc->cond = g_cond_new();
@@ -42,7 +42,7 @@ struct decoder_control *dc_new(GCond *client_cond)
return dc;
}
-void dc_free(struct decoder_control *dc)
+void dc_free(DecoderControl *dc)
{
g_cond_free(dc->cond);
g_mutex_free(dc->mutex);
@@ -52,27 +52,27 @@ void dc_free(struct decoder_control *dc)
av_freep(&dc);
}
-static void dc_command_wait_locked(struct decoder_control *dc)
+static void dc_command_wait_locked(DecoderControl *dc)
{
while (dc->command != DECODE_COMMAND_NONE)
g_cond_wait(dc->client_cond, dc->mutex);
}
-static void dc_command_locked(struct decoder_control *dc, enum decoder_command cmd)
+static void dc_command_locked(DecoderControl *dc, enum decoder_command cmd)
{
dc->command = cmd;
decoder_signal(dc);
dc_command_wait_locked(dc);
}
-static void dc_command(struct decoder_control *dc, enum decoder_command cmd)
+static void dc_command(DecoderControl *dc, enum decoder_command cmd)
{
decoder_lock(dc);
dc_command_locked(dc, cmd);
decoder_unlock(dc);
}
-static void dc_command_async(struct decoder_control *dc, enum decoder_command cmd)
+static void dc_command_async(DecoderControl *dc, enum decoder_command cmd)
{
decoder_lock(dc);
@@ -82,7 +82,7 @@ static void dc_command_async(struct decoder_control *dc, enum decoder_command cm
decoder_unlock(dc);
}
-void dc_start(struct decoder_control *dc, struct song *song,
+void dc_start(DecoderControl *dc, struct song *song,
unsigned start_ms, unsigned end_ms,
int buffer_samples, struct music_pipe *pipe)
{
@@ -98,7 +98,7 @@ void dc_start(struct decoder_control *dc, struct song *song,
dc_command(dc, DECODE_COMMAND_START);
}
-void dc_stop(struct decoder_control *dc)
+void dc_stop(DecoderControl *dc)
{
decoder_lock(dc);
@@ -115,7 +115,7 @@ void dc_stop(struct decoder_control *dc)
decoder_unlock(dc);
}
-bool dc_seek(struct decoder_control *dc, double where)
+bool dc_seek(DecoderControl *dc, double where)
{
assert(dc->state != DECODE_STATE_START);
assert(where >= 0.0);
@@ -134,7 +134,7 @@ bool dc_seek(struct decoder_control *dc, double where)
return true;
}
-void dc_quit(struct decoder_control *dc)
+void dc_quit(DecoderControl *dc)
{
assert(dc->thread != NULL);
@@ -145,7 +145,7 @@ void dc_quit(struct decoder_control *dc)
dc->thread = NULL;
}
-void dc_mixramp_start(struct decoder_control *dc, char *mixramp_start)
+void dc_mixramp_start(DecoderControl *dc, char *mixramp_start)
{
assert(dc != NULL);
@@ -154,7 +154,7 @@ void dc_mixramp_start(struct decoder_control *dc, char *mixramp_start)
g_debug("mixramp_start = %s", mixramp_start ? mixramp_start : "NULL");
}
-void dc_mixramp_end(struct decoder_control *dc, char *mixramp_end)
+void dc_mixramp_end(DecoderControl *dc, char *mixramp_end)
{
assert(dc != NULL);
@@ -163,7 +163,7 @@ void dc_mixramp_end(struct decoder_control *dc, char *mixramp_end)
g_debug("mixramp_end = %s", mixramp_end ? mixramp_end : "NULL");
}
-void dc_mixramp_prev_end(struct decoder_control *dc, char *mixramp_prev_end)
+void dc_mixramp_prev_end(DecoderControl *dc, char *mixramp_prev_end)
{
assert(dc != NULL);
diff --git a/src/decoder/decoder_control.h b/src/decoder/decoder_control.h
index 8f3fc948..e262e0ac 100644
--- a/src/decoder/decoder_control.h
+++ b/src/decoder/decoder_control.h
@@ -41,7 +41,7 @@ enum decoder_state {
DECODE_STATE_ERROR,
};
-struct decoder_control {
+typedef struct DecoderControl {
/** the handle of the decoder thread, or NULL if the decoder
thread isn't running */
GThread *thread;
@@ -118,20 +118,20 @@ struct decoder_control {
char *mixramp_start;
char *mixramp_end;
char *mixramp_prev_end;
-};
+} DecoderControl;
G_GNUC_MALLOC
-struct decoder_control *
+DecoderControl *
dc_new(GCond *client_cond);
void
-dc_free(struct decoder_control *dc);
+dc_free(DecoderControl *dc);
/**
* Locks the #decoder_control object.
*/
static inline void
-decoder_lock(struct decoder_control *dc)
+decoder_lock(DecoderControl *dc)
{
g_mutex_lock(dc->mutex);
}
@@ -140,7 +140,7 @@ decoder_lock(struct decoder_control *dc)
* Unlocks the #decoder_control object.
*/
static inline void
-decoder_unlock(struct decoder_control *dc)
+decoder_unlock(DecoderControl *dc)
{
g_mutex_unlock(dc->mutex);
}
@@ -151,7 +151,7 @@ decoder_unlock(struct decoder_control *dc)
* prior to calling this function.
*/
static inline void
-decoder_wait(struct decoder_control *dc)
+decoder_wait(DecoderControl *dc)
{
g_cond_wait(dc->cond, dc->mutex);
}
@@ -162,26 +162,26 @@ decoder_wait(struct decoder_control *dc)
* this function.
*/
static inline void
-decoder_signal(struct decoder_control *dc)
+decoder_signal(DecoderControl *dc)
{
g_cond_signal(dc->cond);
}
static inline bool
-decoder_is_idle(const struct decoder_control *dc)
+decoder_is_idle(const DecoderControl *dc)
{
return dc->state == DECODE_STATE_STOP ||
dc->state == DECODE_STATE_ERROR;
}
static inline bool
-decoder_is_starting(const struct decoder_control *dc)
+decoder_is_starting(const DecoderControl *dc)
{
return dc->state == DECODE_STATE_START;
}
static inline bool
-decoder_has_failed(const struct decoder_control *dc)
+decoder_has_failed(const DecoderControl *dc)
{
assert(dc->command == DECODE_COMMAND_NONE);
@@ -189,7 +189,7 @@ decoder_has_failed(const struct decoder_control *dc)
}
static inline bool
-decoder_lock_is_idle(struct decoder_control *dc)
+decoder_lock_is_idle(DecoderControl *dc)
{
bool ret;
@@ -201,7 +201,7 @@ decoder_lock_is_idle(struct decoder_control *dc)
}
static inline bool
-decoder_lock_is_starting(struct decoder_control *dc)
+decoder_lock_is_starting(DecoderControl *dc)
{
bool ret;
@@ -213,7 +213,7 @@ decoder_lock_is_starting(struct decoder_control *dc)
}
static inline bool
-decoder_lock_has_failed(struct decoder_control *dc)
+decoder_lock_has_failed(DecoderControl *dc)
{
bool ret;
@@ -225,7 +225,7 @@ decoder_lock_has_failed(struct decoder_control *dc)
}
static inline const struct song *
-decoder_current_song(const struct decoder_control *dc)
+decoder_current_song(const DecoderControl *dc)
{
switch (dc->state) {
case DECODE_STATE_STOP:
@@ -251,26 +251,26 @@ decoder_current_song(const struct decoder_control *dc)
* @param pipe the pipe which receives the decoded chunks (owned by
* the caller)
*/
-void dc_start(struct decoder_control *dc, struct song *song,
+void dc_start(DecoderControl *dc, struct song *song,
unsigned start_ms, unsigned end_ms,
int buffer_samples, struct music_pipe *pipe);
void
-dc_stop(struct decoder_control *dc);
+dc_stop(DecoderControl *dc);
bool
-dc_seek(struct decoder_control *dc, double where);
+dc_seek(DecoderControl *dc, double where);
void
-dc_quit(struct decoder_control *dc);
+dc_quit(DecoderControl *dc);
void
-dc_mixramp_start(struct decoder_control *dc, char *mixramp_start);
+dc_mixramp_start(DecoderControl *dc, char *mixramp_start);
void
-dc_mixramp_end(struct decoder_control *dc, char *mixramp_end);
+dc_mixramp_end(DecoderControl *dc, char *mixramp_end);
void
-dc_mixramp_prev_end(struct decoder_control *dc, char *mixramp_prev_end);
+dc_mixramp_prev_end(DecoderControl *dc, char *mixramp_prev_end);
#endif
diff --git a/src/decoder/decoder_internal.c b/src/decoder/decoder_internal.c
index 3d62ea30..ae9f82bc 100644
--- a/src/decoder/decoder_internal.c
+++ b/src/decoder/decoder_internal.c
@@ -31,7 +31,7 @@
* one.
*/
static enum decoder_command
-need_chunks(struct decoder_control *dc, bool do_wait)
+need_chunks(DecoderControl *dc, bool do_wait)
{
if (dc->command == DECODE_COMMAND_STOP ||
dc->command == DECODE_COMMAND_SEEK)
@@ -49,7 +49,7 @@ need_chunks(struct decoder_control *dc, bool do_wait)
struct music_chunk *decoder_get_chunk(struct decoder *decoder)
{
- struct decoder_control *dc = decoder->dc;
+ DecoderControl *dc = decoder->dc;
struct music_chunk *chunk;
enum decoder_command cmd;
diff --git a/src/decoder/decoder_internal.h b/src/decoder/decoder_internal.h
index 853fd72b..0cd58ac5 100644
--- a/src/decoder/decoder_internal.h
+++ b/src/decoder/decoder_internal.h
@@ -21,13 +21,14 @@
#define MPD_DECODER_INTERNAL_H
#include "decoder_command.h"
+#include "decoder_control.h"
#include "pcm_convert.h"
#include "replay_gain_info.h"
struct input_stream;
struct decoder {
- struct decoder_control *dc;
+ DecoderControl *dc;
struct pcm_convert_state conv_state;
@@ -85,7 +86,6 @@ struct decoder {
*
* @return the chunk, or NULL if we have received a decoder command
*/
-struct music_chunk *
-decoder_get_chunk(struct decoder *decoder);
+struct music_chunk * decoder_get_chunk(struct decoder *decoder);
#endif
diff --git a/src/decoder/decoder_thread.c b/src/decoder/decoder_thread.c
index 59ff26db..8972a82c 100644
--- a/src/decoder/decoder_thread.c
+++ b/src/decoder/decoder_thread.c
@@ -49,7 +49,7 @@
* @param dc the #decoder_control object; must be locked
*/
static void
-decoder_command_finished_locked(struct decoder_control *dc)
+decoder_command_finished_locked(DecoderControl *dc)
{
assert(dc->command != DECODE_COMMAND_NONE);
@@ -70,7 +70,7 @@ decoder_command_finished_locked(struct decoder_control *dc)
* received, NULL on error
*/
static struct input_stream *
-decoder_input_stream_open(struct decoder_control *dc, const char *uri)
+decoder_input_stream_open(DecoderControl *dc, const char *uri)
{
GError *error = NULL;
struct input_stream *is;
@@ -278,7 +278,7 @@ decoder_run_stream_fallback(struct decoder *decoder, struct input_stream *is)
static bool
decoder_run_stream(struct decoder *decoder, const char *uri)
{
- struct decoder_control *dc = decoder->dc;
+ DecoderControl *dc = decoder->dc;
struct input_stream *input_stream;
bool success;
@@ -332,7 +332,7 @@ decoder_load_replay_gain(struct decoder *decoder, const char *path_fs)
static bool
decoder_run_file(struct decoder *decoder, const char *path_fs)
{
- struct decoder_control *dc = decoder->dc;
+ DecoderControl *dc = decoder->dc;
const char *suffix = uri_get_suffix(path_fs);
const struct decoder_plugin *plugin = NULL;
@@ -380,7 +380,7 @@ decoder_run_file(struct decoder *decoder, const char *path_fs)
}
static void
-decoder_run_song(struct decoder_control *dc,
+decoder_run_song(DecoderControl *dc,
const struct song *song, const char *uri)
{
struct decoder decoder = {
@@ -426,7 +426,7 @@ decoder_run_song(struct decoder_control *dc,
}
static void
-decoder_run(struct decoder_control *dc)
+decoder_run(DecoderControl *dc)
{
const struct song *song = dc->song;
char *uri;
@@ -452,7 +452,7 @@ decoder_run(struct decoder_control *dc)
static gpointer
decoder_task(gpointer arg)
{
- struct decoder_control *dc = arg;
+ DecoderControl *dc = arg;
decoder_lock(dc);
@@ -491,7 +491,7 @@ decoder_task(gpointer arg)
}
void
-decoder_thread_start(struct decoder_control *dc)
+decoder_thread_start(DecoderControl *dc)
{
GError *e = NULL;
diff --git a/src/decoder/decoder_thread.h b/src/decoder/decoder_thread.h
index 78f12a54..588f8505 100644
--- a/src/decoder/decoder_thread.h
+++ b/src/decoder/decoder_thread.h
@@ -20,9 +20,8 @@
#ifndef MPD_DECODER_THREAD_H
#define MPD_DECODER_THREAD_H
-struct decoder_control;
+#include "decoder_control.h"
-void
-decoder_thread_start(struct decoder_control *dc);
+void decoder_thread_start(DecoderControl *dc);
#endif
diff --git a/src/player_control.c b/src/player_control.c
index 29d1e12d..ce66581a 100644
--- a/src/player_control.c
+++ b/src/player_control.c
@@ -64,7 +64,7 @@ pc_free(struct player_control *pc)
}
void
-player_wait_decoder(struct player_control *pc, struct decoder_control *dc)
+player_wait_decoder(struct player_control *pc, DecoderControl *dc)
{
assert(pc != NULL);
assert(dc != NULL);
diff --git a/src/player_control.h b/src/player_control.h
index 5a04ab0f..1424a485 100644
--- a/src/player_control.h
+++ b/src/player_control.h
@@ -21,13 +21,12 @@
#define MPD_PLAYER_H
#include "audio_format.h"
+#include "decoder/decoder_control.h"
#include <glib.h>
#include <stdint.h>
-struct decoder_control;
-
enum player_state {
PLAYER_STATE_STOP = 0,
PLAYER_STATE_PAUSE,
@@ -160,7 +159,7 @@ player_wait(struct player_control *pc)
* Note the small difference to the player_wait() function!
*/
void
-player_wait_decoder(struct player_control *pc, struct decoder_control *dc);
+player_wait_decoder(struct player_control *pc, DecoderControl *dc);
/**
* Signals the #player_control object. The object should be locked
diff --git a/src/player_thread.c b/src/player_thread.c
index 4a45e3af..302b38d1 100644
--- a/src/player_thread.c
+++ b/src/player_thread.c
@@ -52,7 +52,7 @@ enum xfade_state {
struct player {
struct player_control *pc;
- struct decoder_control *dc;
+ DecoderControl *dc;
struct music_pipe *pipe;
@@ -152,7 +152,7 @@ player_command_finished(struct player_control *pc)
static void player_dc_start(struct player *player, struct music_pipe *pipe)
{
struct player_control *pc = player->pc;
- struct decoder_control *dc = player->dc;
+ DecoderControl *dc = player->dc;
assert(player->queued || pc->command == PLAYER_COMMAND_SEEK);
assert(pc->next_song != NULL);
@@ -200,7 +200,7 @@ player_dc_at_next_song(const struct player *player)
static void
player_dc_stop(struct player *player)
{
- struct decoder_control *dc = player->dc;
+ DecoderControl *dc = player->dc;
dc_stop(dc);
@@ -227,7 +227,7 @@ static bool
player_wait_for_decoder(struct player *player)
{
struct player_control *pc = player->pc;
- struct decoder_control *dc = player->dc;
+ DecoderControl *dc = player->dc;
assert(player->queued || pc->command == PLAYER_COMMAND_SEEK);
assert(pc->next_song != NULL);
@@ -340,7 +340,7 @@ static bool
player_check_decoder_startup(struct player *player)
{
struct player_control *pc = player->pc;
- struct decoder_control *dc = player->dc;
+ DecoderControl *dc = player->dc;
assert(player->decoder_starting);
@@ -457,7 +457,7 @@ static bool player_seek_decoder(struct player *player)
{
struct player_control *pc = player->pc;
struct song *song = pc->next_song;
- struct decoder_control *dc = player->dc;
+ DecoderControl *dc = player->dc;
assert(pc->next_song != NULL);
@@ -535,7 +535,7 @@ static bool player_seek_decoder(struct player *player)
static void player_process_command(struct player *player)
{
struct player_control *pc = player->pc;
- G_GNUC_UNUSED struct decoder_control *dc = player->dc;
+ G_GNUC_UNUSED DecoderControl *dc = player->dc;
switch (pc->command) {
case PLAYER_COMMAND_NONE:
@@ -696,7 +696,7 @@ static bool
play_next_chunk(struct player *player)
{
struct player_control *pc = player->pc;
- struct decoder_control *dc = player->dc;
+ DecoderControl *dc = player->dc;
if (!audio_output_all_wait(pc, 64 * 2048))
/* the output pipe is still large enough, don't send
@@ -857,7 +857,7 @@ player_song_border(struct player *player)
* basically a state machine, which multiplexes data between the
* decoder thread and the output threads.
*/
-static void do_play(struct player_control *pc, struct decoder_control *dc)
+static void do_play(struct player_control *pc, DecoderControl *dc)
{
struct player player = {
.pc = pc,
@@ -1063,7 +1063,7 @@ player_task(gpointer arg)
{
struct player_control *pc = arg;
- struct decoder_control *dc = dc_new(pc->cond);
+ DecoderControl *dc = dc_new(pc->cond);
decoder_thread_start(dc);
player_lock(pc);