gst_element_set_state failure and bus messages

Tim Müller tim at centricular.com
Thu Aug 7 15:19:40 PDT 2014


On Tue, 2014-07-29 at 11:50 +0200, Carlos Rafael Giani wrote:

Hi,

> I saw something strange the other day with state changes with GStreamer 
> 1.2.0. During a test, I intentionally used filesrc with an invalid 
> filename. As expected, the state change from READY to PAUSED failed. As 
> part of the cleanup operation that followed, I called 
> gst_element_set_state() again, this time setting the pipeline to the 
> NULL state. This returned GST_STATE_CHANGE_SUCCESS , so the state change 
> finished immediately. Perhaps the pipeline is automatically set to NULL 
> if a state change fails?

No, the pipeline is not automatically set to NULL state if a state
change fails.

> Either way, I also noticed that the bus watch did not get any kind of 
> message that the state was changed to NULL.

This is expected default behaviour. When you set the pipeline to NULL
state, the pipeline's bus gets set to flushing, which means all messages
on it will get discarded, including the 'state-change from READY to
NULL' message.

> This caused problems, because some final cleanup operations rely on
> seeing a state change to NULL in the bus watch.

You can set the "auto-flush-bus" property on the pipeline to FALSE, in
which case you will get to see that message. You just need to take care
to clean up any pending messages on the bus yourself as needed.


> Is this some kind of exception? If state change fails, it is implicitely 
> set to NULL, and no state change messages will occur? Or perhaps this is 
> just a bug? I will test with a newer GStreamer version today.
> Also, if a state change finishes immediately (that is, returns 
> GST_STATE_CHANGE_SUCCESS instead of GST_STATE_CHANGE_ASYNC), will it 
> still produce bus watch statechange messages?

No, expected behaviour if I understand you correctly.

Cheers
 -Tim

-- 
Tim Müller, Centricular Ltd - http://www.centricular.com



More information about the gstreamer-devel mailing list