catch overflow errors during record

This commit is contained in:
Damien Elmes 2009-01-22 17:18:01 +09:00
parent 26272cba65
commit 5545f5f622

View file

@ -179,8 +179,15 @@ class PyAudioThreadedRecorder(threading.Thread):
frames_per_buffer=chunk)
all = []
while not self.finish:
data = stream.read(chunk)
all.append(data)
try:
data = stream.read(chunk)
except IOError, e:
if e[1] == pyaudio.paInputOverflowed:
data = None
else:
raise
if data:
all.append(data)
stream.close()
p.terminate()
data = ''.join(all)