avrcp: Defer init until service discovery completes
PATCH 1/2 avrcp: Defer init until service discovery completes
When the remote connects AVCTP before SDP has found its AVRCP records, as iOS does on the first connection after pairing, neither controller nor target is initialized and the session stays without them. Wait for the service discovery with device_wait_for_svc_complete() instead.
The remote uses the session meanwhile: iOS asks for the supported events and registers for EVENT_VOLUME_CHANGED right away, and would not get absolute volume otherwise. Report every supported event from the start, the remote registers only those it uses, and create the target when the control channel connects so these registrations are kept; target_init() completes it from the SDP record. A volume registration with no volume set yet starts at max volume, which target_init() set only for 1.4 controllers with category 2.
--- profiles/audio/avrcp.c | 102 ++++++++++++++++++++++------------------- 1 file changed, 55 insertions(+), 47 deletions(-)
profiles/audio/avrcp.c +55 -47
@@ -252,6 +252,7 @@ struct avrcp {bool pos_changed_supported;uint8_t transaction;struct pending_pdu *pending_pdu; +unsigned int svc_complete_id; };struct passthrough_handler {
@@ -1614,12 +1615,6 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session,if (!(session->supported_events & (1 << pdu->params[0 ]))) goto err; -if (!session->target) { - pdu->params_len =cpu_to_be16 (1 ); - pdu->params[0 ] =AVRCP_STATUS_INVALID_COMMAND ; -return AVC_CTYPE_REJECTED ; - } -switch (pdu->params[0 ]) {case AVRCP_EVENT_STATUS_CHANGED : len =2 ;
@@ -1648,6 +1643,10 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session, len =1 ;break ;case AVRCP_EVENT_VOLUME_CHANGED : +/* Start at max volume if none has been set yet */ +if (media_transport_get_a2dp_volume (dev) <0 ) +media_transport_set_a2dp_volume (dev,127 ); + volume =media_transport_get_a2dp_volume (dev);if (volume <0 ) goto err;
@@ -4263,16 +4262,15 @@ static void session_init_browsing(struct avrcp *session) destroy_browsing); } -static struct avrcp_data *data_init (struct avrcp *session,const char *uuid) +static struct avrcp_data *data_init (struct avrcp *session, +struct avrcp_data *data, +const char *uuid) { -struct avrcp_data *data;const sdp_record_t *rec;sdp_list_t *list, *protos;sdp_profile_desc_t *desc;int port =0 ; - data = g_new0(struct avrcp_data, 1); - rec =btd_device_get_record (session->dev, uuid);if (rec ==NULL )return data;
@@ -4348,14 +4346,9 @@ static void avrcp_connect_browsing(struct avrcp *session)static void target_init (struct avrcp *session) { -struct avrcp_server *server = session->server;struct avrcp_data *target; -struct avrcp_player *player;struct btd_service *service; -if (session->target !=NULL ) -return ; - service =btd_device_get_service (session->dev,AVRCP_REMOTE_UUID );if (service ==NULL ) {
@@ -4363,47 +4356,22 @@ static void target_init(struct avrcp *session)return ; } - target =data_init (session,AVRCP_REMOTE_UUID ); - session->target = target; + target =data_init (session, session->target,AVRCP_REMOTE_UUID );DBG ("%p version 0x%04x" , target, target->version);btd_service_connecting_complete (service,0 ); - player =g_slist_nth_data (server->players,0 ); -if (player !=NULL ) { +if (target->player !=NULL ) {int8_t init_volume; - target->player = player; - player->sessions =g_slist_prepend (player->sessions, session); init_volume =btd_device_get_volume (session->dev);media_transport_set_a2dp_volume (session->dev, init_volume); } - session->supported_events |= (1 <<AVRCP_EVENT_STATUS_CHANGED ) | - (1 <<AVRCP_EVENT_TRACK_CHANGED ) | - (1 <<AVRCP_EVENT_TRACK_REACHED_START ) | - (1 <<AVRCP_EVENT_TRACK_REACHED_END ) | - (1 <<AVRCP_EVENT_SETTINGS_CHANGED ); -if (target->version <0x0104 )return ; -if (avrcp_volume_supported (target)) { - session->supported_events |= - (1 <<AVRCP_EVENT_VOLUME_CHANGED ); -/* Check if transport volume hasn't been initialized then set it -* to max so it works properly if the controller attempts to -* subscribe to AVRCP_EVENT_VOLUME_CHANGED. -*/ -if (media_transport_get_a2dp_volume (session->dev) <0 ) -media_transport_set_a2dp_volume (session->dev,127 ); - } - - session->supported_events |= - (1 <<AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED ) | - (1 <<AVRCP_EVENT_AVAILABLE_PLAYERS_CHANGED ); -/* Only check capabilities if controller is not supported */ if (session->controller ==NULL )avrcp_get_capabilities (session);
@@ -4430,7 +4398,8 @@ static void controller_init(struct avrcp *session)return ; } - controller =data_init (session,AVRCP_TARGET_UUID ); + controller = data_init(session, g_new0(struct avrcp_data, 1), +AVRCP_TARGET_UUID ); session->controller = controller;DBG ("%p version 0x%04x" , controller, controller->version);
@@ -4460,8 +4429,35 @@ static void controller_init(struct avrcp *session)avrcp_connect_browsing (session); } +static void session_svc_complete (struct btd_device *dev,int err, +void *user_data) +{ +struct avrcp *session = user_data; + + session->svc_complete_id =0 ; + +if (btd_device_get_service (session->dev,AVRCP_TARGET_UUID ) !=NULL ) +controller_init (session); + +if (btd_device_get_service (session->dev,AVRCP_REMOTE_UUID ) !=NULL ) +target_init (session); +} +static void session_init_control (struct avrcp *session) { +struct avrcp_player *player; + +/* The remote may register for events before its records are known, +* target_init() completes the target from them. +*/ + session->target = g_new0(struct avrcp_data, 1); + + player =g_slist_nth_data (session->server->players,0 ); +if (player !=NULL ) { + session->target->player = player; + player->sessions =g_slist_prepend (player->sessions, session); + } + session->passthrough_id = avctp_register_passthrough_handler( session->conn, handle_passthrough,
@@ -4473,11 +4469,19 @@ static void session_init_control(struct avrcp *session) session); session->control_handlers = control_handlers; -if (btd_device_get_service (session->dev,AVRCP_TARGET_UUID ) !=NULL ) -controller_init (session); +/* Report every event supported: the remote registers those it uses */ + session->supported_events |= (1 <<AVRCP_EVENT_STATUS_CHANGED ) | + (1 <<AVRCP_EVENT_TRACK_CHANGED ) | + (1 <<AVRCP_EVENT_TRACK_REACHED_START ) | + (1 <<AVRCP_EVENT_TRACK_REACHED_END ) | + (1 <<AVRCP_EVENT_SETTINGS_CHANGED ) | + (1 <<AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED ) | + (1 <<AVRCP_EVENT_AVAILABLE_PLAYERS_CHANGED ) | + (1 <<AVRCP_EVENT_VOLUME_CHANGED ); -if (btd_device_get_service (session->dev,AVRCP_REMOTE_UUID ) !=NULL ) -target_init (session); + session->svc_complete_id =device_wait_for_svc_complete (session->dev, + session_svc_complete, + session); }static void controller_destroy (struct avrcp *session)
@@ -4513,6 +4517,10 @@ static void session_destroy(struct avrcp *session, int err)session_abort_pending_pdu (session); +if (session->svc_complete_id) +device_remove_svc_complete_callback (session->dev, + session->svc_complete_id); + service =btd_device_get_service (session->dev,AVRCP_TARGET_UUID );if (service !=NULL ) {if (session->control_id ==0 )
base-commit: 1608f836188610aabeff5a3164169ebe0360e443
Signature · 1 line
2.43.0
PATCH 2/2 avrcp: Check what the remote uses instead of its AVRCP version
The version in the remote's SDP record does not tell which commands it uses. Android phones such as the Nexus 6P show AVRCP 1.3 in their controller record but set the absolute volume and register for EVENT_VOLUME_CHANGED, and the Huawei Nova 7 registers for it without a controller record that passes avrcp_volume_supported(). Both lose absolute volume control.
Accept SetAbsoluteVolume and notify EVENT_VOLUME_CHANGED whenever the remote uses them: the registration already tells whether to notify. Ask any remote for its capabilities and register the events it reports, connect browsing on the feature bit alone, and drop the version checks before SetAddressedPlayer and player settings, which exist only for players and settings the remote reported. Sending SetAbsoluteVolume still requires category 2 when VolumeCategory is set.
--- profiles/audio/avrcp.c | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-)
profiles/audio/avrcp.c +4 -24
@@ -1740,10 +1740,10 @@ err:return AVC_CTYPE_REJECTED ; } -/* SetAbsoluteVolume requires at least version 1.4 and a category-2 */ +/* SetAbsoluteVolume requires a category-2 */ static bool avrcp_volume_supported (struct avrcp_data *data) { -if (!data || data->version <0x0104 ) +if (!data)return false; if (btd_opts.avrcp.volume_category &&
@@ -1763,11 +1763,6 @@ static uint8_t avrcp_handle_set_absolute_volume(struct avrcp *session,if (len !=1 ) goto err; -if (!avrcp_volume_supported (session->target)) { -error ("SetAbsoluteVolume not supported" ); - goto err; - } - volume = pdu->params[0 ] = pdu->params[0 ] &0x7F ;media_transport_set_a2dp_volume (session->dev, volume);
@@ -3084,8 +3079,7 @@ static void avrcp_set_addressed_player(struct avrcp *session,static void set_addressed_player (struct avrcp *session,struct avrcp_player *player) { -if (!player || !player->id || player->addressed || - session->controller->version <0x0104 ) +if (!player || !player->id || player->addressed)return ;/* Set player as addressed */
@@ -3137,9 +3131,6 @@ static bool ct_set_setting(struct media_player *mp, const char *key,if (session ==NULL )return false; -if (session->controller->version <0x0103 ) -return false; -set_ct_player (session, player); attr =attr_to_val (key);
@@ -4369,9 +4360,6 @@ static void target_init(struct avrcp *session)media_transport_set_a2dp_volume (session->dev, init_volume); } -if (target->version <0x0104 ) -return ; -/* Only check capabilities if controller is not supported */ if (session->controller ==NULL )avrcp_get_capabilities (session);
@@ -4415,14 +4403,8 @@ static void controller_init(struct avrcp *session)return ; } -if (controller->version <0x0103 ) -return ; -avrcp_get_capabilities (session); -if (controller->version <0x0104 ) -return ; -if (!(controller->features &AVRCP_FEATURE_BROWSING ))return ;
@@ -4837,10 +4819,8 @@ int avrcp_set_volume(struct btd_device *dev, int8_t volume, bool notify)return -ENOTCONN ;if (notify) { -if (!avrcp_volume_supported (session->target)) { -error ("EVENT_VOLUME_CHANGED not supported" ); +if (!session->target)return -ENOTSUP ; - }return avrcp_event (session,AVRCP_EVENT_VOLUME_CHANGED , &volume); }
Signature · 1 line
2.43.0
Luiz Augusto von Dentz
maintainerHi Simon,
Quoted 192 lines · Simon Mikuda
When the remote connects AVCTP before SDP has found its AVRCP records, as iOS does on the first connection after pairing, neither controller nor target is initialized and the session stays without them. Wait for the service discovery with
device_wait_for_svc_complete()instead.The remote uses the session meanwhile: iOS asks for the supported events and registers for
EVENT_VOLUME_CHANGEDright away, and would not get absolute volume otherwise. Report every supported event from the start, the remote registers only those it uses, and create the target when the control channel connects so these registrations are kept;target_init()completes it from the SDP record. A volume registration with no volume set yet starts at max volume, whichtarget_init()set only for 1.4 controllers with category 2.Assisted-by Claude:claude-opus-5-5--- profiles/audio/avrcp.c | 102 ++++++++++++++++++++++------------------- 1 file changed, 55 insertions(+), 47 deletions(-)profiles/audio/avrcp.c +39
-44@@ -252,6 +252,7 @@ struct avrcp {bool pos_changed_supported;uint8_t transaction;struct pending_pdu *pending_pdu; +unsigned int svc_complete_id; };struct passthrough_handler {@@ -1614,12 +1615,6 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session,if (!(session->supported_events & (1 << pdu->params[0 ]))) goto err; -if (!session->target) { - pdu->params_len =cpu_to_be16 (1 ); - pdu->params[0 ] =AVRCP_STATUS_INVALID_COMMAND ; -return AVC_CTYPE_REJECTED ; - } -switch (pdu->params[0 ]) {case AVRCP_EVENT_STATUS_CHANGED : len =2 ;@@ -1648,6 +1643,10 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session, len =1 ;break ;case AVRCP_EVENT_VOLUME_CHANGED : +/* Start at max volume if none has been set yet */ +if (media_transport_get_a2dp_volume (dev) <0 ) +media_transport_set_a2dp_volume (dev,127 ); + volume =media_transport_get_a2dp_volume (dev);if (volume <0 ) goto err;@@ -4263,16 +4262,15 @@ static void session_init_browsing(struct avrcp *session) destroy_browsing); } -static struct avrcp_data *data_init (struct avrcp *session,const char *uuid) +static struct avrcp_data *data_init (struct avrcp *session, +struct avrcp_data *data, +const char *uuid) { -struct avrcp_data *data;const sdp_record_t *rec;sdp_list_t *list, *protos;sdp_profile_desc_t *desc;int port =0 ; - data = g_new0(struct avrcp_data, 1); - rec =btd_device_get_record (session->dev, uuid);if (rec ==NULL )return data;@@ -4348,14 +4346,9 @@ static void avrcp_connect_browsing(struct avrcp *session)static void target_init (struct avrcp *session) { -struct avrcp_server *server = session->server;struct avrcp_data *target; -struct avrcp_player *player;struct btd_service *service; -if (session->target !=NULL ) -return ; - service =btd_device_get_service (session->dev,AVRCP_REMOTE_UUID );if (service ==NULL ) {@@ -4363,47 +4356,22 @@ static void target_init(struct avrcp *session)return ; } - target =data_init (session,AVRCP_REMOTE_UUID ); - session->target = target; + target =data_init (session, session->target,AVRCP_REMOTE_UUID );DBG ("%p version 0x%04x" , target, target->version);btd_service_connecting_complete (service,0 ); - player =g_slist_nth_data (server->players,0 ); -if (player !=NULL ) { +if (target->player !=NULL ) {int8_t init_volume; - target->player = player; - player->sessions =g_slist_prepend (player->sessions, session); init_volume =btd_device_get_volume (session->dev);media_transport_set_a2dp_volume (session->dev, init_volume); } - session->supported_events |= (1 <<AVRCP_EVENT_STATUS_CHANGED ) | - (1 <<AVRCP_EVENT_TRACK_CHANGED ) | - (1 <<AVRCP_EVENT_TRACK_REACHED_START ) | - (1 <<AVRCP_EVENT_TRACK_REACHED_END ) | - (1 <<AVRCP_EVENT_SETTINGS_CHANGED ); -if (target->version <0x0104 )return ; -if (avrcp_volume_supported (target)) { - session->supported_events |= - (1 <<AVRCP_EVENT_VOLUME_CHANGED ); -/* Check if transport volume hasn't been initialized then set it -* to max so it works properly if the controller attempts to -* subscribe to AVRCP_EVENT_VOLUME_CHANGED. -*/ -if (media_transport_get_a2dp_volume (session->dev) <0 ) -media_transport_set_a2dp_volume (session->dev,127 ); - } - - session->supported_events |= - (1 <<AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED ) | - (1 <<AVRCP_EVENT_AVAILABLE_PLAYERS_CHANGED ); -/* Only check capabilities if controller is not supported */ if (session->controller ==NULL )avrcp_get_capabilities (session);@@ -4430,7 +4398,8 @@ static void controller_init(struct avrcp *session)return ; } - controller =data_init (session,AVRCP_TARGET_UUID ); + controller = data_init(session, g_new0(struct avrcp_data, 1), +AVRCP_TARGET_UUID ); session->controller = controller;DBG ("%p version 0x%04x" , controller, controller->version);@@ -4460,8 +4429,35 @@ static void controller_init(struct avrcp *session)avrcp_connect_browsing (session); } +static void session_svc_complete (struct btd_device *dev,int err, +void *user_data) +{ +struct avrcp *session = user_data; + + session->svc_complete_id =0 ; + +if (btd_device_get_service (session->dev,AVRCP_TARGET_UUID ) !=NULL ) +controller_init (session); + +if (btd_device_get_service (session->dev,AVRCP_REMOTE_UUID ) !=NULL ) +target_init (session); +} +static void session_init_control (struct avrcp *session) { +struct avrcp_player *player; + +/* The remote may register for events before its records are known, +* target_init() completes the target from them. +*/ + session->target = g_new0(struct avrcp_data, 1); + + player =g_slist_nth_data (session->server->players,0 ); +if (player !=NULL ) { + session->target->player = player; + player->sessions =g_slist_prepend (player->sessions, session); + } + session->passthrough_id = avctp_register_passthrough_handler( session->conn, handle_passthrough,@@ -4473,11 +4469,19 @@ static void session_init_control(struct avrcp *session) session); session->control_handlers = control_handlers; -if (btd_device_get_service (session->dev,AVRCP_TARGET_UUID ) !=NULL )
profiles/audio/avrcp.c static void session_init_control(struct avrcp *session) · line 4480
Quoted 10 lines
profiles/audio/avrcp.c +9
-1-controller_init (session); +/* Report every event supported: the remote registers those it uses */ + session->supported_events |= (1 <<AVRCP_EVENT_STATUS_CHANGED ) | + (1 <<AVRCP_EVENT_TRACK_CHANGED ) | + (1 <<AVRCP_EVENT_TRACK_REACHED_START ) | + (1 <<AVRCP_EVENT_TRACK_REACHED_END ) | + (1 <<AVRCP_EVENT_SETTINGS_CHANGED ) | + (1 <<AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED ) | + (1 <<AVRCP_EVENT_AVAILABLE_PLAYERS_CHANGED ) | + (1 <<AVRCP_EVENT_VOLUME_CHANGED );
So this seems to disregard what version we are operating on so we don't foresee any problems with sessions getting unknown event bits being set? I guess we can only do that if we are absolutely sure PTS/Qualification will never ever be updated to check bits considered RFU (e.g 1.3).
Quoted 25 lines
profiles/audio/avrcp.c +7
-2-if (btd_device_get_service (session->dev,AVRCP_REMOTE_UUID ) !=NULL ) -target_init (session); + session->svc_complete_id =device_wait_for_svc_complete (session->dev, + session_svc_complete, + session); }static void controller_destroy (struct avrcp *session)@@ -4513,6 +4517,10 @@ static void session_destroy(struct avrcp *session, int err)session_abort_pending_pdu (session); +if (session->svc_complete_id) +device_remove_svc_complete_callback (session->dev, + session->svc_complete_id); + service =btd_device_get_service (session->dev,AVRCP_TARGET_UUID );if (service !=NULL ) {if (session->control_id ==0 )base-commit:
1608f836188610aabeff5a3164169ebe0360e443--
2.43.0
Signature · 1 line
Luiz Augusto von Dentz
Good point Luiz.
I have re-run all AVRCP test cases and they passed with these changes fine (on RPi5 with Intel BE200 chip)
BR
Simon
Quoted 237 lines · Luiz Augusto von Dentz
Hi Simon,
Quoted 191 lines · Simon Mikuda
When the remote connects AVCTP before SDP has found its AVRCP records, as iOS does on the first connection after pairing, neither controller nor target is initialized and the session stays without them. Wait for the service discovery with
device_wait_for_svc_complete()instead.The remote uses the session meanwhile: iOS asks for the supported events and registers for
EVENT_VOLUME_CHANGEDright away, and would not get absolute volume otherwise. Report every supported event from the start, the remote registers only those it uses, and create the target when the control channel connects so these registrations are kept;target_init()completes it from the SDP record. A volume registration with no volume set yet starts at max volume, whichtarget_init()set only for 1.4 controllers with category 2.Assisted-by Claude:claude-opus-5-5--- profiles/audio/avrcp.c | 102 ++++++++++++++++++++++------------------- 1 file changed, 55 insertions(+), 47 deletions(-)profiles/audio/avrcp.c +39
-44@@ -252,6 +252,7 @@ struct avrcp {bool pos_changed_supported;uint8_t transaction;struct pending_pdu *pending_pdu; +unsigned int svc_complete_id; };struct passthrough_handler {@@ -1614,12 +1615,6 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session,if (!(session->supported_events & (1 << pdu->params[0 ]))) goto err; -if (!session->target) { - pdu->params_len =cpu_to_be16 (1 ); - pdu->params[0 ] =AVRCP_STATUS_INVALID_COMMAND ; -return AVC_CTYPE_REJECTED ; - } -switch (pdu->params[0 ]) {case AVRCP_EVENT_STATUS_CHANGED : len =2 ;@@ -1648,6 +1643,10 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session, len =1 ;break ;case AVRCP_EVENT_VOLUME_CHANGED : +/* Start at max volume if none has been set yet */ +if (media_transport_get_a2dp_volume (dev) <0 ) +media_transport_set_a2dp_volume (dev,127 ); + volume =media_transport_get_a2dp_volume (dev);if (volume <0 ) goto err;@@ -4263,16 +4262,15 @@ static void session_init_browsing(struct avrcp *session) destroy_browsing); } -static struct avrcp_data *data_init (struct avrcp *session,const char *uuid) +static struct avrcp_data *data_init (struct avrcp *session, +struct avrcp_data *data, +const char *uuid) { -struct avrcp_data *data;const sdp_record_t *rec;sdp_list_t *list, *protos;sdp_profile_desc_t *desc;int port =0 ; - data = g_new0(struct avrcp_data, 1); - rec =btd_device_get_record (session->dev, uuid);if (rec ==NULL )return data;@@ -4348,14 +4346,9 @@ static void avrcp_connect_browsing(struct avrcp *session)static void target_init (struct avrcp *session) { -struct avrcp_server *server = session->server;struct avrcp_data *target; -struct avrcp_player *player;struct btd_service *service; -if (session->target !=NULL ) -return ; - service =btd_device_get_service (session->dev,AVRCP_REMOTE_UUID );if (service ==NULL ) {@@ -4363,47 +4356,22 @@ static void target_init(struct avrcp *session)return ; } - target =data_init (session,AVRCP_REMOTE_UUID ); - session->target = target; + target =data_init (session, session->target,AVRCP_REMOTE_UUID );DBG ("%p version 0x%04x" , target, target->version);btd_service_connecting_complete (service,0 ); - player =g_slist_nth_data (server->players,0 ); -if (player !=NULL ) { +if (target->player !=NULL ) {int8_t init_volume; - target->player = player; - player->sessions =g_slist_prepend (player->sessions, session); init_volume =btd_device_get_volume (session->dev);media_transport_set_a2dp_volume (session->dev, init_volume); } - session->supported_events |= (1 <<AVRCP_EVENT_STATUS_CHANGED ) | - (1 <<AVRCP_EVENT_TRACK_CHANGED ) | - (1 <<AVRCP_EVENT_TRACK_REACHED_START ) | - (1 <<AVRCP_EVENT_TRACK_REACHED_END ) | - (1 <<AVRCP_EVENT_SETTINGS_CHANGED ); -if (target->version <0x0104 )return ; -if (avrcp_volume_supported (target)) { - session->supported_events |= - (1 <<AVRCP_EVENT_VOLUME_CHANGED ); -/* Check if transport volume hasn't been initialized then set it -* to max so it works properly if the controller attempts to -* subscribe to AVRCP_EVENT_VOLUME_CHANGED. -*/ -if (media_transport_get_a2dp_volume (session->dev) <0 ) -media_transport_set_a2dp_volume (session->dev,127 ); - } - - session->supported_events |= - (1 <<AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED ) | - (1 <<AVRCP_EVENT_AVAILABLE_PLAYERS_CHANGED ); -/* Only check capabilities if controller is not supported */ if (session->controller ==NULL )avrcp_get_capabilities (session);@@ -4430,7 +4398,8 @@ static void controller_init(struct avrcp *session)return ; } - controller =data_init (session,AVRCP_TARGET_UUID ); + controller = data_init(session, g_new0(struct avrcp_data, 1), +AVRCP_TARGET_UUID ); session->controller = controller;DBG ("%p version 0x%04x" , controller, controller->version);@@ -4460,8 +4429,35 @@ static void controller_init(struct avrcp *session)avrcp_connect_browsing (session); } +static void session_svc_complete (struct btd_device *dev,int err, +void *user_data) +{ +struct avrcp *session = user_data; + + session->svc_complete_id =0 ; + +if (btd_device_get_service (session->dev,AVRCP_TARGET_UUID ) !=NULL ) +controller_init (session); + +if (btd_device_get_service (session->dev,AVRCP_REMOTE_UUID ) !=NULL ) +target_init (session); +} +static void session_init_control (struct avrcp *session) { +struct avrcp_player *player; + +/* The remote may register for events before its records are known, +* target_init() completes the target from them. +*/ + session->target = g_new0(struct avrcp_data, 1); + + player =g_slist_nth_data (session->server->players,0 ); +if (player !=NULL ) { + session->target->player = player; + player->sessions =g_slist_prepend (player->sessions, session); + } + session->passthrough_id = avctp_register_passthrough_handler( session->conn, handle_passthrough,@@ -4473,11 +4469,19 @@ static void session_init_control(struct avrcp *session) session); session->control_handlers = control_handlers; -if (btd_device_get_service (session->dev,AVRCP_TARGET_UUID ) !=NULL )profiles/audio/avrcp.c static void session_init_control(struct avrcp *session) · line 4480
Quoted 10 lines
profiles/audio/avrcp.c +9
-1-controller_init (session); +/* Report every event supported: the remote registers those it uses */ + session->supported_events |= (1 <<AVRCP_EVENT_STATUS_CHANGED ) | + (1 <<AVRCP_EVENT_TRACK_CHANGED ) | + (1 <<AVRCP_EVENT_TRACK_REACHED_START ) | + (1 <<AVRCP_EVENT_TRACK_REACHED_END ) | + (1 <<AVRCP_EVENT_SETTINGS_CHANGED ) | + (1 <<AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED ) | + (1 <<AVRCP_EVENT_AVAILABLE_PLAYERS_CHANGED ) | + (1 <<AVRCP_EVENT_VOLUME_CHANGED );So this seems to disregard what version we are operating on so we don't foresee any problems with sessions getting unknown event bits being set? I guess we can only do that if we are absolutely sure PTS/Qualification will never ever be updated to check bits considered RFU (e.g 1.3).
Quoted 25 lines
profiles/audio/avrcp.c +7
-2-if (btd_device_get_service (session->dev,AVRCP_REMOTE_UUID ) !=NULL ) -target_init (session); + session->svc_complete_id =device_wait_for_svc_complete (session->dev, + session_svc_complete, + session); }static void controller_destroy (struct avrcp *session)@@ -4513,6 +4517,10 @@ static void session_destroy(struct avrcp *session, int err)session_abort_pending_pdu (session); +if (session->svc_complete_id) +device_remove_svc_complete_callback (session->dev, + session->svc_complete_id); + service =btd_device_get_service (session->dev,AVRCP_TARGET_UUID );if (service !=NULL ) {if (session->control_id ==0 )base-commit:
1608f836188610aabeff5a3164169ebe0360e443--
2.43.0
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/series/1220896/
---Test result---
Test Summary:
CheckPatch PASS 0.92 seconds GitLint PASS 0.60 seconds BuildEll PASS 20.63 seconds BluezMake PASS 324.07 seconds MakeCheck PASS 2.78 seconds MakeDistcheck PASS 150.91 seconds CheckValgrind PASS 162.94 seconds CheckSmatch PASS 323.72 seconds bluezmakeextell PASS 101.75 seconds TestFunctional PASS 1244.74 seconds IncrementalBuild PASS 325.93 seconds ScanBuild PASS 1224.80 seconds
https://github.com/bluez/bluez/pull/2904
---
Regards,
Linux Bluetooth