diff mbox series

[BlueZ] avrcp: Fix always requesting player settings for category 1

Message ID 20200527224343.182610-1-luiz.dentz@gmail.com (mailing list archive)
State Accepted
Delegated to: Luiz Von Dentz
Headers show
Series [BlueZ] avrcp: Fix always requesting player settings for category 1 | expand

Commit Message

Luiz Augusto von Dentz May 27, 2020, 10:43 p.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

Player Application settings is not mandatory for category 1 so instead
of always listing the settings the code now checks if
AVRCP_FEATURE_PLAYER_SETTINGS is enabled.
---
 profiles/audio/avrcp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Luiz Augusto von Dentz May 27, 2020, 10:46 p.m. UTC | #1
On Wed, May 27, 2020 at 3:43 PM Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
>
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> Player Application settings is not mandatory for category 1 so instead
> of always listing the settings the code now checks if
> AVRCP_FEATURE_PLAYER_SETTINGS is enabled.
> ---
>  profiles/audio/avrcp.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
> index 773ccdb60..75811bf98 100644
> --- a/profiles/audio/avrcp.c
> +++ b/profiles/audio/avrcp.c
> @@ -3814,7 +3814,8 @@ static gboolean avrcp_get_capabilities_resp(struct avctp *conn, uint8_t code,
>         if (!session->controller || !session->controller->player)
>                 return FALSE;
>
> -       if (!(events & (1 << AVRCP_EVENT_SETTINGS_CHANGED)))
> +       if ((session->controller->features & AVRCP_FEATURE_PLAYER_SETTINGS) &&
> +                       !(events & (1 << AVRCP_EVENT_SETTINGS_CHANGED)))
>                 avrcp_list_player_attributes(session);
>
>         if (!(events & (1 << AVRCP_EVENT_STATUS_CHANGED)))
> --
> 2.25.3

Please let me know if you are able to test the above patch, it should
fix the problem with Senheisers headsets if the are not setting the
Player Settings bits this would prevent the command to be send so it
doesn't crash.
Andrey Semashev May 28, 2020, 12:23 a.m. UTC | #2
On 2020-05-28 01:46, Luiz Augusto von Dentz wrote:
> On Wed, May 27, 2020 at 3:43 PM Luiz Augusto von Dentz
> <luiz.dentz@gmail.com> wrote:
>>
>> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>>
>> Player Application settings is not mandatory for category 1 so instead
>> of always listing the settings the code now checks if
>> AVRCP_FEATURE_PLAYER_SETTINGS is enabled.
>> ---
>>   profiles/audio/avrcp.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
>> index 773ccdb60..75811bf98 100644
>> --- a/profiles/audio/avrcp.c
>> +++ b/profiles/audio/avrcp.c
>> @@ -3814,7 +3814,8 @@ static gboolean avrcp_get_capabilities_resp(struct avctp *conn, uint8_t code,
>>          if (!session->controller || !session->controller->player)
>>                  return FALSE;
>>
>> -       if (!(events & (1 << AVRCP_EVENT_SETTINGS_CHANGED)))
>> +       if ((session->controller->features & AVRCP_FEATURE_PLAYER_SETTINGS) &&
>> +                       !(events & (1 << AVRCP_EVENT_SETTINGS_CHANGED)))
>>                  avrcp_list_player_attributes(session);
>>
>>          if (!(events & (1 << AVRCP_EVENT_STATUS_CHANGED)))
>> --
>> 2.25.3
> 
> Please let me know if you are able to test the above patch, it should
> fix the problem with Senheisers headsets if the are not setting the
> Player Settings bits this would prevent the command to be send so it
> doesn't crash.
> 

I'll try it with Momentum True Wireless 2 tomorrow.
Andrey Semashev May 28, 2020, 12:23 a.m. UTC | #3
On 2020-05-28 01:46, Luiz Augusto von Dentz wrote:
> On Wed, May 27, 2020 at 3:43 PM Luiz Augusto von Dentz
> <luiz.dentz@gmail.com> wrote:
>>
>> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>>
>> Player Application settings is not mandatory for category 1 so instead
>> of always listing the settings the code now checks if
>> AVRCP_FEATURE_PLAYER_SETTINGS is enabled.
>> ---
>>   profiles/audio/avrcp.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
>> index 773ccdb60..75811bf98 100644
>> --- a/profiles/audio/avrcp.c
>> +++ b/profiles/audio/avrcp.c
>> @@ -3814,7 +3814,8 @@ static gboolean avrcp_get_capabilities_resp(struct avctp *conn, uint8_t code,
>>          if (!session->controller || !session->controller->player)
>>                  return FALSE;
>>
>> -       if (!(events & (1 << AVRCP_EVENT_SETTINGS_CHANGED)))
>> +       if ((session->controller->features & AVRCP_FEATURE_PLAYER_SETTINGS) &&
>> +                       !(events & (1 << AVRCP_EVENT_SETTINGS_CHANGED)))
>>                  avrcp_list_player_attributes(session);
>>
>>          if (!(events & (1 << AVRCP_EVENT_STATUS_CHANGED)))
>> --
>> 2.25.3
> 
> Please let me know if you are able to test the above patch, it should
> fix the problem with Senheisers headsets if the are not setting the
> Player Settings bits this would prevent the command to be send so it
> doesn't crash.
> 

I'll try it with Momentum True Wireless 2 tomorrow.
Andrey Semashev May 28, 2020, 2:31 p.m. UTC | #4
On 2020-05-28 03:23, Andrey Semashev wrote:
> On 2020-05-28 01:46, Luiz Augusto von Dentz wrote:
>> On Wed, May 27, 2020 at 3:43 PM Luiz Augusto von Dentz
>> <luiz.dentz@gmail.com> wrote:
>>>
>>> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>>>
>>> Player Application settings is not mandatory for category 1 so instead
>>> of always listing the settings the code now checks if
>>> AVRCP_FEATURE_PLAYER_SETTINGS is enabled.
>>> ---
>>>   profiles/audio/avrcp.c | 3 ++-
>>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
>>> index 773ccdb60..75811bf98 100644
>>> --- a/profiles/audio/avrcp.c
>>> +++ b/profiles/audio/avrcp.c
>>> @@ -3814,7 +3814,8 @@ static gboolean 
>>> avrcp_get_capabilities_resp(struct avctp *conn, uint8_t code,
>>>          if (!session->controller || !session->controller->player)
>>>                  return FALSE;
>>>
>>> -       if (!(events & (1 << AVRCP_EVENT_SETTINGS_CHANGED)))
>>> +       if ((session->controller->features & 
>>> AVRCP_FEATURE_PLAYER_SETTINGS) &&
>>> +                       !(events & (1 << AVRCP_EVENT_SETTINGS_CHANGED)))
>>>                  avrcp_list_player_attributes(session);
>>>
>>>          if (!(events & (1 << AVRCP_EVENT_STATUS_CHANGED)))
>>> -- 
>>> 2.25.3
>>
>> Please let me know if you are able to test the above patch, it should
>> fix the problem with Senheisers headsets if the are not setting the
>> Player Settings bits this would prevent the command to be send so it
>> doesn't crash.
>>
> 
> I'll try it with Momentum True Wireless 2 tomorrow.

The headset still reboots while trying to connect, although now it 
reboots after receiving AVRCP GetPlayStatus.

I'm attaching packet dumps in btsnoop and pcap formats.
diff mbox series

Patch

diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index 773ccdb60..75811bf98 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -3814,7 +3814,8 @@  static gboolean avrcp_get_capabilities_resp(struct avctp *conn, uint8_t code,
 	if (!session->controller || !session->controller->player)
 		return FALSE;
 
-	if (!(events & (1 << AVRCP_EVENT_SETTINGS_CHANGED)))
+	if ((session->controller->features & AVRCP_FEATURE_PLAYER_SETTINGS) &&
+			!(events & (1 << AVRCP_EVENT_SETTINGS_CHANGED)))
 		avrcp_list_player_attributes(session);
 
 	if (!(events & (1 << AVRCP_EVENT_STATUS_CHANGED)))