fix: audio in verify_sync
This commit is contained in:
1 parent
26cc2883d9
commit
02df187139
1 file changed
+3
-1
+3
-1
@@ -140,6 +140,7 @@ def apply_dark_theme(app: QtWidgets.QApplication):
|
|||||||
class AudioPlayer:
|
class AudioPlayer:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.playing = False
|
self.playing = False
|
||||||
|
self._stream = None
|
||||||
self._lock = threading.Lock()
|
self._lock = threading.Lock()
|
||||||
|
|
||||||
def play(self, data: np.ndarray, sr: int):
|
def play(self, data: np.ndarray, sr: int):
|
||||||
@@ -149,7 +150,7 @@ class AudioPlayer:
|
|||||||
sd.stop()
|
sd.stop()
|
||||||
self.playing = True
|
self.playing = True
|
||||||
try:
|
try:
|
||||||
sd.play(data, samplerate=sr, blocking=False)
|
self._stream = sd.play(data, samplerate=sr, blocking=False)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"audio play error: {e}", file=sys.stderr)
|
print(f"audio play error: {e}", file=sys.stderr)
|
||||||
self.playing = False
|
self.playing = False
|
||||||
@@ -158,6 +159,7 @@ class AudioPlayer:
|
|||||||
if HAS_SD:
|
if HAS_SD:
|
||||||
with self._lock:
|
with self._lock:
|
||||||
sd.stop()
|
sd.stop()
|
||||||
|
self._stream = None
|
||||||
self.playing = False
|
self.playing = False
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user