From c9d023230afa36882ab0b4beb58548d2169087fa Mon Sep 17 00:00:00 2001 From: Tom M Date: Sat, 7 Mar 2020 14:14:28 +0100 Subject: [PATCH] Add verbose error logging for opensles and oboe (#627) --- src/drivers/fluid_oboe.cpp | 13 ++++++++----- src/drivers/fluid_opensles.c | 31 +++++++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/drivers/fluid_oboe.cpp b/src/drivers/fluid_oboe.cpp index 91f2b189..f5500e96 100644 --- a/src/drivers/fluid_oboe.cpp +++ b/src/drivers/fluid_oboe.cpp @@ -126,7 +126,6 @@ new_fluid_oboe_audio_driver(fluid_settings_t *settings, fluid_synth_t *synth) try { - dev = FLUID_NEW(fluid_oboe_audio_driver_t); if(dev == NULL) @@ -171,21 +170,25 @@ new_fluid_oboe_audio_driver(fluid_settings_t *settings, fluid_synth_t *synth) ->setCallback(dev->oboe_callback); result = builder->openStream(&stream); - dev->stream = stream; - if(result != Result::OK) { + FLUID_LOG(FLUID_ERR, "Unable to open Oboe audio stream"); goto error_recovery; } + dev->stream = stream; dev->cont = 1; FLUID_LOG(FLUID_INFO, "Using Oboe driver"); - stream->start(); + result = stream->start(); + if(result != Result::OK) + { + FLUID_LOG(FLUID_ERR, "Unable to start Oboe audio stream"); + goto error_recovery; + } return reinterpret_cast(dev); - } catch(...) { diff --git a/src/drivers/fluid_opensles.c b/src/drivers/fluid_opensles.c index e528eca6..67106a3a 100644 --- a/src/drivers/fluid_opensles.c +++ b/src/drivers/fluid_opensles.c @@ -109,7 +109,7 @@ new_fluid_opensles_audio_driver(fluid_settings_t *settings, fluid_synth_t *synth if(!dev->engine) { - FLUID_LOG(FLUID_ERR, "Failed to create OpenSLES connection"); + FLUID_LOG(FLUID_ERR, "Failed to create the OpenSL ES engine, error code 0x%lx", result); goto error_recovery; } @@ -117,6 +117,7 @@ new_fluid_opensles_audio_driver(fluid_settings_t *settings, fluid_synth_t *synth if(result != SL_RESULT_SUCCESS) { + FLUID_LOG(FLUID_ERR, "Failed to realize the OpenSL ES engine, error code 0x%lx", result); goto error_recovery; } @@ -124,6 +125,7 @@ new_fluid_opensles_audio_driver(fluid_settings_t *settings, fluid_synth_t *synth if(result != SL_RESULT_SUCCESS) { + FLUID_LOG(FLUID_ERR, "Failed to retrieve the OpenSL ES engine interface, error code 0x%lx", result); goto error_recovery; } @@ -131,6 +133,7 @@ new_fluid_opensles_audio_driver(fluid_settings_t *settings, fluid_synth_t *synth if(result != SL_RESULT_SUCCESS) { + FLUID_LOG(FLUID_ERR, "Failed to create the OpenSL ES output mix object, error code 0x%lx", result); goto error_recovery; } @@ -138,6 +141,7 @@ new_fluid_opensles_audio_driver(fluid_settings_t *settings, fluid_synth_t *synth if(result != SL_RESULT_SUCCESS) { + FLUID_LOG(FLUID_ERR, "Failed to realize the OpenSL ES output mix object, error code 0x%lx", result); goto error_recovery; } @@ -179,6 +183,7 @@ new_fluid_opensles_audio_driver(fluid_settings_t *settings, fluid_synth_t *synth if(result != SL_RESULT_SUCCESS) { + FLUID_LOG(FLUID_ERR, "Failed to create the OpenSL ES audio player object, error code 0x%lx", result); goto error_recovery; } @@ -186,6 +191,7 @@ new_fluid_opensles_audio_driver(fluid_settings_t *settings, fluid_synth_t *synth if(result != SL_RESULT_SUCCESS) { + FLUID_LOG(FLUID_ERR, "Failed to realize the OpenSL ES audio player object, error code 0x%lx", result); goto error_recovery; } @@ -194,6 +200,7 @@ new_fluid_opensles_audio_driver(fluid_settings_t *settings, fluid_synth_t *synth if(result != SL_RESULT_SUCCESS) { + FLUID_LOG(FLUID_ERR, "Failed to retrieve the OpenSL ES audio player interface, error code 0x%lx", result); goto error_recovery; } @@ -202,6 +209,7 @@ new_fluid_opensles_audio_driver(fluid_settings_t *settings, fluid_synth_t *synth if(result != SL_RESULT_SUCCESS) { + FLUID_LOG(FLUID_ERR, "Failed to retrieve the OpenSL ES buffer queue interface, error code 0x%lx", result); goto error_recovery; } @@ -224,23 +232,38 @@ new_fluid_opensles_audio_driver(fluid_settings_t *settings, fluid_synth_t *synth if(result != SL_RESULT_SUCCESS) { + FLUID_LOG(FLUID_ERR, "Failed to register the opensles_callback, error code 0x%lx", result); goto error_recovery; } if(dev->is_sample_format_float) { - (*dev->player_buffer_queue_interface)->Enqueue(dev->player_buffer_queue_interface, dev->sles_buffer_float, dev->period_frames * NUM_CHANNELS * sizeof(float)); + result = (*dev->player_buffer_queue_interface)->Enqueue(dev->player_buffer_queue_interface, dev->sles_buffer_float, dev->period_frames * NUM_CHANNELS * sizeof(float)); } else { - (*dev->player_buffer_queue_interface)->Enqueue(dev->player_buffer_queue_interface, dev->sles_buffer_short, dev->period_frames * NUM_CHANNELS * sizeof(short)); + result = (*dev->player_buffer_queue_interface)->Enqueue(dev->player_buffer_queue_interface, dev->sles_buffer_short, dev->period_frames * NUM_CHANNELS * sizeof(short)); + } + + if(result != SL_RESULT_SUCCESS) + { + FLUID_LOG(FLUID_ERR, "Failed to add a buffer to the queue, error code 0x%lx", result); + goto error_recovery; + } + + result = (*dev->audio_player_interface)->SetCallbackEventsMask(dev->audio_player_interface, SL_PLAYEVENT_HEADATEND); + + if(result != SL_RESULT_SUCCESS) + { + FLUID_LOG(FLUID_ERR, "Failed to set OpenSL ES audio player callback events, error code 0x%lx", result); + goto error_recovery; } - (*dev->audio_player_interface)->SetCallbackEventsMask(dev->audio_player_interface, SL_PLAYEVENT_HEADATEND); result = (*dev->audio_player_interface)->SetPlayState(dev->audio_player_interface, SL_PLAYSTATE_PLAYING); if(result != SL_RESULT_SUCCESS) { + FLUID_LOG(FLUID_ERR, "Failed to set OpenSL ES audio player play state to playing, error code 0x%lx", result); goto error_recovery; }