Skip to content

Reliable movie audio buffering and focus recovery - #203

Closed
Recluse wants to merge 3 commits into
KD-lab-Open-Source:mainfrom
Recluse:pr/video-playback
Closed

Recluse wants to merge 3 commits into
KD-lab-Open-Source:mainfrom
Recluse:pr/video-playback

Conversation

@Recluse

@Recluse Recluse commented Oct 21, 2026 •

Copy link
Copy Markdown

The movie audio buffer could mistake a full buffer for an empty one, and playback paused on focus loss without automatically resuming. Buffer access is now synchronized, occupancy is tracked explicitly, and playback resumes when focus returns.

CI downloads FFmpeg from its GitHub mirror after git.ffmpeg.org failed to resolve in a fork build. This repeats the URL-only change from #200; the n8.0 tag and build options are unchanged.

@Recluse
Recluse marked this pull request as ready for review October 21, 2026 11:45
@IonAgorria

Copy link
Copy Markdown
Collaborator

Hello,

Is this done using LLM? in what percentage?
What's the rationale of using a mutex?
Is still performant in low spec computers?
What artifacts were observed to warrant changing the logic around "unused texture areas"?
Was this tested in other platforms as Linux and Windows?

@Recluse

Recluse commented Oct 21, 2026

Copy link
Copy Markdown
Author

Yes, the implementation was written with an LLM; I tested the resulting build on macOS. I don’t have a measured percentage to give you.

The mutex was added to protect the ring buffer and its counters shared between the playback thread and the audio callback, including reads that previously happened outside SDL_LockAudio(). I haven’t benchmarked this on low-spec hardware, so I can’t claim the locking has no playback impact. The choice of synchronization needs a closer look before merging.

The extra texture padding clear was added while investigating a bright strip at the edge of a movie. I later checked the original game on Windows and found the same strip in the source video. That leaves this addition without a demonstrated rendering bug to fix; I’ll remove it and retain the original right-edge clearing.

Playback was tested on macOS with the base game and Emperor’s Testament, including intro, pre-mission and exit movies. I haven’t tested this modified player on Windows or Linux; the Windows comparison above used the original game.

@Recluse

Recluse commented Oct 21, 2026

Copy link
Copy Markdown
Author

The extra bottom-row clearing and opaque padding fill have been removed from this update; the original right-edge clearing is retained.

I tested the updated build on macOS and Windows with native D3D9 on Windows. Movie playback worked correctly in the videos I checked after the removal.

Low-spec performance and Linux playback are still untested. The mutex implementation is unchanged.

@Recluse

Recluse commented Oct 21, 2026

Copy link
Copy Markdown
Author

The fork’s Linux build failed while cloning FFmpeg: Could not resolve host: git.ffmpeg.org.

I applied the same URL-only change as #200 to this branch, using the FFmpeg GitHub mirror for the Linux, macOS and Windows MSYS downloads. The n8.0 tag and build options are unchanged.

@Recluse

Recluse commented Oct 23, 2026

Copy link
Copy Markdown
Author

I tested Perimeter and Emperor's Testament on macOS with the original decoder and player, without #202 or #203. All tested movies play correctly. I also tested windowed mode and switched between applications several times without problems.

These changes were added while investigating the playback issue, but I hadn't tested the build without them before opening the PR. I haven't demonstrated that they are needed to fix the reported problem, so I'll close this PR too. Sorry for taking up your review time.

@Recluse Recluse closed this Oct 23, 2026
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