wavenc: Post warning if file isnt finished properly
authorThiago Santos <thiago.sousa.santos@collabora.co.uk>
Wed, 20 Jan 2010 18:11:15 +0000 (15:11 -0300)
committerThiago Santos <thiago.sousa.santos@collabora.co.uk>
Wed, 20 Jan 2010 18:11:15 +0000 (15:11 -0300)
When the pipeline is shut down and the file isn't
finished properly, wavenc should post a warning.

Fixes #607440

gst/wavenc/gstwavenc.c
gst/wavenc/gstwavenc.h

index dc580be..e2745c6 100644 (file)
@@ -637,6 +637,9 @@ gst_wavenc_event (GstPad * pad, GstEvent * event)
       /* write header with correct length values */
       gst_wavenc_push_header (wavenc, wavenc->length);
 
+      /* we're done with this file */
+      wavenc->finished_properly = TRUE;
+
       /* and forward the EOS event */
       res = gst_pad_event_default (pad, event);
       break;
@@ -668,6 +671,9 @@ gst_wavenc_chain (GstPad * pad, GstBuffer * buf)
      * header when we get EOS and know the exact length */
     flow = gst_wavenc_push_header (wavenc, 0x7FFF0000);
 
+    /* starting a file, means we have to finish it properly */
+    wavenc->finished_properly = FALSE;
+
     if (flow != GST_FLOW_OK)
       return flow;
 
@@ -705,6 +711,8 @@ gst_wavenc_change_state (GstElement * element, GstStateChange transition)
       wavenc->rate = 0;
       wavenc->length = 0;
       wavenc->sent_header = FALSE;
+      /* its true because we haven't writen anything */
+      wavenc->finished_properly = TRUE;
       break;
     default:
       break;
@@ -714,6 +722,19 @@ gst_wavenc_change_state (GstElement * element, GstStateChange transition)
   if (ret != GST_STATE_CHANGE_SUCCESS)
     return ret;
 
+  switch (transition) {
+    case GST_STATE_CHANGE_PAUSED_TO_READY:
+      if (!wavenc->finished_properly) {
+        GST_ELEMENT_WARNING (wavenc, STREAM, MUX,
+            ("Wav stream not finished properly"),
+            ("Wav stream not finished properly, no EOS received "
+                "before shutdown"));
+      }
+      break;
+    default:
+      break;
+  }
+
   return ret;
 }
 
index 52a1237..f4f9aac 100644 (file)
@@ -54,6 +54,7 @@ struct _GstWavEnc {
   guint32    length;
 
   gboolean   sent_header;
+  gboolean   finished_properly;
 };
 
 struct _GstWavEncClass {