From 15296967b6beec8e6f6c5ff4b7e8c274e5d05dca Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Sun, 5 Apr 2009 23:41:16 -0500 Subject: LLMediaImplGStreamer creates new thread for playing. This keeps the viewer responsive while GStreamer does its thing. --- linden/indra/llmedia/llmediaimplgstreamer.cpp | 27 +++++++++++++++++++++------ linden/indra/llmedia/llmediaimplgstreamer.h | 3 +++ 2 files changed, 24 insertions(+), 6 deletions(-) (limited to 'linden') diff --git a/linden/indra/llmedia/llmediaimplgstreamer.cpp b/linden/indra/llmedia/llmediaimplgstreamer.cpp index 2ba33a1..c8f793d 100644 --- a/linden/indra/llmedia/llmediaimplgstreamer.cpp +++ b/linden/indra/llmedia/llmediaimplgstreamer.cpp @@ -30,10 +30,12 @@ * $/LicenseInfo$ */ -#include "llmediaimplgstreamer.h" - ///#if LL_GSTREAMER_ENABLED +#include "linden_common.h" + +#include "llmediaimplgstreamer.h" + extern "C" { #include #include @@ -43,9 +45,8 @@ extern "C" { #include "llmediaimplregister.h" #include "llmediaimplgstreamervidplug.h" +#include "llgstplaythread.h" -#include "llerror.h" -#include "linden_common.h" // register this impl with media manager factory static LLMediaImplRegister sLLMediaImplGStreamerReg( "LLMediaImplGStreamer", new LLMediaImplGStreamerMaker() ); @@ -72,7 +73,8 @@ LLMediaImplGStreamer () : mPump ( NULL ), mPlaybin ( NULL ), mVideoSink ( NULL ), - mState( GST_STATE_NULL ) + mState( GST_STATE_NULL ), + mPlayThread ( NULL ) { startup( NULL ); // Startup gstreamer if it hasn't been already. @@ -713,7 +715,20 @@ bool LLMediaImplGStreamer::play() if (!mPlaybin || mState == GST_STATE_NULL) return true; - startPlay(); + // Clean up the existing thread, if any. + if( mPlayThread != NULL && mPlayThread->isStopped()) + { + delete mPlayThread; + mPlayThread = NULL; + } + + if( mPlayThread == NULL ) + { + // Make a new thread to start playing. This keeps the viewer + // responsive while the stream is resolved and buffered. + mPlayThread = new LLGstPlayThread( (LLMediaImplCommon *)this, "GstPlayThread", NULL); + mPlayThread->start(); + } return true; } diff --git a/linden/indra/llmedia/llmediaimplgstreamer.h b/linden/indra/llmedia/llmediaimplgstreamer.h index be4b3c0..32e6bd1 100644 --- a/linden/indra/llmedia/llmediaimplgstreamer.h +++ b/linden/indra/llmedia/llmediaimplgstreamer.h @@ -48,6 +48,7 @@ extern "C" { } #include "llmediaimplgstreamervidplug.h" +#include "llgstplaythread.h" class LLMediaManagerData; class LLMediaImplMaker; @@ -124,6 +125,8 @@ class LLMediaImplGStreamer: GstSLVideo *mVideoSink; GstState mState; GstState getState() const { return mState; } + + LLGstPlayThread *mPlayThread; }; class LLMediaImplGStreamerMaker : public LLMediaImplMaker -- cgit v1.1