1 | #include <gst/gst.h> |
---|
2 | |
---|
3 | gint i = 0; |
---|
4 | GstElement *pipeline; |
---|
5 | GstPadChainFunction oss_chain; |
---|
6 | |
---|
7 | static GstElement * |
---|
8 | make_and_check_element (gchar * type, gchar * name) |
---|
9 | { |
---|
10 | GstElement *element = gst_element_factory_make (type, name); |
---|
11 | |
---|
12 | if (element == NULL) { |
---|
13 | g_warning |
---|
14 | ("Could not run test, because element type \"%s\" is not installed. Please retry when it is. Assuming it works for now...", |
---|
15 | type); |
---|
16 | exit (1); |
---|
17 | } |
---|
18 | |
---|
19 | return element; |
---|
20 | } |
---|
21 | |
---|
22 | static void |
---|
23 | create_pipeline (void) |
---|
24 | { |
---|
25 | GstElement *src; |
---|
26 | GstElement *sink; |
---|
27 | GstElement *id; |
---|
28 | |
---|
29 | pipeline = gst_pipeline_new ("pipeline"); |
---|
30 | src = make_and_check_element ("sinesrc", "src"); |
---|
31 | /** |
---|
32 | * You need a sink with a loop-based element in here, if you want to kill opt, too. |
---|
33 | * Osssink (chain-based) only breaks the basic scheduler. |
---|
34 | */ |
---|
35 | sink = make_and_check_element ("alsasink", "sink"); |
---|
36 | |
---|
37 | |
---|
38 | gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL); |
---|
39 | gst_element_link (src, sink); |
---|
40 | |
---|
41 | /** |
---|
42 | * now make the bug appear |
---|
43 | * I believe it has something to do with 2 chains being created in the scheduler |
---|
44 | * but I haven't looked at it yet |
---|
45 | * If you comment out the next 4 lines, everything works fine. |
---|
46 | * And no, it's not because of identity, you may use any other element. |
---|
47 | */ |
---|
48 | gst_element_unlink (src, sink); |
---|
49 | id = make_and_check_element ("identity", "id"); |
---|
50 | gst_bin_add (GST_BIN (pipeline), id); |
---|
51 | gst_element_link_many (src, id, sink, NULL); |
---|
52 | |
---|
53 | /* This pipeline will not be removed properly once we unref it */ |
---|
54 | gst_element_set_state (pipeline, GST_STATE_PLAYING); |
---|
55 | } |
---|
56 | |
---|
57 | gint |
---|
58 | main (gint argc, gchar * argv[]) |
---|
59 | { |
---|
60 | gst_init (&argc, &argv); |
---|
61 | create_pipeline (); |
---|
62 | |
---|
63 | while (i < 300) { |
---|
64 | /** |
---|
65 | * only inc i when it works, so the program hangs when _iterate returns false, |
---|
66 | * which it does after the first pipeline isn't unref'd properly and the next |
---|
67 | * osssink refuses to work. |
---|
68 | */ |
---|
69 | if (gst_bin_iterate (GST_BIN (pipeline))) |
---|
70 | i++; |
---|
71 | if (i % 50 == 0) { |
---|
72 | gst_object_unref (GST_OBJECT (pipeline)); |
---|
73 | create_pipeline (); |
---|
74 | } |
---|
75 | } |
---|
76 | return 0; |
---|
77 | } |
---|