]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[mod_av] enable resampler when sample rate mismatch (#153)
authorSeven Du <seven@signalwire.com>
Wed, 15 Apr 2020 02:36:32 +0000 (10:36 +0800)
committerAndrey Volk <andywolk@gmail.com>
Tue, 16 Mar 2021 17:21:10 +0000 (20:21 +0300)
src/mod/applications/mod_av/avformat.c

index ae7d2e840cb8f8b1e99fb71a4c96cc5c30011d29..0b3a452325240aa6be0cb8f725daf7e3277f3e28 100644 (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++) {