aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra
diff options
context:
space:
mode:
authorMcCabe Maxsted2009-02-20 15:33:07 -0700
committerMcCabe Maxsted2009-02-20 15:33:07 -0700
commit829e1b311f5fdd3c19d812b14cccf1175ddf6dc6 (patch)
tree148792be99dc308a5a95b1b50705e17a81a8565d /linden/indra
parentUpdated GStreamer comments (diff)
downloadmeta-impy-829e1b311f5fdd3c19d812b14cccf1175ddf6dc6.zip
meta-impy-829e1b311f5fdd3c19d812b14cccf1175ddf6dc6.tar.gz
meta-impy-829e1b311f5fdd3c19d812b14cccf1175ddf6dc6.tar.bz2
meta-impy-829e1b311f5fdd3c19d812b14cccf1175ddf6dc6.tar.xz
Added STATUS_DEAD to LLMediaBase
Diffstat (limited to 'linden/indra')
-rw-r--r--linden/indra/llaudio/audioengine.cpp55
-rw-r--r--linden/indra/llaudio/audioengine.h6
-rw-r--r--linden/indra/llmedia/llmediabase.h3
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamer.cpp33
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamer.h2
-rw-r--r--linden/indra/newview/lloverlaybar.cpp8
6 files changed, 55 insertions, 52 deletions
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 @@
45#include "llassetstorage.h" 45#include "llassetstorage.h"
46 46
47#include "llmediamanager.h" 47#include "llmediamanager.h"
48#include "llmediabase.h"
49#include "llmediaimplcommon.h"
48 50
49// necessary for grabbing sounds from sim (implemented in viewer) 51// necessary for grabbing sounds from sim (implemented in viewer)
50extern void request_sound(const LLUUID &sound_guid); 52extern void request_sound(const LLUUID &sound_guid);
@@ -101,6 +103,8 @@ void LLAudioEngine::setDefaults()
101 103
102 for (U32 i = 0; i < LLAudioEngine::AUDIO_TYPE_COUNT; i++) 104 for (U32 i = 0; i < LLAudioEngine::AUDIO_TYPE_COUNT; i++)
103 mSecondaryGain[i] = 1.0f; 105 mSecondaryGain[i] = 1.0f;
106
107 mStatus = LLMediaBase::STATUS_UNKNOWN;
104} 108}
105 109
106 110
@@ -168,6 +172,14 @@ void LLAudioEngine::shutdown()
168} 172}
169 173
170 174
175////////////////////////////////////////////////////////////////////////////////
176// virtual (derives from LLMediaBase)
177LLMediaBase::EStatus LLAudioEngine::getStatus()
178{
179 return mStatus;
180}
181
182
171// virtual 183// virtual
172void LLAudioEngine::startInternetStream(const std::string& url) 184void LLAudioEngine::startInternetStream(const std::string& url)
173{ 185{
@@ -179,12 +191,22 @@ void LLAudioEngine::startInternetStream(const std::string& url)
179 if (mgr) 191 if (mgr)
180 { 192 {
181 mInternetStreamMedia = mgr->createSourceFromMimeType(LLURI(url).scheme(), "audio/mpeg"); // assumes that whatever media implementation supports mp3 also supports vorbis. 193 mInternetStreamMedia = mgr->createSourceFromMimeType(LLURI(url).scheme(), "audio/mpeg"); // assumes that whatever media implementation supports mp3 also supports vorbis.
182 LL_INFOS("AudioEngine") << "mInternetStreamMedia is now " << mInternetStreamMedia << llendl; 194 //LL_INFOS("AudioEngine") << "mInternetStreamMedia is now " << mInternetStreamMedia << llendl;
183 } 195 }
184 } 196 }
185 197
186 if(!mInternetStreamMedia) 198 if(!mInternetStreamMedia)
187 return; 199 return;
200
201 // Check for a dead stream, just in case
202 if(getStatus() == LLMediaBase::STATUS_DEAD)
203 {
204 mInternetStreamURL.clear();
205 mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_STOP);
206 mInternetStreamMedia->updateMedia();
207 stopInternetStream();
208 return;
209 }
188 210
189 if (!url.empty()) 211 if (!url.empty())
190 { 212 {
@@ -202,7 +224,6 @@ void LLAudioEngine::startInternetStream(const std::string& url)
202 mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_STOP); 224 mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_STOP);
203 mInternetStreamMedia->updateMedia(); 225 mInternetStreamMedia->updateMedia();
204 } 226 }
205 //#endif
206} 227}
207 228
208// virtual 229// virtual
@@ -223,31 +244,6 @@ void LLAudioEngine::stopInternetStream()
223} 244}
224 245
225// virtual 246// virtual
226void LLAudioEngine::pauseInternetStream(int pause)
227{
228 LL_INFOS("AudioEngine") << "entered pauseInternetStream()" << llendl;
229
230 if(!mInternetStreamMedia)
231 return;
232
233 if(pause)
234 {
235 if(! mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_PAUSE))
236 {
237 LL_INFOS("AudioEngine") << "attempting to pause stream failed!" << llendl;
238 }
239 }
240 else
241 {
242 if(! mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_START))
243 {
244 LL_INFOS("AudioEngine") << "attempting to unpause stream failed!" << llendl;
245 }
246 }
247 mInternetStreamMedia->updateMedia();
248}
249
250// virtual
251void LLAudioEngine::updateInternetStream() 247void LLAudioEngine::updateInternetStream()
252{ 248{
253 if (mInternetStreamMedia) 249 if (mInternetStreamMedia)
@@ -265,11 +261,6 @@ int LLAudioEngine::isInternetStreamPlaying()
265 return 1; // Active and playing 261 return 1; // Active and playing
266 } 262 }
267 263
268 if (mInternetStreamMedia->getStatus() == LLMediaBase::STATUS_PAUSED)
269 {
270 return 2; // paused
271 }
272
273 return 0; // Stopped 264 return 0; // Stopped
274} 265}
275 266
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 @@
45#include "llframetimer.h" 45#include "llframetimer.h"
46#include "llassettype.h" 46#include "llassettype.h"
47 47
48#include "llmediabase.h"
49
48class LLMediaBase; 50class LLMediaBase;
49 51
50const F32 LL_WIND_UPDATE_INTERVAL = 0.1f; 52const F32 LL_WIND_UPDATE_INTERVAL = 0.1f;
@@ -153,13 +155,13 @@ public:
153 // Internet stream methods 155 // Internet stream methods
154 virtual void startInternetStream(const std::string& url); 156 virtual void startInternetStream(const std::string& url);
155 virtual void stopInternetStream(); 157 virtual void stopInternetStream();
156 virtual void pauseInternetStream(int pause);
157 virtual void updateInternetStream(); 158 virtual void updateInternetStream();
158 virtual int isInternetStreamPlaying(); 159 virtual int isInternetStreamPlaying();
159 virtual void getInternetStreamInfo(char* artist, char* title); 160 virtual void getInternetStreamInfo(char* artist, char* title);
160 // use a value from 0.0 to 1.0, inclusive 161 // use a value from 0.0 to 1.0, inclusive
161 virtual void setInternetStreamGain(F32 vol); 162 virtual void setInternetStreamGain(F32 vol);
162 virtual const std::string& getInternetStreamURL(); 163 virtual const std::string& getInternetStreamURL();
164 virtual LLMediaBase::EStatus getStatus();
163 165
164 // For debugging usage 166 // For debugging usage
165 virtual LLVector3 getListenerPos(); 167 virtual LLVector3 getListenerPos();
@@ -246,6 +248,8 @@ protected:
246 248
247 LLFrameTimer mWindUpdateTimer; 249 LLFrameTimer mWindUpdateTimer;
248 250
251 LLMediaBase::EStatus mStatus;
252
249private: 253private:
250 void setDefaults(); 254 void setDefaults();
251 LLMediaBase *mInternetStreamMedia; 255 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
153 STATUS_STARTED = 3, 153 STATUS_STARTED = 3,
154 STATUS_STOPPED = 4, 154 STATUS_STOPPED = 4,
155 STATUS_PAUSED = 6, 155 STATUS_PAUSED = 6,
156 STATUS_RESETTING = 7 156 STATUS_RESETTING = 7,
157 STATUS_DEAD = 8
157 }; 158 };
158 virtual bool addCommand( ECommand cmd ) = 0; 159 virtual bool addCommand( ECommand cmd ) = 0;
159 virtual bool clearCommand() = 0; 160 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)
395 LL_DEBUGS("MediaImpl") << "Setting media URI: " << urlIn.c_str() 395 LL_DEBUGS("MediaImpl") << "Setting media URI: " << urlIn.c_str()
396 << LL_ENDL; 396 << LL_ENDL;
397 397
398 if (NULL == mPump 398 if (mPump == NULL || mPlaybin == NULL)
399 || NULL == mPlaybin)
400 { 399 {
401 return false; 400 return false;
402 } 401 }
@@ -415,6 +414,8 @@ bool LLMediaImplGStreamer::navigateTo (const std::string urlIn)
415 llgst_bus_add_watch (bus, bus_callback, this); 414 llgst_bus_add_watch (bus, bus_callback, this);
416 llgst_object_unref (bus); 415 llgst_object_unref (bus);
417 416
417 mState = GST_STATE_READY;
418
418 // navigateTo implicitly plays, too. 419 // navigateTo implicitly plays, too.
419 play(); 420 play();
420 421
@@ -447,6 +448,8 @@ bool LLMediaImplGStreamer::unload()
447 } 448 }
448 449
449 mVideoSink = NULL; 450 mVideoSink = NULL;
451 mState = GST_STATE_NULL;
452 setStatus(LLMediaBase::STATUS_DEAD);
450 453
451 return true; 454 return true;
452} 455}
@@ -458,15 +461,19 @@ bool LLMediaImplGStreamer::updateMedia()
458 //LL_DEBUGS("MediaImpl") << "updating media..." << LL_ENDL; 461 //LL_DEBUGS("MediaImpl") << "updating media..." << LL_ENDL;
459 462
460 // sanity check 463 // sanity check
461 if (NULL == mPump 464 if (mPump == NULL || mPlaybin == NULL)
462 || NULL == mPlaybin)
463 { 465 {
464#ifdef LL_GST_REPORT_STATE_CHANGES 466#ifdef LL_GST_REPORT_STATE_CHANGES
465 LL_DEBUGS("MediaImpl") << "dead media..." << LL_ENDL; 467 LL_DEBUGS("MediaImpl") << "dead media..." << LL_ENDL;
466#endif 468#endif
469 mState = GST_STATE_NULL;
470 setStatus(LLMediaBase::STATUS_DEAD);
467 return false; 471 return false;
468 } 472 }
469 473
474 if (mState == GST_STATE_VOID_PENDING || mState == GST_STATE_NULL)
475 return false;
476
470 // process next outstanding command 477 // process next outstanding command
471 switch (nextCommand()) 478 switch (nextCommand())
472 { 479 {
@@ -579,13 +586,18 @@ bool LLMediaImplGStreamer::stop()
579{ 586{
580 LL_DEBUGS("MediaImpl") << "attempting to stop..." << LL_ENDL; 587 LL_DEBUGS("MediaImpl") << "attempting to stop..." << LL_ENDL;
581 588
582 if (!mPlaybin) return true; 589 if (!mPlaybin || mState == GST_STATE_NULL)
590 return true;
583 591
584 GstElement *pipeline = (GstElement *)llgst_object_ref(GST_OBJECT(mPlaybin)); 592 GstElement *pipeline = (GstElement *)llgst_object_ref(GST_OBJECT(mPlaybin));
585 llgst_object_unref(pipeline); 593 llgst_object_unref(pipeline);
586 594
587 llgst_element_set_state(pipeline, GST_STATE_READY); 595 llgst_element_set_state(pipeline, GST_STATE_READY);
588 mState = GST_STATE_READY; 596
597 if (mState == GST_STATE_PLAYING)
598 mState = GST_STATE_VOID_PENDING;
599 else
600 mState = GST_STATE_READY;
589 601
590 GstStateChangeReturn state_change = llgst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE); 602 GstStateChangeReturn state_change = llgst_element_get_state(mPlaybin, NULL, NULL, GST_CLOCK_TIME_NONE);
591 LL_DEBUGS("MediaImpl") << "get_state: " << state_change << LL_ENDL; 603 LL_DEBUGS("MediaImpl") << "get_state: " << state_change << LL_ENDL;
@@ -599,7 +611,8 @@ bool LLMediaImplGStreamer::play()
599{ 611{
600 LL_DEBUGS("MediaImpl") << "attempting to play..." << LL_ENDL; 612 LL_DEBUGS("MediaImpl") << "attempting to play..." << LL_ENDL;
601 613
602 if (!mPlaybin) return true; 614 if (!mPlaybin || mState == GST_STATE_NULL)
615 return true;
603 616
604 GstElement *pipeline = (GstElement *)llgst_object_ref(GST_OBJECT(mPlaybin)); 617 GstElement *pipeline = (GstElement *)llgst_object_ref(GST_OBJECT(mPlaybin));
605 llgst_object_unref(pipeline); 618 llgst_object_unref(pipeline);
@@ -615,6 +628,7 @@ bool LLMediaImplGStreamer::play()
615 // Check to make sure playing was successful. If not, stop. 628 // Check to make sure playing was successful. If not, stop.
616 if (state_change == GST_STATE_CHANGE_FAILURE) 629 if (state_change == GST_STATE_CHANGE_FAILURE)
617 { 630 {
631 setStatus(LLMediaBase::STATUS_STOPPED);
618 stop(); 632 stop();
619 } 633 }
620 634
@@ -627,7 +641,8 @@ bool LLMediaImplGStreamer::pause()
627{ 641{
628 LL_DEBUGS("MediaImpl") << "attempting to pause..." << LL_ENDL; 642 LL_DEBUGS("MediaImpl") << "attempting to pause..." << LL_ENDL;
629 643
630 if (!mPlaybin) return true; 644 if (!mPlaybin || mState == GST_STATE_NULL)
645 return true;
631 646
632 llgst_element_set_state(mPlaybin, GST_STATE_PAUSED); 647 llgst_element_set_state(mPlaybin, GST_STATE_PAUSED);
633 mState = GST_STATE_PAUSED; 648 mState = GST_STATE_PAUSED;
@@ -675,7 +690,7 @@ bool LLMediaImplGStreamer::setVolume(float volume)
675 if(mVolume == volume) 690 if(mVolume == volume)
676 return true; 691 return true;
677 692
678 LL_DEBUGS("MediaImpl") << "setVolume(" << volume << ") : " << getpid() << LL_ENDL; 693 LL_DEBUGS("MediaImpl") << "setVolume(" << volume << ") : " << getpid() << LL_ENDL;
679 mVolume = volume; 694 mVolume = volume;
680 if (mPlaybin) 695 if (mPlaybin)
681 { 696 {
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:
74 /* virtual */ int getTextureFormatType() const; 74 /* virtual */ int getTextureFormatType() const;
75 /* virtual */ int getTextureFormatInternal() const; 75 /* virtual */ int getTextureFormatInternal() const;
76 /* virtual */ bool seek( double time ); 76 /* virtual */ bool seek( double time );
77 /* virtual */ bool setVolume( float volume ); 77 /* virtual */ bool setVolume( float volume );
78 78
79 LLMediaEmitter< LLMediaObserver > getEventEmitter() const {return mEventEmitter;}; 79 LLMediaEmitter< LLMediaObserver > getEventEmitter() const {return mEventEmitter;};
80 80
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*)
391 } 391 }
392 } 392 }
393 } 393 }
394 //else
395 //{
396 // gOverlayBar->mMusicState = PAUSED; // desired state
397 // if (gAudiop)
398 // {
399 // gAudiop->pauseInternetStream(1);
400 // }
401 //}
402 else 394 else
403 { 395 {
404 gOverlayBar->mMusicState = STOPPED; // desired state 396 gOverlayBar->mMusicState = STOPPED; // desired state