Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp203751ybt; Tue, 7 Jul 2020 20:34:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkND5wePRB/eQqMS15jcsauiQ5QO50aSo0PTqpIN0BMqAcTMWh9PpQFDHUggPedGaGNWFK X-Received: by 2002:a17:906:1e83:: with SMTP id e3mr35417219ejj.7.1594179284814; Tue, 07 Jul 2020 20:34:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594179284; cv=none; d=google.com; s=arc-20160816; b=A5sX+McC3F2ReSLK/l4QA3gUEgGDvN3fnu7jdWYUJeoeHasF3IBNUO4QBPgikH/GSD MjqF/bbiKsXNkdGC2sEAQOnQLUv3ipOtSInlxDg5NaIUSDaKw8nHc73nUPcNhMs2cGKb DRL9iF6t8SyUTy+q686Syq5QUvvY3RCklS2XcRXcWX2Fn6RLZNL88JBk171FJScI1PbR BETp5f8QYWZN++GrlR0jZl/ujeab6GwuNAJTCKx6PB0HBEH4ITTfhlqgYHdre9JbiEwv oZAeXQy9A976bHtmFn9ydXaldEcipS7mqlgSf6URws/OQobM3Nc6pwVd0tmAw9qYpDwu ApoA== 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=odnQeCCDeJlo4axhRc7XyOZpCom8cJ2ILuCEO99s6zs=; b=OniQjCMwFb+LTU1dcd0uy305wMgZb7PXsqkOJRWkUUPKVMtRkORPo7BbnRfhyX1/gG eSwoBtPeDRSH0pWzfZxKfoiJryzenIWFzOXwNx9Sk3f7PcYVMxSgaBKtC+MCJYy8iz2D +KINj3cYEMBMCHuMLFjnmU1j128qNeMzpbr06jBcNcAzzbOQIjOEqdQXd3Vf+7T3TKJK nIZV/36UgOY/xwmmuywQuMIEJuGTlip9DRK348+JLrHVNXMrnjkaqBOmUTfVqYFMf+WZ Au0EF9GVr4Qbhsqu4y1qDGqn5FQInt85yssNSQbAnsaOxC2WxV37gHiTED/qaIiJM3Cw rI5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=dAP0WOMW; 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 a19si11319284eje.150.2020.07.07.20.33.57; Tue, 07 Jul 2020 20:34:44 -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=dAP0WOMW; 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 S1729095AbgGHDcp (ORCPT + 99 others); Tue, 7 Jul 2020 23:32:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727090AbgGHDcp (ORCPT ); Tue, 7 Jul 2020 23:32:45 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C05AC061755 for ; Tue, 7 Jul 2020 20:32:45 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id y3so50233143ybf.4 for ; Tue, 07 Jul 2020 20:32:45 -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=odnQeCCDeJlo4axhRc7XyOZpCom8cJ2ILuCEO99s6zs=; b=dAP0WOMWjSVSsL757K4+s7n5xeRs51KtF4+KBxJSwGYcJlVgT9BAYzSCVGaUdpi5uK ydksM3Dg7zrYypgOEDuC3BynbfQjTOLcYb4eNwg7kO2n6dbyTGQ9CpIIHuRiVs3ad+Uz CQvxAVh8KSqEvFAcs7w9TGxm/Xqc6A4ruLhU65KwGT/6uxLolCpXpuHYYcUBTjnwcyPe m+6noJLuLHnL4nIU+pxTky14zKoPZQtE4fzdnywRIbDvum3mIwTtyfq4E2H1lIa383V+ L418tai7NfHpzgwRgbUFbV4iN+3WbYoGCtaGltKxOBmaSZB+GXHhVLPCq04lZHmGMe+t 7rBA== 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=odnQeCCDeJlo4axhRc7XyOZpCom8cJ2ILuCEO99s6zs=; b=t0QYXKD/49BhxBhP/eADIPj1LYn5bqsU7ZgiouDNWN0r8Ya0QU9ZIqxBhcOiDCq2ya 0USrtXAdr7iZaDG4AL+jEzfxytmgZ5ss7Yrbax2VXmL+QnWhJozUfSEGAwYIL80njMUF n03r1vlrd7F2dcTS4EAFmVIrfijkE+k9qXL6QYWxmmCKrgYq/Srqr0PqiJ9tj+Fvvedy ul6FlxUej3ArRZbWjRyoCDoE/V4xBDUT4nYGz4l0TxHrAnchKMLUEJneULGXlkEY/PcJ t561VJcbzDCkIu9ItoxmrV6h1JMGChpHO4f3M1r6c2cOw89U3ZHmYvsP1Tc0zGSHmD4y SC/g== X-Gm-Message-State: AOAM533V+hx9Yuac9i8wf4hq3wlDJR80wdlD2miLp7NmmoJng2ciaTJy A67JQoz9SxUf6jWTLhhM+MoRk9O2sTDGEjICNRaw4+atxl+dk0SNccBPkCGAldgK6KjdYlt4KJo tMYy+YReru+spq8gXZ5QaHIGU6/WLXOgw3hBfcQZGGIchql6jsxc8uznDgxHhcF4MNwMVpKZqeY eFOLfE+rL6YOE= X-Received: by 2002:a25:3342:: with SMTP id z63mr87459609ybz.200.1594179164413; Tue, 07 Jul 2020 20:32:44 -0700 (PDT) Date: Wed, 8 Jul 2020 11:32:23 +0800 Message-Id: <20200708113139.bluez.v1.1.I6076fdf5621a5ce59b7307967a8c997638c1d1c8@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.27.0.383.g050319c2ae-goog Subject: [bluez PATCH v1] 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 --- profiles/audio/avrcp.c | 69 ++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 36 deletions(-) diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c index e2428250e..da0c7c9da 100644 --- a/profiles/audio/avrcp.c +++ b/profiles/audio/avrcp.c @@ -369,6 +369,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) { @@ -743,6 +744,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) { @@ -751,6 +781,7 @@ void avrcp_player_event(struct avrcp_player *player, uint8_t id, uint8_t code; uint16_t size; GSList *l; + GList *settings; int attr; int val; @@ -791,19 +822,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; @@ -1626,29 +1645,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.27.0.383.g050319c2ae-goog