Skip to content

Commit

Permalink
Use the correct device name when opening a device by name
Browse files Browse the repository at this point in the history
Duplicate device names will have a '#2' or such appended, so the device's
reported name may be incorrect.
  • Loading branch information
kcat committed Sep 3, 2015
1 parent 7b4f1cf commit 87e4ec6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Alc/backends/mmdevapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,9 @@ static ALCenum ALCmmdevPlayback_open(ALCmmdevPlayback *self, const ALCchar *devi
{
if(al_string_cmp_cstr(iter->name, deviceName) == 0)
{
ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice;
self->devid = strdupW(iter->devid);
al_string_copy(&device->DeviceName, iter->name);
hr = S_OK;
break;
}
Expand Down Expand Up @@ -752,7 +754,8 @@ static HRESULT ALCmmdevPlayback_openProxy(ALCmmdevPlayback *self)
if(SUCCEEDED(hr))
{
self->client = ptr;
get_device_name(self->mmdev, &device->DeviceName);
if(al_string_empty(device->DeviceName))
get_device_name(self->mmdev, &device->DeviceName);
}

if(FAILED(hr))
Expand Down Expand Up @@ -1326,7 +1329,9 @@ static ALCenum ALCmmdevCapture_open(ALCmmdevCapture *self, const ALCchar *device
WARN("Failed to find device name matching \"%s\"\n", deviceName);
else
{
ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice;
self->devid = strdupW(iter->devid);
al_string_copy(&device->DeviceName, iter->name);
hr = S_OK;
}
#undef MATCH_NAME
Expand Down Expand Up @@ -1403,7 +1408,8 @@ static HRESULT ALCmmdevCapture_openProxy(ALCmmdevCapture *self)
if(SUCCEEDED(hr))
{
self->client = ptr;
get_device_name(self->mmdev, &device->DeviceName);
if(al_string_empty(device->DeviceName))
get_device_name(self->mmdev, &device->DeviceName);
}

if(FAILED(hr))
Expand Down

0 comments on commit 87e4ec6

Please # to comment.