comparison src/audio/paudio/SDL_paudio.c @ 3846:66fb40445587 SDL-ryan-multiple-audio-device

Removed distinction between "available" and "init" in audio backends, since both had to be checked for success as a pair at the higher level and several of the Available methods were just always-succeed placeholders anyhow. Now the availability check is done in the init code, and the higher level tries all possible drivers until one manages to initialize successfully.
author Ryan C. Gordon <icculus@icculus.org>
date Tue, 17 Oct 2006 09:09:21 +0000
parents ca74a71063ac
children
comparison
equal deleted inserted replaced
3845:ee5dfa7f7993 3846:66fb40445587
123 } 123 }
124 } 124 }
125 } 125 }
126 return -1; 126 return -1;
127 } 127 }
128
129
130 static int
131 PAUDIO_Available(void)
132 {
133 int fd;
134 int available;
135
136 available = 0;
137 fd = OpenAudioPath(NULL, 0, OPEN_FLAGS, 0);
138 if (fd >= 0) {
139 available = 1;
140 close(fd);
141 }
142 return (available);
143 }
144
145 128
146 /* This function waits until it is possible to write a full sound buffer */ 129 /* This function waits until it is possible to write a full sound buffer */
147 static void 130 static void
148 PAUDIO_WaitDevice(_THIS) 131 PAUDIO_WaitDevice(_THIS)
149 { 132 {
541 } 524 }
542 525
543 static int 526 static int
544 PAUDIO_Init(SDL_AudioDriverImpl *impl) 527 PAUDIO_Init(SDL_AudioDriverImpl *impl)
545 { 528 {
529 int fd = OpenAudioPath(NULL, 0, OPEN_FLAGS, 0);
530 if (fd < 0) {
531 SDL_SetError("PAUDIO: Couldn't open audio device");
532 return 0;
533 }
534 close(fd);
535
546 /* Set the function pointers */ 536 /* Set the function pointers */
547 impl->OpenDevice = DSP_OpenDevice; 537 impl->OpenDevice = DSP_OpenDevice;
548 impl->PlayDevice = DSP_PlayDevice; 538 impl->PlayDevice = DSP_PlayDevice;
549 impl->PlayDevice = DSP_WaitDevice; 539 impl->PlayDevice = DSP_WaitDevice;
550 impl->GetDeviceBuf = DSP_GetDeviceBuf; 540 impl->GetDeviceBuf = DSP_GetDeviceBuf;
553 543
554 return 1; 544 return 1;
555 } 545 }
556 546
557 AudioBootStrap PAUDIO_bootstrap = { 547 AudioBootStrap PAUDIO_bootstrap = {
558 PAUDIO_DRIVER_NAME, "AIX Paudio", 548 PAUDIO_DRIVER_NAME, "AIX Paudio", PAUDIO_Init, 0
559 PAUDIO_Available, PAUDIO_Init, 0
560 }; 549 };
561 550
562 /* vi: set ts=4 sw=4 expandtab: */ 551 /* vi: set ts=4 sw=4 expandtab: */