[gst-devel] How to flush a bus when removing an element from a pipeline?

wl2776 wl2776 at gmail.com
Fri Apr 23 10:45:48 CEST 2010



wl2776 wrote:
> 
> 
> Edward Hervey wrote:
>> 
>> On Thu, 2010-04-22 at 22:52 -0800, wl2776 wrote:
>>> My application adds an uridecodebin instance to the pipeline, and then
>>> removes it, if the element doesn't go to the paused state (this can
>>> happen,
>>> if a non-media file was supplied to the uridecodebin) and returns
>>> GST_STATE_CHANGE_FAILURE.
>> 
>>   Have you set uridecodebin to NULL before removing it ? Have you made
>> sure it didn't connect to anything ? Did you hold an extra reference to
>> uridecodebin before adding it to the pipeline (if not, the pipeline
>> *stole* your reference and you shouldn't have to unref it after removing
>> it from the pipeline).
>> 
> The exact code.
> 
> while(<have a file in a directory and no video or audio stream>) {
>   gboolean rb=FALSE;
>   uridecodebin[1]=gst_element_factory_make("uridecodebin",
>                                            
> (m_video_present)?"audio_decodebin":"video_decodebin");
>   if(uridecodebin[1])
>      rb=gst_bin_add(GST_BIN(m_player),uridecodebin[1]);
>   if(rb){
>      g_object_set(G_OBJECT(uridecodebin[1]),"uri",file_uri,NULL);
>   
>      h_id2=g_signal_connect(G_OBJECT(uridecodebin[1]),"no-more-pads",
>                                     G_CALLBACK(no_more_pads_cb),this);
>      h_id3=g_signal_connect(G_OBJECT(uridecodebin[1]),"unknown-type",
>                                     G_CALLBACK(unknown_type_cb),this);
>      rs=gst_element_set_state(m_player,GST_STATE_PAUSED);
> 
>      while(m_player->current_state!=GST_STATE_PAUSED &&
>           !(m_flags & FLAG_DORENDER_COMPLETE) && 
>            rs!=GST_STATE_CHANGE_FAILURE){
>  	 g_usleep(100000);
>      } 
>      g_signal_handler_disconnect(G_OBJECT(uridecodebin[1]),h_id2);
>      g_signal_handler_disconnect(G_OBJECT(uridecodebin[1]),h_id3);
> 
>      if(rs==GST_STATE_CHANGE_FAILURE){
>         gst_element_set_state(GST_ELEMENT(m_player),GST_STATE_NULL);
>         gst_bin_remove(GST_BIN(m_player),uridecodebin[1]);
>         gst_object_unref(uridecodebin[1]);
>         uridecodebin[1]=NULL;
>      }
>   }
> }
> 
> 
> So, yes, I've put the uridecodebin to NULL.
> No, I didn't hold the extra reference - will remove
> gst_object_unref(uridecodebin[1]);
> 

I have removed gst_object_unref(uridecodebin[1]);
Then, the application run successfully two times, and I've got an Error
message box from GLib, saying it has "recursed", on the third run. 
Unfortunately, I could not read the whole message, as this message box was
covered by the Studio's windows and didn't redraw completely. 
Studio's debug output contained about 10 messages about the first chance
exception Reading location 0xaddress and Writing location 0xanoter_address
The my system has become almost unresponsive, only Alt-Tab has shown a
window, but nothing else happens, so I had to reboot it.
-- 
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/How-to-flush-a-bus-when-removing-an-element-from-a-pipeline-tp2027847p2036455.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.




More information about the gstreamer-devel mailing list