diff options
| author | Craig Jennings <c@cjennings.net> | 2026-02-26 17:15:57 -0600 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-02-26 17:15:57 -0600 |
| commit | c43805f86a6f6b87a3f75ab8ece2610905344ec9 (patch) | |
| tree | 7fea59efbdd25de9271c18c8bed5cdb612cc53f3 | |
| parent | 58ef63abd5a9187ee93609f142cb21a933da16c5 (diff) | |
fix(recording): replace blocking y-or-n-p with non-blocking warning
The no-audio warning was a y-or-n-p prompt that blocked recording start.
This fires too often in legitimate scenarios (starting before a meeting
connects, during silence). Replace with a message in the echo area and
diagnostic steps logged silently to *Messages*. Also add pre-recording
validation to the Commentary section.
| -rw-r--r-- | modules/video-audio-recording.el | 29 | ||||
| -rw-r--r-- | tests/test-video-audio-recording-validate-system-audio.el | 34 |
2 files changed, 41 insertions, 22 deletions
diff --git a/modules/video-audio-recording.el b/modules/video-audio-recording.el index 6ab617ec..2bf35166 100644 --- a/modules/video-audio-recording.el +++ b/modules/video-audio-recording.el @@ -58,6 +58,18 @@ ;; Use this DURING a phone call to see if the call audio is going through ;; the device you think it is. Helps diagnose "missing one side" issues. ;; +;; Pre-Recording Validation +;; ======================== +;; Every time you start a recording, the system audio device is +;; validated automatically: +;; 1. If the configured monitor device no longer exists, it's +;; auto-updated to the current default sink's monitor. +;; 2. If the default audio output has changed (e.g. Bluetooth +;; reconnect, USB DAC plugged in), the monitor is auto-updated. +;; 3. If no audio is currently playing through the monitored sink, +;; a warning is shown in the echo area. Recording proceeds +;; without interruption — check *Messages* for diagnostic steps. +;; ;; Testing Devices Before Important Recordings ;; ============================================ ;; Always test devices before important recordings: @@ -647,15 +659,14 @@ is currently playing." (has-audio (and sink-index (cj/recording--sink-has-active-audio-p sink-index sink-inputs)))) (unless has-audio - (unless (y-or-n-p - (format (concat "Warning: No audio is playing through %s.\n" - "If you're in a meeting, the other participants may not be recorded.\n" - "- Check that your call app is using the expected audio output\n" - "- Run C-; r w to see which device your call is using\n" - "- Run C-; r s to switch devices\n" - "Continue anyway? ") - sink-name)) - (user-error "Recording cancelled"))))))) + (message "Warning: No audio detected on %s — other participants may not be recorded" + sink-name) + (cj/log-silently + (concat "No audio playing through %s.\n" + "If you're in a meeting, the other participants may not be recorded.\n" + " C-; r w show which device your call is using\n" + " C-; r s switch devices") + sink-name)))))) ;;; ============================================================ ;;; Toggle Commands (User-Facing) diff --git a/tests/test-video-audio-recording-validate-system-audio.el b/tests/test-video-audio-recording-validate-system-audio.el index ef730ab3..fd5eafb3 100644 --- a/tests/test-video-audio-recording-validate-system-audio.el +++ b/tests/test-video-audio-recording-validate-system-audio.el @@ -102,11 +102,12 @@ (test-validate-teardown))) (ert-deftest test-validate-system-audio-normal-no-audio-warns () - "Test that no active audio triggers a y-or-n-p warning." + "Test that no active audio shows warning message and logs diagnostic steps." (test-validate-setup) (unwind-protect (let ((cj/recording-system-device "alsa_output.usb-Jabra-00.analog-stereo.monitor") - (prompted nil)) + (messages nil) + (logged nil)) (cl-letf (((symbol-function 'shell-command-to-string) (lambda (cmd) (cond @@ -118,17 +119,23 @@ ((string-match-p "sink-inputs" cmd) "") ((string-match-p "get-default-sink" cmd) "alsa_output.usb-Jabra-00.analog-stereo") (t "")))) - ((symbol-function 'y-or-n-p) - (lambda (prompt) - (setq prompted prompt) - t))) ; User says yes, continue + ((symbol-function 'message) + (lambda (fmt &rest args) + (push (apply #'format fmt args) messages))) + ((symbol-function 'cj/log-silently) + (lambda (fmt &rest args) + (setq logged (apply #'format fmt args))))) (cj/recording--validate-system-audio) - (should prompted) - (should (string-match-p "No audio is playing" prompted)))) + ;; Echo area should show the warning + (should (cl-some (lambda (m) (string-match-p "No audio detected" m)) messages)) + ;; Messages buffer should have diagnostic steps + (should logged) + (should (string-match-p "C-; r w" logged)) + (should (string-match-p "C-; r s" logged)))) (test-validate-teardown))) -(ert-deftest test-validate-system-audio-normal-no-audio-user-cancels () - "Test that user declining the warning cancels recording." +(ert-deftest test-validate-system-audio-normal-no-audio-does-not-block () + "Test that no active audio does not block — recording proceeds." (test-validate-setup) (unwind-protect (let ((cj/recording-system-device "alsa_output.usb-Jabra-00.analog-stereo.monitor")) @@ -142,9 +149,10 @@ ((string-match-p "sink-inputs" cmd) "") ((string-match-p "get-default-sink" cmd) "alsa_output.usb-Jabra-00.analog-stereo") (t "")))) - ((symbol-function 'y-or-n-p) - (lambda (_prompt) nil))) ; User says no - (should-error (cj/recording--validate-system-audio) :type 'user-error))) + ((symbol-function 'message) (lambda (_fmt &rest _args) nil)) + ((symbol-function 'cj/log-silently) (lambda (_fmt &rest _args) nil))) + ;; Should return normally, not signal an error or prompt + (cj/recording--validate-system-audio))) (test-validate-teardown))) ;;; Boundary Cases |
