Reformat Windows device name dressing

This commit is contained in:
Chris Robinson
2015-12-04 15:52:43 -08:00
parent 63567526b0
commit e45ff47361
3 changed files with 27 additions and 29 deletions
+5 -6
View File
@@ -60,7 +60,7 @@
DEFINE_GUID(KSDATAFORMAT_SUBTYPE_PCM, 0x00000001, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
DEFINE_GUID(KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, 0x00000003, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
#define DEVNAME_TAIL " on OpenAL Soft"
#define DEVNAME_HEAD "OpenAL Soft on "
#ifdef HAVE_DYNLOAD
@@ -145,13 +145,12 @@ static BOOL CALLBACK DSoundEnumDevices(GUID *guid, const WCHAR *desc, const WCHA
{
const DevMap *iter;
al_string_copy_wcstr(&entry.name, desc);
if(count == 0)
al_string_append_cstr(&entry.name, DEVNAME_TAIL);
else
al_string_copy_cstr(&entry.name, DEVNAME_HEAD);
al_string_append_wcstr(&entry.name, desc);
if(count != 0)
{
char str[64];
snprintf(str, sizeof(str), " #%d"DEVNAME_TAIL, count+1);
snprintf(str, sizeof(str), " #%d", count+1);
al_string_append_cstr(&entry.name, str);
}
+13 -12
View File
@@ -62,7 +62,7 @@ DEFINE_PROPERTYKEY(PKEY_AudioEndpoint_FormFactor, 0x1da5d803, 0xd492, 0x4edd, 0x
#define X7DOT1 (SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT|SPEAKER_SIDE_LEFT|SPEAKER_SIDE_RIGHT)
#define X7DOT1_WIDE (SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT|SPEAKER_FRONT_LEFT_OF_CENTER|SPEAKER_FRONT_RIGHT_OF_CENTER)
#define DEVNAME_TAIL " on OpenAL Soft"
#define DEVNAME_HEAD "OpenAL Soft on "
typedef struct {
@@ -125,10 +125,13 @@ static void get_device_name(IMMDevice *device, al_string *name)
PROPVARIANT pvname;
HRESULT hr;
al_string_copy_cstr(name, DEVNAME_HEAD);
hr = IMMDevice_OpenPropertyStore(device, STGM_READ, &ps);
if(FAILED(hr))
{
WARN("OpenPropertyStore failed: 0x%08lx\n", hr);
al_string_append_cstr(name, "Unknown Device Name");
return;
}
@@ -136,11 +139,17 @@ static void get_device_name(IMMDevice *device, al_string *name)
hr = IPropertyStore_GetValue(ps, (const PROPERTYKEY*)&DEVPKEY_Device_FriendlyName, &pvname);
if(FAILED(hr))
{
WARN("GetValue Device_FriendlyName failed: 0x%08lx\n", hr);
al_string_append_cstr(name, "Unknown Device Name");
}
else if(pvname.vt == VT_LPWSTR)
al_string_copy_wcstr(name, pvname.pwszVal);
al_string_append_wcstr(name, pvname.pwszVal);
else
{
WARN("Unexpected PROPVARIANT type: 0x%04x\n", pvname.vt);
al_string_append_cstr(name, "Unknown Device Name");
}
PropVariantClear(&pvname);
IPropertyStore_Release(ps);
@@ -193,12 +202,10 @@ static void add_device(IMMDevice *device, LPCWSTR devid, vector_DevMap *list)
const DevMap *iter;
al_string_copy(&entry.name, tmpname);
if(count == 0)
al_string_append_cstr(&entry.name, DEVNAME_TAIL);
else
if(count != 0)
{
char str[64];
snprintf(str, sizeof(str), " #%d"DEVNAME_TAIL, count+1);
snprintf(str, sizeof(str), " #%d", count+1);
al_string_append_cstr(&entry.name, str);
}
@@ -755,10 +762,7 @@ static HRESULT ALCmmdevPlayback_openProxy(ALCmmdevPlayback *self)
{
self->client = ptr;
if(al_string_empty(device->DeviceName))
{
get_device_name(self->mmdev, &device->DeviceName);
al_string_append_cstr(&device->DeviceName, DEVNAME_TAIL);
}
}
if(FAILED(hr))
@@ -1412,10 +1416,7 @@ static HRESULT ALCmmdevCapture_openProxy(ALCmmdevCapture *self)
{
self->client = ptr;
if(al_string_empty(device->DeviceName))
{
get_device_name(self->mmdev, &device->DeviceName);
al_string_append_cstr(&device->DeviceName, DEVNAME_TAIL);
}
}
if(FAILED(hr))
+9 -11
View File
@@ -37,7 +37,7 @@
#define WAVE_FORMAT_IEEE_FLOAT 0x0003
#endif
#define DEVNAME_TAIL " on OpenAL Soft"
#define DEVNAME_HEAD "OpenAL Soft on "
static vector_al_string PlaybackDevices;
@@ -71,13 +71,12 @@ static void ProbePlaybackDevices(void)
ALuint count = 0;
while(1)
{
al_string_copy_wcstr(&dname, WaveCaps.szPname);
if(count == 0)
al_string_append_cstr(&dname, DEVNAME_TAIL);
else
al_string_copy_cstr(&dname, DEVNAME_HEAD);
al_string_append_wcstr(&dname, WaveCaps.szPname);
if(count != 0)
{
char str[64];
snprintf(str, sizeof(str), " #%d"DEVNAME_TAIL, count+1);
snprintf(str, sizeof(str), " #%d", count+1);
al_string_append_cstr(&dname, str);
}
count++;
@@ -115,13 +114,12 @@ static void ProbeCaptureDevices(void)
ALuint count = 0;
while(1)
{
al_string_copy_wcstr(&dname, WaveCaps.szPname);
if(count == 0)
al_string_append_cstr(&dname, DEVNAME_TAIL);
else
al_string_copy_cstr(&dname, DEVNAME_HEAD);
al_string_append_wcstr(&dname, WaveCaps.szPname);
if(count != 0)
{
char str[64];
snprintf(str, sizeof(str), " #%d"DEVNAME_TAIL, count+1);
snprintf(str, sizeof(str), " #%d", count+1);
al_string_append_cstr(&dname, str);
}
count++;