Fixed sound-manager function. 03/166103/5
authorsungrae jo <seongrae.jo@samsung.com>
Mon, 8 Jan 2018 01:45:03 +0000 (10:45 +0900)
committersungrae jo <seongrae.jo@samsung.com>
Fri, 19 Jan 2018 08:48:17 +0000 (17:48 +0900)
Signed-off-by: sungrae jo <seongrae.jo@samsung.com>
Change-Id: I303e29277b528926c89b24dc6e0dba0edf4ad740

server/vcd_recorder.c

index aab017a..7c08a6f 100644 (file)
@@ -259,13 +259,13 @@ static int __apply_device_for_stream_routing()
        sound_device_type_e type;
        sound_device_io_direction_e io_direction;
 
-       if (0 != sound_manager_get_current_device_list(SOUND_DEVICE_IO_DIRECTION_IN_MASK, &device_list)) {
+       if (0 != sound_manager_get_device_list(SOUND_DEVICE_IO_DIRECTION_IN_MASK, &device_list)) {
                SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to get current device list");
                return -1;
        }
 
-       int ret = 0;
-       while (0 == (ret = sound_manager_get_next_device(device_list, &device))) {
+       int ret = -1;
+       while (0 == sound_manager_get_next_device(device_list, &device)) {
                if (0 != sound_manager_get_device_type(device, &type)) {
                        SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to get device tyep");
                        continue;
@@ -280,16 +280,23 @@ static int __apply_device_for_stream_routing()
                                continue;
                        }
                        if (0 != sound_manager_apply_stream_routing(g_stream_info_h)) {
-                               SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR} Fail to apply stream routing");
+                               SLOG(LOG_ERROR, TAG_VCD, "[Recorder ERROR] Fail to apply stream routing");
                                continue;
                        }
-                       SLOG(LOG_DEBUG, TAG_VCD, "[Recorder] Apply device for stream routing");
-                       return 0;
+                       ret = 0;
+                       break;
                }
        }
 
-       SLOG(LOG_WARN, TAG_VCD, "[Recorder] No device");
-       return -1;
+       sound_manager_free_device_list(device_list);
+       device_list = NULL;
+
+       if (0 != ret) {
+               SLOG(LOG_WARN, TAG_VCD, "[Recorder] No device");
+       } else {
+               SLOG(LOG_DEBUG, TAG_VCD, "[Recorder] Apply device for stream routing");
+       }
+       return ret;
 }
 
 static void __device_connection_changed_cb(sound_device_h device, bool is_connected, void *user_data)