Playback continues as expected when you moved a song that was at the end of the playlist.

CQTexperiment
vspader 2009-02-28 11:11:22 -08:00
parent 85630c836a
commit 384911beb6
2 changed files with 18 additions and 11 deletions

View File

@ -26,6 +26,7 @@
id delegate; id delegate;
BOOL outputLaunched; BOOL outputLaunched;
BOOL endOfInputReached;
} }
- (id)init; - (id)init;

View File

@ -24,6 +24,7 @@
output = NULL; output = NULL;
bufferChain = NULL; bufferChain = NULL;
outputLaunched = NO; outputLaunched = NO;
endOfInputReached = NO;
chainQueue = [[NSMutableArray alloc] init]; chainQueue = [[NSMutableArray alloc] init];
} }
@ -63,6 +64,7 @@
[anObject setShouldContinue:NO]; [anObject setShouldContinue:NO];
} }
[chainQueue removeAllObjects]; [chainQueue removeAllObjects];
endOfInputReached = NO;
if (bufferChain) if (bufferChain)
{ {
@ -168,10 +170,9 @@
- (void)resetNextStreams - (void)resetNextStreams
{ {
@synchronized (chainQueue) { @synchronized (chainQueue) {
NSUInteger count = [chainQueue count];
[chainQueue removeAllObjects]; [chainQueue removeAllObjects];
if (count) { if (endOfInputReached) {
[self endOfInputReached:bufferChain]; [self endOfInputReached:bufferChain];
} }
} }
@ -223,15 +224,17 @@
- (BOOL)endOfInputReached:(BufferChain *)sender //Sender is a BufferChain - (BOOL)endOfInputReached:(BufferChain *)sender //Sender is a BufferChain
{ {
BufferChain *newChain = nil;
nextStreamUserInfo = [sender userInfo];
[nextStreamUserInfo retain]; //Retained because when setNextStream is called, it will be released!!!
[self requestNextStream: nextStreamUserInfo];
newChain = [[BufferChain alloc] initWithController:self];
@synchronized (chainQueue) { @synchronized (chainQueue) {
BufferChain *newChain = nil;
nextStreamUserInfo = [sender userInfo];
[nextStreamUserInfo retain]; //Retained because when setNextStream is called, it will be released!!!
[self requestNextStream: nextStreamUserInfo];
newChain = [[BufferChain alloc] initWithController:self];
endOfInputReached = YES;
BufferChain *lastChain = [chainQueue lastObject]; BufferChain *lastChain = [chainQueue lastObject];
if (lastChain == nil) { if (lastChain == nil) {
lastChain = bufferChain; lastChain = bufferChain;
@ -270,8 +273,9 @@
} }
[self addChainToQueue:newChain]; [self addChainToQueue:newChain];
[newChain release];
} }
[newChain release];
return YES; return YES;
} }
@ -281,6 +285,8 @@
@synchronized(chainQueue) { @synchronized(chainQueue) {
if ([chainQueue count] <= 0) if ([chainQueue count] <= 0)
{ {
endOfInputReached = NO;
//End of playlist //End of playlist
[self stop]; [self stop];