Added some error messages that should hopefully fix some initial stuttering issues.

CQTexperiment
vspader 2007-03-19 00:19:47 +00:00
parent 2a0b588f4d
commit 77c7819dd6
6 changed files with 35 additions and 3 deletions

View File

@ -22,6 +22,8 @@
id nextStreamUserInfo; id nextStreamUserInfo;
id delegate; id delegate;
BOOL outputLaunched;
} }
- (id)init; - (id)init;
@ -65,6 +67,7 @@
- (void)endOfInputReached:(BufferChain *)sender; - (void)endOfInputReached:(BufferChain *)sender;
- (void)setShouldContinue:(BOOL)s; - (void)setShouldContinue:(BOOL)s;
- (BufferChain *)bufferChain; - (BufferChain *)bufferChain;
- (void)launchOutputThread;
- (void)endOfInputPlayed; - (void)endOfInputPlayed;
- (void)sendDelegateMethod:(SEL)selector withObject:(id)obj waitUntilDone:(BOOL)wait; - (void)sendDelegateMethod:(SEL)selector withObject:(id)obj waitUntilDone:(BOOL)wait;
@end @end

View File

@ -22,6 +22,7 @@
{ {
output = NULL; output = NULL;
bufferChain = NULL; bufferChain = NULL;
outputLaunched = NO;
chainQueue = [[NSMutableArray alloc] init]; chainQueue = [[NSMutableArray alloc] init];
} }
@ -91,9 +92,9 @@
[bufferChain setUserInfo:userInfo]; [bufferChain setUserInfo:userInfo];
[self setShouldContinue:YES]; [self setShouldContinue:YES];
DBLog(@"DETACHING THREADS");
[output launchThread]; outputLaunched = NO;
NSLog(@"Launching input thread!");
[bufferChain launchThreads]; [bufferChain launchThreads];
[self setPlaybackStatus:kCogStatusPlaying]; [self setPlaybackStatus:kCogStatusPlaying];
@ -165,6 +166,13 @@
return [output amountPlayed]; return [output amountPlayed];
} }
- (void)launchOutputThread
{
if (outputLaunched == NO) {
NSLog(@"Launching output thread!");
[output launchThread];
}
}

View File

@ -40,6 +40,8 @@
- (void)setShouldContinue:(BOOL)s; - (void)setShouldContinue:(BOOL)s;
- (void)initialBufferFilled;
- (void)endOfInputReached; - (void)endOfInputReached;

View File

@ -107,6 +107,11 @@
[controller endOfInputReached:self]; [controller endOfInputReached:self];
} }
- (void)initialBufferFilled
{
[controller launchOutputThread];
}
- (id)finalNode - (id)finalNode
{ {

View File

@ -24,6 +24,7 @@
BOOL shouldContinue; BOOL shouldContinue;
BOOL endOfStream; //All data is now in buffer BOOL endOfStream; //All data is now in buffer
BOOL initialBufferFilled;
} }
- (id)initWithController:(id)c previous:(id)p; - (id)initWithController:(id)c previous:(id)p;

View File

@ -20,6 +20,8 @@
readLock = [[NSLock alloc] init]; readLock = [[NSLock alloc] init];
writeLock = [[NSLock alloc] init]; writeLock = [[NSLock alloc] init];
initialBufferFilled = NO;
controller = c; controller = c;
previousNode = p; previousNode = p;
endOfStream = NO; endOfStream = NO;
@ -43,6 +45,11 @@
if (availOutput == 0) if (availOutput == 0)
{ {
[writeLock unlock]; [writeLock unlock];
if (initialBufferFilled == NO) {
initialBufferFilled = YES;\
if ([controller respondsToSelector:@selector(initialBufferFilled)])
[controller performSelector:@selector(initialBufferFilled)];
}
[semaphore wait]; [semaphore wait];
[writeLock lock]; [writeLock lock];
} }
@ -105,6 +112,12 @@
//else //else
endOfStream = YES; endOfStream = YES;
} }
if (availInput <= 0) {
NSLog(@"BUFFER RAN DRY!");
}
else if (availInput < amount) {
NSLog(@"BUFFER IN DANGER");
}
amountToCopy = availInput; amountToCopy = availInput;
if (amountToCopy > amount) if (amountToCopy > amount)