Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Retry port setup when it fails

  • Loading branch information...
commit 71581cbc5a5f382aec055a2b9c7823ce9e075569 1 parent 03228b3
Jonathan del Strother authored
Showing with 14 additions and 7 deletions.
  1. +2 −3 BBOSCPluginReceiver.h
  2. +12 −4 BBOSCPluginReceiver.m
View
5 BBOSCPluginReceiver.h
@@ -13,10 +13,9 @@
NSMutableArray* messages;
}
@property (nonatomic, readonly, retain) NSString* listeningPath;
-
@property (nonatomic, readonly, retain) NSArray* oscParameters;
-
-@property (nonatomic, readonly, retain) BBOSCInPort *oscPort;
+@property (nonatomic, readonly, retain) BBOSCInPort *oscPort;
+@property (nonatomic, readonly, retain) NSDate* retryTime;
@property (nonatomic, readwrite, assign) BOOL inputDiscardExcessMessages;
@property (nonatomic, readwrite, assign) NSUInteger inputReceivingPort;
View
16 BBOSCPluginReceiver.m
@@ -21,11 +21,12 @@ @interface BBOSCPluginReceiver ()
@property (nonatomic, readwrite, retain) BBOSCInPort *oscPort;
@property (nonatomic, readwrite, retain) NSArray* oscParameters;
@property (nonatomic, readwrite, retain) NSString* listeningPath;
+@property (nonatomic, readwrite, retain) NSDate* retryTime;
@end
@implementation BBOSCPluginReceiver
@dynamic inputDiscardExcessMessages, inputReceivingPort, inputReceivingPath, inputLabel, outputError, outputMessageReceived, outputMessagePath;
-@synthesize oscPort, oscParameters, listeningPath;
+@synthesize oscPort, oscParameters, listeningPath, retryTime;
+ (NSDictionary*) attributes
{
@@ -111,6 +112,7 @@ - (void) dealloc
[messages release];
[listeningPath release];
[oscParameters release];
+ [retryTime release];
[super dealloc];
}
@@ -189,7 +191,7 @@ Return NO in case of failure during the execution (this will prevent rendering o
[messages removeAllObjects];
}
- if ([self didValueForInputKeyChange:@"inputReceivingPort"]||[self didValueForInputKeyChange:@"inputLabel"]) {
+ if ([self didValueForInputKeyChange:@"inputReceivingPort"]||[self didValueForInputKeyChange:@"inputLabel"] || (self.retryTime && [self.retryTime timeIntervalSinceNow]<0)) {
if (self.oscPort) {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; // OSC only closes the socket once the port gets dealloced - be careful to force it to release as soon as possible
[[BBOSCManager sharedManager] removeInput:self.oscPort];
@@ -202,9 +204,15 @@ Return NO in case of failure during the execution (this will prevent rendering o
label = [NSString stringWithFormat:@"BBOSC-%u", self.inputReceivingPort];
self.oscPort = [[BBOSCManager sharedManager] createNewInputForPort:self.inputReceivingPort withLabel:label];
[self.oscPort addDelegate:self];
- if (!self.oscPort)
+
+ if (self.oscPort) {
+ self.retryTime = nil;
+ self.outputError = NO;
+ } else {
NSLog(@"Failed to create input port");
- self.outputError = !self.oscPort;
+ self.retryTime = [NSDate dateWithTimeIntervalSinceNow:1];
+ self.outputError = YES;
+ }
}
if ([messages count]==0) {
Please sign in to comment.
Something went wrong with that request. Please try again.