Mercurial > sdl-ios-xcode
comparison src/audio/dsp/SDL_dspaudio.c @ 96:799bea5504e2
Fixed blocking open bug when using blocking audio writes
author | Sam Lantinga <slouken@lokigames.com> |
---|---|
date | Mon, 09 Jul 2001 15:46:41 +0000 |
parents | ae6e6b73333f |
children | c7bcdece4845 |
comparison
equal
deleted
inserted
replaced
95:d84a06e0c358 | 96:799bea5504e2 |
---|---|
56 /* The tag name used by DSP audio */ | 56 /* The tag name used by DSP audio */ |
57 #define DSP_DRIVER_NAME "dsp" | 57 #define DSP_DRIVER_NAME "dsp" |
58 | 58 |
59 /* Open the audio device for playback, and don't block if busy */ | 59 /* Open the audio device for playback, and don't block if busy */ |
60 #define USE_BLOCKING_WRITES | 60 #define USE_BLOCKING_WRITES |
61 #ifdef USE_BLOCKING_WRITES | |
62 #define OPEN_FLAGS O_WRONLY | |
63 #else | |
64 #define OPEN_FLAGS (O_WRONLY|O_NONBLOCK) | 61 #define OPEN_FLAGS (O_WRONLY|O_NONBLOCK) |
65 #endif | |
66 | 62 |
67 /* Audio driver functions */ | 63 /* Audio driver functions */ |
68 static int DSP_OpenAudio(_THIS, SDL_AudioSpec *spec); | 64 static int DSP_OpenAudio(_THIS, SDL_AudioSpec *spec); |
69 static void DSP_WaitAudio(_THIS); | 65 static void DSP_WaitAudio(_THIS); |
70 static void DSP_PlayAudio(_THIS); | 66 static void DSP_PlayAudio(_THIS); |
337 SDL_SetError("Couldn't open %s: %s", audiodev, strerror(errno)); | 333 SDL_SetError("Couldn't open %s: %s", audiodev, strerror(errno)); |
338 return(-1); | 334 return(-1); |
339 } | 335 } |
340 mixbuf = NULL; | 336 mixbuf = NULL; |
341 | 337 |
338 #ifdef USE_BLOCKING_WRITES | |
339 /* Make the file descriptor use blocking writes with fcntl() */ | |
340 { long flags; | |
341 flags = fcntl(audio_fd, F_GETFL); | |
342 flags &= ~O_NONBLOCK; | |
343 if ( fcntl(audio_fd, F_SETFL, flags) < 0 ) { | |
344 SDL_SetError("Couldn't set audio blocking mode"); | |
345 return(-1); | |
346 } | |
347 } | |
348 #endif | |
349 | |
342 /* Get a list of supported hardware formats */ | 350 /* Get a list of supported hardware formats */ |
343 if ( ioctl(audio_fd, SNDCTL_DSP_GETFMTS, &value) < 0 ) { | 351 if ( ioctl(audio_fd, SNDCTL_DSP_GETFMTS, &value) < 0 ) { |
344 SDL_SetError("Couldn't get audio format list"); | 352 SDL_SetError("Couldn't get audio format list"); |
345 return(-1); | 353 return(-1); |
346 } | 354 } |