aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder_control.h
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-11-08 15:48:00 +0100
committerMax Kellermann <max@duempel.org>2008-11-08 15:48:00 +0100
commit72eba30cf442994c732c135cb77c917f534ff1d7 (patch)
tree43cdc79105e4cea79296274bca00f67dfd636cb7 /src/decoder_control.h
parent8cbdc2667e6f4f3713c329ae21aa3d8ae73fab24 (diff)
downloadmpd-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_control.h42
1 files changed, 30 insertions, 12 deletions
diff --git a/src/decoder_control.h b/src/decoder_control.h
index c710d3038..e9fa449e6 100644
--- a/src/decoder_control.h
+++ b/src/decoder_control.h
@@ -25,19 +25,23 @@
#include "audio_format.h"
#include "notify.h"
+#include <assert.h>
+
#define DECODE_TYPE_FILE 0
#define DECODE_TYPE_URL 1
enum decoder_state {
DECODE_STATE_STOP = 0,
DECODE_STATE_START,
- DECODE_STATE_DECODE
-};
-
-enum decoder_error {
- DECODE_ERROR_NOERROR = 0,
- DECODE_ERROR_UNKTYPE,
- DECODE_ERROR_FILE,
+ DECODE_STATE_DECODE,
+
+ /**
+ * The last "START" command failed, because there was an I/O
+ * error or because no decoder was able to decode the file.
+ * This state will only come after START; once the state has
+ * turned to DECODE, by definition no such error can occur.
+ */
+ DECODE_STATE_ERROR,
};
struct decoder_control {
@@ -45,7 +49,6 @@ struct decoder_control {
volatile enum decoder_state state;
volatile enum decoder_command command;
- volatile enum decoder_error error;
bool seek_error;
bool seekable;
volatile double seek_where;
@@ -69,7 +72,8 @@ void dc_deinit(void);
static inline bool decoder_is_idle(void)
{
- return dc.state == DECODE_STATE_STOP &&
+ return (dc.state == DECODE_STATE_STOP ||
+ dc.state == DECODE_STATE_ERROR) &&
dc.command != DECODE_COMMAND_START;
}
@@ -79,14 +83,28 @@ static inline bool decoder_is_starting(void)
dc.state == DECODE_STATE_START;
}
+static inline bool decoder_has_failed(void)
+{
+ assert(dc.command == DECODE_COMMAND_NONE);
+
+ return dc.state == DECODE_STATE_ERROR;
+}
+
static inline struct song *
decoder_current_song(void)
{
- if (dc.state == DECODE_STATE_STOP ||
- dc.error != DECODE_ERROR_NOERROR)
+ switch (dc.state) {
+ case DECODE_STATE_STOP:
+ case DECODE_STATE_ERROR:
return NULL;
- return dc.current_song;
+ case DECODE_STATE_START:
+ case DECODE_STATE_DECODE:
+ return dc.current_song;
+ }
+
+ assert(false);
+ return NULL;
}
void