Fixed FFMPEG input hitting the end of the stream with samples already in the buffer causing it to live lock afterward

CQTexperiment
Chris Moeller 2014-04-26 15:38:45 -07:00
parent 7876eed573
commit d8817e8f3b
2 changed files with 4 additions and 2 deletions

View File

@ -34,6 +34,7 @@
int bytesConsumedFromDecodedFrame;
int bytesReadFromPacket;
BOOL readNextPacket;
BOOL endOfStream;
}
@end

View File

@ -155,6 +155,7 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op)
totalFrames = codecCtx->sample_rate * ((float)formatCtx->duration/AV_TIME_BASE);
bitrate = (codecCtx->bit_rate) / 1000;
framesRead = 0;
endOfStream = NO;
seekable = [s seekable];
@ -189,8 +190,6 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op)
int bytesToRead = frames * frameSize;
int bytesRead = 0;
BOOL endOfStream = NO;
int8_t* targetBuf = (int8_t*) buf;
memset(buf, 0, bytesToRead);
@ -306,6 +305,7 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op)
if (frame >= totalFrames)
{
framesRead = totalFrames;
endOfStream = YES;
return -1;
}
int64_t ts = frame * (formatCtx->duration) / totalFrames;
@ -314,6 +314,7 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op)
readNextPacket = YES; // so we immediately read next packet
bytesConsumedFromDecodedFrame = INT_MAX; // so we immediately begin decoding next frame
framesRead = frame;
endOfStream = NO;
return frame;
}