mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-23 16:54:03 +02:00
Add ma_get_stock_device_backends().
This commit many warnings when compiling as C89.
This commit is contained in:
+46
-32
@@ -7151,6 +7151,26 @@ END BACKENDS
|
|||||||
|
|
||||||
************************************************************************************************************************************************************/
|
************************************************************************************************************************************************************/
|
||||||
|
|
||||||
|
/* 64 should be enough to cover all stock backends, but if somehow this is exceeded we can increase this. */
|
||||||
|
#ifndef MA_MAX_STOCK_DEVICE_BACKENDS
|
||||||
|
#define MA_MAX_STOCK_DEVICE_BACKENDS 64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* For mapping a config object to a backend. Used for both context configs or device configs. */
|
||||||
|
typedef struct ma_device_backend_config
|
||||||
|
{
|
||||||
|
ma_device_backend_vtable* pVTable;
|
||||||
|
const void* pConfig; /* Can be a pointer to either a backend-specific context config, or a backend-specific device config, depending on context. */
|
||||||
|
} ma_device_backend_config;
|
||||||
|
|
||||||
|
MA_API ma_device_backend_config ma_device_backend_config_init(ma_device_backend_vtable* pVTable, const void* pConfig);
|
||||||
|
|
||||||
|
|
||||||
|
/* This is the list of default device backends in priority order. */
|
||||||
|
MA_API ma_uint32 ma_get_stock_device_backends(ma_device_backend_config* pBackends, size_t backendsCap);
|
||||||
|
|
||||||
|
|
||||||
typedef struct ma_device_backend_info
|
typedef struct ma_device_backend_info
|
||||||
{
|
{
|
||||||
const char* pName;
|
const char* pName;
|
||||||
@@ -7452,15 +7472,6 @@ struct ma_device_descriptor
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* For mapping a config object to a backend. Used for both context configs or device configs. */
|
|
||||||
typedef struct ma_device_backend_config
|
|
||||||
{
|
|
||||||
ma_device_backend_vtable* pVTable;
|
|
||||||
const void* pConfig; /* Can be a pointer to either a backend-specific context config, or a backend-specific device config, depending on context. */
|
|
||||||
} ma_device_backend_config;
|
|
||||||
|
|
||||||
MA_API ma_device_backend_config ma_device_backend_config_init(ma_device_backend_vtable* pVTable, const void* pConfig);
|
|
||||||
|
|
||||||
|
|
||||||
#define MA_DATA_FORMAT_FLAG_EXCLUSIVE_MODE (1U << 1) /* If set, this is supported in exclusive mode. Otherwise not natively supported by exclusive mode. */
|
#define MA_DATA_FORMAT_FLAG_EXCLUSIVE_MODE (1U << 1) /* If set, this is supported in exclusive mode. Otherwise not natively supported by exclusive mode. */
|
||||||
|
|
||||||
@@ -44395,23 +44406,28 @@ static const void* ma_context_config_find_backend_config(const ma_context_config
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* This is the list of default device backends in priority order. */
|
|
||||||
#define MA_STOCK_DEVICE_BACKENDS \
|
MA_API ma_uint32 ma_get_stock_device_backends(ma_device_backend_config* pBackends, size_t backendsCap)
|
||||||
{ \
|
{
|
||||||
{ ma_device_backend_wasapi, NULL }, \
|
ma_uint32 count = 0;
|
||||||
{ ma_device_backend_dsound, NULL }, \
|
|
||||||
{ ma_device_backend_winmm, NULL }, \
|
/* This must be in priority order. */
|
||||||
{ ma_device_backend_coreaudio, NULL }, \
|
if (backendsCap > count) { pBackends[count++] = ma_device_backend_config_init(ma_device_backend_wasapi, NULL); }
|
||||||
{ ma_device_backend_pulseaudio, NULL }, \
|
if (backendsCap > count) { pBackends[count++] = ma_device_backend_config_init(ma_device_backend_dsound, NULL); }
|
||||||
{ ma_device_backend_alsa, NULL }, \
|
if (backendsCap > count) { pBackends[count++] = ma_device_backend_config_init(ma_device_backend_winmm, NULL); }
|
||||||
{ ma_device_backend_jack, NULL }, \
|
if (backendsCap > count) { pBackends[count++] = ma_device_backend_config_init(ma_device_backend_coreaudio, NULL); }
|
||||||
{ ma_device_backend_sndio, NULL }, \
|
if (backendsCap > count) { pBackends[count++] = ma_device_backend_config_init(ma_device_backend_pulseaudio, NULL); }
|
||||||
{ ma_device_backend_audio4, NULL }, \
|
if (backendsCap > count) { pBackends[count++] = ma_device_backend_config_init(ma_device_backend_alsa, NULL); }
|
||||||
{ ma_device_backend_oss, NULL }, \
|
if (backendsCap > count) { pBackends[count++] = ma_device_backend_config_init(ma_device_backend_jack, NULL); }
|
||||||
{ ma_device_backend_aaudio, NULL }, \
|
if (backendsCap > count) { pBackends[count++] = ma_device_backend_config_init(ma_device_backend_sndio, NULL); }
|
||||||
{ ma_device_backend_opensl, NULL }, \
|
if (backendsCap > count) { pBackends[count++] = ma_device_backend_config_init(ma_device_backend_audio4, NULL); }
|
||||||
{ ma_device_backend_webaudio, NULL }, \
|
if (backendsCap > count) { pBackends[count++] = ma_device_backend_config_init(ma_device_backend_oss, NULL); }
|
||||||
{ ma_device_backend_null, NULL } \
|
if (backendsCap > count) { pBackends[count++] = ma_device_backend_config_init(ma_device_backend_aaudio, NULL); }
|
||||||
|
if (backendsCap > count) { pBackends[count++] = ma_device_backend_config_init(ma_device_backend_opensl, NULL); }
|
||||||
|
if (backendsCap > count) { pBackends[count++] = ma_device_backend_config_init(ma_device_backend_webaudio, NULL); }
|
||||||
|
if (backendsCap > count) { pBackends[count++] = ma_device_backend_config_init(ma_device_backend_null, NULL); }
|
||||||
|
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -44420,8 +44436,7 @@ MA_API ma_result ma_context_init(const ma_device_backend_config* pBackends, ma_u
|
|||||||
ma_result result;
|
ma_result result;
|
||||||
ma_context_config defaultConfig;
|
ma_context_config defaultConfig;
|
||||||
ma_uint32 iBackend;
|
ma_uint32 iBackend;
|
||||||
ma_device_backend_config pStockBackends[] = MA_STOCK_DEVICE_BACKENDS;
|
ma_device_backend_config pStockBackends[MA_MAX_STOCK_DEVICE_BACKENDS];
|
||||||
ma_uint32 stockBackendCount = ma_countof(pStockBackends);
|
|
||||||
|
|
||||||
if (pContext == NULL) {
|
if (pContext == NULL) {
|
||||||
return MA_INVALID_ARGS;
|
return MA_INVALID_ARGS;
|
||||||
@@ -44466,7 +44481,7 @@ MA_API ma_result ma_context_init(const ma_device_backend_config* pBackends, ma_u
|
|||||||
/* If NULL was passed in for the backend list we'll want to iterate over our default list. */
|
/* If NULL was passed in for the backend list we'll want to iterate over our default list. */
|
||||||
if (pBackends == NULL) {
|
if (pBackends == NULL) {
|
||||||
pBackends = pStockBackends;
|
pBackends = pStockBackends;
|
||||||
backendCount = stockBackendCount;
|
backendCount = ma_get_stock_device_backends(pStockBackends, ma_countof(pStockBackends));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (iBackend = 0; iBackend < backendCount; iBackend += 1) {
|
for (iBackend = 0; iBackend < backendCount; iBackend += 1) {
|
||||||
@@ -45237,8 +45252,7 @@ MA_API ma_result ma_device_init_ex(const ma_device_backend_config* pBackends, ma
|
|||||||
ma_context* pContext;
|
ma_context* pContext;
|
||||||
ma_uint32 iBackend;
|
ma_uint32 iBackend;
|
||||||
ma_allocation_callbacks allocationCallbacks;
|
ma_allocation_callbacks allocationCallbacks;
|
||||||
ma_device_backend_config pStockBackends[] = MA_STOCK_DEVICE_BACKENDS;
|
ma_device_backend_config pStockBackends[MA_MAX_STOCK_DEVICE_BACKENDS];
|
||||||
ma_uint32 stockBackendCount = ma_countof(pStockBackends);
|
|
||||||
|
|
||||||
if (pConfig == NULL) {
|
if (pConfig == NULL) {
|
||||||
return MA_INVALID_ARGS;
|
return MA_INVALID_ARGS;
|
||||||
@@ -45260,7 +45274,7 @@ MA_API ma_result ma_device_init_ex(const ma_device_backend_config* pBackends, ma
|
|||||||
|
|
||||||
if (pBackends == NULL) {
|
if (pBackends == NULL) {
|
||||||
pBackends = pStockBackends;
|
pBackends = pStockBackends;
|
||||||
backendCount = stockBackendCount;
|
backendCount = ma_get_stock_device_backends(pStockBackends, ma_countof(pStockBackends));
|
||||||
}
|
}
|
||||||
|
|
||||||
result = MA_NO_BACKEND;
|
result = MA_NO_BACKEND;
|
||||||
|
|||||||
@@ -258,10 +258,12 @@ ma_bool32 try_parse_noise(const char* arg, ma_noise_type* pNoiseType)
|
|||||||
|
|
||||||
void print_enabled_backends(void)
|
void print_enabled_backends(void)
|
||||||
{
|
{
|
||||||
const ma_device_backend_config pStockBackends[] = MA_STOCK_DEVICE_BACKENDS;
|
ma_device_backend_config pStockBackends[MA_MAX_STOCK_DEVICE_BACKENDS];
|
||||||
ma_uint32 stockBackendCount = ma_countof(pStockBackends);
|
ma_uint32 stockBackendCount;
|
||||||
ma_uint32 iEnabledStockBackend;
|
ma_uint32 iEnabledStockBackend;
|
||||||
|
|
||||||
|
stockBackendCount = ma_get_stock_device_backends(pStockBackends, ma_countof(pStockBackends));
|
||||||
|
|
||||||
printf("Enabled Backends:\n");
|
printf("Enabled Backends:\n");
|
||||||
|
|
||||||
for (iEnabledStockBackend = 0; iEnabledStockBackend < stockBackendCount; iEnabledStockBackend += 1) {
|
for (iEnabledStockBackend = 0; iEnabledStockBackend < stockBackendCount; iEnabledStockBackend += 1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user