Commit 6a09fb9c authored by David Reid's avatar David Reid

Fix non-Windows builds.

parent a6ec466e
...@@ -22367,12 +22367,10 @@ static ma_result ma_device_reroute__wasapi(ma_device* pDevice, ma_device_type de ...@@ -22367,12 +22367,10 @@ static ma_result ma_device_reroute__wasapi(ma_device* pDevice, ma_device_type de
return MA_SUCCESS; return MA_SUCCESS;
} }
static ma_result ma_device_start__wasapi(ma_device* pDevice) static ma_result ma_device_start__wasapi_nolock(ma_device* pDevice)
{ {
HRESULT hr; HRESULT hr;
MA_ASSERT(pDevice != NULL);
if (pDevice->pContext->wasapi.hAvrt) { if (pDevice->pContext->wasapi.hAvrt) {
LPCWSTR pTaskName = ma_to_usage_string__wasapi(pDevice->wasapi.usage); LPCWSTR pTaskName = ma_to_usage_string__wasapi(pDevice->wasapi.usage);
if (pTaskName) { if (pTaskName) {
...@@ -22404,7 +22402,23 @@ static ma_result ma_device_start__wasapi(ma_device* pDevice) ...@@ -22404,7 +22402,23 @@ static ma_result ma_device_start__wasapi(ma_device* pDevice)
return MA_SUCCESS; return MA_SUCCESS;
} }
static ma_result ma_device_stop__wasapi(ma_device* pDevice) static ma_result ma_device_start__wasapi(ma_device* pDevice)
{
ma_result result;
MA_ASSERT(pDevice != NULL);
/* Wait for any rerouting to finish before attempting to start the device. */
ma_mutex_lock(&pDevice->wasapi.rerouteLock);
{
result = ma_device_start__wasapi_nolock(pDevice);
}
ma_mutex_unlock(&pDevice->wasapi.rerouteLock);
return result;
}
static ma_result ma_device_stop__wasapi_nolock(ma_device* pDevice)
{ {
ma_result result; ma_result result;
HRESULT hr; HRESULT hr;
...@@ -22452,7 +22466,8 @@ static ma_result ma_device_stop__wasapi(ma_device* pDevice) ...@@ -22452,7 +22466,8 @@ static ma_result ma_device_stop__wasapi(ma_device* pDevice)
if (pDevice->playback.shareMode == ma_share_mode_exclusive) { if (pDevice->playback.shareMode == ma_share_mode_exclusive) {
WaitForSingleObject(pDevice->wasapi.hEventPlayback, waitTime); WaitForSingleObject(pDevice->wasapi.hEventPlayback, waitTime);
} else { }
else {
ma_uint32 prevFramesAvaialablePlayback = (ma_uint32)-1; ma_uint32 prevFramesAvaialablePlayback = (ma_uint32)-1;
ma_uint32 framesAvailablePlayback; ma_uint32 framesAvailablePlayback;
for (;;) { for (;;) {
...@@ -22506,6 +22521,22 @@ static ma_result ma_device_stop__wasapi(ma_device* pDevice) ...@@ -22506,6 +22521,22 @@ static ma_result ma_device_stop__wasapi(ma_device* pDevice)
return MA_SUCCESS; return MA_SUCCESS;
} }
static ma_result ma_device_stop__wasapi(ma_device* pDevice)
{
ma_result result;
MA_ASSERT(pDevice != NULL);
/* Wait for any rerouting to finish before attempting to stop the device. */
ma_mutex_lock(&pDevice->wasapi.rerouteLock);
{
result = ma_device_stop__wasapi_nolock(pDevice);
}
ma_mutex_unlock(&pDevice->wasapi.rerouteLock);
return result;
}
#ifndef MA_WASAPI_WAIT_TIMEOUT_MILLISECONDS #ifndef MA_WASAPI_WAIT_TIMEOUT_MILLISECONDS
#define MA_WASAPI_WAIT_TIMEOUT_MILLISECONDS 5000 #define MA_WASAPI_WAIT_TIMEOUT_MILLISECONDS 5000
...@@ -41182,9 +41213,6 @@ MA_API ma_result ma_device_start(ma_device* pDevice) ...@@ -41182,9 +41213,6 @@ MA_API ma_result ma_device_start(ma_device* pDevice)
return MA_SUCCESS; /* Already started. */ return MA_SUCCESS; /* Already started. */
} }
/* Wait for any rerouting to finish before attempting to start the device. */
ma_mutex_lock(&pDevice->wasapi.rerouteLock);
{
ma_mutex_lock(&pDevice->startStopLock); ma_mutex_lock(&pDevice->startStopLock);
{ {
/* Starting and stopping 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. */
...@@ -41225,8 +41253,6 @@ MA_API ma_result ma_device_start(ma_device* pDevice) ...@@ -41225,8 +41253,6 @@ MA_API ma_result ma_device_start(ma_device* pDevice)
} }
} }
ma_mutex_unlock(&pDevice->startStopLock); ma_mutex_unlock(&pDevice->startStopLock);
}
ma_mutex_unlock(&pDevice->wasapi.rerouteLock);
return result; return result;
} }
...@@ -41247,9 +41273,6 @@ MA_API ma_result ma_device_stop(ma_device* pDevice) ...@@ -41247,9 +41273,6 @@ MA_API ma_result ma_device_stop(ma_device* pDevice)
return MA_SUCCESS; /* Already stopped. */ return MA_SUCCESS; /* Already stopped. */
} }
/* Wait for any rerouting to finish before attempting to stop the device. */
ma_mutex_lock(&pDevice->wasapi.rerouteLock);
{
ma_mutex_lock(&pDevice->startStopLock); ma_mutex_lock(&pDevice->startStopLock);
{ {
/* Starting and stopping are wrapped in a mutex which means we can assert that the device is in a started or paused state. */ /* Starting and stopping are wrapped in a mutex which means we can assert that the device is in a started or paused state. */
...@@ -41298,8 +41321,6 @@ MA_API ma_result ma_device_stop(ma_device* pDevice) ...@@ -41298,8 +41321,6 @@ MA_API ma_result ma_device_stop(ma_device* pDevice)
pDevice->playback.inputCacheRemaining = 0; pDevice->playback.inputCacheRemaining = 0;
} }
ma_mutex_unlock(&pDevice->startStopLock); ma_mutex_unlock(&pDevice->startStopLock);
}
ma_mutex_unlock(&pDevice->wasapi.rerouteLock);
return result; return result;
} }
...@@ -73009,7 +73030,7 @@ MA_API ma_result ma_engine_init(const ma_engine_config* pConfig, ma_engine* pEng ...@@ -73009,7 +73030,7 @@ MA_API ma_result ma_engine_init(const ma_engine_config* pConfig, ma_engine* pEng
Temporarily disabled. There is a subtle bug here where front-left and front-right Temporarily disabled. There is a subtle bug here where front-left and front-right
will be used by the device's channel map, but this is not what we want to use for will be used by the device's channel map, but this is not what we want to use for
spatialization. Instead we want to use side-left and side-right. I need to figure spatialization. Instead we want to use side-left and side-right. I need to figure
out a better solution for this. For now, disabling the user of device channel maps. out a better solution for this. For now, disabling the use of device channel maps.
*/ */
/*listenerConfig.pChannelMapOut = pEngine->pDevice->playback.channelMap;*/ /*listenerConfig.pChannelMapOut = pEngine->pDevice->playback.channelMap;*/
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment