Commit 1eaf97d0 authored by David Reid's avatar David Reid

Update test to show a message when a device is stopped.

parent 1e9e2759
......@@ -42,9 +42,7 @@
//
// You can then #include this file in other parts of the program as you would with any other header file.
//
// The implementation of this library will try #include-ing necessary headers for some backends. If you do not have
// the development packages for any particular backend you can disable it by #define-ing the appropriate MAL_NO_*
// option before the implementation.
// If you want to disable a specific backend, #define the appropriate MAL_NO_* option before the implementation.
//
// Note that GCC and Clang requires "-msse2", "-mavx2", etc. for SIMD optimizations.
//
......@@ -56,6 +54,7 @@
//
// Building for macOS
// ------------------
// The macOS build requires -framework CoreFoundation -framework CoreAudio -framework AudioToolbox.
//
// Building for Linux
// ------------------
......@@ -12500,6 +12499,12 @@ mal_result mal_device__stop_backend__jack(mal_device* pDevice)
return mal_post_error(pDevice, "[JACK] An error occurred when deactivating the JACK client.", MAL_ERROR);
}
mal_device__set_state(pDevice, MAL_STATE_STOPPED);
mal_stop_proc onStop = pDevice->onStop;
if (onStop) {
onStop(pDevice);
}
return MAL_SUCCESS;
}
#endif // JACK
......@@ -13847,7 +13852,7 @@ mal_result mal_device_init__coreaudio(mal_context* pContext, mal_device_type dev
#endif
// Backend tax. Need to fiddle with this.
float fBackend = 1.0;
float fBackend = 1.5f; // <-- mini_al's implementation is actually kind of bad at the moment. TODO: Revisit this after AudioUnit implementation.
requestedBufferSizeInFrames = mal_calculate_default_buffer_size_in_frames(pConfig->performanceProfile, pConfig->sampleRate, fCPUSpeed*fType*fBackend);
if (requestedBufferSizeInFrames == 0) {
......@@ -15202,8 +15207,9 @@ mal_result mal_device__stop_backend__opensl(mal_device* pDevice)
// Make sure the client is aware that the device has stopped. There may be an OpenSL|ES callback for this, but I haven't found it.
mal_device__set_state(pDevice, MAL_STATE_STOPPED);
if (pDevice->onStop) {
pDevice->onStop(pDevice);
mal_stop_proc onStop = pDevice->onStop;
if (onStop) {
onStop(pDevice);
}
return MAL_SUCCESS;
......@@ -16728,6 +16734,12 @@ mal_result mal_device__stop_backend__sdl(mal_device* pDevice)
((MAL_PFN_SDL_PauseAudio)pDevice->pContext->sdl.SDL_PauseAudio)(1);
}
mal_device__set_state(pDevice, MAL_STATE_STOPPED);
mal_stop_proc onStop = pDevice->onStop;
if (onStop) {
onStop(pDevice);
}
return MAL_SUCCESS;
}
#endif // SDL
......@@ -43,6 +43,12 @@ void on_log(mal_context* pContext, mal_device* pDevice, const char* message)
printf("%s\n", message);
}
void on_stop(mal_device* pDevice)
{
(void)pDevice;
printf("Device Stopped.\n");
}
FILE* mal_fopen(const char* filePath, const char* openMode)
{
FILE* pFile;
......@@ -2272,6 +2278,7 @@ int do_playback_test(mal_backend backend)
{
mal_context_config contextConfig = mal_context_config_init(on_log);
mal_device_config deviceConfig = mal_device_config_init_default_playback(on_send__playback_test);
deviceConfig.onStopCallback = on_stop;
#if defined(__EMSCRIPTEN__)
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