aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-04-12 04:18:43 +0000
committerEric Wong <normalperson@yhbt.net>2008-04-12 04:18:43 +0000
commit7642d10fe90f77e21addbbbdfb02d95494655bc2 (patch)
tree97af5a42fb35747553f6c97e9a39701e0d7c20fc
parentf2cdac6ee7a338ace92c6e884f65b9f89841970e (diff)
downloadmpd-7642d10fe90f77e21addbbbdfb02d95494655bc2.tar.gz
mpd-7642d10fe90f77e21addbbbdfb02d95494655bc2.tar.xz
mpd-7642d10fe90f77e21addbbbdfb02d95494655bc2.zip
pass DecoderControl object to decoder_sleep()
Less global variables: at any invocation of decoder_sleep(), we have a reference to the DecoderControl anyway, so we should pass it. This costs less than having to call getPlayerData() in every tiny function. Maybe some day we will be able to have multiple decoders at the same time... git-svn-id: https://svn.musicpd.org/mpd/trunk@7316 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/decode.c27
-rw-r--r--src/decode.h2
-rw-r--r--src/outputBuffer.c2
3 files changed, 14 insertions, 17 deletions
diff --git a/src/decode.c b/src/decode.c
index 57bc9a65c..142cc46cc 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -36,23 +36,20 @@ void decoder_wakeup_player(void)
wakeup_player_nb();
}
-void decoder_sleep(void)
+void decoder_sleep(DecoderControl * dc)
{
- DecoderControl *dc = &(getPlayerData()->decoderControl);
notifyWait(&dc->notify);
wakeup_player_nb();
}
-static void player_wakeup_decoder_nb(void)
+static void player_wakeup_decoder_nb(DecoderControl * dc)
{
- DecoderControl *dc = &(getPlayerData()->decoderControl);
notifySignal(&dc->notify);
}
/* called from player_task */
-static void player_wakeup_decoder(void)
+static void player_wakeup_decoder(DecoderControl * dc)
{
- DecoderControl *dc = &(getPlayerData()->decoderControl);
notifySignal(&dc->notify);
player_sleep();
}
@@ -61,7 +58,7 @@ static void stopDecode(DecoderControl * dc)
{
if (dc->start || dc->state != DECODE_STATE_STOP) {
dc->stop = 1;
- do { player_wakeup_decoder_nb(); } while (dc->stop);
+ do { player_wakeup_decoder_nb(dc); } while (dc->stop);
}
}
@@ -105,7 +102,7 @@ static int waitOnDecode(PlayerControl * pc, DecoderControl * dc,
OutputBuffer * cb, int *decodeWaitedOn)
{
while (dc->start)
- player_wakeup_decoder();
+ player_wakeup_decoder(dc);
if (dc->error != DECODE_ERROR_NOERROR) {
pc->errored_song = pc->current_song;
@@ -146,7 +143,7 @@ static int decodeSeek(PlayerControl * pc, DecoderControl * dc,
dc->seekWhere = 0 > dc->seekWhere ? 0 : dc->seekWhere;
dc->seekError = 0;
dc->seek = 1;
- do { player_wakeup_decoder(); } while (dc->seek);
+ do { player_wakeup_decoder(dc); } while (dc->seek);
if (!dc->seekError) {
pc->elapsedTime = dc->seekWhere;
ret = 0;
@@ -333,7 +330,7 @@ static void * decoder_task(mpd_unused void *unused)
{
OutputBuffer *cb = &(getPlayerData()->buffer);
PlayerControl *pc = &(getPlayerData()->playerControl);
- DecoderControl *dc = &(getPlayerData()->decoderControl);
+ DecoderControl * dc = &(getPlayerData()->decoderControl);
notifyEnter(&dc->notify);
@@ -345,7 +342,7 @@ static void * decoder_task(mpd_unused void *unused)
dc->stop = 0;
decoder_wakeup_player();
} else {
- decoder_sleep();
+ decoder_sleep(dc);
}
}
}
@@ -455,7 +452,7 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
get_song_url(tmp, pc->current_song));
break;
} else {
- player_wakeup_decoder();
+ player_wakeup_decoder(dc);
}
if (do_pause) {
dropBufferedAudio();
@@ -490,7 +487,7 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
dc->start = 1;
pc->queueState = PLAYER_QUEUE_DECODE;
wakeup_main_task();
- player_wakeup_decoder_nb();
+ player_wakeup_decoder_nb(dc);
}
if (next >= 0 && doCrossFade == 0 && !dc->start &&
dc->state != DECODE_STATE_START) {
@@ -558,7 +555,7 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
sizeToTime) < 0)
break;
outputBufferShift(cb);
- player_wakeup_decoder_nb();
+ player_wakeup_decoder_nb(dc);
} else if (!outputBufferEmpty(cb) && (int)cb->begin == next) {
/* at the beginning of a new song */
@@ -618,7 +615,7 @@ void decode(void)
dc->seek = 0;
dc->stop = 0;
dc->start = 1;
- do { player_wakeup_decoder(); } while (dc->start);
+ do { player_wakeup_decoder(dc); } while (dc->start);
decodeParent(pc, dc, cb);
}
diff --git a/src/decode.h b/src/decode.h
index ed9a25081..702c0322d 100644
--- a/src/decode.h
+++ b/src/decode.h
@@ -61,7 +61,7 @@ void decode(void);
void decoder_wakeup_player(void);
-void decoder_sleep(void);
+void decoder_sleep(DecoderControl * dc);
void decoderInit(void);
diff --git a/src/outputBuffer.c b/src/outputBuffer.c
index de649e0c7..1f33ad7c2 100644
--- a/src/outputBuffer.c
+++ b/src/outputBuffer.c
@@ -147,7 +147,7 @@ static int tailChunk(OutputBuffer * cb, InputStream * inStream,
}
if (!inStream ||
bufferInputStream(inStream) <= 0) {
- decoder_sleep();
+ decoder_sleep(dc);
}
}
if (dc->stop)