equalizer: Fix high CPU usage by waiting a tiny bit in case of no data fetched from soundcard

This commit is contained in:
Petr Baudis 2013-12-30 17:49:40 +01:00
parent 987e4c8182
commit f83be37812

View file

@ -88,6 +88,7 @@ else:
SAMPLE_SIZE = CHUNK_SIZE*HISTORY_SIZE
FREQ_STEP = float(RATE) / (CHUNK_SIZE * HISTORY_SIZE)
PIXEL_FREQ_RANGE = math.pow(float(MAX_FREQ) / MIN_FREQ, 1.0/EPIXELS)
CHUNK_PERIOD = 1.0 / (RATE / CHUNK_SIZE)
def with_stream( fnc ):
@ -141,7 +142,9 @@ def loop( stream ):
while work:
try: data = stream.read(CHUNK_SIZE)
except IOError: continue
except IOError:
time.sleep(CHUNK_PERIOD)
continue
nowtrig = datetime.now().microsecond / 50000
if (nowtrig == nexttrig):
continue