aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llaudio/audioengine.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2009-02-12 02:06:41 -0600
committerJacek Antonelli2009-02-12 02:06:45 -0600
commit61f97b33f9850d21965d397b947a298c16ba576d (patch)
treea2edff0a7fbc83e2259eda952511b0fbdbea290b /linden/indra/llaudio/audioengine.cpp
parentSecond Life viewer sources 1.22.7-RC (diff)
downloadmeta-impy-61f97b33f9850d21965d397b947a298c16ba576d.zip
meta-impy-61f97b33f9850d21965d397b947a298c16ba576d.tar.gz
meta-impy-61f97b33f9850d21965d397b947a298c16ba576d.tar.bz2
meta-impy-61f97b33f9850d21965d397b947a298c16ba576d.tar.xz
Second Life viewer sources 1.22.8-RC
Diffstat (limited to '')
-rw-r--r--linden/indra/llaudio/audioengine.cpp329
1 files changed, 232 insertions, 97 deletions
diff --git a/linden/indra/llaudio/audioengine.cpp b/linden/indra/llaudio/audioengine.cpp
index 81536cf..c5bc367 100644
--- a/linden/indra/llaudio/audioengine.cpp
+++ b/linden/indra/llaudio/audioengine.cpp
@@ -44,14 +44,13 @@
44#include "llaudiodecodemgr.h" 44#include "llaudiodecodemgr.h"
45#include "llassetstorage.h" 45#include "llassetstorage.h"
46 46
47#include "llmediamanager.h"
48
47// necessary for grabbing sounds from sim (implemented in viewer) 49// necessary for grabbing sounds from sim (implemented in viewer)
48extern void request_sound(const LLUUID &sound_guid); 50extern void request_sound(const LLUUID &sound_guid);
49 51
50LLAudioEngine* gAudiop = NULL; 52LLAudioEngine* gAudiop = NULL;
51 53
52// Maximum amount of time we wait for a transfer to complete before starting
53// off another one.
54const F32 MAX_CURRENT_TRANSFER_TIME = 60.f;
55 54
56// 55//
57// LLAudioEngine implementation 56// LLAudioEngine implementation
@@ -75,13 +74,13 @@ void LLAudioEngine::setDefaults()
75 74
76 mListenerp = NULL; 75 mListenerp = NULL;
77 76
78 mMuted = FALSE; 77 mMuted = false;
79 mUserData = NULL; 78 mUserData = NULL;
80 79
81 mLastStatus = 0; 80 mLastStatus = 0;
82 81
83 mNumChannels = 0; 82 mNumChannels = 0;
84 mEnableWind = FALSE; 83 mEnableWind = false;
85 84
86 S32 i; 85 S32 i;
87 for (i = 0; i < MAX_CHANNELS; i++) 86 for (i = 0; i < MAX_CHANNELS; i++)
@@ -91,7 +90,7 @@ void LLAudioEngine::setDefaults()
91 for (i = 0; i < MAX_BUFFERS; i++) 90 for (i = 0; i < MAX_BUFFERS; i++)
92 { 91 {
93 mBuffers[i] = NULL; 92 mBuffers[i] = NULL;
94 } 93 }
95 94
96 mMasterGain = 1.f; 95 mMasterGain = 1.f;
97 mInternetStreamGain = 0.125f; 96 mInternetStreamGain = 0.125f;
@@ -99,10 +98,13 @@ void LLAudioEngine::setDefaults()
99 98
100 for (U32 i = 0; i < LLAudioEngine::AUDIO_TYPE_COUNT; i++) 99 for (U32 i = 0; i < LLAudioEngine::AUDIO_TYPE_COUNT; i++)
101 mSecondaryGain[i] = 1.0f; 100 mSecondaryGain[i] = 1.0f;
101
102 mInternetStreamMedia = NULL;
103 mInternetStreamURL.clear();
102} 104}
103 105
104 106
105BOOL LLAudioEngine::init(const S32 num_channels, void* userdata) 107bool LLAudioEngine::init(const S32 num_channels, void* userdata)
106{ 108{
107 setDefaults(); 109 setDefaults();
108 110
@@ -114,7 +116,9 @@ BOOL LLAudioEngine::init(const S32 num_channels, void* userdata)
114 // Initialize the decode manager 116 // Initialize the decode manager
115 gAudioDecodeMgrp = new LLAudioDecodeMgr; 117 gAudioDecodeMgrp = new LLAudioDecodeMgr;
116 118
117 return TRUE; 119 llinfos << "LLAudioEngine::init() AudioEngine successfully initialized" << llendl;
120
121 return true;
118} 122}
119 123
120 124
@@ -124,6 +128,9 @@ void LLAudioEngine::shutdown()
124 delete gAudioDecodeMgrp; 128 delete gAudioDecodeMgrp;
125 gAudioDecodeMgrp = NULL; 129 gAudioDecodeMgrp = NULL;
126 130
131 // Clean up wind source
132 cleanupWind();
133
127 // Clean up audio sources 134 // Clean up audio sources
128 source_map::iterator iter_src; 135 source_map::iterator iter_src;
129 for (iter_src = mAllSources.begin(); iter_src != mAllSources.end(); iter_src++) 136 for (iter_src = mAllSources.begin(); iter_src != mAllSources.end(); iter_src++)
@@ -144,22 +151,145 @@ void LLAudioEngine::shutdown()
144 S32 i; 151 S32 i;
145 for (i = 0; i < MAX_CHANNELS; i++) 152 for (i = 0; i < MAX_CHANNELS; i++)
146 { 153 {
147 if (mChannels[i]) 154 delete mChannels[i];
148 { 155 mChannels[i] = NULL;
149 delete mChannels[i];
150 mChannels[i] = NULL;
151 }
152 } 156 }
153 157
154 // Clean up buffers 158 // Clean up buffers
155 for (i = 0; i < MAX_BUFFERS; i++) 159 for (i = 0; i < MAX_BUFFERS; i++)
156 { 160 {
157 if (mBuffers[i]) 161 delete mBuffers[i];
162 mBuffers[i] = NULL;
163 }
164
165 delete mInternetStreamMedia;
166 mInternetStreamMedia = NULL;
167 mInternetStreamURL.clear();
168}
169
170
171// virtual
172void LLAudioEngine::startInternetStream(const std::string& url)
173{
174 llinfos << "entered startInternetStream()" << llendl;
175
176 if (!mInternetStreamMedia)
177 {
178 LLMediaManager* mgr = LLMediaManager::getInstance();
179 if (mgr)
158 { 180 {
159 delete mBuffers[i]; 181 mInternetStreamMedia = mgr->createSourceFromMimeType(LLURI(url).scheme(), "audio/mpeg"); // assumes that whatever media implementation supports mp3 also supports vorbis.
160 mBuffers[i] = NULL; 182 llinfos << "mInternetStreamMedia is now " << mInternetStreamMedia << llendl;
161 } 183 }
162 } 184 }
185
186 if(!mInternetStreamMedia)
187 return;
188
189 if (!url.empty()) {
190 llinfos << "Starting internet stream: " << url << llendl;
191 mInternetStreamURL = url;
192 mInternetStreamMedia->navigateTo ( url );
193 llinfos << "Playing....." << llendl;
194 mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_START);
195 mInternetStreamMedia->updateMedia();
196 } else {
197 llinfos << "setting stream to NULL"<< llendl;
198 mInternetStreamURL.clear();
199 mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_STOP);
200 mInternetStreamMedia->updateMedia();
201 }
202}
203
204// virtual
205void LLAudioEngine::stopInternetStream()
206{
207 llinfos << "entered stopInternetStream()" << llendl;
208
209 if(mInternetStreamMedia)
210 {
211 if( ! mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_STOP)){
212 llinfos << "attempting to stop stream failed!" << llendl;
213 }
214 mInternetStreamMedia->updateMedia();
215 }
216
217 mInternetStreamURL.clear();
218}
219
220// virtual
221void LLAudioEngine::pauseInternetStream(int pause)
222{
223 llinfos << "entered pauseInternetStream()" << llendl;
224
225 if(!mInternetStreamMedia)
226 return;
227
228 if(pause)
229 {
230 if(! mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_PAUSE))
231 {
232 llinfos << "attempting to pause stream failed!" << llendl;
233 }
234 } else {
235 if(! mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_START))
236 {
237 llinfos << "attempting to unpause stream failed!" << llendl;
238 }
239 }
240 mInternetStreamMedia->updateMedia();
241}
242
243// virtual
244void LLAudioEngine::updateInternetStream()
245{
246 if (mInternetStreamMedia)
247 mInternetStreamMedia->updateMedia();
248}
249
250// virtual
251int LLAudioEngine::isInternetStreamPlaying()
252{
253 if (!mInternetStreamMedia)
254 return 0;
255
256 if (mInternetStreamMedia->getStatus() == LLMediaBase::STATUS_STARTED)
257 {
258 return 1; // Active and playing
259 }
260
261 if (mInternetStreamMedia->getStatus() == LLMediaBase::STATUS_PAUSED)
262 {
263 return 2; // paused
264 }
265
266 return 0; // Stopped
267}
268
269// virtual
270void LLAudioEngine::getInternetStreamInfo(char* artist, char* title)
271{
272 artist[0] = 0;
273 title[0] = 0;
274}
275
276// virtual
277void LLAudioEngine::setInternetStreamGain(F32 vol)
278{
279 mInternetStreamGain = vol;
280
281 if(!mInternetStreamMedia)
282 return;
283
284 vol = llclamp(vol, 0.f, 1.f);
285 mInternetStreamMedia->setVolume(vol);
286 mInternetStreamMedia->updateMedia();
287}
288
289// virtual
290const std::string& LLAudioEngine::getInternetStreamURL()
291{
292 return mInternetStreamURL;
163} 293}
164 294
165 295
@@ -203,7 +333,7 @@ void LLAudioEngine::idle(F32 max_decode_time)
203 { 333 {
204 if (mBuffers[i]) 334 if (mBuffers[i])
205 { 335 {
206 mBuffers[i]->mInUse = FALSE; 336 mBuffers[i]->mInUse = false;
207 } 337 }
208 } 338 }
209 339
@@ -255,11 +385,11 @@ void LLAudioEngine::idle(F32 max_decode_time)
255 { 385 {
256 // A sync slave, it doesn't start playing until it's synced up with the master. 386 // A sync slave, it doesn't start playing until it's synced up with the master.
257 // Flag this channel as waiting for sync, and return true. 387 // Flag this channel as waiting for sync, and return true.
258 channelp->setWaiting(TRUE); 388 channelp->setWaiting(true);
259 } 389 }
260 else 390 else
261 { 391 {
262 channelp->setWaiting(FALSE); 392 channelp->setWaiting(false);
263 channelp->play(); 393 channelp->play();
264 } 394 }
265 } 395 }
@@ -399,7 +529,7 @@ void LLAudioEngine::idle(F32 max_decode_time)
399 if (sync_masterp->getChannel()) 529 if (sync_masterp->getChannel())
400 { 530 {
401 channelp->playSynced(master_channelp); 531 channelp->playSynced(master_channelp);
402 channelp->setWaiting(FALSE); 532 channelp->setWaiting(false);
403 } 533 }
404 } 534 }
405 } 535 }
@@ -429,7 +559,7 @@ void LLAudioEngine::idle(F32 max_decode_time)
429 { 559 {
430 if (mChannels[i]) 560 if (mChannels[i])
431 { 561 {
432 mChannels[i]->mLoopedThisFrame = FALSE; 562 mChannels[i]->mLoopedThisFrame = false;
433 } 563 }
434 } 564 }
435 565
@@ -440,13 +570,17 @@ void LLAudioEngine::idle(F32 max_decode_time)
440 // missed picking it up in all the places that can add 570 // missed picking it up in all the places that can add
441 // or request new data. 571 // or request new data.
442 startNextTransfer(); 572 startNextTransfer();
573
574 updateInternetStream();
443} 575}
444 576
445BOOL LLAudioEngine::updateBufferForData(LLAudioData *adp, const LLUUID &audio_uuid) 577
578
579bool LLAudioEngine::updateBufferForData(LLAudioData *adp, const LLUUID &audio_uuid)
446{ 580{
447 if (!adp) 581 if (!adp)
448 { 582 {
449 return FALSE; 583 return false;
450 } 584 }
451 585
452 // Update the audio buffer first - load a sound if we have it. 586 // Update the audio buffer first - load a sound if we have it.
@@ -469,14 +603,14 @@ BOOL LLAudioEngine::updateBufferForData(LLAudioData *adp, const LLUUID &audio_uu
469 } 603 }
470 else 604 else
471 { 605 {
472 return FALSE; 606 return false;
473 } 607 }
474 } 608 }
475 return TRUE; 609 return true;
476} 610}
477 611
478 612
479void LLAudioEngine::enableWind(BOOL enable) 613void LLAudioEngine::enableWind(bool enable)
480{ 614{
481 if (enable && (!mEnableWind)) 615 if (enable && (!mEnableWind))
482 { 616 {
@@ -604,7 +738,7 @@ void LLAudioEngine::cleanupBuffer(LLAudioBuffer *bufferp)
604} 738}
605 739
606 740
607BOOL LLAudioEngine::preloadSound(const LLUUID &uuid) 741bool LLAudioEngine::preloadSound(const LLUUID &uuid)
608{ 742{
609 gAudiop->getAudioData(uuid); // We don't care about the return value, this is just to make sure 743 gAudiop->getAudioData(uuid); // We don't care about the return value, this is just to make sure
610 // that we have an entry, which will mean that the audio engine knows about this 744 // that we have an entry, which will mean that the audio engine knows about this
@@ -612,23 +746,23 @@ BOOL LLAudioEngine::preloadSound(const LLUUID &uuid)
612 if (gAudioDecodeMgrp->addDecodeRequest(uuid)) 746 if (gAudioDecodeMgrp->addDecodeRequest(uuid))
613 { 747 {
614 // This means that we do have a local copy, and we're working on decoding it. 748 // This means that we do have a local copy, and we're working on decoding it.
615 return TRUE; 749 return true;
616 } 750 }
617 751
618 // At some point we need to have the audio/asset system check the static VFS 752 // At some point we need to have the audio/asset system check the static VFS
619 // before it goes off and fetches stuff from the server. 753 // before it goes off and fetches stuff from the server.
620 //llwarns << "Used internal preload for non-local sound" << llendl; 754 //llwarns << "Used internal preload for non-local sound" << llendl;
621 return FALSE; 755 return false;
622} 756}
623 757
624 758
625BOOL LLAudioEngine::isWindEnabled() 759bool LLAudioEngine::isWindEnabled()
626{ 760{
627 return mEnableWind; 761 return mEnableWind;
628} 762}
629 763
630 764
631void LLAudioEngine::setMuted(BOOL muted) 765void LLAudioEngine::setMuted(bool muted)
632{ 766{
633 mMuted = muted; 767 mMuted = muted;
634 enableWind(!mMuted); 768 enableWind(!mMuted);
@@ -751,7 +885,7 @@ void LLAudioEngine::triggerSound(const LLUUID &audio_uuid, const LLUUID& owner_i
751 gAudiop->addAudioSource(asp); 885 gAudiop->addAudioSource(asp);
752 if (pos_global.isExactlyZero()) 886 if (pos_global.isExactlyZero())
753 { 887 {
754 asp->setAmbient(TRUE); 888 asp->setAmbient(true);
755 } 889 }
756 else 890 else
757 { 891 {
@@ -930,7 +1064,7 @@ void LLAudioEngine::cleanupAudioSource(LLAudioSource *asp)
930} 1064}
931 1065
932 1066
933BOOL LLAudioEngine::hasDecodedFile(const LLUUID &uuid) 1067bool LLAudioEngine::hasDecodedFile(const LLUUID &uuid)
934{ 1068{
935 std::string uuid_str; 1069 std::string uuid_str;
936 uuid.toString(uuid_str); 1070 uuid.toString(uuid_str);
@@ -941,16 +1075,16 @@ BOOL LLAudioEngine::hasDecodedFile(const LLUUID &uuid)
941 1075
942 if (gDirUtilp->fileExists(wav_path)) 1076 if (gDirUtilp->fileExists(wav_path))
943 { 1077 {
944 return TRUE; 1078 return true;
945 } 1079 }
946 else 1080 else
947 { 1081 {
948 return FALSE; 1082 return false;
949 } 1083 }
950} 1084}
951 1085
952 1086
953BOOL LLAudioEngine::hasLocalFile(const LLUUID &uuid) 1087bool LLAudioEngine::hasLocalFile(const LLUUID &uuid)
954{ 1088{
955 // See if it's in the VFS. 1089 // See if it's in the VFS.
956 return gVFS->getExists(uuid, LLAssetType::AT_SOUND); 1090 return gVFS->getExists(uuid, LLAssetType::AT_SOUND);
@@ -1166,9 +1300,9 @@ void LLAudioEngine::assetCallback(LLVFS *vfs, const LLUUID &uuid, LLAssetType::E
1166 LLAudioData *adp = gAudiop->getAudioData(uuid); 1300 LLAudioData *adp = gAudiop->getAudioData(uuid);
1167 if (adp) 1301 if (adp)
1168 { 1302 {
1169 adp->setHasValidData(FALSE); 1303 adp->setHasValidData(false);
1170 adp->setHasLocalData(FALSE); 1304 adp->setHasLocalData(false);
1171 adp->setHasDecodedData(FALSE); 1305 adp->setHasDecodedData(false);
1172 } 1306 }
1173 } 1307 }
1174 else 1308 else
@@ -1181,8 +1315,8 @@ void LLAudioEngine::assetCallback(LLVFS *vfs, const LLUUID &uuid, LLAssetType::E
1181 } 1315 }
1182 else 1316 else
1183 { 1317 {
1184 adp->setHasValidData(TRUE); 1318 adp->setHasValidData(true);
1185 adp->setHasLocalData(TRUE); 1319 adp->setHasLocalData(true);
1186 gAudioDecodeMgrp->addDecodeRequest(uuid); 1320 gAudioDecodeMgrp->addDecodeRequest(uuid);
1187 } 1321 }
1188 } 1322 }
@@ -1202,12 +1336,12 @@ LLAudioSource::LLAudioSource(const LLUUID& id, const LLUUID& owner_id, const F32
1202 mPriority(0.f), 1336 mPriority(0.f),
1203 mGain(gain), 1337 mGain(gain),
1204 mType(type), 1338 mType(type),
1205 mAmbient(FALSE), 1339 mAmbient(false),
1206 mLoop(FALSE), 1340 mLoop(false),
1207 mSyncMaster(FALSE), 1341 mSyncMaster(false),
1208 mSyncSlave(FALSE), 1342 mSyncSlave(false),
1209 mQueueSounds(FALSE), 1343 mQueueSounds(false),
1210 mPlayedOnce(FALSE), 1344 mPlayedOnce(false),
1211 mChannelp(NULL), 1345 mChannelp(NULL),
1212 mCurrentDatap(NULL), 1346 mCurrentDatap(NULL),
1213 mQueuedDatap(NULL) 1347 mQueuedDatap(NULL)
@@ -1271,7 +1405,7 @@ void LLAudioSource::updatePriority()
1271 } 1405 }
1272} 1406}
1273 1407
1274BOOL LLAudioSource::setupChannel() 1408bool LLAudioSource::setupChannel()
1275{ 1409{
1276 LLAudioData *adp = getCurrentData(); 1410 LLAudioData *adp = getCurrentData();
1277 1411
@@ -1279,7 +1413,7 @@ BOOL LLAudioSource::setupChannel()
1279 { 1413 {
1280 // We're not ready to play back the sound yet, so don't try and allocate a channel for it. 1414 // We're not ready to play back the sound yet, so don't try and allocate a channel for it.
1281 //llwarns << "Aborting, no buffer" << llendl; 1415 //llwarns << "Aborting, no buffer" << llendl;
1282 return FALSE; 1416 return false;
1283 } 1417 }
1284 1418
1285 1419
@@ -1297,15 +1431,15 @@ BOOL LLAudioSource::setupChannel()
1297 // Now we have to reprioritize. 1431 // Now we have to reprioritize.
1298 // For now, just don't play the sound. 1432 // For now, just don't play the sound.
1299 //llwarns << "Aborting, no free channels" << llendl; 1433 //llwarns << "Aborting, no free channels" << llendl;
1300 return FALSE; 1434 return false;
1301 } 1435 }
1302 1436
1303 mChannelp->setSource(this); 1437 mChannelp->setSource(this);
1304 return TRUE; 1438 return true;
1305} 1439}
1306 1440
1307 1441
1308BOOL LLAudioSource::play(const LLUUID &audio_uuid) 1442bool LLAudioSource::play(const LLUUID &audio_uuid)
1309{ 1443{
1310 if (audio_uuid.isNull()) 1444 if (audio_uuid.isNull())
1311 { 1445 {
@@ -1313,7 +1447,7 @@ BOOL LLAudioSource::play(const LLUUID &audio_uuid)
1313 { 1447 {
1314 getChannel()->setSource(NULL); 1448 getChannel()->setSource(NULL);
1315 setChannel(NULL); 1449 setChannel(NULL);
1316 addAudioData(NULL, TRUE); 1450 addAudioData(NULL, true);
1317 } 1451 }
1318 } 1452 }
1319 // Reset our age timeout if someone attempts to play the source. 1453 // Reset our age timeout if someone attempts to play the source.
@@ -1321,7 +1455,7 @@ BOOL LLAudioSource::play(const LLUUID &audio_uuid)
1321 1455
1322 LLAudioData *adp = gAudiop->getAudioData(audio_uuid); 1456 LLAudioData *adp = gAudiop->getAudioData(audio_uuid);
1323 1457
1324 BOOL has_buffer = gAudiop->updateBufferForData(adp, audio_uuid); 1458 bool has_buffer = gAudiop->updateBufferForData(adp, audio_uuid);
1325 1459
1326 1460
1327 addAudioData(adp); 1461 addAudioData(adp);
@@ -1329,47 +1463,48 @@ BOOL LLAudioSource::play(const LLUUID &audio_uuid)
1329 if (!has_buffer) 1463 if (!has_buffer)
1330 { 1464 {
1331 // Don't bother trying to set up a channel or anything, we don't have an audio buffer. 1465 // Don't bother trying to set up a channel or anything, we don't have an audio buffer.
1332 return FALSE; 1466 return false;
1333 } 1467 }
1334 1468
1335 if (!setupChannel()) 1469 if (!setupChannel())
1336 { 1470 {
1337 return FALSE; 1471 return false;
1338 } 1472 }
1339 1473
1340 if (isSyncSlave()) 1474 if (isSyncSlave())
1341 { 1475 {
1342 // A sync slave, it doesn't start playing until it's synced up with the master. 1476 // A sync slave, it doesn't start playing until it's synced up with the master.
1343 // Flag this channel as waiting for sync, and return true. 1477 // Flag this channel as waiting for sync, and return true.
1344 getChannel()->setWaiting(TRUE); 1478 getChannel()->setWaiting(true);
1345 return TRUE; 1479 return true;
1346 } 1480 }
1347 1481
1348 getChannel()->play(); 1482 getChannel()->play();
1349 return TRUE; 1483 return true;
1350} 1484}
1351 1485
1352 1486
1353BOOL LLAudioSource::isDone() 1487bool LLAudioSource::isDone()
1354{ 1488{
1355 const F32 MAX_AGE = 60.f; 1489 const F32 MAX_AGE = 60.f;
1356 const F32 MAX_UNPLAYED_AGE = 15.f; 1490 const F32 MAX_UNPLAYED_AGE = 15.f;
1491
1357 if (isLoop()) 1492 if (isLoop())
1358 { 1493 {
1359 // Looped sources never die on their own. 1494 // Looped sources never die on their own.
1360 return FALSE; 1495 return false;
1361 } 1496 }
1362 1497
1363 1498
1364 if (hasPendingPreloads()) 1499 if (hasPendingPreloads())
1365 { 1500 {
1366 return FALSE; 1501 return false;
1367 } 1502 }
1368 1503
1369 if (mQueuedDatap) 1504 if (mQueuedDatap)
1370 { 1505 {
1371 // Don't kill this sound if we've got something queued up to play. 1506 // Don't kill this sound if we've got something queued up to play.
1372 return FALSE; 1507 return false;
1373 } 1508 }
1374 1509
1375 F32 elapsed = mAgeTimer.getElapsedTimeF32(); 1510 F32 elapsed = mAgeTimer.getElapsedTimeF32();
@@ -1382,11 +1517,11 @@ BOOL LLAudioSource::isDone()
1382 // We don't have a channel assigned, and it's been 1517 // We don't have a channel assigned, and it's been
1383 // over 5 seconds since we tried to play it. Don't bother. 1518 // over 5 seconds since we tried to play it. Don't bother.
1384 //llinfos << "No channel assigned, source is done" << llendl; 1519 //llinfos << "No channel assigned, source is done" << llendl;
1385 return TRUE; 1520 return true;
1386 } 1521 }
1387 else 1522 else
1388 { 1523 {
1389 return FALSE; 1524 return false;
1390 } 1525 }
1391 } 1526 }
1392 1527
@@ -1394,27 +1529,27 @@ BOOL LLAudioSource::isDone()
1394 { 1529 {
1395 if (elapsed > MAX_AGE) 1530 if (elapsed > MAX_AGE)
1396 { 1531 {
1397 // Arbitarily cut off non-looped sounds when they're 20 seconds old. 1532 // Arbitarily cut off non-looped sounds when they're old.
1398 return TRUE; 1533 return true;
1399 } 1534 }
1400 else 1535 else
1401 { 1536 {
1402 // Sound is still playing and we haven't timed out, don't kill it. 1537 // Sound is still playing and we haven't timed out, don't kill it.
1403 return FALSE; 1538 return false;
1404 } 1539 }
1405 } 1540 }
1406 1541
1407 if ((elapsed > MAX_UNPLAYED_AGE) || mPlayedOnce) 1542 if ((elapsed > MAX_UNPLAYED_AGE) || mPlayedOnce)
1408 { 1543 {
1409 // The sound isn't playing back after 5 seconds or we're already done playing it, kill it. 1544 // The sound isn't playing back after 5 seconds or we're already done playing it, kill it.
1410 return TRUE; 1545 return true;
1411 } 1546 }
1412 1547
1413 return FALSE; 1548 return false;
1414} 1549}
1415 1550
1416 1551
1417void LLAudioSource::addAudioData(LLAudioData *adp, const BOOL set_current) 1552void LLAudioSource::addAudioData(LLAudioData *adp, const bool set_current)
1418{ 1553{
1419 // Only handle a single piece of audio data associated with a source right now, 1554 // Only handle a single piece of audio data associated with a source right now,
1420 // until I implement prefetch. 1555 // until I implement prefetch.
@@ -1482,7 +1617,7 @@ void LLAudioSource::addAudioData(LLAudioData *adp, const BOOL set_current)
1482} 1617}
1483 1618
1484 1619
1485BOOL LLAudioSource::hasPendingPreloads() const 1620bool LLAudioSource::hasPendingPreloads() const
1486{ 1621{
1487 // Check to see if we've got any preloads on deck for this source 1622 // Check to see if we've got any preloads on deck for this source
1488 data_map::const_iterator iter; 1623 data_map::const_iterator iter;
@@ -1492,11 +1627,11 @@ BOOL LLAudioSource::hasPendingPreloads() const
1492 if (!adp->hasDecodedData()) 1627 if (!adp->hasDecodedData())
1493 { 1628 {
1494 // This source is still waiting for a preload 1629 // This source is still waiting for a preload
1495 return TRUE; 1630 return true;
1496 } 1631 }
1497 } 1632 }
1498 1633
1499 return FALSE; 1634 return false;
1500} 1635}
1501 1636
1502 1637
@@ -1531,8 +1666,8 @@ LLAudioBuffer *LLAudioSource::getCurrentBuffer()
1531LLAudioChannel::LLAudioChannel() : 1666LLAudioChannel::LLAudioChannel() :
1532 mCurrentSourcep(NULL), 1667 mCurrentSourcep(NULL),
1533 mCurrentBufferp(NULL), 1668 mCurrentBufferp(NULL),
1534 mLoopedThisFrame(FALSE), 1669 mLoopedThisFrame(false),
1535 mWaiting(FALSE), 1670 mWaiting(false),
1536 mSecondaryGain(1.0f) 1671 mSecondaryGain(1.0f)
1537{ 1672{
1538} 1673}
@@ -1560,7 +1695,7 @@ void LLAudioChannel::setSource(LLAudioSource *sourcep)
1560 //llinfos << "Clearing source for channel" << llendl; 1695 //llinfos << "Clearing source for channel" << llendl;
1561 cleanup(); 1696 cleanup();
1562 mCurrentSourcep = NULL; 1697 mCurrentSourcep = NULL;
1563 mWaiting = FALSE; 1698 mWaiting = false;
1564 return; 1699 return;
1565 } 1700 }
1566 1701
@@ -1578,13 +1713,13 @@ void LLAudioChannel::setSource(LLAudioSource *sourcep)
1578} 1713}
1579 1714
1580 1715
1581BOOL LLAudioChannel::updateBuffer() 1716bool LLAudioChannel::updateBuffer()
1582{ 1717{
1583 if (!mCurrentSourcep) 1718 if (!mCurrentSourcep)
1584 { 1719 {
1585 // This channel isn't associated with any source, nothing 1720 // This channel isn't associated with any source, nothing
1586 // to be updated 1721 // to be updated
1587 return FALSE; 1722 return false;
1588 } 1723 }
1589 1724
1590 // Initialize the channel's gain setting for this sound. 1725 // Initialize the channel's gain setting for this sound.
@@ -1600,14 +1735,14 @@ BOOL LLAudioChannel::updateBuffer()
1600 { 1735 {
1601 // The source hasn't changed what buffer it's playing 1736 // The source hasn't changed what buffer it's playing
1602 bufferp->mLastUseTimer.reset(); 1737 bufferp->mLastUseTimer.reset();
1603 bufferp->mInUse = TRUE; 1738 bufferp->mInUse = true;
1604 } 1739 }
1605 return FALSE; 1740 return false;
1606 } 1741 }
1607 1742
1608 // 1743 //
1609 // The source changed what buffer it's playing. Whe need to clean up the 1744 // The source changed what buffer it's playing. We need to clean up
1610 // existing fmod channel 1745 // the existing channel
1611 // 1746 //
1612 cleanup(); 1747 cleanup();
1613 1748
@@ -1615,16 +1750,16 @@ BOOL LLAudioChannel::updateBuffer()
1615 if (bufferp) 1750 if (bufferp)
1616 { 1751 {
1617 bufferp->mLastUseTimer.reset(); 1752 bufferp->mLastUseTimer.reset();
1618 bufferp->mInUse = TRUE; 1753 bufferp->mInUse = true;
1619 } 1754 }
1620 1755
1621 if (!mCurrentBufferp) 1756 if (!mCurrentBufferp)
1622 { 1757 {
1623 // There's no new buffer to be played, so we just abort. 1758 // There's no new buffer to be played, so we just abort.
1624 return FALSE; 1759 return false;
1625 } 1760 }
1626 1761
1627 return TRUE; 1762 return true;
1628} 1763}
1629 1764
1630 1765
@@ -1638,9 +1773,9 @@ BOOL LLAudioChannel::updateBuffer()
1638LLAudioData::LLAudioData(const LLUUID &uuid) : 1773LLAudioData::LLAudioData(const LLUUID &uuid) :
1639 mID(uuid), 1774 mID(uuid),
1640 mBufferp(NULL), 1775 mBufferp(NULL),
1641 mHasLocalData(FALSE), 1776 mHasLocalData(false),
1642 mHasDecodedData(FALSE), 1777 mHasDecodedData(false),
1643 mHasValidData(TRUE) 1778 mHasValidData(true)
1644{ 1779{
1645 if (uuid.isNull()) 1780 if (uuid.isNull())
1646 { 1781 {
@@ -1651,24 +1786,24 @@ LLAudioData::LLAudioData(const LLUUID &uuid) :
1651 if (gAudiop && gAudiop->hasDecodedFile(uuid)) 1786 if (gAudiop && gAudiop->hasDecodedFile(uuid))
1652 { 1787 {
1653 // Already have a decoded version, don't need to decode it. 1788 // Already have a decoded version, don't need to decode it.
1654 mHasLocalData = TRUE; 1789 mHasLocalData = true;
1655 mHasDecodedData = TRUE; 1790 mHasDecodedData = true;
1656 } 1791 }
1657 else if (gAssetStorage && gAssetStorage->hasLocalAsset(uuid, LLAssetType::AT_SOUND)) 1792 else if (gAssetStorage && gAssetStorage->hasLocalAsset(uuid, LLAssetType::AT_SOUND))
1658 { 1793 {
1659 mHasLocalData = TRUE; 1794 mHasLocalData = true;
1660 } 1795 }
1661} 1796}
1662 1797
1663 1798
1664BOOL LLAudioData::load() 1799bool LLAudioData::load()
1665{ 1800{
1666 // For now, just assume we're going to use one buffer per audiodata. 1801 // For now, just assume we're going to use one buffer per audiodata.
1667 if (mBufferp) 1802 if (mBufferp)
1668 { 1803 {
1669 // We already have this sound in a buffer, don't do anything. 1804 // We already have this sound in a buffer, don't do anything.
1670 llinfos << "Already have a buffer for this sound, don't bother loading!" << llendl; 1805 llinfos << "Already have a buffer for this sound, don't bother loading!" << llendl;
1671 return TRUE; 1806 return true;
1672 } 1807 }
1673 1808
1674 mBufferp = gAudiop->getFreeBuffer(); 1809 mBufferp = gAudiop->getFreeBuffer();
@@ -1676,7 +1811,7 @@ BOOL LLAudioData::load()
1676 { 1811 {
1677 // No free buffers, abort. 1812 // No free buffers, abort.
1678 llinfos << "Not able to allocate a new audio buffer, aborting." << llendl; 1813 llinfos << "Not able to allocate a new audio buffer, aborting." << llendl;
1679 return FALSE; 1814 return false;
1680 } 1815 }
1681 1816
1682 std::string uuid_str; 1817 std::string uuid_str;
@@ -1690,10 +1825,10 @@ BOOL LLAudioData::load()
1690 gAudiop->cleanupBuffer(mBufferp); 1825 gAudiop->cleanupBuffer(mBufferp);
1691 mBufferp = NULL; 1826 mBufferp = NULL;
1692 1827
1693 return FALSE; 1828 return false;
1694 } 1829 }
1695 mBufferp->mAudioDatap = this; 1830 mBufferp->mAudioDatap = this;
1696 return TRUE; 1831 return true;
1697} 1832}
1698 1833
1699 1834