From 84eaf43525034f0ba5fd7f63efbdeace74328e97 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Mon, 23 Mar 2020 19:15:32 +1000 Subject: [PATCH] reduce the chances of a race condition in mplayer code Not perfect, it may still happen. https://anki.tenderapp.com/discussions/ankidesktop/39832-an-error-occurred-audio --- qt/aqt/sound.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/qt/aqt/sound.py b/qt/aqt/sound.py index 94b71032f..cdd9b65d0 100644 --- a/qt/aqt/sound.py +++ b/qt/aqt/sound.py @@ -393,8 +393,9 @@ class SimpleMplayerSlaveModePlayer(SimpleMplayerPlayer): The trailing newline is automatically added.""" str_args = [str(x) for x in args] - self._process.stdin.write(" ".join(str_args).encode("utf8") + b"\n") - self._process.stdin.flush() + if self._process: + self._process.stdin.write(" ".join(str_args).encode("utf8") + b"\n") + self._process.stdin.flush() def seek_relative(self, secs: int) -> None: self.command("seek", secs, 0)