Skip to content
Permalink
Browse files

equalizer: Fix high CPU usage by waiting a tiny bit in case of no dat…

…a fetched from soundcard
  • Loading branch information...
pasky committed Dec 30, 2013
1 parent 987e4c8 commit f83be378124a5dd98379f405ad60ef461376095a
Showing with 4 additions and 1 deletion.
  1. +4 −1 host_python/equalizer.py
@@ -88,6 +88,7 @@ def print_usage():
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

0 comments on commit f83be37

Please sign in to comment.
You can’t perform that action at this time.