From 05b3bb9dc9e368ab4a025768ae26410ea3bfce96 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 9 Jul 2001 15:46:41 +0000 Subject: [PATCH] Fixed blocking open bug when using blocking audio writes --- src/audio/dsp/SDL_dspaudio.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/audio/dsp/SDL_dspaudio.c b/src/audio/dsp/SDL_dspaudio.c index 8c560d9fb..82d790be4 100644 --- a/src/audio/dsp/SDL_dspaudio.c +++ b/src/audio/dsp/SDL_dspaudio.c @@ -58,11 +58,7 @@ static char rcsid = /* Open the audio device for playback, and don't block if busy */ #define USE_BLOCKING_WRITES -#ifdef USE_BLOCKING_WRITES -#define OPEN_FLAGS O_WRONLY -#else #define OPEN_FLAGS (O_WRONLY|O_NONBLOCK) -#endif /* Audio driver functions */ static int DSP_OpenAudio(_THIS, SDL_AudioSpec *spec); @@ -339,6 +335,18 @@ static int DSP_OpenAudio(_THIS, SDL_AudioSpec *spec) } mixbuf = NULL; +#ifdef USE_BLOCKING_WRITES + /* Make the file descriptor use blocking writes with fcntl() */ + { long flags; + flags = fcntl(audio_fd, F_GETFL); + flags &= ~O_NONBLOCK; + if ( fcntl(audio_fd, F_SETFL, flags) < 0 ) { + SDL_SetError("Couldn't set audio blocking mode"); + return(-1); + } + } +#endif + /* Get a list of supported hardware formats */ if ( ioctl(audio_fd, SNDCTL_DSP_GETFMTS, &value) < 0 ) { SDL_SetError("Couldn't get audio format list");