From 4de8bd004c78630b1a025f5c7e93e415ae19276c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Wed, 8 Aug 2012 10:56:51 +0100 Subject: [PATCH] No code with side-effects inside g_assert() please --- ext/jpeg/gstjpegdec.c | 10 ++++++---- ext/libpng/gstpngdec.c | 10 ++++++---- gst/isomp4/gstqtmoovrecover.c | 3 ++- tests/icles/ximagesrc-test.c | 12 ++++++------ 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/ext/jpeg/gstjpegdec.c b/ext/jpeg/gstjpegdec.c index bf542f2..54abe4e 100644 --- a/ext/jpeg/gstjpegdec.c +++ b/ext/jpeg/gstjpegdec.c @@ -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)) { diff --git a/ext/libpng/gstpngdec.c b/ext/libpng/gstpngdec.c index c173343..1178958 100644 --- a/ext/libpng/gstpngdec.c +++ b/ext/libpng/gstpngdec.c @@ -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)) { diff --git a/gst/isomp4/gstqtmoovrecover.c b/gst/isomp4/gstqtmoovrecover.c index 343678c..07fd35a 100644 --- a/gst/isomp4/gstqtmoovrecover.c +++ b/gst/isomp4/gstqtmoovrecover.c @@ -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); diff --git a/tests/icles/ximagesrc-test.c b/tests/icles/ximagesrc-test.c index a01bf65..12ec0dc 100644 --- a/tests/icles/ximagesrc-test.c +++ b/tests/icles/ximagesrc-test.c @@ -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); -- 2.7.4