diff options
author | Max Kellermann <max@duempel.org> | 2008-11-08 15:48:00 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-11-08 15:48:00 +0100 |
commit | 72eba30cf442994c732c135cb77c917f534ff1d7 (patch) | |
tree | 43cdc79105e4cea79296274bca00f67dfd636cb7 /src/decoder_thread.c | |
parent | 8cbdc2667e6f4f3713c329ae21aa3d8ae73fab24 (diff) | |
download | mpd-72eba30cf442994c732c135cb77c917f534ff1d7.tar.gz mpd-72eba30cf442994c732c135cb77c917f534ff1d7.tar.xz mpd-72eba30cf442994c732c135cb77c917f534ff1d7.zip |
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".
Diffstat (limited to '')
-rw-r--r-- | src/decoder_thread.c | 20 |
1 files changed, 9 insertions, 11 deletions
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; |