comparison src/audio/paudio/SDL_paudio.c @ 2060:866052b01ee5

indent is evil
author Sam Lantinga <slouken@libsdl.org>
date Sat, 28 Oct 2006 16:48:03 +0000
parents 5f6550e5184f
children e27bdcc80744
comparison
equal deleted inserted replaced
2059:4685ccd33d0e 2060:866052b01ee5
135 /* See if we need to use timed audio synchronization */ 135 /* See if we need to use timed audio synchronization */
136 if (this->hidden->frame_ticks) { 136 if (this->hidden->frame_ticks) {
137 /* Use timer for general audio synchronization */ 137 /* Use timer for general audio synchronization */
138 Sint32 ticks; 138 Sint32 ticks;
139 139
140 ticks = ((Sint32)(this->hidden->next_frame-SDL_GetTicks()))-FUDGE_TICKS; 140 ticks =
141 ((Sint32) (this->hidden->next_frame - SDL_GetTicks())) -
142 FUDGE_TICKS;
141 if (ticks > 0) { 143 if (ticks > 0) {
142 SDL_Delay(ticks); 144 SDL_Delay(ticks);
143 } 145 }
144 } else { 146 } else {
145 audio_buffer paud_bufinfo; 147 audio_buffer paud_bufinfo;
168 } 170 }
169 171
170 #ifdef DEBUG_AUDIO 172 #ifdef DEBUG_AUDIO
171 fprintf(stderr, "Waiting for audio to get ready\n"); 173 fprintf(stderr, "Waiting for audio to get ready\n");
172 #endif 174 #endif
173 if (select(this->hidden->audio_fd+1,NULL,&fdset,NULL,&timeout) <= 0) { 175 if (select(this->hidden->audio_fd + 1, NULL, &fdset, NULL, &timeout)
176 <= 0) {
174 const char *message = 177 const char *message =
175 "Audio timeout - buggy audio driver? (disabled)"; 178 "Audio timeout - buggy audio driver? (disabled)";
176 /* 179 /*
177 * In general we should never print to the screen, 180 * In general we should never print to the screen,
178 * but in this case we have no other way of letting 181 * but in this case we have no other way of letting
262 audio_change paud_change; 265 audio_change paud_change;
263 int fd = -1; 266 int fd = -1;
264 267
265 /* Initialize all variables that we clean on shutdown */ 268 /* Initialize all variables that we clean on shutdown */
266 this->hidden = (struct SDL_PrivateAudioData *) 269 this->hidden = (struct SDL_PrivateAudioData *)
267 SDL_malloc((sizeof *this->hidden)); 270 SDL_malloc((sizeof *this->hidden));
268 if (this->hidden == NULL) { 271 if (this->hidden == NULL) {
269 SDL_OutOfMemory(); 272 SDL_OutOfMemory();
270 return 0; 273 return 0;
271 } 274 }
272 SDL_memset(this->hidden, 0, (sizeof *this->hidden)); 275 SDL_memset(this->hidden, 0, (sizeof *this->hidden));
513 } 516 }
514 517
515 /* Check to see if we need to use select() workaround */ 518 /* Check to see if we need to use select() workaround */
516 if (workaround != NULL) { 519 if (workaround != NULL) {
517 this->hidden->frame_ticks = (float) (this->spec.samples * 1000) / 520 this->hidden->frame_ticks = (float) (this->spec.samples * 1000) /
518 this->spec.freq; 521 this->spec.freq;
519 this->hidden->next_frame = SDL_GetTicks() + this->hidden->frame_ticks; 522 this->hidden->next_frame = SDL_GetTicks() + this->hidden->frame_ticks;
520 } 523 }
521 524
522 /* We're ready to rock and roll. :-) */ 525 /* We're ready to rock and roll. :-) */
523 return 1; 526 return 1;
524 } 527 }
525 528
526 static int 529 static int
527 PAUDIO_Init(SDL_AudioDriverImpl *impl) 530 PAUDIO_Init(SDL_AudioDriverImpl * impl)
528 { 531 {
529 int fd = OpenAudioPath(NULL, 0, OPEN_FLAGS, 0); 532 int fd = OpenAudioPath(NULL, 0, OPEN_FLAGS, 0);
530 if (fd < 0) { 533 if (fd < 0) {
531 SDL_SetError("PAUDIO: Couldn't open audio device"); 534 SDL_SetError("PAUDIO: Couldn't open audio device");
532 return 0; 535 return 0;
537 impl->OpenDevice = DSP_OpenDevice; 540 impl->OpenDevice = DSP_OpenDevice;
538 impl->PlayDevice = DSP_PlayDevice; 541 impl->PlayDevice = DSP_PlayDevice;
539 impl->PlayDevice = DSP_WaitDevice; 542 impl->PlayDevice = DSP_WaitDevice;
540 impl->GetDeviceBuf = DSP_GetDeviceBuf; 543 impl->GetDeviceBuf = DSP_GetDeviceBuf;
541 impl->CloseDevice = DSP_CloseDevice; 544 impl->CloseDevice = DSP_CloseDevice;
542 impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: add device enum! */ 545 impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: add device enum! */
543 546
544 return 1; 547 return 1;
545 } 548 }
546 549
547 AudioBootStrap PAUDIO_bootstrap = { 550 AudioBootStrap PAUDIO_bootstrap = {