mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-24 01:04:02 +02:00
Update test to show a message when a device is stopped.
This commit is contained in:
@@ -42,9 +42,7 @@
|
|||||||
//
|
//
|
||||||
// You can then #include this file in other parts of the program as you would with any other header file.
|
// 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
|
// If you want to disable a specific backend, #define the appropriate MAL_NO_* option before the implementation.
|
||||||
// the development packages for any particular backend you can disable it by #define-ing the appropriate MAL_NO_*
|
|
||||||
// option before the implementation.
|
|
||||||
//
|
//
|
||||||
// Note that GCC and Clang requires "-msse2", "-mavx2", etc. for SIMD optimizations.
|
// Note that GCC and Clang requires "-msse2", "-mavx2", etc. for SIMD optimizations.
|
||||||
//
|
//
|
||||||
@@ -56,6 +54,7 @@
|
|||||||
//
|
//
|
||||||
// Building for macOS
|
// Building for macOS
|
||||||
// ------------------
|
// ------------------
|
||||||
|
// The macOS build requires -framework CoreFoundation -framework CoreAudio -framework AudioToolbox.
|
||||||
//
|
//
|
||||||
// Building for Linux
|
// 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) {
|
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);
|
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;
|
return MAL_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -13847,7 +13852,7 @@ mal_result mal_device_init__coreaudio(mal_context* pContext, mal_device_type dev
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Backend tax. Need to fiddle with this.
|
// 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);
|
requestedBufferSizeInFrames = mal_calculate_default_buffer_size_in_frames(pConfig->performanceProfile, pConfig->sampleRate, fCPUSpeed*fType*fBackend);
|
||||||
if (requestedBufferSizeInFrames == 0) {
|
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.
|
// 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);
|
mal_device__set_state(pDevice, MAL_STATE_STOPPED);
|
||||||
if (pDevice->onStop) {
|
mal_stop_proc onStop = pDevice->onStop;
|
||||||
pDevice->onStop(pDevice);
|
if (onStop) {
|
||||||
|
onStop(pDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
return MAL_SUCCESS;
|
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_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;
|
return MAL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,12 @@ void on_log(mal_context* pContext, mal_device* pDevice, const char* message)
|
|||||||
printf("%s\n", 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* mal_fopen(const char* filePath, const char* openMode)
|
||||||
{
|
{
|
||||||
FILE* pFile;
|
FILE* pFile;
|
||||||
@@ -2272,6 +2278,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;
|
||||||
|
|
||||||
#if defined(__EMSCRIPTEN__)
|
#if defined(__EMSCRIPTEN__)
|
||||||
deviceConfig.format = mal_format_f32;
|
deviceConfig.format = mal_format_f32;
|
||||||
|
|||||||
Reference in New Issue
Block a user