mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-23 08:44:04 +02:00
Minor refactor the AAudio backend.
This commit is contained in:
+29
-18
@@ -41075,18 +41075,39 @@ static ma_result ma_job_process__device__aaudio_reroute(ma_job* pJob)
|
|||||||
return result;
|
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_aaudio* pDeviceStateAAudio = ma_device_get_backend_state__aaudio(pDevice);
|
||||||
ma_device_state_async_wait(&pDeviceStateAAudio->async);
|
|
||||||
|
|
||||||
return MA_SUCCESS;
|
for (;;) {
|
||||||
|
ma_result result;
|
||||||
|
|
||||||
|
if (blockingMode == MA_BLOCKING_MODE_BLOCKING) {
|
||||||
|
ma_device_state_async_wait(&pDeviceStateAAudio->async);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ma_result ma_device_step__aaudio(ma_device* pDevice)
|
if (!ma_device_is_started(pDevice)) {
|
||||||
{
|
return MA_DEVICE_NOT_STARTED;
|
||||||
ma_device_state_aaudio* pDeviceStateAAudio = ma_device_get_backend_state__aaudio(pDevice);
|
}
|
||||||
ma_device_state_async_step(&pDeviceStateAAudio->async, pDevice);
|
|
||||||
|
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;
|
return MA_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -41096,17 +41117,7 @@ static void ma_device_loop__aaudio(ma_device* pDevice)
|
|||||||
MA_ASSERT(pDevice != NULL);
|
MA_ASSERT(pDevice != NULL);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
ma_result result = ma_device_wait__aaudio(pDevice);
|
ma_result result = ma_device_step__aaudio(pDevice, MA_BLOCKING_MODE_BLOCKING);
|
||||||
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);
|
|
||||||
if (result != MA_SUCCESS) {
|
if (result != MA_SUCCESS) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user