No code with side-effects inside g_assert() please
authorTim-Philipp Müller <tim@centricular.net>
Wed, 8 Aug 2012 09:56:51 +0000 (10:56 +0100)
committerTim-Philipp Müller <tim@centricular.net>
Wed, 8 Aug 2012 10:07:55 +0000 (11:07 +0100)
ext/jpeg/gstjpegdec.c
ext/libpng/gstpngdec.c
gst/isomp4/gstqtmoovrecover.c
tests/icles/ximagesrc-test.c

index bf542f2..54abe4e 100644 (file)
@@ -1316,15 +1316,17 @@ invalid_yuvrgbgrayscale:
 static gboolean
 gst_jpeg_dec_decide_allocation (GstVideoDecoder * bdec, GstQuery * query)
 {
-  GstBufferPool *pool;
+  GstBufferPool *pool = NULL;
   GstStructure *config;
 
   if (!GST_VIDEO_DECODER_CLASS (parent_class)->decide_allocation (bdec, query))
     return FALSE;
 
-  g_assert (gst_query_get_n_allocation_pools (query) > 0);
-  gst_query_parse_nth_allocation_pool (query, 0, &pool, NULL, NULL, NULL);
-  g_assert (pool != NULL);
+  if (gst_query_get_n_allocation_pools (query) > 0)
+    gst_query_parse_nth_allocation_pool (query, 0, &pool, NULL, NULL, NULL);
+
+  if (pool == NULL)
+    return FALSE;
 
   config = gst_buffer_pool_get_config (pool);
   if (gst_query_find_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL)) {
index c173343..1178958 100644 (file)
@@ -394,15 +394,17 @@ beach:
 static gboolean
 gst_pngdec_decide_allocation (GstVideoDecoder * bdec, GstQuery * query)
 {
-  GstBufferPool *pool;
+  GstBufferPool *pool = NULL;
   GstStructure *config;
 
   if (!GST_VIDEO_DECODER_CLASS (parent_class)->decide_allocation (bdec, query))
     return FALSE;
 
-  g_assert (gst_query_get_n_allocation_pools (query) > 0);
-  gst_query_parse_nth_allocation_pool (query, 0, &pool, NULL, NULL, NULL);
-  g_assert (pool != NULL);
+  if (gst_query_get_n_allocation_pools (query) > 0)
+    gst_query_parse_nth_allocation_pool (query, 0, &pool, NULL, NULL, NULL);
+
+  if (pool == NULL)
+    return FALSE;
 
   config = gst_buffer_pool_get_config (pool);
   if (gst_query_find_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL)) {
index 343678c..07fd35a 100644 (file)
@@ -362,7 +362,8 @@ gst_qt_moov_recover_change_state (GstElement * element,
       gst_task_join (qtmr->task);
       break;
     case GST_STATE_CHANGE_READY_TO_NULL:
-      g_assert (gst_task_get_state (qtmr->task) == GST_TASK_STOPPED);
+      if (gst_task_get_state (qtmr->task) != GST_TASK_STOPPED)
+        GST_ERROR ("task %p should be stopped by now", qtmr->task);
       gst_object_unref (qtmr->task);
       qtmr->task = NULL;
       g_rec_mutex_clear (&qtmr->task_mutex);
index a01bf65..12ec0dc 100644 (file)
@@ -37,9 +37,7 @@ int
 main (int argc, char **argv)
 {
   GstElement *pipeline;
-#ifndef G_DISABLE_ASSERT
-  GstState state, pending;
-#endif
+  GstState state;
   GError *error = NULL;
 
   gst_init (&argc, &argv);
@@ -55,9 +53,11 @@ main (int argc, char **argv)
   gst_element_set_state (pipeline, GST_STATE_PLAYING);
 
   /* lets check it gets to PLAYING */
-  g_assert (gst_element_get_state (pipeline, &state, &pending,
-          GST_CLOCK_TIME_NONE) != GST_STATE_CHANGE_FAILURE);
-  g_assert (state == GST_STATE_PLAYING || pending == GST_STATE_PLAYING);
+  if (gst_element_get_state (pipeline, &state, NULL,
+          GST_CLOCK_TIME_NONE) == GST_STATE_CHANGE_FAILURE ||
+      state != GST_STATE_PLAYING) {
+    g_warning ("State change to playing failed");
+  }
 
   /* We want to get out after 5 seconds */
   g_timeout_add (5000, (GSourceFunc) terminate_playback, pipeline);