summaryrefslogtreecommitdiff
path: root/tests/examples
diff options
context:
space:
mode:
authorStefan Kost <ensonic@users.sf.net>2010-07-09 15:58:50 +0300
committerStefan Kost <ensonic@users.sf.net>2010-08-05 10:31:50 +0300
commit461fd8d82d8ece3ae6bd4ce7884c52851a5e6b2c (patch)
tree9ea27ffa67d457323467e8d8097bb9d535552af5 /tests/examples
parentdbe8e5d1ad9be08c8304128a63025a1520badc44 (diff)
tests: clean up eventloop in examples
Don't leak the bus. Don't parse messages with the method for errors (triggers gobject warning).
Diffstat (limited to 'tests/examples')
-rw-r--r--tests/examples/helloworld/helloworld.c25
-rw-r--r--tests/examples/launch/mp3parselaunch.c25
-rw-r--r--tests/examples/queue/queue.c26
-rw-r--r--tests/examples/stepping/framestep1.c28
-rw-r--r--tests/examples/streams/stream-status.c12
-rw-r--r--tests/examples/typefind/typefind.c25
6 files changed, 103 insertions, 38 deletions
diff --git a/tests/examples/helloworld/helloworld.c b/tests/examples/helloworld/helloworld.c
index 9749651cc..6b3227729 100644
--- a/tests/examples/helloworld/helloworld.c
+++ b/tests/examples/helloworld/helloworld.c
@@ -6,35 +6,46 @@ event_loop (GstElement * pipe)
{
GstBus *bus;
GstMessage *message = NULL;
+ gboolean running = TRUE;
bus = gst_element_get_bus (GST_ELEMENT (pipe));
- while (TRUE) {
+ while (running) {
message = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
g_assert (message != NULL);
switch (message->type) {
case GST_MESSAGE_EOS:
- gst_message_unref (message);
- return;
- case GST_MESSAGE_WARNING:
+ running = FALSE;
+ break;
+ case GST_MESSAGE_WARNING:{
+ GError *gerror;
+ gchar *debug;
+
+ gst_message_parse_warning (message, &gerror, &debug);
+ gst_object_default_error (GST_MESSAGE_SRC (message), gerror, debug);
+ g_error_free (gerror);
+ g_free (debug);
+ break;
+ }
case GST_MESSAGE_ERROR:{
GError *gerror;
gchar *debug;
gst_message_parse_error (message, &gerror, &debug);
gst_object_default_error (GST_MESSAGE_SRC (message), gerror, debug);
- gst_message_unref (message);
g_error_free (gerror);
g_free (debug);
- return;
+ running = FALSE;
+ break;
}
default:
- gst_message_unref (message);
break;
}
+ gst_message_unref (message);
}
+ gst_object_unref (bus);
}
int
diff --git a/tests/examples/launch/mp3parselaunch.c b/tests/examples/launch/mp3parselaunch.c
index fcd7fe502..cc00a07c3 100644
--- a/tests/examples/launch/mp3parselaunch.c
+++ b/tests/examples/launch/mp3parselaunch.c
@@ -7,35 +7,46 @@ event_loop (GstElement * pipe)
{
GstBus *bus;
GstMessage *message = NULL;
+ gboolean running = TRUE;
bus = gst_element_get_bus (GST_ELEMENT (pipe));
- while (TRUE) {
+ while (running) {
message = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
g_assert (message != NULL);
switch (message->type) {
case GST_MESSAGE_EOS:
- gst_message_unref (message);
- return;
- case GST_MESSAGE_WARNING:
+ running = FALSE;
+ break;
+ case GST_MESSAGE_WARNING:{
+ GError *gerror;
+ gchar *debug;
+
+ gst_message_parse_warning (message, &gerror, &debug);
+ gst_object_default_error (GST_MESSAGE_SRC (message), gerror, debug);
+ g_error_free (gerror);
+ g_free (debug);
+ break;
+ }
case GST_MESSAGE_ERROR:{
GError *gerror;
gchar *debug;
gst_message_parse_error (message, &gerror, &debug);
gst_object_default_error (GST_MESSAGE_SRC (message), gerror, debug);
- gst_message_unref (message);
g_error_free (gerror);
g_free (debug);
- return;
+ running = FALSE;
+ break;
}
default:
- gst_message_unref (message);
break;
}
+ gst_message_unref (message);
}
+ gst_object_unref (bus);
}
int
diff --git a/tests/examples/queue/queue.c b/tests/examples/queue/queue.c
index 514fd35de..27ca94e1f 100644
--- a/tests/examples/queue/queue.c
+++ b/tests/examples/queue/queue.c
@@ -14,34 +14,46 @@ event_loop (GstElement * pipe)
{
GstBus *bus;
GstMessage *message = NULL;
+ gboolean running = TRUE;
bus = gst_element_get_bus (GST_ELEMENT (pipe));
- while (TRUE) {
+ while (running) {
message = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
+
g_assert (message != NULL);
switch (message->type) {
case GST_MESSAGE_EOS:
- gst_message_unref (message);
- return;
- case GST_MESSAGE_WARNING:
+ running = FALSE;
+ break;
+ case GST_MESSAGE_WARNING:{
+ GError *gerror;
+ gchar *debug;
+
+ gst_message_parse_warning (message, &gerror, &debug);
+ gst_object_default_error (GST_MESSAGE_SRC (message), gerror, debug);
+ g_error_free (gerror);
+ g_free (debug);
+ break;
+ }
case GST_MESSAGE_ERROR:{
GError *gerror;
gchar *debug;
gst_message_parse_error (message, &gerror, &debug);
gst_object_default_error (GST_MESSAGE_SRC (message), gerror, debug);
- gst_message_unref (message);
g_error_free (gerror);
g_free (debug);
- return;
+ running = FALSE;
+ break;
}
default:
- gst_message_unref (message);
break;
}
+ gst_message_unref (message);
}
+ gst_object_unref (bus);
}
int
diff --git a/tests/examples/stepping/framestep1.c b/tests/examples/stepping/framestep1.c
index e188284ae..f33532bda 100644
--- a/tests/examples/stepping/framestep1.c
+++ b/tests/examples/stepping/framestep1.c
@@ -6,10 +6,11 @@ event_loop (GstElement * pipe)
{
GstBus *bus;
GstMessage *message = NULL;
+ gboolean running = TRUE;
bus = gst_element_get_bus (GST_ELEMENT (pipe));
- while (TRUE) {
+ while (running) {
message = gst_bus_timed_pop_filtered (bus, GST_MESSAGE_ANY, -1);
g_assert (message != NULL);
@@ -17,9 +18,18 @@ event_loop (GstElement * pipe)
switch (message->type) {
case GST_MESSAGE_EOS:
g_message ("got EOS");
- gst_message_unref (message);
- return;
- case GST_MESSAGE_WARNING:
+ running = FALSE;
+ break;
+ case GST_MESSAGE_WARNING:{
+ GError *gerror;
+ gchar *debug;
+
+ gst_message_parse_warning (message, &gerror, &debug);
+ gst_object_default_error (GST_MESSAGE_SRC (message), gerror, debug);
+ g_error_free (gerror);
+ g_free (debug);
+ break;
+ }
case GST_MESSAGE_ERROR:
{
GError *gerror;
@@ -27,10 +37,10 @@ event_loop (GstElement * pipe)
gst_message_parse_error (message, &gerror, &debug);
gst_object_default_error (GST_MESSAGE_SRC (message), gerror, debug);
- gst_message_unref (message);
g_error_free (gerror);
g_free (debug);
- return;
+ running = FALSE;
+ break;
}
case GST_MESSAGE_STEP_DONE:
{
@@ -51,14 +61,14 @@ event_loop (GstElement * pipe)
g_message ("step done: %" GST_TIME_FORMAT " skipped",
GST_TIME_ARGS (duration));
}
-
- return;
+ break;
}
default:
- gst_message_unref (message);
break;
}
+ gst_message_unref (message);
}
+ gst_object_unref (bus);
}
/* signalled when a new preroll buffer is available */
diff --git a/tests/examples/streams/stream-status.c b/tests/examples/streams/stream-status.c
index e8ebb6708..f667468a3 100644
--- a/tests/examples/streams/stream-status.c
+++ b/tests/examples/streams/stream-status.c
@@ -16,7 +16,17 @@ event_loop (GstBus * bus, GstElement * pipe)
g_message ("received EOS");
gst_message_unref (message);
return;
- case GST_MESSAGE_WARNING:
+ case GST_MESSAGE_WARNING:{
+ GError *gerror;
+ gchar *debug;
+
+ gst_message_parse_warning (message, &gerror, &debug);
+ gst_object_default_error (GST_MESSAGE_SRC (message), gerror, debug);
+ gst_message_unref (message);
+ g_error_free (gerror);
+ g_free (debug);
+ break;
+ }
case GST_MESSAGE_ERROR:{
GError *gerror;
gchar *debug;
diff --git a/tests/examples/typefind/typefind.c b/tests/examples/typefind/typefind.c
index 8476c2ac4..58f11dbbf 100644
--- a/tests/examples/typefind/typefind.c
+++ b/tests/examples/typefind/typefind.c
@@ -42,35 +42,46 @@ event_loop (GstElement * pipe)
{
GstBus *bus;
GstMessage *message = NULL;
+ gboolean running = TRUE;
bus = gst_element_get_bus (GST_ELEMENT (pipe));
- while (TRUE) {
+ while (running) {
message = gst_bus_poll (bus, GST_MESSAGE_ANY, -1);
g_assert (message != NULL);
switch (message->type) {
case GST_MESSAGE_EOS:
- gst_message_unref (message);
- return;
- case GST_MESSAGE_WARNING:
+ running = FALSE;
+ break;
+ case GST_MESSAGE_WARNING:{
+ GError *gerror;
+ gchar *debug;
+
+ gst_message_parse_warning (message, &gerror, &debug);
+ gst_object_default_error (GST_MESSAGE_SRC (message), gerror, debug);
+ g_error_free (gerror);
+ g_free (debug);
+ break;
+ }
case GST_MESSAGE_ERROR:{
GError *gerror;
gchar *debug;
gst_message_parse_error (message, &gerror, &debug);
gst_object_default_error (GST_MESSAGE_SRC (message), gerror, debug);
- gst_message_unref (message);
g_error_free (gerror);
g_free (debug);
- return;
+ running = FALSE;
+ break;
}
default:
- gst_message_unref (message);
break;
}
+ gst_message_unref (message);
}
+ gst_object_unref (bus);
}
int