From 7ee436b435e7383a8c39b44c1fc6f0b65358e83e Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 12 Apr 2008 04:12:21 +0000 Subject: 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 --- src/decode.c | 83 +++++++++++++++++++++++++++++------------------------------- 1 file changed, 40 insertions(+), 43 deletions(-) (limited to 'src/decode.c') 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) { -- cgit v1.2.3