API CHANGE: Change return type of device enumeration callback.

The callback passed into `ma_context_enumerate_devices()` would
previously return a boolean, with true telling miniaudio to continue
enumeration, and false to abort. This got a bit confusing to read at
times, so I've decided to make this more explicit.

The new return type is an enum called `ma_device_enumeration_result`.
Instead of returning true to continue enumeration, the new return value
is `MA_DEVICE_ENUMERATION_CONTINUE`. Similarly, instead of returning
false to abort enumeration, `MA_DEVICE_ENUMERATION_ABORT` should be
returned instead.
This commit is contained in:
David Reid
2025-07-21 11:33:15 +10:00
parent 5d86a6ef82
commit 2b81f75cca
3 changed files with 106 additions and 138 deletions
@@ -363,7 +363,7 @@ static void ma_context_uninit__pipewire(ma_context* pContext)
ma_free(pContextStatePipeWire, ma_context_get_allocation_callbacks(pContext));
}
static ma_bool32 ma_context_enumerate_device_from_type__pipewire(ma_context* pContext, ma_device_type deviceType, ma_enum_devices_callback_proc callback, void* pUserData)
static ma_device_enumeration_result ma_context_enumerate_device_from_type__pipewire(ma_context* pContext, ma_device_type deviceType, ma_enum_devices_callback_proc callback, void* pUserData)
{
ma_device_info deviceInfo;
@@ -396,7 +396,7 @@ static ma_bool32 ma_context_enumerate_device_from_type__pipewire(ma_context* pCo
static ma_result ma_context_enumerate_devices__pipewire(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData)
{
ma_context_state_pipewire* pContextStatePipeWire = ma_context_get_backend_state__pipewire(pContext);
ma_bool32 cbResult = MA_TRUE;
ma_device_enumeration_result cbResult = MA_DEVICE_ENUMERATION_CONTINUE;
MA_PIPEWIRE_ASSERT(pContextStatePipeWire != NULL);
MA_PIPEWIRE_ASSERT(callback != NULL);
@@ -404,12 +404,12 @@ static ma_result ma_context_enumerate_devices__pipewire(ma_context* pContext, ma
/* TODO: Proper device enumeration. */
/* Playback. */
if (cbResult) {
if (cbResult == MA_DEVICE_ENUMERATION_CONTINUE) {
cbResult = ma_context_enumerate_device_from_type__pipewire(pContext, ma_device_type_playback, callback, pUserData);
}
/* Capture. */
if (cbResult) {
if (cbResult == MA_DEVICE_ENUMERATION_CONTINUE) {
cbResult = ma_context_enumerate_device_from_type__pipewire(pContext, ma_device_type_capture, callback, pUserData);
}