Skip to content

fixed: claiming the active source on routing changes that don't select us - #768

Open
phycoforce wants to merge 2 commits into
Pulse-Eight:masterfrom
phycoforce:fix-routing-change-active-source
Open

phycoforce wants to merge 2 commits into
Pulse-Eight:masterfrom
phycoforce:fix-routing-change-active-source

Conversation

@phycoforce

Copy link
Copy Markdown

Fixes #767.

Two small changes to the generic routing-change handling, no vendor handlers touched:

  1. CCECBusDevice::SetActiveRoute() runs on the device that sent the routing change, but tested ActiveSourceSent() on that device instead of on newRoute. The flag is only set on devices libCEC transmits for, so the test was always true and libCEC re-announced on every routing change to its address, even while it was already the active source and had said so. It now tests newRoute->ActiveSourceSent(), which reads as the original intent: announce if we haven't since the TV's last power change (ResetActiveSourceSent()), or if we aren't the active source.
  2. CCECCommandHandler::HandleRoutingChange() skips SetActiveRoute() when the original and new address are equal, and logs it at debug level. Such a routing change reports no change of route, so it doesn't mean this device was selected. The sender is still marked as powered on, which the Philips handler relies on for the TV's 0.0.0.0 -> 0.0.0.0 at power-up (its override runs first and is unchanged).

<Set Stream Path>, <Routing Information> and activation at startup are unchanged.

Tested

On real hardware: LibreELEC, Kodi 22.0-RC1, Pulse-Eight USB-CEC (firmware 12); LG OLED (2026) -> Samsung HW-Q930F on eARC (2.0.0.0) -> Kodi (2.1.0.0); Nintendo Switch 2 on another TV input (3.0.0.0). 8.1.7 with these two commits (master has no other code changes since 8.1.7), loaded into Kodi, CEC debug log on.

  • Console wakes the TV while the TV was last on Kodi's input (the case in libCEC claims active source on a <Routing Change> that changes nothing, taking the TV away from another source (AVR/soundbar setups) #767), 2 runs: libCEC sent no <Active Source>, the soundbar's no-op routing changes were logged as ignored (1 and 2 of them), and the TV was on the console after about 2 s both times. Stock 8.1.7: 24 and 12 <Active Source>, and the TV ended on Kodi.
  • Normal power-on with Kodi's input selected: TV on Kodi; libCEC answered both <Set Stream Path> and ignored 5 no-op routing changes. Stock: 6 to 8 <Active Source> per power-on.
  • TV remote, from the console back to Kodi: libCEC activated on the TV's 0f:80:30:00:21:00 and answered <Set Stream Path>, as before.
  • TV remote, away to an empty input and back: the LG claims <Active Source> itself on the empty input, so this took the same path as above; picture and audio were back at once.
  • Kodi starts while the TV is on another input: one <Active Source> at startup. The TV then routed to Kodi (0f:80:30:00:21:00), and libCEC didn't repeat itself (change 1). It also ignored the soundbar's 5f:80:21:00:21:00 (change 2). TV and soundbar both switched to Kodi.

Console wake with this change (source, routing and system audio messages only; libCEC sent no <Image View On> or <Active Source> for the rest of the minute):

13:14:43.702 >> 40:04                 console: image view on
13:14:44.171 >> 4f:82:30:00           console: active source 3.0.0.0
             marking Recorder 1 (1) as inactive source
13:14:44.861 >> 05:70:00:00
13:14:44.964 >> 05:70:21:00
13:14:45.778 >> 0f:80:21:00:30:00     TV: routing change 2.1.0.0 -> 3.0.0.0
13:14:47.709 >> 5f:80:21:00:21:00     audio system: no-op routing change
             >> Audio (5) routing change to the same address (2100), ignored
13:14:48.594 >> 0f:86:30:00           TV: set stream path 3.0.0.0

Not covered: TVs from other vendors, and a device that sends a same-address routing change when the user re-selects the input that is already showing. libCEC would no longer re-announce there, but the TV is already on that input.

Full debug logs for every run, stock and with this change: https://gist.github.com/phycoforce/d2cb9afbacb3ce9d02af8dc72361ca68

SetActiveRoute() runs on the device that sent the <Routing Change> or
<Routing Information>, but it called ActiveSourceSent() on that device
instead of on the libCEC device the route leads to. The flag is only
set for devices libCEC transmits <Active Source> for, so the test was
always true and libCEC re-sent <Image View On> + <Active Source> on
every routing change to its address, even while it was the active
source and had already announced it.
…address

A <Routing Change> whose original and new address are equal reports no
change of route, so it does not mean that this device was selected. A
Samsung HW-Q930F soundbar broadcasts one (5f:80:21:00:21:00) each time
it settles its HDMI input while the TV powers on, and libCEC answered
each with <Image View On> + <Active Source>. When another source had
just woken the TV, this pulled the TV back to libCEC's input until the
other source gave up.

The sender is still marked as powered on, which the Philips handler
relies on for the TV's 0.0.0.0 -> 0.0.0.0 routing change at power-up.

This branch has not been deployed

No deployments
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.

libCEC claims active source on a <Routing Change> that changes nothing, taking the TV away from another source (AVR/soundbar setups)

1 participant