mirror of https://github.com/Syncplay/syncplay
Fix for exception due to missing buzzer.wav
This commit is contained in:
parent
cbdf10075e
commit
38669acc44
|
@ -15,21 +15,24 @@ def doBuzz():
|
||||||
winsound.PlaySound(buzzPath, winsound.SND_FILENAME|winsound.SND_ASYNC)
|
winsound.PlaySound(buzzPath, winsound.SND_FILENAME|winsound.SND_ASYNC)
|
||||||
elif(alsaaudio):
|
elif(alsaaudio):
|
||||||
buzzPath = utils.findWorkingDir() + "/resources/buzzer.wav"
|
buzzPath = utils.findWorkingDir() + "/resources/buzzer.wav"
|
||||||
buzz = wave.open(buzzPath, 'rb')
|
print buzzPath
|
||||||
device = alsaaudio.PCM(0)
|
try:
|
||||||
device.setchannels(buzz.getnchannels())
|
buzz = wave.open(buzzPath, 'rb')
|
||||||
device.setrate(buzz.getframerate())
|
device = alsaaudio.PCM(0)
|
||||||
if buzz.getsampwidth() == 1:
|
device.setchannels(buzz.getnchannels())
|
||||||
device.setformat(alsaaudio.PCM_FORMAT_U8)
|
device.setrate(buzz.getframerate())
|
||||||
elif buzz.getsampwidth() == 2:
|
if buzz.getsampwidth() == 1:
|
||||||
device.setformat(alsaaudio.PCM_FORMAT_S16_LE)
|
device.setformat(alsaaudio.PCM_FORMAT_U8)
|
||||||
else:
|
elif buzz.getsampwidth() == 2:
|
||||||
raise ValueError('Unsupported buzzer format')
|
device.setformat(alsaaudio.PCM_FORMAT_S16_LE)
|
||||||
device.setperiodsize(640)
|
else:
|
||||||
data = buzz.readframes(640)
|
raise ValueError('Unsupported buzzer format')
|
||||||
while data:
|
device.setperiodsize(640)
|
||||||
device.write(data)
|
|
||||||
data = buzz.readframes(640)
|
data = buzz.readframes(640)
|
||||||
buzz.close()
|
while data:
|
||||||
|
device.write(data)
|
||||||
|
data = buzz.readframes(640)
|
||||||
|
buzz.close()
|
||||||
|
except IOError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue