X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=snd_modplug.c;h=596b38ff75ab7d8e3a85da14a225dc285c6bd2b9;hb=5bc48d9464fea386c50754dac15fcf0d2c3ad200;hp=ec14ce95cd029edae5a1f50cf6aec971872f82e4;hpb=9f5dc5b8171bfb05a239c1e2a2cb041574c746d2;p=xonotic%2Fdarkplaces.git diff --git a/snd_modplug.c b/snd_modplug.c index ec14ce95..596b38ff 100644 --- a/snd_modplug.c +++ b/snd_modplug.c @@ -341,10 +341,10 @@ static const snd_buffer_t* ModPlug_FetchSound (void *sfxfetcher, void **chfetche // 1- to ensure we won't lose many samples during the resampling process // 2- to reduce calls to ModPlug_FetchSound to regulate workload newlength = (int)(per_sfx->format.speed*STREAM_BUFFER_FILL); - if (newlength + sb->nbframes > sb->maxframes) + if ((size_t) ((double) newlength * (double)sb->format.speed / (double)per_sfx->format.speed) + sb->nbframes > sb->maxframes) { - Con_Printf ("ModPlug_FetchSound: stream buffer overflow (%u sample frames / %u)\n", - sb->format.speed + sb->nbframes, sb->maxframes); + Con_Printf ("ModPlug_FetchSound: stream buffer overflow (%u + %u = %u sample frames / %u)\n", + (unsigned int) ((double) newlength * (double)sb->format.speed / (double)per_sfx->format.speed), sb->nbframes, (unsigned int) ((double) newlength * (double)sb->format.speed / (double)per_sfx->format.speed) + sb->nbframes, sb->maxframes); return NULL; } newlength *= factor; // convert from sample frames to bytes