Set up some infrastructure for the new device info structure.

This commit is contained in:
David Reid
2026-01-15 14:24:41 +10:00
parent 461ced3280
commit 434bfc6a0b
2 changed files with 20 additions and 5 deletions
+16 -4
View File
@@ -7553,19 +7553,31 @@ struct ma_device_descriptor
typedef struct typedef struct
{ {
/* Basic info. This is the only information guaranteed to be filled in during device enumeration. */
ma_device_id id; ma_device_id id;
char name[MA_MAX_DEVICE_NAME_LENGTH + 1]; /* +1 for null terminator. */ char name[MA_MAX_DEVICE_NAME_LENGTH + 1]; /* +1 for null terminator. */
ma_bool32 isDefault; ma_bool32 isDefault;
/*
List of natively supported formats. Each entry should have a unique [flags,format] pair which
can be thought of as the key. Then each entry will have a range of supported channels and sample
rates. Note that a device won't necessarily support every single channel and sample rate between
the reported range. For example, a sample rate range of [44100, 48000] may be reported, but
that doesn't mean a rate of, say, 47000 will be supported. The same applies for channels.
*/
ma_uint32 nativeDataFormatCount; ma_uint32 nativeDataFormatCount;
struct struct
{ {
ma_format format; /* Sample format. If set to ma_format_unknown, all sample formats are supported. */ ma_uint32 flags; /* A combination of MA_DATA_FORMAT_FLAG_* flags. */
ma_format format; /* Sample format. */
ma_uint32 minChannels;
ma_uint32 maxChannels;
ma_uint32 minSampleRate;
ma_uint32 maxSampleRate;
/* Legacy deprecated stuff. Will be removed later when the new system is added.. */
ma_uint32 channels; /* If set to 0, all channels are supported. */ ma_uint32 channels; /* If set to 0, all channels are supported. */
ma_uint32 sampleRate; /* If set to 0, all sample rates are supported. */ ma_uint32 sampleRate; /* If set to 0, all sample rates are supported. */
ma_uint32 flags; /* A combination of MA_DATA_FORMAT_FLAG_* flags. */ } nativeDataFormats[16]; /* Should be big enough for [flags,format] to act as the key. */
} nativeDataFormats[/*ma_format_count * ma_standard_sample_rate_count * MA_MAX_CHANNELS*/ 64]; /* Not sure how big to make this. There can be *many* permutations for virtual devices which can support anything. */
} ma_device_info; } ma_device_info;
struct ma_device_config struct ma_device_config
+4 -1
View File
@@ -335,7 +335,10 @@ ma_result print_device_info(const ma_device_info* pDeviceInfo, ma_bool32 printDe
printf(" Default: %s\n", (pDeviceInfo->isDefault) ? "Yes" : "No"); printf(" Default: %s\n", (pDeviceInfo->isDefault) ? "Yes" : "No");
printf(" Format Count: %d\n", pDeviceInfo->nativeDataFormatCount); printf(" Format Count: %d\n", pDeviceInfo->nativeDataFormatCount);
for (iFormat = 0; iFormat < pDeviceInfo->nativeDataFormatCount; ++iFormat) { for (iFormat = 0; iFormat < pDeviceInfo->nativeDataFormatCount; ++iFormat) {
printf(" %s, %d, %d\n", ma_get_format_name(pDeviceInfo->nativeDataFormats[iFormat].format), pDeviceInfo->nativeDataFormats[iFormat].channels, pDeviceInfo->nativeDataFormats[iFormat].sampleRate); printf(" %s, [%d, %d], [%d, %d]\n",
ma_get_format_name(pDeviceInfo->nativeDataFormats[iFormat].format),
pDeviceInfo->nativeDataFormats[iFormat].minChannels, pDeviceInfo->nativeDataFormats[iFormat].maxChannels,
pDeviceInfo->nativeDataFormats[iFormat].minSampleRate, pDeviceInfo->nativeDataFormats[iFormat].maxSampleRate);
} }
} }