From 5545f5f622128884127f9b2f4fcb7d71237cea67 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 22 Jan 2009 17:18:01 +0900 Subject: [PATCH] catch overflow errors during record --- anki/sound.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/anki/sound.py b/anki/sound.py index d83ff4006..6a13ac24e 100644 --- a/anki/sound.py +++ b/anki/sound.py @@ -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)