diff options
Diffstat (limited to '')
-rw-r--r-- | src/DecoderControl.cxx (renamed from src/decoder_control.c) | 44 |
1 files changed, 39 insertions, 5 deletions
diff --git a/src/decoder_control.c b/src/DecoderControl.cxx index 2ce03b666..2ffaf116f 100644 --- a/src/decoder_control.c +++ b/src/DecoderControl.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2011 The Music Player Daemon Project + * Copyright (C) 2003-2013 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -18,8 +18,9 @@ */ #include "config.h" -#include "decoder_control.h" -#include "pipe.h" +#include "DecoderControl.hxx" +#include "MusicPipe.hxx" +#include "song.h" #include <assert.h> @@ -27,7 +28,7 @@ #define G_LOG_DOMAIN "decoder_control" struct decoder_control * -dc_new(GCond *client_cond) +dc_new() { struct decoder_control *dc = g_new(struct decoder_control, 1); @@ -35,11 +36,13 @@ dc_new(GCond *client_cond) dc->mutex = g_mutex_new(); dc->cond = g_cond_new(); - dc->client_cond = client_cond; + dc->client_cond = g_cond_new(); dc->state = DECODE_STATE_STOP; dc->command = DECODE_COMMAND_NONE; + dc->song = NULL; + dc->replay_gain_db = 0; dc->replay_gain_prev_db = 0; dc->mixramp_start = NULL; @@ -52,6 +55,12 @@ dc_new(GCond *client_cond) void dc_free(struct decoder_control *dc) { + dc_clear_error(dc); + + if (dc->song != NULL) + song_free(dc->song); + + g_cond_free(dc->client_cond); g_cond_free(dc->cond); g_mutex_free(dc->mutex); g_free(dc->mixramp_start); @@ -79,6 +88,7 @@ static void dc_command(struct decoder_control *dc, enum decoder_command cmd) { decoder_lock(dc); + dc_clear_error(dc); dc_command_locked(dc, cmd); decoder_unlock(dc); } @@ -94,6 +104,27 @@ dc_command_async(struct decoder_control *dc, enum decoder_command cmd) decoder_unlock(dc); } +bool +decoder_is_current_song(const struct decoder_control *dc, + const struct song *song) +{ + assert(dc != NULL); + assert(song != NULL); + + switch (dc->state) { + case DECODE_STATE_STOP: + case DECODE_STATE_ERROR: + return false; + + case DECODE_STATE_START: + case DECODE_STATE_DECODE: + return song_equals(dc->song, song); + } + + assert(false); + return false; +} + void dc_start(struct decoder_control *dc, struct song *song, unsigned start_ms, unsigned end_ms, @@ -104,6 +135,9 @@ dc_start(struct decoder_control *dc, struct song *song, assert(pipe != NULL); assert(music_pipe_empty(pipe)); + if (dc->song != NULL) + song_free(dc->song); + dc->song = song; dc->start_ms = start_ms; dc->end_ms = end_ms; |