Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp3109260pxu; Mon, 19 Oct 2020 04:19:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCpUA3sATf8+J4ZRY4NNUYoV1f8kOB/hsjLQYVYHVkvC4ymTKWVVohwmwYiYH7pxySCjsE X-Received: by 2002:a50:cf0b:: with SMTP id c11mr17127650edk.87.1603106361370; Mon, 19 Oct 2020 04:19:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603106361; cv=none; d=google.com; s=arc-20160816; b=gcJKImdaPcyhRM12OyK11tYqL/K/nI+UAFoTjVvi4wX76jFSMUZbMyXzCYvRO2BDZF UjBO444xxqOUWy6yAEV3W1arzWBZpAxcIUJ0oQ79HXjlyvYStJQBosEmn0AJdLIEexvk xBdhes0aSH2BFw9+IT3Tyl64C/O1okQbyy6G7AmFbra/B8a00kzFFNZEu7/tshsIp6lc qEwTx/r8p0BM4kc3P4hjB8iYC6j2TkI7mYeM3JsNTrESlJkASCixuHwzme9lBV/8ENT/ 2F0lEI3KikOBmM9dCi50cPghM9qZa4w17Td8MtyeULp40V8AzndWQ5Tt+kRd0h6yYBur dzcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:subject:message-id:date:from:mime-version :dkim-signature; bh=eO+sfU9p3a6wYac7KK6fViGM9QTWAk8ORNW0ihu4jdA=; b=uITo7GKXlGo2JmPAPQKWHDLcuQKKdDfTyTGWBNp6W0Bk34BUT2WQFnk0tMzwCILRB7 LnANQnVImg5yrqY/z4PLAmBSVMUqbqpE3e+8NDlg78E/Uc461pPog0kZ9L2eIrnHPyo0 xzSMgiEvSjZYnj8BZFW24NoRDD1kQQ6tKFEhmoYDnmfd1UE3yNw0fn5l9d5tl9i1gfxL zzbk9vpGkFbg2MrekVScT0m2SbS2ZKoe+wec9iFbUHxZsN1nb9renZFMl3rYFX+iyzab jF2L/kOeoNHVnYScybs26V12USluU7B2jX35loJ3MUoWX/7rpAfvwfp4V15GdsrvldIE jrng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sWLmaHrB; 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 c20si9153081ejr.515.2020.10.19.04.18.45; Mon, 19 Oct 2020 04:19:21 -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=sWLmaHrB; 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 S1728792AbgJSKIi (ORCPT + 99 others); Mon, 19 Oct 2020 06:08:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728768AbgJSKIi (ORCPT ); Mon, 19 Oct 2020 06:08:38 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0C9BC0613CE for ; Mon, 19 Oct 2020 03:08:37 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id t25so13023462ejd.13 for ; Mon, 19 Oct 2020 03:08:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=eO+sfU9p3a6wYac7KK6fViGM9QTWAk8ORNW0ihu4jdA=; b=sWLmaHrBOxbdpmClMLIOhQvLSOf0UasVVLXfPMvf/UOZgJydiiESxgkYyZAounnfha DJPgQPEg8OLcUAH3Tpc6glvlyT42PjY6aWOXJ77/U0NBEzseLq9y/QtLYEmu9+fRo67Q auu7HluS/VUBeWaYIFVub5U3IaicD7b8KAptqRRSetQ7mbe2aaKFHAArSokyMC7rHg61 tONrTAV5FPsrp4qpp4gzLOuK4/2ujKUSY4L1J7vtxdbYbttyV2gbbQlM7rl27NJVO8yy 6ZFtZoIOA7D5RqOjqTKlJvhf2hFtmhxYwCIy2HduAlQ5lgc9s80aQhvcmS22r73CGBch BBfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=eO+sfU9p3a6wYac7KK6fViGM9QTWAk8ORNW0ihu4jdA=; b=XTSAKsZo29lpKyhQ3iA717QW3kW8PUgvK7whcQaNLzQnUCP2hGC6cDVwfaFT5sEA7g qoRfb8hk1QNTftNK3Edy8ZCvck2Ej7SpwYf+vOxap0KrZHFOm731oGCTR+t/Nh+0bIDf pkEIc7Q78XkbldyOgPypEv42KyasIxpEOm40Dyyd+c3A/M4lioVtQsMckyOdRhT3k9ba XQxp7GXZf8odbQDocfhBN1kdRbl9b9CfSR5TbszCdLyXE9I8aIeHFnoE0gEigEEk7LwH +WU62VqYByv8T/i05n1F6BIxmQZFoi9GRC8Q4Wg5uNbpYYvgK/XRLD7OMJ+zc5hUNY7g YRGw== X-Gm-Message-State: AOAM531/AMTSwUkU2yltIkN5leJz0OxQu3Oi8hLaAiLJVwKxAxGBcBCX AlxBxUF0oUQWA532jYWUNzxYtdKlHtU7prlJD/EFt8JQT+1h X-Received: by 2002:a17:906:6dc6:: with SMTP id j6mr17413776ejt.354.1603102115322; Mon, 19 Oct 2020 03:08:35 -0700 (PDT) MIME-Version: 1.0 From: Marek Czerski Date: Mon, 19 Oct 2020 12:08:24 +0200 Message-ID: Subject: avrcp: possible race condition during connection establishment To: linux-bluetooth@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi all, I was looking into, so called, absolute volume control that was introduced in AVRCP v1.4. What I want to achieve is to send audio from android smartphone to linux based device running bluez and make the volume control on the smartphone side to control the volume on the device. So the device is the a2dp sink + avrcp CT/TG and the phone is a2dp source + avrcp CT/TG. I assume that if all is working correctly then on the dbus the Volume property of the org.bluez.MediaTransport1 will be changed by the volume control of the phone and changes made to this property from the device would propagate to the phone volume slider. This is not happening and what I believe is the cause is that AVRCP_EVENT_VOLUME_CHANGED event registration request sent from the phone is rejected by the bluez. I can see that on the wireshark snoop from the device's bluetooth adapter. And on wireshark I see that AVRCP_EVENT_VOLUME_CHANGED event registration is sent by the phone before bluez initializes session->supported_events variable (not really sure about that). I think that this rejection makes the phone to not send SetAbsoluteVolume commands to the device on volume change. To test my theory i changed the session_init_control function in the profiles/audio/avrcp.c to call first target_init and then controller_init. This caused the AVRCP_EVENT_VOLUME_CHANGED event not been rejected and the volume control from the phone works as expected. After reading AVRCP specification I did not find any reason for the CT on the phone side not to send event registration immediately after the AVCTP connection establishment. So I believe that bluez should not reject event registration in this case. Best Regards, Marek Czerski