(MMDevice) Changes:
* Add mmdevice_samplerate * _WIN32_WINNT checks will fail on modern MSYS2/MIngw-w64 setups (Win10/11) - _WINN32_WINNT will be 0x0601 (1537) - i.e. Win7 and up. We can assume MMDevice is available since Vista, so lower these checks to Vista and up
This commit is contained in:
parent
1cb78161a6
commit
537712a634
|
@ -108,6 +108,45 @@ const char *mmdevice_hresult_name(int hr)
|
|||
return "<unknown>";
|
||||
}
|
||||
|
||||
size_t mmdevice_samplerate(void *data)
|
||||
{
|
||||
HRESULT hr;
|
||||
PWAVEFORMATEX devfmt_props;
|
||||
PROPVARIANT prop_var;
|
||||
IMMDevice *device = (IMMDevice*)data;
|
||||
IPropertyStore *prop_store = NULL;
|
||||
DWORD result = 0;
|
||||
|
||||
if (!device)
|
||||
return 0;
|
||||
|
||||
hr = _IMMDevice_OpenPropertyStore(device,
|
||||
STGM_READ, &prop_store);
|
||||
|
||||
if (FAILED(hr))
|
||||
return 0;
|
||||
|
||||
PropVariantInit(&prop_var);
|
||||
hr = _IPropertyStore_GetValue(prop_store,
|
||||
PKEY_AudioEngine_DeviceFormat, &prop_var);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
devfmt_props = (PWAVEFORMATEX)prop_var.blob.pBlobData;
|
||||
result = devfmt_props->nSamplesPerSec;
|
||||
}
|
||||
|
||||
PropVariantClear(&prop_var);
|
||||
if (prop_store)
|
||||
{
|
||||
#ifdef __cplusplus
|
||||
prop_store->Release();
|
||||
#else
|
||||
prop_store->lpVtbl->Release(prop_store);
|
||||
#endif
|
||||
prop_store = NULL;
|
||||
}
|
||||
return (size_t)result;
|
||||
}
|
||||
|
||||
char *mmdevice_name(void *data)
|
||||
{
|
||||
|
|
|
@ -30,8 +30,14 @@ void *mmdevice_list_new(const void *u, unsigned data_flow);
|
|||
*/
|
||||
char* mmdevice_name(void *data);
|
||||
|
||||
/**
|
||||
* Gets the samplerate of the provided IMMDevice.
|
||||
*/
|
||||
size_t mmdevice_samplerate(void *data);
|
||||
|
||||
const char *mmdevice_hresult_name(int hr);
|
||||
|
||||
|
||||
void *mmdevice_init_device(const char *id, unsigned data_flow);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Fix for MSYS2 increasing _WIN32_WINNT to 0x0603*/
|
||||
/* Fix for MSYS2 increasing _WIN32_WINNT to 0x0603 */
|
||||
#if defined(__MINGW32__) || defined(__MINGW64__)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
|
|
|
@ -38,7 +38,13 @@
|
|||
|
||||
#include "xaudio.h"
|
||||
|
||||
#if (_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/)
|
||||
#if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0600 /*_WIN32_WINNT_VISTA */)
|
||||
#ifndef HAVE_MMDEVICE
|
||||
#define HAVE_MMDEVICE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MMDEVICE
|
||||
#include "../common/mmdevice_common.h"
|
||||
#endif
|
||||
|
||||
|
@ -265,29 +271,27 @@ static xaudio2_t *xaudio2_new(unsigned *rate, unsigned channels,
|
|||
/* Search for device name first */
|
||||
if (list && list->elems)
|
||||
{
|
||||
if (list->elems)
|
||||
/* If any devices were found... */
|
||||
size_t i;
|
||||
for (i = 0; i < list->size; i++)
|
||||
{
|
||||
/* If any devices were found... */
|
||||
size_t i;
|
||||
for (i = 0; i < list->size; i++)
|
||||
if (string_is_equal(dev_id, list->elems[i].data))
|
||||
{
|
||||
if (string_is_equal(dev_id, list->elems[i].data))
|
||||
{
|
||||
RARCH_DBG("[XAudio2] Found device #%d: \"%s\".\n", i, list->elems[i].data);
|
||||
idx_found = i;
|
||||
break;
|
||||
}
|
||||
RARCH_DBG("[XAudio2] Found device #%d: \"%s\".\n", i,
|
||||
list->elems[i].data);
|
||||
idx_found = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Index was not found yet based on name string,
|
||||
* just assume id is a one-character number index. */
|
||||
if (idx_found == -1)
|
||||
/* Index was not found yet based on name string,
|
||||
* just assume id is a one-character number index. */
|
||||
if (idx_found == -1)
|
||||
{
|
||||
if (isdigit(dev_id[0]))
|
||||
{
|
||||
if (isdigit(dev_id[0]))
|
||||
{
|
||||
idx_found = strtoul(dev_id, NULL, 0);
|
||||
RARCH_LOG("[XAudio2] Fallback, device index is a single number index instead: %d.\n", idx_found);
|
||||
}
|
||||
idx_found = strtoul(dev_id, NULL, 0);
|
||||
RARCH_LOG("[XAudio2] Fallback, device index is a single number index instead: %d.\n", idx_found);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -521,7 +525,7 @@ static void xa_device_list_free(void *u, void *slp)
|
|||
|
||||
static void *xa_list_new(void *u)
|
||||
{
|
||||
#if defined(_XBOX) || !(_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/)
|
||||
#if defined(_XBOX) || !defined(HAVE_MMDEVICE)
|
||||
unsigned i;
|
||||
union string_list_elem_attr attr;
|
||||
uint32_t dev_count = 0;
|
||||
|
|
Loading…
Reference in New Issue