summaryrefslogtreecommitdiff
path: root/indra/llaudio
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llaudio')
-rw-r--r--indra/llaudio/CMakeLists.txt6
-rw-r--r--indra/llaudio/llaudiodecodemgr.cpp10
-rw-r--r--indra/llaudio/llaudioengine.cpp81
-rw-r--r--indra/llaudio/llaudioengine.h9
-rw-r--r--indra/llaudio/llaudioengine_openal.cpp2
-rw-r--r--indra/llaudio/llaudioengine_openal.h2
-rw-r--r--indra/llaudio/llvorbisencode.cpp7
-rw-r--r--indra/llaudio/llvorbisencode.h1
8 files changed, 86 insertions, 32 deletions
diff --git a/indra/llaudio/CMakeLists.txt b/indra/llaudio/CMakeLists.txt
index e869b9717c..632e5d46e3 100644
--- a/indra/llaudio/CMakeLists.txt
+++ b/indra/llaudio/CMakeLists.txt
@@ -14,7 +14,6 @@ include(LLVFS)
include_directories(
${LLAUDIO_INCLUDE_DIRS}
- ${FMOD_INCLUDE_DIR}
${LLCOMMON_INCLUDE_DIRS}
${LLMATH_INCLUDE_DIRS}
${LLMESSAGE_INCLUDE_DIRS}
@@ -25,6 +24,7 @@ include_directories(
${VORBIS_INCLUDE_DIRS}
${OPENAL_LIB_INCLUDE_DIRS}
${FREEAULT_LIB_INCLUDE_DIRS}
+ ${FMOD_INCLUDE_DIR}
)
set(llaudio_SOURCE_FILES
@@ -45,6 +45,10 @@ set(llaudio_HEADER_FILES
)
if (FMOD)
+ include_directories(
+ ${FMOD_INCLUDE_DIR}
+ )
+
list(APPEND llaudio_SOURCE_FILES
llaudioengine_fmod.cpp
lllistener_fmod.cpp
diff --git a/indra/llaudio/llaudiodecodemgr.cpp b/indra/llaudio/llaudiodecodemgr.cpp
index c82f194ff4..f0b44f97d2 100644
--- a/indra/llaudio/llaudiodecodemgr.cpp
+++ b/indra/llaudio/llaudiodecodemgr.cpp
@@ -218,7 +218,7 @@ 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;
@@ -680,4 +680,10 @@ BOOL LLAudioDecodeMgr::addDecodeRequest(const LLUUID &uuid)
return FALSE;
}
-
+#if LL_DARWIN || LL_LINUX
+// HACK: to fool the compiler into not emitting unused warnings.
+namespace {
+ const ov_callbacks callback_array[4] = {OV_CALLBACKS_DEFAULT, OV_CALLBACKS_NOCLOSE, OV_CALLBACKS_STREAMONLY,
+ OV_CALLBACKS_STREAMONLY_NOCLOSE};
+}
+#endif
diff --git a/indra/llaudio/llaudioengine.cpp b/indra/llaudio/llaudioengine.cpp
index 8843acc891..5e540ad8c5 100644
--- a/indra/llaudio/llaudioengine.cpp
+++ b/indra/llaudio/llaudioengine.cpp
@@ -97,6 +97,11 @@ void LLAudioEngine::setDefaults()
}
mMasterGain = 1.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;
@@ -247,15 +252,6 @@ void LLAudioEngine::idle(F32 max_decode_time)
// Primarily does position updating, cleanup of unused audio sources.
// Also does regeneration of the current priority of each audio source.
- if (getMuted())
- {
- setInternalGain(0.f);
- }
- else
- {
- setInternalGain(getMasterGain());
- }
-
S32 i;
for (i = 0; i < MAX_BUFFERS; i++)
{
@@ -284,6 +280,12 @@ void LLAudioEngine::idle(F32 max_decode_time)
continue;
}
+ if (sourcep->isMuted())
+ {
+ ++iter;
+ continue;
+ }
+
if (!sourcep->getChannel() && sourcep->getCurrentBuffer())
{
// We could potentially play this sound if its priority is high enough.
@@ -336,9 +338,9 @@ void LLAudioEngine::idle(F32 max_decode_time)
// attached to each channel, since only those with active channels
// can have anything interesting happen with their queue? (Maybe not true)
LLAudioSource *sourcep = iter->second;
- if (!sourcep->mQueuedDatap)
+ if (!sourcep->mQueuedDatap || sourcep->isMuted())
{
- // Nothing queued, so we don't care.
+ // Muted, or nothing queued, so we don't care.
continue;
}
@@ -418,6 +420,10 @@ void LLAudioEngine::idle(F32 max_decode_time)
for (iter = mAllSources.begin(); iter != mAllSources.end(); ++iter)
{
LLAudioSource *sourcep = iter->second;
+ if (sourcep->isMuted())
+ {
+ continue;
+ }
if (sourcep->isSyncMaster())
{
if (sourcep->getPriority() > max_sm_priority)
@@ -691,15 +697,23 @@ bool LLAudioEngine::isWindEnabled()
void LLAudioEngine::setMuted(bool muted)
{
- mMuted = muted;
+ if (muted != mMuted)
+ {
+ mMuted = muted;
+ setMasterGain(mMasterGain);
+ }
enableWind(!mMuted);
}
-
void LLAudioEngine::setMasterGain(const F32 gain)
{
mMasterGain = gain;
- setInternalGain(gain);
+ F32 internal_gain = getMuted() ? 0.f : gain;
+ if (internal_gain != mInternalGain)
+ {
+ mInternalGain = internal_gain;
+ setInternalGain(mInternalGain);
+ }
}
F32 LLAudioEngine::getMasterGain()
@@ -1243,13 +1257,14 @@ LLAudioSource::LLAudioSource(const LLUUID& id, const LLUUID& owner_id, const F32
mOwnerID(owner_id),
mPriority(0.f),
mGain(gain),
- mType(type),
+ mSourceMuted(false),
mAmbient(false),
mLoop(false),
mSyncMaster(false),
mSyncSlave(false),
mQueueSounds(false),
mPlayedOnce(false),
+ mType(type),
mChannelp(NULL),
mCurrentDatap(NULL),
mQueuedDatap(NULL)
@@ -1301,6 +1316,10 @@ void LLAudioSource::updatePriority()
{
mPriority = 1.f;
}
+ else if (isMuted())
+ {
+ mPriority = 0.f;
+ }
else
{
// Priority is based on distance
@@ -1349,25 +1368,33 @@ bool LLAudioSource::setupChannel()
bool LLAudioSource::play(const LLUUID &audio_uuid)
{
+ // Special abuse of play(); don't play a sound, but kill it.
if (audio_uuid.isNull())
{
if (getChannel())
{
getChannel()->setSource(NULL);
setChannel(NULL);
- addAudioData(NULL, true);
+ if (!isMuted())
+ {
+ mCurrentDatap = NULL;
+ }
}
+ return false;
}
+
// Reset our age timeout if someone attempts to play the source.
mAgeTimer.reset();
LLAudioData *adp = gAudiop->getAudioData(audio_uuid);
-
- bool has_buffer = gAudiop->updateBufferForData(adp, audio_uuid);
-
-
addAudioData(adp);
+ if (isMuted())
+ {
+ return false;
+ }
+
+ bool has_buffer = gAudiop->updateBufferForData(adp, audio_uuid);
if (!has_buffer)
{
// Don't bother trying to set up a channel or anything, we don't have an audio buffer.
@@ -1392,10 +1419,11 @@ bool LLAudioSource::play(const LLUUID &audio_uuid)
}
-bool LLAudioSource::isDone()
+bool LLAudioSource::isDone() const
{
const F32 MAX_AGE = 60.f;
const F32 MAX_UNPLAYED_AGE = 15.f;
+ const F32 MAX_MUTED_AGE = 11.f;
if (isLoop())
{
@@ -1403,7 +1431,6 @@ bool LLAudioSource::isDone()
return false;
}
-
if (hasPendingPreloads())
{
return false;
@@ -1420,10 +1447,10 @@ bool LLAudioSource::isDone()
// This is a single-play source
if (!mChannelp)
{
- if ((elapsed > MAX_UNPLAYED_AGE) || mPlayedOnce)
+ if ((elapsed > (mSourceMuted ? MAX_MUTED_AGE : MAX_UNPLAYED_AGE)) || mPlayedOnce)
{
// We don't have a channel assigned, and it's been
- // over 5 seconds since we tried to play it. Don't bother.
+ // over 15 seconds since we tried to play it. Don't bother.
//llinfos << "No channel assigned, source is done" << llendl;
return true;
}
@@ -1449,7 +1476,7 @@ bool LLAudioSource::isDone()
if ((elapsed > MAX_UNPLAYED_AGE) || mPlayedOnce)
{
- // The sound isn't playing back after 5 seconds or we're already done playing it, kill it.
+ // The sound isn't playing back after 15 seconds or we're already done playing it, kill it.
return true;
}
@@ -1534,6 +1561,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 6a5000d7ed..30d2490635 100644
--- a/indra/llaudio/llaudioengine.h
+++ b/indra/llaudio/llaudioengine.h
@@ -118,8 +118,8 @@ public:
// Use these for temporarily muting the audio system.
// Does not change buffers, initialization, etc. but
// stops playing new sounds.
- virtual void setMuted(bool muted);
- virtual bool getMuted() const { return mMuted; }
+ void setMuted(bool muted);
+ bool getMuted() const { return mMuted; }
#ifdef USE_PLUGIN_MEDIA
LLPluginClassMedia* initializeMedia(const std::string& media_type);
#endif
@@ -239,6 +239,7 @@ protected:
LLAudioBuffer *mBuffers[MAX_BUFFERS];
F32 mMasterGain;
+ F32 mInternalGain; // Actual gain set; either mMasterGain or 0 when mMuted is true.
F32 mSecondaryGain[AUDIO_TYPE_COUNT];
F32 mNextWindUpdate;
@@ -303,7 +304,8 @@ public:
virtual void setGain(const F32 gain) { mGain = llclamp(gain, 0.f, 1.f); }
const LLUUID &getID() const { return mID; }
- bool isDone();
+ bool isDone() const;
+ bool isMuted() const { return mSourceMuted; }
LLAudioData *getCurrentData();
LLAudioData *getQueuedData();
@@ -325,6 +327,7 @@ protected:
LLUUID mOwnerID; // owner of the object playing the sound
F32 mPriority;
F32 mGain;
+ bool mSourceMuted;
bool mAmbient;
bool mLoop;
bool mSyncMaster;
diff --git a/indra/llaudio/llaudioengine_openal.cpp b/indra/llaudio/llaudioengine_openal.cpp
index e352045291..34a057dcc0 100644
--- a/indra/llaudio/llaudioengine_openal.cpp
+++ b/indra/llaudio/llaudioengine_openal.cpp
@@ -32,6 +32,8 @@
#include "lllistener_openal.h"
+const float LLAudioEngine_OpenAL::WIND_BUFFER_SIZE_SEC = 0.05f;
+
LLAudioEngine_OpenAL::LLAudioEngine_OpenAL()
:
mWindGen(NULL),
diff --git a/indra/llaudio/llaudioengine_openal.h b/indra/llaudio/llaudioengine_openal.h
index 258febb1a8..6639d9dfe6 100644
--- a/indra/llaudio/llaudioengine_openal.h
+++ b/indra/llaudio/llaudioengine_openal.h
@@ -67,7 +67,7 @@ class LLAudioEngine_OpenAL : public LLAudioEngine
int mNumEmptyWindALBuffers;
static const int MAX_NUM_WIND_BUFFERS = 80;
- static const float WIND_BUFFER_SIZE_SEC = 0.05f; // 1/20th sec
+ static const float WIND_BUFFER_SIZE_SEC; // 1/20th sec
};
class LLAudioChannelOpenAL : public LLAudioChannel
diff --git a/indra/llaudio/llvorbisencode.cpp b/indra/llaudio/llvorbisencode.cpp
index 9f479189d7..0e0c80a456 100644
--- a/indra/llaudio/llvorbisencode.cpp
+++ b/indra/llaudio/llvorbisencode.cpp
@@ -120,6 +120,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 d33aacf1ea..6b22a2cb59 100644
--- a/indra/llaudio/llvorbisencode.h
+++ b/indra/llaudio/llvorbisencode.h
@@ -38,6 +38,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;