Repository navigation
android: keep the connection while phone as speaker is playing - #39
Conversation
Signed-off-by: abinanthan-cg <dabinanthan@gmail.com>
Include recent valid PC speaker frames in the existing busy state, so Run in the background OFF waits for this supported activity to finish. Adapted from upstream PR thtbee#39 commit f890fcc. Preserves the existing PCM validation, lifecycle preference and route gates. Signed-off-by: abinanthan-cg <dabinanthan@gmail.com>
|
PR is working nicely. I patched onto my Linux stacked branches and created smoke test apps, and it's a welcomed change. Cheers |
thtbee
left a comment
There was a problem hiding this comment.
Thanks for picking this up, and for the tests on ActivityWindow.
One thing before merging. The PC stops sending frames about 500 ms after the sound goes quiet (pc_audio_stream.rs, the silence tail), so the 3 s window only covers audio that's actually playing. With "Run in the background" off, pausing a song for more than about 8 s (3 s window plus the 5 s stop delay) stops the core, and pressing play on the PC no longer reaches the phone. That's the case people will hit most: pause, read something, play again.
The phone already has a steadier signal. While "Phone as speaker" is on at the PC, its deck.state lists an output with the id nectarlink:phone_speaker (desktop/app/src/deck.rs, sample_live_state), and that lands in each device's deckState.outputDevices in CoreState. Could busy count that too, for any connected PC? Something like:
state.map { s -> s.devices.any { d -> d.deckState?.outputDevices?.any { it.id == "nectarlink:phone_speaker" } == true } }
.distinctUntilChanged()Then the frame window can stay as a backup for the gap before the first deck.state arrives. A test for the new flow (relay on keeps it busy with no frames, relay off lets it go) would be good too.
The watchdog thread looks right to me, including the restart in finally when frames arrive while it's exiting.
The PC stops sending audio about 500 ms into silence, so a paused song let the frame window run out and, with "Run in the background" off, the core stopped and Play on the PC no longer reached the phone. Busy now also counts a connected PC whose deck state lists the phone as an output; the frame window covers the moment before the first deck state arrives.
|
Thanks again for this, Abinanthan. To get it into the next release I added the change from my review myself (a696a48): |
thtbee
left a comment
There was a problem hiding this comment.
Thanks Abinanthan. Approving with the relay check added; CI is green.
|
thanks @thtbee for merging |
Follow-up to #22, the phone as speaker case thtbee mentioned in the review.
With "Run in the background" off, the core stopped about 5 s after leaving the app even while PC audio was playing on the phone, because it wasn't part of
busy.What changed
playingflow that is true while audio frames arrived in the last 3 s. playFrame only does a timestamp write and flips the flow when it was false, no timer or allocation per frameplayingas a fifth input, so the existing 5 s delay + 2 s debounce wait for the audio to endTested on Oppo, Android 11, setting off
Gradle tests, lint and header check pass.