media: Fix registering PAC endpoints if ISO socket are not supported
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Tue, 30 Aug 2022 21:49:20 +0000 (14:49 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 15 May 2023 09:25:54 +0000 (14:55 +0530)
If adapter don't support ISO sockets the PAC UUIDs shall not be allowed
to be registered as they depend on ISO sockets to work properly.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
profiles/audio/media.c

index b03439a..2fea023 100644 (file)
@@ -1467,20 +1467,23 @@ static bool endpoint_properties_get(const char *uuid,
        return true;
 }
 
-static bool endpoint_supported(void)
+static bool endpoint_supported(struct btd_adapter *adapter)
 {
        return true;
 }
 
-static bool experimental_endpoint_supported(void)
+static bool experimental_endpoint_supported(struct btd_adapter *adapter)
 {
+       if (!btd_adapter_has_exp_feature(adapter, EXP_FEAT_ISO_SOCKET))
+               return false;
+
        return g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL;
 }
 
 static struct media_endpoint_init {
        const char *uuid;
        bool (*func)(struct media_endpoint *endpoint, int *err);
-       bool (*supported)(void);
+       bool (*supported)(struct btd_adapter *adapter);
 } init_table[] = {
        { A2DP_SOURCE_UUID, endpoint_init_a2dp_source, endpoint_supported },
        { A2DP_SINK_UUID, endpoint_init_a2dp_sink, endpoint_supported },
@@ -1554,6 +1557,10 @@ media_endpoint_create(struct media_adapter *adapter,
 
        for (i = 0; i < ARRAY_SIZE(init_table); i++) {
                init = &init_table[i];
+
+               if (!init->supported(adapter->btd_adapter))
+                       continue;
+
                if (!strcasecmp(init->uuid, uuid)) {
                        succeeded = init->func(endpoint, err);
                        break;
@@ -3402,6 +3409,7 @@ static const GDBusMethodTable media_methods[] = {
 static gboolean supported_uuids(const GDBusPropertyTable *property,
                                        DBusMessageIter *iter, void *data)
 {
+       struct media_adapter *adapter = data;
        DBusMessageIter entry;
        size_t i;
 
@@ -3411,7 +3419,7 @@ static gboolean supported_uuids(const GDBusPropertyTable *property,
        for (i = 0; i < ARRAY_SIZE(init_table); i++) {
                struct media_endpoint_init *init = &init_table[i];
 
-               if (init->supported())
+               if (init->supported(adapter->btd_adapter))
                        dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING,
                                                        &init->uuid);
        }