aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llaudio
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llaudio')
-rw-r--r--linden/indra/llaudio/CMakeLists.txt3
-rw-r--r--linden/indra/llaudio/audioengine.cpp94
-rw-r--r--linden/indra/llaudio/audioengine.h5
-rw-r--r--linden/indra/llaudio/audioengine_fmod.h2
-rw-r--r--linden/indra/llaudio/audioengine_openal.cpp30
-rw-r--r--linden/indra/llaudio/audioengine_openal.h1
-rw-r--r--linden/indra/llaudio/listener_openal.cpp1
-rw-r--r--linden/indra/llaudio/listener_openal.h3
-rw-r--r--linden/indra/llaudio/llaudiodecodemgr.cpp23
9 files changed, 119 insertions, 43 deletions
diff --git a/linden/indra/llaudio/CMakeLists.txt b/linden/indra/llaudio/CMakeLists.txt
index 235248e..70041e7 100644
--- a/linden/indra/llaudio/CMakeLists.txt
+++ b/linden/indra/llaudio/CMakeLists.txt
@@ -4,6 +4,7 @@ project(llaudio)
4 4
5include(00-Common) 5include(00-Common)
6include(Audio) 6include(Audio)
7include(OPENAL)
7include(FMOD) 8include(FMOD)
8include(OPENAL) 9include(OPENAL)
9include(LLCommon) 10include(LLCommon)
@@ -25,6 +26,7 @@ include_directories(
25 ${OPENAL_LIB_INCLUDE_DIRS} 26 ${OPENAL_LIB_INCLUDE_DIRS}
26 ${FREEAULT_LIB_INCLUDE_DIRS} 27 ${FREEAULT_LIB_INCLUDE_DIRS}
27 ${LLMEDIA_INCLUDE_DIRS} 28 ${LLMEDIA_INCLUDE_DIRS}
29 ${GSTREAMER_INCLUDE_DIRS}
28 ) 30 )
29 31
30set(llaudio_SOURCE_FILES 32set(llaudio_SOURCE_FILES
@@ -83,6 +85,7 @@ set_source_files_properties(${llaudio_HEADER_FILES}
83list(APPEND llaudio_SOURCE_FILES ${llaudio_HEADER_FILES}) 85list(APPEND llaudio_SOURCE_FILES ${llaudio_HEADER_FILES})
84 86
85add_library (llaudio ${llaudio_SOURCE_FILES}) 87add_library (llaudio ${llaudio_SOURCE_FILES})
88
86target_link_libraries( 89target_link_libraries(
87 llaudio 90 llaudio
88 ${VORBISENC_LIBRARIES} 91 ${VORBISENC_LIBRARIES}
diff --git a/linden/indra/llaudio/audioengine.cpp b/linden/indra/llaudio/audioengine.cpp
index c5bc367..dd0ffff 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 mInternetStreamMedia = NULL; 104 mInternetStreamMedia = NULL;
103 mInternetStreamURL.clear(); 105 mInternetStreamURL.clear();
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{
@@ -184,31 +196,51 @@ void LLAudioEngine::startInternetStream(const std::string& url)
184 } 196 }
185 197
186 if(!mInternetStreamMedia) 198 if(!mInternetStreamMedia)
199 {
187 return; 200 return;
188 201 }
189 if (!url.empty()) { 202 // Check for a dead stream from gstreamer, just in case
190 llinfos << "Starting internet stream: " << url << llendl; 203 else if(getStatus() == LLMediaBase::STATUS_DEAD)
191 mInternetStreamURL = url; 204 {
192 mInternetStreamMedia->navigateTo ( url ); 205 llinfos << "don't play dead stream urls"<< llendl;
193 llinfos << "Playing....." << llendl; 206 mInternetStreamURL.clear();
194 mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_START); 207 mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_STOP);
195 mInternetStreamMedia->updateMedia(); 208 mInternetStreamMedia->updateMedia();
196 } else { 209 stopInternetStream();
197 llinfos << "setting stream to NULL"<< llendl; 210 }
211 else if (url.empty())
212 {
213 llinfos << "url is emptly. Setting stream to NULL"<< llendl;
198 mInternetStreamURL.clear(); 214 mInternetStreamURL.clear();
199 mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_STOP); 215 mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_STOP);
200 mInternetStreamMedia->updateMedia(); 216 mInternetStreamMedia->updateMedia();
201 } 217 }
218 // Stream appears to be good, attempting to play
219 else
220 {
221 // stop any other stream first
222 stopInternetStream();
223
224 llinfos << "Starting internet stream: " << url << llendl;
225 mInternetStreamURL = url;
226 mInternetStreamMedia->navigateTo(url);
227 //llinfos << "Playing....." << llendl;
228 mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_START);
229 mInternetStreamMedia->updateMedia();
230 mStatus = LLMediaBase::STATUS_STARTED;
231 }
202} 232}
203 233
204// virtual 234// virtual
205void LLAudioEngine::stopInternetStream() 235void LLAudioEngine::stopInternetStream()
206{ 236{
207 llinfos << "entered stopInternetStream()" << llendl; 237 llinfos << "entered stopInternetStream()" << llendl;
208 238 mInternetStreamURL.clear();
209 if(mInternetStreamMedia) 239
240 if(mInternetStreamMedia)
210 { 241 {
211 if( ! mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_STOP)){ 242 if(!mInternetStreamMedia->addCommand(LLMediaBase::COMMAND_STOP))
243 {
212 llinfos << "attempting to stop stream failed!" << llendl; 244 llinfos << "attempting to stop stream failed!" << llendl;
213 } 245 }
214 mInternetStreamMedia->updateMedia(); 246 mInternetStreamMedia->updateMedia();
@@ -300,6 +332,13 @@ void LLAudioEngine::updateChannels()
300 { 332 {
301 if (mChannels[i]) 333 if (mChannels[i])
302 { 334 {
335 // set secondary gain if type is available
336 LLAudioSource* source = mChannels[i]->getSource();
337 if (source)
338 {
339 mChannels[i]->setSecondaryGain(mSecondaryGain[source->getType()]);
340 }
341
303 mChannels[i]->updateBuffer(); 342 mChannels[i]->updateBuffer();
304 mChannels[i]->update3DPosition(); 343 mChannels[i]->update3DPosition();
305 mChannels[i]->updateLoop(); 344 mChannels[i]->updateLoop();
@@ -378,7 +417,7 @@ void LLAudioEngine::idle(F32 max_decode_time)
378 LLAudioChannel *channelp = getFreeChannel(max_priority); 417 LLAudioChannel *channelp = getFreeChannel(max_priority);
379 if (channelp) 418 if (channelp)
380 { 419 {
381 //llinfos << "Replacing source in channel due to priority!" << llendl; 420 //LL_INFOS("AudioEngine") << "Replacing source in channel due to priority!" << llendl;
382 max_sourcep->setChannel(channelp); 421 max_sourcep->setChannel(channelp);
383 channelp->setSource(max_sourcep); 422 channelp->setSource(max_sourcep);
384 if (max_sourcep->isSyncSlave()) 423 if (max_sourcep->isSyncSlave())
@@ -545,7 +584,7 @@ void LLAudioEngine::idle(F32 max_decode_time)
545 { 584 {
546 if (!mBuffers[i]->mInUse && mBuffers[i]->mLastUseTimer.getElapsedTimeF32() > 30.f) 585 if (!mBuffers[i]->mInUse && mBuffers[i]->mLastUseTimer.getElapsedTimeF32() > 30.f)
547 { 586 {
548 //llinfos << "Flushing unused buffer!" << llendl; 587 //LL_INFOS("AudioEngine") << "Flushing unused buffer!" << llendl;
549 mBuffers[i]->mAudioDatap->mBufferp = NULL; 588 mBuffers[i]->mAudioDatap->mBufferp = NULL;
550 delete mBuffers[i]; 589 delete mBuffers[i];
551 mBuffers[i] = NULL; 590 mBuffers[i] = NULL;
@@ -658,8 +697,8 @@ LLAudioBuffer *LLAudioEngine::getFreeBuffer()
658 697
659 if (buffer_id >= 0) 698 if (buffer_id >= 0)
660 { 699 {
661 llinfos << "Taking over unused buffer " << buffer_id << llendl; 700 LL_INFOS("AudioEngine") << "Taking over unused buffer " << buffer_id << llendl;
662 //llinfos << "Flushing unused buffer!" << llendl; 701 //LL_INFOS("AudioEngine") << "Flushing unused buffer!" << llendl;
663 mBuffers[buffer_id]->mAudioDatap->mBufferp = NULL; 702 mBuffers[buffer_id]->mAudioDatap->mBufferp = NULL;
664 delete mBuffers[buffer_id]; 703 delete mBuffers[buffer_id];
665 mBuffers[buffer_id] = createBuffer(); 704 mBuffers[buffer_id] = createBuffer();
@@ -871,9 +910,10 @@ void LLAudioEngine::triggerSound(const LLUUID &audio_uuid, const LLUUID& owner_i
871 const S32 type, const LLVector3d &pos_global) 910 const S32 type, const LLVector3d &pos_global)
872{ 911{
873 // Create a new source (since this can't be associated with an existing source. 912 // Create a new source (since this can't be associated with an existing source.
874 //llinfos << "Localized: " << audio_uuid << llendl; 913 //LL_INFOS("AudioEngine") << "Localized: " << audio_uuid << llendl;
875 914
876 if (mMuted) 915 //If we cannot hear it, dont even try to load the sound.
916 if (mMuted || gain == 0.0)
877 { 917 {
878 return; 918 return;
879 } 919 }
@@ -1093,10 +1133,10 @@ bool LLAudioEngine::hasLocalFile(const LLUUID &uuid)
1093 1133
1094void LLAudioEngine::startNextTransfer() 1134void LLAudioEngine::startNextTransfer()
1095{ 1135{
1096 //llinfos << "LLAudioEngine::startNextTransfer()" << llendl; 1136 //LL_INFOS("AudioEngine") << "LLAudioEngine::startNextTransfer()" << llendl;
1097 if (mCurrentTransfer.notNull() || getMuted()) 1137 if (mCurrentTransfer.notNull() || getMuted())
1098 { 1138 {
1099 //llinfos << "Transfer in progress, aborting" << llendl; 1139 //LL_INFOS("AudioEngine") << "Transfer in progress, aborting" << llendl;
1100 return; 1140 return;
1101 } 1141 }
1102 1142
@@ -1277,7 +1317,7 @@ void LLAudioEngine::startNextTransfer()
1277 1317
1278 if (asset_id.notNull()) 1318 if (asset_id.notNull())
1279 { 1319 {
1280 llinfos << "Getting asset data for: " << asset_id << llendl; 1320 LL_INFOS("AudioEngine") << "Getting asset data for: " << asset_id << llendl;
1281 gAudiop->mCurrentTransfer = asset_id; 1321 gAudiop->mCurrentTransfer = asset_id;
1282 gAudiop->mCurrentTransferTimer.reset(); 1322 gAudiop->mCurrentTransferTimer.reset();
1283 gAssetStorage->getAssetData(asset_id, LLAssetType::AT_SOUND, 1323 gAssetStorage->getAssetData(asset_id, LLAssetType::AT_SOUND,
@@ -1285,7 +1325,7 @@ void LLAudioEngine::startNextTransfer()
1285 } 1325 }
1286 else 1326 else
1287 { 1327 {
1288 //llinfos << "No pending transfers?" << llendl; 1328 //LL_INFOS("AudioEngine") << "No pending transfers?" << llendl;
1289 } 1329 }
1290} 1330}
1291 1331
@@ -1295,7 +1335,7 @@ void LLAudioEngine::assetCallback(LLVFS *vfs, const LLUUID &uuid, LLAssetType::E
1295{ 1335{
1296 if (result_code) 1336 if (result_code)
1297 { 1337 {
1298 llinfos << "Boom, error in audio file transfer: " << LLAssetStorage::getErrorString( result_code ) << " (" << result_code << ")" << llendl; 1338 LL_INFOS("AudioEngine") << "Boom, error in audio file transfer: " << LLAssetStorage::getErrorString( result_code ) << " (" << result_code << ")" << llendl;
1299 // Need to mark data as bad to avoid constant rerequests. 1339 // Need to mark data as bad to avoid constant rerequests.
1300 LLAudioData *adp = gAudiop->getAudioData(uuid); 1340 LLAudioData *adp = gAudiop->getAudioData(uuid);
1301 if (adp) 1341 if (adp)
@@ -1676,7 +1716,7 @@ LLAudioChannel::LLAudioChannel() :
1676LLAudioChannel::~LLAudioChannel() 1716LLAudioChannel::~LLAudioChannel()
1677{ 1717{
1678 // Need to disconnect any sources which are using this channel. 1718 // Need to disconnect any sources which are using this channel.
1679 //llinfos << "Cleaning up audio channel" << llendl; 1719 //LL_INFOS("AudioEngine") << "Cleaning up audio channel" << llendl;
1680 if (mCurrentSourcep) 1720 if (mCurrentSourcep)
1681 { 1721 {
1682 mCurrentSourcep->setChannel(NULL); 1722 mCurrentSourcep->setChannel(NULL);
@@ -1687,12 +1727,12 @@ LLAudioChannel::~LLAudioChannel()
1687 1727
1688void LLAudioChannel::setSource(LLAudioSource *sourcep) 1728void LLAudioChannel::setSource(LLAudioSource *sourcep)
1689{ 1729{
1690 //llinfos << this << ": setSource(" << sourcep << ")" << llendl; 1730 //LL_INFOS("AudioEngine") << this << ": setSource(" << sourcep << ")" << llendl;
1691 1731
1692 if (!sourcep) 1732 if (!sourcep)
1693 { 1733 {
1694 // Clearing the source for this channel, don't need to do anything. 1734 // Clearing the source for this channel, don't need to do anything.
1695 //llinfos << "Clearing source for channel" << llendl; 1735 //LL_INFOS("AudioEngine") << "Clearing source for channel" << llendl;
1696 cleanup(); 1736 cleanup();
1697 mCurrentSourcep = NULL; 1737 mCurrentSourcep = NULL;
1698 mWaiting = false; 1738 mWaiting = false;
@@ -1702,7 +1742,7 @@ void LLAudioChannel::setSource(LLAudioSource *sourcep)
1702 if (sourcep == mCurrentSourcep) 1742 if (sourcep == mCurrentSourcep)
1703 { 1743 {
1704 // Don't reallocate the channel, this will make FMOD goofy. 1744 // Don't reallocate the channel, this will make FMOD goofy.
1705 //llinfos << "Calling setSource with same source!" << llendl; 1745 //LL_INFOS("AudioEngine") << "Calling setSource with same source!" << llendl;
1706 } 1746 }
1707 1747
1708 mCurrentSourcep = sourcep; 1748 mCurrentSourcep = sourcep;
diff --git a/linden/indra/llaudio/audioengine.h b/linden/indra/llaudio/audioengine.h
index b582f14..d289ba5 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;
@@ -160,6 +162,7 @@ public:
160 // use a value from 0.0 to 1.0, inclusive 162 // use a value from 0.0 to 1.0, inclusive
161 virtual void setInternetStreamGain(F32 vol); 163 virtual void setInternetStreamGain(F32 vol);
162 virtual const std::string& getInternetStreamURL(); 164 virtual const std::string& getInternetStreamURL();
165 virtual LLMediaBase::EStatus getStatus();
163 166
164 // For debugging usage 167 // For debugging usage
165 virtual LLVector3 getListenerPos(); 168 virtual LLVector3 getListenerPos();
@@ -246,6 +249,8 @@ protected:
246 249
247 LLFrameTimer mWindUpdateTimer; 250 LLFrameTimer mWindUpdateTimer;
248 251
252 LLMediaBase::EStatus mStatus;
253
249private: 254private:
250 void setDefaults(); 255 void setDefaults();
251 LLMediaBase *mInternetStreamMedia; 256 LLMediaBase *mInternetStreamMedia;
diff --git a/linden/indra/llaudio/audioengine_fmod.h b/linden/indra/llaudio/audioengine_fmod.h
index 4d2cbce..60f75b9 100644
--- a/linden/indra/llaudio/audioengine_fmod.h
+++ b/linden/indra/llaudio/audioengine_fmod.h
@@ -49,7 +49,7 @@ public:
49 49
50 // initialization/startup/shutdown 50 // initialization/startup/shutdown
51 virtual bool init(const S32 num_channels, void *user_data); 51 virtual bool init(const S32 num_channels, void *user_data);
52 virtual std::string getDriverName(bool verbose); 52 virtual std::string getDriverName(bool verbose);
53 virtual void allocateListener(); 53 virtual void allocateListener();
54 54
55 virtual void shutdown(); 55 virtual void shutdown();
diff --git a/linden/indra/llaudio/audioengine_openal.cpp b/linden/indra/llaudio/audioengine_openal.cpp
index b33e0b0..a14b725 100644
--- a/linden/indra/llaudio/audioengine_openal.cpp
+++ b/linden/indra/llaudio/audioengine_openal.cpp
@@ -54,15 +54,41 @@ LLAudioEngine_OpenAL::~LLAudioEngine_OpenAL()
54{ 54{
55} 55}
56 56
57static ALboolean alutInitHelp(const char **errorstring)
58{
59 ALboolean result = AL_FALSE;
60 ALenum err = AL_NO_ERROR;
61#if LL_WINDOWS
62 __try {
63 result = alutInit(NULL, NULL);
64 err = alutGetError();
65 alGetError(); // hit loading of wrap_oal.dll
66 if(!result) *errorstring = alutGetErrorString(err);
67 } __except( EXCEPTION_EXECUTE_HANDLER ) {
68 *errorstring = "[Exception]";
69 result = AL_FALSE;
70 }
71 return result;
72#else
73 result = alutInit(NULL, NULL);
74 if(!result) {
75 err = alutGetError();
76 *errorstring = alutGetErrorString(err);
77 }
78 return result;
79#endif
80}
81
57// virtual 82// virtual
58bool LLAudioEngine_OpenAL::init(const S32 num_channels, void* userdata) 83bool LLAudioEngine_OpenAL::init(const S32 num_channels, void* userdata)
59{ 84{
85 const char *errorstring = "(null)";
60 mWindGen = NULL; 86 mWindGen = NULL;
61 LLAudioEngine::init(num_channels, userdata); 87 LLAudioEngine::init(num_channels, userdata);
62 88
63 if(!alutInit(NULL, NULL)) 89 if(!alutInitHelp(&errorstring))
64 { 90 {
65 llwarns << "LLAudioEngine_OpenAL::init() ALUT initialization failed: " << alutGetErrorString (alutGetError ()) << llendl; 91 llwarns << "LLAudioEngine_OpenAL::init() ALUT initialization failed: " << errorstring << llendl;
66 return false; 92 return false;
67 } 93 }
68 94
diff --git a/linden/indra/llaudio/audioengine_openal.h b/linden/indra/llaudio/audioengine_openal.h
index 54b60e6..5ccdcb7 100644
--- a/linden/indra/llaudio/audioengine_openal.h
+++ b/linden/indra/llaudio/audioengine_openal.h
@@ -39,6 +39,7 @@
39#include "listener_openal.h" 39#include "listener_openal.h"
40#include "windgen.h" 40#include "windgen.h"
41 41
42
42class LLAudioEngine_OpenAL : public LLAudioEngine 43class LLAudioEngine_OpenAL : public LLAudioEngine
43{ 44{
44 public: 45 public:
diff --git a/linden/indra/llaudio/listener_openal.cpp b/linden/indra/llaudio/listener_openal.cpp
index 718de63..a164242 100644
--- a/linden/indra/llaudio/listener_openal.cpp
+++ b/linden/indra/llaudio/listener_openal.cpp
@@ -122,4 +122,3 @@ F32 LLListener_OpenAL::getDistanceFactor()
122{ 122{
123 return mDistanceFactor; 123 return mDistanceFactor;
124} 124}
125
diff --git a/linden/indra/llaudio/listener_openal.h b/linden/indra/llaudio/listener_openal.h
index 3e4353f..6f71a02 100644
--- a/linden/indra/llaudio/listener_openal.h
+++ b/linden/indra/llaudio/listener_openal.h
@@ -35,7 +35,8 @@
35 35
36#include "listener.h" 36#include "listener.h"
37 37
38#include "AL/al.h" 38
39//#include "AL/al.h"
39#include "AL/alut.h" 40#include "AL/alut.h"
40 41
41class LLListener_OpenAL : public LLListener 42class LLListener_OpenAL : public LLListener
diff --git a/linden/indra/llaudio/llaudiodecodemgr.cpp b/linden/indra/llaudio/llaudiodecodemgr.cpp
index 0515648..c984e1f 100644
--- a/linden/indra/llaudio/llaudiodecodemgr.cpp
+++ b/linden/indra/llaudio/llaudiodecodemgr.cpp
@@ -374,16 +374,16 @@ BOOL LLVorbisDecodeState::finishDecode()
374 374
375 // write "data" chunk length, in little-endian format 375 // write "data" chunk length, in little-endian format
376 S32 data_length = mWAVBuffer.size() - WAV_HEADER_SIZE; 376 S32 data_length = mWAVBuffer.size() - WAV_HEADER_SIZE;
377 mWAVBuffer[40] = (data_length) & 0x000000FF; 377 mWAVBuffer[40] = (data_length - 8) & 0x000000FF;
378 mWAVBuffer[41] = (data_length >> 8) & 0x000000FF; 378 mWAVBuffer[41] = ((data_length - 8)>> 8) & 0x000000FF;
379 mWAVBuffer[42] = (data_length >> 16) & 0x000000FF; 379 mWAVBuffer[42] = ((data_length - 8)>> 16) & 0x000000FF;
380 mWAVBuffer[43] = (data_length >> 24) & 0x000000FF; 380 mWAVBuffer[43] = ((data_length - 8)>> 24) & 0x000000FF;
381
381 // write overall "RIFF" length, in little-endian format 382 // write overall "RIFF" length, in little-endian format
382 data_length += 36; 383 mWAVBuffer[4] = (data_length + 28) & 0x000000FF;
383 mWAVBuffer[4] = (data_length) & 0x000000FF; 384 mWAVBuffer[5] = ((data_length + 28) >> 8) & 0x000000FF;
384 mWAVBuffer[5] = (data_length >> 8) & 0x000000FF; 385 mWAVBuffer[6] = ((data_length + 28) >> 16) & 0x000000FF;
385 mWAVBuffer[6] = (data_length >> 16) & 0x000000FF; 386 mWAVBuffer[7] = ((data_length + 28) >> 24) & 0x000000FF;
386 mWAVBuffer[7] = (data_length >> 24) & 0x000000FF;
387 387
388 // 388 //
389 // FUDGECAKES!!! Vorbis encode/decode messes up loop point transitions (pop) 389 // FUDGECAKES!!! Vorbis encode/decode messes up loop point transitions (pop)
@@ -395,7 +395,8 @@ BOOL LLVorbisDecodeState::finishDecode()
395 S32 fade_length; 395 S32 fade_length;
396 char pcmout[4096]; /*Flawfinder: ignore*/ 396 char pcmout[4096]; /*Flawfinder: ignore*/
397 397
398 fade_length = llmin((S32)128,(S32)(data_length-36)/8); 398 fade_length = llmin((S32)128,(S32)(data_length)/8);
399
399 if((S32)mWAVBuffer.size() >= (WAV_HEADER_SIZE + 2* fade_length)) 400 if((S32)mWAVBuffer.size() >= (WAV_HEADER_SIZE + 2* fade_length))
400 { 401 {
401 memcpy(pcmout, &mWAVBuffer[WAV_HEADER_SIZE], (2 * fade_length)); /*Flawfinder: ignore*/ 402 memcpy(pcmout, &mWAVBuffer[WAV_HEADER_SIZE], (2 * fade_length)); /*Flawfinder: ignore*/
@@ -435,7 +436,7 @@ BOOL LLVorbisDecodeState::finishDecode()
435 } 436 }
436 } 437 }
437 438
438 if (36 == data_length) 439 if (0 == data_length)
439 { 440 {
440 llwarns << "BAD Vorbis decode in finishDecode!" << llendl; 441 llwarns << "BAD Vorbis decode in finishDecode!" << llendl;
441 mValid = FALSE; 442 mValid = FALSE;