Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Andros Baphomet
2013-10-12 12:59:26 -04:00
21 changed files with 540 additions and 723 deletions

View File

@@ -679,7 +679,7 @@ namespace HACD
{
if ((!condition1) && m_callBack)
{
sprintf(msg, "\n-> %lu\t%f\t%f\t%f\n", m_pqueue.size(), m_graph.m_vertices[v1].m_surf*100.0/m_area, m_graph.m_vertices[v2].m_surf*100.0/m_area, m_graph.m_edges[currentEdge.m_name].m_concavity);
sprintf(msg, "\n-> %zu\t%f\t%f\t%f\n", m_pqueue.size(), m_graph.m_vertices[v1].m_surf*100.0/m_area, m_graph.m_vertices[v2].m_surf*100.0/m_area, m_graph.m_edges[currentEdge.m_name].m_concavity);
(*m_callBack)(msg, progress, globalConcavity, m_graph.GetNVertices());
}
globalConcavity = std::max<double>(globalConcavity ,m_graph.m_edges[currentEdge.m_name].m_concavity);
@@ -879,7 +879,7 @@ namespace HACD
if (m_callBack)
{
char msg[1024];
sprintf(msg, "\t CH(%lu) \t %lu \t %lf \t %lu \t %f \t %lu\n", v, static_cast<unsigned long>(p), m_graph.m_vertices[v].m_concavity, m_graph.m_vertices[v].m_distPoints.Size(), m_graph.m_vertices[v].m_surf*100.0/m_area, m_graph.m_vertices[v].m_ancestors.size());
sprintf(msg, "\t CH(%zu) \t %zu \t %lf \t %zu \t %f \t %zu\n", v, static_cast<unsigned long>(p), m_graph.m_vertices[v].m_concavity, m_graph.m_vertices[v].m_distPoints.Size(), m_graph.m_vertices[v].m_surf*100.0/m_area, m_graph.m_vertices[v].m_ancestors.size());
(*m_callBack)(msg, 0.0, 0.0, m_nClusters);
p++;
}

View File

@@ -685,6 +685,12 @@ void LLAudioDecodeMgr::Impl::processQueue(const F32 num_secs)
mCurrentDecodep = new LLVorbisDecodeState(uuid, d_path);
if (!mCurrentDecodep->initDecode())
{
LLAudioData *adp = gAudiop->getAudioData(uuid);
if(adp)
{
adp->setHasValidData(false);
adp->setHasCompletedDecode(true);
}
mCurrentDecodep = NULL;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -147,7 +147,7 @@ public:
const LLVector3d &pos_global = LLVector3d::zero,
const LLUUID source_object = LLUUID::null);
// </edit>
bool preloadSound(const LLUUID &id);
bool preloadSound(const LLUUID &id); //Preloads sounds without requiring a source.
void addAudioSource(LLAudioSource *asp);
void cleanupAudioSource(LLAudioSource *asp);
@@ -179,8 +179,6 @@ public:
bool hasDecodedFile(const LLUUID &uuid);
bool hasLocalFile(const LLUUID &uuid);
bool updateBufferForData(LLAudioData *adp, const LLUUID &audio_uuid = LLUUID::null);
void setAllowLargeSounds(bool allow) { mAllowLargeSounds = allow ;}
bool getAllowLargeSounds() const {return mAllowLargeSounds;}
@@ -244,6 +242,7 @@ public://Jay: IDGAF
source_map mAllSources;
protected:
data_map mAllData;
std::list<LLUUID> mPreloadSystemList;
LLAudioChannel *mChannels[MAX_CHANNELS];
// Buffers needs to change into a different data structure, as the number of buffers
@@ -287,9 +286,7 @@ public:
virtual void update(); // Update this audio source
void updatePriority();
void preload(const LLUUID &audio_id); // Only used for preloading UI sounds, now.
void addAudioData(LLAudioData *adp, bool set_current = TRUE);
void preload(const LLUUID &audio_id);
void setAmbient(const bool ambient) { mAmbient = ambient; }
bool isAmbient() const { return mAmbient; }
@@ -450,11 +447,10 @@ protected:
virtual void play() = 0;
virtual void playSynced(LLAudioChannel *channelp) = 0;
virtual void cleanup();
void setWaiting(bool waiting) { mWaiting = waiting; }
public:
virtual bool isPlaying() = 0;
bool isWaiting() const { return mWaiting; }
bool isFree() const { return mCurrentSourcep==NULL; }
protected:
virtual bool updateBuffer(); // Check to see if the buffer associated with the source changed, and update if necessary.
@@ -465,7 +461,6 @@ protected:
LLAudioSource *mCurrentSourcep;
LLAudioBuffer *mCurrentBufferp;
bool mLoopedThisFrame;
bool mWaiting; // Waiting for sync.
F32 mSecondaryGain;
};

View File

