clean up main and soundlib

This commit is contained in:
petrucci4prez 2017-06-03 01:55:06 -04:00
parent 0fc324cb7b
commit 4183309c12
2 changed files with 3 additions and 8 deletions

View File

@ -37,8 +37,6 @@ if __name__ == '__main__':
stateMachine = StateMachine() stateMachine = StateMachine()
# TODO: segfaults are annoying :(
#~ signal.signal(signal.SIGSEGV, sig_handler)
signal.signal(signal.SIGTERM, sigtermHandler) signal.signal(signal.SIGTERM, sigtermHandler)
excChildListener() excChildListener()

View File

@ -10,6 +10,7 @@ logger = logging.getLogger(__name__)
# TODO: figure out why we have buffer underruns # TODO: figure out why we have buffer underruns
# TODO: why does the mixer segfault? (at least I think that's the cuprit) # TODO: why does the mixer segfault? (at least I think that's the cuprit)
# TODO: stop all sounds before shutting down mixer
class SoundEffect(mixer.Sound): class SoundEffect(mixer.Sound):
def __init__(self, path, volume=None, loops=0): def __init__(self, path, volume=None, loops=0):
super().__init__(path) super().__init__(path)
@ -143,18 +144,15 @@ class SoundLib:
for name, sound in s.items(): for name, sound in s.items():
sound.set_volume(v) sound.set_volume(v)
# TODO: maybe could simply now that we are not using MP for TTS
def _ttsMonitor(self): def _ttsMonitor(self):
q = self._ttsQueue q = self._ttsQueue
has_task_done = hasattr(q, 'task_done')
while not self._stop.isSet(): while not self._stop.isSet():
try: try:
text = self._ttsQueue.get(True) text = self._ttsQueue.get(True)
if text is self._sentinel: if text is self._sentinel:
break break
self._playSpeech(text) self._playSpeech(text)
if has_task_done: q.task_done()
q.task_done()
except queue.Empty: except queue.Empty:
pass pass
# There might still be records in the queue. # There might still be records in the queue.
@ -164,8 +162,7 @@ class SoundLib:
if text is self._sentinel: if text is self._sentinel:
break break
self._playSpeech(text) self._playSpeech(text)
if has_task_done: q.task_done()
q.task_done()
except queue.Empty: except queue.Empty:
break break