obs-ffmpeg: Fix iteration over sample formats

This commit is contained in:
derrod 2023-04-05 11:32:17 +02:00 committed by Rodney
parent ba38a7d9f4
commit cf6adf84ab

View file

@ -289,10 +289,10 @@ static void *enc_create(obs_data_t *settings, obs_encoder_t *encoder,
/* Check if the requested format is actually available for the specified /* Check if the requested format is actually available for the specified
* encoder. This may not always be the case due to FFmpeg changes or a * encoder. This may not always be the case due to FFmpeg changes or a
* fallback being used (for example, when libopus is unavailable). */ * fallback being used (for example, when libopus is unavailable). */
enum AVSampleFormat fmt = enc->codec->sample_fmts[0]; const enum AVSampleFormat *fmt = enc->codec->sample_fmts;
while (fmt != AV_SAMPLE_FMT_NONE) { while (*fmt != AV_SAMPLE_FMT_NONE) {
if (fmt == sample_format) { if (*fmt == sample_format) {
enc->context->sample_fmt = fmt; enc->context->sample_fmt = *fmt;
break; break;
} }
fmt++; fmt++;