Commit 88d90003 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

mmdevice: adapt to hotplug event

(However support for IMMNotificationClient remains missing.)
parent da917bba
...@@ -473,7 +473,7 @@ static void *MMThread(void *data) ...@@ -473,7 +473,7 @@ static void *MMThread(void *data)
} }
/*** Audio devices ***/ /*** Audio devices ***/
static int DevicesEnum(audio_output_t *aout, char ***idp, char ***namep) static int DevicesEnum(audio_output_t *aout)
{ {
aout_sys_t *sys = aout->sys; aout_sys_t *sys = aout->sys;
HRESULT hr; HRESULT hr;
...@@ -494,16 +494,13 @@ static int DevicesEnum(audio_output_t *aout, char ***idp, char ***namep) ...@@ -494,16 +494,13 @@ static int DevicesEnum(audio_output_t *aout, char ***idp, char ***namep)
msg_Warn(aout, "cannot count audio endpoints (error 0x%lx)", hr); msg_Warn(aout, "cannot count audio endpoints (error 0x%lx)", hr);
count = 0; count = 0;
} }
else
msg_Dbg(aout, "Available Windows Audio devices:");
char **ids = xmalloc (count * sizeof (*ids));
char **names = xmalloc (count * sizeof (*names));
unsigned n = 0; unsigned n = 0;
for (UINT i = 0; i < count; i++) for (UINT i = 0; i < count; i++)
{ {
IMMDevice *dev; IMMDevice *dev;
char *id, *name = NULL;
hr = IMMDeviceCollection_Item(devs, i, &dev); hr = IMMDeviceCollection_Item(devs, i, &dev);
if (FAILED(hr)) if (FAILED(hr))
...@@ -517,8 +514,7 @@ static int DevicesEnum(audio_output_t *aout, char ***idp, char ***namep) ...@@ -517,8 +514,7 @@ static int DevicesEnum(audio_output_t *aout, char ***idp, char ***namep)
IMMDevice_Release(dev); IMMDevice_Release(dev);
continue; continue;
} }
ids[n] = FromWide(devid); id = FromWide(devid);
names[n] = NULL;
CoTaskMemFree(devid); CoTaskMemFree(devid);
/* User-readable device name */ /* User-readable device name */
...@@ -531,21 +527,18 @@ static int DevicesEnum(audio_output_t *aout, char ***idp, char ***namep) ...@@ -531,21 +527,18 @@ static int DevicesEnum(audio_output_t *aout, char ***idp, char ***namep)
PropVariantInit(&v); PropVariantInit(&v);
hr = IPropertyStore_GetValue(props, &PKEY_Device_FriendlyName, &v); hr = IPropertyStore_GetValue(props, &PKEY_Device_FriendlyName, &v);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
names[n] = FromWide(v.pwszVal); name = FromWide(v.pwszVal);
PropVariantClear(&v); PropVariantClear(&v);
IPropertyStore_Release(props); IPropertyStore_Release(props);
} }
IMMDevice_Release(dev); IMMDevice_Release(dev);
if (names[n] == NULL)
names[n] = xstrdup(ids[n]);
msg_Dbg(aout, "%s (%s)", ids[n], names[n]); aout_HotplugReport(aout, id, (name != NULL) ? name : id);
free(name);
free(id);
n++; n++;
} }
IMMDeviceCollection_Release(devs); IMMDeviceCollection_Release(devs);
*idp = ids;
*namep = names;
return n; return n;
} }
...@@ -765,8 +758,8 @@ static int Open(vlc_object_t *obj) ...@@ -765,8 +758,8 @@ static int Open(vlc_object_t *obj)
aout->flush = Flush; aout->flush = Flush;
aout->volume_set = VolumeSet; aout->volume_set = VolumeSet;
aout->mute_set = MuteSet; aout->mute_set = MuteSet;
aout->device_enum = DevicesEnum;
aout->device_select = DeviceSelect; aout->device_select = DeviceSelect;
DevicesEnum(aout);
return VLC_SUCCESS; return VLC_SUCCESS;
error: error:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment