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

This commit is contained in:
David Reid
2018-06-30 20:47:48 +10:00
parent 1e9e2759b7
commit 1eaf97d061
2 changed files with 25 additions and 6 deletions
+18 -6
View File
@@ -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
// ------------------
@@ -12499,6 +12498,12 @@ mal_result mal_device__stop_backend__jack(mal_device* pDevice)
if (((mal_jack_deactivate_proc)pContext->jack.jack_deactivate)((mal_jack_client_t*)pDevice->jack.pClient) != 0) {
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;
}
@@ -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;
@@ -16727,6 +16733,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;
}
+7
View File
@@ -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;