Merged in changes.
commit
b795030bde
|
@ -59,7 +59,7 @@ escapeForLastFM(NSString *string)
|
|||
|
||||
- (semaphore_t) semaphore;
|
||||
|
||||
- (void) processAudioScrobblerCommands:(AudioScrobbler *)myself;
|
||||
- (void) processAudioScrobblerCommands:(id)unused;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -85,7 +85,7 @@ escapeForLastFM(NSString *string)
|
|||
return nil;
|
||||
}
|
||||
|
||||
[NSThread detachNewThreadSelector:@selector(processAudioScrobblerCommands:) toTarget:self withObject:self];
|
||||
[NSThread detachNewThreadSelector:@selector(processAudioScrobblerCommands:) toTarget:self withObject:nil];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ escapeForLastFM(NSString *string)
|
|||
return _semaphore;
|
||||
}
|
||||
|
||||
- (void) processAudioScrobblerCommands:(AudioScrobbler *)myself
|
||||
- (void) processAudioScrobblerCommands:(id)unused
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
AudioScrobblerClient *client = [[AudioScrobblerClient alloc] init];
|
||||
|
@ -200,18 +200,18 @@ escapeForLastFM(NSString *string)
|
|||
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];
|
||||
|
@ -234,14 +234,14 @@ escapeForLastFM(NSString *string)
|
|||
}
|
||||
}
|
||||
|
||||
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)])
|
||||
|
@ -256,7 +256,7 @@ escapeForLastFM(NSString *string)
|
|||
}
|
||||
|
||||
[client release];
|
||||
[myself setAudioScrobblerThreadCompleted:YES];
|
||||
[self setAudioScrobblerThreadCompleted:YES];
|
||||
|
||||
[pool release];
|
||||
}
|
||||
|
|
|
@ -188,42 +188,32 @@ addressForHost(NSString *hostname)
|
|||
{
|
||||
NSParameterAssert(INADDR_NONE != remoteAddress);
|
||||
|
||||
struct sockaddr_in socketAddress;
|
||||
int result;
|
||||
|
||||
_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);
|
||||
|
||||
result = connect(_socket, (const struct sockaddr *)&socketAddress, sizeof(struct sockaddr_in));
|
||||
|
||||
// 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));
|
||||
}
|
||||
}
|
||||
|
||||
// Don't log failures, because the client may not be running
|
||||
if(-1 == result) {
|
||||
close(_socket);
|
||||
|
||||
_socket = -1;
|
||||
_port = 0;
|
||||
_doPortStepping = NO;
|
||||
|
||||
return NO;
|
||||
}
|
||||
_port = port;
|
||||
|
||||
return YES;
|
||||
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;
|
||||
}
|
||||
|
||||
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));
|
||||
if(-1 == result) {
|
||||
close(_socket);
|
||||
_socket = -1;
|
||||
|
||||
_port++;
|
||||
}
|
||||
} while (YES == _doPortStepping && -1 == result && _port < (port + kPortsToStep));
|
||||
|
||||
return (-1 != result);
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
<!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>
|
||||
|
@ -89,7 +91,7 @@
|
|||
<key>CFBundleTypeIconFile</key>
|
||||
<string>ape.icns</string>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>Monkey's Audio File</string>
|
||||
<string>Monkey's Audio File</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Viewer</string>
|
||||
<key>LSTypeIsPackage</key>
|
||||
|
@ -429,7 +431,7 @@
|
|||
<key>NSPersistentStoreTypeKey</key>
|
||||
<string>Binary</string>
|
||||
</dict>
|
||||
</array>
|
||||
</array>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>Cog</string>
|
||||
<key>CFBundleHelpBookFolder</key>
|
||||
|
|
|
@ -157,7 +157,7 @@
|
|||
- (void)tableView:(NSTableView *)tableView
|
||||
didClickTableColumn:(NSTableColumn *)tableColumn
|
||||
{
|
||||
if ([self shuffle] == YES)
|
||||
if ([self shuffle] != ShuffleOff)
|
||||
[self resetShuffleList];
|
||||
}
|
||||
|
||||
|
@ -278,7 +278,7 @@
|
|||
|
||||
[acceptedURLs release];
|
||||
|
||||
if ([self shuffle] == YES)
|
||||
if ([self shuffle] != ShuffleOff)
|
||||
[self resetShuffleList];
|
||||
|
||||
return YES;
|
||||
|
@ -293,7 +293,7 @@
|
|||
{
|
||||
[super insertObjects:objects atArrangedObjectIndexes:indexes];
|
||||
|
||||
if ([self shuffle] == YES)
|
||||
if ([self shuffle] != ShuffleOff)
|
||||
[self resetShuffleList];
|
||||
}
|
||||
|
||||
|
@ -326,7 +326,7 @@
|
|||
|
||||
[super removeObjectsAtArrangedObjectIndexes:indexes];
|
||||
|
||||
if ([self shuffle] == YES)
|
||||
if ([self shuffle] != ShuffleOff)
|
||||
[self resetShuffleList];
|
||||
|
||||
[playbackController playlistDidChange:self];
|
||||
|
@ -360,7 +360,7 @@
|
|||
|
||||
[s release];
|
||||
|
||||
if ([self shuffle] == YES)
|
||||
if ([self shuffle] != ShuffleOff)
|
||||
[self resetShuffleList];
|
||||
}
|
||||
|
||||
|
@ -369,7 +369,7 @@
|
|||
[self setSortDescriptors:nil];
|
||||
|
||||
[self setContent:[Shuffle shuffleList:[self content]]];
|
||||
if ([self shuffle] == YES)
|
||||
if ([self shuffle] != ShuffleOff)
|
||||
[self resetShuffleList];
|
||||
}
|
||||
|
||||
|
@ -484,7 +484,7 @@
|
|||
return pe;
|
||||
}
|
||||
|
||||
if ([self shuffle] == YES)
|
||||
if ([self shuffle] != ShuffleOff)
|
||||
{
|
||||
return [self shuffledEntryAtIndex:(pe.shuffleIndex + 1)];
|
||||
}
|
||||
|
@ -532,7 +532,7 @@
|
|||
return pe;
|
||||
}
|
||||
|
||||
if ([self shuffle] == YES)
|
||||
if ([self shuffle] != ShuffleOff)
|
||||
{
|
||||
return [self shuffledEntryAtIndex:(pe.shuffleIndex - 1)];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue