flacparse: ensure we only check for sample/block mixup at start
authorVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Sun, 4 Dec 2011 12:50:57 +0000 (12:50 +0000)
committerVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Sun, 4 Dec 2011 12:50:57 +0000 (12:50 +0000)
Otherwise we might trigger at some point within the file, but the
check is only making sense for the second block.

gst/audioparsers/gstflacparse.c
gst/audioparsers/gstflacparse.h

index 7554404667f9d786a2b432f9ed01b9d445ae6401..9cfdb98103ae3f355744443cd814aedb917383fa 100644 (file)
@@ -328,6 +328,7 @@ gst_flac_parse_start (GstBaseParse * parse)
   flacparse->blocking_strategy = 0;
   flacparse->block_size = 0;
   flacparse->sample_number = 0;
+  flacparse->strategy_checked = FALSE;
 
   /* "fLaC" marker */
   gst_base_parse_set_min_frame_size (GST_BASE_PARSE (flacparse), 4);
@@ -538,11 +539,16 @@ gst_flac_parse_frame_header_is_valid (GstFlacParse * flacparse,
   /* Sanity check sample number against blocking strategy, as it seems
      some files claim fixed block size but supply sample numbers,
      rather than block numbers. */
-  if (set && blocking_strategy == 0 && block_size == sample_number) {
-    GST_WARNING_OBJECT (flacparse, "This file claims fixed block size, "
-        "but seems to be lying: assuming variable block size");
-    flacparse->force_variable_block_size = TRUE;
-    blocking_strategy = 1;
+  if (blocking_strategy == 0 && flacparse->block_size != 0) {
+    if (!flacparse->strategy_checked) {
+      if (block_size == sample_number) {
+        GST_WARNING_OBJECT (flacparse, "This file claims fixed block size, "
+            "but seems to be lying: assuming variable block size");
+        flacparse->force_variable_block_size = TRUE;
+        blocking_strategy = 1;
+      }
+      flacparse->strategy_checked = TRUE;
+    }
   }
 
   /* 
index 282755244cd0169f6271d89296f5d9e1aeb6a351..ebdc1b972adfb7690dae01478a58a8be960c4ee5 100644 (file)
@@ -74,6 +74,7 @@ struct _GstFlacParse {
   guint8 blocking_strategy;
   guint16 block_size;
   guint64 sample_number;
+  gboolean strategy_checked;
 
   GstTagList *tags;