moved code to playChunk()
Similar to the crossFade() patch: pass chunk objects to playChunk(), simplify decodeParent() by removing clutter. git-svn-id: https://svn.musicpd.org/mpd/trunk@7275 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:

committed by
Eric Wong

parent
2e648b57f3
commit
b009b2a437
30
src/decode.c
30
src/decode.c
@@ -374,6 +374,24 @@ static void crossFade(OutputBufferChunk * a, OutputBufferChunk * b,
|
|||||||
a->chunkSize = b->chunkSize;
|
a->chunkSize = b->chunkSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int playChunk(PlayerControl * pc, OutputBufferChunk * chunk,
|
||||||
|
AudioFormat * format, double sizeToTime)
|
||||||
|
{
|
||||||
|
pc->elapsedTime = chunk->times;
|
||||||
|
pc->bitRate = chunk->bitRate;
|
||||||
|
|
||||||
|
pcm_volumeChange(chunk->data, chunk->chunkSize,
|
||||||
|
format, pc->softwareVolume);
|
||||||
|
|
||||||
|
if (playAudio(chunk->data,
|
||||||
|
chunk->chunkSize) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
pc->totalPlayTime +=
|
||||||
|
sizeToTime * chunk->chunkSize;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb)
|
static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb)
|
||||||
{
|
{
|
||||||
int pause = 0;
|
int pause = 0;
|
||||||
@@ -546,17 +564,9 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* play the current chunk */
|
/* play the current chunk */
|
||||||
pc->elapsedTime = beginChunk->times;
|
if (playChunk(pc, beginChunk, &(cb->audioFormat),
|
||||||
pc->bitRate = beginChunk->bitRate;
|
sizeToTime) < 0)
|
||||||
pcm_volumeChange(beginChunk->data,
|
|
||||||
beginChunk->chunkSize,
|
|
||||||
&(cb->audioFormat),
|
|
||||||
pc->softwareVolume);
|
|
||||||
if (playAudio(beginChunk->data,
|
|
||||||
beginChunk->chunkSize) < 0)
|
|
||||||
break;
|
break;
|
||||||
pc->totalPlayTime +=
|
|
||||||
sizeToTime * beginChunk->chunkSize;
|
|
||||||
outputBufferShift(cb);
|
outputBufferShift(cb);
|
||||||
player_wakeup_decoder_nb();
|
player_wakeup_decoder_nb();
|
||||||
} else if (!outputBufferEmpty(cb) && cb->begin == next) {
|
} else if (!outputBufferEmpty(cb) && cb->begin == next) {
|
||||||
|
Reference in New Issue
Block a user