Commit f57e03c5 authored by David Reid's avatar David Reid

Fix deadlock in example when a device is closed unexpectedly.

parent d0b8588b
...@@ -2260,6 +2260,15 @@ mal_uint32 on_send__playback_test(mal_device* pDevice, mal_uint32 frameCount, vo ...@@ -2260,6 +2260,15 @@ mal_uint32 on_send__playback_test(mal_device* pDevice, mal_uint32 frameCount, vo
#endif #endif
} }
void on_stop__playback_test(mal_device* pDevice)
{
playback_test_callback_data* pData = (playback_test_callback_data*)pDevice->pUserData;
mal_assert(pData != NULL);
printf("Device Stopped.\n");
mal_event_signal(&pData->endOfPlaybackEvent);
}
int do_playback_test(mal_backend backend) int do_playback_test(mal_backend backend)
{ {
mal_result result = MAL_SUCCESS; mal_result result = MAL_SUCCESS;
...@@ -2280,7 +2289,7 @@ int do_playback_test(mal_backend backend) ...@@ -2280,7 +2289,7 @@ int do_playback_test(mal_backend backend)
{ {
mal_context_config contextConfig = mal_context_config_init(on_log); mal_context_config contextConfig = mal_context_config_init(on_log);
mal_device_config deviceConfig = mal_device_config_init_default_playback(on_send__playback_test); mal_device_config deviceConfig = mal_device_config_init_default_playback(on_send__playback_test);
deviceConfig.onStopCallback = on_stop; deviceConfig.onStopCallback = on_stop__playback_test;
#if defined(__EMSCRIPTEN__) #if defined(__EMSCRIPTEN__)
deviceConfig.format = mal_format_f32; deviceConfig.format = mal_format_f32;
......
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