Skip to content

Duck the Sendspin stream while Alexa holds audio focus - #106

Merged
bboe merged 1 commit into
bboe:mainfrom
alitheg:alexa-focus-ducking
Oct 9, 2026
Merged

bboe merged 1 commit into
bboe:mainfrom
alitheg:alexa-focus-ducking

Conversation

@alitheg

@alitheg alitheg commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Alexa takes audio focus as GAIN_TRANSIENT_MAY_DUCK while she listens and answers, but Android 5.1 doesn't duck anything itself, and the player holds no focus, so the music carried on at full level over her.

alexa.FocusWatcher follows logcat -s MediaFocusControl and keeps the set of clients holding focus, since her requests overlap: one question moved focus through 3 clients over 10 seconds. A may-duck holder takes the stream to 20%, a transient or exclusive one to 10%, the same levels sendspinlite uses on an Echo Show. A permanent gain doesn't duck. Each holder expires after 15 minutes, and the set is cleared whenever logcat exits, so it fails towards full level.

Chime.Duck sets a gain the stream applies to its own samples after placement, ramping down in 40 ms and back up in 240 ms, so timing and sync are untouched. At full gain the samples aren't touched at all.

The two watchers now share one logcat loop, and its children are started with Pdeathsig: a restart used to leave each watcher's logcat running under init.

Verified on a Dot by ear across a "what time is it" with overlapping holders. docs/audio.md has the log format and the numbers.

Happy to adapt, etc, or if you don't want to integrate it I'll just keep using my fork 😄

@bboe

bboe commented Oct 9, 2026

Copy link
Copy Markdown
Owner

Hi! Thanks for the PR. I just saw this, so I'll try to take a look at it before the weekend.

Alexa takes audio focus as GAIN_TRANSIENT_MAY_DUCK while she listens and
answers, but Android 5.1 doesn't duck anything itself, and the player holds
no focus, so the music carried on at full level over her.

alexa.FocusWatcher follows logcat -s MediaFocusControl and keeps the set of
clients holding focus, since her requests overlap: one question moved focus
through 3 clients over 10 seconds. A may-duck holder takes the stream to 20%,
a transient or exclusive one to 10%, the same levels sendspinlite uses on an
Echo Show. A permanent gain doesn't duck. Each holder expires after 15
minutes, and the set is cleared whenever logcat exits, so it fails toward
full level.

Chime.Duck sets a gain the stream applies to its own samples after placement,
ramping down in 40 ms and back up in 240 ms, so timing and sync are
untouched. At full gain the samples aren't touched at all.

The two watchers now share one logcat loop, and its children are started
with Pdeathsig: a restart used to leave each watcher's logcat running under
init.

An expired hold says so in the log, because nothing else shows a duck: it
is a gain on the samples, so dumpsys and the volume sensors read unchanged.

Verified on a Dot by ear across a "what time is it" with overlapping
holders. docs/audio.md has the log format and the numbers.
@bboe
bboe force-pushed the alexa-focus-ducking branch from 8352503 to aee302d Compare October 9, 2026 01:09
@bboe
bboe merged commit aee302d into bboe:main Oct 9, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants