From 8a01df50528478c6f22769e4dc67967188f3d58a Mon Sep 17 00:00:00 2001 From: Packit Service Date: Dec 09 2020 20:26:48 +0000 Subject: Apply patch libsndfile-1.0.28-flacbufovfl.patch patch_name: libsndfile-1.0.28-flacbufovfl.patch present_in_specfile: true --- diff --git a/src/common.h b/src/common.h index 0bd810c..e2669b6 100644 --- a/src/common.h +++ b/src/common.h @@ -725,6 +725,7 @@ enum SFE_FLAC_INIT_DECODER, SFE_FLAC_LOST_SYNC, SFE_FLAC_BAD_SAMPLE_RATE, + SFE_FLAC_CHANNEL_COUNT_CHANGED, SFE_FLAC_UNKOWN_ERROR, SFE_WVE_NOT_WVE, diff --git a/src/flac.c b/src/flac.c index 40629c7..aad7920 100644 --- a/src/flac.c +++ b/src/flac.c @@ -435,6 +435,19 @@ sf_flac_meta_callback (const FLAC__StreamDecoder * UNUSED (decoder), const FLAC_ switch (metadata->type) { case FLAC__METADATA_TYPE_STREAMINFO : + if (psf->sf.channels > 0 && psf->sf.channels != (int) metadata->data.stream_info.channels) + { psf_log_printf (psf, "Error: FLAC stream changed from %d to %d channels\n" + "Nothing to be but to error out.\n" , + psf->sf.channels, metadata->data.stream_info.channels) ; + psf->error = SFE_FLAC_CHANNEL_COUNT_CHANGED ; + return ; + } ; + + if (psf->sf.channels > 0 && psf->sf.samplerate != (int) metadata->data.stream_info.sample_rate) + { psf_log_printf (psf, "Warning: FLAC stream changed sample rates from %d to %d.\n" + "Carrying on as if nothing happened.", + psf->sf.samplerate, metadata->data.stream_info.sample_rate) ; + } ; psf->sf.channels = metadata->data.stream_info.channels ; psf->sf.samplerate = metadata->data.stream_info.sample_rate ; psf->sf.frames = metadata->data.stream_info.total_samples ; diff --git a/src/sndfile.c b/src/sndfile.c index b76bfe9..1f57846 100644 --- a/src/sndfile.c +++ b/src/sndfile.c @@ -245,6 +245,7 @@ ErrorStruct SndfileErrors [] = { SFE_FLAC_INIT_DECODER , "Error : problem with initialization of the flac decoder." }, { SFE_FLAC_LOST_SYNC , "Error : flac decoder lost sync." }, { SFE_FLAC_BAD_SAMPLE_RATE, "Error : flac does not support this sample rate." }, + { SFE_FLAC_CHANNEL_COUNT_CHANGED, "Error : flac channel changed mid stream." }, { SFE_FLAC_UNKOWN_ERROR , "Error : unknown error in flac decoder." }, { SFE_WVE_NOT_WVE , "Error : not a WVE file." },