From: o.danchenko Date: Thu, 30 Jun 2016 15:59:06 +0000 (+0300) Subject: ALURE support has been enabled. X-Git-Tag: submit/tizen/20160824.052737~4^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b90ef888bff7a79f5efb399b23a151be566706f4;p=platform%2Fcore%2Fapi%2Fsound-pool.git ALURE support has been enabled. Change-Id: Ia708e95d7ec9d377d11959f2d99c9d9d17f770fd --- diff --git a/CMakeLists.txt b/CMakeLists.txt index d34c3c1..f675d3a 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,13 @@ INCLUDE_DIRECTORIES(${INC_DIR}) SET(dependents "dlog glib-2.0 openal freealut" ) SET(pc_dependents "dlog glib-2.0 openal freealut" ) +IF(DEFINED ENV{ENABLE_ALURE}) + SET(dependents "${dependents} alure" ) + SET(pc_dependents "${pc_dependents} alure" ) + SET(PKG_CONFIG_CFLAGS "${PKG_CONFIG_CFLAGS} -DENABLE_ALURE") + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DENABLE_ALURE") +ENDIF() + INCLUDE(FindPkgConfig) pkg_check_modules(${fw_name} REQUIRED ${dependents}) FOREACH(flag ${${fw_name}_CFLAGS}) diff --git a/include/sound_pool_private.h b/include/sound_pool_private.h index 2b3af54..a170d6c 100644 --- a/include/sound_pool_private.h +++ b/include/sound_pool_private.h @@ -78,7 +78,7 @@ extern "C" { ##arg); \ } while (0) -#define SP_DEBUF_FENTER() \ +#define SP_DEBUG_FENTER() \ do { \ LOGD(FONT_COLOR_YELLOW""FONT_COLOR_RESET); \ } while (0) diff --git a/packaging/sound-pool.spec b/packaging/sound-pool.spec index 0f74e31..d4679e5 100644 --- a/packaging/sound-pool.spec +++ b/packaging/sound-pool.spec @@ -12,6 +12,7 @@ BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(openal) BuildRequires: pkgconfig(freealut) +#BuildRequires: pkgconfig(alure) %description Tizen Sound Pool Module allowing sounds playing for audio resources. @@ -32,6 +33,7 @@ cp %{SOURCE1001} . export CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage" export CXXFLAGS="$CXXFLAGS -fprofile-arcs -ftest-coverage" export LDFLAGS="$LDFLAGS -lgcov" +#export ENABLE_ALURE=1 MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` %cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DFULLVER=%{version} -DMAJORVER=${MAJORVER} diff --git a/src/priority.c b/src/priority.c index 9399567..d8ff7c1 100644 --- a/src/priority.c +++ b/src/priority.c @@ -26,7 +26,7 @@ static gint __stream_stream_proirity_cmp(gconstpointer a, gconstpointer b); static gint __stream_stream_proirity_cmp(gconstpointer a, gconstpointer b) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_RETVM_IF(!a, 0, "Firs pointer is NULL."); SP_RETVM_IF(!b, 0, "Second pointer is NULL."); sound_stream_t *stream_a = (sound_stream_t *)a; @@ -41,7 +41,7 @@ static gint __stream_stream_proirity_cmp(gconstpointer a, gconstpointer b) sound_pool_error_e _sound_stream_priority_create(sound_pool_t *pool, stream_priority_manager_t **mgr) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_RETVM_IF(!pool, SOUND_POOL_ERROR_INVALID_PARAMETER, "Stream priority " "manager can't be created for NULL sound pool"); SP_RETVM_IF(!mgr, SOUND_POOL_ERROR_INVALID_PARAMETER, "Can't create " @@ -52,8 +52,6 @@ sound_pool_error_e _sound_stream_priority_create(sound_pool_t *pool, SOUND_POOL_ERROR_OUT_OF_MEMORY, "Memory alloc failure. Can't create stream priority manager."); - int ret = SOUND_POOL_ERROR_NONE; - _mgr->priority_queue = NULL; _mgr->pool = pool; pool->mgr_priority = _mgr; @@ -61,17 +59,15 @@ sound_pool_error_e _sound_stream_priority_create(sound_pool_t *pool, *mgr = _mgr; SP_DEBUG_FLEAVE(); - return ret; + return SOUND_POOL_ERROR_NONE; } sound_pool_error_e _sound_stream_priority_destroy(stream_priority_manager_t *mgr) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_RETVM_IF(!mgr, SOUND_POOL_ERROR_INVALID_PARAMETER, "Can't handle priority " "manager, it is NULL."); - int ret = SOUND_POOL_ERROR_NONE; - if (mgr->priority_queue) { g_list_free(mgr->priority_queue); mgr->priority_queue = NULL; @@ -82,14 +78,13 @@ sound_pool_error_e _sound_stream_priority_destroy(stream_priority_manager_t *mgr SP_SAFE_GFREE(mgr); SP_DEBUG_FLEAVE(); - return ret; + return SOUND_POOL_ERROR_NONE; } sound_pool_error_e _sound_stream_priority_add_stream( stream_priority_manager_t *mgr, sound_stream_t *stream) { - SP_DEBUF_FENTER(); - int ret = SOUND_POOL_ERROR_NONE; + SP_DEBUG_FENTER(); SP_INST_CHECK(mgr, SOUND_POOL_ERROR_INVALID_PARAMETER); SP_INST_CHECK(stream, SOUND_POOL_ERROR_INVALID_PARAMETER); @@ -97,16 +92,15 @@ sound_pool_error_e _sound_stream_priority_add_stream( _sound_stream_priority_update_playback(mgr); SP_DEBUG_FLEAVE(); - return ret; + return SOUND_POOL_ERROR_NONE; } sound_pool_error_e _sound_stream_priority_remove_stream( stream_priority_manager_t *mgr, sound_stream_t *stream) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_INST_CHECK(mgr, SOUND_POOL_ERROR_INVALID_PARAMETER); SP_INST_CHECK(stream, SOUND_POOL_ERROR_INVALID_PARAMETER); - int ret = SOUND_POOL_ERROR_NONE; GList* to_delete; to_delete = g_list_find(mgr->priority_queue, (gpointer)stream); @@ -118,13 +112,13 @@ sound_pool_error_e _sound_stream_priority_remove_stream( _sound_stream_priority_update_playback(mgr); SP_DEBUG_FLEAVE(); - return ret; + return SOUND_POOL_ERROR_NONE; } sound_pool_error_e _sound_stream_priority_check(stream_priority_manager_t *mgr, sound_stream_t *stream, gboolean *out) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_INST_CHECK(mgr, SOUND_POOL_ERROR_INVALID_PARAMETER); SP_INST_CHECK(stream, SOUND_POOL_ERROR_INVALID_PARAMETER); SP_INST_CHECK(out, SOUND_POOL_ERROR_INVALID_PARAMETER); @@ -134,7 +128,6 @@ sound_pool_error_e _sound_stream_priority_check(stream_priority_manager_t *mgr, SP_INST_CHECK(g_hash_table_lookup(mgr->pool->sources, stream->parent_source->tag_name), SOUND_POOL_ERROR_KEY_NOT_AVAILABLE); *out = FALSE; - int ret = SOUND_POOL_ERROR_NONE; int position = g_list_index(mgr->priority_queue, (gconstpointer)stream); SP_RETVM_IF(-1 == position, SOUND_POOL_ERROR_INVALID_PARAMETER, @@ -144,12 +137,12 @@ sound_pool_error_e _sound_stream_priority_check(stream_priority_manager_t *mgr, *out = TRUE; SP_DEBUG_FLEAVE(); - return ret; + return SOUND_POOL_ERROR_NONE; } void _sound_stream_priority_update_playback(stream_priority_manager_t *mgr) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_RETM_IF(!mgr, "Priority manager pointer is NULL."); SP_RETM_IF(!mgr->pool, "Pool pointer is NULL."); SP_RETM_IF(!mgr->pool->cbmgr, "Callback manager pointer is NULL."); diff --git a/src/sound_pool.c b/src/sound_pool.c index 6236e6e..15a179f 100644 --- a/src/sound_pool.c +++ b/src/sound_pool.c @@ -34,17 +34,17 @@ static unsigned int sound_pool_amount = 0; sound_pool_error_e sound_pool_create(unsigned max_streams, sound_pool_h *pool) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_RETVM_IF(max_streams == 0, SOUND_POOL_ERROR_INVALID_PARAMETER, "Max streams count should be greater then 0."); - SP_RETVM_IF(SOUND_POOL_MAX_POOLS_AMOUNT < (sound_pool_amount+1), + SP_RETVM_IF(SOUND_POOL_MAX_POOLS_AMOUNT < (sound_pool_amount + 1), SOUND_POOL_ERROR_INVALID_OPERATION, "Max pools count should be no more than %d.", SOUND_POOL_MAX_POOLS_AMOUNT); SP_INST_CHECK(pool, SOUND_POOL_ERROR_INVALID_PARAMETER); sound_pool_t *_pool = NULL; - const int ret = _sound_pool_create(max_streams, &_pool); + sound_pool_error_e ret = _sound_pool_create(max_streams, &_pool); SP_RETVM_IF(ret != SOUND_POOL_ERROR_NONE, ret, "Error while creating sound pool instance."); SP_INST_CHECK(pool, SOUND_POOL_ERROR_INVALID_OPERATION); @@ -59,9 +59,9 @@ sound_pool_error_e sound_pool_create(unsigned max_streams, sound_pool_h *pool) sound_pool_error_e sound_pool_destroy(sound_pool_h pool) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); - const int ret = _sound_pool_destroy((sound_pool_t *)pool); + sound_pool_error_e ret = _sound_pool_destroy((sound_pool_t *)pool); SP_RETVM_IF(ret != SOUND_POOL_ERROR_NONE, ret, "Error occurred when destroying the sound pool"); --sound_pool_amount; @@ -74,11 +74,11 @@ sound_pool_error_e sound_pool_destroy(sound_pool_h pool) sound_pool_error_e sound_pool_load_source_from_file(sound_pool_h pool, const char *file_name, const char *tag) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); sound_pool_t *_pool = (sound_pool_t *)pool; sound_source_t *_src = NULL; - int ret = _sound_source_create(_pool, tag, &_src); + sound_pool_error_e ret = _sound_source_create(_pool, tag, &_src); SP_RETVM_IF(ret != SOUND_POOL_ERROR_NONE, ret, "Error while creating sound source instance."); @@ -95,11 +95,11 @@ sound_pool_error_e sound_pool_load_source_from_file(sound_pool_h pool, sound_pool_error_e sound_pool_unload_source(sound_pool_h pool, const char *tag) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); sound_pool_t *_pool = (sound_pool_t *)pool; sound_source_t *_source = NULL; - int ret = _sound_pool_get_source_by_tag(_pool, tag, &_source); + sound_pool_error_e ret = _sound_pool_get_source_by_tag(_pool, tag, &_source); SP_RETVM_IF(ret != SOUND_POOL_ERROR_NONE, ret, "Error occurred when " "getting sound source [%s] from the sound pool", tag); SP_INST_CHECK(_source, SOUND_POOL_ERROR_INVALID_OPERATION); @@ -116,12 +116,12 @@ sound_pool_error_e sound_pool_stream_play(sound_pool_h pool, const char *tag, unsigned loop, float volume, unsigned priority, sound_pool_stream_state_change_cb callback, void *data, unsigned *id) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_INST_CHECK(id, SOUND_POOL_ERROR_INVALID_PARAMETER); sound_pool_t *_pool = (sound_pool_t *)pool; sound_source_t *_source = NULL; - int ret = _sound_pool_get_source_by_tag(_pool, tag, &_source); + sound_pool_error_e ret = _sound_pool_get_source_by_tag(_pool, tag, &_source); SP_RETVM_IF(ret != SOUND_POOL_ERROR_NONE, ret, "Error occurred when " "getting sound source [%s] from the sound pool", tag); SP_INST_CHECK(_source, SOUND_POOL_ERROR_INVALID_OPERATION); @@ -157,11 +157,11 @@ sound_pool_error_e sound_pool_stream_play(sound_pool_h pool, const char *tag, sound_pool_error_e sound_pool_stream_pause(sound_pool_h pool, unsigned id) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); sound_pool_t *_pool = (sound_pool_t *)pool; sound_stream_t *_stream = NULL; - int ret = _sound_pool_get_stream_by_id(_pool, id, &_stream); + sound_pool_error_e ret = _sound_pool_get_stream_by_id(_pool, id, &_stream); SP_RETVM_IF(ret != SOUND_POOL_ERROR_NONE, ret, "Error occurred when " "getting sound stream [%u] from the sound pool", id); SP_INST_CHECK(_stream, SOUND_POOL_ERROR_INVALID_OPERATION); @@ -176,10 +176,10 @@ sound_pool_error_e sound_pool_stream_pause(sound_pool_h pool, unsigned id) sound_pool_error_e sound_pool_stream_resume(sound_pool_h pool, unsigned id) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); sound_pool_t *_pool = (sound_pool_t *)pool; sound_stream_t *_stream = NULL; - int ret = _sound_pool_get_stream_by_id(_pool, id, &_stream); + sound_pool_error_e ret = _sound_pool_get_stream_by_id(_pool, id, &_stream); SP_RETVM_IF(ret != SOUND_POOL_ERROR_NONE, ret, "Error occurred when " "getting sound stream [%u] from the sound pool", id); SP_INST_CHECK(_stream, SOUND_POOL_ERROR_INVALID_OPERATION); @@ -194,11 +194,11 @@ sound_pool_error_e sound_pool_stream_resume(sound_pool_h pool, unsigned id) sound_pool_error_e sound_pool_stream_stop(sound_pool_h pool, unsigned id) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); sound_pool_t *_pool = (sound_pool_t *)pool; sound_stream_t *_stream = NULL; - int ret = _sound_pool_get_stream_by_id(_pool, id, &_stream); + sound_pool_error_e ret = _sound_pool_get_stream_by_id(_pool, id, &_stream); SP_RETVM_IF(ret != SOUND_POOL_ERROR_NONE, ret, "Error occurred when " "getting sound stream [%u] from the sound pool", id); SP_INST_CHECK(_stream, SOUND_POOL_ERROR_INVALID_OPERATION); @@ -213,9 +213,9 @@ sound_pool_error_e sound_pool_stream_stop(sound_pool_h pool, unsigned id) sound_pool_error_e sound_pool_get_state(sound_pool_h pool, sound_pool_state_e *state) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); - const int ret = _sound_pool_get_state(pool, state); + sound_pool_error_e ret = _sound_pool_get_state(pool, state); SP_RETVM_IF(ret != SOUND_POOL_ERROR_NONE, ret, "Error occurred when " "getting state of the sound pool"); @@ -225,9 +225,9 @@ sound_pool_error_e sound_pool_get_state(sound_pool_h pool, sound_pool_state_e *s sound_pool_error_e sound_pool_activate(sound_pool_h pool) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); - const int ret = _sound_pool_activate((sound_pool_t *)pool); + sound_pool_error_e ret = _sound_pool_activate((sound_pool_t *)pool); SP_RETVM_IF(ret != SOUND_POOL_ERROR_NONE, ret, "Error occurred when " "activating sound pool"); @@ -237,9 +237,9 @@ sound_pool_error_e sound_pool_activate(sound_pool_h pool) sound_pool_error_e sound_pool_deactivate(sound_pool_h pool) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); - const int ret = _sound_pool_deactivate((sound_pool_t *)pool); + sound_pool_error_e ret = _sound_pool_deactivate((sound_pool_t *)pool); SP_RETVM_IF(ret != SOUND_POOL_ERROR_NONE, ret, "Error occurred when " "deactivating sound pool"); @@ -249,9 +249,9 @@ sound_pool_error_e sound_pool_deactivate(sound_pool_h pool) sound_pool_error_e sound_pool_set_volume(sound_pool_h pool, float volume) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); - const int ret = _sound_pool_set_volume((sound_pool_t *)pool, volume); + sound_pool_error_e ret = _sound_pool_set_volume((sound_pool_t *)pool, volume); SP_RETVM_IF(ret != SOUND_POOL_ERROR_NONE, ret, "Error occurred when " "setting volume for sound pool"); @@ -261,9 +261,9 @@ sound_pool_error_e sound_pool_set_volume(sound_pool_h pool, float volume) sound_pool_error_e sound_pool_get_volume(sound_pool_h pool, float *volume) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); - const int ret = _sound_pool_get_volume((sound_pool_t *)pool, volume); + sound_pool_error_e ret = _sound_pool_get_volume((sound_pool_t *)pool, volume); SP_RETVM_IF(ret != SOUND_POOL_ERROR_NONE, ret, "Error occurred when " "getting volume for sound pool"); @@ -274,11 +274,11 @@ sound_pool_error_e sound_pool_get_volume(sound_pool_h pool, float *volume) sound_pool_error_e sound_pool_stream_get_state(sound_pool_h pool, unsigned id, sound_pool_stream_state_e *state) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); sound_pool_t *_pool = (sound_pool_t *)pool; sound_stream_t *_stream = NULL; - int ret = _sound_pool_get_stream_by_id(_pool, id, &_stream); + sound_pool_error_e ret = _sound_pool_get_stream_by_id(_pool, id, &_stream); SP_RETVM_IF(ret != SOUND_POOL_ERROR_NONE, ret, "Error occurred when " "getting sound stream [%u] from the sound pool", id); SP_INST_CHECK(_stream, SOUND_POOL_ERROR_INVALID_OPERATION); @@ -294,11 +294,11 @@ sound_pool_error_e sound_pool_stream_get_state(sound_pool_h pool, unsigned id, sound_pool_error_e sound_pool_stream_set_loop(sound_pool_h pool, unsigned id, unsigned loop) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); sound_pool_t *_pool = (sound_pool_t *)pool; sound_stream_t *_stream = NULL; - int ret = _sound_pool_get_stream_by_id(_pool, id, &_stream); + sound_pool_error_e ret = _sound_pool_get_stream_by_id(_pool, id, &_stream); SP_RETVM_IF(ret != SOUND_POOL_ERROR_NONE, ret, "Error occurred when " "getting sound stream [%u] from the sound pool", id); SP_INST_CHECK(_stream, SOUND_POOL_ERROR_INVALID_OPERATION); @@ -314,11 +314,11 @@ sound_pool_error_e sound_pool_stream_set_loop(sound_pool_h pool, unsigned id, sound_pool_error_e sound_pool_stream_get_loop(sound_pool_h pool, unsigned id, unsigned *loop) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); sound_pool_t *_pool = (sound_pool_t *)pool; sound_stream_t *_stream = NULL; - int ret = _sound_pool_get_stream_by_id(_pool, id, &_stream); + sound_pool_error_e ret = _sound_pool_get_stream_by_id(_pool, id, &_stream); SP_RETVM_IF(ret != SOUND_POOL_ERROR_NONE, ret, "Error occurred when " "getting sound stream [%u] from the sound pool", id); SP_INST_CHECK(_stream, SOUND_POOL_ERROR_INVALID_OPERATION); @@ -334,11 +334,11 @@ sound_pool_error_e sound_pool_stream_get_loop(sound_pool_h pool, unsigned id, sound_pool_error_e sound_pool_stream_set_volume(sound_pool_h pool, unsigned id, float volume) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); sound_pool_t *_pool = (sound_pool_t *)pool; sound_stream_t *_stream = NULL; - int ret = _sound_pool_get_stream_by_id(_pool, id, &_stream); + sound_pool_error_e ret = _sound_pool_get_stream_by_id(_pool, id, &_stream); SP_RETVM_IF(ret != SOUND_POOL_ERROR_NONE, ret, "Error occurred when " "getting sound stream [%u] from the sound pool", id); SP_INST_CHECK(_stream, SOUND_POOL_ERROR_INVALID_OPERATION); @@ -354,11 +354,11 @@ sound_pool_error_e sound_pool_stream_set_volume(sound_pool_h pool, unsigned id, sound_pool_error_e sound_pool_stream_get_volume(sound_pool_h pool, unsigned id, float *volume) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); sound_pool_t *_pool = (sound_pool_t *)pool; sound_stream_t *_stream = NULL; - int ret = _sound_pool_get_stream_by_id(_pool, id, &_stream); + sound_pool_error_e ret = _sound_pool_get_stream_by_id(_pool, id, &_stream); SP_RETVM_IF(ret != SOUND_POOL_ERROR_NONE, ret, "Error occurred when " "getting sound stream [%u] from the sound pool", id); SP_INST_CHECK(_stream, SOUND_POOL_ERROR_INVALID_OPERATION); @@ -374,11 +374,11 @@ sound_pool_error_e sound_pool_stream_get_volume(sound_pool_h pool, unsigned id, sound_pool_error_e sound_pool_stream_set_priority(sound_pool_h pool, unsigned id, unsigned priority) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); sound_pool_t *_pool = (sound_pool_t *)pool; sound_stream_t *_stream = NULL; - int ret = _sound_pool_get_stream_by_id(_pool, id, &_stream); + sound_pool_error_e ret = _sound_pool_get_stream_by_id(_pool, id, &_stream); SP_RETVM_IF(ret != SOUND_POOL_ERROR_NONE, ret, "Error occurred when " "getting sound stream [%u] from the sound pool", id); SP_INST_CHECK(_stream, SOUND_POOL_ERROR_INVALID_OPERATION); @@ -394,11 +394,11 @@ sound_pool_error_e sound_pool_stream_set_priority(sound_pool_h pool, sound_pool_error_e sound_pool_stream_get_priority(sound_pool_h pool, unsigned id, unsigned *priority) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); sound_pool_t *_pool = (sound_pool_t *)pool; sound_stream_t *_stream = NULL; - int ret = _sound_pool_get_stream_by_id(_pool, id, &_stream); + sound_pool_error_e ret = _sound_pool_get_stream_by_id(_pool, id, &_stream); SP_RETVM_IF(ret != SOUND_POOL_ERROR_NONE, ret, "Error occurred when " "getting sound stream [%u] from the sound pool", id); SP_INST_CHECK(_stream, SOUND_POOL_ERROR_INVALID_OPERATION); @@ -414,10 +414,9 @@ sound_pool_error_e sound_pool_stream_get_priority(sound_pool_h pool, sound_pool_error_e sound_pool_set_state_change_callback(sound_pool_h pool, sound_pool_state_change_cb callback, void *data) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); - const int ret = - _sound_pool_set_callback((sound_pool_t *)pool, callback, data); + sound_pool_error_e ret = _sound_pool_set_callback((sound_pool_t *)pool, callback, data); SP_RETVM_IF(ret != SOUND_POOL_ERROR_NONE, ret, "Error occurred when " "setting state changing callback for sound pool"); @@ -427,9 +426,9 @@ sound_pool_error_e sound_pool_set_state_change_callback(sound_pool_h pool, sound_pool_error_e sound_pool_unset_state_change_callback(sound_pool_h pool) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); - const int ret = _sound_pool_unset_callback((sound_pool_t *)pool); + sound_pool_error_e ret = _sound_pool_unset_callback((sound_pool_t *)pool); SP_RETVM_IF(ret != SOUND_POOL_ERROR_NONE, ret, "Error occurred when " "unsetting state changing callback for sound pool"); @@ -441,11 +440,11 @@ sound_pool_error_e sound_pool_stream_set_state_change_callback( sound_pool_h pool, unsigned id, sound_pool_stream_state_change_cb callback, void *data) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); sound_pool_t *_pool = (sound_pool_t *)pool; sound_stream_t *_stream = NULL; - int ret = _sound_pool_get_stream_by_id(_pool, id, &_stream); + sound_pool_error_e ret = _sound_pool_get_stream_by_id(_pool, id, &_stream); SP_RETVM_IF(ret != SOUND_POOL_ERROR_NONE, ret, "Error occurred when " "getting sound stream [%u] from the sound pool", id); SP_INST_CHECK(_stream, SOUND_POOL_ERROR_INVALID_OPERATION); @@ -461,11 +460,11 @@ sound_pool_error_e sound_pool_stream_set_state_change_callback( sound_pool_error_e sound_pool_stream_unset_state_change_callback( sound_pool_h pool, unsigned id) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); sound_pool_t *_pool = (sound_pool_t *)pool; sound_stream_t *_stream = NULL; - int ret = _sound_pool_get_stream_by_id(_pool, id, &_stream); + sound_pool_error_e ret = _sound_pool_get_stream_by_id(_pool, id, &_stream); SP_RETVM_IF(ret != SOUND_POOL_ERROR_NONE, ret, "Error occurred when " "getting sound stream [%u] from the sound pool", id); SP_INST_CHECK(_stream, SOUND_POOL_ERROR_INVALID_OPERATION); diff --git a/src/soundpool.c b/src/soundpool.c index 631a3aa..faa6fcc 100644 --- a/src/soundpool.c +++ b/src/soundpool.c @@ -38,7 +38,7 @@ static void __stream_deactivate_iter(gpointer key, gpointer value, static void __stream_activate_iter(gpointer key, gpointer value, gpointer user_data) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_RETM_IF(!user_data, "Empty user data."); SP_RETM_IF(!value, "Empty sound stream data."); guint *len = (guint*)user_data; @@ -59,7 +59,7 @@ static void __stream_activate_iter(gpointer key, gpointer value, static void __stream_deactivate_iter(gpointer key, gpointer value, gpointer user_data) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_RETM_IF(!user_data, "Empty user data."); SP_RETM_IF(!value, "Empty sound stream data."); guint *len = (guint*)user_data; @@ -75,7 +75,7 @@ static void __stream_deactivate_iter(gpointer key, gpointer value, sound_pool_error_e _sound_pool_create(size_t max_streams, sound_pool_t **pool) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_RETVM_IF(max_streams == 0, SOUND_POOL_ERROR_INVALID_PARAMETER, "Max streams count should be greater than 0."); @@ -86,7 +86,7 @@ sound_pool_error_e _sound_pool_create(size_t max_streams, sound_pool_t **pool) SP_RETVM_IF(!pool, SOUND_POOL_ERROR_INVALID_PARAMETER, "Can't create " "sound pool. Pool pointer is NULL"); - int ret = SOUND_POOL_ERROR_NONE; + sound_pool_error_e ret = SOUND_POOL_ERROR_NONE; _pool->al_context = NULL; _pool->al_context = alcCreateContext(alcOpenDevice(NULL), NULL); if (!_pool->al_context) { @@ -141,12 +141,12 @@ cfail: sound_pool_error_e _sound_pool_destroy(sound_pool_t *pool) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_INST_CHECK(pool, SOUND_POOL_ERROR_INVALID_PARAMETER); _sound_pool_deactivate(pool); if (pool->cbmgr) { - const int ret = _stream_cb_manager_destroy(pool->cbmgr); + sound_pool_error_e ret = _stream_cb_manager_destroy(pool->cbmgr); SP_RETVM_IF(ret != SOUND_POOL_ERROR_NONE, ret, "Error occurred when " "trying to destroy sound pool callback manager."); pool->cbmgr = NULL; @@ -173,7 +173,7 @@ sound_pool_error_e _sound_pool_destroy(sound_pool_t *pool) } if (pool->mgr_priority) { - const int ret = _sound_stream_priority_destroy(pool->mgr_priority); + sound_pool_error_e ret = _sound_stream_priority_destroy(pool->mgr_priority); SP_RETVM_IF(ret != SOUND_POOL_ERROR_NONE, ret, "Error occurred when trying to destroy priority manager."); pool->mgr_priority = NULL; @@ -194,7 +194,7 @@ sound_pool_error_e _sound_pool_destroy(sound_pool_t *pool) sound_pool_error_e _sound_pool_activate(sound_pool_t *pool) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_INST_CHECK(pool, SOUND_POOL_ERROR_INVALID_PARAMETER); SP_RETVM_IF(pool->state == SOUND_POOL_STATE_ACTIVE, @@ -229,7 +229,7 @@ sound_pool_error_e _sound_pool_activate(sound_pool_t *pool) sound_pool_error_e _sound_pool_deactivate(sound_pool_t *pool) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_INST_CHECK(pool, SOUND_POOL_ERROR_INVALID_PARAMETER); SP_RETVM_IF(pool->state == SOUND_POOL_STATE_INACTIVE, SOUND_POOL_ERROR_INVALID_OPERATION, @@ -264,7 +264,7 @@ sound_pool_error_e _sound_pool_deactivate(sound_pool_t *pool) sound_pool_error_e _sound_pool_get_state(sound_pool_t *pool, sound_pool_state_e *state) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_INST_CHECK(pool, SOUND_POOL_ERROR_INVALID_PARAMETER); SP_INST_CHECK(state, SOUND_POOL_ERROR_INVALID_PARAMETER); *state = pool->state; @@ -274,7 +274,7 @@ sound_pool_error_e _sound_pool_get_state(sound_pool_t *pool, sound_pool_error_e _sound_pool_set_volume(sound_pool_t *pool, float volume) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_INST_CHECK(pool, SOUND_POOL_ERROR_INVALID_PARAMETER); SP_RETVM_IF((volume < 0.0f || volume > 1.0f), SOUND_POOL_ERROR_INVALID_PARAMETER, @@ -291,7 +291,7 @@ sound_pool_error_e _sound_pool_set_volume(sound_pool_t *pool, float volume) sound_pool_error_e _sound_pool_get_volume(sound_pool_t *pool, float *volume) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_INST_CHECK(pool, SOUND_POOL_ERROR_INVALID_PARAMETER); SP_INST_CHECK(volume, SOUND_POOL_ERROR_INVALID_PARAMETER); *volume = pool->volume; @@ -302,7 +302,7 @@ sound_pool_error_e _sound_pool_get_volume(sound_pool_t *pool, float *volume) sound_pool_error_e _sound_pool_set_callback(sound_pool_t *pool, sound_pool_state_change_cb callback, void *data) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_INST_CHECK(pool, SOUND_POOL_ERROR_INVALID_PARAMETER); SP_INST_CHECK(callback, SOUND_POOL_ERROR_INVALID_PARAMETER); @@ -315,7 +315,7 @@ sound_pool_error_e _sound_pool_set_callback(sound_pool_t *pool, sound_pool_error_e _sound_pool_unset_callback(sound_pool_t *pool) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_INST_CHECK(pool, SOUND_POOL_ERROR_INVALID_PARAMETER); pool->state_cb_info.callback = NULL; diff --git a/src/source.c b/src/source.c index d9584dd..c67c2a2 100644 --- a/src/source.c +++ b/src/source.c @@ -24,13 +24,16 @@ #include "internal/stream.h" #include +#ifdef ENABLE_ALURE +# include +#endif static int __sound_pool_add_source(sound_pool_t *pool, sound_source_t *src); static int __sound_pool_remove_source(sound_pool_t *pool, sound_source_t *src); static int __sound_pool_add_source(sound_pool_t *pool, sound_source_t *src) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_INST_CHECK(pool, SOUND_POOL_ERROR_INVALID_PARAMETER); SP_INST_CHECK(src, SOUND_POOL_ERROR_INVALID_PARAMETER); SP_RETVM_IF(!pool->sources, SOUND_POOL_ERROR_INVALID_OPERATION, "Sound " @@ -54,7 +57,7 @@ static int __sound_pool_add_source(sound_pool_t *pool, sound_source_t *src) static int __sound_pool_remove_source(sound_pool_t *pool, sound_source_t *src) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_INST_CHECK(pool, SOUND_POOL_ERROR_INVALID_PARAMETER); SP_INST_CHECK(pool->sources, SOUND_POOL_ERROR_INVALID_PARAMETER); SP_INST_CHECK(src, SOUND_POOL_ERROR_INVALID_PARAMETER); @@ -73,7 +76,6 @@ static int __sound_pool_remove_source(sound_pool_t *pool, sound_source_t *src) guint size_before = g_hash_table_size(pool->streams); gchar *tag = (gchar*)key; sound_stream_t *stream = (sound_stream_t*)value; - SP_INFO("(%s)(%s)", src->tag_name, stream->parent_source->tag_name); if (src == stream->parent_source) _sound_stream_destroy((sound_stream_t*)value); guint size_after = g_hash_table_size(pool->streams); @@ -92,7 +94,7 @@ static int __sound_pool_remove_source(sound_pool_t *pool, sound_source_t *src) sound_pool_error_e _sound_source_create(sound_pool_t *pool, const char *tag, sound_source_t **src) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_RETVM_IF(!pool, SOUND_POOL_ERROR_INVALID_PARAMETER, "Can't create sound source in NULL sound pool"); SP_RETVM_IF(!tag, SOUND_POOL_ERROR_INVALID_PARAMETER, @@ -117,7 +119,7 @@ sound_pool_error_e _sound_source_create(sound_pool_t *pool, const char *tag, SOUND_POOL_ERROR_OUT_OF_MEMORY, "Memory alloc failure. Can't create sound _src"); - int ret = SOUND_POOL_ERROR_NONE; + sound_pool_error_e ret = SOUND_POOL_ERROR_NONE; alGenBuffers(1, &_src->al_buffer); if (alGetError() != AL_NO_ERROR) { ret = SOUND_POOL_ERROR_OUT_OF_MEMORY; @@ -146,7 +148,7 @@ cfail: sound_pool_error_e _sound_source_destroy(sound_source_t *src) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_RETVM_IF(!src, SOUND_POOL_ERROR_INVALID_PARAMETER, "Can't destroy NULL sound source"); @@ -168,14 +170,14 @@ sound_pool_error_e _sound_source_destroy(sound_source_t *src) sound_pool_error_e _sound_source_load_from_file(sound_source_t *src, const char *fname) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_INST_CHECK(src, SOUND_POOL_ERROR_INVALID_PARAMETER); SP_INST_CHECK(fname, SOUND_POOL_ERROR_INVALID_PARAMETER); SP_INST_CHECK(src->parent_pool, SOUND_POOL_ERROR_INVALID_OPERATION); SP_RETVM_IF(!alcMakeContextCurrent(src->parent_pool->al_context), SOUND_POOL_ERROR_INVALID_OPERATION, "Can't set current AL context."); - int ret = SOUND_POOL_ERROR_NONE; + sound_pool_error_e ret = SOUND_POOL_ERROR_NONE; ALenum format; ALsizei size; ALvoid* data = NULL; @@ -183,9 +185,22 @@ sound_pool_error_e _sound_source_load_from_file(sound_source_t *src, ALboolean loop; alutLoadWAVFile((ALbyte*)fname, &format, &data, &size, &freq, &loop); + +#ifdef ENABLE_ALURE + if (alGetError() != AL_NO_ERROR || !data) { + if (alureBufferDataFromFile(fname, src->al_buffer) == AL_FALSE) { + src->al_buffer = AL_NONE; + SP_ERROR("Can't load audio file. No such file [%s]", fname); + ret = SOUND_POOL_ERROR_NO_SUCH_FILE; + } + SP_DEBUG_FLEAVE(); + return ret; + } +#else SP_RETVM_IF(alGetError() != AL_NO_ERROR || !data, SOUND_POOL_ERROR_NO_SUCH_FILE, "Can't load audio file. No such " "file [%s]", fname); +#endif alBufferData(src->al_buffer, format, data, size, freq); if (alGetError() != AL_NO_ERROR) { @@ -202,7 +217,7 @@ sound_pool_error_e _sound_source_load_from_file(sound_source_t *src, sound_pool_error_e _sound_pool_get_source_by_tag(sound_pool_t *pool, const char *tag, sound_source_t **src) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_INST_CHECK(pool, SOUND_POOL_ERROR_INVALID_PARAMETER); SP_INST_CHECK(tag, SOUND_POOL_ERROR_INVALID_PARAMETER); SP_INST_CHECK(src, SOUND_POOL_ERROR_INVALID_PARAMETER); diff --git a/src/stream.c b/src/stream.c index aa5fa68..d2bb663 100644 --- a/src/stream.c +++ b/src/stream.c @@ -31,8 +31,8 @@ static const char *__stringify_stream_state(sound_pool_stream_state_e state); static void __al_source_state_cb(ALuint source, ALenum state, ALvoid *data); -static int __sound_pool_add_stream(sound_pool_t *pool, sound_stream_t *stream); -static int __sound_pool_remove_stream(sound_pool_t *pool, sound_stream_t *stream); +static sound_pool_error_e __sound_pool_add_stream(sound_pool_t *pool, sound_stream_t *stream); +static sound_pool_error_e __sound_pool_remove_stream(sound_pool_t *pool, sound_stream_t *stream); static const char *__stringify_stream_state(sound_pool_stream_state_e state) { @@ -56,7 +56,7 @@ static const char *__stringify_stream_state(sound_pool_stream_state_e state) static void __al_source_state_cb(ALuint source, ALenum state, ALvoid *data) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); sound_stream_t *stream = (sound_stream_t *)data; SP_RETM_IF(!stream, "Can't handle stream in OpenAL callback, it is NULL"); @@ -102,9 +102,9 @@ static void __al_source_state_cb(ALuint source, ALenum state, ALvoid *data) SP_DEBUG_FLEAVE(); } -static int __sound_pool_add_stream(sound_pool_t *pool, sound_stream_t *stream) +static sound_pool_error_e __sound_pool_add_stream(sound_pool_t *pool, sound_stream_t *stream) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_INST_CHECK(pool, SOUND_POOL_ERROR_INVALID_PARAMETER); SP_INST_CHECK(stream, SOUND_POOL_ERROR_INVALID_PARAMETER); SP_RETVM_IF(!pool->streams, SOUND_POOL_ERROR_INVALID_OPERATION, "Sound " @@ -122,7 +122,7 @@ static int __sound_pool_add_stream(sound_pool_t *pool, sound_stream_t *stream) SOUND_POOL_ERROR_INVALID_OPERATION, "Error occurred when adding " "the stream [%u] to the sound pool", stream->id); - int ret = _sound_stream_priority_add_stream(pool->mgr_priority, stream); + sound_pool_error_e ret = _sound_stream_priority_add_stream(pool->mgr_priority, stream); SP_RETVM_IF(SOUND_POOL_ERROR_NONE != ret, ret, "Error occurred when adding " "the stream [%u] to the priority queue.", stream->id); @@ -130,9 +130,9 @@ static int __sound_pool_add_stream(sound_pool_t *pool, sound_stream_t *stream) return SOUND_POOL_ERROR_NONE; } -static int __sound_pool_remove_stream(sound_pool_t *pool, sound_stream_t *stream) +static sound_pool_error_e __sound_pool_remove_stream(sound_pool_t *pool, sound_stream_t *stream) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_INST_CHECK(pool, SOUND_POOL_ERROR_INVALID_PARAMETER); SP_INST_CHECK(pool->mgr_priority, SOUND_POOL_ERROR_INVALID_PARAMETER); SP_INST_CHECK(stream, SOUND_POOL_ERROR_INVALID_PARAMETER); @@ -158,7 +158,7 @@ static int __sound_pool_remove_stream(sound_pool_t *pool, sound_stream_t *stream sound_pool_error_e _sound_stream_create(sound_source_t *src, sound_stream_t **stream) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_RETVM_IF(!src, SOUND_POOL_ERROR_INVALID_PARAMETER, "Can't create sound stream in NULL sound source"); SP_RETVM_IF(!stream, SOUND_POOL_ERROR_INVALID_PARAMETER, @@ -184,7 +184,7 @@ sound_pool_error_e _sound_stream_create(sound_source_t *src, _stream->state_cb_info.callback = NULL; _stream->state_cb_info.user_data = NULL; - int ret = SOUND_POOL_ERROR_NONE; + sound_pool_error_e ret = SOUND_POOL_ERROR_NONE; alGenSources((ALsizei)1, &_stream->al_source); if (alGetError() != AL_NO_ERROR) { ret = SOUND_POOL_ERROR_OUT_OF_MEMORY; @@ -230,7 +230,7 @@ cfail: sound_pool_error_e _sound_stream_destroy(sound_stream_t *stream) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_RETVM_IF(!stream, SOUND_POOL_ERROR_INVALID_PARAMETER, "Can't destroy NULL sound stream"); SP_RETVM_IF(!stream->parent_source->parent_pool, SOUND_POOL_ERROR_INVALID_PARAMETER, @@ -259,7 +259,7 @@ sound_pool_error_e _sound_stream_destroy(sound_stream_t *stream) sound_pool_error_e _sound_stream_play(sound_stream_t *stream) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_INST_CHECK(stream, SOUND_POOL_ERROR_INVALID_PARAMETER); SP_INST_CHECK(stream->parent_source, SOUND_POOL_ERROR_INVALID_PARAMETER); sound_pool_t *pool = stream->parent_source->parent_pool; @@ -296,7 +296,7 @@ sound_pool_error_e _sound_stream_play(sound_stream_t *stream) sound_pool_error_e _sound_stream_pause(sound_stream_t *stream) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_INST_CHECK(stream, SOUND_POOL_ERROR_INVALID_PARAMETER); SP_INST_CHECK(stream->parent_source, SOUND_POOL_ERROR_INVALID_PARAMETER); sound_pool_t *pool = stream->parent_source->parent_pool; @@ -328,7 +328,7 @@ sound_pool_error_e _sound_stream_pause(sound_stream_t *stream) sound_pool_error_e _sound_stream_resume(sound_stream_t *stream) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_INST_CHECK(stream, SOUND_POOL_ERROR_INVALID_PARAMETER); SP_INST_CHECK(stream->parent_source, SOUND_POOL_ERROR_INVALID_PARAMETER); sound_pool_t *pool = stream->parent_source->parent_pool; @@ -360,7 +360,7 @@ sound_pool_error_e _sound_stream_resume(sound_stream_t *stream) sound_pool_error_e _sound_stream_stop(sound_stream_t *stream) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_INST_CHECK(stream, SOUND_POOL_ERROR_INVALID_PARAMETER); SP_INST_CHECK(stream->parent_source, SOUND_POOL_ERROR_INVALID_PARAMETER); sound_pool_t *pool = stream->parent_source->parent_pool; @@ -383,7 +383,7 @@ sound_pool_error_e _sound_stream_stop(sound_stream_t *stream) sound_pool_error_e _sound_stream_set_loop(sound_stream_t *stream, unsigned loop) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_INST_CHECK(stream, SOUND_POOL_ERROR_INVALID_PARAMETER); sound_pool_t *pool = stream->parent_source->parent_pool; SP_INST_CHECK(pool, SOUND_POOL_ERROR_INVALID_PARAMETER); @@ -399,7 +399,7 @@ sound_pool_error_e _sound_stream_set_loop(sound_stream_t *stream, unsigned loop) sound_pool_error_e _sound_stream_get_loop(sound_stream_t *stream, unsigned *loop) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_INST_CHECK(stream, SOUND_POOL_ERROR_INVALID_PARAMETER); SP_INST_CHECK(loop, SOUND_POOL_ERROR_INVALID_PARAMETER); @@ -411,7 +411,7 @@ sound_pool_error_e _sound_stream_get_loop(sound_stream_t *stream, unsigned *loop sound_pool_error_e _sound_stream_set_volume(sound_stream_t *stream, float volume) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_INST_CHECK(stream, SOUND_POOL_ERROR_INVALID_PARAMETER); SP_RETVM_IF((volume < 0.0f || volume > 1.0f), SOUND_POOL_ERROR_INVALID_PARAMETER, @@ -431,7 +431,7 @@ sound_pool_error_e _sound_stream_set_volume(sound_stream_t *stream, float volume sound_pool_error_e _sound_stream_get_volume(sound_stream_t *stream, float *volume) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_INST_CHECK(stream, SOUND_POOL_ERROR_INVALID_PARAMETER); SP_INST_CHECK(volume, SOUND_POOL_ERROR_INVALID_PARAMETER); @@ -444,7 +444,7 @@ sound_pool_error_e _sound_stream_get_volume(sound_stream_t *stream, float *volum sound_pool_error_e _sound_stream_get_state(sound_stream_t *stream, sound_pool_stream_state_e *state) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_INST_CHECK(stream, SOUND_POOL_ERROR_INVALID_PARAMETER); SP_INST_CHECK(state, SOUND_POOL_ERROR_INVALID_PARAMETER); @@ -456,7 +456,7 @@ sound_pool_error_e _sound_stream_get_state(sound_stream_t *stream, sound_pool_error_e _sound_stream_set_priority(sound_stream_t *stream, unsigned rank) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_INST_CHECK(stream, SOUND_POOL_ERROR_INVALID_PARAMETER); SP_INST_CHECK(stream->parent_source->parent_pool, SOUND_POOL_ERROR_INVALID_PARAMETER); SP_INST_CHECK(stream->parent_source->parent_pool->mgr_priority, SOUND_POOL_ERROR_INVALID_PARAMETER); @@ -485,7 +485,7 @@ sound_pool_error_e _sound_stream_set_priority(sound_stream_t *stream, unsigned r sound_pool_error_e _sound_stream_get_priority(sound_stream_t *stream, unsigned *rank) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_INST_CHECK(stream, SOUND_POOL_ERROR_INVALID_PARAMETER); SP_INST_CHECK(rank, SOUND_POOL_ERROR_INVALID_PARAMETER); @@ -498,7 +498,7 @@ sound_pool_error_e _sound_stream_get_priority(sound_stream_t *stream, unsigned * sound_pool_error_e _sound_stream_set_callback(sound_stream_t *stream, sound_pool_stream_state_change_cb callback, void *data) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_INST_CHECK(stream, SOUND_POOL_ERROR_INVALID_PARAMETER); SP_INST_CHECK(callback, SOUND_POOL_ERROR_INVALID_PARAMETER); @@ -511,7 +511,7 @@ sound_pool_error_e _sound_stream_set_callback(sound_stream_t *stream, sound_pool_error_e _sound_stream_unset_callback(sound_stream_t *stream) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_INST_CHECK(stream, SOUND_POOL_ERROR_INVALID_PARAMETER); stream->state_cb_info.callback = NULL; @@ -524,7 +524,7 @@ sound_pool_error_e _sound_stream_unset_callback(sound_stream_t *stream) sound_pool_error_e _sound_pool_get_stream_by_id(sound_pool_t *pool, unsigned id, sound_stream_t **stream) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_INST_CHECK(pool, SOUND_POOL_ERROR_INVALID_PARAMETER); SP_INST_CHECK(stream, SOUND_POOL_ERROR_INVALID_PARAMETER); diff --git a/src/stream_cb_manager.c b/src/stream_cb_manager.c index 9e08c2b..329b022 100644 --- a/src/stream_cb_manager.c +++ b/src/stream_cb_manager.c @@ -28,7 +28,7 @@ static void __queue_destroy_item(gpointer data); static void __queue_destroy_item(gpointer data) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_SAFE_GFREE(data); @@ -37,7 +37,7 @@ static void __queue_destroy_item(gpointer data) static void __thread_cancel_cleanup(void *user_data) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); stream_cb_manager_t *cbmgr = (stream_cb_manager_t *)user_data; g_async_queue_unref(cbmgr->isolator_callback_queue); @@ -51,7 +51,7 @@ static void __thread_cancel_cleanup(void *user_data) static gpointer __sound_pool_callback_isolator(gpointer user_data) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); int err = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); if (err != 0) SP_INFO("Can't setup cancel type for isolation thread with error [%d].", err); @@ -110,7 +110,7 @@ static gpointer __sound_pool_callback_isolator(gpointer user_data) sound_pool_error_e _stream_cb_manager_create(sound_pool_t *pool, stream_cb_manager_t **cbmgr) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_RETVM_IF(!pool, SOUND_POOL_ERROR_INVALID_PARAMETER, "Stream callback " "manager can't be created for NULL sound pool"); SP_RETVM_IF(!cbmgr, SOUND_POOL_ERROR_INVALID_PARAMETER, "Can't create " @@ -148,10 +148,10 @@ sound_pool_error_e _stream_cb_manager_create(sound_pool_t *pool, sound_pool_error_e _stream_cb_manager_destroy(stream_cb_manager_t *cbmgr) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_RETVM_IF(!cbmgr, SOUND_POOL_ERROR_INVALID_PARAMETER, "Can't handle callback " "manager, it is NULL."); - + sound_pool_error_e ret = SOUND_POOL_ERROR_NONE; pthread_t thread = cbmgr->isolator_thread; @@ -160,40 +160,42 @@ sound_pool_error_e _stream_cb_manager_destroy(stream_cb_manager_t *cbmgr) err = pthread_cancel(thread); if (0 != err) { SP_ERROR("Error while cancelling of isolation thread[%d].", err); - g_async_queue_unref(cbmgr->isolator_callback_queue); - pthread_mutex_destroy(&cbmgr->isolator_data_mutex); - pthread_cond_destroy(&cbmgr->isolator_data_cond); - SP_SAFE_GFREE(cbmgr); - SP_DEBUG_FLEAVE(); - return SOUND_POOL_ERROR_INVALID_OPERATION; + ret = SOUND_POOL_ERROR_INVALID_OPERATION; + GOTO_FAIL("", creturn); } } else { SP_ERROR("Invalid isolation thread[%d].", err); - g_async_queue_unref(cbmgr->isolator_callback_queue); - pthread_mutex_destroy(&cbmgr->isolator_data_mutex); - pthread_cond_destroy(&cbmgr->isolator_data_cond); - SP_SAFE_GFREE(cbmgr); - SP_DEBUG_FLEAVE(); - return SOUND_POOL_ERROR_INVALID_OPERATION; + ret = SOUND_POOL_ERROR_INVALID_OPERATION; + GOTO_FAIL("", creturn); } - void *ret; - err = pthread_join(thread, &ret); + void *return_val; + err = pthread_join(thread, &return_val); if (0 != err) SP_ERROR("Error while joining of isolation thread[%d].", err); - if (ret == PTHREAD_CANCELED) + if (return_val == PTHREAD_CANCELED) SP_INFO("Isolation thread canceled."); - else - SP_INFO("Routine joining of isolation thread."); + else { + ret = SOUND_POOL_ERROR_NONE; + GOTO_FAIL("Routine joining of isolation thread.", creturn); + } SP_DEBUG_FLEAVE(); - return SOUND_POOL_ERROR_NONE; + return ret; + +creturn: + g_async_queue_unref(cbmgr->isolator_callback_queue); + pthread_mutex_destroy(&cbmgr->isolator_data_mutex); + pthread_cond_destroy(&cbmgr->isolator_data_cond); + SP_SAFE_GFREE(cbmgr); + SP_DEBUG_FLEAVE(); + return ret; } sound_pool_error_e _stream_cb_manager_register_event(stream_cb_manager_t *cbmgr, sound_stream_t *stream) { - SP_DEBUF_FENTER(); + SP_DEBUG_FENTER(); SP_RETVM_IF(!cbmgr, SOUND_POOL_ERROR_INVALID_PARAMETER, "Can't handle callback manager, it is NULL."); SP_RETVM_IF(!stream, SOUND_POOL_ERROR_INVALID_PARAMETER,