<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
I reply to myself:<br><br>2 things:<br><br>1. I was using decodebin wich tends to be deprecated now AFAIK; I've rewritten it with playbin2;<br><br>2. it is solved in my new rewriting; I'm not sure how I did, but I&nbsp; have noticed this:<br><br>I have started a new playbin2 function from scratch : it worked; then i tried to link it from my gtk graphical interface : it didn't work; the call to the function with playbin2 was direct, like that :<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; g_signal_connect(G_OBJECT(pButton[0]), "clicked", G_CALLBACK(playbin2), NULL);<br><br>When I changed, to <br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; g_signal_connect(G_OBJECT(pButton[0]), "clicked", G_CALLBACK(onPlay), NULL); <br><br>where the 'onPlay' function calls the playbin2 function, it started to work... but it still doesn't make sense for me.......<br><br>Victor<br><br><hr id="stopSpelling">From: nadaeck@hotmail.com<br>To: gstreamer-devel@lists.freedesktop.org<br>Subject: call to the GstBus unexpectedly stops while playing audio file....<br>Date: Sat, 23 Apr 2011 19:55:36 +0200<br><br>

<meta http-equiv="Content-Type" content="text/html; charset=unicode">
<meta name="Generator" content="Microsoft SafeHTML">
<style>
.ExternalClass .ecxhmmessage P
{padding:0px;}
.ExternalClass body.ecxhmmessage
{font-size:10pt;font-family:Tahoma;}

</style>


