diff options
Diffstat (limited to 'linden/indra/llaudio/audioengine.cpp')
-rw-r--r-- | linden/indra/llaudio/audioengine.cpp | 395 |
1 files changed, 278 insertions, 117 deletions
diff --git a/linden/indra/llaudio/audioengine.cpp b/linden/indra/llaudio/audioengine.cpp index 5dd5b28..da9bcba 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) |
48 | extern void request_sound(const LLUUID &sound_guid); | 50 | extern void request_sound(const LLUUID &sound_guid); |
49 | 51 | ||
50 | LLAudioEngine* gAudiop = NULL; | 52 | LLAudioEngine* gAudiop = NULL; |
51 | 53 | ||
52 | // Maximum amount of time we wait for a transfer to complete before starting | ||
53 | // off another one. | ||
54 | const 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,15 +90,21 @@ 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; |
98 | mNextWindUpdate = 0.f; | 97 | mNextWindUpdate = 0.f; |
98 | |||
99 | mInternetStreamMedia = NULL; | ||
100 | mInternetStreamURL.clear(); | ||
101 | |||
102 | for (U32 i = 0; i < LLAudioEngine::AUDIO_TYPE_COUNT; i++) | ||
103 | mSecondaryGain[i] = 1.0f; | ||
99 | } | 104 | } |
100 | 105 | ||
101 | 106 | ||
102 | BOOL LLAudioEngine::init(const S32 num_channels, void* userdata) | 107 | bool LLAudioEngine::init(const S32 num_channels, void* userdata) |
103 | { | 108 | { |
104 | setDefaults(); | 109 | setDefaults(); |
105 | 110 | ||
@@ -111,7 +116,9 @@ BOOL LLAudioEngine::init(const S32 num_channels, void* userdata) | |||
111 | // Initialize the decode manager | 116 | // Initialize the decode manager |
112 | gAudioDecodeMgrp = new LLAudioDecodeMgr; | 117 | gAudioDecodeMgrp = new LLAudioDecodeMgr; |
113 | 118 | ||
114 | return TRUE; | 119 | LL_INFOS("AudioEngine") << "LLAudioEngine::init() AudioEngine successfully initialized" << llendl; |
120 | |||
121 | return true; | ||
115 | } | 122 | } |
116 | 123 | ||
117 | 124 | ||
@@ -121,6 +128,9 @@ void LLAudioEngine::shutdown() | |||
121 | delete gAudioDecodeMgrp; | 128 | delete gAudioDecodeMgrp; |
122 | gAudioDecodeMgrp = NULL; | 129 | gAudioDecodeMgrp = NULL; |
123 | 130 | ||
131 | // Clean up wind source | ||
132 | cleanupWind(); | ||
133 | |||
124 | // Clean up audio sources | 134 | // Clean up audio sources |
125 | source_map::iterator iter_src; | 135 | source_map::iterator iter_src; |
126 | for (iter_src = mAllSources.begin(); iter_src != mAllSources.end(); iter_src++) | 136 | for (iter_src = mAllSources.begin(); iter_src != mAllSources.end(); iter_src++) |
@@ -141,22 +151,146 @@ void LLAudioEngine::shutdown() | |||
141 | S32 i; | 151 | S32 i; |
142 | for (i = 0; i < MAX_CHANNELS; i++) | 152 | for (i = 0; i < MAX_CHANNELS; i++) |
143 | { | 153 | { |
144 | if (mChannels[i]) | 154 | delete mChannels[i]; |
145 | { | 155 | mChannels[i] = NULL; |
146 | delete mChannels[i]; | ||
147 | mChannels[i] = NULL; | ||
148 | } | ||
149 | } | 156 | } |
150 | 157 | ||
151 | // Clean up buffers | 158 | // Clean up buffers |
152 | for (i = 0; i < MAX_BUFFERS; i++) | 159 | for (i = 0; i < MAX_BUFFERS; i++) |
153 | { | 160 | { |
154 | 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 | ||
172 | void LLAudioEngine::startInternetStream(const std::string& url) | ||
173 | { | ||
174 | LL_INFOS("AudioEngine") << "entered startInternetStream()" << llendl; | ||
175 | |||
176 | if (!mInternetStreamMedia) | ||
177 | { | ||
178 | LLMediaManager* mgr = LLMediaManager::getInstance(); | ||
179 | if (mgr) | ||
155 | { | 180 | { |
156 | delete mBuffers[i]; | 181 | mInternetStreamMedia = mgr->createSourceFromMimeType(LLURI(url).scheme(), "audio/mpeg"); // assumes that whatever media implementation supports mp3 also supports vorbis. |
157 | mBuffers[i] = NULL; | 182 | LL_INFOS("AudioEngine") << "mInternetStreamMedia is now " << mInternetStreamMedia << llendl; |
183 | } | ||
184 | } | ||
185 | |||
186 | if(!mInternetStreamMedia) | ||
187 | return; | ||
188 | |||
189 | if (!url.empty()) { | ||
190 | LL_INFOS("AudioEngine") << "Starting internet stream: " << url << llendl; | ||
191 | mInternetStreamURL = url; | ||
192 | mInternetStreamMedia->navigateTo ( url ); | ||
193 | LL_INFOS("AudioEngine") << "Playing....." << llendl; | ||
194 | mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_START); | ||
195 | mInternetStreamMedia->updateMedia(); | ||
196 | } else { | ||
197 | LL_INFOS("AudioEngine") << "setting stream to NULL"<< llendl; | ||
198 | mInternetStreamURL.clear(); | ||
199 | mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_STOP); | ||
200 | mInternetStreamMedia->updateMedia(); | ||
201 | } | ||
202 | //#endif | ||
203 | } | ||
204 | |||
205 | // virtual | ||
206 | void LLAudioEngine::stopInternetStream() | ||
207 | { | ||
208 | LL_INFOS("AudioEngine") << "entered stopInternetStream()" << llendl; | ||
209 | |||
210 | if(mInternetStreamMedia) | ||
211 | { | ||
212 | if( ! mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_STOP)){ | ||
213 | LL_INFOS("AudioEngine") << "attempting to stop stream failed!" << llendl; | ||
214 | } | ||
215 | mInternetStreamMedia->updateMedia(); | ||
216 | } | ||
217 | |||
218 | mInternetStreamURL.clear(); | ||
219 | } | ||
220 | |||
221 | // virtual | ||
222 | void LLAudioEngine::pauseInternetStream(int pause) | ||
223 | { | ||
224 | LL_INFOS("AudioEngine") << "entered pauseInternetStream()" << llendl; | ||
225 | |||
226 | if(!mInternetStreamMedia) | ||
227 | return; | ||
228 | |||
229 | if(pause) | ||
230 | { | ||
231 | if(! mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_PAUSE)) | ||
232 | { | ||
233 | LL_INFOS("AudioEngine") << "attempting to pause stream failed!" << llendl; | ||
234 | } | ||
235 | } else { | ||
236 | if(! mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_START)) | ||
237 | { | ||
238 | LL_INFOS("AudioEngine") << "attempting to unpause stream failed!" << llendl; | ||
158 | } | 239 | } |
159 | } | 240 | } |
241 | mInternetStreamMedia->updateMedia(); | ||
242 | } | ||
243 | |||
244 | // virtual | ||
245 | void LLAudioEngine::updateInternetStream() | ||
246 | { | ||
247 | if (mInternetStreamMedia) | ||
248 | mInternetStreamMedia->updateMedia(); | ||
249 | } | ||
250 | |||
251 | // virtual | ||
252 | int LLAudioEngine::isInternetStreamPlaying() | ||
253 | { | ||
254 | if (!mInternetStreamMedia) | ||
255 | return 0; | ||
256 | |||
257 | if (mInternetStreamMedia->getStatus() == LLMediaBase::STATUS_STARTED) | ||
258 | { | ||
259 | return 1; // Active and playing | ||
260 | } | ||
261 | |||
262 | if (mInternetStreamMedia->getStatus() == LLMediaBase::STATUS_PAUSED) | ||
263 | { | ||
264 | return 2; // paused | ||
265 | } | ||
266 | |||
267 | return 0; // Stopped | ||
268 | } | ||
269 | |||
270 | // virtual | ||
271 | void LLAudioEngine::getInternetStreamInfo(char* artist, char* title) | ||
272 | { | ||
273 | artist[0] = 0; | ||
274 | title[0] = 0; | ||
275 | } | ||
276 | |||
277 | // virtual | ||
278 | void LLAudioEngine::setInternetStreamGain(F32 vol) | ||
279 | { | ||
280 | mInternetStreamGain = vol; | ||
281 | |||
282 | if(!mInternetStreamMedia) | ||
283 | return; | ||
284 | |||
285 | vol = llclamp(vol, 0.f, 1.f); | ||
286 | mInternetStreamMedia->setVolume(vol); | ||
287 | mInternetStreamMedia->updateMedia(); | ||
288 | } | ||
289 | |||
290 | // virtual | ||
291 | const std::string& LLAudioEngine::getInternetStreamURL() | ||
292 | { | ||
293 | return mInternetStreamURL; | ||
160 | } | 294 | } |
161 | 295 | ||
162 | 296 | ||
@@ -167,6 +301,13 @@ void LLAudioEngine::updateChannels() | |||
167 | { | 301 | { |
168 | if (mChannels[i]) | 302 | if (mChannels[i]) |
169 | { | 303 | { |
304 | // set secondary gain if type is available | ||
305 | LLAudioSource* source = mChannels[i]->getSource(); | ||
306 | if (source) | ||
307 | { | ||
308 | mChannels[i]->setSecondaryGain(mSecondaryGain[source->getType()]); | ||
309 | } | ||
310 | |||
170 | mChannels[i]->updateBuffer(); | 311 | mChannels[i]->updateBuffer(); |
171 | mChannels[i]->update3DPosition(); | 312 | mChannels[i]->update3DPosition(); |
172 | mChannels[i]->updateLoop(); | 313 | mChannels[i]->updateLoop(); |
@@ -200,7 +341,7 @@ void LLAudioEngine::idle(F32 max_decode_time) | |||
200 | { | 341 | { |
201 | if (mBuffers[i]) | 342 | if (mBuffers[i]) |
202 | { | 343 | { |
203 | mBuffers[i]->mInUse = FALSE; | 344 | mBuffers[i]->mInUse = false; |
204 | } | 345 | } |
205 | } | 346 | } |
206 | 347 | ||
@@ -245,18 +386,18 @@ void LLAudioEngine::idle(F32 max_decode_time) | |||
245 | LLAudioChannel *channelp = getFreeChannel(max_priority); | 386 | LLAudioChannel *channelp = getFreeChannel(max_priority); |
246 | if (channelp) | 387 | if (channelp) |
247 | { | 388 | { |
248 | //llinfos << "Replacing source in channel due to priority!" << llendl; | 389 | //LL_INFOS("AudioEngine") << "Replacing source in channel due to priority!" << llendl; |
249 | max_sourcep->setChannel(channelp); | 390 | max_sourcep->setChannel(channelp); |
250 | channelp->setSource(max_sourcep); | 391 | channelp->setSource(max_sourcep); |
251 | if (max_sourcep->isSyncSlave()) | 392 | if (max_sourcep->isSyncSlave()) |
252 | { | 393 | { |
253 | // A sync slave, it doesn't start playing until it's synced up with the master. | 394 | // A sync slave, it doesn't start playing until it's synced up with the master. |
254 | // Flag this channel as waiting for sync, and return true. | 395 | // Flag this channel as waiting for sync, and return true. |
255 | channelp->setWaiting(TRUE); | 396 | channelp->setWaiting(true); |
256 | } | 397 | } |
257 | else | 398 | else |
258 | { | 399 | { |
259 | channelp->setWaiting(FALSE); | 400 | channelp->setWaiting(false); |
260 | channelp->play(); | 401 | channelp->play(); |
261 | } | 402 | } |
262 | } | 403 | } |
@@ -396,7 +537,7 @@ void LLAudioEngine::idle(F32 max_decode_time) | |||
396 | if (sync_masterp->getChannel()) | 537 | if (sync_masterp->getChannel()) |
397 | { | 538 | { |
398 | channelp->playSynced(master_channelp); | 539 | channelp->playSynced(master_channelp); |
399 | channelp->setWaiting(FALSE); | 540 | channelp->setWaiting(false); |
400 | } | 541 | } |
401 | } | 542 | } |
402 | } | 543 | } |
@@ -412,7 +553,7 @@ void LLAudioEngine::idle(F32 max_decode_time) | |||
412 | { | 553 | { |
413 | if (!mBuffers[i]->mInUse && mBuffers[i]->mLastUseTimer.getElapsedTimeF32() > 30.f) | 554 | if (!mBuffers[i]->mInUse && mBuffers[i]->mLastUseTimer.getElapsedTimeF32() > 30.f) |
414 | { | 555 | { |
415 | //llinfos << "Flushing unused buffer!" << llendl; | 556 | //LL_INFOS("AudioEngine") << "Flushing unused buffer!" << llendl; |
416 | mBuffers[i]->mAudioDatap->mBufferp = NULL; | 557 | mBuffers[i]->mAudioDatap->mBufferp = NULL; |
417 | delete mBuffers[i]; | 558 | delete mBuffers[i]; |
418 | mBuffers[i] = NULL; | 559 | mBuffers[i] = NULL; |
@@ -426,7 +567,7 @@ void LLAudioEngine::idle(F32 max_decode_time) | |||
426 | { | 567 | { |
427 | if (mChannels[i]) | 568 | if (mChannels[i]) |
428 | { | 569 | { |
429 | mChannels[i]->mLoopedThisFrame = FALSE; | 570 | mChannels[i]->mLoopedThisFrame = false; |
430 | } | 571 | } |
431 | } | 572 | } |
432 | 573 | ||
@@ -437,13 +578,17 @@ void LLAudioEngine::idle(F32 max_decode_time) | |||
437 | // missed picking it up in all the places that can add | 578 | // missed picking it up in all the places that can add |
438 | // or request new data. | 579 | // or request new data. |
439 | startNextTransfer(); | 580 | startNextTransfer(); |
581 | |||
582 | updateInternetStream(); | ||
440 | } | 583 | } |
441 | 584 | ||
442 | BOOL LLAudioEngine::updateBufferForData(LLAudioData *adp, const LLUUID &audio_uuid) | 585 | |
586 | |||
587 | bool LLAudioEngine::updateBufferForData(LLAudioData *adp, const LLUUID &audio_uuid) | ||
443 | { | 588 | { |
444 | if (!adp) | 589 | if (!adp) |
445 | { | 590 | { |
446 | return FALSE; | 591 | return false; |
447 | } | 592 | } |
448 | 593 | ||
449 | // Update the audio buffer first - load a sound if we have it. | 594 | // Update the audio buffer first - load a sound if we have it. |
@@ -466,14 +611,14 @@ BOOL LLAudioEngine::updateBufferForData(LLAudioData *adp, const LLUUID &audio_uu | |||
466 | } | 611 | } |
467 | else | 612 | else |
468 | { | 613 | { |
469 | return FALSE; | 614 | return false; |
470 | } | 615 | } |
471 | } | 616 | } |
472 | return TRUE; | 617 | return true; |
473 | } | 618 | } |
474 | 619 | ||
475 | 620 | ||
476 | void LLAudioEngine::enableWind(BOOL enable) | 621 | void LLAudioEngine::enableWind(bool enable) |
477 | { | 622 | { |
478 | if (enable && (!mEnableWind)) | 623 | if (enable && (!mEnableWind)) |
479 | { | 624 | { |
@@ -521,8 +666,8 @@ LLAudioBuffer *LLAudioEngine::getFreeBuffer() | |||
521 | 666 | ||
522 | if (buffer_id >= 0) | 667 | if (buffer_id >= 0) |
523 | { | 668 | { |
524 | llinfos << "Taking over unused buffer " << buffer_id << llendl; | 669 | LL_INFOS("AudioEngine") << "Taking over unused buffer " << buffer_id << llendl; |
525 | //llinfos << "Flushing unused buffer!" << llendl; | 670 | //LL_INFOS("AudioEngine") << "Flushing unused buffer!" << llendl; |
526 | mBuffers[buffer_id]->mAudioDatap->mBufferp = NULL; | 671 | mBuffers[buffer_id]->mAudioDatap->mBufferp = NULL; |
527 | delete mBuffers[buffer_id]; | 672 | delete mBuffers[buffer_id]; |
528 | mBuffers[buffer_id] = createBuffer(); | 673 | mBuffers[buffer_id] = createBuffer(); |
@@ -601,7 +746,7 @@ void LLAudioEngine::cleanupBuffer(LLAudioBuffer *bufferp) | |||
601 | } | 746 | } |
602 | 747 | ||
603 | 748 | ||
604 | BOOL LLAudioEngine::preloadSound(const LLUUID &uuid) | 749 | bool LLAudioEngine::preloadSound(const LLUUID &uuid) |
605 | { | 750 | { |
606 | gAudiop->getAudioData(uuid); // We don't care about the return value, this is just to make sure | 751 | gAudiop->getAudioData(uuid); // We don't care about the return value, this is just to make sure |
607 | // that we have an entry, which will mean that the audio engine knows about this | 752 | // that we have an entry, which will mean that the audio engine knows about this |
@@ -609,23 +754,23 @@ BOOL LLAudioEngine::preloadSound(const LLUUID &uuid) | |||
609 | if (gAudioDecodeMgrp->addDecodeRequest(uuid)) | 754 | if (gAudioDecodeMgrp->addDecodeRequest(uuid)) |
610 | { | 755 | { |
611 | // This means that we do have a local copy, and we're working on decoding it. | 756 | // This means that we do have a local copy, and we're working on decoding it. |
612 | return TRUE; | 757 | return true; |
613 | } | 758 | } |
614 | 759 | ||
615 | // At some point we need to have the audio/asset system check the static VFS | 760 | // At some point we need to have the audio/asset system check the static VFS |
616 | // before it goes off and fetches stuff from the server. | 761 | // before it goes off and fetches stuff from the server. |
617 | //llwarns << "Used internal preload for non-local sound" << llendl; | 762 | //llwarns << "Used internal preload for non-local sound" << llendl; |
618 | return FALSE; | 763 | return false; |
619 | } | 764 | } |
620 | 765 | ||
621 | 766 | ||
622 | BOOL LLAudioEngine::isWindEnabled() | 767 | bool LLAudioEngine::isWindEnabled() |
623 | { | 768 | { |
624 | return mEnableWind; | 769 | return mEnableWind; |
625 | } | 770 | } |
626 | 771 | ||
627 | 772 | ||
628 | void LLAudioEngine::setMuted(BOOL muted) | 773 | void LLAudioEngine::setMuted(bool muted) |
629 | { | 774 | { |
630 | mMuted = muted; | 775 | mMuted = muted; |
631 | enableWind(!mMuted); | 776 | enableWind(!mMuted); |
@@ -643,6 +788,18 @@ F32 LLAudioEngine::getMasterGain() | |||
643 | return mMasterGain; | 788 | return mMasterGain; |
644 | } | 789 | } |
645 | 790 | ||
791 | void LLAudioEngine::setSecondaryGain(S32 type, F32 gain) | ||
792 | { | ||
793 | llassert(type < LLAudioEngine::AUDIO_TYPE_COUNT); | ||
794 | |||
795 | mSecondaryGain[type] = gain; | ||
796 | } | ||
797 | |||
798 | F32 LLAudioEngine::getSecondaryGain(S32 type) | ||
799 | { | ||
800 | return mSecondaryGain[type]; | ||
801 | } | ||
802 | |||
646 | F32 LLAudioEngine::getInternetStreamGain() | 803 | F32 LLAudioEngine::getInternetStreamGain() |
647 | { | 804 | { |
648 | return mInternetStreamGain; | 805 | return mInternetStreamGain; |
@@ -718,10 +875,11 @@ F64 LLAudioEngine::mapWindVecToPan(LLVector3 wind_vec) | |||
718 | } | 875 | } |
719 | 876 | ||
720 | 877 | ||
721 | void LLAudioEngine::triggerSound(const LLUUID &audio_uuid, const LLUUID& owner_id, const F32 gain, const LLVector3d &pos_global) | 878 | void LLAudioEngine::triggerSound(const LLUUID &audio_uuid, const LLUUID& owner_id, const F32 gain, |
879 | const S32 type, const LLVector3d &pos_global) | ||
722 | { | 880 | { |
723 | // Create a new source (since this can't be associated with an existing source. | 881 | // Create a new source (since this can't be associated with an existing source. |
724 | //llinfos << "Localized: " << audio_uuid << llendl; | 882 | //LL_INFOS("AudioEngine") << "Localized: " << audio_uuid << llendl; |
725 | 883 | ||
726 | if (mMuted) | 884 | if (mMuted) |
727 | { | 885 | { |
@@ -731,11 +889,11 @@ void LLAudioEngine::triggerSound(const LLUUID &audio_uuid, const LLUUID& owner_i | |||
731 | LLUUID source_id; | 889 | LLUUID source_id; |
732 | source_id.generate(); | 890 | source_id.generate(); |
733 | 891 | ||
734 | LLAudioSource *asp = new LLAudioSource(source_id, owner_id, gain); | 892 | LLAudioSource *asp = new LLAudioSource(source_id, owner_id, gain, type); |
735 | gAudiop->addAudioSource(asp); | 893 | gAudiop->addAudioSource(asp); |
736 | if (pos_global.isExactlyZero()) | 894 | if (pos_global.isExactlyZero()) |
737 | { | 895 | { |
738 | asp->setAmbient(TRUE); | 896 | asp->setAmbient(true); |
739 | } | 897 | } |
740 | else | 898 | else |
741 | { | 899 | { |
@@ -914,7 +1072,7 @@ void LLAudioEngine::cleanupAudioSource(LLAudioSource *asp) | |||
914 | } | 1072 | } |
915 | 1073 | ||
916 | 1074 | ||
917 | BOOL LLAudioEngine::hasDecodedFile(const LLUUID &uuid) | 1075 | bool LLAudioEngine::hasDecodedFile(const LLUUID &uuid) |
918 | { | 1076 | { |
919 | std::string uuid_str; | 1077 | std::string uuid_str; |
920 | uuid.toString(uuid_str); | 1078 | uuid.toString(uuid_str); |
@@ -925,16 +1083,16 @@ BOOL LLAudioEngine::hasDecodedFile(const LLUUID &uuid) | |||
925 | 1083 | ||
926 | if (gDirUtilp->fileExists(wav_path)) | 1084 | if (gDirUtilp->fileExists(wav_path)) |
927 | { | 1085 | { |
928 | return TRUE; | 1086 | return true; |
929 | } | 1087 | } |
930 | else | 1088 | else |
931 | { | 1089 | { |
932 | return FALSE; | 1090 | return false; |
933 | } | 1091 | } |
934 | } | 1092 | } |
935 | 1093 | ||
936 | 1094 | ||
937 | BOOL LLAudioEngine::hasLocalFile(const LLUUID &uuid) | 1095 | bool LLAudioEngine::hasLocalFile(const LLUUID &uuid) |
938 | { | 1096 | { |
939 | // See if it's in the VFS. | 1097 | // See if it's in the VFS. |
940 | return gVFS->getExists(uuid, LLAssetType::AT_SOUND); | 1098 | return gVFS->getExists(uuid, LLAssetType::AT_SOUND); |
@@ -943,10 +1101,10 @@ BOOL LLAudioEngine::hasLocalFile(const LLUUID &uuid) | |||
943 | 1101 | ||
944 | void LLAudioEngine::startNextTransfer() | 1102 | void LLAudioEngine::startNextTransfer() |
945 | { | 1103 | { |
946 | //llinfos << "LLAudioEngine::startNextTransfer()" << llendl; | 1104 | //LL_INFOS("AudioEngine") << "LLAudioEngine::startNextTransfer()" << llendl; |
947 | if (mCurrentTransfer.notNull() || getMuted()) | 1105 | if (mCurrentTransfer.notNull() || getMuted()) |
948 | { | 1106 | { |
949 | //llinfos << "Transfer in progress, aborting" << llendl; | 1107 | //LL_INFOS("AudioEngine") << "Transfer in progress, aborting" << llendl; |
950 | return; | 1108 | return; |
951 | } | 1109 | } |
952 | 1110 | ||
@@ -1127,7 +1285,7 @@ void LLAudioEngine::startNextTransfer() | |||
1127 | 1285 | ||
1128 | if (asset_id.notNull()) | 1286 | if (asset_id.notNull()) |
1129 | { | 1287 | { |
1130 | llinfos << "Getting asset data for: " << asset_id << llendl; | 1288 | LL_INFOS("AudioEngine") << "Getting asset data for: " << asset_id << llendl; |
1131 | gAudiop->mCurrentTransfer = asset_id; | 1289 | gAudiop->mCurrentTransfer = asset_id; |
1132 | gAudiop->mCurrentTransferTimer.reset(); | 1290 | gAudiop->mCurrentTransferTimer.reset(); |
1133 | gAssetStorage->getAssetData(asset_id, LLAssetType::AT_SOUND, | 1291 | gAssetStorage->getAssetData(asset_id, LLAssetType::AT_SOUND, |
@@ -1135,7 +1293,7 @@ void LLAudioEngine::startNextTransfer() | |||
1135 | } | 1293 | } |
1136 | else | 1294 | else |
1137 | { | 1295 | { |
1138 | //llinfos << "No pending transfers?" << llendl; | 1296 | //LL_INFOS("AudioEngine") << "No pending transfers?" << llendl; |
1139 | } | 1297 | } |
1140 | } | 1298 | } |
1141 | 1299 | ||
@@ -1145,14 +1303,14 @@ void LLAudioEngine::assetCallback(LLVFS *vfs, const LLUUID &uuid, LLAssetType::E | |||
1145 | { | 1303 | { |
1146 | if (result_code) | 1304 | if (result_code) |
1147 | { | 1305 | { |
1148 | llinfos << "Boom, error in audio file transfer: " << LLAssetStorage::getErrorString( result_code ) << " (" << result_code << ")" << llendl; | 1306 | LL_INFOS("AudioEngine") << "Boom, error in audio file transfer: " << LLAssetStorage::getErrorString( result_code ) << " (" << result_code << ")" << llendl; |
1149 | // Need to mark data as bad to avoid constant rerequests. | 1307 | // Need to mark data as bad to avoid constant rerequests. |
1150 | LLAudioData *adp = gAudiop->getAudioData(uuid); | 1308 | LLAudioData *adp = gAudiop->getAudioData(uuid); |
1151 | if (adp) | 1309 | if (adp) |
1152 | { | 1310 | { |
1153 | adp->setHasValidData(FALSE); | 1311 | adp->setHasValidData(false); |
1154 | adp->setHasLocalData(FALSE); | 1312 | adp->setHasLocalData(false); |
1155 | adp->setHasDecodedData(FALSE); | 1313 | adp->setHasDecodedData(false); |
1156 | } | 1314 | } |
1157 | } | 1315 | } |
1158 | else | 1316 | else |
@@ -1165,8 +1323,8 @@ void LLAudioEngine::assetCallback(LLVFS *vfs, const LLUUID &uuid, LLAssetType::E | |||
1165 | } | 1323 | } |
1166 | else | 1324 | else |
1167 | { | 1325 | { |
1168 | adp->setHasValidData(TRUE); | 1326 | adp->setHasValidData(true); |
1169 | adp->setHasLocalData(TRUE); | 1327 | adp->setHasLocalData(true); |
1170 | gAudioDecodeMgrp->addDecodeRequest(uuid); | 1328 | gAudioDecodeMgrp->addDecodeRequest(uuid); |
1171 | } | 1329 | } |
1172 | } | 1330 | } |
@@ -1180,17 +1338,18 @@ void LLAudioEngine::assetCallback(LLVFS *vfs, const LLUUID &uuid, LLAssetType::E | |||
1180 | // | 1338 | // |
1181 | 1339 | ||
1182 | 1340 | ||
1183 | LLAudioSource::LLAudioSource(const LLUUID& id, const LLUUID& owner_id, const F32 gain) | 1341 | LLAudioSource::LLAudioSource(const LLUUID& id, const LLUUID& owner_id, const F32 gain, const S32 type) |
1184 | : mID(id), | 1342 | : mID(id), |
1185 | mOwnerID(owner_id), | 1343 | mOwnerID(owner_id), |
1186 | mPriority(0.f), | 1344 | mPriority(0.f), |
1187 | mGain(gain), | 1345 | mGain(gain), |
1188 | mAmbient(FALSE), | 1346 | mType(type), |
1189 | mLoop(FALSE), | 1347 | mAmbient(false), |
1190 | mSyncMaster(FALSE), | 1348 | mLoop(false), |
1191 | mSyncSlave(FALSE), | 1349 | mSyncMaster(false), |
1192 | mQueueSounds(FALSE), | 1350 | mSyncSlave(false), |
1193 | mPlayedOnce(FALSE), | 1351 | mQueueSounds(false), |
1352 | mPlayedOnce(false), | ||
1194 | mChannelp(NULL), | 1353 | mChannelp(NULL), |
1195 | mCurrentDatap(NULL), | 1354 | mCurrentDatap(NULL), |
1196 | mQueuedDatap(NULL) | 1355 | mQueuedDatap(NULL) |
@@ -1254,7 +1413,7 @@ void LLAudioSource::updatePriority() | |||
1254 | } | 1413 | } |
1255 | } | 1414 | } |
1256 | 1415 | ||
1257 | BOOL LLAudioSource::setupChannel() | 1416 | bool LLAudioSource::setupChannel() |
1258 | { | 1417 | { |
1259 | LLAudioData *adp = getCurrentData(); | 1418 | LLAudioData *adp = getCurrentData(); |
1260 | 1419 | ||
@@ -1262,7 +1421,7 @@ BOOL LLAudioSource::setupChannel() | |||
1262 | { | 1421 | { |
1263 | // We're not ready to play back the sound yet, so don't try and allocate a channel for it. | 1422 | // We're not ready to play back the sound yet, so don't try and allocate a channel for it. |
1264 | //llwarns << "Aborting, no buffer" << llendl; | 1423 | //llwarns << "Aborting, no buffer" << llendl; |
1265 | return FALSE; | 1424 | return false; |
1266 | } | 1425 | } |
1267 | 1426 | ||
1268 | 1427 | ||
@@ -1280,15 +1439,15 @@ BOOL LLAudioSource::setupChannel() | |||
1280 | // Now we have to reprioritize. | 1439 | // Now we have to reprioritize. |
1281 | // For now, just don't play the sound. | 1440 | // For now, just don't play the sound. |
1282 | //llwarns << "Aborting, no free channels" << llendl; | 1441 | //llwarns << "Aborting, no free channels" << llendl; |
1283 | return FALSE; | 1442 | return false; |
1284 | } | 1443 | } |
1285 | 1444 | ||
1286 | mChannelp->setSource(this); | 1445 | mChannelp->setSource(this); |
1287 | return TRUE; | 1446 | return true; |
1288 | } | 1447 | } |
1289 | 1448 | ||
1290 | 1449 | ||
1291 | BOOL LLAudioSource::play(const LLUUID &audio_uuid) | 1450 | bool LLAudioSource::play(const LLUUID &audio_uuid) |
1292 | { | 1451 | { |
1293 | if (audio_uuid.isNull()) | 1452 | if (audio_uuid.isNull()) |
1294 | { | 1453 | { |
@@ -1296,7 +1455,7 @@ BOOL LLAudioSource::play(const LLUUID &audio_uuid) | |||
1296 | { | 1455 | { |
1297 | getChannel()->setSource(NULL); | 1456 | getChannel()->setSource(NULL); |
1298 | setChannel(NULL); | 1457 | setChannel(NULL); |
1299 | addAudioData(NULL, TRUE); | 1458 | addAudioData(NULL, true); |
1300 | } | 1459 | } |
1301 | } | 1460 | } |
1302 | // Reset our age timeout if someone attempts to play the source. | 1461 | // Reset our age timeout if someone attempts to play the source. |
@@ -1304,7 +1463,7 @@ BOOL LLAudioSource::play(const LLUUID &audio_uuid) | |||
1304 | 1463 | ||
1305 | LLAudioData *adp = gAudiop->getAudioData(audio_uuid); | 1464 | LLAudioData *adp = gAudiop->getAudioData(audio_uuid); |
1306 | 1465 | ||
1307 | BOOL has_buffer = gAudiop->updateBufferForData(adp, audio_uuid); | 1466 | bool has_buffer = gAudiop->updateBufferForData(adp, audio_uuid); |
1308 | 1467 | ||
1309 | 1468 | ||
1310 | addAudioData(adp); | 1469 | addAudioData(adp); |
@@ -1312,47 +1471,48 @@ BOOL LLAudioSource::play(const LLUUID &audio_uuid) | |||
1312 | if (!has_buffer) | 1471 | if (!has_buffer) |
1313 | { | 1472 | { |
1314 | // Don't bother trying to set up a channel or anything, we don't have an audio buffer. | 1473 | // Don't bother trying to set up a channel or anything, we don't have an audio buffer. |
1315 | return FALSE; | 1474 | return false; |
1316 | } | 1475 | } |
1317 | 1476 | ||
1318 | if (!setupChannel()) | 1477 | if (!setupChannel()) |
1319 | { | 1478 | { |
1320 | return FALSE; | 1479 | return false; |
1321 | } | 1480 | } |
1322 | 1481 | ||
1323 | if (isSyncSlave()) | 1482 | if (isSyncSlave()) |
1324 | { | 1483 | { |
1325 | // A sync slave, it doesn't start playing until it's synced up with the master. | 1484 | // A sync slave, it doesn't start playing until it's synced up with the master. |
1326 | // Flag this channel as waiting for sync, and return true. | 1485 | // Flag this channel as waiting for sync, and return true. |
1327 | getChannel()->setWaiting(TRUE); | 1486 | getChannel()->setWaiting(true); |
1328 | return TRUE; | 1487 | return true; |
1329 | } | 1488 | } |
1330 | 1489 | ||
1331 | getChannel()->play(); | 1490 | getChannel()->play(); |
1332 | return TRUE; | 1491 | return true; |
1333 | } | 1492 | } |
1334 | 1493 | ||
1335 | 1494 | ||
1336 | BOOL LLAudioSource::isDone() | 1495 | bool LLAudioSource::isDone() |
1337 | { | 1496 | { |
1338 | const F32 MAX_AGE = 60.f; | 1497 | const F32 MAX_AGE = 60.f; |
1339 | const F32 MAX_UNPLAYED_AGE = 15.f; | 1498 | const F32 MAX_UNPLAYED_AGE = 15.f; |
1499 | |||
1340 | if (isLoop()) | 1500 | if (isLoop()) |
1341 | { | 1501 | { |
1342 | // Looped sources never die on their own. | 1502 | // Looped sources never die on their own. |
1343 | return FALSE; | 1503 | return false; |
1344 | } | 1504 | } |
1345 | 1505 | ||
1346 | 1506 | ||
1347 | if (hasPendingPreloads()) | 1507 | if (hasPendingPreloads()) |
1348 | { | 1508 | { |
1349 | return FALSE; | 1509 | return false; |
1350 | } | 1510 | } |
1351 | 1511 | ||
1352 | if (mQueuedDatap) | 1512 | if (mQueuedDatap) |
1353 | { | 1513 | { |
1354 | // Don't kill this sound if we've got something queued up to play. | 1514 | // Don't kill this sound if we've got something queued up to play. |
1355 | return FALSE; | 1515 | return false; |
1356 | } | 1516 | } |
1357 | 1517 | ||
1358 | F32 elapsed = mAgeTimer.getElapsedTimeF32(); | 1518 | F32 elapsed = mAgeTimer.getElapsedTimeF32(); |
@@ -1364,12 +1524,12 @@ BOOL LLAudioSource::isDone() | |||
1364 | { | 1524 | { |
1365 | // We don't have a channel assigned, and it's been | 1525 | // We don't have a channel assigned, and it's been |
1366 | // over 5 seconds since we tried to play it. Don't bother. | 1526 | // over 5 seconds since we tried to play it. Don't bother. |
1367 | //llinfos << "No channel assigned, source is done" << llendl; | 1527 | //LL_INFOS("AudioEngine") << "No channel assigned, source is done" << llendl; |
1368 | return TRUE; | 1528 | return true; |
1369 | } | 1529 | } |
1370 | else | 1530 | else |
1371 | { | 1531 | { |
1372 | return FALSE; | 1532 | return false; |
1373 | } | 1533 | } |
1374 | } | 1534 | } |
1375 | 1535 | ||
@@ -1377,27 +1537,27 @@ BOOL LLAudioSource::isDone() | |||
1377 | { | 1537 | { |
1378 | if (elapsed > MAX_AGE) | 1538 | if (elapsed > MAX_AGE) |
1379 | { | 1539 | { |
1380 | // Arbitarily cut off non-looped sounds when they're 20 seconds old. | 1540 | // Arbitarily cut off non-looped sounds when they're old. |
1381 | return TRUE; | 1541 | return true; |
1382 | } | 1542 | } |
1383 | else | 1543 | else |
1384 | { | 1544 | { |
1385 | // Sound is still playing and we haven't timed out, don't kill it. | 1545 | // Sound is still playing and we haven't timed out, don't kill it. |
1386 | return FALSE; | 1546 | return false; |
1387 | } | 1547 | } |
1388 | } | 1548 | } |
1389 | 1549 | ||
1390 | if ((elapsed > MAX_UNPLAYED_AGE) || mPlayedOnce) | 1550 | if ((elapsed > MAX_UNPLAYED_AGE) || mPlayedOnce) |
1391 | { | 1551 | { |
1392 | // The sound isn't playing back after 5 seconds or we're already done playing it, kill it. | 1552 | // The sound isn't playing back after 5 seconds or we're already done playing it, kill it. |
1393 | return TRUE; | 1553 | return true; |
1394 | } | 1554 | } |
1395 | 1555 | ||
1396 | return FALSE; | 1556 | return false; |
1397 | } | 1557 | } |
1398 | 1558 | ||
1399 | 1559 | ||
1400 | void LLAudioSource::addAudioData(LLAudioData *adp, const BOOL set_current) | 1560 | void LLAudioSource::addAudioData(LLAudioData *adp, const bool set_current) |
1401 | { | 1561 | { |
1402 | // Only handle a single piece of audio data associated with a source right now, | 1562 | // Only handle a single piece of audio data associated with a source right now, |
1403 | // until I implement prefetch. | 1563 | // until I implement prefetch. |
@@ -1465,7 +1625,7 @@ void LLAudioSource::addAudioData(LLAudioData *adp, const BOOL set_current) | |||
1465 | } | 1625 | } |
1466 | 1626 | ||
1467 | 1627 | ||
1468 | BOOL LLAudioSource::hasPendingPreloads() const | 1628 | bool LLAudioSource::hasPendingPreloads() const |
1469 | { | 1629 | { |
1470 | // Check to see if we've got any preloads on deck for this source | 1630 | // Check to see if we've got any preloads on deck for this source |
1471 | data_map::const_iterator iter; | 1631 | data_map::const_iterator iter; |
@@ -1475,11 +1635,11 @@ BOOL LLAudioSource::hasPendingPreloads() const | |||
1475 | if (!adp->hasDecodedData()) | 1635 | if (!adp->hasDecodedData()) |
1476 | { | 1636 | { |
1477 | // This source is still waiting for a preload | 1637 | // This source is still waiting for a preload |
1478 | return TRUE; | 1638 | return true; |
1479 | } | 1639 | } |
1480 | } | 1640 | } |
1481 | 1641 | ||
1482 | return FALSE; | 1642 | return false; |
1483 | } | 1643 | } |
1484 | 1644 | ||
1485 | 1645 | ||
@@ -1514,8 +1674,9 @@ LLAudioBuffer *LLAudioSource::getCurrentBuffer() | |||
1514 | LLAudioChannel::LLAudioChannel() : | 1674 | LLAudioChannel::LLAudioChannel() : |
1515 | mCurrentSourcep(NULL), | 1675 | mCurrentSourcep(NULL), |
1516 | mCurrentBufferp(NULL), | 1676 | mCurrentBufferp(NULL), |
1517 | mLoopedThisFrame(FALSE), | 1677 | mLoopedThisFrame(false), |
1518 | mWaiting(FALSE) | 1678 | mWaiting(false), |
1679 | mSecondaryGain(1.0f) | ||
1519 | { | 1680 | { |
1520 | } | 1681 | } |
1521 | 1682 | ||
@@ -1523,7 +1684,7 @@ LLAudioChannel::LLAudioChannel() : | |||
1523 | LLAudioChannel::~LLAudioChannel() | 1684 | LLAudioChannel::~LLAudioChannel() |
1524 | { | 1685 | { |
1525 | // Need to disconnect any sources which are using this channel. | 1686 | // Need to disconnect any sources which are using this channel. |
1526 | //llinfos << "Cleaning up audio channel" << llendl; | 1687 | //LL_INFOS("AudioEngine") << "Cleaning up audio channel" << llendl; |
1527 | if (mCurrentSourcep) | 1688 | if (mCurrentSourcep) |
1528 | { | 1689 | { |
1529 | mCurrentSourcep->setChannel(NULL); | 1690 | mCurrentSourcep->setChannel(NULL); |
@@ -1534,22 +1695,22 @@ LLAudioChannel::~LLAudioChannel() | |||
1534 | 1695 | ||
1535 | void LLAudioChannel::setSource(LLAudioSource *sourcep) | 1696 | void LLAudioChannel::setSource(LLAudioSource *sourcep) |
1536 | { | 1697 | { |
1537 | //llinfos << this << ": setSource(" << sourcep << ")" << llendl; | 1698 | //LL_INFOS("AudioEngine") << this << ": setSource(" << sourcep << ")" << llendl; |
1538 | 1699 | ||
1539 | if (!sourcep) | 1700 | if (!sourcep) |
1540 | { | 1701 | { |
1541 | // Clearing the source for this channel, don't need to do anything. | 1702 | // Clearing the source for this channel, don't need to do anything. |
1542 | //llinfos << "Clearing source for channel" << llendl; | 1703 | //LL_INFOS("AudioEngine") << "Clearing source for channel" << llendl; |
1543 | cleanup(); | 1704 | cleanup(); |
1544 | mCurrentSourcep = NULL; | 1705 | mCurrentSourcep = NULL; |
1545 | mWaiting = FALSE; | 1706 | mWaiting = false; |
1546 | return; | 1707 | return; |
1547 | } | 1708 | } |
1548 | 1709 | ||
1549 | if (sourcep == mCurrentSourcep) | 1710 | if (sourcep == mCurrentSourcep) |
1550 | { | 1711 | { |
1551 | // Don't reallocate the channel, this will make FMOD goofy. | 1712 | // Don't reallocate the channel, this will make FMOD goofy. |
1552 | //llinfos << "Calling setSource with same source!" << llendl; | 1713 | //LL_INFOS("AudioEngine") << "Calling setSource with same source!" << llendl; |
1553 | } | 1714 | } |
1554 | 1715 | ||
1555 | mCurrentSourcep = sourcep; | 1716 | mCurrentSourcep = sourcep; |
@@ -1558,13 +1719,13 @@ void LLAudioChannel::setSource(LLAudioSource *sourcep) | |||
1558 | } | 1719 | } |
1559 | 1720 | ||
1560 | 1721 | ||
1561 | BOOL LLAudioChannel::updateBuffer() | 1722 | bool LLAudioChannel::updateBuffer() |
1562 | { | 1723 | { |
1563 | if (!mCurrentSourcep) | 1724 | if (!mCurrentSourcep) |
1564 | { | 1725 | { |
1565 | // This channel isn't associated with any source, nothing | 1726 | // This channel isn't associated with any source, nothing |
1566 | // to be updated | 1727 | // to be updated |
1567 | return FALSE; | 1728 | return false; |
1568 | } | 1729 | } |
1569 | 1730 | ||
1570 | LLAudioBuffer *bufferp = mCurrentSourcep->getCurrentBuffer(); | 1731 | LLAudioBuffer *bufferp = mCurrentSourcep->getCurrentBuffer(); |
@@ -1574,14 +1735,14 @@ BOOL LLAudioChannel::updateBuffer() | |||
1574 | { | 1735 | { |
1575 | // The source hasn't changed what buffer it's playing | 1736 | // The source hasn't changed what buffer it's playing |
1576 | bufferp->mLastUseTimer.reset(); | 1737 | bufferp->mLastUseTimer.reset(); |
1577 | bufferp->mInUse = TRUE; | 1738 | bufferp->mInUse = true; |
1578 | } | 1739 | } |
1579 | return FALSE; | 1740 | return false; |
1580 | } | 1741 | } |
1581 | 1742 | ||
1582 | // | 1743 | // |
1583 | // 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 |
1584 | // existing fmod channel | 1745 | // the existing channel |
1585 | // | 1746 | // |
1586 | cleanup(); | 1747 | cleanup(); |
1587 | 1748 | ||
@@ -1589,16 +1750,16 @@ BOOL LLAudioChannel::updateBuffer() | |||
1589 | if (bufferp) | 1750 | if (bufferp) |
1590 | { | 1751 | { |
1591 | bufferp->mLastUseTimer.reset(); | 1752 | bufferp->mLastUseTimer.reset(); |
1592 | bufferp->mInUse = TRUE; | 1753 | bufferp->mInUse = true; |
1593 | } | 1754 | } |
1594 | 1755 | ||
1595 | if (!mCurrentBufferp) | 1756 | if (!mCurrentBufferp) |
1596 | { | 1757 | { |
1597 | // 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. |
1598 | return FALSE; | 1759 | return false; |
1599 | } | 1760 | } |
1600 | 1761 | ||
1601 | return TRUE; | 1762 | return true; |
1602 | } | 1763 | } |
1603 | 1764 | ||
1604 | 1765 | ||
@@ -1612,9 +1773,9 @@ BOOL LLAudioChannel::updateBuffer() | |||
1612 | LLAudioData::LLAudioData(const LLUUID &uuid) : | 1773 | LLAudioData::LLAudioData(const LLUUID &uuid) : |
1613 | mID(uuid), | 1774 | mID(uuid), |
1614 | mBufferp(NULL), | 1775 | mBufferp(NULL), |
1615 | mHasLocalData(FALSE), | 1776 | mHasLocalData(false), |
1616 | mHasDecodedData(FALSE), | 1777 | mHasDecodedData(false), |
1617 | mHasValidData(TRUE) | 1778 | mHasValidData(true) |
1618 | { | 1779 | { |
1619 | if (uuid.isNull()) | 1780 | if (uuid.isNull()) |
1620 | { | 1781 | { |
@@ -1625,32 +1786,32 @@ LLAudioData::LLAudioData(const LLUUID &uuid) : | |||
1625 | if (gAudiop && gAudiop->hasDecodedFile(uuid)) | 1786 | if (gAudiop && gAudiop->hasDecodedFile(uuid)) |
1626 | { | 1787 | { |
1627 | // Already have a decoded version, don't need to decode it. | 1788 | // Already have a decoded version, don't need to decode it. |
1628 | mHasLocalData = TRUE; | 1789 | mHasLocalData = true; |
1629 | mHasDecodedData = TRUE; | 1790 | mHasDecodedData = true; |
1630 | } | 1791 | } |
1631 | else if (gAssetStorage && gAssetStorage->hasLocalAsset(uuid, LLAssetType::AT_SOUND)) | 1792 | else if (gAssetStorage && gAssetStorage->hasLocalAsset(uuid, LLAssetType::AT_SOUND)) |
1632 | { | 1793 | { |
1633 | mHasLocalData = TRUE; | 1794 | mHasLocalData = true; |
1634 | } | 1795 | } |
1635 | } | 1796 | } |
1636 | 1797 | ||
1637 | 1798 | ||
1638 | BOOL LLAudioData::load() | 1799 | bool LLAudioData::load() |
1639 | { | 1800 | { |
1640 | // 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. |
1641 | if (mBufferp) | 1802 | if (mBufferp) |
1642 | { | 1803 | { |
1643 | // 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. |
1644 | llinfos << "Already have a buffer for this sound, don't bother loading!" << llendl; | 1805 | LL_INFOS("AudioEngine") << "Already have a buffer for this sound, don't bother loading!" << llendl; |
1645 | return TRUE; | 1806 | return true; |
1646 | } | 1807 | } |
1647 | 1808 | ||
1648 | mBufferp = gAudiop->getFreeBuffer(); | 1809 | mBufferp = gAudiop->getFreeBuffer(); |
1649 | if (!mBufferp) | 1810 | if (!mBufferp) |
1650 | { | 1811 | { |
1651 | // No free buffers, abort. | 1812 | // No free buffers, abort. |
1652 | llinfos << "Not able to allocate a new audio buffer, aborting." << llendl; | 1813 | LL_INFOS("AudioEngine") << "Not able to allocate a new audio buffer, aborting." << llendl; |
1653 | return FALSE; | 1814 | return false; |
1654 | } | 1815 | } |
1655 | 1816 | ||
1656 | std::string uuid_str; | 1817 | std::string uuid_str; |
@@ -1664,10 +1825,10 @@ BOOL LLAudioData::load() | |||
1664 | gAudiop->cleanupBuffer(mBufferp); | 1825 | gAudiop->cleanupBuffer(mBufferp); |
1665 | mBufferp = NULL; | 1826 | mBufferp = NULL; |
1666 | 1827 | ||
1667 | return FALSE; | 1828 | return false; |
1668 | } | 1829 | } |
1669 | mBufferp->mAudioDatap = this; | 1830 | mBufferp->mAudioDatap = this; |
1670 | return TRUE; | 1831 | return true; |
1671 | } | 1832 | } |
1672 | 1833 | ||
1673 | 1834 | ||