diff --git a/indra/llaudio/llaudiodecodemgr.cpp b/indra/llaudio/llaudiodecodemgr.cpp index b80ce5306..908eca5a6 100644 --- a/indra/llaudio/llaudiodecodemgr.cpp +++ b/indra/llaudio/llaudiodecodemgr.cpp @@ -222,31 +222,61 @@ BOOL LLVorbisDecodeState::initDecode() S32 sample_count = ov_pcm_total(&mVF, -1); size_t size_guess = (size_t)sample_count; vorbis_info* vi = ov_info(&mVF, -1); - size_guess *= vi->channels; + size_guess *= (vi? vi->channels : 1); size_guess *= 2; size_guess += 2048; bool abort_decode = false; + + if (vi) + { + if( vi->channels < 1 || vi->channels > LLVORBIS_CLIP_MAX_CHANNELS ) + { + abort_decode = true; + llwarns << "Bad channel count: " << vi->channels << llendl; + } + } + else // !vi + { + abort_decode = true; + llwarns << "No default bitstream found" << llendl; + } // - // This magic value is equivilent to 150MiB of data. - // Prevents griffers from utilizin a huge xbox sound the size of god to instafry the viewer + // This magic value is equivilent to 150MiB of data. + // Prevents griffers from utilizin a huge xbox sound the size of god to instafry the viewer if(size_guess >= 157286400) { llwarns << "Bad sound caught by zmagic" << llendl; abort_decode = true; } - - else /* */if( vi->channels < 1 || vi->channels > LLVORBIS_CLIP_MAX_CHANNELS ) + else + { + // + //Much more restrictive than zmagic. Perhaps make toggleable. + if( (size_t)sample_count > LLVORBIS_CLIP_REJECT_SAMPLES || + (size_t)sample_count <= 0) { abort_decode = true; - llwarns << "Bad channel count: " << vi->channels << llendl; + llwarns << "Illegal sample count: " << sample_count << llendl; } - + if( size_guess > LLVORBIS_CLIP_REJECT_SIZE || + size_guess < 0) + { + abort_decode = true; + llwarns << "Illegal sample size: " << size_guess << llendl; + } + // + } + // if( abort_decode ) { llwarns << "Canceling initDecode. Bad asset: " << mUUID << llendl; - llwarns << "Bad asset encoded by: " << ov_comment(&mVF,-1)->vendor << llendl; + vorbis_comment* comment = ov_comment(&mVF,-1); + if (comment && comment->vendor) + { + llwarns << "Bad asset encoded by: " << comment->vendor << llendl; + } delete mInFilep; mInFilep = NULL; return FALSE; diff --git a/indra/llaudio/llaudioengine.cpp b/indra/llaudio/llaudioengine.cpp index 36ab23d7a..b61d934dd 100644 --- a/indra/llaudio/llaudioengine.cpp +++ b/indra/llaudio/llaudioengine.cpp @@ -104,7 +104,11 @@ void LLAudioEngine::setDefaults() } mMasterGain = 1.f; - mInternalGain = 0.f; + // Setting mInternalGain to an out of range value fixes the issue reported in STORM-830. + // There is an edge case in setMasterGain during startup which prevents setInternalGain from + // being called if the master volume setting and mInternalGain both equal 0, so using -1 forces + // the if statement in setMasterGain to execute when the viewer starts up. + mInternalGain = -1.f; mNextWindUpdate = 0.f; mStreamingAudioImpl = NULL; @@ -204,12 +208,12 @@ void LLAudioEngine::updateInternetStream() } // virtual -int LLAudioEngine::isInternetStreamPlaying() +LLAudioEngine::LLAudioPlayState LLAudioEngine::isInternetStreamPlaying() { if (mStreamingAudioImpl) - return mStreamingAudioImpl->isPlaying(); + return (LLAudioEngine::LLAudioPlayState) mStreamingAudioImpl->isPlaying(); - return 0; // Stopped + return LLAudioEngine::AUDIO_STOPPED; // Stopped } @@ -594,7 +598,7 @@ LLAudioBuffer * LLAudioEngine::getFreeBuffer() if (buffer_id >= 0) { - llinfos << "Taking over unused buffer " << buffer_id << llendl; + lldebugs << "Taking over unused buffer " << buffer_id << llendl; //llinfos << "Flushing unused buffer!" << llendl; mBuffers[buffer_id]->mAudioDatap->mBufferp = NULL; delete mBuffers[buffer_id]; @@ -1627,6 +1631,10 @@ bool LLAudioSource::hasPendingPreloads() const LLAudioData *adp = iter->second; // note: a bad UUID will forever be !hasDecodedData() // but also !hasValidData(), hence the check for hasValidData() + if (!adp) + { + continue; + } if (!adp->hasDecodedData() && adp->hasValidData()) { // This source is still waiting for a preload diff --git a/indra/llaudio/llaudioengine.h b/indra/llaudio/llaudioengine.h index fa323607b..4d5d919e1 100644 --- a/indra/llaudio/llaudioengine.h +++ b/indra/llaudio/llaudioengine.h @@ -91,6 +91,15 @@ public: AUDIO_TYPE_COUNT = 4 // last }; + enum LLAudioPlayState + { + // isInternetStreamPlaying() returns an *int*, with + // 0 = stopped, 1 = playing, 2 = paused. + AUDIO_STOPPED = 0, + AUDIO_PLAYING = 1, + AUDIO_PAUSED = 2 + }; + LLAudioEngine(); virtual ~LLAudioEngine(); @@ -161,7 +170,7 @@ public: void stopInternetStream(); void pauseInternetStream(int pause); void updateInternetStream(); // expected to be called often - int isInternetStreamPlaying(); + LLAudioPlayState isInternetStreamPlaying(); // use a value from 0.0 to 1.0, inclusive void setInternetStreamGain(F32 vol); std::string getInternetStreamURL(); diff --git a/indra/llaudio/llaudioengine_fmod.cpp b/indra/llaudio/llaudioengine_fmod.cpp index 3c6573e74..8d3f70f89 100644 --- a/indra/llaudio/llaudioengine_fmod.cpp +++ b/indra/llaudio/llaudioengine_fmod.cpp @@ -131,6 +131,7 @@ bool LLAudioEngine_FMOD::init(const S32 num_channels, void* userdata) bool audio_ok = false; if (!audio_ok) + { if (NULL == getenv("LL_BAD_FMOD_ESD")) /*Flawfinder: ignore*/ { LL_DEBUGS("AppInit") << "Trying ESD audio output..." << LL_ENDL; @@ -147,8 +148,9 @@ bool LLAudioEngine_FMOD::init(const S32 num_channels, void* userdata) } else { LL_DEBUGS("AppInit") << "ESD audio output SKIPPED" << LL_ENDL; } - + } if (!audio_ok) + { if (NULL == getenv("LL_BAD_FMOD_OSS")) /*Flawfinder: ignore*/ { LL_DEBUGS("AppInit") << "Trying OSS audio output..." << LL_ENDL; @@ -164,8 +166,9 @@ bool LLAudioEngine_FMOD::init(const S32 num_channels, void* userdata) } else { LL_DEBUGS("AppInit") << "OSS audio output SKIPPED" << LL_ENDL; } - + } if (!audio_ok) + { if (NULL == getenv("LL_BAD_FMOD_ALSA")) /*Flawfinder: ignore*/ { LL_DEBUGS("AppInit") << "Trying ALSA audio output..." << LL_ENDL; @@ -181,7 +184,7 @@ bool LLAudioEngine_FMOD::init(const S32 num_channels, void* userdata) } else { LL_DEBUGS("AppInit") << "OSS audio output SKIPPED" << LL_ENDL; } - + } if (!audio_ok) { LL_WARNS("AppInit") << "Overall audio init failure." << LL_ENDL; diff --git a/indra/llaudio/llstreamingaudio_fmod.cpp b/indra/llaudio/llstreamingaudio_fmod.cpp index a71a87203..fe9468856 100644 --- a/indra/llaudio/llstreamingaudio_fmod.cpp +++ b/indra/llaudio/llstreamingaudio_fmod.cpp @@ -174,7 +174,7 @@ void LLStreamingAudio_FMOD::update() break; case -3: // failed to open, file not found, perhaps - llwarns << "InternetSteam - failed to open" << llendl; + llwarns << "InternetStream - failed to open" << llendl; stop(); return; case -4: @@ -271,7 +271,7 @@ void LLStreamingAudio_FMOD::setGain(F32 vol) if (mFMODInternetStreamChannel != -1) { - vol = llclamp(vol, 0.f, 1.f); + vol = llclamp(vol * vol, 0.f, 1.f); int vol_int = llround(vol * 255.f); FSOUND_SetVolumeAbsolute(mFMODInternetStreamChannel, vol_int); } diff --git a/indra/llaudio/llvorbisencode.cpp b/indra/llaudio/llvorbisencode.cpp index a24394da1..443b57698 100644 --- a/indra/llaudio/llvorbisencode.cpp +++ b/indra/llaudio/llvorbisencode.cpp @@ -126,6 +126,13 @@ S32 check_for_invalid_wav_formats(const std::string& in_fname, std::string& erro + ((U32) wav_header[5] << 8) + wav_header[4]; + if (chunk_length > physical_file_size - file_pos - 4) + { + infile.close(); + error_msg = "SoundFileInvalidChunkSize"; + return(LLVORBISENC_CHUNK_SIZE_ERR); + } + // llinfos << "chunk found: '" << wav_header[0] << wav_header[1] << wav_header[2] << wav_header[3] << "'" << llendl; if (!(strncmp((char *)&(wav_header[0]),"fmt ",4))) diff --git a/indra/llaudio/llvorbisencode.h b/indra/llaudio/llvorbisencode.h index 2825a301e..0828073d7 100644 --- a/indra/llaudio/llvorbisencode.h +++ b/indra/llaudio/llvorbisencode.h @@ -44,6 +44,7 @@ const S32 LLVORBISENC_MULTICHANNEL_ERR = 7; // can't do stereo const S32 LLVORBISENC_UNSUPPORTED_SAMPLE_RATE = 8; // unsupported sample rate const S32 LLVORBISENC_UNSUPPORTED_WORD_SIZE = 9; // unsupported word size const S32 LLVORBISENC_CLIP_TOO_LONG = 10; // source file is too long +const S32 LLVORBISENC_CHUNK_SIZE_ERR = 11; // chunk size is wrong const F32 LLVORBIS_CLIP_MAX_TIME = 10.0f; const U8 LLVORBIS_CLIP_MAX_CHANNELS = 2; diff --git a/indra/llaudio/llwindgen.h b/indra/llaudio/llwindgen.h index 1908b2545..0e6d0aa2c 100644 --- a/indra/llaudio/llwindgen.h +++ b/indra/llaudio/llwindgen.h @@ -52,7 +52,8 @@ public: mY1(0.0f), mCurrentGain(0.f), mCurrentFreq(100.f), - mCurrentPanGainR(0.5f) + mCurrentPanGainR(0.5f), + mLastSample(0.f) { mSamplePeriod = (F32)mSubSamples / (F32)mInputSamplingRate; mB2 = expf(-F_TWO_PI * mFilterBandWidth * mSamplePeriod); diff --git a/indra/newview/skins/default/xui/en-us/notifications.xml b/indra/newview/skins/default/xui/en-us/notifications.xml index 85daad8a5..ba4d59c41 100644 --- a/indra/newview/skins/default/xui/en-us/notifications.xml +++ b/indra/newview/skins/default/xui/en-us/notifications.xml @@ -1454,6 +1454,14 @@ Could not find 'data' chunk in WAV header: [FILE] + +Wrong chunk size in WAV file: +[FILE] + +