mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 23:42: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'
|
__docformat__ = 'restructuredtext'
|
||||||
|
|
||||||
import re, sys, threading, time, subprocess, os, signal, atexit, errno
|
import re, sys, threading, time, subprocess, os, signal, atexit, errno
|
||||||
|
from anki.hooks import addHook
|
||||||
|
|
||||||
# Shared utils
|
# Shared utils
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
@ -164,7 +165,7 @@ def clearMplayerQueue():
|
||||||
mplayerQueue.append(None)
|
mplayerQueue.append(None)
|
||||||
mplayerCond.release()
|
mplayerCond.release()
|
||||||
|
|
||||||
def stopMplayer():
|
def stopMplayer(restart=False):
|
||||||
mplayerCond.acquire()
|
mplayerCond.acquire()
|
||||||
if mplayerManager.mplayer:
|
if mplayerManager.mplayer:
|
||||||
while 1:
|
while 1:
|
||||||
|
@ -176,14 +177,23 @@ def stopMplayer():
|
||||||
# osx throws interrupt errors regularly, but we want to
|
# osx throws interrupt errors regularly, but we want to
|
||||||
# ignore other errors on shutdown
|
# ignore other errors on shutdown
|
||||||
break
|
break
|
||||||
|
except ValueError:
|
||||||
|
# already closed
|
||||||
|
break
|
||||||
|
if not restart:
|
||||||
mplayerManager.mplayer = -1
|
mplayerManager.mplayer = -1
|
||||||
mplayerCond.notify()
|
mplayerCond.notify()
|
||||||
mplayerCond.release()
|
mplayerCond.release()
|
||||||
|
|
||||||
|
def stopMplayerOnce():
|
||||||
|
stopMplayer(restart=True)
|
||||||
|
|
||||||
mplayerManager = MplayerMonitor()
|
mplayerManager = MplayerMonitor()
|
||||||
mplayerManager.start()
|
mplayerManager.start()
|
||||||
atexit.register(stopMplayer)
|
atexit.register(stopMplayer)
|
||||||
|
|
||||||
|
addHook("deckClosed", stopMplayerOnce)
|
||||||
|
|
||||||
# PyAudio recording
|
# PyAudio recording
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue