Fixed assertion failure in diskaudio target caused by new hotplugging support.
authorRyan C. Gordon <icculus@icculus.org>
Tue, 30 Jun 2015 13:46:06 -0400
changeset 9786 d857f324bede
parent 9785 6e87ae760e6d
child 9787 08b2895a935a
Fixed assertion failure in diskaudio target caused by new hotplugging support. Fixes Bugzilla #3032.
src/audio/disk/SDL_diskaudio.c
--- a/src/audio/disk/SDL_diskaudio.c	Mon Jun 29 22:24:00 2015 -0700
+++ b/src/audio/disk/SDL_diskaudio.c	Tue Jun 30 13:46:06 2015 -0400
@@ -102,8 +102,9 @@
 static int
 DISKAUD_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
 {
+    /* handle != NULL means "user specified the placeholder name on the fake detected device list" */
+    const char *fname = DISKAUD_GetOutputFilename(handle ? NULL : devname);
     const char *envr = SDL_getenv(DISKENVR_WRITEDELAY);
-    const char *fname = DISKAUD_GetOutputFilename(devname);
 
     this->hidden = (struct SDL_PrivateAudioData *)
         SDL_malloc(sizeof(*this->hidden));
@@ -141,6 +142,13 @@
     return 0;
 }
 
+static void
+DISKAUD_DetectDevices(void)
+{
+    /* !!! FIXME: stole this literal string from DEFAULT_OUTPUT_DEVNAME in SDL_audio.c */
+    SDL_AddAudioDevice(SDL_FALSE, "System audio output device", (void *) 0x1);
+}
+
 static int
 DISKAUD_Init(SDL_AudioDriverImpl * impl)
 {
@@ -150,6 +158,7 @@
     impl->PlayDevice = DISKAUD_PlayDevice;
     impl->GetDeviceBuf = DISKAUD_GetDeviceBuf;
     impl->CloseDevice = DISKAUD_CloseDevice;
+    impl->DetectDevices = DISKAUD_DetectDevices;
 
     impl->AllowsArbitraryDeviceNames = 1;