Fixed blocking open bug when using blocking audio writes
authorSam Lantinga <slouken@lokigames.com>
Mon, 09 Jul 2001 15:46:41 +0000
changeset 96799bea5504e2
parent 95 d84a06e0c358
child 97 c7bcdece4845
Fixed blocking open bug when using blocking audio writes
src/audio/dsp/SDL_dspaudio.c
     1.1 --- a/src/audio/dsp/SDL_dspaudio.c	Sun Jul 08 09:03:47 2001 +0000
     1.2 +++ b/src/audio/dsp/SDL_dspaudio.c	Mon Jul 09 15:46:41 2001 +0000
     1.3 @@ -58,11 +58,7 @@
     1.4  
     1.5  /* Open the audio device for playback, and don't block if busy */
     1.6  #define USE_BLOCKING_WRITES
     1.7 -#ifdef USE_BLOCKING_WRITES
     1.8 -#define OPEN_FLAGS	O_WRONLY
     1.9 -#else
    1.10  #define OPEN_FLAGS	(O_WRONLY|O_NONBLOCK)
    1.11 -#endif
    1.12  
    1.13  /* Audio driver functions */
    1.14  static int DSP_OpenAudio(_THIS, SDL_AudioSpec *spec);
    1.15 @@ -339,6 +335,18 @@
    1.16  	}
    1.17  	mixbuf = NULL;
    1.18  
    1.19 +#ifdef USE_BLOCKING_WRITES
    1.20 +	/* Make the file descriptor use blocking writes with fcntl() */
    1.21 +	{ long flags;
    1.22 +		flags = fcntl(audio_fd, F_GETFL);
    1.23 +		flags &= ~O_NONBLOCK;
    1.24 +		if ( fcntl(audio_fd, F_SETFL, flags) < 0 ) {
    1.25 +			SDL_SetError("Couldn't set audio blocking mode");
    1.26 +			return(-1);
    1.27 +		}
    1.28 +	}
    1.29 +#endif
    1.30 +
    1.31  	/* Get a list of supported hardware formats */
    1.32  	if ( ioctl(audio_fd, SNDCTL_DSP_GETFMTS, &value) < 0 ) {
    1.33  		SDL_SetError("Couldn't get audio format list");