aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llaudio/audioengine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llaudio/audioengine.cpp')
-rw-r--r--linden/indra/llaudio/audioengine.cpp94
1 files changed, 67 insertions, 27 deletions
diff --git a/linden/indra/llaudio/audioengine.cpp b/linden/indra/llaudio/audioengine.cpp
index d8082aa..5f1c060 100644
--- a/linden/indra/llaudio/audioengine.cpp
+++ b/linden/indra/llaudio/audioengine.cpp
@@ -46,6 +46,8 @@
46#include "llassetstorage.h" 46#include "llassetstorage.h"
47 47
48#include "llmediamanager.h" 48#include "llmediamanager.h"
49#include "llmediabase.h"
50#include "llmediaimplcommon.h"
49 51
50// necessary for grabbing sounds from sim (implemented in viewer) 52// necessary for grabbing sounds from sim (implemented in viewer)
51extern void request_sound(const LLUUID &sound_guid); 53extern void request_sound(const LLUUID &sound_guid);
@@ -100,6 +102,8 @@ void LLAudioEngine::setDefaults()
100 mInternetStreamMedia = NULL; 102 mInternetStreamMedia = NULL;
101 mInternetStreamURL.clear(); 103 mInternetStreamURL.clear();
102 104
105 mStatus = LLMediaBase::STATUS_UNKNOWN;
106
103 for (U32 i = 0; i < LLAudioEngine::AUDIO_TYPE_COUNT; i++) 107 for (U32 i = 0; i < LLAudioEngine::AUDIO_TYPE_COUNT; i++)
104 mSecondaryGain[i] = 1.0f; 108 mSecondaryGain[i] = 1.0f;
105} 109}
@@ -169,6 +173,14 @@ void LLAudioEngine::shutdown()
169} 173}
170 174
171 175
176////////////////////////////////////////////////////////////////////////////////
177// virtual (derives from LLMediaBase)
178LLMediaBase::EStatus LLAudioEngine::getStatus()
179{
180 return mStatus;
181}
182
183
172// virtual 184// virtual
173void LLAudioEngine::startInternetStream(const std::string& url) 185void LLAudioEngine::startInternetStream(const std::string& url)
174{ 186{
@@ -185,31 +197,51 @@ void LLAudioEngine::startInternetStream(const std::string& url)
185 } 197 }
186 198
187 if(!mInternetStreamMedia) 199 if(!mInternetStreamMedia)
200 {
188 return; 201 return;
189 202 }
190 if (!url.empty()) { 203 // Check for a dead stream from gstreamer, just in case
191 llinfos << "Starting internet stream: " << url << llendl; 204 else if(getStatus() == LLMediaBase::STATUS_DEAD)
192 mInternetStreamURL = url; 205 {
193 mInternetStreamMedia->navigateTo ( url ); 206 llinfos << "don't play dead stream urls"<< llendl;
194 llinfos << "Playing....." << llendl; 207 mInternetStreamURL.clear();
195 mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_START); 208 mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_STOP);
196 mInternetStreamMedia->updateMedia(); 209 mInternetStreamMedia->updateMedia();
197 } else { 210 stopInternetStream();
198 llinfos << "setting stream to NULL"<< llendl; 211 }
212 else if (url.empty())
213 {
214 llinfos << "url is emptly. Setting stream to NULL"<< llendl;
199 mInternetStreamURL.clear(); 215 mInternetStreamURL.clear();
200 mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_STOP); 216 mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_STOP);
201 mInternetStreamMedia->updateMedia(); 217 mInternetStreamMedia->updateMedia();
202 } 218 }
219 // Stream appears to be good, attempting to play
220 else
221 {
222 // stop any other stream first
223 stopInternetStream();
224
225 llinfos << "Starting internet stream: " << url << llendl;
226 mInternetStreamURL = url;
227 mInternetStreamMedia->navigateTo(url);
228 //llinfos << "Playing....." << llendl;
229 mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_START);
230 mInternetStreamMedia->updateMedia();
231 mStatus = LLMediaBase::STATUS_STARTED;
232 }
203} 233}
204 234
205// virtual 235// virtual
206void LLAudioEngine::stopInternetStream() 236void LLAudioEngine::stopInternetStream()
207{ 237{
208 llinfos << "entered stopInternetStream()" << llendl; 238 llinfos << "entered stopInternetStream()" << llendl;
209 239 mInternetStreamURL.clear();
210 if(mInternetStreamMedia) 240
241 if(mInternetStreamMedia)
211 { 242 {
212 if( ! mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_STOP)){ 243 if(!mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_STOP))
244 {
213 llinfos << "attempting to stop stream failed!" << llendl; 245 llinfos << "attempting to stop stream failed!" << llendl;
214 } 246 }
215 mInternetStreamMedia->updateMedia(); 247 mInternetStreamMedia->updateMedia();
@@ -301,6 +333,13 @@ void LLAudioEngine::updateChannels()
301 { 333 {
302 if (mChannels[i]) 334 if (mChannels[i])
303 { 335 {
336 // set secondary gain if type is available
337 LLAudioSource* source = mChannels[i]->getSource();
338 if (source)
339 {
340 mChannels[i]->setSecondaryGain(mSecondaryGain[source->getType()]);
341 }
342
304 mChannels[i]->updateBuffer(); 343 mChannels[i]->updateBuffer();
305 mChannels[i]->update3DPosition(); 344 mChannels[i]->update3DPosition();
306 mChannels[i]->updateLoop(); 345 mChannels[i]->updateLoop();
@@ -379,7 +418,7 @@ void LLAudioEngine::idle(F32 max_decode_time)
379 LLAudioChannel *channelp = getFreeChannel(max_priority); 418 LLAudioChannel *channelp = getFreeChannel(max_priority);
380 if (channelp) 419 if (channelp)
381 { 420 {
382 //llinfos << "Replacing source in channel due to priority!" << llendl; 421 //LL_INFOS("AudioEngine") << "Replacing source in channel due to priority!" << llendl;
383 max_sourcep->setChannel(channelp); 422 max_sourcep->setChannel(channelp);
384 channelp->setSource(max_sourcep); 423 channelp->setSource(max_sourcep);
385 if (max_sourcep->isSyncSlave()) 424 if (max_sourcep->isSyncSlave())
@@ -546,7 +585,7 @@ void LLAudioEngine::idle(F32 max_decode_time)
546 { 585 {
547 if (!mBuffers[i]->mInUse && mBuffers[i]->mLastUseTimer.getElapsedTimeF32() > 30.f) 586 if (!mBuffers[i]->mInUse && mBuffers[i]->mLastUseTimer.getElapsedTimeF32() > 30.f)
548 { 587 {
549 //llinfos << "Flushing unused buffer!" << llendl; 588 //LL_INFOS("AudioEngine") << "Flushing unused buffer!" << llendl;
550 mBuffers[i]->mAudioDatap->mBufferp = NULL; 589 mBuffers[i]->mAudioDatap->mBufferp = NULL;
551 delete mBuffers[i]; 590 delete mBuffers[i];
552 mBuffers[i] = NULL; 591 mBuffers[i] = NULL;
@@ -659,8 +698,8 @@ LLAudioBuffer *LLAudioEngine::getFreeBuffer()
659 698
660 if (buffer_id >= 0) 699 if (buffer_id >= 0)
661 { 700 {
662 llinfos << "Taking over unused buffer " << buffer_id << llendl; 701 LL_INFOS("AudioEngine") << "Taking over unused buffer " << buffer_id << llendl;
663 //llinfos << "Flushing unused buffer!" << llendl; 702 //LL_INFOS("AudioEngine") << "Flushing unused buffer!" << llendl;
664 mBuffers[buffer_id]->mAudioDatap->mBufferp = NULL; 703 mBuffers[buffer_id]->mAudioDatap->mBufferp = NULL;
665 delete mBuffers[buffer_id]; 704 delete mBuffers[buffer_id];
666 mBuffers[buffer_id] = createBuffer(); 705 mBuffers[buffer_id] = createBuffer();
@@ -872,9 +911,10 @@ void LLAudioEngine::triggerSound(const LLUUID &audio_uuid, const LLUUID& owner_i
872 const S32 type, const LLVector3d &pos_global) 911 const S32 type, const LLVector3d &pos_global)
873{ 912{
874 // Create a new source (since this can't be associated with an existing source. 913 // Create a new source (since this can't be associated with an existing source.
875 //llinfos << "Localized: " << audio_uuid << llendl; 914 //LL_INFOS("AudioEngine") << "Localized: " << audio_uuid << llendl;
876 915
877 if (mMuted) 916 //If we cannot hear it, dont even try to load the sound.
917 if (mMuted || gain == 0.0)
878 { 918 {
879 return; 919 return;
880 } 920 }
@@ -1094,10 +1134,10 @@ bool LLAudioEngine::hasLocalFile(const LLUUID &uuid)
1094 1134
1095void LLAudioEngine::startNextTransfer() 1135void LLAudioEngine::startNextTransfer()
1096{ 1136{
1097 //llinfos << "LLAudioEngine::startNextTransfer()" << llendl; 1137 //LL_INFOS("AudioEngine") << "LLAudioEngine::startNextTransfer()" << llendl;
1098 if (mCurrentTransfer.notNull() || getMuted()) 1138 if (mCurrentTransfer.notNull() || getMuted())
1099 { 1139 {
1100 //llinfos << "Transfer in progress, aborting" << llendl; 1140 //LL_INFOS("AudioEngine") << "Transfer in progress, aborting" << llendl;
1101 return; 1141 return;
1102 } 1142 }
1103 1143
@@ -1278,7 +1318,7 @@ void LLAudioEngine::startNextTransfer()
1278 1318
1279 if (asset_id.notNull()) 1319 if (asset_id.notNull())
1280 { 1320 {
1281 llinfos << "Getting asset data for: " << asset_id << llendl; 1321 LL_INFOS("AudioEngine") << "Getting asset data for: " << asset_id << llendl;
1282 gAudiop->mCurrentTransfer = asset_id; 1322 gAudiop->mCurrentTransfer = asset_id;
1283 gAudiop->mCurrentTransferTimer.reset(); 1323 gAudiop->mCurrentTransferTimer.reset();
1284 gAssetStorage->getAssetData(asset_id, LLAssetType::AT_SOUND, 1324 gAssetStorage->getAssetData(asset_id, LLAssetType::AT_SOUND,
@@ -1286,7 +1326,7 @@ void LLAudioEngine::startNextTransfer()
1286 } 1326 }
1287 else 1327 else
1288 { 1328 {
1289 //llinfos << "No pending transfers?" << llendl; 1329 //LL_INFOS("AudioEngine") << "No pending transfers?" << llendl;
1290 } 1330 }
1291} 1331}
1292 1332
@@ -1296,7 +1336,7 @@ void LLAudioEngine::assetCallback(LLVFS *vfs, const LLUUID &uuid, LLAssetType::E
1296{ 1336{
1297 if (result_code) 1337 if (result_code)
1298 { 1338 {
1299 llinfos << "Boom, error in audio file transfer: " << LLAssetStorage::getErrorString( result_code ) << " (" << result_code << ")" << llendl; 1339 LL_INFOS("AudioEngine") << "Boom, error in audio file transfer: " << LLAssetStorage::getErrorString( result_code ) << " (" << result_code << ")" << llendl;
1300 // Need to mark data as bad to avoid constant rerequests. 1340 // Need to mark data as bad to avoid constant rerequests.
1301 LLAudioData *adp = gAudiop->getAudioData(uuid); 1341 LLAudioData *adp = gAudiop->getAudioData(uuid);
1302 if (adp) 1342 if (adp)
@@ -1679,7 +1719,7 @@ LLAudioChannel::LLAudioChannel() :
1679LLAudioChannel::~LLAudioChannel() 1719LLAudioChannel::~LLAudioChannel()
1680{ 1720{
1681 // Need to disconnect any sources which are using this channel. 1721 // Need to disconnect any sources which are using this channel.
1682 //llinfos << "Cleaning up audio channel" << llendl; 1722 //LL_INFOS("AudioEngine") << "Cleaning up audio channel" << llendl;
1683 if (mCurrentSourcep) 1723 if (mCurrentSourcep)
1684 { 1724 {
1685 mCurrentSourcep->setChannel(NULL); 1725 mCurrentSourcep->setChannel(NULL);
@@ -1690,12 +1730,12 @@ LLAudioChannel::~LLAudioChannel()
1690 1730
1691void LLAudioChannel::setSource(LLAudioSource *sourcep) 1731void LLAudioChannel::setSource(LLAudioSource *sourcep)
1692{ 1732{
1693 //llinfos << this << ": setSource(" << sourcep << ")" << llendl; 1733 //LL_INFOS("AudioEngine") << this << ": setSource(" << sourcep << ")" << llendl;
1694 1734
1695 if (!sourcep) 1735 if (!sourcep)
1696 { 1736 {
1697 // Clearing the source for this channel, don't need to do anything. 1737 // Clearing the source for this channel, don't need to do anything.
1698 //llinfos << "Clearing source for channel" << llendl; 1738 //LL_INFOS("AudioEngine") << "Clearing source for channel" << llendl;
1699 cleanup(); 1739 cleanup();
1700 mCurrentSourcep = NULL; 1740 mCurrentSourcep = NULL;
1701 mWaiting = false; 1741 mWaiting = false;
@@ -1705,7 +1745,7 @@ void LLAudioChannel::setSource(LLAudioSource *sourcep)
1705 if (sourcep == mCurrentSourcep) 1745 if (sourcep == mCurrentSourcep)
1706 { 1746 {
1707 // Don't reallocate the channel, this will make FMOD goofy. 1747 // Don't reallocate the channel, this will make FMOD goofy.
1708 //llinfos << "Calling setSource with same source!" << llendl; 1748 //LL_INFOS("AudioEngine") << "Calling setSource with same source!" << llendl;
1709 } 1749 }
1710 1750
1711 mCurrentSourcep = sourcep; 1751 mCurrentSourcep = sourcep;