src/audio/SDL_audio.c
changeset 10252 4d99b888e7e5
parent 10246 db0b712b79dd
child 10253 4a1faf81a620
equal deleted inserted replaced
10251:6b259657cfd1 10252:4d99b888e7e5
  1141 static SDL_AudioDeviceID
  1141 static SDL_AudioDeviceID
  1142 open_audio_device(const char *devname, int iscapture,
  1142 open_audio_device(const char *devname, int iscapture,
  1143                   const SDL_AudioSpec * desired, SDL_AudioSpec * obtained,
  1143                   const SDL_AudioSpec * desired, SDL_AudioSpec * obtained,
  1144                   int allowed_changes, int min_id)
  1144                   int allowed_changes, int min_id)
  1145 {
  1145 {
       
  1146     const SDL_bool is_internal_thread = (desired->callback != NULL);
  1146     SDL_AudioDeviceID id = 0;
  1147     SDL_AudioDeviceID id = 0;
  1147     SDL_AudioSpec _obtained;
  1148     SDL_AudioSpec _obtained;
  1148     SDL_AudioDevice *device;
  1149     SDL_AudioDevice *device;
  1149     SDL_bool build_cvt;
  1150     SDL_bool build_cvt;
  1150     void *handle = NULL;
  1151     void *handle = NULL;
  1377         /* Start the audio thread */
  1378         /* Start the audio thread */
  1378 
  1379 
  1379         /* !!! FIXME: we don't force the audio thread stack size here because it calls into user code, but maybe we should? */
  1380         /* !!! FIXME: we don't force the audio thread stack size here because it calls into user code, but maybe we should? */
  1380         /* buffer queueing callback only needs a few bytes, so make the stack tiny. */
  1381         /* buffer queueing callback only needs a few bytes, so make the stack tiny. */
  1381         char name[64];
  1382         char name[64];
  1382         const SDL_bool is_internal_thread =
       
  1383             (device->spec.callback == SDL_BufferQueueDrainCallback) ||
       
  1384             (device->spec.callback == SDL_BufferQueueFillCallback);
       
  1385         const size_t stacksize = is_internal_thread ? 64 * 1024 : 0;
  1383         const size_t stacksize = is_internal_thread ? 64 * 1024 : 0;
  1386 
       
  1387         SDL_snprintf(name, sizeof (name), "SDLAudioDev%d", (int) device->id);
  1384         SDL_snprintf(name, sizeof (name), "SDLAudioDev%d", (int) device->id);
  1388         device->thread = SDL_CreateThreadInternal(iscapture ? SDL_CaptureAudio : SDL_RunAudio, name, stacksize, device);
  1385         device->thread = SDL_CreateThreadInternal(iscapture ? SDL_CaptureAudio : SDL_RunAudio, name, stacksize, device);
  1389 
  1386 
  1390         if (device->thread == NULL) {
  1387         if (device->thread == NULL) {
  1391             SDL_CloseAudioDevice(device->id);
  1388             SDL_CloseAudioDevice(device->id);