From e9428449ff495e1f64b0362084892ecce46f6c6e Mon Sep 17 00:00:00 2001 From: kelciour Date: Tue, 3 Jan 2023 04:59:39 +0300 Subject: [PATCH] Fix two mpv issues on Windows (#2294) * Fix mpv with two Windows accounts at the same time Closes #2203 * Add a workaround for audio cut off early on Windows Closes #1730 --- qt/aqt/mpv.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/qt/aqt/mpv.py b/qt/aqt/mpv.py index f62355dd6..cae1201f9 100644 --- a/qt/aqt/mpv.py +++ b/qt/aqt/mpv.py @@ -92,6 +92,9 @@ class MPVBase: "--gapless-audio=no", ] + if is_win: + default_argv += ["--af-add=lavfi=[apad=pad_dur=0.150]"] + def __init__(self, window_id=None, debug=False): self.window_id = window_id self.debug = debug @@ -143,7 +146,7 @@ class MPVBase: --input-unix-socket option. """ if is_win: - self._sock_filename = "ankimpv" + self._sock_filename = "ankimpv{}".format(os.getpid()) return fd, self._sock_filename = tempfile.mkstemp(prefix="mpv.") os.close(fd) @@ -156,12 +159,11 @@ class MPVBase: start = time.time() while self.is_running() and time.time() < start + 10: time.sleep(0.1) - if is_win: # named pipe try: self._sock = win32file.CreateFile( - r"\\.\pipe\ankimpv", + r"\\.\pipe\{}".format(self._sock_filename), win32file.GENERIC_READ | win32file.GENERIC_WRITE, 0, None,