SetEvent(pThis->pDevice->wasapi.hBreakEvent); // <-- The main loop will be waiting on some events. We want to break from this wait ASAP so we can change the device as quickly as possible.
#if 0
SetEvent(pThis->pDevice->wasapi.hBreakEvent); // <-- The main loop will be waiting on some events. We want to break from this wait ASAP so we can change the device as quickly as possible.
if (pDevice->pContext->onDeviceRead || pDevice->pContext->onDeviceWrite) { /* <-- TODO: Get rid of this check once the old implementation has been entirely replaced. */
return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "mal_device_start() called for an uninitialized device.", MAL_DEVICE_NOT_INITIALIZED);
return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "mal_device_start() called for an uninitialized device.", MAL_DEVICE_NOT_INITIALIZED);
}
}
/*
Starting the device doesn't do anything in synchronous mode because in that case it's started automatically with
mal_device_write() and mal_device_read(). It's best to return an error so that the application can be aware that
it's not doing it right.
*/
if (!mal_device__is_async(pDevice)) {
return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "mal_device_start() called in synchronous mode. This should only be used in asynchronous/callback mode.", MAL_DEVICE_NOT_INITIALIZED);
}
mal_result result = MAL_ERROR;
mal_result result = MAL_ERROR;
mal_mutex_lock(&pDevice->lock);
mal_mutex_lock(&pDevice->lock);
{
{
// Starting, stopping and pausing are wrapped in a mutex which means we can assert that the device is in a stopped or paused state.
// Starting and stopping are wrapped in a mutex which means we can assert that the device is in a stopped or paused state.