Skip to content
Permalink
Browse files
Improve sound duration calculation
  • Loading branch information
rickgaiser authored and KrahJohlito committed Jul 5, 2020
1 parent 8b252bf commit 2f5030d649347843406a49e68311e14dc11c4811
Showing with 6 additions and 1 deletion.
  1. +6 −1 src/sound.c
@@ -126,7 +126,12 @@ static int sfxLoad(struct sfxEffect *sfxData, audsrv_adpcm_t *sfx)
{
int ret;

sfxData->duration_ms = sfxCalculateSoundDuration(sfxData->size);
// Calculate duration based on decompressed size
sfxData->duration_ms = sfxCalculateSoundDuration(((u32 *)sfxData->buffer)[3]);
// Estimate duration based on filesize, is the ADPCM header was 0
if (sfxData->duration_ms == 0)
sfxData->duration_ms = sfxData->size / 47;

ret = audsrv_load_adpcm(sfx, sfxData->buffer, sfxData->size);
if (sfxData->builtin == 0) {
free(sfxData->buffer);

0 comments on commit 2f5030d

Please sign in to comment.