<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 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> g_signal_connect(G_OBJECT(pButton[0]), "clicked", G_CALLBACK(playbin2), NULL);<br><br>When I changed, to <br><br> 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> <br>Please how could I fix this?<br><br>This is the code : <br><br>#include <stdlib.h><br>#include <stdio.h><br>#include <string.h><br>#include <gst/gst.h><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> GstCaps *caps;<br> GstStructure *str;<br> GstPad *audiopad;<br><br> audiopad = gst_element_get_static_pad (audio, "sink");<br> if (GST_PAD_IS_LINKED (audiopad)) {<br> g_object_unref (audiopad);<br> return;<br> }<br><br> caps = gst_pad_get_caps (pad);<br> str = gst_caps_get_structure (caps, 0);<br> if (!g_strrstr (gst_structure_get_name (str), "audio")) {<br> gst_caps_unref (caps);<br> gst_object_unref (audiopad);<br> return;<br> }<br> gst_caps_unref (caps);<br><br> gst_pad_link (pad, audiopad);<br> g_object_unref (audiopad);<br>}<br><br>static gboolean message_handler (GstBus * bus, GstMessage * message, gpointer data)<br>{ <br> counter ++;<br> printf("%d\n", counter);<br> int ii = 0;<br> const GValue *magnitudes;<br> <br> if (message->type == GST_MESSAGE_ELEMENT) {<br> counter = 0;<br> const GstStructure *s = gst_message_get_structure (message);<br> const gchar *name = gst_structure_get_name (s);<br> GstClockTime endtime;<br> <br> if (strcmp (name, "spectrum") == 0) {<br> if (!gst_structure_get_clock_time (s, "endtime", &endtime)){<br> //endtime = GST_CLOCK_TIME_NONE;<br> magnitudes = gst_structure_get_value (s, "magnitude");<br> }<br> }<br> <br> }<br> else if (message->type == GST_MESSAGE_EOS) {<br> g_main_loop_quit (loop);<br> }<br>return TRUE;<br>}<br><br>main(int argc, char **argv)<br>{<br> int AUDIOFREQ = 44100;<br> int interval = 100000000;<br> int spect_bands = 20;<br> GstElement *src, *dec, *audioconvert, *conv, *spectrum, *sink;<br> GstBus *bus;<br> GstCaps *caps;<br> GstPad *audiopad;<br> GstStateChangeReturn res;<br> GstElement *pipeline;<br> gchar *uri;<br> <br> <br> gst_init (NULL, NULL);<br> loop = g_main_loop_new(NULL, FALSE);<br><br> pipeline = gst_pipeline_new ("pipeline");<br> bus = gst_element_get_bus (pipeline);<br> gst_bus_add_watch (bus, message_handler, loop);<br> gst_object_unref (bus);<br><br> src = gst_element_factory_make ("filesrc", "source");<br> g_object_set (G_OBJECT (src), "location", "/home/victor/Music/chopin_nocturne.mp3" , NULL);<br> dec = gst_element_factory_make ("decodebin", "decoder");<br> g_signal_connect (dec, "new-decoded-pad", G_CALLBACK (cb_newpad), NULL);<br> spectrum = gst_element_factory_make ("spectrum", "spectrum");<br> g_object_set (G_OBJECT (spectrum), "bands", spect_bands, "threshold", -80,<br> "message", TRUE, "message-phase", TRUE, "interval", interval, NULL);<br> gst_bin_add_many (GST_BIN (pipeline), src, dec, NULL);<br> gst_element_link (src, dec);<br><br> audio = gst_bin_new ("audiobin");<br> conv = gst_element_factory_make ("audioconvert", "aconv");<br> audiopad = gst_element_get_static_pad (conv, "sink");<br> sink = gst_element_factory_make ("alsasink", "sink");<br> gst_bin_add_many (GST_BIN (audio), conv, spectrum, sink, NULL);<br> gst_element_link_many (conv, spectrum, sink, NULL);<br> gst_element_add_pad (audio,<br> gst_ghost_pad_new ("sink", audiopad));<br> gst_object_unref (audiopad);<br> gst_bin_add (GST_BIN (pipeline), audio);<br><br> gst_element_set_state (pipeline, GST_STATE_PLAYING);<br> <br> g_main_loop_run (loop);<br> gst_element_set_state (pipeline, GST_STATE_NULL);<br> gst_object_unref (GST_OBJECT (pipeline));<br> <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>