source: trunk/third/gstreamer/testsuite/schedulers/147894-2.c @ 21005

Revision 21005, 3.5 KB checked in by ghudson, 20 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r21004, which included commits to RCS files with non-trunk default branches.
Line 
1/* GStreamer
2 * Copyright (C) 2004 Wim Taymans <wim@fluendo.com>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public
15 * License along with this library; if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18
19#include <unistd.h>
20
21#include <gst/gst.h>
22
23static gboolean empty;
24static gboolean bug;
25static gboolean handoff;
26static GstElement *pipeline2;
27
28static void
29queue_empty (GstElement * element)
30{
31  g_print ("queue empty\n");
32  if (!handoff)
33    bug = TRUE;
34}
35
36static void
37queue_filled (GstElement * element)
38{
39  g_print ("queue filled\n");
40  empty = FALSE;
41
42  /* read from the other end */
43  handoff = FALSE;
44  bug = FALSE;
45
46  alarm (5);
47
48  g_print ("emptying queue with 5 second timeout...\n");
49  while (!bug && !handoff) {
50    gst_bin_iterate (GST_BIN (pipeline2));
51  }
52}
53
54static void
55handoff_identity (GstElement * element)
56{
57  g_print ("identity handoff\n");
58  handoff = TRUE;
59}
60
61gint
62main (gint argc, gchar ** argv)
63{
64  GstElement *pipeline, *src, *sink, *queue, *id;
65
66  gst_init (&argc, &argv);
67
68  g_print ("setting up...\n");
69  /* setup pipeline */
70  pipeline = gst_element_factory_make ("pipeline", NULL);
71  g_assert (pipeline);
72  src = gst_element_factory_make ("fakesrc", NULL);
73  g_assert (src);
74  queue = gst_element_factory_make ("queue", NULL);
75  g_assert (queue);
76  g_signal_connect (G_OBJECT (queue), "overrun", (GCallback) queue_filled,
77      NULL);
78  g_signal_connect (G_OBJECT (queue), "underrun", (GCallback) queue_empty,
79      NULL);
80  gst_bin_add_many (GST_BIN (pipeline), src, queue, NULL);
81
82  gst_element_link_pads (src, "src", queue, "sink");
83
84  /* second pipeline for sinks */
85  pipeline2 = gst_element_factory_make ("pipeline", NULL);
86  g_assert (pipeline2);
87  id = gst_element_factory_make ("identity", NULL);
88  g_assert (id);
89  g_signal_connect (G_OBJECT (id), "handoff", (GCallback) handoff_identity,
90      NULL);
91
92  sink = gst_element_factory_make ("fakesink", NULL);
93  g_assert (sink);
94  gst_bin_add_many (GST_BIN (pipeline2), id, sink, NULL);
95
96  gst_element_link_pads (queue, "src", id, "sink");
97  gst_element_link_pads (id, "src", sink, "sink");
98
99  if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
100    g_assert_not_reached ();
101
102  if (gst_element_set_state (pipeline2, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
103    g_assert_not_reached ();
104
105  g_print ("running...\n");
106  /* fill queue */
107  empty = TRUE;
108  while (empty) {
109    gst_bin_iterate (GST_BIN (pipeline));
110  }
111  g_assert (!bug);
112
113  g_print ("relinking...\n");
114  /* now unlink and link id and sink */
115  gst_element_unlink_pads (id, "src", sink, "sink");
116  gst_element_link_pads (id, "src", sink, "sink");
117
118  g_print ("running again...\n");
119  /* fill queue */
120  empty = TRUE;
121  while (empty) {
122    gst_bin_iterate (GST_BIN (pipeline));
123  }
124  g_assert (!bug);
125
126  /* trigger the bug */
127
128
129  g_print ("cleaning up...\n");
130  gst_object_unref (GST_OBJECT (pipeline));
131  gst_object_unref (GST_OBJECT (pipeline2));
132  src = id = sink = pipeline = pipeline2 = NULL;
133
134  g_print ("done.\n");
135  return 0;
136}
Note: See TracBrowser for help on using the repository browser.