Fixed FFMPEG input hitting the end of the stream with samples already in the buffer causing it to live lock afterward
parent
7876eed573
commit
d8817e8f3b
|
@ -34,6 +34,7 @@
|
|||
int bytesConsumedFromDecodedFrame;
|
||||
int bytesReadFromPacket;
|
||||
BOOL readNextPacket;
|
||||
BOOL endOfStream;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue