Permalink
Browse files

Allow discard of received-message overflow

  • Loading branch information...
1 parent b899731 commit 9ba1116955ff24152c14e555f4f2a44c8c81b95f Jonathan del Strother committed Sep 10, 2009
Showing with 12 additions and 2 deletions.
  1. +1 −0 BBOSCPluginReceiver.h
  2. +11 −2 BBOSCPluginReceiver.m
@@ -19,6 +19,7 @@
@property (nonatomic, readonly, retain) OSCInPort *oscPort;
+@property (nonatomic, readwrite, assign) BOOL inputDiscardExcessMessages;
@property (nonatomic, readwrite, assign) NSUInteger inputReceivingPort;
@property (nonatomic, readwrite, assign) NSString* inputReceivingPath;
@property (nonatomic, readwrite, assign) BOOL outputMessageReceived;
View
@@ -24,7 +24,7 @@ @interface BBOSCPluginReceiver ()
@end
@implementation BBOSCPluginReceiver
-@dynamic inputReceivingPort, inputReceivingPath, outputMessageReceived, outputMessagePath;
+@dynamic inputDiscardExcessMessages, inputReceivingPort, inputReceivingPath, outputMessageReceived, outputMessagePath;
@synthesize oscPort, oscParameters, listeningPath;
+ (NSDictionary*) attributes
@@ -45,6 +45,10 @@ Specify the optional attributes for property based ports (QCPortAttributeNameKey
return [NSDictionary dictionaryWithObjectsAndKeys:@"Receiving Port", QCPortAttributeNameKey,
[NSNumber numberWithInt:60000], QCPortAttributeDefaultValueKey, nil];
}
+ if ([key isEqualToString:@"inputDiscardExcessMessages"]) {
+ return [NSDictionary dictionaryWithObjectsAndKeys:@"Discard Excess Messages", QCPortAttributeNameKey,
+ [NSNumber numberWithBool:NO], QCPortAttributeDefaultValueKey, nil];
+ }
if ([key isEqualToString:@"inputReceivingPath"]) {
return [NSDictionary dictionaryWithObjectsAndKeys:@"Receiving Path", QCPortAttributeNameKey,
@"", QCPortAttributeDefaultValueKey, nil];
@@ -216,7 +220,12 @@ Return NO in case of failure during the execution (this will prevent rendering o
self.outputMessagePath = [message address];
- [messages removeObjectAtIndex:0];
+ // If we want to be super-responsive, trash any extra messages that are received that we didn't get around to processing this frame
+ // If we want to catch every single message, leave them in a queue to be processed in a later frame.
+ if (self.inputDiscardExcessMessages)
+ [messages removeAllObjects];
+ else
+ [messages removeObjectAtIndex:0];
}
[messageLock unlock];

0 comments on commit 9ba1116

Please sign in to comment.