Fixed some synchronization problems.
parent
e78a961fa3
commit
2e44b9833e
|
@ -209,6 +209,7 @@
|
|||
[self requestNextStream: nextStreamUserInfo];
|
||||
newChain = [[BufferChain alloc] initWithController:self];
|
||||
|
||||
@synchronized (chainQueue) {
|
||||
BufferChain *lastChain = [chainQueue lastObject];
|
||||
if (lastChain == nil) {
|
||||
lastChain = bufferChain;
|
||||
|
@ -247,7 +248,7 @@
|
|||
}
|
||||
|
||||
[self addChainToQueue:newChain];
|
||||
|
||||
}
|
||||
[newChain release];
|
||||
|
||||
return YES;
|
||||
|
@ -255,6 +256,7 @@
|
|||
|
||||
- (void)endOfInputPlayed
|
||||
{
|
||||
@synchronized(chainQueue) {
|
||||
if ([chainQueue count] <= 0)
|
||||
{
|
||||
//End of playlist
|
||||
|
@ -268,7 +270,6 @@
|
|||
|
||||
[bufferChain release];
|
||||
|
||||
@synchronized(chainQueue) {
|
||||
bufferChain = [chainQueue objectAtIndex:0];
|
||||
[bufferChain retain];
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ static OSStatus ACInputProc(AudioConverterRef inAudioConverter, UInt32* ioNumber
|
|||
converter->callbackBuffer = malloc(amountToWrite);
|
||||
|
||||
amountRead = [converter readData:converter->callbackBuffer amount:amountToWrite];
|
||||
if (amountRead == 0)
|
||||
if (amountRead == 0 && [converter endOfStream] == NO)
|
||||
{
|
||||
ioData->mBuffers[0].mDataByteSize = 0;
|
||||
*ioNumberDataPackets = 0;
|
||||
|
@ -70,20 +70,10 @@ static OSStatus ACInputProc(AudioConverterRef inAudioConverter, UInt32* ioNumber
|
|||
-(void)process
|
||||
{
|
||||
char writeBuf[CHUNK_SIZE];
|
||||
int amountConverted;
|
||||
|
||||
|
||||
while ([self shouldContinue] == YES) //Need to watch EOS somehow....
|
||||
while ([self shouldContinue] == YES && [self endOfStream] == NO) //Need to watch EOS somehow....
|
||||
{
|
||||
amountConverted = [self convert:writeBuf amount:CHUNK_SIZE];
|
||||
|
||||
// NSLog(@"Amount converted %@: %i %i", self, amountConverted, [self endOfStream]);
|
||||
if (amountConverted == 0 && [self endOfStream] == YES)
|
||||
{
|
||||
// NSLog(@"END OF STREAM FOR ZINE DINNER!!!!");
|
||||
return;
|
||||
}
|
||||
|
||||
int amountConverted = [self convert:writeBuf amount:CHUNK_SIZE];
|
||||
[self writeData:writeBuf amount:amountConverted];
|
||||
}
|
||||
}
|
||||
|
@ -101,12 +91,16 @@ static OSStatus ACInputProc(AudioConverterRef inAudioConverter, UInt32* ioNumber
|
|||
ioData.mNumberBuffers = 1;
|
||||
|
||||
err = AudioConverterFillComplexBuffer(converter, ACInputProc, self, &ioNumberFrames, &ioData, NULL);
|
||||
int amountRead = ioData.mBuffers[0].mDataByteSize;
|
||||
if (err == kAudioConverterErr_InvalidInputSize) //It returns insz at EOS at times...so run it again to make sure all data is converted
|
||||
{
|
||||
return [self convert:dest amount:amount];
|
||||
NSLog(@"INSIZE: %i", amountRead);
|
||||
amountRead += [self convert:dest + amountRead amount:amount - amountRead];
|
||||
}
|
||||
|
||||
return ioData.mBuffers[0].mDataByteSize;
|
||||
NSLog(@"Amount read: %i/%i", amountRead, amount);
|
||||
|
||||
return amountRead;
|
||||
}
|
||||
|
||||
- (BOOL)setupWithInputFormat:(AudioStreamBasicDescription)inf outputFormat:(AudioStreamBasicDescription)outf
|
||||
|
|
Loading…
Reference in New Issue