Repository navigation
fix: flatpak mpv can no longer hang or outlive TTS_ka - #23
Merged
Merged
Conversation
A flatpak mpv broke playback cleanup in three ways: - The PID Popen holds is bwrap, not mpv. Killing it, as close() and stop() did, left mpv-bin running. mpv is now started with start_new_session=True and stopped with the new mpv_ipc.kill_process_group. - Its bundled mpris plugin blocks forever when DBUS_SESSION_BUS_ADDRESS is unset (e.g. an MCP server launched by stdio_client without env=). mpv then answers IPC but never plays and ignores SIGTERM and quit. Headless mpv (IPC and stdin playlist) now gets --load-scripts=no, and MpvIpc.wait_done raises if no appended entry starts within START_TIMEOUT instead of waiting forever. - MpvIpc.start() left mpv running when it connected but observe_property got no answer. It now closes mpv before raising. Chunk errors are recorded in StreamingAudioPlayer.playback_error, and a blocking MCP `speak` raises ToolError with that reason instead of answering "played in 0.7s" when mpv said "audio output initialization failed". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
An MCP
speakleft a flatpak mpv running for 8 hours, and only SIGKILL stopped it. The investigation found five problems, all fixed here.Popenholds isbwrap, not mpv, and SIGKILL to it leavesmpv-binrunning. mpv is now started withstart_new_session=Trueand stopped with the newmpv_ipc.kill_process_group. That coversMpvIpc.close()andStreamingAudioPlayer.stop().MpvIpc.wait_donenow raises if no appended entry starts withinSTART_TIMEOUT(10 s), instead of waiting forever.mprisplugin blocks forever withoutDBUS_SESSION_BUS_ADDRESS, for example when an MCP server is started bystdio_clientwithoutenv=. mpv then answers IPC but never plays and ignores SIGTERM andquit. Headless mpv (both the IPC and the stdin-playlist launch) now gets--load-scripts=no. Windowed mpv keeps the user's scripts.MpvIpc.start()could leak mpv. If mpv connected but didn't answerobserve_property,start()raised without closing it. It now closes mpv first.StreamingAudioPlayer.playback_error. A blockingspeakraisesToolErrorwith the reason, instead of answering "played in 0.7s" after mpv reported "audio output initialization failed".Test plan
shwrapper's process group and checks that its child dies too.pytestsuite passes; no new mypy or flake8 findingsspeak(blocking) through a plain flatpak mpv, started bystdio_clientwith its default minimal env:--load-scripts=nostripped out to force the mpris hang: fails after the 10 s start timeout with "mpv did not start playing within 10s", and the stuck mpv is killed through its process group.🤖 Generated with Claude Code