add lock to soundlib volume utility
This commit is contained in:
parent
4cf3328339
commit
624574df3d
|
@ -2,7 +2,7 @@
|
||||||
Implements all sound functionality
|
Implements all sound functionality
|
||||||
'''
|
'''
|
||||||
import logging, os, hashlib, queue, time, psutil
|
import logging, os, hashlib, queue, time, psutil
|
||||||
from threading import Event
|
from threading import Event, RLock
|
||||||
from exceptionThreading import ExceptionThread, async
|
from exceptionThreading import ExceptionThread, async
|
||||||
from pygame import mixer
|
from pygame import mixer
|
||||||
from subprocess import call
|
from subprocess import call
|
||||||
|
@ -114,6 +114,7 @@ class SoundLib:
|
||||||
|
|
||||||
self._ttsQueue = queue.Queue()
|
self._ttsQueue = queue.Queue()
|
||||||
self._stopper = Event()
|
self._stopper = Event()
|
||||||
|
self._lock = RLock()
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
self._startMonitor()
|
self._startMonitor()
|
||||||
|
@ -137,6 +138,7 @@ class SoundLib:
|
||||||
|
|
||||||
@async(daemon=False)
|
@async(daemon=False)
|
||||||
def _fader(self, lowerVolume, totalDuration, fadeDuration=0.2, stepSize=5):
|
def _fader(self, lowerVolume, totalDuration, fadeDuration=0.2, stepSize=5):
|
||||||
|
with self._lock:
|
||||||
alarm = self.soundEffects['triggered']
|
alarm = self.soundEffects['triggered']
|
||||||
alarmVolume = alarm.volume
|
alarmVolume = alarm.volume
|
||||||
alarmVolumeDelta = alarmVolume - lowerVolume
|
alarmVolumeDelta = alarmVolume - lowerVolume
|
||||||
|
@ -168,6 +170,7 @@ class SoundLib:
|
||||||
|
|
||||||
# will not change sounds that have preset volume
|
# will not change sounds that have preset volume
|
||||||
def _applyVolumesToSounds(self, volume):
|
def _applyVolumesToSounds(self, volume):
|
||||||
|
with self._lock:
|
||||||
self.volume = volume
|
self.volume = volume
|
||||||
v = volume/100
|
v = volume/100
|
||||||
s = self.soundEffects
|
s = self.soundEffects
|
||||||
|
|
Loading…
Reference in New Issue