Use a sample to indicate a reader EOF.

This commit is contained in:
Damiano Galassi committed 2016-07-23 17:20:31 +02:00
1 parent 54437f9030
commit 6a2b4a1fad
12 files changed
+121 -71

No files matched your search

+18 -5
View File
@@ -255,6 +255,7 @@ OSStatus EncoderDataProc(AudioConverterRef inAudioConverter,
AudioConverterDispose(converterEnc);
[self enqueueEndOfFileSample];
encoderDone = YES;
}
@@ -666,7 +667,12 @@ OSStatus DecoderDataProc(AudioConverterRef inAudioConverter,
}
- (void)addSample:(MP42SampleBuffer *)sample {
[_inputSamplesBuffer enqueue:sample];
if (sample->flags & MP42SampleBufferFlagEndOfFile) {
[self setInputDone];
}
else {
[_inputSamplesBuffer enqueue:sample];
}
}
- (MP42SampleBuffer *)copyEncodedSample {
@@ -678,6 +684,17 @@ OSStatus DecoderDataProc(AudioConverterRef inAudioConverter,
encoderData.fileReaderDone = YES;
}
/**
* Sends the EOF flag down the muxer chain.
*/
- (void)enqueueEndOfFileSample
{
MP42SampleBuffer *sample = [[MP42SampleBuffer alloc] init];
sample->flags |= MP42SampleBufferFlagEndOfFile;
[_outputSamplesBuffer enqueue:sample];
[sample release];
}
- (void)cancel {
OSAtomicIncrement32(&_cancelled);
@@ -692,10 +709,6 @@ OSStatus DecoderDataProc(AudioConverterRef inAudioConverter,
}
}
- (BOOL)encoderDone {
return encoderDone && [_outputSamplesBuffer isEmpty];
}
- (NSData *)magicCookie {
return [[outputMagicCookie retain] autorelease];
}