Showing the changes to libavfilter/src_buffer.c (1 of 1 file). Show all
Unified · Split
| @@ -215,19 +215,25 @@ static int check_format_change_audio(AVFilterContext *ctx, · 214 unmodified lines | ||
| 215 | 215 | int ret, logged = 0; |
| 216 | 216 | |
| 217 | 217 | link = ctx->outputs[0]; |
| 218 | − if (samplesref->audio->sample_rate != link->sample_rate) { | |
| 218 | + if (samplesref->audio->sample_rate != link->sample_rate || | |
| 219 | + samplesref->format != link->format || | |
| 220 | + samplesref->audio->channel_layout != link->channel_layout) { | |
| 219 | 221 | |
| 220 | 222 | log_input_change(ctx, link, samplesref); |
| 221 | 223 | logged = 1; |
| 222 | 224 | |
| 223 | − abuffer->sample_rate = samplesref->audio->sample_rate; | |
| 225 | + abuffer->sample_rate = samplesref->audio->sample_rate; | |
| 226 | + abuffer->sample_format = samplesref->format; | |
| 227 | + abuffer->channel_layout = samplesref->audio->channel_layout; | |
| 224 | 228 | |
| 225 | 229 | if (!abuffer->aresample) { |
| 226 | 230 | ret = insert_filter(abuffer, link, &abuffer->aresample, "aresample"); |
| 227 | 231 | if (ret < 0) return ret; |
| 228 | 232 | } else { |
| 229 | 233 | link = abuffer->aresample->outputs[0]; |
| 230 | − if (samplesref->audio->sample_rate == link->sample_rate) | |
| 234 | + if (samplesref->audio->sample_rate == link->sample_rate && | |
| 235 | + samplesref->format == link->format && | |
| 236 | + samplesref->audio->channel_layout == link->channel_layout) | |
| 231 | 237 | remove_filter(&abuffer->aresample); |
| 232 | 238 | else |
| 233 | 239 | if ((ret = reconfigure_filter(abuffer, abuffer->aresample)) < 0) |
| @@ -235,28 +241,6 @@ static int check_format_change_audio(AVFilterContext *ctx, · 1 unmodified line | ||
| 235 | 241 | } |
| 236 | 242 | } |
| 237 | 243 | |
| 238 | − link = ctx->outputs[0]; | |
| 239 | − if (samplesref->format != link->format || | |
| 240 | − samplesref->audio->channel_layout != link->channel_layout) { | |
| 241 | − | |
| 242 | − if (!logged) log_input_change(ctx, link, samplesref); | |
| 243 | − | |
| 244 | − abuffer->sample_format = samplesref->format; | |
| 245 | − abuffer->channel_layout = samplesref->audio->channel_layout; | |
| 246 | − | |
| 247 | − if (!abuffer->aconvert) { | |
| 248 | − ret = insert_filter(abuffer, link, &abuffer->aconvert, "aconvert"); | |
| 249 | − if (ret < 0) return ret; | |
| 250 | − } else { | |
| 251 | − link = abuffer->aconvert->outputs[0]; | |
| 252 | − if (samplesref->format == link->format && | |
| 253 | − samplesref->audio->channel_layout == link->channel_layout) | |
| 254 | − remove_filter(&abuffer->aconvert); | |
| 255 | − else | |
| 256 | − if ((ret = reconfigure_filter(abuffer, abuffer->aconvert)) < 0) | |
| 257 | − return ret; | |
| 258 | − } | |
| 259 | − } | |
| 260 | 244 | |
| 261 | 245 | return 0; |
| 262 | 246 | } |