From 551d8a6c8531ff6fbdf0e3e5fe32e943b6eec1d9 Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Wed, 18 Feb 2009 04:01:36 -0700 Subject: Fixed some bad comment formatting --- linden/indra/llaudio/audioengine.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'linden/indra') diff --git a/linden/indra/llaudio/audioengine.cpp b/linden/indra/llaudio/audioengine.cpp index da9bcba..3a079f1 100644 --- a/linden/indra/llaudio/audioengine.cpp +++ b/linden/indra/llaudio/audioengine.cpp @@ -186,14 +186,17 @@ void LLAudioEngine::startInternetStream(const std::string& url) if(!mInternetStreamMedia) return; - if (!url.empty()) { + if (!url.empty()) + { LL_INFOS("AudioEngine") << "Starting internet stream: " << url << llendl; mInternetStreamURL = url; mInternetStreamMedia->navigateTo ( url ); LL_INFOS("AudioEngine") << "Playing....." << llendl; mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_START); mInternetStreamMedia->updateMedia(); - } else { + } + else + { LL_INFOS("AudioEngine") << "setting stream to NULL"<< llendl; mInternetStreamURL.clear(); mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_STOP); @@ -207,9 +210,10 @@ void LLAudioEngine::stopInternetStream() { LL_INFOS("AudioEngine") << "entered stopInternetStream()" << llendl; - if(mInternetStreamMedia) + if(mInternetStreamMedia) { - if( ! mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_STOP)){ + if(!mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_STOP)) + { LL_INFOS("AudioEngine") << "attempting to stop stream failed!" << llendl; } mInternetStreamMedia->updateMedia(); @@ -232,7 +236,9 @@ void LLAudioEngine::pauseInternetStream(int pause) { LL_INFOS("AudioEngine") << "attempting to pause stream failed!" << llendl; } - } else { + } + else + { if(! mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_START)) { LL_INFOS("AudioEngine") << "attempting to unpause stream failed!" << llendl; -- cgit v1.1 From d3415294494f0f640f41560e035add0befb25259 Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Wed, 18 Feb 2009 04:07:28 -0700 Subject: Added error checking to play/stop/pause to prevent bad looping --- linden/indra/llmedia/llmediaimplgstreamer.cpp | 64 +++++++++++++--------- .../llmedia/llmediaimplgstreamer_syms_raw.inc | 2 + 2 files changed, 41 insertions(+), 25 deletions(-) (limited to 'linden/indra') diff --git a/linden/indra/llmedia/llmediaimplgstreamer.cpp b/linden/indra/llmedia/llmediaimplgstreamer.cpp index bae8ad9..d821bcd 100644 --- a/linden/indra/llmedia/llmediaimplgstreamer.cpp +++ b/linden/indra/llmedia/llmediaimplgstreamer.cpp @@ -36,6 +36,7 @@ extern "C" { #include +#include } #include "llmediamanager.h" @@ -93,22 +94,6 @@ LLMediaImplGStreamer () : // todo: cleanup pump return; // error } - - if (NULL == getenv("LL_GSTREAMER_EXTERNAL")) - { - // instantiate and connect a custom video sink - LL_DEBUGS("MediaManager") << "extrenal video sink..." << LL_ENDL; - mVideoSink = - GST_SLVIDEO(llgst_element_factory_make ("private-slvideo", "slvideo")); - if (!mVideoSink) - { - LL_WARNS("MediaImpl") << "Could not instantiate private-slvideo element." << LL_ENDL; - // todo: cleanup. - return; // error - } - - g_object_set(mPlaybin, "video-sink", mVideoSink, NULL); - } } // virtual @@ -394,7 +379,6 @@ bool LLMediaImplGStreamer::navigateTo (const std::string urlIn) // set URI g_object_set (G_OBJECT (mPlaybin), "uri", urlIn.c_str(), NULL); - //g_object_set (G_OBJECT (mPlaybin), "uri", "file:///tmp/movie", NULL); // get playbin's bus - perhaps this can/should be done in ctor GstBus *bus = llgst_pipeline_get_bus (GST_PIPELINE (mPlaybin)); @@ -567,10 +551,19 @@ bool LLMediaImplGStreamer::updateMedia() // bool LLMediaImplGStreamer::stop() { - LL_DEBUGS("MediaImpl") << "stopping media..." << LL_ENDL; - // todo: error-check this? - llgst_element_set_state(mPlaybin, GST_STATE_READY); + LL_DEBUGS("MediaImpl") << "attempting to stop..." << LL_ENDL; + + if (!mPlaybin) return true; + + GstElement *pipeline = (GstElement *)llgst_object_ref(GST_OBJECT(mPlaybin)); + llgst_object_unref(pipeline); + + llgst_element_set_state(pipeline, GST_STATE_READY); mState = GST_STATE_READY; + + GstStateChangeReturn state_change = llgst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE); + LL_DEBUGS("MediaImpl") << "get_state: " << state_change << LL_ENDL; + return true; } @@ -578,10 +571,25 @@ bool LLMediaImplGStreamer::stop() // bool LLMediaImplGStreamer::play() { - LL_DEBUGS("MediaImpl") << "playing media..." << LL_ENDL; - // todo: error-check this? - llgst_element_set_state(mPlaybin, GST_STATE_PLAYING); + LL_DEBUGS("MediaImpl") << "attempting to play..." << LL_ENDL; + + if (!mPlaybin) return true; + + GstElement *pipeline = (GstElement *)llgst_object_ref(GST_OBJECT(mPlaybin)); + llgst_object_unref(pipeline); + + llgst_element_set_state(pipeline, GST_STATE_PLAYING); mState = GST_STATE_PLAYING; + /*llgst_element_set_state(mPlaybin, GST_STATE_PLAYING); + mState = GST_STATE_PLAYING;*/ + + GstStateChangeReturn state_change = llgst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE); + LL_DEBUGS("MediaImpl") << "get_state: " << state_change << LL_ENDL; + + // Check to make sure playing was successful. If not, stop. + if (state_change == GST_STATE_CHANGE_FAILURE) + stop(); + return true; } @@ -589,10 +597,16 @@ bool LLMediaImplGStreamer::play() // bool LLMediaImplGStreamer::pause() { - LL_DEBUGS("MediaImpl") <<"pausing media..." << LL_ENDL; - // todo: error-check this? + LL_DEBUGS("MediaImpl") << "attempting to pause..." << LL_ENDL; + + if (!mPlaybin) return true; + llgst_element_set_state(mPlaybin, GST_STATE_PAUSED); mState = GST_STATE_PAUSED; + + GstStateChangeReturn state_change = llgst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE); + LL_DEBUGS("MediaImpl") << "get_state: " << state_change << LL_ENDL; + return true; }; diff --git a/linden/indra/llmedia/llmediaimplgstreamer_syms_raw.inc b/linden/indra/llmedia/llmediaimplgstreamer_syms_raw.inc index e17a7a0..9996ba4 100644 --- a/linden/indra/llmedia/llmediaimplgstreamer_syms_raw.inc +++ b/linden/indra/llmedia/llmediaimplgstreamer_syms_raw.inc @@ -7,7 +7,9 @@ LL_GST_SYM(true, gst_message_parse_error, void, GstMessage *message, GError **ge LL_GST_SYM(true, gst_message_parse_warning, void, GstMessage *message, GError **gerror, gchar **debug); LL_GST_SYM(true, gst_message_parse_state_changed, void, GstMessage *message, GstState *oldstate, GstState *newstate, GstState *pending); LL_GST_SYM(true, gst_element_set_state, GstStateChangeReturn, GstElement *element, GstState state); +LL_GST_SYM(true, gst_element_get_state, GstStateChangeReturn, GstElement *element, GstState *state, GstState *pending, GstClockTime timeout); LL_GST_SYM(true, gst_object_unref, void, gpointer object); +LL_GST_SYM(true, gst_object_ref, gpointer, gpointer object); LL_GST_SYM(true, gst_object_get_type, GType, void); LL_GST_SYM(true, gst_pipeline_get_type, GType, void); LL_GST_SYM(true, gst_pipeline_get_bus, GstBus*, GstPipeline *pipeline); -- cgit v1.1 From 1b7dec80a55365ebda061319a134cf87a1aaa61a Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Wed, 18 Feb 2009 07:07:31 -0700 Subject: Added GStreamer version info to About > Imprudence --- linden/indra/llmedia/llmediaimplgstreamer.cpp | 8 +++++--- linden/indra/llmedia/llmediaimplgstreamer_syms_raw.inc | 1 + linden/indra/newview/llfloaterabout.cpp | 10 ++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) (limited to 'linden/indra') diff --git a/linden/indra/llmedia/llmediaimplgstreamer.cpp b/linden/indra/llmedia/llmediaimplgstreamer.cpp index d821bcd..c7f2b4a 100644 --- a/linden/indra/llmedia/llmediaimplgstreamer.cpp +++ b/linden/indra/llmedia/llmediaimplgstreamer.cpp @@ -127,10 +127,12 @@ LLMediaImplGStreamer:: // virtual std::string LLMediaImplGStreamer::getVersion() { - std::string rtn; - rtn = "[" + sLLMediaImplGStreamerReg.getImplName() + "] - GStreamer 0.10.x"; - return rtn; + guint major, minor, micro, nano; + llgst_version(&major, &minor, µ, &nano); + std::string version = llformat("%d.%d.%d.%d",major,minor,micro,nano); + return version; } + // //THIS IS THE METHOD THAT'S BREAKING STUFF /////////////////////////////////////////////////////////////////////////////// diff --git a/linden/indra/llmedia/llmediaimplgstreamer_syms_raw.inc b/linden/indra/llmedia/llmediaimplgstreamer_syms_raw.inc index 9996ba4..fcee823 100644 --- a/linden/indra/llmedia/llmediaimplgstreamer_syms_raw.inc +++ b/linden/indra/llmedia/llmediaimplgstreamer_syms_raw.inc @@ -37,6 +37,7 @@ LL_GST_SYM(true, gst_value_get_fraction_numerator, gint, const GValue *value); LL_GST_SYM(true, gst_value_get_fraction_denominator, gint, const GValue *value); LL_GST_SYM(true, gst_structure_get_name, G_CONST_RETURN gchar *, const GstStructure *structure); LL_GST_SYM(true, gst_element_seek, bool, GstElement *, gdouble, GstFormat, GstSeekFlags, GstSeekType, gint64, GstSeekType, gint64); +LL_GST_SYM(true, gst_version, void, guint *major, guint *minor, guint *micro, guint *nano); // optional symbols to grab LL_GST_SYM(false, gst_segtrap_set_enabled, void, gboolean enabled); diff --git a/linden/indra/newview/llfloaterabout.cpp b/linden/indra/newview/llfloaterabout.cpp index 4953410..aeca4b5 100644 --- a/linden/indra/newview/llfloaterabout.cpp +++ b/linden/indra/newview/llfloaterabout.cpp @@ -42,6 +42,7 @@ #include "llcurl.h" #include "llimagej2c.h" #include "audioengine.h" +#include "llmediaimplgstreamer.h" #include "llviewertexteditor.h" #include "llviewercontrol.h" @@ -208,6 +209,15 @@ LLFloaterAbout::LLFloaterAbout() LLMediaManager *mgr = LLMediaManager::getInstance(); if (mgr) { + LLMediaBase *gstreamer = new LLMediaImplGStreamer(); + if (gstreamer) + { + support.append("GStreamer Version: "); + support.append( gstreamer->getVersion() ); + support.append("\n"); + } + delete gstreamer; + LLMediaBase *media_source = mgr->createSourceFromMimeType("http", "text/html"); if (media_source) { -- cgit v1.1 From 3d8d2e63eb60fc2268bd81b0f972ac9825b7214f Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Wed, 18 Feb 2009 12:24:17 -0700 Subject: Updated GStreamer comments --- linden/indra/llmedia/llmediaimplgstreamer.cpp | 36 +++++++++++++++++++++++---- linden/indra/llmedia/llmediaimplgstreamer.h | 1 + 2 files changed, 32 insertions(+), 5 deletions(-) (limited to 'linden/indra') diff --git a/linden/indra/llmedia/llmediaimplgstreamer.cpp b/linden/indra/llmedia/llmediaimplgstreamer.cpp index c7f2b4a..b17dbb9 100644 --- a/linden/indra/llmedia/llmediaimplgstreamer.cpp +++ b/linden/indra/llmedia/llmediaimplgstreamer.cpp @@ -73,7 +73,7 @@ LLMediaImplGStreamer () : mPump ( NULL ), mPlaybin ( NULL ), mVideoSink ( NULL ), - mState( GST_STATE_NULL ) + mState( GST_STATE_NULL ) { LL_DEBUGS("MediaManager") << "constructing media..." << LL_ENDL; mVolume = -1.0; // XXX Hack to make the vould change happend first time @@ -94,6 +94,24 @@ LLMediaImplGStreamer () : // todo: cleanup pump return; // error } + + if (NULL == getenv("LL_GSTREAMER_EXTERNAL")) + { + // instantiate and connect a custom video sink + LL_DEBUGS("MediaManager") << "extrenal video sink..." << LL_ENDL; + + // Plays inworld instead of in external player + mVideoSink = + GST_SLVIDEO(llgst_element_factory_make ("private-slvideo", "slvideo")); + if (!mVideoSink) + { + LL_WARNS("MediaImpl") << "Could not instantiate private-slvideo element." << LL_ENDL; + // todo: cleanup. + return; // error + } + + g_object_set(mPlaybin, "video-sink", mVideoSink, NULL); + } } // virtual @@ -134,7 +152,7 @@ std::string LLMediaImplGStreamer::getVersion() } // -//THIS IS THE METHOD THAT'S BREAKING STUFF +// STARTUP /////////////////////////////////////////////////////////////////////////////// // (static) super-initialization - called once at application startup bool LLMediaImplGStreamer::startup (LLMediaManagerData* init_data) @@ -148,6 +166,10 @@ bool LLMediaImplGStreamer::startup (LLMediaManagerData* init_data) // Get symbols! #if LL_WINDOWS if (! grab_gst_syms("libgstreamer-0.10.dll", "libgstvideo-0.10.dll", "libgstaudio-0.10.dll") ) + { + LL_WARNS("MediaImpl") << "Couldn't find suitable GStreamer 0.10 support on this system - video playback disabled." << LL_ENDL; + return false; + } #else if (! grab_gst_syms("libgstreamer-0.10.so.0", "libgstvideo-0.10.so.0", "libgstaudio-0.10.so.0") ) { @@ -167,7 +189,7 @@ bool LLMediaImplGStreamer::startup (LLMediaManagerData* init_data) saved_locale = setlocale(LC_ALL, NULL); if (0 == llgst_init_check(NULL, NULL, NULL)) { - LL_WARNS("MediaImpl") << "GST init failed for unspecified reason." << LL_ENDL; + LL_WARNS("MediaImpl") << "GStreamer library failed to initialize and load standard plugins." << LL_ENDL; setlocale(LC_ALL, saved_locale.c_str() ); return false; } @@ -191,6 +213,7 @@ bool LLMediaImplGStreamer::closedown() /////////////////////////////////////////////////////////////////////////////// // +// Uncomment the line below to enable spammy debug data. //#define LL_GST_REPORT_STATE_CHANGES #ifdef LL_GST_REPORT_STATE_CHANGES static const char* get_gst_state_name(GstState state) @@ -256,7 +279,8 @@ gboolean LLMediaImplGStreamer::bus_callback(GstBus *bus, GstMessage *message, gp LL_DEBUGS("MediaImpl") << "State changed to NULL" << LL_ENDL; #endif if (impl->getState() == GST_STATE_PLAYING) - { // We got stoped by gstremer... + { + // Stream was probably dropped, trying to restart impl->play(); #ifdef LL_GST_REPORT_STATE_CHANGES LL_DEBUGS("MediaImpl") << "Trying to restart." << LL_ENDL; @@ -590,7 +614,9 @@ bool LLMediaImplGStreamer::play() // Check to make sure playing was successful. If not, stop. if (state_change == GST_STATE_CHANGE_FAILURE) + { stop(); + } return true; } @@ -644,7 +670,7 @@ bool LLMediaImplGStreamer::seek(double time) // virtual bool LLMediaImplGStreamer::setVolume(float volume) { - // XXX hack to make volume volume changes less othen + // XXX hack to make volume volume changes less othen // bug in gstreamer 0.10.21 if(mVolume == volume) return true; diff --git a/linden/indra/llmedia/llmediaimplgstreamer.h b/linden/indra/llmedia/llmediaimplgstreamer.h index 5b493ad..10b01dd 100644 --- a/linden/indra/llmedia/llmediaimplgstreamer.h +++ b/linden/indra/llmedia/llmediaimplgstreamer.h @@ -84,6 +84,7 @@ class LLMediaImplGStreamer: bool pause(); bool stop(); bool play(); + static gboolean bus_callback (GstBus *bus, GstMessage *message, gpointer data); -- cgit v1.1 From 829e1b311f5fdd3c19d812b14cccf1175ddf6dc6 Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Fri, 20 Feb 2009 15:33:07 -0700 Subject: Added STATUS_DEAD to LLMediaBase --- linden/indra/llaudio/audioengine.cpp | 55 +++++++++++---------------- linden/indra/llaudio/audioengine.h | 6 ++- linden/indra/llmedia/llmediabase.h | 3 +- linden/indra/llmedia/llmediaimplgstreamer.cpp | 33 +++++++++++----- linden/indra/llmedia/llmediaimplgstreamer.h | 2 +- linden/indra/newview/lloverlaybar.cpp | 8 ---- 6 files changed, 55 insertions(+), 52 deletions(-) (limited to 'linden/indra') diff --git a/linden/indra/llaudio/audioengine.cpp b/linden/indra/llaudio/audioengine.cpp index 3a079f1..400e938 100644 --- a/linden/indra/llaudio/audioengine.cpp +++ b/linden/indra/llaudio/audioengine.cpp @@ -45,6 +45,8 @@ #include "llassetstorage.h" #include "llmediamanager.h" +#include "llmediabase.h" +#include "llmediaimplcommon.h" // necessary for grabbing sounds from sim (implemented in viewer) extern void request_sound(const LLUUID &sound_guid); @@ -101,6 +103,8 @@ void LLAudioEngine::setDefaults() for (U32 i = 0; i < LLAudioEngine::AUDIO_TYPE_COUNT; i++) mSecondaryGain[i] = 1.0f; + + mStatus = LLMediaBase::STATUS_UNKNOWN; } @@ -168,6 +172,14 @@ void LLAudioEngine::shutdown() } +//////////////////////////////////////////////////////////////////////////////// +// virtual (derives from LLMediaBase) +LLMediaBase::EStatus LLAudioEngine::getStatus() +{ + return mStatus; +} + + // virtual void LLAudioEngine::startInternetStream(const std::string& url) { @@ -179,12 +191,22 @@ void LLAudioEngine::startInternetStream(const std::string& url) if (mgr) { mInternetStreamMedia = mgr->createSourceFromMimeType(LLURI(url).scheme(), "audio/mpeg"); // assumes that whatever media implementation supports mp3 also supports vorbis. - LL_INFOS("AudioEngine") << "mInternetStreamMedia is now " << mInternetStreamMedia << llendl; + //LL_INFOS("AudioEngine") << "mInternetStreamMedia is now " << mInternetStreamMedia << llendl; } } if(!mInternetStreamMedia) return; + + // Check for a dead stream, just in case + if(getStatus() == LLMediaBase::STATUS_DEAD) + { + mInternetStreamURL.clear(); + mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_STOP); + mInternetStreamMedia->updateMedia(); + stopInternetStream(); + return; + } if (!url.empty()) { @@ -202,7 +224,6 @@ void LLAudioEngine::startInternetStream(const std::string& url) mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_STOP); mInternetStreamMedia->updateMedia(); } - //#endif } // virtual @@ -223,31 +244,6 @@ void LLAudioEngine::stopInternetStream() } // virtual -void LLAudioEngine::pauseInternetStream(int pause) -{ - LL_INFOS("AudioEngine") << "entered pauseInternetStream()" << llendl; - - if(!mInternetStreamMedia) - return; - - if(pause) - { - if(! mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_PAUSE)) - { - LL_INFOS("AudioEngine") << "attempting to pause stream failed!" << llendl; - } - } - else - { - if(! mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_START)) - { - LL_INFOS("AudioEngine") << "attempting to unpause stream failed!" << llendl; - } - } - mInternetStreamMedia->updateMedia(); -} - -// virtual void LLAudioEngine::updateInternetStream() { if (mInternetStreamMedia) @@ -265,11 +261,6 @@ int LLAudioEngine::isInternetStreamPlaying() return 1; // Active and playing } - if (mInternetStreamMedia->getStatus() == LLMediaBase::STATUS_PAUSED) - { - return 2; // paused - } - return 0; // Stopped } diff --git a/linden/indra/llaudio/audioengine.h b/linden/indra/llaudio/audioengine.h index 15cb35f..878a96a 100644 --- a/linden/indra/llaudio/audioengine.h +++ b/linden/indra/llaudio/audioengine.h @@ -45,6 +45,8 @@ #include "llframetimer.h" #include "llassettype.h" +#include "llmediabase.h" + class LLMediaBase; const F32 LL_WIND_UPDATE_INTERVAL = 0.1f; @@ -153,13 +155,13 @@ public: // Internet stream methods virtual void startInternetStream(const std::string& url); virtual void stopInternetStream(); - virtual void pauseInternetStream(int pause); virtual void updateInternetStream(); virtual int isInternetStreamPlaying(); virtual void getInternetStreamInfo(char* artist, char* title); // use a value from 0.0 to 1.0, inclusive virtual void setInternetStreamGain(F32 vol); virtual const std::string& getInternetStreamURL(); + virtual LLMediaBase::EStatus getStatus(); // For debugging usage virtual LLVector3 getListenerPos(); @@ -246,6 +248,8 @@ protected: LLFrameTimer mWindUpdateTimer; + LLMediaBase::EStatus mStatus; + private: void setDefaults(); LLMediaBase *mInternetStreamMedia; diff --git a/linden/indra/llmedia/llmediabase.h b/linden/indra/llmedia/llmediabase.h index dad02ca..b5b9420 100644 --- a/linden/indra/llmedia/llmediabase.h +++ b/linden/indra/llmedia/llmediabase.h @@ -153,7 +153,8 @@ class LLMediaBase STATUS_STARTED = 3, STATUS_STOPPED = 4, STATUS_PAUSED = 6, - STATUS_RESETTING = 7 + STATUS_RESETTING = 7, + STATUS_DEAD = 8 }; virtual bool addCommand( ECommand cmd ) = 0; virtual bool clearCommand() = 0; diff --git a/linden/indra/llmedia/llmediaimplgstreamer.cpp b/linden/indra/llmedia/llmediaimplgstreamer.cpp index b17dbb9..20a1fc3 100644 --- a/linden/indra/llmedia/llmediaimplgstreamer.cpp +++ b/linden/indra/llmedia/llmediaimplgstreamer.cpp @@ -395,8 +395,7 @@ bool LLMediaImplGStreamer::navigateTo (const std::string urlIn) LL_DEBUGS("MediaImpl") << "Setting media URI: " << urlIn.c_str() << LL_ENDL; - if (NULL == mPump - || NULL == mPlaybin) + if (mPump == NULL || mPlaybin == NULL) { return false; } @@ -415,6 +414,8 @@ bool LLMediaImplGStreamer::navigateTo (const std::string urlIn) llgst_bus_add_watch (bus, bus_callback, this); llgst_object_unref (bus); + mState = GST_STATE_READY; + // navigateTo implicitly plays, too. play(); @@ -447,6 +448,8 @@ bool LLMediaImplGStreamer::unload() } mVideoSink = NULL; + mState = GST_STATE_NULL; + setStatus(LLMediaBase::STATUS_DEAD); return true; } @@ -458,15 +461,19 @@ bool LLMediaImplGStreamer::updateMedia() //LL_DEBUGS("MediaImpl") << "updating media..." << LL_ENDL; // sanity check - if (NULL == mPump - || NULL == mPlaybin) + if (mPump == NULL || mPlaybin == NULL) { #ifdef LL_GST_REPORT_STATE_CHANGES LL_DEBUGS("MediaImpl") << "dead media..." << LL_ENDL; #endif + mState = GST_STATE_NULL; + setStatus(LLMediaBase::STATUS_DEAD); return false; } + if (mState == GST_STATE_VOID_PENDING || mState == GST_STATE_NULL) + return false; + // process next outstanding command switch (nextCommand()) { @@ -579,13 +586,18 @@ bool LLMediaImplGStreamer::stop() { LL_DEBUGS("MediaImpl") << "attempting to stop..." << LL_ENDL; - if (!mPlaybin) return true; + if (!mPlaybin || mState == GST_STATE_NULL) + return true; GstElement *pipeline = (GstElement *)llgst_object_ref(GST_OBJECT(mPlaybin)); llgst_object_unref(pipeline); llgst_element_set_state(pipeline, GST_STATE_READY); - mState = GST_STATE_READY; + + if (mState == GST_STATE_PLAYING) + mState = GST_STATE_VOID_PENDING; + else + mState = GST_STATE_READY; GstStateChangeReturn state_change = llgst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE); LL_DEBUGS("MediaImpl") << "get_state: " << state_change << LL_ENDL; @@ -599,7 +611,8 @@ bool LLMediaImplGStreamer::play() { LL_DEBUGS("MediaImpl") << "attempting to play..." << LL_ENDL; - if (!mPlaybin) return true; + if (!mPlaybin || mState == GST_STATE_NULL) + return true; GstElement *pipeline = (GstElement *)llgst_object_ref(GST_OBJECT(mPlaybin)); llgst_object_unref(pipeline); @@ -615,6 +628,7 @@ bool LLMediaImplGStreamer::play() // Check to make sure playing was successful. If not, stop. if (state_change == GST_STATE_CHANGE_FAILURE) { + setStatus(LLMediaBase::STATUS_STOPPED); stop(); } @@ -627,7 +641,8 @@ bool LLMediaImplGStreamer::pause() { LL_DEBUGS("MediaImpl") << "attempting to pause..." << LL_ENDL; - if (!mPlaybin) return true; + if (!mPlaybin || mState == GST_STATE_NULL) + return true; llgst_element_set_state(mPlaybin, GST_STATE_PAUSED); mState = GST_STATE_PAUSED; @@ -675,7 +690,7 @@ bool LLMediaImplGStreamer::setVolume(float volume) if(mVolume == volume) return true; - LL_DEBUGS("MediaImpl") << "setVolume(" << volume << ") : " << getpid() << LL_ENDL; + LL_DEBUGS("MediaImpl") << "setVolume(" << volume << ") : " << getpid() << LL_ENDL; mVolume = volume; if (mPlaybin) { diff --git a/linden/indra/llmedia/llmediaimplgstreamer.h b/linden/indra/llmedia/llmediaimplgstreamer.h index 10b01dd..dec970a 100644 --- a/linden/indra/llmedia/llmediaimplgstreamer.h +++ b/linden/indra/llmedia/llmediaimplgstreamer.h @@ -74,7 +74,7 @@ class LLMediaImplGStreamer: /* virtual */ int getTextureFormatType() const; /* virtual */ int getTextureFormatInternal() const; /* virtual */ bool seek( double time ); - /* virtual */ bool setVolume( float volume ); + /* virtual */ bool setVolume( float volume ); LLMediaEmitter< LLMediaObserver > getEventEmitter() const {return mEventEmitter;}; diff --git a/linden/indra/newview/lloverlaybar.cpp b/linden/indra/newview/lloverlaybar.cpp index 80cac14..a4eedbb 100644 --- a/linden/indra/newview/lloverlaybar.cpp +++ b/linden/indra/newview/lloverlaybar.cpp @@ -391,14 +391,6 @@ void LLOverlayBar::toggleMusicPlay(void*) } } } - //else - //{ - // gOverlayBar->mMusicState = PAUSED; // desired state - // if (gAudiop) - // { - // gAudiop->pauseInternetStream(1); - // } - //} else { gOverlayBar->mMusicState = STOPPED; // desired state -- cgit v1.1 From f36844960f4b03ca52006ae5608f0062f5a9f557 Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Fri, 20 Feb 2009 18:04:44 -0700 Subject: get_state shows name info --- linden/indra/llmedia/llmediaimplgstreamer.cpp | 6 +++--- linden/indra/llmedia/llmediaimplgstreamer_syms_raw.inc | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'linden/indra') diff --git a/linden/indra/llmedia/llmediaimplgstreamer.cpp b/linden/indra/llmedia/llmediaimplgstreamer.cpp index 20a1fc3..ece3fb0 100644 --- a/linden/indra/llmedia/llmediaimplgstreamer.cpp +++ b/linden/indra/llmedia/llmediaimplgstreamer.cpp @@ -600,7 +600,7 @@ bool LLMediaImplGStreamer::stop() mState = GST_STATE_READY; GstStateChangeReturn state_change = llgst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE); - LL_DEBUGS("MediaImpl") << "get_state: " << state_change << LL_ENDL; + LL_DEBUGS("MediaImpl") << "get_state: " << llgst_element_state_change_return_get_name(state_change) << LL_ENDL; return true; } @@ -623,7 +623,7 @@ bool LLMediaImplGStreamer::play() mState = GST_STATE_PLAYING;*/ GstStateChangeReturn state_change = llgst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE); - LL_DEBUGS("MediaImpl") << "get_state: " << state_change << LL_ENDL; + LL_DEBUGS("MediaImpl") << "get_state: " << llgst_element_state_change_return_get_name(state_change) << LL_ENDL; // Check to make sure playing was successful. If not, stop. if (state_change == GST_STATE_CHANGE_FAILURE) @@ -648,7 +648,7 @@ bool LLMediaImplGStreamer::pause() mState = GST_STATE_PAUSED; GstStateChangeReturn state_change = llgst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE); - LL_DEBUGS("MediaImpl") << "get_state: " << state_change << LL_ENDL; + LL_DEBUGS("MediaImpl") << "get_state: " << llgst_element_state_change_return_get_name(state_change) << LL_ENDL; return true; }; diff --git a/linden/indra/llmedia/llmediaimplgstreamer_syms_raw.inc b/linden/indra/llmedia/llmediaimplgstreamer_syms_raw.inc index fcee823..0d0d764 100644 --- a/linden/indra/llmedia/llmediaimplgstreamer_syms_raw.inc +++ b/linden/indra/llmedia/llmediaimplgstreamer_syms_raw.inc @@ -38,6 +38,7 @@ LL_GST_SYM(true, gst_value_get_fraction_denominator, gint, const GValue *value); LL_GST_SYM(true, gst_structure_get_name, G_CONST_RETURN gchar *, const GstStructure *structure); LL_GST_SYM(true, gst_element_seek, bool, GstElement *, gdouble, GstFormat, GstSeekFlags, GstSeekType, gint64, GstSeekType, gint64); LL_GST_SYM(true, gst_version, void, guint *major, guint *minor, guint *micro, guint *nano); +LL_GST_SYM(true, gst_element_state_change_return_get_name, const gchar *, GstStateChangeReturn state_ret); // optional symbols to grab LL_GST_SYM(false, gst_segtrap_set_enabled, void, gboolean enabled); -- cgit v1.1