We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1013 - Mix_CloseAudio() takes 2 seconds to run
Summary: Mix_CloseAudio() takes 2 seconds to run
Status: RESOLVED INVALID
Alias: None
Product: SDL_mixer
Classification: Unclassified
Component: misc (show other bugs)
Version: 1.2.8
Hardware: x86 Linux
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-30 08:33 UTC by Jacques Le Normand
Modified: 2012-01-01 01:53 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jacques Le Normand 2010-06-30 08:33:59 UTC
// This code takes 2 seconds to run; it will output "2 seconds to close"
//	g++ -Wall -I/usr/include/SDL test.cpp -o test.o -lSDL_mixer

#include <iostream>
#include <ctime>
#include <SDL/SDL_mixer.h>

int main(){
  int audio_rate = 44100;
  int audio_buffers = 1024;
  Uint16 audio_format = AUDIO_S16SYS;
  int audio_channels = 1;
  Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers);      
  time_t a = time(NULL);
  Mix_CloseAudio();
  time_t b = time(NULL);
  std::cout << difftime(b,a) << " seconds to close" << std::endl;
  return 0;
}
Comment 1 Ryan C. Gordon 2011-08-24 23:41:54 UTC
I assume this is on Linux, right?

This isn't SDL_Mixer, it's SDL's pulseaudio (and maybe ALSA) target. We wait for all audio we wanted to play to finish (so it doesn't cut off the end), but the Pulse API is blocking too long in its drain operation.

--ryan.
Comment 2 Ryan C. Gordon 2012-01-01 01:53:31 UTC
Having looked into this a bit more, it's actually not our bug, it's PulseAudio's:

   http://pulseaudio.org/ticket/866

(Using "ALSA" on modern versions of Ubuntu just reroutes your audio through PulseAudio, so you can't even get below the PulseAudio layer by default anymore...)

--ryan.