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})
##arg); \
} while (0)
-#define SP_DEBUF_FENTER() \
+#define SP_DEBUG_FENTER() \
do { \
LOGD(FONT_COLOR_YELLOW"<Enter>"FONT_COLOR_RESET); \
} while (0)
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.
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}
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;
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 "
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;
*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;
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);
_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);
_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);
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,
*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.");
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);
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;
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.");
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);
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);
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);
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);
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);
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");
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");
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");
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");
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");
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);
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);
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);
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);
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);
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);
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);
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");
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");
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);
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);
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;
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;
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.");
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) {
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;
}
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;
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,
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,
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;
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,
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;
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);
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;
#include "internal/stream.h"
#include <AL/alut.h>
+#ifdef ENABLE_ALURE
+# include <AL/alure.h>
+#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 "
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);
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);
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,
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;
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");
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;
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) {
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);
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)
{
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");
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 "
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);
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);
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,
_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;
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,
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;
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;
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;
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;
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);
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);
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,
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);
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);
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);
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);
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);
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;
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);
static void __queue_destroy_item(gpointer data)
{
- SP_DEBUF_FENTER();
+ SP_DEBUG_FENTER();
SP_SAFE_GFREE(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);
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);
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 "
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;
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,