From 8f3e8c14a4d5a23f59e3ebbb4b5cbd17439fa865 Mon Sep 17 00:00:00 2001 From: y2q-actionman Date: Mon, 5 Apr 2021 14:20:28 +0900 Subject: [PATCH 1/2] added init check around ao-open-live --- mixalot.lisp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mixalot.lisp b/mixalot.lisp index c22b303..6645599 100644 --- a/mixalot.lisp +++ b/mixalot.lisp @@ -304,9 +304,13 @@ (ao-fmt-rate fmt) rate (ao-fmt-byte-format fmt) AO_FMT_LITTLE (ao-fmt-matrix fmt) matrix) - (ao-open-live (ao-default-driver-id) - fmt - (null-pointer))))) + (let ((device (ao-open-live (ao-default-driver-id) + fmt + (null-pointer)))) + (when (null-pointer-p device) + ;; TODO: see errno via CFFI-grovel. + (error "libao ao-open-live failed.")) + device)))) #+mixalot::use-ao (defun main-thread-init () From 8158e1acb6431d87eba43b30ceddcc8ef3bd3241 Mon Sep 17 00:00:00 2001 From: y2q-actionman Date: Sat, 10 Apr 2021 12:15:38 +0900 Subject: [PATCH 2/2] Moved open-ao calling to parental thread --- mixalot.lisp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/mixalot.lisp b/mixalot.lisp index 6645599..6dd7c22 100644 --- a/mixalot.lisp +++ b/mixalot.lisp @@ -619,18 +619,21 @@ should be output in STREAMER-MIX-INTO or STREAMER-WRITE-INTO." #-(or mixalot::use-ao mixalot::use-alsa) (error "Neither mixalot::use-ao nor mixalot::use-alsa existed on *features* when this function was compiled. That is wrong.") (let ((mixer (funcall constructor :rate rate))) + #+mixalot::use-alsa (bordeaux-threads:make-thread (lambda () - #+mixalot::use-ao - (progn - (setf (mixer-device mixer) (open-ao :rate rate)) - (run-mixer-process mixer)) - #+mixalot::use-alsa (call-with-pcm rate (lambda (pcm) (setf (mixer-device mixer) pcm) (run-mixer-process mixer)))) :name (format nil "Mixer thread ~:D Hz" rate)) + #+mixalot::use-ao + (let ((device (open-ao :rate rate))) + (setf (mixer-device mixer) device) + (bordeaux-threads:make-thread + (lambda () + (run-mixer-process mixer)) + :name (format nil "Mixer thread ~:D Hz" rate))) mixer)) (defun destroy-mixer (mixer)