mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-26 12:53:12 -06:00
Fixed sound.py when there are multiple sessions trying to load the library
This commit is contained in:
parent
d4b410cafd
commit
80f2e8f984
33
src/sound.py
33
src/sound.py
@ -22,6 +22,8 @@ import tempfile
|
|||||||
import glob
|
import glob
|
||||||
URLPlayer = None
|
URLPlayer = None
|
||||||
|
|
||||||
|
is_created = False
|
||||||
|
|
||||||
def setup():
|
def setup():
|
||||||
global URLPlayer
|
global URLPlayer
|
||||||
if not URLPlayer:
|
if not URLPlayer:
|
||||||
@ -58,23 +60,26 @@ class soundSystem(object):
|
|||||||
|
|
||||||
def __init__(self, soundConfig):
|
def __init__(self, soundConfig):
|
||||||
""" Sound Player."""
|
""" Sound Player."""
|
||||||
|
global is_created
|
||||||
self.config = soundConfig
|
self.config = soundConfig
|
||||||
# Set the output and input default devices.
|
# Set the output and input default devices.
|
||||||
try:
|
if is_created == False:
|
||||||
self.output = Output()
|
try:
|
||||||
self.input = Input()
|
self.output = Output()
|
||||||
except IOError:
|
self.input = Input()
|
||||||
pass
|
except IOError:
|
||||||
|
pass
|
||||||
# Try to use the selected device from the configuration. It can fail if the machine does not has a mic.
|
# Try to use the selected device from the configuration. It can fail if the machine does not has a mic.
|
||||||
try:
|
if is_created == False:
|
||||||
log.debug("Setting input and output devices...")
|
try:
|
||||||
self.output.set_device(self.output.find_device_by_name(self.config["output_device"]))
|
log.debug("Setting input and output devices...")
|
||||||
self.input.set_device(self.input.find_device_by_name(self.config["input_device"]))
|
self.output.set_device(self.output.find_device_by_name(self.config["output_device"]))
|
||||||
except:
|
self.input.set_device(self.input.find_device_by_name(self.config["input_device"]))
|
||||||
log.exception("Error in input or output devices, using defaults...")
|
except:
|
||||||
self.config["output_device"] = "Default"
|
log.exception("Error in input or output devices, using defaults...")
|
||||||
self.config["input_device"] = "Default"
|
self.config["output_device"] = "Default"
|
||||||
|
self.config["input_device"] = "Default"
|
||||||
|
is_created = True
|
||||||
self.files = []
|
self.files = []
|
||||||
self.cleaner = RepeatingTimer(60, self.clear_list)
|
self.cleaner = RepeatingTimer(60, self.clear_list)
|
||||||
self.cleaner.start()
|
self.cleaner.start()
|
||||||
|
Loading…
Reference in New Issue
Block a user