Fixed FFMPEG input hitting the end of the stream with samples already in the buffer causing it to live lock afterward
This commit is contained in:
parent
7876eed573
commit
d8817e8f3b
2 changed files with 4 additions and 2 deletions
|
@ -34,6 +34,7 @@
|
||||||
int bytesConsumedFromDecodedFrame;
|
int bytesConsumedFromDecodedFrame;
|
||||||
int bytesReadFromPacket;
|
int bytesReadFromPacket;
|
||||||
BOOL readNextPacket;
|
BOOL readNextPacket;
|
||||||
|
BOOL endOfStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -155,6 +155,7 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op)
|
||||||
totalFrames = codecCtx->sample_rate * ((float)formatCtx->duration/AV_TIME_BASE);
|
totalFrames = codecCtx->sample_rate * ((float)formatCtx->duration/AV_TIME_BASE);
|
||||||
bitrate = (codecCtx->bit_rate) / 1000;
|
bitrate = (codecCtx->bit_rate) / 1000;
|
||||||
framesRead = 0;
|
framesRead = 0;
|
||||||
|
endOfStream = NO;
|
||||||
|
|
||||||
seekable = [s seekable];
|
seekable = [s seekable];
|
||||||
|
|
||||||
|
@ -189,8 +190,6 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op)
|
||||||
int bytesToRead = frames * frameSize;
|
int bytesToRead = frames * frameSize;
|
||||||
int bytesRead = 0;
|
int bytesRead = 0;
|
||||||
|
|
||||||
BOOL endOfStream = NO;
|
|
||||||
|
|
||||||
int8_t* targetBuf = (int8_t*) buf;
|
int8_t* targetBuf = (int8_t*) buf;
|
||||||
memset(buf, 0, bytesToRead);
|
memset(buf, 0, bytesToRead);
|
||||||
|
|
||||||
|
@ -306,6 +305,7 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op)
|
||||||
if (frame >= totalFrames)
|
if (frame >= totalFrames)
|
||||||
{
|
{
|
||||||
framesRead = totalFrames;
|
framesRead = totalFrames;
|
||||||
|
endOfStream = YES;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int64_t ts = frame * (formatCtx->duration) / totalFrames;
|
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
|
readNextPacket = YES; // so we immediately read next packet
|
||||||
bytesConsumedFromDecodedFrame = INT_MAX; // so we immediately begin decoding next frame
|
bytesConsumedFromDecodedFrame = INT_MAX; // so we immediately begin decoding next frame
|
||||||
framesRead = frame;
|
framesRead = frame;
|
||||||
|
endOfStream = NO;
|
||||||
|
|
||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue