From e0a398036bfd0f926666350d8a3e10efca843190 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Thu, 11 Jul 2002 15:13:09 +0000 Subject: [PATCH] better problem checking Original commit message from CVS: better problem checking --- examples/cutter/cutter.c | 13 +++++++++---- tests/old/examples/cutter/cutter.c | 13 +++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/examples/cutter/cutter.c b/examples/cutter/cutter.c index b1c80cee4d..b19d90a5f5 100644 --- a/examples/cutter/cutter.c +++ b/examples/cutter/cutter.c @@ -123,7 +123,8 @@ int main (int argc, char *argv[]) NULL); /* create an audio src */ - audiosrc = gst_element_factory_make ("osssrc", "audio_src"); + if (!(audiosrc = gst_element_factory_make ("osssrc", "audio_src"))) + g_error ("Could not create 'osssrc' element !\n"); /* set params */ @@ -131,9 +132,12 @@ int main (int argc, char *argv[]) "channels", 1, "format", 16, NULL); - encoder = gst_element_factory_make ("passthrough", "encoder"); - disksink = gst_element_factory_make ("afsink", "disk_sink"); - + if (!(encoder = gst_element_factory_make ("passthrough", "encoder"))) + g_error ("Could not create 'passthrough' element !\n"); + + if (!(disksink = gst_element_factory_make ("afsink", "disk_sink"))) + g_error ("Could not create 'afsink' element !\n"); + g_object_set (G_OBJECT (disksink), "location", "/dev/null", NULL); thread = gst_thread_new ("thread"); @@ -144,6 +148,7 @@ int main (int argc, char *argv[]) g_assert (main_bin != NULL); queue = gst_element_factory_make ("queue", "queue"); + g_assert (queue); /* add elements to bin */ gst_bin_add (GST_BIN (main_bin), audiosrc); diff --git a/tests/old/examples/cutter/cutter.c b/tests/old/examples/cutter/cutter.c index b1c80cee4d..b19d90a5f5 100644 --- a/tests/old/examples/cutter/cutter.c +++ b/tests/old/examples/cutter/cutter.c @@ -123,7 +123,8 @@ int main (int argc, char *argv[]) NULL); /* create an audio src */ - audiosrc = gst_element_factory_make ("osssrc", "audio_src"); + if (!(audiosrc = gst_element_factory_make ("osssrc", "audio_src"))) + g_error ("Could not create 'osssrc' element !\n"); /* set params */ @@ -131,9 +132,12 @@ int main (int argc, char *argv[]) "channels", 1, "format", 16, NULL); - encoder = gst_element_factory_make ("passthrough", "encoder"); - disksink = gst_element_factory_make ("afsink", "disk_sink"); - + if (!(encoder = gst_element_factory_make ("passthrough", "encoder"))) + g_error ("Could not create 'passthrough' element !\n"); + + if (!(disksink = gst_element_factory_make ("afsink", "disk_sink"))) + g_error ("Could not create 'afsink' element !\n"); + g_object_set (G_OBJECT (disksink), "location", "/dev/null", NULL); thread = gst_thread_new ("thread"); @@ -144,6 +148,7 @@ int main (int argc, char *argv[]) g_assert (main_bin != NULL); queue = gst_element_factory_make ("queue", "queue"); + g_assert (queue); /* add elements to bin */ gst_bin_add (GST_BIN (main_bin), audiosrc);