Skip to content

fix(avfoundation): composite every OSD object into one overlay - #4

Open
demrom wants to merge 1 commit into
streamyfin:avfoundation-ao-tvosfrom
demrom:fix/avfoundation-osd-composition
Open

demrom wants to merge 1 commit into
streamyfin:avfoundation-ao-tvosfrom
demrom:fix/avfoundation-osd-composition

Conversation

@demrom

@demrom demrom commented Oct 15, 2026

Copy link
Copy Markdown

Description

With both sid and secondary-sid set, vo_avfoundation shows only one of the two subtitle tracks.

The driver draws through mpv's legacy osd_draw(), which calls its callback once per OSD object. Primary and secondary subtitles are separate objects, and draw_osd_cb replaced the cached overlay on every call, so only the last object stayed on screen.

The driver now calls osd_render() and draws the whole sub_bitmap_list into one image covering the union of all parts' bounds, in composite mode and in CALayer mode. An empty list still clears the overlay, so the osd_callback_invoked flag is gone.

Only the vo_avfoundation.m section of patch 0004 changes. Its diffstat, hunk length and blob hash are updated to match. Most of the diff is the drawing loop moving one level in, so "Hide whitespace" makes it easier to read.

Ticket / Issue

Refs streamyfin/streamyfin#960, which asks for two subtitle tracks at once. On iOS that needs this fix first.

Testing

  • Patches 0001 to 0006 apply with git apply to a clean mpv v0.41.0, the way base.swift applies them.
  • vo_avfoundation.m compiles for iOS arm64 with the libmpv build's own compile command. The one existing warning (label followed by a declaration) is unchanged.
  • A small macOS harness includes vo_avfoundation.m, stubs osd_render() to return two subtitle objects (one at the bottom, one at the top) and calls render_osd(). Before this change the bottom object is fully transparent in the overlay in both composite and CALayer mode. After it, both objects are opaque in both modes, and an empty list clears the overlay.
  • On an iPhone (composite mode) both tracks now show. That build also carried unrelated local screenshot changes to this driver. I did not test tvOS; only the harness covers CALayer mode.

vo_avfoundation drew subtitles through the legacy osd_draw() callback,
which mpv calls once per OSD object: primary subtitles, secondary
subtitles, OSD text and script overlays each arrive in a separate call.
Every call replaced the cached overlay, so only the last object survived.
With secondary-sid set, the primary track disappeared.

Use osd_render() and draw the whole sub_bitmap_list into one image over
the union of its bounds, in both composite and CALayer mode. An empty
list still clears the overlay, which replaces the osd_callback_invoked
flag.
@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: edfae51d-03b2-4123-b97f-07d8ec4885ef

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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