src/io/source_avcodec.c: give up reading file if number of channel changes during...
authorPaul Brossier <piem@piem.org>
Mon, 6 Aug 2018 13:54:37 +0000 (15:54 +0200)
committerPaul Brossier <piem@piem.org>
Mon, 6 Aug 2018 13:54:37 +0000 (15:54 +0200)
src/io/source_avcodec.c

index 6d8efa7..7082bc2 100644 (file)
@@ -425,6 +425,13 @@ void aubio_source_avcodec_readframe(aubio_source_avcodec_t *s, uint_t * read_sam
     goto beach;
   }
 
+  if (avFrame->channels != (sint_t)s->input_channels) {
+    AUBIO_WRN ("source_avcodec: trying to read from %d channel(s),"
+        "but configured for %d; is '%s' corrupt?\n", avFrame->channels,
+        s->input_channels, s->path);
+    goto beach;
+  }
+
 #ifdef HAVE_AVRESAMPLE
   in_linesize = 0;
   av_samples_get_buffer_size(&in_linesize, avCodecCtx->channels,