comparison src/audio/SDL_audio.c @ 3888:6d2e1961661a SDL-1.2

Removed broken AmigaOS support. Fixes Bugzilla #337.
author Ryan C. Gordon <icculus@icculus.org>
date Sun, 29 Oct 2006 03:58:27 +0000
parents dba874934f0c
children 42e83d81224b
comparison
equal deleted inserted replaced
3887:9dcceea84416 3888:6d2e1961661a
79 #if SDL_AUDIO_DRIVER_COREAUDIO 79 #if SDL_AUDIO_DRIVER_COREAUDIO
80 &COREAUDIO_bootstrap, 80 &COREAUDIO_bootstrap,
81 #endif 81 #endif
82 #if SDL_AUDIO_DRIVER_SNDMGR 82 #if SDL_AUDIO_DRIVER_SNDMGR
83 &SNDMGR_bootstrap, 83 &SNDMGR_bootstrap,
84 #endif
85 #if SDL_AUDIO_DRIVER_AHI
86 &AHI_bootstrap,
87 #endif 84 #endif
88 #if SDL_AUDIO_DRIVER_MINT 85 #if SDL_AUDIO_DRIVER_MINT
89 &MINTAUDIO_GSXB_bootstrap, 86 &MINTAUDIO_GSXB_bootstrap,
90 &MINTAUDIO_MCSN_bootstrap, 87 &MINTAUDIO_MCSN_bootstrap,
91 &MINTAUDIO_STFA_bootstrap, 88 &MINTAUDIO_STFA_bootstrap,
113 110
114 /* Various local functions */ 111 /* Various local functions */
115 int SDL_AudioInit(const char *driver_name); 112 int SDL_AudioInit(const char *driver_name);
116 void SDL_AudioQuit(void); 113 void SDL_AudioQuit(void);
117 114
118 #if SDL_AUDIO_DRIVER_AHI
119 static int audio_configured = 0;
120 #endif
121
122 /* The general mixing thread function */ 115 /* The general mixing thread function */
123 int SDLCALL SDL_RunAudio(void *audiop) 116 int SDLCALL SDL_RunAudio(void *audiop)
124 { 117 {
125 SDL_AudioDevice *audio = (SDL_AudioDevice *)audiop; 118 SDL_AudioDevice *audio = (SDL_AudioDevice *)audiop;
126 Uint8 *stream; 119 Uint8 *stream;
127 int stream_len; 120 int stream_len;
128 void *udata; 121 void *udata;
129 void (SDLCALL *fill)(void *userdata,Uint8 *stream, int len); 122 void (SDLCALL *fill)(void *userdata,Uint8 *stream, int len);
130 int silence; 123 int silence;
131 #if SDL_AUDIO_DRIVER_AHI
132 int started = 0;
133
134 /* AmigaOS NEEDS that the audio driver is opened in the thread that uses it! */
135
136 D(bug("Task audio started audio struct:<%lx>...\n",audiop));
137
138 D(bug("Before Openaudio..."));
139 if(audio->OpenAudio(audio, &audio->spec)==-1)
140 {
141 D(bug("Open audio failed...\n"));
142 return(-1);
143 }
144 D(bug("OpenAudio...OK\n"));
145 #endif
146 124
147 /* Perform any thread setup */ 125 /* Perform any thread setup */
148 if ( audio->ThreadInit ) { 126 if ( audio->ThreadInit ) {
149 audio->ThreadInit(audio); 127 audio->ThreadInit(audio);
150 } 128 }
151 audio->threadid = SDL_ThreadID(); 129 audio->threadid = SDL_ThreadID();
152 130
153 /* Set up the mixing function */ 131 /* Set up the mixing function */
154 fill = audio->spec.callback; 132 fill = audio->spec.callback;
155 udata = audio->spec.userdata; 133 udata = audio->spec.userdata;
156
157 #if SDL_AUDIO_DRIVER_AHI
158 audio_configured = 1;
159
160 D(bug("Audio configured... Checking for conversion\n"));
161 SDL_mutexP(audio->mixer_lock);
162 D(bug("Semaphore obtained...\n"));
163 #endif
164 134
165 if ( audio->convert.needed ) { 135 if ( audio->convert.needed ) {
166 if ( audio->convert.src_format == AUDIO_U8 ) { 136 if ( audio->convert.src_format == AUDIO_U8 ) {
167 silence = 0x80; 137 silence = 0x80;
168 } else { 138 } else {
171 stream_len = audio->convert.len; 141 stream_len = audio->convert.len;
172 } else { 142 } else {
173 silence = audio->spec.silence; 143 silence = audio->spec.silence;
174 stream_len = audio->spec.size; 144 stream_len = audio->spec.size;
175 } 145 }
176
177 #if SDL_AUDIO_DRIVER_AHI
178 SDL_mutexV(audio->mixer_lock);
179 D(bug("Entering audio loop...\n"));
180 #endif
181 146
182 #ifdef __OS2__ 147 #ifdef __OS2__
183 /* Increase the priority of this thread to make sure that 148 /* Increase the priority of this thread to make sure that
184 the audio will be continuous all the time! */ 149 the audio will be continuous all the time! */
185 #ifdef USE_DOSSETPRIORITY 150 #ifdef USE_DOSSETPRIORITY
251 /* Wait for the audio to drain.. */ 216 /* Wait for the audio to drain.. */
252 if ( audio->WaitDone ) { 217 if ( audio->WaitDone ) {
253 audio->WaitDone(audio); 218 audio->WaitDone(audio);
254 } 219 }
255 220
256 #if SDL_AUDIO_DRIVER_AHI
257 D(bug("WaitAudio...Done\n"));
258
259 audio->CloseAudio(audio);
260
261 D(bug("CloseAudio..Done, subtask exiting...\n"));
262 audio_configured = 0;
263 #endif
264 #ifdef __OS2__ 221 #ifdef __OS2__
265 #ifdef DEBUG_BUILD 222 #ifdef DEBUG_BUILD
266 printf("[SDL_RunAudio] : Task exiting. (TID%d)\n", SDL_ThreadID()); 223 printf("[SDL_RunAudio] : Task exiting. (TID%d)\n", SDL_ThreadID());
267 #endif 224 #endif
268 #endif 225 #endif
530 SDL_memcpy(&audio->spec, desired, sizeof(audio->spec)); 487 SDL_memcpy(&audio->spec, desired, sizeof(audio->spec));
531 audio->convert.needed = 0; 488 audio->convert.needed = 0;
532 audio->enabled = 1; 489 audio->enabled = 1;
533 audio->paused = 1; 490 audio->paused = 1;
534 491
535 #if !SDL_AUDIO_DRIVER_AHI
536
537 /* AmigaOS opens audio inside the main loop */
538 audio->opened = audio->OpenAudio(audio, &audio->spec)+1; 492 audio->opened = audio->OpenAudio(audio, &audio->spec)+1;
539 493
540 if ( ! audio->opened ) { 494 if ( ! audio->opened ) {
541 SDL_CloseAudio(); 495 SDL_CloseAudio();
542 return(-1); 496 return(-1);
543 } 497 }
544 #else
545 D(bug("Locking semaphore..."));
546 SDL_mutexP(audio->mixer_lock);
547
548
549 audio->thread = SDL_CreateThread(SDL_RunAudio, audio);
550 D(bug("Created thread...\n"));
551
552 if ( audio->thread == NULL ) {
553 SDL_mutexV(audio->mixer_lock);
554 SDL_CloseAudio();
555 SDL_SetError("Couldn't create audio thread");
556 return(-1);
557 }
558
559 while(!audio_configured)
560 SDL_Delay(100);
561 #endif
562 498
563 /* If the audio driver changes the buffer size, accept it */ 499 /* If the audio driver changes the buffer size, accept it */
564 if ( audio->spec.samples != desired->samples ) { 500 if ( audio->spec.samples != desired->samples ) {
565 desired->samples = audio->spec.samples; 501 desired->samples = audio->spec.samples;
566 SDL_CalculateAudioSpec(desired); 502 SDL_CalculateAudioSpec(desired);
600 return(-1); 536 return(-1);
601 } 537 }
602 } 538 }
603 } 539 }
604 540
605 #if !SDL_AUDIO_DRIVER_AHI
606 /* Start the audio thread if necessary */ 541 /* Start the audio thread if necessary */
607 switch (audio->opened) { 542 switch (audio->opened) {
608 case 1: 543 case 1:
609 /* Start the audio thread */ 544 /* Start the audio thread */
610 #if (defined(__WIN32__) && !defined(_WIN32_WCE)) && !defined(HAVE_LIBC) 545 #if (defined(__WIN32__) && !defined(_WIN32_WCE)) && !defined(HAVE_LIBC)
622 557
623 default: 558 default:
624 /* The audio is now playing */ 559 /* The audio is now playing */
625 break; 560 break;
626 } 561 }
627 #else
628 SDL_mutexV(audio->mixer_lock);
629 D(bug("SDL_OpenAudio USCITA...\n"));
630
631 #endif
632 562
633 return(0); 563 return(0);
634 } 564 }
635 565
636 SDL_audiostatus SDL_GetAudioStatus(void) 566 SDL_audiostatus SDL_GetAudioStatus(void)
700 } 630 }
701 if ( audio->convert.needed ) { 631 if ( audio->convert.needed ) {
702 SDL_FreeAudioMem(audio->convert.buf); 632 SDL_FreeAudioMem(audio->convert.buf);
703 633
704 } 634 }
705 #if !SDL_AUDIO_DRIVER_AHI
706 if ( audio->opened ) { 635 if ( audio->opened ) {
707 audio->CloseAudio(audio); 636 audio->CloseAudio(audio);
708 audio->opened = 0; 637 audio->opened = 0;
709 } 638 }
710 #endif
711 /* Free the driver data */ 639 /* Free the driver data */
712 audio->free(audio); 640 audio->free(audio);
713 current_audio = NULL; 641 current_audio = NULL;
714 } 642 }
715 } 643 }