Split up mmdevice enumeration string list to separate

file
This commit is contained in:
twinaphex 2019-07-25 05:42:23 +02:00
parent 89657914cd
commit 95c5d22c5a
6 changed files with 319 additions and 261 deletions

View File

@ -660,6 +660,7 @@ ifeq ($(HAVE_DSOUND), 1)
endif
ifeq ($(HAVE_WASAPI), 1)
HAVE_MMDEVICE_COMMON = 1
OBJ += audio/drivers/wasapi.o
DEFINES += -DHAVE_WASAPI
LIBS += -lole32 -lksuser
@ -671,6 +672,10 @@ ifeq ($(HAVE_XAUDIO), 1)
LIBS += -lole32
endif
ifeq ($(HAVE_MMDEVICE_COMMON), 1)
OBJ += audio/common/mmdevice_common.o
endif
ifeq ($(HAVE_WINMM), 1)
OBJ += midi/drivers/winmm_midi.o
DEFINES += -DHAVE_WINMM

View File

@ -0,0 +1,166 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2017 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <lists/string_list.h>
#include <queues/fifo_queue.h>
#include "mmdevice_common.h"
#include "../../retroarch.h"
#include "../../verbosity.h"
#include "../../configuration.h"
void *mmdevice_list_new(void *u)
{
HRESULT hr;
UINT i;
PROPVARIANT prop_var;
int ir;
union string_list_elem_attr attr;
IMMDeviceEnumerator *enumerator = NULL;
IMMDeviceCollection *collection = NULL;
UINT dev_count = 0;
IMMDevice *device = NULL;
LPWSTR dev_id_wstr = NULL;
IPropertyStore *prop_store = NULL;
bool prop_var_init = false;
bool br = false;
char *dev_id_str = NULL;
char *dev_name_str = NULL;
struct string_list *sl = string_list_new();
if (!sl)
return NULL;
attr.i = 0;
#ifdef __cplusplus
hr = CoCreateInstance(CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL,
IID_IMMDeviceEnumerator, (void **)&enumerator);
#else
hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL,
&IID_IMMDeviceEnumerator, (void **)&enumerator);
#endif
if (FAILED(hr))
goto error;
hr = _IMMDeviceEnumerator_EnumAudioEndpoints(enumerator,
eRender, DEVICE_STATE_ACTIVE, &collection);
if (FAILED(hr))
goto error;
hr = _IMMDeviceCollection_GetCount(collection, &dev_count);
if (FAILED(hr))
goto error;
for (i = 0; i < dev_count; ++i)
{
hr = _IMMDeviceCollection_Item(collection, i, &device);
if (FAILED(hr))
goto error;
hr = _IMMDevice_GetId(device, &dev_id_wstr);
if (FAILED(hr))
goto error;
ir = WideCharToMultiByte(CP_ACP, 0, dev_id_wstr, -1,
NULL, 0, NULL, NULL);
if (!ir)
goto error;
dev_id_str = (char *)malloc(ir);
if (!dev_id_str)
goto error;
ir = WideCharToMultiByte(CP_ACP, 0, dev_id_wstr, -1,
dev_id_str, ir, NULL, NULL);
if (!ir)
goto error;
hr = _IMMDevice_OpenPropertyStore(device, STGM_READ, &prop_store);
if (FAILED(hr))
goto error;
PropVariantInit(&prop_var);
prop_var_init = true;
hr = _IPropertyStore_GetValue(prop_store, PKEY_Device_FriendlyName,
&prop_var);
if (FAILED(hr))
goto error;
ir = WideCharToMultiByte(CP_ACP, 0, prop_var.pwszVal, -1,
NULL, 0, NULL, NULL);
if (!ir)
goto error;
dev_name_str = (char *)malloc(ir);
if (!dev_name_str)
goto error;
ir = WideCharToMultiByte(CP_ACP, 0, prop_var.pwszVal, -1,
dev_name_str, ir, NULL, NULL);
if (!ir)
goto error;
RARCH_LOG("[WASAPI]: %s %s\n", dev_name_str, dev_id_str);
br = string_list_append(sl, dev_id_str, attr);
if (!br)
goto error;
PropVariantClear(&prop_var);
prop_var_init = false;
if (dev_id_wstr)
CoTaskMemFree(dev_id_wstr);
if (dev_id_str)
free(dev_id_str);
if (dev_name_str)
free(dev_name_str);
dev_id_str = NULL;
dev_name_str = NULL;
dev_id_wstr = NULL;
IFACE_RELEASE(prop_store);
IFACE_RELEASE(device);
}
IFACE_RELEASE(collection);
IFACE_RELEASE(enumerator);
return sl;
error:
if (dev_id_str)
free(dev_id_str);
if (dev_name_str)
free(dev_name_str);
dev_id_str = NULL;
dev_name_str = NULL;
if (prop_var_init)
PropVariantClear(&prop_var);
IFACE_RELEASE(prop_store);
if (dev_id_wstr)
CoTaskMemFree(dev_id_wstr);
dev_id_wstr = NULL;
IFACE_RELEASE(device);
IFACE_RELEASE(collection);
IFACE_RELEASE(enumerator);
if (sl)
string_list_free(sl);
RARCH_ERR("[WASAPI]: Device enumeration failed.\n");
return NULL;
}

