aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llaudio/llaudiodecodemgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/llaudio/llaudiodecodemgr.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/linden/indra/llaudio/llaudiodecodemgr.cpp b/linden/indra/llaudio/llaudiodecodemgr.cpp
index 7cd48a9..cfd0500 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;