mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 15:32:23 -04:00
close mplayer on deck close as media path may change
This commit is contained in:
parent
8c8a76d08d
commit
ad5a7c8bf7
1 changed files with 12 additions and 2 deletions
|
@ -9,6 +9,7 @@ Sound support
|
|||
__docformat__ = 'restructuredtext'
|
||||
|
||||
import re, sys, threading, time, subprocess, os, signal, atexit, errno
|
||||
from anki.hooks import addHook
|
||||
|
||||
# Shared utils
|
||||
##########################################################################
|
||||
|
@ -164,7 +165,7 @@ def clearMplayerQueue():
|
|||
mplayerQueue.append(None)
|
||||
mplayerCond.release()
|
||||
|
||||
def stopMplayer():
|
||||
def stopMplayer(restart=False):
|
||||
mplayerCond.acquire()
|
||||
if mplayerManager.mplayer:
|
||||
while 1:
|
||||
|
@ -176,14 +177,23 @@ def stopMplayer():
|
|||
# osx throws interrupt errors regularly, but we want to
|
||||
# ignore other errors on shutdown
|
||||
break
|
||||
mplayerManager.mplayer = -1
|
||||
except ValueError:
|
||||
# already closed
|
||||
break
|
||||
if not restart:
|
||||
mplayerManager.mplayer = -1
|
||||
mplayerCond.notify()
|
||||
mplayerCond.release()
|
||||
|
||||
def stopMplayerOnce():
|
||||
stopMplayer(restart=True)
|
||||
|
||||
mplayerManager = MplayerMonitor()
|
||||
mplayerManager.start()
|
||||
atexit.register(stopMplayer)
|
||||
|
||||
addHook("deckClosed", stopMplayerOnce)
|
||||
|
||||
# PyAudio recording
|
||||
##########################################################################
|
||||
|
||||
|
|
Loading…
Reference in a new issue