FFmpeg Input: Fix format changes
Format changes should only occur on whole packet intervals. Signed-off-by: Christopher Snowhill <kode54@gmail.com>CQTexperiment
parent
90ce0e5ae4
commit
4fd24838fa
|
@ -553,6 +553,24 @@ int64_t ffmpeg_seek(void *opaque, int64_t offset, int whence) {
|
||||||
seekBytesSkip -= minSkipped;
|
seekBytesSkip -= minSkipped;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int _channels = codecCtx->channels;
|
||||||
|
uint32_t _channelConfig = (uint32_t)codecCtx->channel_layout;
|
||||||
|
float _frequency = codecCtx->sample_rate;
|
||||||
|
|
||||||
|
if(_channels != channels ||
|
||||||
|
_channelConfig != channelConfig ||
|
||||||
|
_frequency != frequency) {
|
||||||
|
if(bytesRead > 0) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
channels = _channels;
|
||||||
|
channelConfig = _channelConfig;
|
||||||
|
frequency = _frequency;
|
||||||
|
[self willChangeValueForKey:@"properties"];
|
||||||
|
[self didChangeValueForKey:@"properties"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int toConsume = FFMIN((dataSize - bytesConsumedFromDecodedFrame), (bytesToRead - bytesRead));
|
int toConsume = FFMIN((dataSize - bytesConsumedFromDecodedFrame), (bytesToRead - bytesRead));
|
||||||
|
|
||||||
// copy decoded samples to Cog's buffer
|
// copy decoded samples to Cog's buffer
|
||||||
|
@ -575,20 +593,6 @@ int64_t ffmpeg_seek(void *opaque, int64_t offset, int whence) {
|
||||||
bytesRead += toConsume;
|
bytesRead += toConsume;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _channels = codecCtx->channels;
|
|
||||||
uint32_t _channelConfig = (uint32_t)codecCtx->channel_layout;
|
|
||||||
float _frequency = codecCtx->sample_rate;
|
|
||||||
|
|
||||||
if(_channels != channels ||
|
|
||||||
_channelConfig != channelConfig ||
|
|
||||||
_frequency != frequency) {
|
|
||||||
channels = _channels;
|
|
||||||
channelConfig = _channelConfig;
|
|
||||||
frequency = _frequency;
|
|
||||||
[self willChangeValueForKey:@"properties"];
|
|
||||||
[self didChangeValueForKey:@"properties"];
|
|
||||||
}
|
|
||||||
|
|
||||||
int framesReadNow = bytesRead / frameSize;
|
int framesReadNow = bytesRead / frameSize;
|
||||||
if(totalFrames && (framesRead + framesReadNow > totalFrames))
|
if(totalFrames && (framesRead + framesReadNow > totalFrames))
|
||||||
framesReadNow = (int)(totalFrames - framesRead);
|
framesReadNow = (int)(totalFrames - framesRead);
|
||||||
|
|
Loading…
Reference in New Issue