#define DEFAULT_VOLUME_VALUE 1.0f
-static ALCdevice *device = NULL;
static void __stream_activate_iter(gpointer key, gpointer value,
gpointer user_data);
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;
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;
SP_DEBUG_FLEAVE();
}
-sound_pool_error_e _sound_pool_create(size_t max_streams, sound_pool_t **pool)
+sound_pool_error_e _sound_pool_create(sound_pool_t **pool)
{
- SP_DEBUF_FENTER();
- SP_RETVM_IF(max_streams == 0, SOUND_POOL_ERROR_INVALID_PARAMETER,
- "Max streams count should be greater than 0.");
+ SP_DEBUG_FENTER();
+ SP_INST_CHECK(pool, SOUND_POOL_ERROR_INVALID_PARAMETER);
sound_pool_t *_pool = NULL;
SP_RETVM_IF(!(_pool = g_try_malloc0(sizeof(*_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) {
"table in sound pool", cfail);
}
- _pool->max_streams = max_streams;
_pool->volume = DEFAULT_VOLUME_VALUE;
_pool->max_stream_index = 0;
_pool->state = SOUND_POOL_STATE_INACTIVE;
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_state_e old_state = pool->state;
pool->state = SOUND_POOL_STATE_ACTIVE;
- /* Generate array of all AlSources in pool */
- GPtrArray *streams = NULL;
+ _sound_stream_priority_update_playback(pool->mgr_priority);
+
if (g_hash_table_size(pool->streams) > 0) {
SP_RETVM_IF(!alcMakeContextCurrent(pool->al_context),
SOUND_POOL_ERROR_INVALID_OPERATION, "Can't set current context.");
SP_INFO("Resuming [%d] number of streams.", len);
}
- if (streams)
- g_ptr_array_free(streams, TRUE);
-
SP_INFO("Sound pool has been activated");
if (pool->state_cb_info.callback)
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_state_e old_state = pool->state;
pool->state = SOUND_POOL_STATE_INACTIVE;
- /* Generate array of all AlSources in pool */
- GPtrArray *streams = NULL;
if (g_hash_table_size(pool->streams) > 0) {
SP_RETVM_IF(!alcMakeContextCurrent(pool->al_context),
SOUND_POOL_ERROR_INVALID_OPERATION, "Can't set current context.");
SP_INFO("Suspending [%d] number of streams.", len);
}
- if (streams)
- g_ptr_array_free(streams, TRUE);
-
SP_INFO("Sound pool has been deactivated");
if (pool->state_cb_info.callback)
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;