Skip to content

Commit

Permalink
Fixed blocking open bug when using blocking audio writes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Lantinga committed Jul 9, 2001
1 parent 49d718e commit 05b3bb9
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/audio/dsp/SDL_dspaudio.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 05b3bb9

Please sign in to comment.