aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-08-26 08:29:35 +0200
committerMax Kellermann <max@duempel.org>2008-08-26 08:29:35 +0200
commit70904adf18611348b3cefdda9aae437442ba90a8 (patch)
treebfc89dc15154e24fb14e8d2bd9c2848fcc65e70c /src
parenta1ce999978adb716bec99ac259faf20d88306443 (diff)
downloadmpd-70904adf18611348b3cefdda9aae437442ba90a8.tar.gz
mpd-70904adf18611348b3cefdda9aae437442ba90a8.tar.xz
mpd-70904adf18611348b3cefdda9aae437442ba90a8.zip
hide DecoderControl accesses in inline functions
Unfortunately, we have to pass the DecoderControl pointer to these inline functions, because the global variable "dc" may not be available here. This will be fixed later.
Diffstat (limited to '')
-rw-r--r--src/decode.h21
-rw-r--r--src/player_thread.c16
2 files changed, 27 insertions, 10 deletions
diff --git a/src/decode.h b/src/decode.h
index f68507d3f..ba6193a99 100644
--- a/src/decode.h
+++ b/src/decode.h
@@ -61,6 +61,27 @@ typedef struct _DecoderControl {
void decoderInit(void);
+static inline int decoder_is_idle(DecoderControl *dc)
+{
+ return dc->state == DECODE_STATE_STOP &&
+ dc->command != DECODE_COMMAND_START;
+}
+
+static inline int decoder_is_starting(DecoderControl *dc)
+{
+ return dc->command == DECODE_COMMAND_START ||
+ dc->state == DECODE_STATE_START;
+}
+
+static inline Song *decoder_current_song(DecoderControl *dc)
+{
+ if (dc->state == DECODE_STATE_STOP ||
+ dc->error != DECODE_ERROR_NOERROR)
+ return NULL;
+
+ return dc->current_song;
+}
+
void dc_command_wait(Notify *notify);
void dc_start(Notify *notify, Song *song);
diff --git a/src/player_thread.c b/src/player_thread.c
index 6f0828f93..bdc140852 100644
--- a/src/player_thread.c
+++ b/src/player_thread.c
@@ -65,9 +65,7 @@ static int decodeSeek(int *decodeWaitedOn, int *next)
int ret = -1;
double where;
- if (dc.state == DECODE_STATE_STOP ||
- dc.error != DECODE_ERROR_NOERROR ||
- dc.current_song != pc.next_song) {
+ if (decoder_current_song(&dc) != pc.next_song) {
dc_stop(&pc.notify);
*next = -1;
ob_clear();
@@ -224,7 +222,7 @@ static void decodeParent(void)
pc.error = PLAYER_ERROR_FILE;
break;
}
- else if (dc.state != DECODE_STATE_START) {
+ else if (!decoder_is_starting(&dc)) {
/* the decoder is ready and ok */
decodeWaitedOn = 0;
if(openAudioDevice(&(ob.audioFormat))<0) {
@@ -256,7 +254,7 @@ static void decodeParent(void)
}
}
- if (dc.state == DECODE_STATE_STOP &&
+ if (decoder_is_idle(&dc) &&
pc.queueState == PLAYER_QUEUE_FULL &&
pc.queueLockState == PLAYER_QUEUE_UNLOCKED) {
/* the decoder has finished the current song;
@@ -267,8 +265,7 @@ static void decodeParent(void)
wakeup_main_task();
}
if (next >= 0 && do_xfade == XFADE_UNKNOWN &&
- dc.command != DECODE_COMMAND_START &&
- dc.state != DECODE_STATE_START) {
+ !decoder_is_starting(&dc)) {
/* enable cross fading in this song? if yes,
calculate how many chunks will be required
for it */
@@ -314,7 +311,7 @@ static void decodeParent(void)
} else {
/* there are not enough
decoded chunks yet */
- if (dc.state == DECODE_STATE_STOP) {
+ if (decoder_is_idle(&dc)) {
/* the decoder isn't
running, abort
cross fading */
@@ -362,8 +359,7 @@ static void decodeParent(void)
pc.queueState = PLAYER_QUEUE_EMPTY;
wakeup_main_task();
- } else if (dc.state == DECODE_STATE_STOP &&
- dc.command != DECODE_COMMAND_START) {
+ } else if (decoder_is_idle(&dc)) {
break;
} else {
/*DEBUG("waiting for decoded audio, play silence\n");*/