aboutsummaryrefslogtreecommitdiffstats
path: root/src/decode.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-04-12 04:12:21 +0000
committerEric Wong <normalperson@yhbt.net>2008-04-12 04:12:21 +0000
commit7ee436b435e7383a8c39b44c1fc6f0b65358e83e (patch)
tree40c4f1849af5a966a68a3861f5b590f05a66c7d3 /src/decode.c
parent753b5cf360e9ddd88ff0e0e3b05b0b107ff5b851 (diff)
downloadmpd-7ee436b435e7383a8c39b44c1fc6f0b65358e83e.tar.gz
mpd-7ee436b435e7383a8c39b44c1fc6f0b65358e83e.tar.xz
mpd-7ee436b435e7383a8c39b44c1fc6f0b65358e83e.zip
integrated macro handleDecodeStart() into caller
Another patch indended to improve the CPP macro hell. This enlarges the function decodeParent(), but it cannot be converted into a standalone function easily, because it references so many local variables. git-svn-id: https://svn.musicpd.org/mpd/trunk@7258 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/decode.c')
-rw-r--r--src/decode.c83
1 files changed, 40 insertions, 43 deletions
diff --git a/src/decode.c b/src/decode.c
index 47dc96882..7e27e49f0 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -96,48 +96,6 @@ static int calculateCrossFadeChunks(PlayerControl * pc, AudioFormat * af)
return (int)chunks;
}
-#define handleDecodeStart() \
- if(decodeWaitedOn) { \
- if(dc->state!=DECODE_STATE_START && \
- dc->error==DECODE_ERROR_NOERROR) \
- { \
- decodeWaitedOn = 0; \
- if(openAudioDevice(&(cb->audioFormat))<0) { \
- char tmp[MPD_PATH_MAX]; \
- pc->errored_song = pc->current_song; \
- pc->error = PLAYER_ERROR_AUDIO; \
- ERROR("problems opening audio device " \
- "while playing \"%s\"\n", \
- get_song_url(tmp, pc->current_song)); \
- quitDecode(pc,dc); \
- return; \
- } else { \
- player_wakeup_decoder(); \
- } \
- if (pause) { \
- dropBufferedAudio(); \
- closeAudioDevice(); \
- } \
- pc->totalTime = dc->totalTime; \
- pc->sampleRate = dc->audioFormat.sampleRate; \
- pc->bits = dc->audioFormat.bits; \
- pc->channels = dc->audioFormat.channels; \
- sizeToTime = 8.0/cb->audioFormat.bits/ \
- cb->audioFormat.channels/ \
- cb->audioFormat.sampleRate; \
- } \
- else if(dc->state!=DECODE_STATE_START) { \
- pc->errored_song = pc->current_song; \
- pc->error = PLAYER_ERROR_FILE; \
- quitDecode(pc,dc); \
- return; \
- } \
- else { \
- player_sleep(); \
- continue; \
- } \
- }
-
static int waitOnDecode(PlayerControl * pc, DecoderControl * dc,
OutputBuffer * cb, int *decodeWaitedOn)
{
@@ -451,7 +409,46 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
return;
}
- handleDecodeStart();
+ if (decodeWaitedOn) {
+ if(dc->state!=DECODE_STATE_START &&
+ dc->error==DECODE_ERROR_NOERROR) {
+ decodeWaitedOn = 0;
+ if(openAudioDevice(&(cb->audioFormat))<0) {
+ char tmp[MPD_PATH_MAX];
+ pc->errored_song = pc->current_song;
+ pc->error = PLAYER_ERROR_AUDIO;
+ ERROR("problems opening audio device "
+ "while playing \"%s\"\n",
+ get_song_url(tmp, pc->current_song));
+ quitDecode(pc,dc);
+ return;
+ } else {
+ player_wakeup_decoder();
+ }
+ if (pause) {
+ dropBufferedAudio();
+ closeAudioDevice();
+ }
+ pc->totalTime = dc->totalTime;
+ pc->sampleRate = dc->audioFormat.sampleRate;
+ pc->bits = dc->audioFormat.bits;
+ pc->channels = dc->audioFormat.channels;
+ sizeToTime = 8.0/cb->audioFormat.bits/
+ cb->audioFormat.channels/
+ cb->audioFormat.sampleRate;
+ }
+ else if(dc->state!=DECODE_STATE_START) {
+ pc->errored_song = pc->current_song;
+ pc->error = PLAYER_ERROR_FILE;
+ quitDecode(pc,dc);
+ return;
+ }
+ else {
+ player_sleep();
+ continue;
+ }
+ }
+
if (dc->state == DECODE_STATE_STOP &&
pc->queueState == PLAYER_QUEUE_FULL &&
pc->queueLockState == PLAYER_QUEUE_UNLOCKED) {