Skip to content

Commit

Permalink
audio: better way to calculate buffer drain wait times.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Oct 7, 2016
1 parent 76f48ac commit 551cdc8
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/audio/SDL_audio.c
Expand Up @@ -1152,9 +1152,8 @@ close_audio_device(SDL_AudioDevice * device)
Uint32 delay = 0;

if (!device->iscapture) {
/* x2000: x1000 (cvt to ms) and x2 (alternating DMA buffers). */
const SDL_AudioSpec *spec = &device->spec;
delay = (Uint32) ((((float)spec->samples) / ((float)spec->freq)) * 2000.0f);
delay = ((spec.samples * 1000) / spec.freq) * 2;
}

/* Lock to make sure an audio callback doesn't fire after we return.
Expand All @@ -1170,7 +1169,6 @@ close_audio_device(SDL_AudioDevice * device)
if (delay > 0) {
/* Block the amount that is roughly pending for playback, so we
don't drop audio if the process exits right after this call. */
printf("audio close: delay for %u ms\n", (unsigned int) delay);
SDL_Delay(delay);
}
}
Expand Down

0 comments on commit 551cdc8

Please sign in to comment.