Hello<br><br>I'm playing an audio files with decodebin. This works fine but and the file is played, but the call to the GstBus is somehow stopped while the file is still beeing played, despite the bus calling function returns TRUE everytime.<br><br>I have added a 'spectrum' element since my goal is to work on harmonics analysis.<br>&nbsp;<br>Please how could I fix this?<br><br>This is the code : <br><br>#include &lt;stdlib.h&gt;<br>#include &lt;stdio.h&gt;<br>#include &lt;string.h&gt;<br>#include &lt;gst/gst.h&gt;<br><br>GstElement *audio;<br>int counter = 0;<br>GMainLoop *loop;<br><br>static void cb_newpad (GstElement *decodebin, GstPad *pad, gboolean last, gpointer data)<br>{<br>&nbsp; GstCaps *caps;<br>&nbsp; GstStructure *str;<br>&nbsp; GstPad *audiopad;<br><br>&nbsp; audiopad = gst_element_get_static_pad (audio, "sink");<br>&nbsp; if (GST_PAD_IS_LINKED (audiopad)) {<br>&nbsp;&nbsp;&nbsp; g_object_unref (audiopad);<br>&nbsp;&nbsp;&nbsp; return;<br>&nbsp; }<br><br>&nbsp; caps = gst_pad_get_caps (pad);<br>&nbsp; str = gst_caps_get_structure (caps, 0);<br>&nbsp; if (!g_strrstr (gst_structure_get_name (str), "audio")) {<br>&nbsp;&nbsp;&nbsp; gst_caps_unref (caps);<br>&nbsp;&nbsp;&nbsp; gst_object_unref (audiopad);<br>&nbsp;&nbsp;&nbsp; return;<br>&nbsp; }<br>&nbsp; gst_caps_unref (caps);<br><br>&nbsp; gst_pad_link (pad, audiopad);<br>&nbsp; g_object_unref (audiopad);<br>}<br><br>static gboolean message_handler (GstBus * bus, GstMessage * message, gpointer data)<br>{&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp; &nbsp;counter ++;<br>&nbsp;&nbsp; &nbsp;printf("%d\n", counter);<br>&nbsp;&nbsp; &nbsp;int ii = 0;<br>&nbsp;&nbsp; &nbsp;const GValue *magnitudes;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (message-&gt;type == GST_MESSAGE_ELEMENT) {<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;counter = 0;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;const GstStructure *s = gst_message_get_structure (message);<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;const gchar *name = gst_structure_get_name (s);<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;GstClockTime endtime;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (strcmp (name, "spectrum") == 0) {<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if (!gst_structure_get_clock_time (s, "endtime", &amp;endtime)){<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//endtime = GST_CLOCK_TIME_NONE;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;magnitudes = gst_structure_get_value (s, "magnitude");<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br>&nbsp;&nbsp; &nbsp;else if (message-&gt;type == GST_MESSAGE_EOS) {<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;g_main_loop_quit (loop);<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br>return TRUE;<br>}<br><br>main(int argc, char **argv)<br>{<br>&nbsp;&nbsp; &nbsp;int AUDIOFREQ = 44100;<br>&nbsp;&nbsp; &nbsp;int interval = 100000000;<br>&nbsp;&nbsp; &nbsp;int spect_bands = 20;<br>&nbsp;&nbsp; &nbsp;GstElement *src, *dec, *audioconvert, *conv, *spectrum, *sink;<br>&nbsp;&nbsp; &nbsp;GstBus *bus;<br>&nbsp;&nbsp; &nbsp;GstCaps *caps;<br>&nbsp;&nbsp; &nbsp;GstPad *audiopad;<br>&nbsp;&nbsp; &nbsp;GstStateChangeReturn res;<br>&nbsp;&nbsp; &nbsp;GstElement *pipeline;<br>&nbsp;&nbsp; &nbsp;gchar *uri;<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp; &nbsp;gst_init (NULL, NULL);<br>&nbsp;&nbsp; &nbsp;loop = g_main_loop_new(NULL, FALSE);<br><br>&nbsp;&nbsp; &nbsp;pipeline = gst_pipeline_new ("pipeline");<br>&nbsp;&nbsp; &nbsp;bus = gst_element_get_bus (pipeline);<br>&nbsp;&nbsp; &nbsp;gst_bus_add_watch (bus, message_handler, loop);<br>&nbsp;&nbsp; &nbsp;gst_object_unref (bus);<br><br>&nbsp;&nbsp; &nbsp;src = gst_element_factory_make ("filesrc", "source");<br>&nbsp;&nbsp; &nbsp;g_object_set (G_OBJECT (src), "location", "/home/victor/Music/chopin_nocturne.mp3" , NULL);<br>&nbsp;&nbsp; &nbsp;dec = gst_element_factory_make ("decodebin", "decoder");<br>&nbsp;&nbsp; &nbsp;g_signal_connect (dec, "new-decoded-pad", G_CALLBACK (cb_newpad), NULL);<br>&nbsp;&nbsp; &nbsp;spectrum = gst_element_factory_make ("spectrum", "spectrum");<br>&nbsp;&nbsp; &nbsp;g_object_set (G_OBJECT (spectrum), "bands", spect_bands, "threshold", -80,<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; "message", TRUE, "message-phase", TRUE, "interval", interval, NULL);<br>&nbsp;&nbsp; &nbsp;gst_bin_add_many (GST_BIN (pipeline), src, dec, NULL);<br>&nbsp;&nbsp; &nbsp;gst_element_link (src, dec);<br><br>&nbsp;&nbsp; &nbsp;audio = gst_bin_new ("audiobin");<br>&nbsp;&nbsp; &nbsp;conv = gst_element_factory_make ("audioconvert", "aconv");<br>&nbsp;&nbsp; &nbsp;audiopad = gst_element_get_static_pad (conv, "sink");<br>&nbsp;&nbsp; &nbsp;sink = gst_element_factory_make ("alsasink", "sink");<br>&nbsp;&nbsp; &nbsp;gst_bin_add_many (GST_BIN (audio), conv, spectrum, sink, NULL);<br>&nbsp;&nbsp; &nbsp;gst_element_link_many (conv, spectrum, sink, NULL);<br>&nbsp;&nbsp; &nbsp;gst_element_add_pad (audio,<br>&nbsp;&nbsp; &nbsp;gst_ghost_pad_new ("sink", audiopad));<br>&nbsp;&nbsp; &nbsp;gst_object_unref (audiopad);<br>&nbsp;&nbsp; &nbsp;gst_bin_add (GST_BIN (pipeline), audio);<br><br>&nbsp;&nbsp; &nbsp;gst_element_set_state (pipeline, GST_STATE_PLAYING);<br>&nbsp;&nbsp; &nbsp;<br>&nbsp;&nbsp; &nbsp;g_main_loop_run (loop);<br>&nbsp;&nbsp; &nbsp;gst_element_set_state (pipeline, GST_STATE_NULL);<br>&nbsp;&nbsp; &nbsp;gst_object_unref (GST_OBJECT (pipeline));<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>}<br><br><br>This works since the music is played (I've chosen a defined mp3 piece from my hard drive), but the counter that is the 'message_handler' function stops at '43'.....<br><br>Does anyone have a clue to help me please? <br><br>Thank you <br><br>Victor                                               
<br>_______________________________________________
gstreamer-devel mailing list
gstreamer-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel                                               </body>
</html>