Commit e566c4c6 authored by Eric Wong's avatar Eric Wong

decode: fix unsigned comparision and add some paranoid assertions

git-svn-id: https://svn.musicpd.org/mpd/trunk@7301 09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent f275a1a1
......@@ -79,24 +79,25 @@ static void quitDecode(PlayerControl * pc, DecoderControl * dc)
static unsigned calculateCrossFadeChunks(PlayerControl * pc, AudioFormat * af,
float totalTime)
{
long chunks;
unsigned chunks;
if (pc->crossFade <= 0 || pc->crossFade >= totalTime ||
if (pc->crossFade == 0 || pc->crossFade >= totalTime ||
!isCurrentAudioFormat(af))
return 0;
assert(pc->crossFade > 0);
assert(af->bits > 0);
assert(af->channels > 0);
assert(af->sampleRate > 0);
chunks = (af->sampleRate * af->bits * af->channels / 8.0 / CHUNK_SIZE);
chunks = (chunks * pc->crossFade + 0.5);
assert(buffered_chunks >= buffered_before_play);
if (chunks > (buffered_chunks - buffered_before_play)) {
if (chunks > (buffered_chunks - buffered_before_play))
chunks = buffered_chunks - buffered_before_play;
}
if (chunks < 0)
chunks = 0;
return (unsigned)chunks;
return chunks;
}
static int waitOnDecode(PlayerControl * pc, DecoderControl * dc,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment