From a7b8cb87de637ead46af48aff84afaee3e489e13 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 26 Oct 2023 11:46:02 +1000 Subject: [PATCH] Don't block collection when playing audio https://forums.ankiweb.net/t/anki-23-10-release-candidate/35967/60 --- qt/aqt/sound.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/qt/aqt/sound.py b/qt/aqt/sound.py index 564252574..fbd0548f8 100644 --- a/qt/aqt/sound.py +++ b/qt/aqt/sound.py @@ -294,7 +294,9 @@ class SimpleProcessPlayer(Player): # pylint: disable=abstract-method def play(self, tag: AVTag, on_done: OnDoneCallback) -> None: self._terminate_flag = False self._taskman.run_in_background( - lambda: self._play(tag), lambda res: self._on_done(res, on_done) + lambda: self._play(tag), + lambda res: self._on_done(res, on_done), + uses_collection=False, ) def stop(self) -> None: @@ -529,7 +531,9 @@ def encode_mp3(mw: aqt.AnkiQt, src_wav: str, on_done: Callable[[str], None]) -> on_done(dst_mp3) - mw.taskman.run_in_background(lambda: _encode_mp3(src_wav, dst_mp3), _on_done) + mw.taskman.run_in_background( + lambda: _encode_mp3(src_wav, dst_mp3), _on_done, uses_collection=False + ) # Recording interface @@ -623,7 +627,9 @@ class QtAudioInputRecorder(Recorder): fut.result() Recorder.stop(self, on_done) - self.mw.taskman.run_in_background(write_file, and_then) + self.mw.taskman.run_in_background( + write_file, and_then, uses_collection=False + ) # schedule the stop for half a second in the future, # to avoid truncating the end of the recording