Fix for SVACE defects
[platform/core/api/sound-pool.git] / src / soundpool.c
index faa6fcc..bbcd013 100644 (file)
@@ -29,7 +29,6 @@
 
 #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,
@@ -73,11 +72,10 @@ static void __stream_deactivate_iter(gpointer key, gpointer value,
        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_DEBUG_FENTER();
-       SP_RETVM_IF(max_streams == 0, SOUND_POOL_ERROR_INVALID_PARAMETER,
-                       "Max streams count should be greater than 0.");
+       SP_INST_CHECK(pool, SOUND_POOL_ERROR_INVALID_PARAMETER);
 
        sound_pool_t *_pool = NULL;
        SP_RETVM_IF(!(_pool = g_try_malloc0(sizeof(*_pool))),
@@ -111,7 +109,6 @@ sound_pool_error_e _sound_pool_create(size_t max_streams, sound_pool_t **pool)
                                "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;
@@ -204,8 +201,8 @@ sound_pool_error_e _sound_pool_activate(sound_pool_t *pool)
        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.");
@@ -214,9 +211,6 @@ sound_pool_error_e _sound_pool_activate(sound_pool_t *pool)
                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)
@@ -238,8 +232,6 @@ sound_pool_error_e _sound_pool_deactivate(sound_pool_t *pool)
        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.");
@@ -248,9 +240,6 @@ sound_pool_error_e _sound_pool_deactivate(sound_pool_t *pool)
                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)