From b145debcba6af423e990fddea6430ea414a37e06 Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Mon, 30 Mar 2009 01:56:18 -0700 Subject: removed gst_element_get_state --- linden/indra/llmedia/llmediaimplgstreamer.cpp | 74 ++++++++++++++++----------- 1 file changed, 45 insertions(+), 29 deletions(-) (limited to 'linden/indra/llmedia/llmediaimplgstreamer.cpp') diff --git a/linden/indra/llmedia/llmediaimplgstreamer.cpp b/linden/indra/llmedia/llmediaimplgstreamer.cpp index 3c4d0a0..952e22f 100644 --- a/linden/indra/llmedia/llmediaimplgstreamer.cpp +++ b/linden/indra/llmedia/llmediaimplgstreamer.cpp @@ -653,20 +653,23 @@ bool LLMediaImplGStreamer::stop() if (!mPlaybin || mState == GST_STATE_NULL) return true; - GstElement *pipeline = (GstElement *)gst_object_ref(GST_OBJECT(mPlaybin)); - gst_object_unref(pipeline); - - gst_element_set_state(pipeline, GST_STATE_READY); + GstStateChangeReturn state_change; - if (mState == GST_STATE_PLAYING) - mState = GST_STATE_VOID_PENDING; - else - mState = GST_STATE_READY; + state_change = gst_element_set_state(mPlaybin, GST_STATE_READY); - GstStateChangeReturn state_change = gst_element_get_state(mPlaybin, NULL, NULL, GST_MSECOND*5); - LL_DEBUGS("MediaImpl") << "get_state: " << gst_element_state_change_return_get_name(state_change) << LL_ENDL; + LL_DEBUGS("MediaImpl") << "result: " + << gst_element_state_change_return_get_name(state_change) << LL_ENDL; - return true; + if (state_change == GST_STATE_CHANGE_FAILURE) + { + LL_WARNS("MediaImpl") << "could not stop stream!" << LL_ENDL; + return false; + } + else + { + mState = GST_STATE_READY; + return true; + } } /////////////////////////////////////////////////////////////////////////////// @@ -678,25 +681,28 @@ bool LLMediaImplGStreamer::play() if (!mPlaybin || mState == GST_STATE_NULL) return true; - GstElement *pipeline = (GstElement *)gst_object_ref(GST_OBJECT(mPlaybin)); - gst_object_unref(pipeline); - - gst_element_set_state(pipeline, GST_STATE_PLAYING); - mState = GST_STATE_PLAYING; - /*gst_element_set_state(mPlaybin, GST_STATE_PLAYING); - mState = GST_STATE_PLAYING;*/ + GstStateChangeReturn state_change; + + state_change = gst_element_set_state(mPlaybin, GST_STATE_PLAYING); - GstStateChangeReturn state_change = gst_element_get_state(mPlaybin, NULL, NULL, GST_MSECOND*5); - LL_DEBUGS("MediaImpl") << "get_state: " << gst_element_state_change_return_get_name(state_change) << LL_ENDL; + LL_DEBUGS("MediaImpl") << "result: " + << gst_element_state_change_return_get_name(state_change) << LL_ENDL; // Check to make sure playing was successful. If not, stop. + // NOTE: state_change is almost always GST_STATE_CHANGE_ASYNC if (state_change == GST_STATE_CHANGE_FAILURE) { - setStatus(LLMediaBase::STATUS_STOPPED); + // If failing from a bad stream, go into pending state + // (this is stopped at the callback) + mState = GST_STATE_VOID_PENDING; stop(); + return false; + } + else + { + mState = GST_STATE_PLAYING; + return true; } - - return true; } /////////////////////////////////////////////////////////////////////////////// @@ -708,13 +714,23 @@ bool LLMediaImplGStreamer::pause() if (!mPlaybin || mState == GST_STATE_NULL) return true; - gst_element_set_state(mPlaybin, GST_STATE_PAUSED); - mState = GST_STATE_PAUSED; - - GstStateChangeReturn state_change = gst_element_get_state(mPlaybin, NULL, NULL, GST_MSECOND*5); - LL_DEBUGS("MediaImpl") << "get_state: " << gst_element_state_change_return_get_name(state_change) << LL_ENDL; + GstStateChangeReturn state_change; - return true; + state_change = gst_element_set_state(mPlaybin, GST_STATE_PAUSED); + + LL_DEBUGS("MediaImpl") << "result: " + << gst_element_state_change_return_get_name(state_change) << LL_ENDL; + + if (state_change == GST_STATE_CHANGE_FAILURE) + { + LL_WARNS("MediaImpl") << "could not pause stream!" << LL_ENDL; + return false; + } + else + { + mState = GST_STATE_PAUSED; + return true; + } }; -- cgit v1.1