Anonymous avatar Anonymous committed 1c680e2 Merge

Merged in changes.

Comments (0)

Files changed (4)

AudioScrobbler/AudioScrobbler.m

 
 - (semaphore_t)			semaphore;
 
-- (void)				processAudioScrobblerCommands:(AudioScrobbler *)myself;
+- (void)				processAudioScrobblerCommands:(id)unused;
 
 @end
 
 			return nil;
 		}
 		
-		[NSThread detachNewThreadSelector:@selector(processAudioScrobblerCommands:) toTarget:self withObject:self];
+		[NSThread detachNewThreadSelector:@selector(processAudioScrobblerCommands:) toTarget:self withObject:nil];
 	}
 	return self;
 }
 	return _semaphore;
 }
 
-- (void) processAudioScrobblerCommands:(AudioScrobbler *)myself
+- (void) processAudioScrobblerCommands:(id)unused
 {
 	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
 	AudioScrobblerClient	*client				= [[AudioScrobblerClient alloc] init];
 	NSString				*response			= nil;
 	in_port_t				port				= 33367;
 	
-	while([myself keepProcessingAudioScrobblerCommands]) {
+	while([self keepProcessingAudioScrobblerCommands]) {
 		NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
 
 		// Get the first command to be sent
-		@synchronized([myself queue]) {
-			enumerator	= [[myself queue] objectEnumerator];
+		@synchronized([self queue]) {
+			enumerator	= [[self queue] objectEnumerator];
 			command		= [[enumerator nextObject] retain];
 		
-			[[myself queue] removeObjectIdenticalTo:command];
+			[[self queue] removeObjectIdenticalTo:command];
 		}
 
-		if(nil != command) {
+		if(nil != command) { 
 			@try {
 				if([client connectToHost:@"localhost" port:port]) {
 					port = [client connectedPort];
 			}
 		}
 		
-		semaphore_timedwait([myself semaphore], timeout);
+		semaphore_timedwait([self semaphore], timeout);
 		[pool release];
 	}
 	
 	// Send a final stop command to cleanup
 	@try {
 		if([client connectToHost:@"localhost" port:port]) {
-			[client send:[NSString stringWithFormat:@"STOP c=%@\n", [myself pluginID]]];
+			[client send:[NSString stringWithFormat:@"STOP c=%@\n", [self pluginID]]];
 			
 			response = [client receive];
 			if(2 > [response length] || NSOrderedSame != [response compare:@"OK" options:NSLiteralSearch range:NSMakeRange(0,2)])
 	}
 	
 	[client release];
-	[myself setAudioScrobblerThreadCompleted:YES];
+	[self setAudioScrobblerThreadCompleted:YES];
 
 	[pool release];
 }

AudioScrobbler/AudioScrobblerClient.m

 {
 	NSParameterAssert(INADDR_NONE != remoteAddress);
 	
-	struct sockaddr_in		socketAddress;
-	int						result;
+	_port = port;
+	
+	int result;
+	do {
+		struct sockaddr_in		socketAddress;
 
-	_socket = socket(AF_INET, SOCK_STREAM, 0);
-	if(-1 == _socket) {
-		NSLog(@"Unable to create socket (%s)", strerror(errno));
-		return NO;
-	}
+		_socket = socket(AF_INET, SOCK_STREAM, 0);
+		if(-1 == _socket) {
+			NSLog(@"Unable to create socket (%s)", strerror(errno));
+			return NO;
+		}
 
-	_port							= port;
-	socketAddress.sin_family		= AF_INET;
-	socketAddress.sin_addr.s_addr	= remoteAddress;
-	socketAddress.sin_port			= htons(_port);
+		socketAddress.sin_family		= AF_INET;
+		socketAddress.sin_addr.s_addr	= remoteAddress;
+		socketAddress.sin_port			= htons(_port);
 
-	result = connect(_socket, (const struct sockaddr *)&socketAddress, sizeof(struct sockaddr_in));
+		result = connect(_socket, (const struct sockaddr *)&socketAddress, sizeof(struct sockaddr_in));
+		if(-1 == result) {
+			close(_socket);
+			_socket = -1;
 
-	// Don't check result yet
-	if(_doPortStepping) {
-		while(-1 == result && _port <= (port + kPortsToStep)) {
-			socketAddress.sin_port = htons(++_port);
-			result = connect(_socket, (const struct sockaddr *)&socketAddress, sizeof(struct sockaddr_in));
+			_port++;
 		}
-	}
+	} while (YES == _doPortStepping && -1 == result && _port < (port + kPortsToStep));
 
-	// Don't log failures, because the client may not be running
-	if(-1 == result) {
-		close(_socket);
-		
-		_socket				= -1;
-		_port				= 0;
-		_doPortStepping		= NO;
-		
-		return NO;
-	}
-	
-	return YES;
+	return (-1 != result);
 }
 
 @end
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
+	<key>LSMinimumSystemVersion</key>
+	<string>10.5.0</string>
 	<key>CFBundleDevelopmentRegion</key>
 	<string>English</string>
 	<key>CFBundleDocumentTypes</key>
 			<key>CFBundleTypeIconFile</key>
 			<string>ape.icns</string>
 			<key>CFBundleTypeName</key>
-			<string>Monkey's Audio File</string>
+			<string>Monkey&apos;s Audio File</string>
 			<key>CFBundleTypeRole</key>
 			<string>Viewer</string>
 			<key>LSTypeIsPackage</key>
 			<key>NSPersistentStoreTypeKey</key>
 			<string>Binary</string>
 		</dict>
-</array>
+	</array>
 	<key>CFBundleExecutable</key>
 	<string>Cog</string>
 	<key>CFBundleHelpBookFolder</key>

Playlist/PlaylistController.m

 - (void)tableView:(NSTableView *)tableView
 		didClickTableColumn:(NSTableColumn *)tableColumn
 {
-	if ([self shuffle] == YES)
+	if ([self shuffle] != ShuffleOff)
 		[self resetShuffleList];
 }
 
 	
 	[acceptedURLs release];
 	
-	if ([self shuffle] == YES)
+	if ([self shuffle] != ShuffleOff)
 		[self resetShuffleList];
 	
 	return YES;
 {
 	[super insertObjects:objects atArrangedObjectIndexes:indexes];
 	
-	if ([self shuffle] == YES)
+	if ([self shuffle] != ShuffleOff)
 		[self resetShuffleList];
 }
 
 	
 	[super removeObjectsAtArrangedObjectIndexes:indexes];
 	
-	if ([self shuffle] == YES)
+	if ([self shuffle] != ShuffleOff)
 		[self resetShuffleList];
 
 	[playbackController playlistDidChange:self];
 
 	[s release];	
 
-	if ([self shuffle] == YES)
+	if ([self shuffle] != ShuffleOff)
 		[self resetShuffleList];
 }
 
 	[self setSortDescriptors:nil];
 
 	[self setContent:[Shuffle shuffleList:[self content]]];
-	if ([self shuffle] == YES)
+	if ([self shuffle] != ShuffleOff)
 		[self resetShuffleList];
 }
 
 		return pe;
 	}
 	
-	if ([self shuffle] == YES)
+	if ([self shuffle] != ShuffleOff)
 	{
 		return [self shuffledEntryAtIndex:(pe.shuffleIndex + 1)];
 	}
 		return pe;
 	}
 	
-	if ([self shuffle] == YES)
+	if ([self shuffle] != ShuffleOff)
 	{
 		return [self shuffledEntryAtIndex:(pe.shuffleIndex - 1)];
 	}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.