Permalink
Browse files

Don't block the event loop for too long by only reading a few messages

  • Loading branch information...
1 parent 94f320a commit 490bb700a267a1efde40bd9abfb8a437af59a253 @alexcrichton alexcrichton committed Jun 30, 2012
Showing with 4 additions and 1 deletion.
  1. +4 −1 AudioStreamer/AudioStreamer.m
@@ -714,7 +714,10 @@ - (void)handleReadFromStream:(CFReadStreamRef)aStream
UInt8 bytes[2048];
CFIndex length;
- while (state_ != AS_STOPPED && CFReadStreamHasBytesAvailable(stream)) {
+ int i;
+ for (i = 0;
+ i < 3 && state_ != AS_STOPPED && CFReadStreamHasBytesAvailable(stream);
+ i++) {
length = CFReadStreamRead(stream, bytes, sizeof(bytes));
if (length < 0) {

0 comments on commit 490bb70

Please sign in to comment.