View File

@ -0,0 +1,120 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2017 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _MMDEVICE_COMMON_H
#define _MMDEVICE_COMMON_H
#include <stdlib.h>
#ifdef _WIN32_WINNT
#undef _WIN32_WINNT
#endif
#define _WIN32_WINNT 0x0600
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winerror.h>
#include <propidl.h>
#include <initguid.h>
#include <mmdeviceapi.h>
#include <mmreg.h>
#include <audioclient.h>
#include <retro_common_api.h>
#ifdef _MSC_VER
DEFINE_GUID(IID_IAudioClient, 0x1CB9AD4C, 0xDBFA, 0x4C32, 0xB1, 0x78, 0xC2, 0xF5, 0x68, 0xA7, 0x03, 0xB2);
DEFINE_GUID(IID_IAudioRenderClient, 0xF294ACFC, 0x3146, 0x4483, 0xA7, 0xBF, 0xAD, 0xDC, 0xA7, 0xC2, 0x60, 0xE2);
DEFINE_GUID(IID_IMMDeviceEnumerator, 0xA95664D2, 0x9614, 0x4F35, 0xA7, 0x46, 0xDE, 0x8D, 0xB6, 0x36, 0x17, 0xE6);
DEFINE_GUID(CLSID_MMDeviceEnumerator, 0xBCDE0395, 0xE52F, 0x467C, 0x8E, 0x3D, 0xC4, 0x57, 0x92, 0x91, 0x69, 0x2E);
#undef KSDATAFORMAT_SUBTYPE_IEEE_FLOAT
DEFINE_GUID(KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, 0x00000003, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
#endif
DEFINE_PROPERTYKEY(PKEY_Device_FriendlyName, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 14); /* DEVPROP_TYPE_STRING */
#ifdef __cplusplus
#define _IMMDeviceCollection_Item(This,nDevice,ppdevice) (This)->Item(nDevice,ppdevice)
#define _IAudioClient_Start(This) ( (This)->Start() )
#define _IAudioClient_Stop(This) ( (This)->Stop() )
#define _IAudioClient_GetCurrentPadding(This,pNumPaddingFrames) \
( (This)->GetCurrentPadding(pNumPaddingFrames) )
#define _IAudioRenderClient_GetBuffer(This,NumFramesRequested,ppData) \
( (This)->GetBuffer(NumFramesRequested,ppData) )
#define _IAudioRenderClient_ReleaseBuffer(This,NumFramesWritten,dwFlags) \
( (This)->ReleaseBuffer(NumFramesWritten,dwFlags) )
#define _IAudioClient_GetService(This,riid,ppv) ( (This)->GetService(riid,ppv) )
#define _IAudioClient_SetEventHandle(This,eventHandle) ( (This)->SetEventHandle(eventHandle) )
#define _IAudioClient_GetBufferSize(This,pNumBufferFrames) ( (This)->GetBufferSize(pNumBufferFrames) )
#define _IAudioClient_GetStreamLatency(This,phnsLatency) ( (This)->GetStreamLatency(phnsLatency) )
#define _IAudioClient_GetDevicePeriod(This,phnsDefaultDevicePeriod,phnsMinimumDevicePeriod) ( (This)->GetDevicePeriod(phnsDefaultDevicePeriod,phnsMinimumDevicePeriod) )
#define _IMMDevice_Activate(This,iid,dwClsCtx,pActivationParams,ppv) ((This)->Activate(iid,(dwClsCtx),pActivationParams,ppv))
#define _IMMDeviceEnumerator_EnumAudioEndpoints(This,dataFlow,dwStateMask,ppDevices) (This)->EnumAudioEndpoints(dataFlow,dwStateMask,ppDevices)
#define _IMMDeviceEnumerator_GetDefaultAudioEndpoint(This,dataFlow,role,ppEndpoint) (This)->GetDefaultAudioEndpoint(dataFlow,role,ppEndpoint)
#define _IMMDevice_OpenPropertyStore(This,stgmAccess,ppProperties) (This)->OpenPropertyStore(stgmAccess,ppProperties)
#define _IMMDevice_GetId(This,ppstrId) ((This)->GetId(ppstrId))
#define _IPropertyStore_GetValue(This,key,pv) ( (This)->GetValue(key,pv) )
#define _IMMDeviceCollection_GetCount(This,cProps) ( (This)->GetCount(cProps) )
#else
#define _IMMDeviceCollection_Item(This,nDevice,ppdevice) (This)->lpVtbl->Item(This,nDevice,ppdevice)
#define _IAudioClient_Start(This) ( (This)->lpVtbl -> Start(This) )
#define _IAudioClient_Stop(This) ( (This)->lpVtbl -> Stop(This) )
#define _IAudioClient_GetCurrentPadding(This,pNumPaddingFrames) \
( (This)->lpVtbl -> GetCurrentPadding(This,pNumPaddingFrames) )
#define _IAudioRenderClient_GetBuffer(This,NumFramesRequested,ppData) \
( (This)->lpVtbl -> GetBuffer(This,NumFramesRequested,ppData) )
#define _IAudioRenderClient_ReleaseBuffer(This,NumFramesWritten,dwFlags) \
( (This)->lpVtbl -> ReleaseBuffer(This,NumFramesWritten,dwFlags) )
#define _IAudioClient_GetService(This,riid,ppv) ( (This)->lpVtbl -> GetService(This,&(riid),ppv) )
#define _IAudioClient_SetEventHandle(This,eventHandle) ( (This)->lpVtbl -> SetEventHandle(This,eventHandle) )
#define _IAudioClient_GetBufferSize(This,pNumBufferFrames) ( (This)->lpVtbl -> GetBufferSize(This,pNumBufferFrames) )
#define _IAudioClient_GetStreamLatency(This,phnsLatency) ( (This)->lpVtbl -> GetStreamLatency(This,phnsLatency) )
#define _IAudioClient_GetDevicePeriod(This,phnsDefaultDevicePeriod,phnsMinimumDevicePeriod) ( (This)->lpVtbl -> GetDevicePeriod(This,phnsDefaultDevicePeriod,phnsMinimumDevicePeriod) )
#define _IMMDevice_Activate(This,iid,dwClsCtx,pActivationParams,ppv) ((This)->lpVtbl->Activate(This,&(iid),dwClsCtx,pActivationParams,ppv))
#define _IMMDeviceEnumerator_EnumAudioEndpoints(This,dataFlow,dwStateMask,ppDevices) (This)->lpVtbl->EnumAudioEndpoints(This,dataFlow,dwStateMask,ppDevices)
#define _IMMDeviceEnumerator_GetDefaultAudioEndpoint(This,dataFlow,role,ppEndpoint) (This)->lpVtbl->GetDefaultAudioEndpoint(This,dataFlow,role,ppEndpoint)
#define _IMMDevice_OpenPropertyStore(This,stgmAccess,ppProperties) (This)->lpVtbl->OpenPropertyStore(This,stgmAccess,ppProperties)
#define _IMMDevice_GetId(This,ppstrId) (This)->lpVtbl->GetId(This,ppstrId)
#define _IPropertyStore_GetValue(This,key,pv) ( (This)->lpVtbl -> GetValue(This,&(key),pv) )
#define _IMMDeviceCollection_GetCount(This,cProps) ( (This)->lpVtbl -> GetCount(This,cProps) )
#endif
#ifdef __cplusplus
#ifndef IFACE_RELEASE
#define IFACE_RELEASE(iface) \
if (iface) \
{ \
iface->Release(); \
iface = NULL; \
}
#endif
#else
#ifndef IFACE_RELEASE
#define IFACE_RELEASE(iface) \
if (iface) \
{ \
iface->lpVtbl->Release(iface);\
iface = NULL; \
}
#endif
#endif
RETRO_BEGIN_DECLS
void *mmdevice_list_new(void *u);
RETRO_END_DECLS
#endif

View File

@ -15,100 +15,15 @@
#include <stdlib.h>
#ifdef _WIN32_WINNT
#undef _WIN32_WINNT
#endif
#define _WIN32_WINNT 0x0600
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winerror.h>
#include <propidl.h>
#include <initguid.h>
#include <mmdeviceapi.h>
#include <mmreg.h>
#include <audioclient.h>
#ifdef _MSC_VER
DEFINE_GUID(IID_IAudioClient, 0x1CB9AD4C, 0xDBFA, 0x4C32, 0xB1, 0x78, 0xC2, 0xF5, 0x68, 0xA7, 0x03, 0xB2);
DEFINE_GUID(IID_IAudioRenderClient, 0xF294ACFC, 0x3146, 0x4483, 0xA7, 0xBF, 0xAD, 0xDC, 0xA7, 0xC2, 0x60, 0xE2);
DEFINE_GUID(IID_IMMDeviceEnumerator, 0xA95664D2, 0x9614, 0x4F35, 0xA7, 0x46, 0xDE, 0x8D, 0xB6, 0x36, 0x17, 0xE6);
DEFINE_GUID(CLSID_MMDeviceEnumerator, 0xBCDE0395, 0xE52F, 0x467C, 0x8E, 0x3D, 0xC4, 0x57, 0x92, 0x91, 0x69, 0x2E);
#undef KSDATAFORMAT_SUBTYPE_IEEE_FLOAT
DEFINE_GUID(KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, 0x00000003, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
#endif
#include <lists/string_list.h>
#include <queues/fifo_queue.h>
#include "../common/mmdevice_common.h"
#include "../../retroarch.h"
#include "../../verbosity.h"
#include "../../configuration.h"
DEFINE_PROPERTYKEY(PKEY_Device_FriendlyName, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 14); /* DEVPROP_TYPE_STRING */
#ifdef __cplusplus
#define _IMMDeviceCollection_Item(This,nDevice,ppdevice) (This)->Item(nDevice,ppdevice)
#define _IAudioClient_Start(This) ( (This)->Start() )
#define _IAudioClient_Stop(This) ( (This)->Stop() )
#define _IAudioClient_GetCurrentPadding(This,pNumPaddingFrames) \
( (This)->GetCurrentPadding(pNumPaddingFrames) )
#define _IAudioRenderClient_GetBuffer(This,NumFramesRequested,ppData) \
( (This)->GetBuffer(NumFramesRequested,ppData) )
#define _IAudioRenderClient_ReleaseBuffer(This,NumFramesWritten,dwFlags) \
( (This)->ReleaseBuffer(NumFramesWritten,dwFlags) )
#define _IAudioClient_GetService(This,riid,ppv) ( (This)->GetService(riid,ppv) )
#define _IAudioClient_SetEventHandle(This,eventHandle) ( (This)->SetEventHandle(eventHandle) )
#define _IAudioClient_GetBufferSize(This,pNumBufferFrames) ( (This)->GetBufferSize(pNumBufferFrames) )
#define _IAudioClient_GetStreamLatency(This,phnsLatency) ( (This)->GetStreamLatency(phnsLatency) )
#define _IAudioClient_GetDevicePeriod(This,phnsDefaultDevicePeriod,phnsMinimumDevicePeriod) ( (This)->GetDevicePeriod(phnsDefaultDevicePeriod,phnsMinimumDevicePeriod) )
#define _IMMDevice_Activate(This,iid,dwClsCtx,pActivationParams,ppv) ((This)->Activate(iid,(dwClsCtx),pActivationParams,ppv))
#define _IMMDeviceEnumerator_EnumAudioEndpoints(This,dataFlow,dwStateMask,ppDevices) (This)->EnumAudioEndpoints(dataFlow,dwStateMask,ppDevices)
#define _IMMDeviceEnumerator_GetDefaultAudioEndpoint(This,dataFlow,role,ppEndpoint) (This)->GetDefaultAudioEndpoint(dataFlow,role,ppEndpoint)
#define _IMMDevice_OpenPropertyStore(This,stgmAccess,ppProperties) (This)->OpenPropertyStore(stgmAccess,ppProperties)
#define _IMMDevice_GetId(This,ppstrId) ((This)->GetId(ppstrId))
#define _IPropertyStore_GetValue(This,key,pv) ( (This)->GetValue(key,pv) )
#define _IMMDeviceCollection_GetCount(This,cProps) ( (This)->GetCount(cProps) )
#else
#define _IMMDeviceCollection_Item(This,nDevice,ppdevice) (This)->lpVtbl->Item(This,nDevice,ppdevice)
#define _IAudioClient_Start(This) ( (This)->lpVtbl -> Start(This) )
#define _IAudioClient_Stop(This) ( (This)->lpVtbl -> Stop(This) )
#define _IAudioClient_GetCurrentPadding(This,pNumPaddingFrames) \
( (This)->lpVtbl -> GetCurrentPadding(This,pNumPaddingFrames) )
#define _IAudioRenderClient_GetBuffer(This,NumFramesRequested,ppData) \
( (This)->lpVtbl -> GetBuffer(This,NumFramesRequested,ppData) )
#define _IAudioRenderClient_ReleaseBuffer(This,NumFramesWritten,dwFlags) \
( (This)->lpVtbl -> ReleaseBuffer(This,NumFramesWritten,dwFlags) )
#define _IAudioClient_GetService(This,riid,ppv) ( (This)->lpVtbl -> GetService(This,&(riid),ppv) )
#define _IAudioClient_SetEventHandle(This,eventHandle) ( (This)->lpVtbl -> SetEventHandle(This,eventHandle) )
#define _IAudioClient_GetBufferSize(This,pNumBufferFrames) ( (This)->lpVtbl -> GetBufferSize(This,pNumBufferFrames) )
#define _IAudioClient_GetStreamLatency(This,phnsLatency) ( (This)->lpVtbl -> GetStreamLatency(This,phnsLatency) )
#define _IAudioClient_GetDevicePeriod(This,phnsDefaultDevicePeriod,phnsMinimumDevicePeriod) ( (This)->lpVtbl -> GetDevicePeriod(This,phnsDefaultDevicePeriod,phnsMinimumDevicePeriod) )
#define _IMMDevice_Activate(This,iid,dwClsCtx,pActivationParams,ppv) ((This)->lpVtbl->Activate(This,&(iid),dwClsCtx,pActivationParams,ppv))
#define _IMMDeviceEnumerator_EnumAudioEndpoints(This,dataFlow,dwStateMask,ppDevices) (This)->lpVtbl->EnumAudioEndpoints(This,dataFlow,dwStateMask,ppDevices)
#define _IMMDeviceEnumerator_GetDefaultAudioEndpoint(This,dataFlow,role,ppEndpoint) (This)->lpVtbl->GetDefaultAudioEndpoint(This,dataFlow,role,ppEndpoint)
#define _IMMDevice_OpenPropertyStore(This,stgmAccess,ppProperties) (This)->lpVtbl->OpenPropertyStore(This,stgmAccess,ppProperties)
#define _IMMDevice_GetId(This,ppstrId) (This)->lpVtbl->GetId(This,ppstrId)
#define _IPropertyStore_GetValue(This,key,pv) ( (This)->lpVtbl -> GetValue(This,&(key),pv) )
#define _IMMDeviceCollection_GetCount(This,cProps) ( (This)->lpVtbl -> GetCount(This,cProps) )
#endif
#ifdef __cplusplus
#define IFACE_RELEASE(iface) \
if (iface) \
{ \
iface->Release(); \
iface = NULL; \
}
#else
#define IFACE_RELEASE(iface) \
if (iface) \
{ \
iface->lpVtbl->Release(iface);\
iface = NULL; \
}
#endif
typedef struct
{
bool exclusive;
@ -921,147 +836,6 @@ static bool wasapi_use_float(void *wh)
return w->frame_size == 8;
}
static void *wasapi_device_list_new(void *u)
{
HRESULT hr;
UINT i;
PROPVARIANT prop_var;
int ir;
union string_list_elem_attr attr;
IMMDeviceEnumerator *enumerator = NULL;
IMMDeviceCollection *collection = NULL;
UINT dev_count = 0;
IMMDevice *device = NULL;
LPWSTR dev_id_wstr = NULL;
IPropertyStore *prop_store = NULL;
bool prop_var_init = false;
bool br = false;
char *dev_id_str = NULL;
char *dev_name_str = NULL;
struct string_list *sl = string_list_new();
if (!sl)
return NULL;
attr.i = 0;
#ifdef __cplusplus
hr = CoCreateInstance(CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL,
IID_IMMDeviceEnumerator, (void **)&enumerator);
#else
hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL,
&IID_IMMDeviceEnumerator, (void **)&enumerator);
#endif
if (FAILED(hr))
goto error;
hr = _IMMDeviceEnumerator_EnumAudioEndpoints(enumerator,
eRender, DEVICE_STATE_ACTIVE, &collection);
if (FAILED(hr))
goto error;
hr = _IMMDeviceCollection_GetCount(collection, &dev_count);
if (FAILED(hr))
goto error;
for (i = 0; i < dev_count; ++i)
{
hr = _IMMDeviceCollection_Item(collection, i, &device);
if (FAILED(hr))
goto error;
hr = _IMMDevice_GetId(device, &dev_id_wstr);
if (FAILED(hr))
goto error;
ir = WideCharToMultiByte(CP_ACP, 0, dev_id_wstr, -1,
NULL, 0, NULL, NULL);
if (!ir)
goto error;
dev_id_str = (char *)malloc(ir);
if (!dev_id_str)
goto error;
ir = WideCharToMultiByte(CP_ACP, 0, dev_id_wstr, -1,
dev_id_str, ir, NULL, NULL);
if (!ir)
goto error;
hr = _IMMDevice_OpenPropertyStore(device, STGM_READ, &prop_store);
if (FAILED(hr))
goto error;
PropVariantInit(&prop_var);
prop_var_init = true;
hr = _IPropertyStore_GetValue(prop_store, PKEY_Device_FriendlyName,
&prop_var);
if (FAILED(hr))
goto error;
ir = WideCharToMultiByte(CP_ACP, 0, prop_var.pwszVal, -1,
NULL, 0, NULL, NULL);
if (!ir)
goto error;
dev_name_str = (char *)malloc(ir);
if (!dev_name_str)
goto error;
ir = WideCharToMultiByte(CP_ACP, 0, prop_var.pwszVal, -1,
dev_name_str, ir, NULL, NULL);
if (!ir)
goto error;
RARCH_LOG("[WASAPI]: %s %s\n", dev_name_str, dev_id_str);
br = string_list_append(sl, dev_id_str, attr);
if (!br)
goto error;
PropVariantClear(&prop_var);
prop_var_init = false;
if (dev_id_wstr)
CoTaskMemFree(dev_id_wstr);
if (dev_id_str)
free(dev_id_str);
if (dev_name_str)
free(dev_name_str);
dev_id_str = NULL;
dev_name_str = NULL;
dev_id_wstr = NULL;
IFACE_RELEASE(prop_store);
IFACE_RELEASE(device);
}
IFACE_RELEASE(collection);
IFACE_RELEASE(enumerator);
return sl;
error:
if (dev_id_str)
free(dev_id_str);
if (dev_name_str)
free(dev_name_str);
dev_id_str = NULL;
dev_name_str = NULL;
if (prop_var_init)
PropVariantClear(&prop_var);
IFACE_RELEASE(prop_store);
if (dev_id_wstr)
CoTaskMemFree(dev_id_wstr);
dev_id_wstr = NULL;
IFACE_RELEASE(device);
IFACE_RELEASE(collection);
IFACE_RELEASE(enumerator);
if (sl)
string_list_free(sl);
RARCH_ERR("[WASAPI]: Device enumeration failed.\n");
return NULL;
}
static void wasapi_device_list_free(void *u, void *slp)
{
struct string_list *sl = (struct string_list*)slp;
@ -1106,7 +880,7 @@ audio_driver_t audio_wasapi = {
wasapi_free,
wasapi_use_float,
"wasapi",
wasapi_device_list_new,
mmdevice_list_new,
wasapi_device_list_free,
wasapi_write_avail,
wasapi_buffer_size

View File

@ -1069,12 +1069,12 @@ static bool core_info_compare_api_version(int sys_major, int sys_minor, int majo
bool core_info_hw_api_supported(core_info_t *info)
{
unsigned i;
enum gfx_ctx_api sys_api;
gfx_ctx_flags_t sys_flags = {0};
int i;
gfx_ctx_flags_t sys_flags = {0};
const char *sys_api_version_str = video_driver_get_gpu_api_version_string();
int sys_api_version_major = 0;
int sys_api_version_minor = 0;
int sys_api_version_major = 0;
int sys_api_version_minor = 0;
enum api_parse_state
{
@ -1091,21 +1091,21 @@ bool core_info_hw_api_supported(core_info_t *info)
for (i = 0; i < info->required_hw_api_list->size; i++)
{
char api_str[32] = {0};
char version[16] = {0};
char major_str[16] = {0};
char minor_str[16] = {0};
const char *cur_api = info->required_hw_api_list->elems[i].data;
int api_pos = 0;
int major_str_pos = 0;
int minor_str_pos = 0;
int cur_api_len = 0;
int j = 0;
int major = 0;
int minor = 0;
bool found_major = false;
bool found_minor = false;
enum compare_op op = COMPARE_OP_GREATER_EQUAL;
char api_str[32] = {0};
char version[16] = {0};
char major_str[16] = {0};
char minor_str[16] = {0};
const char *cur_api = info->required_hw_api_list->elems[i].data;
int api_pos = 0;
int major_str_pos = 0;
int minor_str_pos = 0;
int cur_api_len = 0;
int j = 0;
int major = 0;
int minor = 0;
bool found_major = false;
bool found_minor = false;
enum compare_op op = COMPARE_OP_GREATER_EQUAL;
enum api_parse_state state = STATE_API_NAME;
if (string_is_empty(cur_api))
@ -1143,9 +1143,7 @@ bool core_info_hw_api_supported(core_info_t *info)
j++;
}
else if (cur_api[j] == '=')
{
op = COMPARE_OP_EQUAL;
}
else if (cur_api[j] == '!' && cur_api[j + 1] == '=')
{
op = COMPARE_OP_NOT_EQUAL;
@ -1162,13 +1160,9 @@ bool core_info_hw_api_supported(core_info_t *info)
j++;
}
else if (cur_api[j] == '<')
{
op = COMPARE_OP_LESS;
}
else if (cur_api[j] == '>')
{
op = COMPARE_OP_GREATER;
}
}
state = STATE_API_VERSION;
@ -1190,10 +1184,7 @@ bool core_info_hw_api_supported(core_info_t *info)
minor_str[minor_str_pos++] = cur_api[j];
}
else if (cur_api[j] == '.')
{
found_minor = true;
}
break;
}
default:
@ -1216,11 +1207,9 @@ bool core_info_hw_api_supported(core_info_t *info)
(string_is_equal_noncase(api_str, "openglcompat") && sys_api == GFX_CTX_OPENGL_API) ||
(string_is_equal_noncase(api_str, "openglcompatibility") && sys_api == GFX_CTX_OPENGL_API))
{
if (sys_flags.flags & (1 << GFX_CTX_FLAGS_GL_CORE_CONTEXT))
{
/* system is running a core context while compat is requested */
/* system is running a core context while compat is requested */
if (sys_flags.flags & (1 << GFX_CTX_FLAGS_GL_CORE_CONTEXT))
return false;
}
sscanf(sys_api_version_str, "%d.%d", &sys_api_version_major, &sys_api_version_minor);

View File

@ -874,6 +874,10 @@ AUDIO
#include "../audio/drivers/nullaudio.c"
#if defined(HAVE_WASAPI) || defined(HAVE_XAUDIO)
#include "../audio/common/mmdevice_common.c"
#endif
/*============================================================
MIDI
============================================================ */