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-command-structure.el | 72 ++++++++++++++++------ 1 file changed, 54 insertions(+), 18 deletions(-) (limited to 'tests/test-video-audio-recording-command-structure.el') diff --git a/tests/test-video-audio-recording-command-structure.el b/tests/test-video-audio-recording-command-structure.el index c964b246..f4c24c39 100644 --- a/tests/test-video-audio-recording-command-structure.el +++ b/tests/test-video-audio-recording-command-structure.el @@ -52,7 +52,9 @@ ((symbol-function 'start-process-shell-command) (lambda (_name _buffer cmd) (setq command cmd) - (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 (string-match-p "wf-recorder" command)))) (test-command-structure-teardown))) @@ -66,7 +68,9 @@ ((symbol-function 'start-process-shell-command) (lambda (_name _buffer cmd) (setq command cmd) - (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 (string-match-p "wf-recorder -y" command)))) (test-command-structure-teardown))) @@ -80,7 +84,9 @@ ((symbol-function 'start-process-shell-command) (lambda (_name _buffer cmd) (setq command cmd) - (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 use libx264, not h264 (should (string-match-p "-c libx264" command)) @@ -96,7 +102,9 @@ ((symbol-function 'start-process-shell-command) (lambda (_name _buffer cmd) (setq command cmd) - (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 (string-match-p "-m matroska" command)))) (test-command-structure-teardown))) @@ -110,7 +118,9 @@ ((symbol-function 'start-process-shell-command) (lambda (_name _buffer cmd) (setq command cmd) - (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 use -f /dev/stdout, not -o - (should (string-match-p "-f /dev/stdout" command)) @@ -126,7 +136,9 @@ ((symbol-function 'start-process-shell-command) (lambda (_name _buffer cmd) (setq command cmd) - (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) ;; These flags don't exist in wf-recorder (should-not (string-match-p "--no-audio" command)) @@ -142,7 +154,9 @@ ((symbol-function 'start-process-shell-command) (lambda (_name _buffer cmd) (setq command cmd) - (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 pipe wf-recorder to ffmpeg (should (string-match-p "wf-recorder.*|.*ffmpeg" command)))) @@ -157,7 +171,9 @@ ((symbol-function 'start-process-shell-command) (lambda (_name _buffer cmd) (setq command cmd) - (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 (string-match-p "ffmpeg -i pipe:0" command)))) (test-command-structure-teardown))) @@ -173,7 +189,9 @@ ((symbol-function 'start-process-shell-command) (lambda (_name _buffer cmd) (setq command cmd) - (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 (string-match-p "x11grab" command)))) (test-command-structure-teardown))) @@ -187,7 +205,9 @@ ((symbol-function 'start-process-shell-command) (lambda (_name _buffer cmd) (setq command cmd) - (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 (string-match-p "wf-recorder" command)))) (test-command-structure-teardown))) @@ -201,7 +221,9 @@ ((symbol-function 'start-process-shell-command) (lambda (_name _buffer cmd) (setq command cmd) - (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 (string-match-p "-i :0" command)))) (test-command-structure-teardown))) @@ -216,7 +238,9 @@ (cl-letf (((symbol-function 'start-process-shell-command) (lambda (_name _buffer cmd) (setq command cmd) - (make-process :name "fake-audio" :command '("sleep" "1000"))))) + (make-process :name "fake-audio" :command '("sleep" "1000")))) + ((symbol-function 'cj/recording--validate-system-audio) + (lambda () nil))) (cj/ffmpeg-record-audio audio-recordings-dir) (should (string-match-p "^ffmpeg " command)))) (test-command-structure-teardown))) @@ -229,7 +253,9 @@ (cl-letf (((symbol-function 'start-process-shell-command) (lambda (_name _buffer cmd) (setq command cmd) - (make-process :name "fake-audio" :command '("sleep" "1000"))))) + (make-process :name "fake-audio" :command '("sleep" "1000")))) + ((symbol-function 'cj/recording--validate-system-audio) + (lambda () nil))) (cj/ffmpeg-record-audio audio-recordings-dir) (should (string-match-p "-f pulse" command)))) (test-command-structure-teardown))) @@ -242,7 +268,9 @@ (cl-letf (((symbol-function 'start-process-shell-command) (lambda (_name _buffer cmd) (setq command cmd) - (make-process :name "fake-audio" :command '("sleep" "1000"))))) + (make-process :name "fake-audio" :command '("sleep" "1000")))) + ((symbol-function 'cj/recording--validate-system-audio) + (lambda () nil))) (cj/ffmpeg-record-audio audio-recordings-dir) (should (string-match-p "\\.m4a" command)))) (test-command-structure-teardown))) @@ -258,7 +286,9 @@ ((symbol-function 'start-process-shell-command) (lambda (_name _buffer cmd) (setq command cmd) - (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 (string-match-p "-filter_complex" command)) (should (string-match-p "amerge" command)))) @@ -273,7 +303,9 @@ ((symbol-function 'start-process-shell-command) (lambda (_name _buffer cmd) (setq command cmd) - (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 (string-match-p "-map 0:v" command)) (should (string-match-p "-map.*\\[out\\]" command)))) @@ -288,7 +320,9 @@ ((symbol-function 'start-process-shell-command) (lambda (_name _buffer cmd) (setq command cmd) - (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 (string-match-p "-c:v copy" command)))) (test-command-structure-teardown))) @@ -302,7 +336,9 @@ ((symbol-function 'start-process-shell-command) (lambda (_name _buffer cmd) (setq command cmd) - (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 (string-match-p "\\.mkv" command)))) (test-command-structure-teardown))) -- cgit v1.2.3