device-manager: avoid registering the built-in device if not loaded properly 39/276439/3
authorSeungbae Shin <seungbae.shin@samsung.com>
Thu, 16 Jun 2022 14:48:35 +0000 (23:48 +0900)
committerSeungbae Shin <seungbae.shin@samsung.com>
Tue, 21 Jun 2022 02:39:02 +0000 (11:39 +0900)
Previously, it was shown that the built-in device exists even module is not loaded correctly.
Now, this change fixed that mismatch.

[Version] 15.0.17
[Issue Type] Bug

Change-Id: I6c78231e62c75ac759964697ee2e079a80bb58c3

packaging/pulseaudio-modules-tizen.spec
src/device-manager.c

index 16babe13b110f38178e54ba6c3a65242fc8e5ca6..994fa153e8a202064a277cb5a0a93877ad3ba178 100644 (file)
@@ -2,7 +2,7 @@
 
 Name:             pulseaudio-modules-tizen
 Summary:          Pulseaudio modules for Tizen
-Version:          15.0.16
+Version:          15.0.17
 Release:          0
 Group:            Multimedia/Audio
 License:          LGPL-2.1+
index b5d6e9c3a84240595fd09a231e5506d33168a3b7..4ba445014f4e576aed69afb82c050124427bd785 100644 (file)
@@ -2015,6 +2015,7 @@ static int _load_type_devices(device_type_info *type_info, bool is_playback, pa_
     const char *device_string, *params;
     bool first_one = true;
     void *device;
+    bool loaded = false;
 
     pa_assert(dm);
     pa_assert(type_info);
@@ -2035,6 +2036,7 @@ static int _load_type_devices(device_type_info *type_info, bool is_playback, pa_
     }
 
     PA_HASHMAP_FOREACH_KV(role, device_string, pcm_devices, state) {
+        pa_log_debug("k:role(%s), v:device_string(%s)", role, device_string);
         /* skip duplicate load */
         if (is_playback && _core_get_sink(dm->core, device_string, NULL)) {
             pa_log_debug("Already loaded %s", device_string);
@@ -2065,6 +2067,12 @@ static int _load_type_devices(device_type_info *type_info, bool is_playback, pa_
             first_one = false;
         }
         pa_log_info("load device success %s %s %s", device_string, params, role);
+        loaded = true;
+    }
+
+    if (!loaded) {
+        pa_log_error("Returning error due to no device loaded in success");
+        return -1;
     }
 
     return 0;
@@ -2204,7 +2212,7 @@ static int load_builtin_devices(pa_device_manager *dm) {
 
         type = type_info->type;
 
-        pa_log_info("type_info : %s", type);
+        pa_log_info("[%u] type_info : %s", type_idx, type);
         detected_type = _device_get_detected(dm, type, NULL);
         if (detected_type == DEVICE_DISCONNECTED) {
             pa_log_info("Not detected yet");
@@ -2219,23 +2227,25 @@ static int load_builtin_devices(pa_device_manager *dm) {
                 _load_type_devices(type_info, true, dm);
             }
             handle_device_connected(dm, type, NULL, NULL, detected_type, type_info);
-        } else if (device_type_is_use_external_card(type) == false) {
-            dm_device_direction_t direction;
-            direction = device_type_get_static_direction(type);
+        } else if (!device_type_is_use_external_card(type)) {
+            dm_device_direction_t direction = device_type_get_static_direction(type);
             if (direction == DM_DEVICE_DIRECTION_NONE) {
                 pa_log_warn("Wrong direction");
                 continue;
             }
-            if (direction & DM_DEVICE_DIRECTION_OUT)
-                _load_type_devices(type_info, true, dm);
-            if (direction & DM_DEVICE_DIRECTION_IN)
-                _load_type_devices(type_info, false, dm);
-            handle_device_connected(dm, type, NULL, NULL, detected_type, type_info);
+
+            if ( _load_type_devices(type_info, (direction & DM_DEVICE_DIRECTION_OUT), dm) == 0)
+                handle_device_connected(dm, type, NULL, NULL, detected_type, type_info);
+            else
+                pa_log_warn("type %s failed....", type);
+
         } else {
             pa_log_warn("Invalid case");
         }
     }
 
+    pa_log_debug("Load Builtin Devices Done");
+
     return 0;
 }