From 1e5f9d26738244cf5c07eed2c334a73729bfa9dd Mon Sep 17 00:00:00 2001 From: Kevin Mitchell Date: Tue, 16 Dec 2014 01:56:12 -0800 Subject: ao/wasapi: use IsEqualGUID and IsEqualPropertyKey before we were reinventing this wheel --- audio/out/ao_wasapi_changenotify.c | 6 +++--- audio/out/ao_wasapi_utils.c | 31 ++++++------------------------- audio/out/ao_wasapi_utils.h | 2 -- 3 files changed, 9 insertions(+), 30 deletions(-) diff --git a/audio/out/ao_wasapi_changenotify.c b/audio/out/ao_wasapi_changenotify.c index 0d299361e4..9d4235a2cd 100755 --- a/audio/out/ao_wasapi_changenotify.c +++ b/audio/out/ao_wasapi_changenotify.c @@ -54,8 +54,8 @@ static HRESULT STDMETHODCALLTYPE sIMMNotificationClient_QueryInterface( IMMNotificationClient* This, REFIID riid, void **ppvObject) { /* Compatible with IMMNotificationClient and IUnknown */ - if (!mp_GUID_compare(&IID_IMMNotificationClient, riid) || - !mp_GUID_compare(&IID_IUnknown, riid)) { + if ( IsEqualGUID(&IID_IMMNotificationClient, riid) || + IsEqualGUID(&IID_IUnknown, riid) ) { *ppvObject = (void *)This; return S_OK; } else { @@ -178,7 +178,7 @@ static HRESULT STDMETHODCALLTYPE sIMMNotificationClient_OnPropertyValueChanged( if (pwstrDeviceId && !wcscmp(change->monitored, pwstrDeviceId)) { MP_VERBOSE(ao, "OnPropertyValueChanged triggered\n"); MP_VERBOSE(ao, "Changed property: "); - if (!mp_PKEY_compare(&PKEY_AudioEngine_DeviceFormat, &key)) { + if ( IsEqualPropertyKey(PKEY_AudioEngine_DeviceFormat, key) ) { MP_VERBOSE(change->ao, "PKEY_AudioEngine_DeviceFormat - requesting ao reload\n"); ao_request_reload(change->ao); diff --git a/audio/out/ao_wasapi_utils.c b/audio/out/ao_wasapi_utils.c index 0000995349..04638deac3 100755 --- a/audio/out/ao_wasapi_utils.c +++ b/audio/out/ao_wasapi_utils.c @@ -50,25 +50,6 @@ DEFINE_GUID(mp_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, 0x00000003, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71); -int mp_GUID_compare(const GUID *l, const GUID *r) -{ - unsigned int i; - if (l->Data1 != r->Data1) return 1; - if (l->Data2 != r->Data2) return 1; - if (l->Data3 != r->Data3) return 1; - for (i = 0; i < 8; i++) { - if (l->Data4[i] != r->Data4[i]) return 1; - } - return 0; -} - -int mp_PKEY_compare(const PROPERTYKEY *l, const PROPERTYKEY *r) -{ - if (mp_GUID_compare(&l->fmtid, &r->fmtid)) return 1; - if (l->pid != r->pid) return 1; - return 0; -} - char *mp_GUID_to_str_buf(char *buf, size_t buf_size, const GUID *guid) { snprintf(buf, buf_size, @@ -194,11 +175,11 @@ static char *waveformat_to_str_buf(char *buf, size_t buf_size, const WAVEFORMATE case WAVE_FORMAT_EXTENSIBLE: { WAVEFORMATEXTENSIBLE *wformat = (WAVEFORMATEXTENSIBLE *)wf; - if ( !mp_GUID_compare(&mp_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, - &wformat->SubFormat) ) + if ( IsEqualGUID(&mp_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, + &wformat->SubFormat) ) type = "float"; - else if ( !mp_GUID_compare(&mp_KSDATAFORMAT_SUBTYPE_PCM, - &wformat->SubFormat) ) + else if ( IsEqualGUID(&mp_KSDATAFORMAT_SUBTYPE_PCM, + &wformat->SubFormat) ) type = "s"; break; } @@ -221,7 +202,7 @@ static bool waveformat_is_float(WAVEFORMATEX *wf) case WAVE_FORMAT_EXTENSIBLE: { WAVEFORMATEXTENSIBLE *wformat = (WAVEFORMATEXTENSIBLE *)wf; - return !mp_GUID_compare(&mp_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, &wformat->SubFormat); + return IsEqualGUID(&mp_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, &wformat->SubFormat); } case WAVE_FORMAT_IEEE_FLOAT: return true; @@ -236,7 +217,7 @@ static bool waveformat_is_pcm(WAVEFORMATEX *wf) case WAVE_FORMAT_EXTENSIBLE: { WAVEFORMATEXTENSIBLE *wformat = (WAVEFORMATEXTENSIBLE *)wf; - return !mp_GUID_compare(&mp_KSDATAFORMAT_SUBTYPE_PCM, &wformat->SubFormat); + return IsEqualGUID(&mp_KSDATAFORMAT_SUBTYPE_PCM, &wformat->SubFormat); } case WAVE_FORMAT_PCM: return true; diff --git a/audio/out/ao_wasapi_utils.h b/audio/out/ao_wasapi_utils.h index 00caba659a..a44cd4d45a 100755 --- a/audio/out/ao_wasapi_utils.h +++ b/audio/out/ao_wasapi_utils.h @@ -27,8 +27,6 @@ #include "ao.h" #include "internal.h" -int mp_GUID_compare(const GUID *l, const GUID *r); -int mp_PKEY_compare(const PROPERTYKEY *l, const PROPERTYKEY *r); char *mp_GUID_to_str_buf(char *buf, size_t buf_size, const GUID *guid); char *mp_PKEY_to_str_buf(char *buf, size_t buf_size, const PROPERTYKEY *pkey); #define mp_GUID_to_str(guid) mp_GUID_to_str_buf((char[40]){0}, 40, (guid)) -- cgit v1.2.3