Compile with gcc $(pkg-config --libs --cflags gstreamer-0.8 gstreamer-gconf-0.8 gconf-2.0 ) gst-test.c -o gst-test --------------------------------[SNIP]-------------------------------------------------- #include #include typedef struct { gboolean play; guint attempt; GstElement *bin; } Data; static gboolean tick (Data *data) { data->attempt++; g_print ("Attempt %d to change state", data->attempt); if (data->play) { g_print("State: READY->PLAYING\n"); gst_element_set_state (data->bin, GST_STATE_PLAYING); } else { g_print("State: PLAYING->READY\n"); gst_element_set_state (data->bin, GST_STATE_READY); } data->play = !data->play; return TRUE; } int main (int argc, char **argv) { GstElement *playbin; GstElement *gconf; GstElement *bin; GstElement *tee; GstElement *tcpserversink; Data *data; gst_init (&argc, &argv); /* Here is the layout: Playbin's Audiosink: -Bin -Tee - Gconf (alsa) - tcpserversink */ playbin = gst_element_factory_make ("playbin", "playbin"); //Change this to a file on your drive g_object_set (G_OBJECT (playbin), "uri", "file:///home/kikidonk/lone-music/iced.mp3", NULL); bin = gst_bin_new ("bin"); gconf = gst_gconf_get_default_audio_sink (); tee = gst_element_factory_make ("tee", "tee"); tcpserversink = gst_element_factory_make ("tcpserversink", "tcp"); g_object_set (G_OBJECT (tcpserversink), "port", 10333, "protocol", 1, NULL); gst_bin_add (GST_BIN (bin), gconf); gst_bin_add (GST_BIN (bin), tee); gst_bin_add (GST_BIN (bin), tcpserversink); gst_element_link (tee, gconf); gst_element_link (tee, tcpserversink); gst_element_add_ghost_pad (bin, gst_element_get_pad (tee, "sink"), "sink"); g_object_set (G_OBJECT (playbin), "audio-sink", bin, NULL); gst_element_set_state (playbin, GST_STATE_PLAYING); /* Every 2 sec, switch between PLAYING and READY state the playbin */ data = g_new0(Data, 1); data->play = FALSE; data->bin = playbin; data->attempt = 0; g_timeout_add (2000, (GSourceFunc) tick, data); /* Go ! */ gst_main (); gst_element_set_state (playbin, GST_STATE_NULL); gst_object_unref (GST_OBJECT (playbin)); g_free (data); return 0; } --------------------------------[SNIP]-------------------------------------------------- GDB Debug gdb ./gst-test GNU gdb 6.3 Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i686-pc-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1". (gdb) run Starting program: /home/kikidonk/gst-test [Thread debugging using libthread_db enabled] [New Thread 16384 (LWP 24145)] [New Thread 32769 (LWP 24148)] [New Thread 16386 (LWP 24149)] [New Thread 32771 (LWP 24150)] [New Thread 49156 (LWP 24151)] Attempt 1 to change stateState: PLAYING->READY [Thread 32771 (LWP 24150) exited] [New Thread 65539 (LWP 24152)] [Thread 49156 (LWP 24151) exited] Attempt 2 to change stateState: READY->PLAYING [New Thread 81924 (LWP 24153)] Attempt 3 to change stateState: PLAYING->READY [Thread 65539 (LWP 24152) exited] Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 16384 (LWP 24145)] 0xb7b49ef8 in IA__g_hash_table_destroy (hash_table=0x80ef858) at ghash.c:179 179 g_hash_nodes_destroy (hash_table->nodes[i], (gdb) where #0 0xb7b49ef8 in IA__g_hash_table_destroy (hash_table=0x80ef858) at ghash.c:179 #1 0xb783ab13 in gst_multifdsink_close (this=0x80ef560) at gstmultifdsink.c:1709 #2 0xb783acd4 in gst_multifdsink_change_state (element=0x80ef560) at gstmultifdsink.c:1742 #3 0xb7e65976 in gst_element_set_state_func (element=0x80ef560, state=GST_STATE_NULL) at gstelement.c:2872 #4 0xb7e6565c in gst_element_set_state (element=0x80ef560, state=GST_STATE_NULL) at gstelement.c:2815 #5 0xb7e53d25 in set_kid_state_func (bin=0x806eba8, child=0x80ef560, user_data=0xbf980ab0) at gstbin.c:841 #6 0xb7e53bd7 in gst_bin_foreach (bin=0x806eba8, func=0xb7e53c2f , data=0xbf980ab0) at gstbin.c:805 #7 0xb7e540dd in gst_bin_change_state (element=0x806eba8) at gstbin.c:903 #8 0xb7e65976 in gst_element_set_state_func (element=0x806eba8, state=GST_STATE_NULL) at gstelement.c:2872 #9 0xb7e54365 in gst_bin_set_state (element=0x806eba8, state=GST_STATE_NULL) at gstbin.c:950 #10 0xb7e6565c in gst_element_set_state (element=0x806eba8, state=GST_STATE_NULL) at gstelement.c:2815 #11 0xb788f02f in gst_play_bin_change_state (element=0x80e0d38) at gstplaybin.c:878 ---Type to continue, or q to quit--- #12 0xb7e65976 in gst_element_set_state_func (element=0x80e0d38, state=GST_STATE_READY) at gstelement.c:2872 #13 0xb7e6565c in gst_element_set_state (element=0x80e0d38, state=GST_STATE_READY) at gstelement.c:2815 #14 0x08048c04 in tick () #15 0xb7b5ca5a in g_timeout_dispatch (source=0x8292e20, callback=0x8048b94 , user_data=0x8286c68) at gmain.c:3293 #16 0xb7b59c43 in g_main_dispatch (context=0x806c958) at gmain.c:1934 #17 0xb7b5aefd in IA__g_main_context_dispatch (context=0x806c958) at gmain.c:2484 #18 0xb7b5b3a8 in g_main_context_iterate (context=0x806c958, block=1, dispatch=1, self=0x804f5b0) at gmain.c:2565 #19 0xb7b5bb04 in IA__g_main_loop_run (loop=0x8285a30) at gmain.c:2769 #20 0xb7e4ec4f in gst_main () at gst.c:864 #21 0x08048e6b in main ()