From db455a1b0d867869ac7cdd296bb323951edf03ea Mon Sep 17 00:00:00 2001 From: cottongin Date: Thu, 19 Nov 2026 14:23:17 -0500 Subject: [PATCH] fix(app): guard video_worker_loop PID ownership and assert pcm_sink output --- app/src/video_player.cpp | 5 +++++ app/tests/test_timelapse_and_gallery.cpp | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/app/src/video_player.cpp b/app/src/video_player.cpp index 0cb02b4..0f12a9c 100644 --- a/app/src/video_player.cpp +++ b/app/src/video_player.cpp @@ -1229,12 +1229,17 @@ void VideoPlayer::video_worker_loop(double start_pos_sec, int status = 0; if (!stopped_by_caller && natural_eof) { + bool owns_pid = false; { std::lock_guard plock(proc_mutex_); if (video_pid_ == child_pid) { video_pid_ = -1; + owns_pid = true; } } + if (!owns_pid) { + return; + } if (!media_detail::reap_pid_timeout(child_pid, 500, &status)) { pid_t tmp = child_pid; media_detail::kill_and_reap(tmp); diff --git a/app/tests/test_timelapse_and_gallery.cpp b/app/tests/test_timelapse_and_gallery.cpp index fc5f919..c8c828a 100644 --- a/app/tests/test_timelapse_and_gallery.cpp +++ b/app/tests/test_timelapse_and_gallery.cpp @@ -718,6 +718,10 @@ void test_video_player_decodes_frames_seeks_and_handles_silent_mp4() { } std::this_thread::sleep_for(std::chrono::milliseconds(20)); } + assert(af.seq > 0); + assert(pcm_samples.load() > 0); + player.stop(); + // Muted play(false) on audio MP4 skips pcm_sink and reaches EOF naturally pcm_samples.store(0); assert(player.open(audio_mp4, 226, 128));