a2dp: Don't suspend a sink stream on our own
PATCH v2 1/1 a2dp: Don't suspend a sink stream on our own
When the remote source starts a stream that no transport owner takes within 5 seconds, or the owner goes away without Release(), BlueZ suspends the stream. Some phones then wait for us to resume it and never start it again. PTS GAVDP/ACP/APP/TRC/BV-02-C fails the same way.
Leave suspending a sink stream to the remote source. Release() still suspends it, and source streams keep the timer. A sink transport whose owner goes away while the stream plays is now pending, not idle, so it can be acquired again.
---
Changes in v2:
- transport: a sink transport whose owner goes away while the stream plays is pending, not idle, so TryAcquire() works again
profiles/audio/a2dp.c | 8 ++++++-- profiles/audio/transport.c | 13 ++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-)
profiles/audio/a2dp.c +6 -2
@@ -1409,7 +1409,10 @@ static gboolean start_ind(struct avdtp *session, struct avdtp_local_sep *sep,if (!a2dp_stream)return FALSE; -if (!a2dp_stream->locked) +/* Leave suspending a sink stream to the remote source: some phones +* wait for us to resume a stream we suspended. +*/ +if (!a2dp_stream->locked && a2dp_sep->type ==AVDTP_SEP_TYPE_SOURCE ) a2dp_stream->suspend_timer = timeout_add_seconds( SUSPEND_TIMEOUT, (timeout_func_t) suspend_timeout,
@@ -3604,7 +3607,8 @@ gboolean a2dp_sep_unlock(struct a2dp_sep *sep, struct avdtp *session)/* Set timer here */ break ;case AVDTP_STATE_STREAMING : -if (avdtp_suspend (session, stream->stream) ==0 ) +if (sep->type ==AVDTP_SEP_TYPE_SOURCE && +avdtp_suspend (session, stream->stream) ==0 ) stream->suspending = TRUE;break ;case AVDTP_STATE_IDLE :
profiles/audio/transport.c +12 -1
@@ -458,6 +458,7 @@ static guint transport_a2dp_suspend(struct media_transport *transport,struct a2dp_transport *a2dp = transport->data;struct media_endpoint *endpoint = transport->endpoint;struct a2dp_sep *sep =media_endpoint_get_sep (endpoint); +struct avdtp_stream *stream;if (owner !=NULL ) {if (a2dp->resume_id) {
@@ -469,7 +470,17 @@ static guint transport_a2dp_suspend(struct media_transport *transport, owner); } -transport_set_state (transport,TRANSPORT_STATE_IDLE ); +/* A sink stream is left for the remote to suspend: until then it is +* playing, just not acquired. +*/ + stream =transport_a2dp_get_stream (transport); + +if (!strcmp (media_endpoint_get_uuid (endpoint),A2DP_SINK_UUID ) && +avdtp_stream_get_state (stream) ==AVDTP_STATE_STREAMING ) +transport_set_state (transport,TRANSPORT_STATE_PENDING ); +else +transport_set_state (transport,TRANSPORT_STATE_IDLE ); +a2dp_sep_unlock (sep, a2dp->session);return 0 ;
base-commit: 1608f836188610aabeff5a3164169ebe0360e443
Signature · 1 line
2.43.0