[outputs] Fix segfault if encode_reset() fails to setup an encode_ctx

This commit is contained in:
ejurgensen 2019-02-27 21:59:44 +01:00
parent 1285128b9a
commit 3e4766ffaa

View File

@ -223,10 +223,20 @@ quality_to_xcode(struct media_quality *quality)
return XCODE_PCM16_44100;
if (quality->sample_rate == 44100 && quality->bits_per_sample == 24)
return XCODE_PCM24_44100;
if (quality->sample_rate == 44100 && quality->bits_per_sample == 32)
return XCODE_PCM32_44100;
if (quality->sample_rate == 48000 && quality->bits_per_sample == 16)
return XCODE_PCM16_48000;
if (quality->sample_rate == 48000 && quality->bits_per_sample == 24)
return XCODE_PCM24_48000;
if (quality->sample_rate == 48000 && quality->bits_per_sample == 32)
return XCODE_PCM32_48000;
if (quality->sample_rate == 96000 && quality->bits_per_sample == 16)
return XCODE_PCM16_96000;
if (quality->sample_rate == 96000 && quality->bits_per_sample == 24)
return XCODE_PCM24_96000;
if (quality->sample_rate == 96000 && quality->bits_per_sample == 32)
return XCODE_PCM32_96000;
return XCODE_UNKNOWN;
}
@ -310,6 +320,9 @@ buffer_fill(struct output_buffer *obuf, void *buf, size_t bufsize, struct media_
if (quality_is_equal(&output_quality_subscriptions[i].quality, quality))
continue; // Skip, no resampling required and we have the data in element 0
if (!output_quality_subscriptions[i].encode_ctx)
continue;
frame = transcode_frame_new(buf, bufsize, nsamples, quality->sample_rate, quality->bits_per_sample);
if (!frame)
continue;