Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp138421pxa; Tue, 4 Aug 2020 19:09:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwSY/qwijuSYLfd1axCBUvq21LHFCrnPjxyf4ghu9NWzs4AkCaNkPkoSbKUITEj6f7fuYR X-Received: by 2002:a17:906:3b8d:: with SMTP id u13mr972352ejf.383.1596593387775; Tue, 04 Aug 2020 19:09:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596593387; cv=none; d=google.com; s=arc-20160816; b=c6i9/kT4+DjsLoTIlJG/mFyJJZGOm6kBRtiCvio/xdhCDm/AGatrd+ewSY+kBJwhhX pgFsjBOxfOvKxSsTK9wUGDPgLpPaGLU2F03M9g7IKYAfhNaEEM2sfCI0HHhsPIjMe8Uq myWdA9LhhagQJ39hrct2z/OTFLXoBsbJD1XSGwS+DPqLtkPMWw1If1VKr4A/nh+cPhjs kj6lHAROBKMtlM8G0XmHGW23Kp7TUM5DKkc3X9wysVhe7D5GNRg+X8UFrQiZY8MFewYl +XyB7mdtd8PESzfpvceHUMA8xGFjhfNL+lMI06PKSeFBnVhWzKWDeiOtfu04A06LLVTi Uyhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:mime-version :message-id:date:dkim-signature; bh=OVuwt5e+xgXyzQNIFWeSxNVaCjdVa8/8Q/IXl45czd0=; b=wedub9EsjMGQKSXflW899PzqSdvCAxufEQW33JA9Jjl84R+0/gKLJsUcbeOdEAwkxu iBbHzTOxoIFw2Lt59PxA2Tvf9tUN8VVTWyeiPzUMCwIzSA2K9BoXM+rGhFb6iokerfTU h9AmD9ZsBLTTFWJejuhBV/P43leCUcU79AbPqmRI4A922Fx8IEflhk/8sJVA+bvXTWVb VvDLf5UvhxivJUXP8bdQT+6KX9VUHfiipSg14UQ+u/QdMqO1GMRHzUxtzjE8Q7wriZHv JHpCDkZhZRpsbTyMgREay/xWxKtfJadv7vy1ZSArWFBAyd7u2yxYRGSOQKaTXMSF6btz e9DQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="dbvpIYt/"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id se5si329339ejb.744.2020.08.04.19.09.01; Tue, 04 Aug 2020 19:09:47 -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=@google.com header.s=20161025 header.b="dbvpIYt/"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726841AbgHECGL (ORCPT + 99 others); Tue, 4 Aug 2020 22:06:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725864AbgHECGL (ORCPT ); Tue, 4 Aug 2020 22:06:11 -0400 Received: from mail-qt1-x84a.google.com (mail-qt1-x84a.google.com [IPv6:2607:f8b0:4864:20::84a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA53FC06174A for ; Tue, 4 Aug 2020 19:06:10 -0700 (PDT) Received: by mail-qt1-x84a.google.com with SMTP id z20so6482755qti.21 for ; Tue, 04 Aug 2020 19:06:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=OVuwt5e+xgXyzQNIFWeSxNVaCjdVa8/8Q/IXl45czd0=; b=dbvpIYt/WRicOqkDi68hfUiragxidL6czwd73bk3nvyY0rOh+cWD+TFos8g9FxeyXh U1tggJt7LZgD+4Ng934Gv/rd6PAGlwADBnlALJ5pR5Yafb3BpRp/zxz6vFtvexnGvqfv uPeK48kXWczEVEkxaVeA4sU6Bs/ytiO34j2vx6Ntpq2rvP76XPWqCTYZNfRY6D6gNz7n jwdDCIeW5PwbJiyxMRP7naX0TSgYEs0GRVoXFWmymVmQt/AikjcRXBSTBxC5PohBoZNR ONWrPfczQvP3atMQF3kkbR39hDlSCpoVEnjeV1FxaNQFbMci+2rbaeK0GEcjpELCaeG9 fXNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=OVuwt5e+xgXyzQNIFWeSxNVaCjdVa8/8Q/IXl45czd0=; b=J/t9ThCoa4GCb28Ydt/LpQadKpr9LD6gDNx/frqDevYNyOp+K5YT2DyE/oW5JCsf59 YuBQWK2ibHxyDj/U/LO6aiuiarYXM1Nl4ecnS/J2uLTn/xNA6FJWWUC63PKETQvN6med C1EXseKguW10RfsSH+tgQTJwo1EJvI9A6GpiWi8TvpDLTeCLtaQgUbunuSa77DJ03f+N AhWaBuFiMOxx317e4yJISuF3Ny+tVajfNmdYV8j9otpRxqnExYgeetTjoYG42BxIOlso IOKf6iDPDt7OxIhsERW/AEN/tRHrBAORj9/Vx1SMYqBiE3RyLEgbfcjepjPJWqkjOBr2 +f6w== X-Gm-Message-State: AOAM531lWNA1Bqu37ywIDXsYkJyNJECpFNR7ezP9qcvAvvUSiMGm/xQP vPxzOqaHSzd2+5HrVynuTBkTT7Wn8wiceHoBPRPbIyu7FL3rGgmaPHB0CUdhfeDqvm/EBiB1dVM AdVekRuw334HDNgoxxJp0DGxIEW5b4QstVlsZd6NL33xUQd3qxjdlYTa/VaBMYT74XALXSmZ66Y v91ceIoY/65uI= X-Received: by 2002:a05:6214:4e1:: with SMTP id cl1mr1325762qvb.147.1596593169940; Tue, 04 Aug 2020 19:06:09 -0700 (PDT) Date: Wed, 5 Aug 2020 10:05:36 +0800 Message-Id: <20200805100342.bluez.v3.1.I6076fdf5621a5ce59b7307967a8c997638c1d1c8@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog Subject: [bluez PATCH v3] avrcp: include all player settings in notif event From: Howard Chung To: linux-bluetooth@vger.kernel.org Cc: luiz.dentz@gmail.com, Howard Chung , 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 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