Disable session backward compatibility with soundpool
[platform/core/api/sound-pool.git] / src / source.c
index 21de78d..c35d8af 100644 (file)
 
 #include "internal/source.h"
 #include "internal/stream.h"
-
 #include <unistd.h>
-#include <AL/alut.h>
 #ifdef ENABLE_ALURE
-#      include <AL/alure.h>
+#include <AL/alure.h>
+#else
+#include <AL/alut.h>
 #endif
 
 static sound_pool_error_e __sound_pool_add_source(sound_pool_t *pool, sound_source_t *src);
@@ -77,8 +77,13 @@ static sound_pool_error_e __sound_pool_remove_source(sound_pool_t *pool, sound_s
                while (g_hash_table_iter_next(&iter, &key, &value)) {
                        guint size_before = g_hash_table_size(pool->streams);
                        sound_stream_t *stream = (sound_stream_t*)value;
-                       if (src == stream->parent_source)
-                               _sound_stream_destroy((sound_stream_t*)value);
+                       if (src == stream->parent_source) {
+                               if (stream->state == SOUND_POOL_STREAM_STATE_STOPPED || stream->state == SOUND_POOL_STREAM_STATE_FINISHED) {
+                                       SP_DEBUG("Callback isolator thread destroying the stream");
+                               } else {
+                                       _sound_stream_destroy((sound_stream_t*)value);
+                               }
+                       }
                        guint size_after = g_hash_table_size(pool->streams);
                        if (size_before != size_after)
                                g_hash_table_iter_init(&iter, pool->streams);
@@ -103,7 +108,7 @@ static sound_pool_error_e __probe_file_access(const char *file, int amode)
                strerror_r(errno, errmsg, sizeof(errmsg));
                SP_ERROR("Couldn`t open file in [%i] mode, reason [%s].", amode, errmsg);
                if (EACCES == errno)
-                       ret = SOUND_POOL_ERROR_PERMISSION_DENIED;
+                       ret = SOUND_POOL_ERROR_NOT_PERMITTED;
                else if (ENOENT == errno)
                        ret = SOUND_POOL_ERROR_NO_SUCH_FILE;
                else