linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sonny Sasaka <sonnysasaka@chromium.org>
To: Marijn Suijten <marijn.suijten@somainline.org>
Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
	"linux-bluetooth@vger.kernel.org"
	<linux-bluetooth@vger.kernel.org>
Subject: Re: [PATCH BlueZ] Queue SetAbsoluteVolume if there is an in-progress one.
Date: Tue, 8 Jun 2021 11:37:10 -0700	[thread overview]
Message-ID: <CAO271mkpy5W0KB60X5G1mwp92bB+K2Ru3ODP8K2APCkjfkX70w@mail.gmail.com> (raw)
In-Reply-To: <f3e18adc-b1ad-2ab5-164e-43a1ae20f708@somainline.org>

Hi Marijn,

Thanks for your inputs. Having a separate SetAbsoluteVolume API that
blocks (until the peer acknowledges the change) is certainly more
featureful than this patch's approach, since the media player can
decide what to do with pending SetAbsoluteVolume calls and have the
flexibility to handle the situation. However, there is also a value in
the shorter term approach that this patch without any changes in the
media player part and has been tested to solve the janky slider issue
in Chrome OS. I believe that this would also solve PulseAudio's
similar janky slider issue for the short term.

If Marijn and Luiz are okay with the shorter term approach first, I
will continue updating this patch according to Luiz's comments, but
otherwise I will abandon this patch in favor of the separate
SetAbsoluteVolume API that Marijn will provide.

On Tue, Jun 8, 2021 at 2:50 AM Marijn Suijten
<marijn.suijten@somainline.org> wrote:
>
> Hi Luiz,
>
> On 6/8/21 1:47 AM, Luiz Augusto von Dentz wrote:
> > Hi Marijn,
> >
> [..]
> >> We've been running into a similar issue with PulseAudio.  There is no
> >> way to track a Set call for the Volume property back to the
> >> property-change notification, running into both jitter on quick
> >> successive volume changes and the inability to reflect peer hardware
> >> volume in case the peer rounds the requested volume to a coarser scale.
> >>    This rounded value is supposedly returned from SetAbsoluteVolume
> >> according to AVRCP spec 1.6.2, section 6.13.2:
> >>
> >>      The volume level which has actually been set on the TG is returned in
> >>      the response.
> >>
> >> I would have proposed a new DBUS function SetAbsoluteVolume that accepts
> >> volume as sole argument, blocks until the peer replies, and returns the
> >> actual volume as per its namesake AVRCP command.  This should address
> >> both issues.
> >>
> >> Note that it is also impossible to distinguish Volume property changes
> >> from an action invoked on the peer (ie. the user pressing physical
> >> buttons or using a volume slider on headphones) or the result of an
> >> earlier Set(Volume) call as these to my knowledge all happen async, may
> >> be intertwined, may involve rounding (on the peer) to make the resulting
> >> number different, etc.
> >
> > Yep, the volume may actually be rounded like you said, so Im not
> > really sure how we can queue because we will not be able to verify the
> > volume has been set properly, we could do a blocking call even in case
> > of setting as a property we only need to delay the call to
> > g_dbus_pending_property_success until we actually receive a response,
> > that said there maybe some impact on the user experience since if you
> > have the volume implemented with something like a slider it will not
> > move smoothly anymore, but I guess that is better than have it
> > flipping back and forth, well except that can still happens because
> > the volume can be changed on the device in the meantime but I guess
> > the client wont see those changes until the method returns if it is
> > blocking waiting for the reply, which means it will only see that the
> > value flipped to something else later when the signals are dispatched.
>
>
> The main use-case is software volume compensation for devices with
> limited granularity, for which we need to know exactly what is replied
> to AVRCP's SetAbsoluteVolume call.  Delaying
> g_dbus_pending_property_success will only block the call longer but
> won't exactly let us know the resulting value.  We can immediately Get
> the new property after (or try and relate the change notification to
> it), but there's nothing preventing a change on the device intervening.
>   In that case we should discard requested volume (on the host) and
> software compensation, and take/display device volume as-is.
> This seems unfortunate as the AVRCP spec provides exactly the
> consistency we're looking for here.
>
> As for user experience it seems acceptable to make such a call block
> until the peer replies, if only for a much more predictable API.  It is
> then up to the caller (ie. PulseAudio) to deal with that by
> disabling/blocking the slider, or scheduling the most recent volume
> update to be sent as soon as a reply is received (the DBus call returns).
>
> >
> > If you feel like that is acceptable I'm happy to review any patches in
> > that direction.
> >
>
> [..]
>
> > --
> > Luiz Augusto von Dentz
> - Marijn

  reply	other threads:[~2021-06-08 18:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-07 18:46 [PATCH BlueZ] Queue SetAbsoluteVolume if there is an in-progress one Sonny Sasaka
2021-06-07 20:15 ` [BlueZ] " bluez.test.bot
2021-06-07 21:16 ` [PATCH BlueZ] " Luiz Augusto von Dentz
2021-06-07 22:46   ` Marijn Suijten
2021-06-07 23:47     ` Luiz Augusto von Dentz
2021-06-08  9:50       ` Marijn Suijten
2021-06-08 18:37         ` Sonny Sasaka [this message]
2021-08-08 10:15           ` Marijn Suijten
2021-08-09 17:46             ` Sonny Sasaka
2021-08-09 20:31               ` Marijn Suijten
2021-08-09 20:49                 ` Sonny Sasaka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAO271mkpy5W0KB60X5G1mwp92bB+K2Ru3ODP8K2APCkjfkX70w@mail.gmail.com \
    --to=sonnysasaka@chromium.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=marijn.suijten@somainline.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).