Handle the case of flushing resampler by sending NULL
This commit is contained in:
parent
c6adf46384
commit
a0f021ee12
|
@ -84,8 +84,7 @@ void FFMPEGInit() {
|
||||||
Info("Not enabling ffmpeg logs, as LOG_FFMPEG and/or LOG_DEBUG is disabled in options, or this monitor not part of your debug targets");
|
Info("Not enabling ffmpeg logs, as LOG_FFMPEG and/or LOG_DEBUG is disabled in options, or this monitor not part of your debug targets");
|
||||||
av_log_set_level(AV_LOG_QUIET);
|
av_log_set_level(AV_LOG_QUIET);
|
||||||
}
|
}
|
||||||
#if LIBAVFORMAT_VERSION_CHECK(58, 9, 0, 64, 0)
|
#if !LIBAVFORMAT_VERSION_CHECK(58, 9, 0, 64, 0)
|
||||||
#else
|
|
||||||
av_register_all();
|
av_register_all();
|
||||||
#endif
|
#endif
|
||||||
avformat_network_init();
|
avformat_network_init();
|
||||||
|
@ -691,10 +690,14 @@ int zm_resample_audio(
|
||||||
AVFrame *out_frame
|
AVFrame *out_frame
|
||||||
) {
|
) {
|
||||||
#if defined(HAVE_LIBSWRESAMPLE)
|
#if defined(HAVE_LIBSWRESAMPLE)
|
||||||
|
if ( in_frame ) {
|
||||||
// Resample the in_frame into the audioSampleBuffer until we process the whole
|
// Resample the in_frame into the audioSampleBuffer until we process the whole
|
||||||
// decoded data. Note: pts does not survive resampling or converting
|
// decoded data. Note: pts does not survive resampling or converting
|
||||||
Debug(2, "Converting %d to %d samples using swresample",
|
Debug(2, "Converting %d to %d samples using swresample",
|
||||||
in_frame->nb_samples, out_frame->nb_samples);
|
in_frame->nb_samples, out_frame->nb_samples);
|
||||||
|
} else {
|
||||||
|
Debug(2, "Sending NULL frame to flush resampler");
|
||||||
|
}
|
||||||
int ret = swr_convert_frame(resample_ctx, out_frame, in_frame);
|
int ret = swr_convert_frame(resample_ctx, out_frame, in_frame);
|
||||||
if ( ret < 0 ) {
|
if ( ret < 0 ) {
|
||||||
Error("Could not resample frame (error '%s')",
|
Error("Could not resample frame (error '%s')",
|
||||||
|
@ -705,6 +708,10 @@ int zm_resample_audio(
|
||||||
swr_get_delay(resample_ctx, out_frame->sample_rate));
|
swr_get_delay(resample_ctx, out_frame->sample_rate));
|
||||||
#else
|
#else
|
||||||
#if defined(HAVE_LIBAVRESAMPLE)
|
#if defined(HAVE_LIBAVRESAMPLE)
|
||||||
|
if ( ! in_frame ) {
|
||||||
|
Error("Flushing resampler not supported by AVRESAMPLE");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
int ret = avresample_convert(resample_ctx, NULL, 0, 0, in_frame->data,
|
int ret = avresample_convert(resample_ctx, NULL, 0, 0, in_frame->data,
|
||||||
0, in_frame->nb_samples);
|
0, in_frame->nb_samples);
|
||||||
if ( ret < 0 ) {
|
if ( ret < 0 ) {
|
||||||
|
|
Loading…
Reference in New Issue