Commit 860d6bd4 authored by Thomas Guillem's avatar Thomas Guillem

mmdevice: split DeviceHotplugReport()

Add DeviceGetFriendlyName() that can be used to fetch the friendly name.

(cherry picked from commit 9d694a9d)
Signed-off-by: Thomas Guillem's avatarThomas Guillem <thomas@gllm.fr>
parent 85164b7b
......@@ -451,25 +451,17 @@ static const struct IAudioVolumeDuckNotificationVtbl vlc_AudioVolumeDuckNotifica
/*** Audio devices ***/
/** Gets the user-readable device name */
static int DeviceHotplugReport(audio_output_t *aout, LPCWSTR wid,
IMMDevice *dev)
static char *DeviceGetFriendlyName(IMMDevice *dev)
{
IPropertyStore *props;
char *name;
PROPVARIANT v;
HRESULT hr;
char *id = FromWide(wid);
if (unlikely(id == NULL))
return VLC_ENOMEM;
hr = IMMDevice_OpenPropertyStore(dev, STGM_READ, &props);
if (FAILED(hr))
{
free(id);
return VLC_EGENERIC;
}
return NULL;
char *name = NULL;
PropVariantInit(&v);
hr = IPropertyStore_GetValue(props, &PKEY_Device_FriendlyName, &v);
if (SUCCEEDED(hr))
......@@ -477,10 +469,23 @@ static int DeviceHotplugReport(audio_output_t *aout, LPCWSTR wid,
name = FromWide(v.pwszVal);
PropVariantClear(&v);
}
else
name = id;
IPropertyStore_Release(props);
return name;
}
static int DeviceHotplugReport(audio_output_t *aout, LPCWSTR wid,
IMMDevice *dev)
{
char *id = FromWide(wid);
if (!id)
return VLC_EGENERIC;
char *name = DeviceGetFriendlyName(dev);
if (name == NULL)
name = id;
aout_HotplugReport(aout, id, name);
free(id);
......
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