transport: Delay existence based on delay reporting capability
authorArkadiusz Bokowy <arkadiusz.bokowy@gmail.com>
Tue, 8 Oct 2024 20:09:26 +0000 (22:09 +0200)
committerWootak Jung <wootak.jung@samsung.com>
Thu, 20 Feb 2025 07:43:23 +0000 (16:43 +0900)
In case when the existence of the delay property is based on its value
not being zero it is not possible to read the delay if sink sets it to
zero on purpose (or it was not updated by the sink at all). However,
client might expect it to be readable, if SEP reports delay reporting
as available.

Instead of checking the value, we should check the capabilities of
the AVDTP stream. Also, by doing that we can allow this property to
be writable in the future - the exists() callback is used in the
properties_set() function as well.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
profiles/audio/avdtp.c
profiles/audio/avdtp.h
profiles/audio/transport.c

index 91025ec6ccc77e1c082445afb9218eb1f231ac6f..ee6608958b90331da758f2a2c5df2baede7627b3 100644 (file)
@@ -3710,6 +3710,10 @@ gboolean avdtp_stream_has_capabilities(struct avdtp_stream *stream,
        return TRUE;
 }
 
+gboolean avdtp_stream_has_delay_reporting(struct avdtp_stream *stream) {
+       return stream->delay_reporting;
+}
+
 struct avdtp_remote_sep *avdtp_stream_get_remote_sep(
                                                struct avdtp_stream *stream)
 {
index db7ef68f6283eebe9813863a5d108c7e2c1f8599..999fd547098f298f0c96dc894ad25651d250bfd3 100755 (executable)
@@ -256,6 +256,7 @@ struct avdtp_service_capability *avdtp_stream_get_codec(
                                                struct avdtp_stream *stream);
 gboolean avdtp_stream_has_capabilities(struct avdtp_stream *stream,
                                        GSList *caps);
+gboolean avdtp_stream_has_delay_reporting(struct avdtp_stream *stream);
 struct avdtp_remote_sep *avdtp_stream_get_remote_sep(
                                                struct avdtp_stream *stream);
 
index 29306a8178694a6c8273967fdf00f54fe7f6c5f8..88383dabe39ab7a6b82f47d95b2dcf6a3b622cf0 100644 (file)
@@ -384,13 +384,22 @@ static gboolean media_transport_set_fd(struct media_transport *transport,
        return TRUE;
 }
 
+static void *transport_a2dp_get_stream(struct media_transport *transport)
+{
+       struct a2dp_sep *sep = media_endpoint_get_sep(transport->endpoint);
+
+       if (!sep)
+               return NULL;
+
+       return a2dp_sep_get_stream(sep);
+}
+
 static void a2dp_resume_complete(struct avdtp *session, int err,
                                                        void *user_data)
 {
        struct media_owner *owner = user_data;
        struct media_request *req = owner->pending;
        struct media_transport *transport = owner->transport;
-       struct a2dp_sep *sep = media_endpoint_get_sep(transport->endpoint);
        struct avdtp_stream *stream;
        int fd;
        uint16_t imtu, omtu;
@@ -401,7 +410,7 @@ static void a2dp_resume_complete(struct avdtp *session, int err,
        if (err)
                goto fail;
 
-       stream = a2dp_sep_get_stream(sep);
+       stream = transport_a2dp_get_stream(transport);
        if (stream == NULL)
                goto fail;
 
@@ -859,9 +868,13 @@ static gboolean get_state(const GDBusPropertyTable *property,
 static gboolean delay_reporting_exists(const GDBusPropertyTable *property, void *data)
 {
        struct media_transport *transport = data;
-       struct a2dp_transport *a2dp = transport->data;
+       struct avdtp_stream *stream;
+
+       stream = media_transport_get_stream(transport);
+       if (stream == NULL)
+               return FALSE;
 
-       return a2dp->delay != 0;
+       return avdtp_stream_has_delay_reporting(stream);
 }
 #endif
 
@@ -2154,9 +2167,9 @@ static void *transport_asha_init(struct media_transport *transport, void *data)
 #define A2DP_OPS(_uuid, _init, _set_volume, _destroy) \
        TRANSPORT_OPS(_uuid, transport_a2dp_properties, NULL, NULL, _init, \
                        transport_a2dp_resume, transport_a2dp_suspend, \
-                       transport_a2dp_cancel, NULL, NULL, \
-                       transport_a2dp_get_volume, _set_volume, \
-                       _destroy)
+                       transport_a2dp_cancel, NULL, \
+                       transport_a2dp_get_stream, transport_a2dp_get_volume, \
+                       _set_volume, _destroy)
 
 #define BAP_OPS(_uuid, _props, _set_owner, _remove_owner) \
        TRANSPORT_OPS(_uuid, _props, _set_owner, _remove_owner,\