Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp791647pxa; Wed, 5 Aug 2020 12:53:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyuMdU4BhQSJUUQgDvbPhEMx72FwF2NdEr8IsvxWDycpM+ggmh1gxnSxzS3r7iCW1Fr7lNx X-Received: by 2002:a17:906:359b:: with SMTP id o27mr965551ejb.103.1596657187756; Wed, 05 Aug 2020 12:53:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596657187; cv=none; d=google.com; s=arc-20160816; b=mvQ/f5c5SMMPz+gGYSCztxmw6KOD18H01lSBfYe4S6QD1RyhNNeE+0wi7xTkP9arZy f4VS9vaKQMYZPwlchWBY0hQCtzGiHtyYrKLhcYtrYkOzBnZQdI4bV43q/bl5BTUrvbBb oEGbmCj1u5aw+bDscb/21AU7PVqzT9HL7bf5JsqBpbyahTwPKyfafRDxBvupQx/HwPnr LgSNhg8ffALY7UbFmuKgHQvZBUI/bx81jmci6zaS0u/1JwCXx2FSYAxAllFMGLrD8F1i CCEHzkTNyjrylnDhSVwcyt7Xiwq9AQZt9gQKEljj/nWhCtLcUiipwmux5L5V+c5AyYSt Cguw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=+uvhSulsTo3IYqkmirIw+uCMi1pBoea9+GY2Ru9yZyY=; b=tTvboZZiu/Dm95oJgPshpc6LwN+7a2payavkMjuMJmTTXVcKuacdTMhwQwOlF6zbZH TZ8ueNnVm0DEiLyZc4wpgKi/hZFdc32qIbE1Ww08pD4LmBdyL8LYpnOA5sXlYOETPXC3 qn0j1ADr3/F3eUmmRJd2u4+nxjQFmPX1MLEyRoNiWpFgsTJ4FDNMoxLBLvVevarAYzYl dTvG7Vlm/oVzm13/SifutImzPN9F/iD5CDcQFyc50c89QE0l1fJKkcA2TCrtzmu2mY65 cp2M1DcPcL8948tLy8F1gZhhJ77qViCppCzojVvKzWNAcSCVGXS5aX3CusnIj3NCP2kO NxhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=o44XPh0h; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g22si1882738ejd.159.2020.08.05.12.52.28; Wed, 05 Aug 2020 12:53:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=o44XPh0h; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728127AbgHETvM (ORCPT + 99 others); Wed, 5 Aug 2020 15:51:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728244AbgHETuw (ORCPT ); Wed, 5 Aug 2020 15:50:52 -0400 Received: from mail-oi1-x241.google.com (mail-oi1-x241.google.com [IPv6:2607:f8b0:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02D8EC061575 for ; Wed, 5 Aug 2020 12:50:52 -0700 (PDT) Received: by mail-oi1-x241.google.com with SMTP id e6so20473090oii.4 for ; Wed, 05 Aug 2020 12:50:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+uvhSulsTo3IYqkmirIw+uCMi1pBoea9+GY2Ru9yZyY=; b=o44XPh0hnxv6lw/4AMZHgdfmf/+lWcU04OKR3IjWzINiSv5taRh+U6neT/ONZz06rJ 0DL+4vvgGOERkOYfAaokmDH70dpTm0uRANPyh+ZlOLNoIgn8/WquQ8RtmYkFB9F/1Yff EyFUGY9EcOoYaC0NJzRMzg9lxCHkOQ+P2TUCdZFXaKX08L1Uai3wZtxmjQ70pu6TP3hO dWAIGBQjnX21mfQISf9Es7yqCKGRUBv3+cyGOruzrRSTjbY3weCnKlIXeGyFHHk4q4NM heosTO6q/L8I2B6yMazu1M+rhHATol5t9N/WguRMPUM4ymSpBaIwW6YQmKDP25r2F7EA XBOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+uvhSulsTo3IYqkmirIw+uCMi1pBoea9+GY2Ru9yZyY=; b=KQCv+PrKyiRW3DTTMj8AWqh39gI3IT7QeOcCfUiqFB6xFZiwzEoi9hdfeMTRk1H6F1 99XB+vK6BvNttBxXXVmF7wFUIQ9ilgr/mRgpJFwPgPvdZZ4bN4Vb80A3NjPZ4nKyB1VV aFPABDd/5CivqRD09At2/9An39dFOoDN/4CQyHvqROVGKfNYa8UhnvWeQZ0pnYBZibY+ 2AiqGXzdGUNLRZI4QRVs4btQp5v2WtccXsbQM1kShStmdI+qdKsYlXSxenr+G08fmmB4 ZAXCD5CpIY2xShcYUVtO3lAEnDjvpeb5Ta23BwYW8taUWzVgXVB281tQyDE9hrCgnxwH UNdA== X-Gm-Message-State: AOAM531wsvuWE8Gpjs532dAGUI125wsgdn6nhtFoEI5FIURyCcnfGR9w tWKAGGtn0KPJPu7rZ0w+0KfRKrtAyH98J+2Y+H0= X-Received: by 2002:aca:cc50:: with SMTP id c77mr3948006oig.152.1596657051339; Wed, 05 Aug 2020 12:50:51 -0700 (PDT) MIME-Version: 1.0 References: <20200805100342.bluez.v3.1.I6076fdf5621a5ce59b7307967a8c997638c1d1c8@changeid> In-Reply-To: <20200805100342.bluez.v3.1.I6076fdf5621a5ce59b7307967a8c997638c1d1c8@changeid> From: Luiz Augusto von Dentz Date: Wed, 5 Aug 2020 12:50:41 -0700 Message-ID: Subject: Re: [bluez PATCH v3] avrcp: include all player settings in notif event To: Howard Chung Cc: "linux-bluetooth@vger.kernel.org" , Archie Pusaka Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Howard, On Tue, Aug 4, 2020 at 7:06 PM Howard Chung wrote: > > According to AVRCP 1.6.2 spec section 6.7.2 table 6.39, all player > application settings should be returned to the CT and let CT to > determine which settings have changed. Currently bluez only returns > the changed attribute instead. This patch also addresses a potential > issue on which the number of application settings mismatches with > the actual number returned. > > Reviewed-by: Archie Pusaka > --- > > Changes in v3: > - Rebase to master > > Changes in v2: > - Fixed unused variables > > profiles/audio/avrcp.c | 71 +++++++++++++++++++----------------------- > 1 file changed, 32 insertions(+), 39 deletions(-) > > diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c > index 4e7ff75c0..5d0256c52 100644 > --- a/profiles/audio/avrcp.c > +++ b/profiles/audio/avrcp.c > @@ -370,6 +370,7 @@ static uint32_t company_ids[] = { > }; > > static void avrcp_register_notification(struct avrcp *session, uint8_t event); > +static GList *player_list_settings(struct avrcp_player *player); > > static sdp_record_t *avrcp_ct_record(void) > { > @@ -744,6 +745,35 @@ static int play_status_to_val(const char *status) > return -EINVAL; > } > > +static uint16_t player_settings_changed(struct avrcp_player *player, > + struct avrcp_header *pdu) > +{ > + GList *settings = player_list_settings(player); > + int size = 2; > + > + for (; settings; settings = settings->next) { > + const char *key = settings->data; > + int attr; > + int val; > + > + attr = attr_to_val(key); > + if (attr < 0) > + continue; > + > + val = player_get_setting(player, attr); > + if (val < 0) > + continue; > + > + pdu->params[size++] = attr; > + pdu->params[size++] = val; > + } > + > + g_list_free(settings); > + > + pdu->params[1] = (size - 2) >> 1; > + return size; > +} > + > void avrcp_player_event(struct avrcp_player *player, uint8_t id, > const void *data) > { > @@ -752,8 +782,6 @@ void avrcp_player_event(struct avrcp_player *player, uint8_t id, > uint8_t code; > uint16_t size; > GSList *l; > - int attr; > - int val; > > if (player->sessions == NULL) > return; > @@ -792,19 +820,7 @@ void avrcp_player_event(struct avrcp_player *player, uint8_t id, > size = 1; > break; > case AVRCP_EVENT_SETTINGS_CHANGED: > - size = 2; > - pdu->params[1] = 1; > - > - attr = attr_to_val(data); > - if (attr < 0) > - return; > - > - val = player_get_setting(player, attr); > - if (val < 0) > - return; > - > - pdu->params[size++] = attr; > - pdu->params[size++] = val; > + size = player_settings_changed(player, pdu); > break; > case AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED: > size = 5; > @@ -1597,7 +1613,6 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session, > uint16_t len = ntohs(pdu->params_len); > uint64_t uid; > int8_t volume; > - GList *settings; > > /* > * 1 byte for EventID, 4 bytes for Playback interval but the latest > @@ -1628,29 +1643,7 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session, > len = 1; > break; > case AVRCP_EVENT_SETTINGS_CHANGED: > - len = 1; > - settings = player_list_settings(player); > - > - pdu->params[len++] = g_list_length(settings); > - for (; settings; settings = settings->next) { > - const char *key = settings->data; > - int attr; > - int val; > - > - attr = attr_to_val(key); > - if (attr < 0) > - continue; > - > - val = player_get_setting(player, attr); > - if (val < 0) > - continue; > - > - pdu->params[len++] = attr; > - pdu->params[len++] = val; > - } > - > - g_list_free(settings); > - > + len = player_settings_changed(player, pdu); > break; > case AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED: > len = 5; > -- > 2.28.0.163.g6104cc2f0b6-goog Applied, thanks. -- Luiz Augusto von Dentz