From 58ef63abd5a9187ee93609f142cb21a933da16c5 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Thu, 26 Feb 2026 17:08:19 -0600 Subject: feat(recording): validate system audio device before recording Add pre-recording validation that catches stale or drifted system audio devices before they cause silent recordings. When the default audio output changes (Bluetooth reconnect, device switch) between setup and recording, the monitor device is auto-updated. Warns if no audio is currently playing through the monitored sink. Co-Authored-By: Craig Jennings --- .../test-video-audio-recording-process-cleanup.el | 43 +++++++++++++--------- 1 file changed, 26 insertions(+), 17 deletions(-) (limited to 'tests/test-video-audio-recording-process-cleanup.el') diff --git a/tests/test-video-audio-recording-process-cleanup.el b/tests/test-video-audio-recording-process-cleanup.el index d1cd442c..42b5b96d 100644 --- a/tests/test-video-audio-recording-process-cleanup.el +++ b/tests/test-video-audio-recording-process-cleanup.el @@ -166,7 +166,9 @@ so ffmpeg sees EOF on its video input pipe and starts finalizing the file." 0)) ((symbol-function 'start-process-shell-command) (lambda (_name _buffer _command) - (make-process :name "fake-video" :command '("sleep" "1000"))))) + (make-process :name "fake-video" :command '("sleep" "1000")))) + ((symbol-function 'cj/recording--validate-system-audio) + (lambda () nil))) (cj/ffmpeg-record-video video-recordings-dir) (should pkill-called) (should (member "-INT" pkill-args)) @@ -186,7 +188,9 @@ so ffmpeg sees EOF on its video input pipe and starts finalizing the file." 0)) ((symbol-function 'start-process-shell-command) (lambda (_name _buffer _command) - (make-process :name "fake-video" :command '("sleep" "1000"))))) + (make-process :name "fake-video" :command '("sleep" "1000")))) + ((symbol-function 'cj/recording--validate-system-audio) + (lambda () nil))) (cj/ffmpeg-record-video video-recordings-dir) (should-not pkill-called))) (test-cleanup-teardown))) @@ -299,13 +303,15 @@ This is an integration test that requires wf-recorder and Wayland." (skip-unless (cj/recording--wayland-p)) (test-cleanup-setup) (unwind-protect - (let ((initial-count (test-cleanup--count-wf-recorder-processes))) - (cj/ffmpeg-record-video video-recordings-dir) - (sit-for 1.0) - (should (> (test-cleanup--count-wf-recorder-processes) initial-count)) - (cj/video-recording-stop) - (sit-for 1.0) - (should (= (test-cleanup--count-wf-recorder-processes) initial-count))) + (cl-letf (((symbol-function 'cj/recording--validate-system-audio) + (lambda () nil))) + (let ((initial-count (test-cleanup--count-wf-recorder-processes))) + (cj/ffmpeg-record-video video-recordings-dir) + (sit-for 1.0) + (should (> (test-cleanup--count-wf-recorder-processes) initial-count)) + (cj/video-recording-stop) + (sit-for 1.0) + (should (= (test-cleanup--count-wf-recorder-processes) initial-count)))) (test-cleanup-teardown) (ignore-errors (call-process "pkill" nil nil nil "-INT" "wf-recorder")))) @@ -317,7 +323,8 @@ This is an integration test that requires wf-recorder and Wayland." (skip-unless (cj/recording--wayland-p)) (test-cleanup-setup) (unwind-protect - (progn + (cl-letf (((symbol-function 'cj/recording--validate-system-audio) + (lambda () nil))) ;; Create an orphan wf-recorder (simulating a crash) (start-process "orphan-wf" nil "wf-recorder" "-c" "libx264" "-m" "matroska" "-f" "/dev/null") (sit-for 0.5) @@ -342,13 +349,15 @@ This is an integration test that requires wf-recorder and Wayland." (skip-unless (cj/recording--wayland-p)) (test-cleanup-setup) (unwind-protect - (let ((initial-count (test-cleanup--count-wf-recorder-processes))) - (dotimes (_ 3) - (cj/ffmpeg-record-video video-recordings-dir) - (sit-for 0.5) - (cj/video-recording-stop) - (sit-for 0.5)) - (should (= (test-cleanup--count-wf-recorder-processes) initial-count))) + (cl-letf (((symbol-function 'cj/recording--validate-system-audio) + (lambda () nil))) + (let ((initial-count (test-cleanup--count-wf-recorder-processes))) + (dotimes (_ 3) + (cj/ffmpeg-record-video video-recordings-dir) + (sit-for 0.5) + (cj/video-recording-stop) + (sit-for 0.5)) + (should (= (test-cleanup--count-wf-recorder-processes) initial-count)))) (test-cleanup-teardown) (ignore-errors (call-process "pkill" nil nil nil "-INT" "wf-recorder")))) -- cgit v1.2.3