mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-22 00:06:59 +02:00
Minor refactor the AAudio backend.
This commit is contained in:
+30
-19
@@ -41075,18 +41075,39 @@ static ma_result ma_job_process__device__aaudio_reroute(ma_job* pJob)
|
||||
return result;
|
||||
}
|
||||
|
||||
static ma_result ma_device_wait__aaudio(ma_device* pDevice)
|
||||
|
||||
static ma_result ma_device_step__aaudio(ma_device* pDevice, ma_blocking_mode blockingMode)
|
||||
{
|
||||
ma_device_state_aaudio* pDeviceStateAAudio = ma_device_get_backend_state__aaudio(pDevice);
|
||||
ma_device_state_async_wait(&pDeviceStateAAudio->async);
|
||||
|
||||
return MA_SUCCESS;
|
||||
}
|
||||
for (;;) {
|
||||
ma_result result;
|
||||
|
||||
static ma_result ma_device_step__aaudio(ma_device* pDevice)
|
||||
{
|
||||
ma_device_state_aaudio* pDeviceStateAAudio = ma_device_get_backend_state__aaudio(pDevice);
|
||||
ma_device_state_async_step(&pDeviceStateAAudio->async, pDevice);
|
||||
if (blockingMode == MA_BLOCKING_MODE_BLOCKING) {
|
||||
ma_device_state_async_wait(&pDeviceStateAAudio->async);
|
||||
}
|
||||
|
||||
if (!ma_device_is_started(pDevice)) {
|
||||
return MA_DEVICE_NOT_STARTED;
|
||||
}
|
||||
|
||||
result = ma_device_state_async_step(&pDeviceStateAAudio->async, pDevice);
|
||||
if (result == MA_SUCCESS) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (result != MA_NO_DATA_AVAILABLE) {
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Getting here means no data was processed. In non-blocking mode we don't care, just get out of the loop. */
|
||||
if (blockingMode == MA_BLOCKING_MODE_NON_BLOCKING) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* Getting here means we're in blocking mode and no data was processed. In this case we'd rather keep waiting for data to be available. */
|
||||
continue;
|
||||
}
|
||||
|
||||
return MA_SUCCESS;
|
||||
}
|
||||
@@ -41096,17 +41117,7 @@ static void ma_device_loop__aaudio(ma_device* pDevice)
|
||||
MA_ASSERT(pDevice != NULL);
|
||||
|
||||
for (;;) {
|
||||
ma_result result = ma_device_wait__aaudio(pDevice);
|
||||
if (result != MA_SUCCESS) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* If the wait terminated due to the device being stopped, abort now. */
|
||||
if (!ma_device_is_started(pDevice)) {
|
||||
break;
|
||||
}
|
||||
|
||||
result = ma_device_step__aaudio(pDevice);
|
||||
ma_result result = ma_device_step__aaudio(pDevice, MA_BLOCKING_MODE_BLOCKING);
|
||||
if (result != MA_SUCCESS) {
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user