aboutsummaryrefslogtreecommitdiffstats
path: root/src/decode.h
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2008-08-16 09:28:15 -0700
committerEric Wong <normalperson@yhbt.net>2008-08-16 09:39:32 -0700
commit44d9f62f34e0561d83ea32941f0ea1b529b1490d (patch)
tree5345eba046b6e3bcf8c063e7bae8b501b7a99f4a /src/decode.h
parentf9f70860622613686e6ac0bf7ebd448f437d92a7 (diff)
downloadmpd-44d9f62f34e0561d83ea32941f0ea1b529b1490d.tar.gz
mpd-44d9f62f34e0561d83ea32941f0ea1b529b1490d.tar.xz
mpd-44d9f62f34e0561d83ea32941f0ea1b529b1490d.zip
core rewrite (decode,player,outputBuffer,playlist)
This is a huge refactoring of the core mpd process. The queueing/buffering mechanism is heavily reworked. The player.c code has been merged into outputBuffer (the actual ring buffering logic is handled by ringbuf.c); and decode.c actually handles decoding stuff. The end result is several hundreds of lines shorter, even though we still have a lot of DEBUG statements left in there for tracing and a lot of assertions, too.
Diffstat (limited to '')
-rw-r--r--src/decode.h59
1 files changed, 33 insertions, 26 deletions
diff --git a/src/decode.h b/src/decode.h
index 8ee2a095f..b1ba138e2 100644
--- a/src/decode.h
+++ b/src/decode.h
@@ -22,43 +22,50 @@
#include "song.h"
#include "audio.h"
-#include "notify.h"
+#include "condition.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 dc_action {
+ DC_ACTION_NONE = 0,
+ DC_ACTION_START,
+ DC_ACTION_SEEK, /* like start, but clears previously decoded audio */
+ DC_ACTION_STOP,
+ DC_ACTION_QUIT
};
-#define DECODE_ERROR_NOERROR 0
-#define DECODE_ERROR_UNKTYPE 10
-#define DECODE_ERROR_FILE 20
+/* only changeable by dc.thread */
+enum dc_state {
+ DC_STATE_STOP = 0, /* decoder stopped (no song) */
+ DC_STATE_DECODE, /* open() + {file,stream}DecodeFunc (+ paused) */
+ DC_STATE_QUIT /* NIH, the pthread cancellation API blows... */
+};
-typedef struct _DecoderControl {
- Notify notify;
+struct decoder_control {
+ Song * current_song; /* only needed for wavpack, remove? */
+ enum dc_state state; /* rw=dc.thread, r=main */
+ enum dc_action action; /* rw protected by action_cond */
+ float total_time; /* w=dc.thread, r=main */
+ float seek_where; /* -1 == error, rw protected by action_cond */
+ pthread_t thread;
+ AudioFormat audio_format; /* w=dc.thread, r=all */
+};
- volatile enum decoder_state state;
- volatile mpd_sint8 stop;
- volatile mpd_sint8 start;
- volatile mpd_uint16 error;
- volatile mpd_sint8 seek;
- volatile mpd_sint8 seekError;
- volatile mpd_sint8 seekable;
- volatile double seekWhere;
- AudioFormat audioFormat;
- Song *current_song;
- volatile float totalTime;
-} DecoderControl;
+extern struct decoder_control dc;
-void decode(void);
+void dc_trigger_action(enum dc_action action, float seek_where);
+void decoder_init(void);
+int dc_try_unhalt(void);
+void dc_halt(void);
-void decoder_wakeup_player(void);
+void dc_action_begin(void);
+void dc_action_end(void);
-void decoder_sleep(void);
+int dc_intr(void);
+int dc_seek(void);
-void decoderInit(void);
+enum seek_err_type { DC_SEEK_MISMATCH = -2, DC_SEEK_ERROR = -1 };
+void dc_action_seek_fail(enum seek_err_type);
#endif