@@ -97,17 +97,17 @@ public:
DEAD,
UNKNOWN
};
STATUS getPtrStatus(LLAudioChannelFMODEX* channel)
STATUS getPtrStatus(LLAudioChannel* channel)
{
if(!channel)
return UNKNOWN;
return getPtrStatus(channel->mChannelp);
return getPtrStatus(dynamic_cast<LLAudioChannelFMODEX*>(channel)->mChannelp);
}
STATUS getPtrStatus(LLAudioBufferFMODEX* sound)
STATUS getPtrStatus(LLAudioBuffer* sound)
{
if(!sound)
return UNKNOWN;
return getPtrStatus(sound->mSoundp);
return getPtrStatus(dynamic_cast<LLAudioBufferFMODEX*>(sound)->mSoundp);
}
STATUS getPtrStatus(FMOD::Channel* channel)
{
@@ -131,18 +131,14 @@ public:
}
void addNewSound(FMOD::Sound* sound)
{
llassert(getPtrStatus(sound) != ACTIVE);
assertActiveState(sound,true,false);
mDeadSounds.erase(sound);
mActiveSounds.insert(std::make_pair(sound,std::set<FMOD::Channel*>()));
}
void removeSound(FMOD::Sound* sound)
{
#ifdef SHOW_ASSERT
STATUS status = getPtrStatus(sound);
llassert(status != DEAD);
llassert(status != UNKNOWN);
#endif
assertActiveState(sound,true);
active_sounds_t::const_iterator it = mActiveSounds.find(sound);
llassert(it != mActiveSounds.end());
@@ -150,49 +146,39 @@ public:
{
if(!it->second.empty())
{
#ifdef LL_RELEASE_FOR_DOWNLOAD
LL_WARNS("AudioImpl") << "Removing sound " << sound << " with attached channels: \n";
#else
LL_ERRS("AudioImpl") << "Removing sound " << sound << " with attached channels: \n";
#endif
for(std::set<FMOD::Channel*>::iterator it2 = it->second.begin(); it2 != it->second.end();++it2)
{
switch(getPtrStatus(*it2))
{
case ACTIVE:
llcont << " Channel " << *it2 << " ACTIVE\n";
LL_CONT << " Channel " << *it2 << " ACTIVE\n";
break;
case DEAD:
llcont << " Channel " << *it2 << " DEAD\n";
LL_CONT << " Channel " << *it2 << " DEAD\n";
break;
default:
llcont << " Channel " << *it2 << " UNKNOWN\n";
LL_CONT << " Channel " << *it2 << " UNKNOWN\n";
}
}
llcont << llendl;
LL_CONT << LL_ENDL;
}
llassert(it->second.empty());
mDeadSounds.insert(sound);
mActiveSounds.erase(sound);
}
}
void addNewChannelToSound(FMOD::Sound* sound,FMOD::Channel* channel)
{
STATUS status = getPtrStatus(sound);
llassert(status != DEAD);
llassert(status != UNKNOWN);
status = getPtrStatus(channel);
llassert(status != ACTIVE);
assertActiveState(sound,true);
assertActiveState(channel,true,false);
mActiveSounds[sound].insert(channel);
mActiveChannels.insert(std::make_pair(channel,sound));
}
void removeChannel(FMOD::Channel* channel)
{
#ifdef SHOW_ASSERT
STATUS status = getPtrStatus(channel);
llassert(status != DEAD);
llassert(status != UNKNOWN);
#endif
gSoundCheck.assertActiveState(channel,true);
active_channels_t::const_iterator it = mActiveChannels.find(channel);
llassert(it != mActiveChannels.end());
@@ -214,25 +200,32 @@ public:
mActiveChannels.erase(channel);
}
}
template <typename T>
void assertActiveState(T ptr, bool try_log=false, bool active=true)
{
#ifndef SHOW_ASSERT
if(try_log && sVerboseDebugging)
#endif
{
CFMODSoundChecks::STATUS chan = gSoundCheck.getPtrStatus(ptr);
if(try_log && sVerboseDebugging)
{
if(active)
{
if(chan == CFMODSoundChecks::DEAD)
LL_WARNS("AudioImpl") << __FUNCTION__ << ": Using unexpectedly dead " << typeid(T*).name() << " " << ptr << LL_ENDL;
else if(chan == CFMODSoundChecks::UNKNOWN)
LL_WARNS("AudioImpl") << __FUNCTION__ << ": Using unexpectedly unknown " << typeid(T*).name() << " " << ptr << LL_ENDL;
}
else if(chan == CFMODSoundChecks::ACTIVE)
LL_WARNS("AudioImpl") << __FUNCTION__ << ": Using unexpectedly active " << typeid(T*).name() << " " << ptr << LL_ENDL;
}
llassert( active == (chan == CFMODSoundChecks::ACTIVE) );
}
}
} gSoundCheck;
bool isActive(LLAudioChannel* channel)
{
return gSoundCheck.getPtrStatus(dynamic_cast<LLAudioChannelFMODEX*>(channel)) == CFMODSoundChecks::ACTIVE;
}
bool isActive(LLAudioBuffer* sound)
{
return gSoundCheck.getPtrStatus(dynamic_cast<LLAudioBufferFMODEX*>(sound)) == CFMODSoundChecks::ACTIVE;
}
#define CHECK_PTR(ptr) \
if(sVerboseDebugging){\
CFMODSoundChecks::STATUS chan = gSoundCheck.getPtrStatus(ptr); \
if(chan == CFMODSoundChecks::DEAD) \
LL_DEBUGS("AudioImpl") << __FUNCTION__ << ": Using dead " << typeid(ptr).name() << " " << ptr << llendl; \
else if(chan == CFMODSoundChecks::UNKNOWN) \
LL_DEBUGS("AudioImpl") << __FUNCTION__ << ": Using unknown " << typeid(ptr).name() << " " << ptr << llendl;} \
LLAudioEngine_FMODEX::LLAudioEngine_FMODEX(bool enable_profiler, bool verbose_debugging)
{
sVerboseDebugging = verbose_debugging;
@@ -253,7 +246,7 @@ inline bool Check_FMOD_Error(FMOD_RESULT result, const char *string)
{
if(result == FMOD_OK)
return false;
LL_WARNS("AudioImpl") << string << " Error: " << FMOD_ErrorString(result) << llendl;
LL_WARNS("AudioImpl") << string << " Error: " << FMOD_ErrorString(result) << LL_ENDL;
return true;
}
@@ -261,11 +254,11 @@ void* F_STDCALL decode_alloc(unsigned int size, FMOD_MEMORY_TYPE type, const cha
{
if(type & FMOD_MEMORY_STREAM_DECODE)
{
LL_INFOS("AudioImpl") << "Decode buffer size: " << size << llendl;
LL_INFOS("AudioImpl") << "Decode buffer size: " << size << LL_ENDL;
}
else if(type & FMOD_MEMORY_STREAM_FILE)
{
LL_INFOS("AudioImpl") << "Stream buffer size: " << size << llendl;
LL_INFOS("AudioImpl") << "Stream buffer size: " << size << LL_ENDL;
}
return new char[size];
}
@@ -504,7 +497,7 @@ void LLAudioEngine_FMODEX::allocateListener(void)
mListenerp = (LLListener *) new LLListener_FMODEX(mSystem);
if (!mListenerp)
{
LL_WARNS("AudioImpl") << "Listener creation failed" << llendl;
LL_WARNS("AudioImpl") << "Listener creation failed" << LL_ENDL;
}
}
@@ -513,16 +506,18 @@ void LLAudioEngine_FMODEX::shutdown()
{
stopInternetStream();
LL_INFOS("AudioImpl") << "About to LLAudioEngine::shutdown()" << llendl;
LL_INFOS("AudioImpl") << "About to LLAudioEngine::shutdown()" << LL_ENDL;
LLAudioEngine::shutdown();
LL_INFOS("AudioImpl") << "LLAudioEngine_FMODEX::shutdown() closing FMOD Ex" << llendl;
LL_INFOS("AudioImpl") << "LLAudioEngine_FMODEX::shutdown() closing FMOD Ex" << LL_ENDL;
if ( mSystem ) // speculative fix for MAINT-2657
{
mSystem->close();
mSystem->release();
LL_INFOS("AudioImpl") << "LLAudioEngine_FMODEX::shutdown() Requesting FMOD Ex system closure" << LL_ENDL;
mSystem->close();
LL_INFOS("AudioImpl") << "LLAudioEngine_FMODEX::shutdown() Requesting FMOD Ex system release" << LL_ENDL;
mSystem->release();
}
LL_INFOS("AudioImpl") << "LLAudioEngine_FMODEX::shutdown() done closing FMOD Ex" << llendl;
LL_INFOS("AudioImpl") << "LLAudioEngine_FMODEX::shutdown() done closing FMOD Ex" << LL_ENDL;
delete mListenerp;
mListenerp = NULL;
@@ -654,7 +649,7 @@ LLAudioChannelFMODEX::LLAudioChannelFMODEX(FMOD::System *system) : LLAudioChanne
LLAudioChannelFMODEX::~LLAudioChannelFMODEX()
{
if(sVerboseDebugging)
LL_DEBUGS("AudioImpl") << "Destructing Audio Channel. mChannelp = " << mChannelp << llendl;
LL_DEBUGS("AudioImpl") << "Destructing Audio Channel. mChannelp = " << mChannelp << LL_ENDL;
cleanup();
}
@@ -678,7 +673,7 @@ void LLAudioChannelFMODEX::onRelease()
{
llassert(mChannelp);
if(sVerboseDebugging)
LL_DEBUGS("AudioImpl") << "Fmod signaled channel release for channel " << mChannelp << llendl;
LL_DEBUGS("AudioImpl") << "Fmod signaled channel release for channel " << mChannelp << LL_ENDL;
gSoundCheck.removeChannel(mChannelp);
mChannelp = NULL; //Null out channel here so cleanup doesn't try to redundantly stop it.
cleanup();
@@ -688,42 +683,32 @@ bool LLAudioChannelFMODEX::updateBuffer()
{
if (LLAudioChannel::updateBuffer())
{
// Base class update returned true, which means that we need to actually
// set up the channel for a different buffer.
LLAudioBufferFMODEX *bufferp = (LLAudioBufferFMODEX *)mCurrentSourcep->getCurrentBuffer();
llassert(mCurrentBufferp != NULL);
llassert(mCurrentBufferp == bufferp);
// Base class update returned true, which means the channel buffer was changed, and not is null.
// Grab the FMOD sample associated with the buffer
FMOD::Sound *soundp = bufferp->getSound();
FMOD::Sound *soundp = ((LLAudioBufferFMODEX*)mCurrentBufferp)->getSound();
if (!soundp)
{
// This is bad, there should ALWAYS be a sound associated with a legit
// buffer.
LL_ERRS("AudioImpl") << "No FMOD sound!" << llendl;
LL_ERRS("AudioImpl") << "No FMOD sound!" << LL_ENDL;
return false;
}
// Actually play the sound. Start it off paused so we can do all the necessary
// setup.
if(!mChannelp)
{
llassert(!isActive(this));
FMOD_RESULT result = getSystem()->playSound(FMOD_CHANNEL_FREE, soundp, true, &mChannelp);
Check_FMOD_Error(result, "FMOD::System::playSound");
if(result == FMOD_OK)
{
if(sVerboseDebugging)
LL_DEBUGS("AudioImpl") << "Created channel " << mChannelp << " for sound " << soundp << llendl;
LL_DEBUGS("AudioImpl") << "Created channel " << mChannelp << " for sound " << soundp << LL_ENDL;
gSoundCheck.addNewChannelToSound(soundp,mChannelp);
mChannelp->setCallback(&channel_callback);
mChannelp->setUserData(this);
llassert(isActive(this));
}
}
}
@@ -731,11 +716,9 @@ bool LLAudioChannelFMODEX::updateBuffer()
// If we have a source for the channel, we need to update its gain.
if (mCurrentSourcep && mChannelp)
{
// SJB: warnings can spam and hurt framerate, disabling
FMOD_RESULT result;
CHECK_PTR(mChannelp);
gSoundCheck.assertActiveState(this);
result = mChannelp->setVolume(getSecondaryGain() * mCurrentSourcep->getGain());
Check_FMOD_Error(result, "FMOD::Channel::setVolume");
result = mChannelp->setMode(mCurrentSourcep->isLoop() ? FMOD_LOOP_NORMAL : FMOD_LOOP_OFF);
@@ -762,7 +745,7 @@ void LLAudioChannelFMODEX::update3DPosition()
return;
}
CHECK_PTR(mChannelp);
gSoundCheck.assertActiveState(this);
if (mCurrentSourcep->isAmbient())
{
@@ -790,7 +773,7 @@ void LLAudioChannelFMODEX::updateLoop()
return;
}
CHECK_PTR(mChannelp);
gSoundCheck.assertActiveState(this);
//
// Hack: We keep track of whether we looped or not by seeing when the
@@ -814,26 +797,19 @@ void LLAudioChannelFMODEX::cleanup()
if (!mChannelp)
{
llassert(!isActive(this));
llassert(mCurrentBufferp == NULL);
//llinfos << "Aborting cleanup with no channel handle." << llendl;
//LL_INFOS("AudioImpl") << "Aborting cleanup with no channel handle." << LL_ENDL;
return;
}
CHECK_PTR(mChannelp);
if(sVerboseDebugging)
LL_DEBUGS("AudioImpl") << "Stopping channel " << mChannelp << llendl;
LL_DEBUGS("AudioImpl") << "Stopping channel " << mChannelp << LL_ENDL;
gSoundCheck.removeChannel(mChannelp);
mChannelp->setCallback(NULL);
if(!Check_FMOD_Error(mChannelp->stop(),"FMOD::Channel::stop"))
{
gSoundCheck.removeChannel(mChannelp);
}
Check_FMOD_Error(mChannelp->stop(),"FMOD::Channel::stop");
mChannelp = NULL;
llassert(!isActive(this));
}
@@ -841,18 +817,16 @@ void LLAudioChannelFMODEX::play()
{
if (!mChannelp)
{
LL_WARNS("AudioImpl") << "Playing without a channel handle, aborting" << llendl;
LL_WARNS("AudioImpl") << "Playing without a channel handle, aborting" << LL_ENDL;
return;
}
llassert(isActive(this));
CHECK_PTR(mChannelp);
gSoundCheck.assertActiveState(this,true);
Check_FMOD_Error(mChannelp->setPaused(false), "FMOD::Channel::setPaused");
if(sVerboseDebugging)
LL_DEBUGS("AudioImpl") << "Playing channel " << mChannelp << llendl;
LL_DEBUGS("AudioImpl") << "Playing channel " << mChannelp << LL_ENDL;
getSource()->setPlayedOnce(true);
@@ -870,10 +844,10 @@ void LLAudioChannelFMODEX::playSynced(LLAudioChannel *channelp)
return;
}
CHECK_PTR(mChannelp);
gSoundCheck.assertActiveState(this,true);
U32 cur_pos;
if(Check_FMOD_Error(mChannelp->getPosition(&cur_pos,FMOD_TIMEUNIT_PCMBYTES), "Unable to retrieve current position"))
if(Check_FMOD_Error(fmod_channelp->mChannelp->getPosition(&cur_pos,FMOD_TIMEUNIT_PCMBYTES), "Unable to retrieve current position"))
return;
cur_pos %= mCurrentBufferp->getLength();
@@ -893,7 +867,7 @@ bool LLAudioChannelFMODEX::isPlaying()
return false;
}
CHECK_PTR(mChannelp);
gSoundCheck.assertActiveState(this);
bool paused, playing;
Check_FMOD_Error(mChannelp->getPaused(&paused),"FMOD::Channel::getPaused");
@@ -917,11 +891,10 @@ LLAudioBufferFMODEX::~LLAudioBufferFMODEX()
if(mSoundp)
{
if(sVerboseDebugging)
LL_DEBUGS("AudioImpl") << "Release sound " << mSoundp << llendl;
LL_DEBUGS("AudioImpl") << "Release sound " << mSoundp << LL_ENDL;
CHECK_PTR(mSoundp);
Check_FMOD_Error(mSoundp->release(),"FMOD::Sound::Release");
gSoundCheck.removeSound(mSoundp);
Check_FMOD_Error(mSoundp->release(),"FMOD::Sound::Release");
mSoundp = NULL;
}
}
@@ -945,10 +918,9 @@ bool LLAudioBufferFMODEX::loadWAV(const std::string& filename)
if (mSoundp)
{
CHECK_PTR(mSoundp);
gSoundCheck.removeSound(mSoundp);
// If there's already something loaded in this buffer, clean it up.
Check_FMOD_Error(mSoundp->release(),"FMOD::Sound::release");
gSoundCheck.removeSound(mSoundp);
mSoundp = NULL;
}
@@ -967,7 +939,7 @@ bool LLAudioBufferFMODEX::loadWAV(const std::string& filename)
if (result != FMOD_OK)
{
// We failed to load the file for some reason.
LL_WARNS("AudioImpl") << "Could not load data '" << filename << "': " << FMOD_ErrorString(result) << llendl;
LL_WARNS("AudioImpl") << "Could not load data '" << filename << "': " << FMOD_ErrorString(result) << LL_ENDL;
//
// If we EVER want to load wav files provided by end users, we need
@@ -992,7 +964,7 @@ U32 LLAudioBufferFMODEX::getLength()
return 0;
}
CHECK_PTR(mSoundp);
gSoundCheck.assertActiveState(this);
U32 length;
Check_FMOD_Error(mSoundp->getLength(&length, FMOD_TIMEUNIT_PCMBYTES),"FMOD::Sound::getLength");
return length;
@@ -1001,7 +973,7 @@ U32 LLAudioBufferFMODEX::getLength()
void LLAudioChannelFMODEX::set3DMode(bool use3d)
{
CHECK_PTR(mChannelp);
gSoundCheck.assertActiveState(this);
FMOD_MODE current_mode;
if(Check_FMOD_Error(mChannelp->getMode(&current_mode),"FMOD::Channel::getMode"))

View File

@@ -215,7 +215,16 @@ BOOL LLEditingMotion::onUpdate(F32 time, U8* joint_mask)
if (!target.isFinite())
{
llwarns << "Non finite target in editing motion with target distance of " << target_dist <<
" and focus point " << focus_pt << " and pointAtPt: " << *pointAtPt << llendl;
" and focus point " << focus_pt << " and pointAtPt: ";
if (pointAtPt)
{
llcont << *pointAtPt;
}
else
{
llcont << "NULL";
}
llcont << llendl;
}
mTarget.setPosition( target + mParentJoint.getPosition());

View File

@@ -249,6 +249,10 @@ public:
virtual ~LLAssetStorage();
void setUpstream(const LLHost &upstream_host);
bool isUpstreamOK() const
{
return mUpstreamHost.isOk();
}
virtual BOOL hasLocalAsset(const LLUUID &uuid, LLAssetType::EType type);

View File

@@ -1534,33 +1534,6 @@ bool LLAppViewer::cleanup()
llinfos << "Global stuff deleted" << llendflush;
if (gAudiop)
{
// shut down the streaming audio sub-subsystem first, in case it relies on not outliving the general audio subsystem.
LLStreamingAudioInterface *sai = gAudiop->getStreamingAudioImpl();
delete sai;
gAudiop->setStreamingAudioImpl(NULL);
// shut down the audio subsystem
bool want_longname = false;
if (gAudiop->getDriverName(want_longname) == "FMOD")
{
// This hack exists because fmod likes to occasionally
// crash or hang forever when shutting down, for no
// apparent reason.
llwarns << "Hack, skipping FMOD audio engine cleanup" << llendflush;
}
else
{
gAudiop->shutdown();
}
delete gAudiop;
gAudiop = NULL;
}
// Note: this is where LLFeatureManager::getInstance()-> used to be deleted.
// Patch up settings for next time
@@ -3942,6 +3915,9 @@ void LLAppViewer::idle()
gViewerWindow->updateUI();
//updateUI may have created sounds (clicks, etc). Call idleAudio to dispatch asap.
idleAudio();
///////////////////////////////////////
// Agent and camera movement
//
@@ -4120,22 +4096,6 @@ void LLAppViewer::idle()
gObjectList.updateApparentAngles(gAgent);
}
{
gFrameStats.start(LLFrameStats::AUDIO);
LLFastTimer t(FTM_AUDIO_UPDATE);
if (gAudiop)
{
audio_update_volume(false);
audio_update_listener();
audio_update_wind(false);
// this line actually commits the changes we've made to source positions, etc.
const F32 max_audio_decode_time = 0.002f; // 2 ms decode time
gAudiop->idle(max_audio_decode_time);
}
}
// Execute deferred tasks.
LLDeferredTaskList::instance().run();
@@ -4440,6 +4400,51 @@ void LLAppViewer::idleNetwork()
}
}
void LLAppViewer::idleAudio()
{
gFrameStats.start(LLFrameStats::AUDIO);
LLFastTimer t(FTM_AUDIO_UPDATE);
if (gAudiop)
{
audio_update_volume();
audio_update_listener();
// this line actually commits the changes we've made to source positions, etc.
const F32 max_audio_decode_time = 0.002f; // 2 ms decode time
gAudiop->idle(max_audio_decode_time);
}
}
void LLAppViewer::shutdownAudio()
{
if (gAudiop)
{
// shut down the streaming audio sub-subsystem first, in case it relies on not outliving the general audio subsystem.
LLStreamingAudioInterface *sai = gAudiop->getStreamingAudioImpl();
delete sai;
gAudiop->setStreamingAudioImpl(NULL);
// shut down the audio subsystem
bool want_longname = false;
if (gAudiop->getDriverName(want_longname) == "FMOD")
{
// This hack exists because fmod likes to occasionally
// crash or hang forever when shutting down, for no
// apparent reason.
llwarns << "Hack, skipping FMOD audio engine cleanup" << llendflush;
}
else
{
gAudiop->shutdown();
}
delete gAudiop;
gAudiop = NULL;
}
}
void LLAppViewer::disconnectViewer()
{
if (gDisconnected)
@@ -4540,6 +4545,9 @@ void LLAppViewer::disconnectViewer()
LLDestroyClassList::instance().fireCallbacks();
cleanup_xfer_manager();
shutdownAudio();
gDisconnected = TRUE;
}

