Skip to content

libcec: fix HDMI input grab-back on routing change to external device#52

Open
samtheruby wants to merge 1 commit into
pannal:coreelec-21_localfrom
samtheruby:libcec-routing-fix
Open

libcec: fix HDMI input grab-back on routing change to external device#52
samtheruby wants to merge 1 commit into
pannal:coreelec-21_localfrom
samtheruby:libcec-routing-fix

Conversation

@samtheruby
Copy link
Copy Markdown
Contributor

@samtheruby samtheruby commented May 15, 2026

Summary

Adds packages/mediacenter/libcec/patches/libcec-001-fix-active-source-on-routing-change.patch. It patches SetActiveRoute() and HandleSetStreamPath() in libcec to call MarkAsInactiveSource() on all libCEC-controlled devices when CEC routing changes to a known external device (one not handled by libCEC).

Bug fixed

Without this fix, m_bActiveSource stays true after the user switches HDMI input away via the TV remote. ~30 seconds later the TV broadcasts REQUEST_ACTIVE_SOURCE and libCEC responds, causing the box to steal the HDMI input back — a user-visible long-standing regression where you switch to a game console / streaming stick / etc. and the box yanks focus back unprompted.

Test plan

  • Confirm make image builds libcec without patch warnings or failures.
  • On a real device: open Kodi, then use the TV remote to switch input to another HDMI source (e.g. a game console). Wait > 30 seconds. Confirm the Amlogic box does NOT yank focus back.
  • Switch back to the Amlogic box from the TV remote — confirm normal route-change behaviour still works.
  • Regression: confirm Kodi can still take active source on user request (CEC "active source" command, playback start, etc.).

Patches SetActiveRoute() and HandleSetStreamPath() to call
MarkAsInactiveSource() on all libCEC-controlled devices when CEC routing
changes to a known external device (one not handled by libCEC).

Without this fix, m_bActiveSource stays true after the user switches
input away via the TV remote. When the TV broadcasts
REQUEST_ACTIVE_SOURCE ~30 seconds later, libCEC responds and steals the
HDMI input back — a long-standing user-visible regression where the box
yanks focus from whatever the user just switched to.

The patch file landed in two follow-up fixes for the patch format
itself (formerly separate commits, now squashed):
- Fix a malformed blank context line between SetActiveRoute and
  SetStreamPath where the leading space had been stripped, causing
  `patch` to treat it as end-of-hunk and report the file as malformed.
- Fix wrong old/new line counts in both hunks and trim the second
  hunk's leading context from 13 lines (needing fuzz 12) to 3 so the
  patch applies cleanly with default fuzz.

End state is a single packages/mediacenter/libcec/patches/
libcec-001-fix-active-source-on-routing-change.patch that applies
cleanly against the current libcec source tree.
@samtheruby
Copy link
Copy Markdown
Contributor Author

All possible tests passed, As well as 0 bugs when in regular use, I think this is ready for prime time!

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.

1 participant