From 72eba30cf442994c732c135cb77c917f534ff1d7 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 8 Nov 2008 15:48:00 +0100 Subject: decoder: converted dc.error to a dc.state value The player did not care about the exact error value, it only checked whether an error has occured. This could fit well into decoder_control.state - introduce a new state "DECODE_STATE_ERROR". --- src/decoder_thread.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'src/decoder_thread.c') diff --git a/src/decoder_thread.c b/src/decoder_thread.c index 7c870d6e7..23a947d77 100644 --- a/src/decoder_thread.c +++ b/src/decoder_thread.c @@ -61,13 +61,13 @@ static void decoder_run(void) else uri = song_get_url(song, buffer); if (uri == NULL) { - dc.error = DECODE_ERROR_FILE; + dc.state = DECODE_STATE_ERROR; return; } dc.current_song = dc.next_song; /* NEED LOCK */ if (!input_stream_open(&input_stream, uri)) { - dc.error = DECODE_ERROR_FILE; + dc.state = DECODE_STATE_ERROR; return; } @@ -84,19 +84,21 @@ static void decoder_run(void) while (!input_stream.ready) { if (dc.command != DECODE_COMMAND_NONE) { input_stream_close(&input_stream); + dc.state = DECODE_STATE_STOP; return; } ret = input_stream_buffer(&input_stream); if (ret < 0) { input_stream_close(&input_stream); - dc.error = DECODE_ERROR_FILE; + dc.state = DECODE_STATE_ERROR; return; } } if (dc.command == DECODE_COMMAND_STOP) { input_stream_close(&input_stream); + dc.state = DECODE_STATE_STOP; return; } @@ -161,27 +163,23 @@ static void decoder_run(void) music_pipe_flush(); - if (!ret) { - dc.error = plugin == NULL - ? DECODE_ERROR_UNKTYPE - : DECODE_ERROR_FILE; - } - if (close_instream) input_stream_close(&input_stream); + + dc.state = ret ? DECODE_STATE_STOP : DECODE_STATE_ERROR; } static void * decoder_task(mpd_unused void *arg) { while (1) { - assert(dc.state == DECODE_STATE_STOP); + assert(dc.state == DECODE_STATE_STOP || + dc.state == DECODE_STATE_ERROR); switch (dc.command) { case DECODE_COMMAND_START: case DECODE_COMMAND_SEEK: decoder_run(); - dc.state = DECODE_STATE_STOP; dc.command = DECODE_COMMAND_NONE; notify_signal(&pc.notify); break; -- cgit v1.2.3