[mod_av] enable resampler when sample rate mismatch (#153)

This commit is contained in:
Seven Du 2020-04-15 10:36:32 +08:00 committed by Andrey Volk
parent 3c5773719e
commit 9875e190aa
1 changed files with 2 additions and 2 deletions

View File

@ -702,7 +702,7 @@ GCC_DIAG_ON(deprecated-declarations)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "sample_rate: %d nb_samples: %d\n", mst->frame->sample_rate, mst->frame->nb_samples);
if (c->sample_fmt != AV_SAMPLE_FMT_S16) {
if (c->sample_fmt != AV_SAMPLE_FMT_S16 || c->sample_rate != mst->sample_rate) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "sample_fmt %d != AV_SAMPLE_FMT_S16, start resampler\n", c->sample_fmt);
mst->resample_ctx = swr_alloc();
@ -1231,7 +1231,7 @@ GCC_DIAG_ON(deprecated-declarations)
context->audio_st[1].sample_rate = handle->samplerate;
GCC_DIAG_OFF(deprecated-declarations)
if (context->audio_st[0].st->codec->sample_fmt != AV_SAMPLE_FMT_S16) {
if (context->audio_st[0].st->codec->sample_fmt != AV_SAMPLE_FMT_S16 || context->audio_st[0].st->codec->sample_rate != handle->samplerate) {
GCC_DIAG_ON(deprecated-declarations)
int x;
for (x = 0; x < context->has_audio && x < 2 && c[x]; x++) {