View File

@@ -210,6 +210,8 @@ private:
// update avatar SLID and display name caches
void idleNameCache();
void idleNetwork();
void idleAudio();
void shutdownAudio();
void sendLogoutRequest();
void disconnectViewer();

View File

@@ -174,7 +174,8 @@ void LLFloaterBlacklist::addEntry(LLUUID key, LLSD data)
std::string wav_path= gDirUtilp->getExpandedFilename(LL_PATH_CACHE,sound_id.asString()) + ".dsf";
if(LLAPRFile::isExist(wav_path, LL_APR_RPB))
LLAPRFile::remove(wav_path);
gAudiop->removeAudioData(sound_id);
if(gAudiop)
gAudiop->removeAudioData(sound_id);
}
blacklist_entries.insert(std::pair<LLUUID,LLSD>(key,data));
updateBlacklists();

View File

@@ -498,6 +498,7 @@ void LLFloaterChat::triggerAlerts(const std::string& text)
{
if ((std::string)highlight["sound_lluuid"] != LLUUID::null.asString())
{
if(gAudiop)
gAudiop->triggerSound(highlight["sound_lluuid"].asUUID(),
gAgent.getID(),
1.f,

View File

@@ -304,6 +304,7 @@ void LLFloaterExploreSounds::handle_play_locally(void* user_data)
if(std::find(asset_list.begin(), asset_list.end(), item.mAssetID) == asset_list.end())
{
asset_list.push_back(item.mAssetID);
if(gAudiop)
gAudiop->triggerSound(item.mAssetID, LLUUID::null, 1.0f, LLAudioEngine::AUDIO_TYPE_UI);
}
}

View File

@@ -136,6 +136,8 @@ LLFloaterPay::LLFloaterPay(const std::string& name,
// Destroys the object
LLFloaterPay::~LLFloaterPay()
{
// In case this floater is currently waiting for a reply.
gMessageSystem->setHandlerFuncFast(_PREHASH_PayPriceReply, 0, 0);
}
// static

View File

@@ -93,13 +93,13 @@ LLPreviewSound::LLPreviewSound(const std::string& name, const LLRect& rect, cons
// preload the sound
if(item && gAudiop)
{
gAudiop->preloadSound(item->getAssetUUID());
// <edit>
// that thing above doesn't actually start a sound transfer, so I will do it
//LLAudioSource *asp = new LLAudioSource(gAgent.getID(), gAgent.getID(), F32(1.0f), LLAudioEngine::AUDIO_TYPE_UI);
LLAudioSource *asp = gAgentAvatarp->getAudioSource(gAgent.getID());
LLAudioData *datap = gAudiop->getAudioData(item->getAssetUUID());
asp->addAudioData(datap, FALSE);
if(asp)
{
asp->preload(item->getAssetUUID());
}
// </edit>
}

View File

@@ -375,6 +375,88 @@ void hooked_process_sound_trigger(LLMessageSystem *msg, void **)
LLFloaterAvatarList::sound_trigger_hook(msg,NULL);
}
void init_audio()
{
if (FALSE == gSavedSettings.getBOOL("NoAudio"))
{
gAudiop = NULL;
#ifdef LL_FMODEX
if (!gAudiop
#if !LL_WINDOWS
&& NULL == getenv("LL_BAD_FMODEX_DRIVER")
#endif // !LL_WINDOWS
)
{
gAudiop = (LLAudioEngine *) new LLAudioEngine_FMODEX(gSavedSettings.getBOOL("SHEnableFMODExProfiler"),gSavedSettings.getBOOL("SHEnableFMODEXVerboseDebugging"));
}
#endif
#ifdef LL_OPENAL
if (!gAudiop
#if !LL_WINDOWS
&& NULL == getenv("LL_BAD_OPENAL_DRIVER")
#endif // !LL_WINDOWS
)
{
gAudiop = (LLAudioEngine *) new LLAudioEngine_OpenAL();
}
#endif
#ifdef LL_FMOD
if (!gAudiop
#if !LL_WINDOWS
&& NULL == getenv("LL_BAD_FMOD_DRIVER")
#endif // !LL_WINDOWS
)
{
gAudiop = (LLAudioEngine *) new LLAudioEngine_FMOD();
}
#endif
if (gAudiop)
{
#if LL_WINDOWS
// FMOD on Windows needs the window handle to stop playing audio
// when window is minimized. JC
void* window_handle = (HWND)gViewerWindow->getPlatformWindow();
#else
void* window_handle = NULL;
#endif
bool init = gAudiop->init(kAUDIO_NUM_SOURCES, window_handle);
if(init)
{
gAudiop->setMuted(TRUE);
if(gSavedSettings.getBOOL("AllowLargeSounds"))
gAudiop->setAllowLargeSounds(true);
}
else
{
LL_WARNS("AppInit") << "Unable to initialize audio engine" << LL_ENDL;
delete gAudiop;
gAudiop = NULL;
}
if (gAudiop)
{
// if the audio engine hasn't set up its own preferred handler for streaming audio then set up the generic streaming audio implementation which uses media plugins
if (NULL == gAudiop->getStreamingAudioImpl())
{
LL_INFOS("AppInit") << "Using media plugins to render streaming audio" << LL_ENDL;
gAudiop->setStreamingAudioImpl(new LLStreamingAudio_MediaPlugins());
}
// Unmute audio if desired and setup volumes.
// This is a not-uncommon crash site, so surround it with
// llinfos output to aid diagnosis.
LL_INFOS("AppInit") << "Doing first audio_update_volume..." << LL_ENDL;
audio_update_volume(false);
LL_INFOS("AppInit") << "Done first audio_update_volume." << LL_ENDL;
}
}
}
LL_INFOS("AppInit") << "Audio Engine Initialized." << LL_ENDL;
}
// Returns false to skip other idle processing. Should only return
// true when all initialization done.
bool idle_startup()
@@ -674,85 +756,6 @@ bool idle_startup()
//-------------------------------------------------
AIFilePicker::loadFile("filepicker_contexts.xml");
//-------------------------------------------------
// Init audio, which may be needed for prefs dialog
// or audio cues in connection UI.
//-------------------------------------------------
if (FALSE == gSavedSettings.getBOOL("NoAudio"))
{
gAudiop = NULL;
#ifdef LL_FMODEX
if (!gAudiop
#if !LL_WINDOWS
&& NULL == getenv("LL_BAD_FMODEX_DRIVER")
#endif // !LL_WINDOWS
)
{
gAudiop = (LLAudioEngine *) new LLAudioEngine_FMODEX(gSavedSettings.getBOOL("SHEnableFMODExProfiler"),gSavedSettings.getBOOL("SHEnableFMODEXVerboseDebugging"));
}
#endif
#ifdef LL_OPENAL
if (!gAudiop
#if !LL_WINDOWS
&& NULL == getenv("LL_BAD_OPENAL_DRIVER")
#endif // !LL_WINDOWS
)
{
gAudiop = (LLAudioEngine *) new LLAudioEngine_OpenAL();
}
#endif
#ifdef LL_FMOD
if (!gAudiop
#if !LL_WINDOWS
&& NULL == getenv("LL_BAD_FMOD_DRIVER")
#endif // !LL_WINDOWS
)
{
gAudiop = (LLAudioEngine *) new LLAudioEngine_FMOD();
}
#endif
if (gAudiop)
{
#if LL_WINDOWS
// FMOD on Windows needs the window handle to stop playing audio
// when window is minimized. JC
void* window_handle = (HWND)gViewerWindow->getPlatformWindow();
#else
void* window_handle = NULL;
#endif
bool init = gAudiop->init(kAUDIO_NUM_SOURCES, window_handle);
if(init)
{
gAudiop->setMuted(TRUE);
if(gSavedSettings.getBOOL("AllowLargeSounds"))
gAudiop->setAllowLargeSounds(true);
}
else
{
LL_WARNS("AppInit") << "Unable to initialize audio engine" << LL_ENDL;
delete gAudiop;
gAudiop = NULL;
}
if (gAudiop)
{
// if the audio engine hasn't set up its own preferred handler for streaming audio then set up the generic streaming audio implementation which uses media plugins
if (NULL == gAudiop->getStreamingAudioImpl())
{
LL_INFOS("AppInit") << "Using media plugins to render streaming audio" << LL_ENDL;
gAudiop->setStreamingAudioImpl(new LLStreamingAudio_MediaPlugins());
}
}
}
}
LL_INFOS("AppInit") << "Audio Engine Initialized." << LL_ENDL;
if (LLTimer::knownBadTimer())
{
@@ -889,15 +892,13 @@ bool idle_startup()
if (login_history.size() > 0)
{
LLPanelLogin::setFields(*login_history.getEntries().rbegin());
display_startup();
}
else
{
LLPanelLogin::setFields(firstname, lastname, password);
display_startup();
LLPanelLogin::giveFocus();
}
display_startup();
LLPanelLogin::giveFocus();
gSavedSettings.setBOOL("FirstRunThisInstall", FALSE);
@@ -2356,7 +2357,7 @@ bool idle_startup()
if (!gNoRender)
{
// JC: Initializing audio requests many sounds for download.
//Now that we're loading the world, initialize the audio engine.
init_audio();
display_startup();
@@ -2535,6 +2536,8 @@ bool idle_startup()
LLViewerShaderMgr::instance()->setShaders();
display_startup();
}
//Precache UI sounds.
precache_audio();
}
return TRUE;
@@ -2677,13 +2680,8 @@ bool idle_startup()
gSavedSettings.setF32("RenderFarClip", 32.0f);
}
// Unmute audio if desired and setup volumes.
// Unmute audio if desired and setup volumes.
// This is a not-uncommon crash site, so surround it with
// llinfos output to aid diagnosis.
LL_INFOS("AppInit") << "Doing first audio_update_volume..." << LL_ENDL;
audio_update_volume();
LL_INFOS("AppInit") << "Done first audio_update_volume." << LL_ENDL;
//Agent avatar is ready. Create the listener.
audio_update_listener();
// reset keyboard focus to sane state of pointing at world
gFocusMgr.setKeyboardFocus(NULL);

View File

@@ -46,28 +46,15 @@
/////////////////////////////////////////////////////////
void init_audio()
void precache_audio()
{
if (!gAudiop)
{
llwarns << "Failed to create an appropriate Audio Engine" << llendl;
static bool already_precached = false;
if(already_precached)
return;
}
LLVector3d lpos_global = gAgentCamera.getCameraPositionGlobal();
LLVector3 lpos_global_f;
already_precached = true;
lpos_global_f.setVec(lpos_global);
gAudiop->setListener(lpos_global_f,
LLVector3::zero, // LLViewerCamera::getInstance()->getVelocity(), // !!! BUG need to replace this with smoothed velocity!
LLViewerCamera::getInstance()->getUpAxis(),
LLViewerCamera::getInstance()->getAtAxis());
// load up our initial set of sounds we'll want so they're in memory and ready to be played
BOOL mute_audio = gSavedSettings.getBOOL("MuteAudio");
if (!mute_audio && FALSE == gSavedSettings.getBOOL("NoPreload"))
// load up our initial set of sounds we'll want so they're in memory and ready to be played
if (gAudiop && !gSavedSettings.getBOOL("MuteAudio") && !gSavedSettings.getBOOL("NoPreload"))
{
gAudiop->preloadSound(LLUUID(gSavedSettings.getString("UISndAlert")));
gAudiop->preloadSound(LLUUID(gSavedSettings.getString("UISndBadKeystroke")));
@@ -110,11 +97,9 @@ void init_audio()
gAudiop->preloadSound(LLUUID(gSavedSettings.getString("UISndWindowClose")));
gAudiop->preloadSound(LLUUID(gSavedSettings.getString("UISndWindowOpen")));
}
audio_update_volume(true);
}
void audio_update_volume(bool force_update)
void audio_update_volume( bool wind_fade )
{
static const LLCachedControl<F32> master_volume("AudioLevelMaster",1.0);
static const LLCachedControl<F32> audio_level_sfx("AudioLevelSFX",1.0);
@@ -154,11 +139,6 @@ void audio_update_volume(bool force_update)
gAudiop->setRolloffFactor( audio_level_underwater_rolloff );
gAudiop->setMuted(mute_audio);
if (force_update)
{
audio_update_wind(true);
}
// handle secondary gains
gAudiop->setSecondaryGain(LLAudioEngine::AUDIO_TYPE_SFX,
@@ -167,6 +147,8 @@ void audio_update_volume(bool force_update)
mute_ui ? 0.f : audio_level_ui);
gAudiop->setSecondaryGain(LLAudioEngine::AUDIO_TYPE_AMBIENT,
mute_ambient ? 0.f : audio_level_ambient);
audio_update_wind(wind_fade);
}
// Streaming Music
@@ -217,17 +199,23 @@ void audio_update_listener()
}
}
void audio_update_wind(bool force_update)
void audio_update_wind(bool fade)
{
#ifdef kAUDIO_ENABLE_WIND
if(gAgent.getRegion())
if(gAgent.getRegion() && gAudiop)
{
// Scale down the contribution of weather-simulation wind to the
// ambient wind noise. Wind velocity averages 3.5 m/s, with gusts to 7 m/s
// whereas steady-state avatar walk velocity is only 3.2 m/s.
// Without this the world feels desolate on first login when you are
// standing still.
static LLCachedControl<F32> wind_level("AudioLevelWind", 0.5f);
static LLCachedControl<F32> wind_level("AudioLevelWind", 0.5f);
static LLCachedControl<bool> mute_audio("MuteAudio", false);
static LLCachedControl<bool> mute_ambient("MuteAmbient", false);
static LLCachedControl<F32> audio_level_master("AudioLevelMaster", 1.f);
static LLCachedControl<F32> audio_level_ambient("AudioLevelAmbient", 1.f);
LLVector3 scaled_wind_vec = gWindVec * wind_level;
// Mix in the avatar's motion, subtract because when you walk north,
@@ -240,18 +228,18 @@ void audio_update_wind(bool force_update)
// don't use the setter setMaxWindGain() because we don't
// want to screw up the fade-in on startup by setting actual source gain
// outside the fade-in.
F32 master_volume = gSavedSettings.getBOOL("MuteAudio") ? 0.f : gSavedSettings.getF32("AudioLevelMaster");
F32 ambient_volume = gSavedSettings.getBOOL("MuteAmbient") ? 0.f : gSavedSettings.getF32("AudioLevelAmbient");
F32 master_volume = mute_audio ? 0.f : audio_level_master;
F32 ambient_volume = mute_ambient ? 0.f : audio_level_ambient;
F32 max_wind_volume = master_volume * ambient_volume;
const F32 WIND_SOUND_TRANSITION_TIME = 2.f;
// amount to change volume this frame
F32 volume_delta = (LLFrameTimer::getFrameDeltaTimeF32() / WIND_SOUND_TRANSITION_TIME) * max_wind_volume;
if (force_update)
F32 volume_delta = 1.f;
if(fade)
{
// initialize wind volume (force_update) by using large volume_delta
// which is sufficient to completely turn off or turn on wind noise
volume_delta = 1.f;
// amount to change volume this frame
volume_delta = (LLFrameTimer::getFrameDeltaTimeF32() / WIND_SOUND_TRANSITION_TIME) * max_wind_volume;
}
static LLCachedControl<bool> MuteWind("MuteWind");

View File

@@ -39,9 +39,9 @@
#define kAUDIO_NUM_BUFFERS 30
#define kAUDIO_NUM_SOURCES 30
void init_audio();
void audio_update_volume(bool force_update = true);
void precache_audio();
void audio_update_volume(bool wind_fade = true);
void audio_update_listener();
void audio_update_wind(bool force_update = true);
void audio_update_wind(bool fade);
#endif //LL_VIEWER_H

View File

@@ -355,7 +355,7 @@ static bool handleChatPersistTimeChanged(const LLSD& newvalue)
static void handleAudioVolumeChanged(const LLSD& newvalue)
{
audio_update_volume(true);
audio_update_volume(false);
}
static bool handleJoystickChanged(const LLSD& newvalue)

View File

@@ -5328,8 +5328,6 @@ void process_preload_sound(LLMessageSystem *msg, void **user_data)
LLAudioSource *sourcep = objectp->getAudioSource(owner_id);
if (!sourcep) return;
LLAudioData *datap = gAudiop->getAudioData(sound_id);
// Note that I don't actually do any loading of the
// audio data into a buffer at this point, as it won't actually
// help us out.
@@ -5338,8 +5336,8 @@ void process_preload_sound(LLMessageSystem *msg, void **user_data)
LLVector3d pos_global = objectp->getPositionGlobal();
if (gAgent.canAccessMaturityAtGlobal(pos_global))
{
// Add audioData starts a transfer internally.
sourcep->addAudioData(datap, FALSE);
// Preload starts a transfer internally.
sourcep->preload(sound_id);
}
}

View File

@@ -1432,7 +1432,7 @@ BOOL LLViewerWindow::handleActivate(LLWindow *window, BOOL activated)
}
// Unmute audio
audio_update_volume();
audio_update_volume(false);
}
else
{
@@ -1457,7 +1457,7 @@ BOOL LLViewerWindow::handleActivate(LLWindow *window, BOOL activated)
stopGL();
}
// Mute audio
audio_update_volume();
audio_update_volume(false);
}
return TRUE;
}

View File

@@ -83,6 +83,9 @@ SHFloaterMediaTicker::SHFloaterMediaTicker() : LLFloater()/*, LLSingleton<SHFloa
}
void SHFloaterMediaTicker::updateTickerText() //called via draw.
{
if(!gAudiop)
return;
bool stream_paused = gAudiop->getStreamingAudioImpl()->isPlaying() != 1; //will return 1 if playing.
bool dirty = setPaused(stream_paused);
@@ -119,7 +122,7 @@ void SHFloaterMediaTicker::updateTickerText() //called via draw.
void SHFloaterMediaTicker::drawOscilloscope() //called via draw.
{
if(!mVisualizer || !gAudiop->getStreamingAudioImpl()->supportsWaveData())
if(!gAudiop || !mVisualizer || !gAudiop->getStreamingAudioImpl()->supportsWaveData())
return;
static const S32 NUM_LINE_STRIPS = 64; //How many lines to draw. 64 is more than enough.