diff --git a/indra/llaudio/llaudiodecodemgr.cpp b/indra/llaudio/llaudiodecodemgr.cpp index 18635737b..5f5696e37 100644 --- a/indra/llaudio/llaudiodecodemgr.cpp +++ b/indra/llaudio/llaudiodecodemgr.cpp @@ -33,7 +33,6 @@ #include "llaudiodecodemgr.h" -#include "llvorbisdecode.h" #include "llaudioengine.h" #include "lllfsthread.h" #include "llvfile.h" @@ -43,10 +42,12 @@ #include "llassetstorage.h" #include "llrefcount.h" +#include "llvorbisencode.h" + #include "vorbis/codec.h" #include "vorbis/vorbisfile.h" -#include "llvorbisencode.h" -#include //VS2010 +#include +#include extern LLAudioEngine *gAudiop; @@ -120,7 +121,7 @@ size_t vfs_read(void *ptr, size_t size, size_t nmemb, void *datasource) } } -int vfs_seek(void *datasource, ogg_int64_t offset, int whence) +S32 vfs_seek(void *datasource, ogg_int64_t offset, S32 whence) { LLVFile *file = (LLVFile *)datasource; @@ -142,7 +143,7 @@ int vfs_seek(void *datasource, ogg_int64_t offset, int whence) origin = -1; break; default: - LL_ERRS() << "Invalid whence argument to vfs_seek" << LL_ENDL; + LL_ERRS("AudioEngine") << "Invalid whence argument to vfs_seek" << LL_ENDL; return -1; } @@ -156,7 +157,7 @@ int vfs_seek(void *datasource, ogg_int64_t offset, int whence) } } -int vfs_close (void *datasource) +S32 vfs_close (void *datasource) { LLVFile *file = (LLVFile *)datasource; delete file; @@ -196,25 +197,25 @@ BOOL LLVorbisDecodeState::initDecode() vfs_callbacks.close_func = vfs_close; vfs_callbacks.tell_func = vfs_tell; - //LL_INFOS() << "Initing decode from vfile: " << mUUID << LL_ENDL; + LL_DEBUGS("AudioEngine") << "Initing decode from vfile: " << mUUID << LL_ENDL; mInFilep = new LLVFile(gVFS, mUUID, LLAssetType::AT_SOUND); if (!mInFilep || !mInFilep->getSize()) { - LL_WARNS() << "unable to open vorbis source vfile for reading" << LL_ENDL; + LL_WARNS("AudioEngine") << "unable to open vorbis source vfile for reading" << LL_ENDL; delete mInFilep; mInFilep = NULL; return FALSE; } - int r = ov_open_callbacks(mInFilep, &mVF, NULL, 0, vfs_callbacks); + S32 r = ov_open_callbacks(mInFilep, &mVF, NULL, 0, vfs_callbacks); if(r < 0) { - LL_WARNS() << r << " Input to vorbis decode does not appear to be an Ogg bitstream: " << mUUID << LL_ENDL; + LL_WARNS("AudioEngine") << r << " Input to vorbis decode does not appear to be an Ogg bitstream: " << mUUID << LL_ENDL; return(FALSE); } - S32 sample_count = ov_pcm_total(&mVF, -1); + S32 sample_count = (S32)ov_pcm_total(&mVF, -1); size_t size_guess = (size_t)sample_count; vorbis_info* vi = ov_info(&mVF, -1); size_guess *= (vi? vi->channels : 1); @@ -228,13 +229,13 @@ BOOL LLVorbisDecodeState::initDecode() if( vi->channels < 1 || vi->channels > LLVORBIS_CLIP_MAX_CHANNELS ) { abort_decode = true; - LL_WARNS() << "Bad channel count: " << vi->channels << LL_ENDL; + LL_WARNS("AudioEngine") << "Bad channel count: " << vi->channels << LL_ENDL; } } else // !vi { abort_decode = true; - LL_WARNS() << "No default bitstream found" << LL_ENDL; + LL_WARNS("AudioEngine") << "No default bitstream found" << LL_ENDL; } // // This magic value is equivalent to 150MiB of data. @@ -252,25 +253,25 @@ BOOL LLVorbisDecodeState::initDecode() (size_t)sample_count <= 0) { abort_decode = true; - LL_WARNS() << "Illegal sample count: " << sample_count << LL_ENDL; + LL_WARNS("AudioEngine") << "Illegal sample count: " << sample_count << LL_ENDL; } if( size_guess > LLVORBIS_CLIP_REJECT_SIZE || size_guess < 0) { abort_decode = true; - LL_WARNS() << "Illegal sample size: " << size_guess << LL_ENDL; + LL_WARNS("AudioEngine") << "Illegal sample size: " << size_guess << LL_ENDL; } // } // if( abort_decode ) { - LL_WARNS() << "Canceling initDecode. Bad asset: " << mUUID << LL_ENDL; + LL_WARNS("AudioEngine") << "Canceling initDecode. Bad asset: " << mUUID << LL_ENDL; vorbis_comment* comment = ov_comment(&mVF,-1); if (comment && comment->vendor) { - LL_WARNS() << "Bad asset encoded by: " << comment->vendor << LL_ENDL; + LL_WARNS("AudioEngine") << "Bad asset encoded by: " << comment->vendor << LL_ENDL; } delete mInFilep; mInFilep = NULL; @@ -388,7 +389,7 @@ BOOL LLVorbisDecodeState::decodeSection() { if (!mInFilep) { - LL_WARNS() << "No VFS file to decode in vorbis!" << LL_ENDL; + LL_WARNS("AudioEngine") << "No VFS file to decode in vorbis!" << LL_ENDL; return TRUE; } if (mDone) @@ -413,7 +414,7 @@ BOOL LLVorbisDecodeState::decodeSection() /* error in the stream. Not a problem, just reporting it in case we (the app) cares. In this case, we don't. */ - LL_WARNS() << "BAD vorbis decode in decodeSection." << LL_ENDL; + LL_WARNS("AudioEngine") << "BAD vorbis decode in decodeSection." << LL_ENDL; mValid = FALSE; mDone = TRUE; @@ -434,7 +435,7 @@ BOOL LLVorbisDecodeState::finishDecode() { if (!isValid()) { - LL_WARNS() << "Bogus vorbis decode state for " << getUUID() << ", aborting!" << LL_ENDL; + LL_WARNS("AudioEngine") << "Bogus vorbis decode state for " << getUUID() << ", aborting!" << LL_ENDL; return TRUE; // We've finished } @@ -515,7 +516,7 @@ BOOL LLVorbisDecodeState::finishDecode() if (36 == data_length) { - LL_WARNS() << "BAD Vorbis decode in finishDecode!" << LL_ENDL; + LL_WARNS("AudioEngine") << "BAD Vorbis decode in finishDecode!" << LL_ENDL; mValid = FALSE; return TRUE; // we've finished } @@ -532,7 +533,7 @@ BOOL LLVorbisDecodeState::finishDecode() { if (mBytesRead == 0) { - LL_WARNS() << "Unable to write file in LLVorbisDecodeState::finishDecode" << LL_ENDL; + LL_WARNS("AudioEngine") << "Unable to write file in LLVorbisDecodeState::finishDecode" << LL_ENDL; mValid = FALSE; return TRUE; // we've finished } @@ -550,7 +551,7 @@ BOOL LLVorbisDecodeState::finishDecode() LLVFile output(gVFS, mUUID, LLAssetType::AT_SOUND_WAV); output.write(&mWAVBuffer[0], mWAVBuffer.size()); #endif - //LL_INFOS() << "Finished decode for " << getUUID() << LL_ENDL; + LL_DEBUGS("AudioEngine") << "Finished decode for " << getUUID() << LL_ENDL; return TRUE; } @@ -559,7 +560,7 @@ void LLVorbisDecodeState::flushBadFile() { if (mInFilep) { - LL_WARNS() << "Flushing bad vorbis file from VFS for " << mUUID << LL_ENDL; + LL_WARNS("AudioEngine") << "Flushing bad vorbis file from VFS for " << mUUID << LL_ENDL; mInFilep->remove(); } } @@ -576,7 +577,7 @@ public: void processQueue(const F32 num_secs = 0.005); protected: - LLLinkedQueue mDecodeQueue; + std::deque mDecodeQueue; LLPointer mCurrentDecodep; }; @@ -608,12 +609,16 @@ void LLAudioDecodeMgr::Impl::processQueue(const F32 num_secs) if (mCurrentDecodep->isDone() && !mCurrentDecodep->isValid()) { // We had an error when decoding, abort. - LL_WARNS() << mCurrentDecodep->getUUID() << " has invalid vorbis data, aborting decode" << LL_ENDL; + LL_WARNS("AudioEngine") << mCurrentDecodep->getUUID() << " has invalid vorbis data, aborting decode" << LL_ENDL; mCurrentDecodep->flushBadFile(); - LLAudioData *adp = gAudiop->getAudioData(mCurrentDecodep->getUUID()); - if(adp) + + if (gAudiop) { - adp->setLoadState(LLAudioData::STATE_LOAD_ERROR); + LLAudioData *adp = gAudiop->getAudioData(mCurrentDecodep->getUUID()); + if(adp) + { + adp->setLoadState(LLAudioData::STATE_LOAD_ERROR); + } } mCurrentDecodep = NULL; done = TRUE; @@ -626,13 +631,13 @@ void LLAudioDecodeMgr::Impl::processQueue(const F32 num_secs) } else if (mCurrentDecodep) { - if (mCurrentDecodep->finishDecode()) + if (gAudiop && mCurrentDecodep->finishDecode()) { // We finished! LLAudioData *adp = gAudiop->getAudioData(mCurrentDecodep->getUUID()); if (!adp) { - LL_WARNS() << "Missing LLAudioData for decode of " << mCurrentDecodep->getUUID() << LL_ENDL; + LL_WARNS("AudioEngine") << "Missing LLAudioData for decode of " << mCurrentDecodep->getUUID() << LL_ENDL; } else if (mCurrentDecodep->isValid() && mCurrentDecodep->isDone()) { @@ -645,7 +650,7 @@ void LLAudioDecodeMgr::Impl::processQueue(const F32 num_secs) else { adp->setLoadState(LLAudioData::STATE_LOAD_ERROR); - LL_INFOS() << "Vorbis decode failed for " << mCurrentDecodep->getUUID() << LL_ENDL; + LL_INFOS("AudioEngine") << "Vorbis decode failed for " << mCurrentDecodep->getUUID() << LL_ENDL; } mCurrentDecodep = NULL; } @@ -655,7 +660,7 @@ void LLAudioDecodeMgr::Impl::processQueue(const F32 num_secs) if (!done) { - if (!mDecodeQueue.getLength()) + if (mDecodeQueue.empty()) { // Nothing else on the queue. done = TRUE; @@ -663,8 +668,9 @@ void LLAudioDecodeMgr::Impl::processQueue(const F32 num_secs) else { LLUUID uuid; - mDecodeQueue.pop(uuid); - if (gAudiop->hasDecodedFile(uuid)) + uuid = mDecodeQueue.front(); + mDecodeQueue.pop_front(); + if (!gAudiop || gAudiop->hasDecodedFile(uuid)) { // This file has already been decoded, don't decode it again. continue; @@ -715,11 +721,26 @@ void LLAudioDecodeMgr::processQueue(const F32 num_secs) bool LLAudioDecodeMgr::addDecodeRequest(const LLUUID &uuid) { - if(!uuid.notNull()) - return false; - else if (!gAssetStorage || !gAssetStorage->hasLocalAsset(uuid, LLAssetType::AT_SOUND)) - return false; - - mImpl->mDecodeQueue.push(uuid); - return true; + if(uuid.isNull()) + { + return true; + } + + if (gAudiop && gAudiop->hasDecodedFile(uuid)) + { + // Already have a decoded version, don't need to decode it. + LL_DEBUGS("AudioEngine") << "addDecodeRequest for " << uuid << " has decoded file already" << LL_ENDL; + return true; + } + + if (gAssetStorage && gAssetStorage->hasLocalAsset(uuid, LLAssetType::AT_SOUND)) + { + // Just put it on the decode queue. + LL_DEBUGS("AudioEngine") << "addDecodeRequest for " << uuid << " has local asset file already" << LL_ENDL; + mImpl->mDecodeQueue.push_back(uuid); + return true; + } + + LL_DEBUGS("AudioEngine") << "addDecodeRequest for " << uuid << " no file available" << LL_ENDL; + return false; } diff --git a/indra/llaudio/llaudiodecodemgr.h b/indra/llaudio/llaudiodecodemgr.h index 3ff894dba..e2319a32f 100644 --- a/indra/llaudio/llaudiodecodemgr.h +++ b/indra/llaudio/llaudiodecodemgr.h @@ -28,7 +28,6 @@ #include "stdtypes.h" -#include "lllinkedqueue.h" #include "lluuid.h" #include "llassettype.h" diff --git a/indra/llaudio/llaudioengine.cpp b/indra/llaudio/llaudioengine.cpp index 99e151f12..61aa25be1 100644 --- a/indra/llaudio/llaudioengine.cpp +++ b/indra/llaudio/llaudioengine.cpp @@ -1046,8 +1046,12 @@ void LLAudioEngine::cleanupAudioSource(LLAudioSource *asp) LL_WARNS("AudioEngine") << "Cleaning up unknown audio source!" << LL_ENDL; return; } - delete asp; - mAllSources.erase(iter); + else + { + LL_DEBUGS("AudioEngine") << "Cleaning up audio sources for "<< asp->getID() <createDSP(&dspdesc, &mWindDSP), "FMOD::createDSP") || !mWindDSP) + mWindDSPDesc = new FMOD_DSP_DESCRIPTION(); + memset(mWindDSPDesc, 0, sizeof(*mWindDSPDesc)); //Set everything to zero + mWindDSPDesc->pluginsdkversion = FMOD_PLUGIN_SDK_VERSION; + strncpy(mWindDSPDesc->name, "Wind Unit", sizeof(mWindDSPDesc->name)); //Set name to "Wind Unit" + mWindDSPDesc->numoutputbuffers = 1; + mWindDSPDesc->read = &windDSPCallback; //Assign callback. + if (Check_FMOD_Error(mSystem->createDSP(mWindDSPDesc, &mWindDSP), "FMOD::createDSP") || !mWindDSP) return false; int frequency = 44100; @@ -518,9 +517,9 @@ bool LLAudioEngine_FMODSTUDIO::initWind() mWindGen = new LLWindGen((U32)frequency); if (!Check_FMOD_Error(mWindDSP->setUserData((void*)mWindGen), "FMOD::DSP::setUserData") && - !Check_FMOD_Error(mSystem->playDSP(mWindDSP, NULL, false, 0), "FMOD::System::playDSP") && !Check_FMOD_Error(mSystem->getSoftwareFormat(NULL, &mode, NULL), "FMOD::System::getSoftwareFormat") && - !Check_FMOD_Error(mWindDSP->setChannelFormat(FMOD_CHANNELMASK_STEREO, 2, mode), "FMOD::DSP::setChannelFormat")) + !Check_FMOD_Error(mWindDSP->setChannelFormat(FMOD_CHANNELMASK_STEREO, 2, mode), "FMOD::DSP::setChannelFormat") && + !Check_FMOD_Error(mSystem->playDSP(mWindDSP, NULL, false, 0), "FMOD::System::playDSP")) return true; //Success } @@ -540,6 +539,9 @@ void LLAudioEngine_FMODSTUDIO::cleanupWind() mWindDSP = NULL; } + delete mWindDSPDesc; + mWindDSPDesc = NULL; + delete mWindGen; mWindGen = NULL; } @@ -885,7 +887,7 @@ bool LLAudioBufferFMODSTUDIO::loadWAV(const std::string& filename) return false; } - if (!LLAPRFile::isExist(filename, LL_APR_RPB)) + if (!gDirUtilp->fileExists(filename)) { // File not found, abort. return false; diff --git a/indra/llaudio/llaudioengine_fmodstudio.h b/indra/llaudio/llaudioengine_fmodstudio.h index 730a702a1..ff45d3ecb 100644 --- a/indra/llaudio/llaudioengine_fmodstudio.h +++ b/indra/llaudio/llaudioengine_fmodstudio.h @@ -48,6 +48,7 @@ namespace FMOD class Sound; class DSP; } +typedef struct FMOD_DSP_DESCRIPTION FMOD_DSP_DESCRIPTION; //Interfaces class LLAudioEngine_FMODSTUDIO : public LLAudioEngine @@ -81,6 +82,7 @@ protected: LLWindGen *mWindGen; + FMOD_DSP_DESCRIPTION *mWindDSPDesc; FMOD::DSP *mWindDSP; FMOD::System *mSystem; bool mEnableProfiler; diff --git a/indra/llaudio/lllistener.cpp b/indra/llaudio/lllistener.cpp index df2366c8c..0723fdbeb 100644 --- a/indra/llaudio/lllistener.cpp +++ b/indra/llaudio/lllistener.cpp @@ -28,15 +28,18 @@ #include "lllistener.h" -#define DEFAULT_AT 0.0f,0.0f,-1.0f -#define DEFAULT_UP 0.0f,1.0f,0.0f +const LLVector3 DEFAULT_AT(0.0f, 0.0f, -1.0f); +const LLVector3 DEFAULT_UP(0.0f, 1.0f, 0.0f); //----------------------------------------------------------------------- // constructor //----------------------------------------------------------------------- LLListener::LLListener() + : mPosition(LLVector3::zero), + mListenAt(DEFAULT_AT), + mListenUp(DEFAULT_UP), + mVelocity(LLVector3::zero) { - init(); } //----------------------------------------------------------------------- @@ -44,15 +47,6 @@ LLListener::~LLListener() { } -//----------------------------------------------------------------------- -void LLListener::init(void) -{ - mPosition.zeroVec(); - mListenAt.setVec(DEFAULT_AT); - mListenUp.setVec(DEFAULT_UP); - mVelocity.zeroVec(); -} - //----------------------------------------------------------------------- void LLListener::translate(LLVector3 offset) { @@ -99,9 +93,6 @@ void LLListener::orient(LLVector3 up, LLVector3 at) //----------------------------------------------------------------------- void LLListener::set(LLVector3 pos, LLVector3 vel, LLVector3 up, LLVector3 at) { - mPosition = pos; - mVelocity = vel; - setPosition(pos); setVelocity(vel); orient(up,at); diff --git a/indra/llaudio/lllistener.h b/indra/llaudio/lllistener.h index 41836bf03..11c1ad2ae 100644 --- a/indra/llaudio/lllistener.h +++ b/indra/llaudio/lllistener.h @@ -45,7 +45,6 @@ class LLListener public: LLListener(); virtual ~LLListener(); - virtual void init(); virtual void set(LLVector3 pos, LLVector3 vel, LLVector3 up, LLVector3 at); diff --git a/indra/llaudio/lllistener_fmodstudio.cpp b/indra/llaudio/lllistener_fmodstudio.cpp index e2074ce2d..42d819ef6 100644 --- a/indra/llaudio/lllistener_fmodstudio.cpp +++ b/indra/llaudio/lllistener_fmodstudio.cpp @@ -39,10 +39,12 @@ //----------------------------------------------------------------------- // constructor //----------------------------------------------------------------------- -LLListener_FMODSTUDIO::LLListener_FMODSTUDIO(FMOD::System *system) +LLListener_FMODSTUDIO::LLListener_FMODSTUDIO(FMOD::System *system) + : LLListener(), + mDopplerFactor(1.0f), + mRolloffFactor(1.0f) { mSystem = system; - init(); } //----------------------------------------------------------------------- @@ -50,21 +52,12 @@ LLListener_FMODSTUDIO::~LLListener_FMODSTUDIO() { } -//----------------------------------------------------------------------- -void LLListener_FMODSTUDIO::init(void) -{ - // do inherited - LLListener::init(); - mDopplerFactor = 1.0f; - mRolloffFactor = 1.0f; -} - //----------------------------------------------------------------------- void LLListener_FMODSTUDIO::translate(LLVector3 offset) { LLListener::translate(offset); - mSystem->set3DListenerAttributes(0, (FMOD_VECTOR*)mPosition.mV, NULL, (FMOD_VECTOR*)mListenAt.mV, (FMOD_VECTOR*)mListenUp.mV); + mSystem->set3DListenerAttributes(0, (FMOD_VECTOR*)mPosition.mV, NULL, NULL, NULL); } //----------------------------------------------------------------------- @@ -72,7 +65,7 @@ void LLListener_FMODSTUDIO::setPosition(LLVector3 pos) { LLListener::setPosition(pos); - mSystem->set3DListenerAttributes(0, (FMOD_VECTOR*)mPosition.mV, NULL, (FMOD_VECTOR*)mListenAt.mV, (FMOD_VECTOR*)mListenUp.mV); + mSystem->set3DListenerAttributes(0, (FMOD_VECTOR*)mPosition.mV, NULL, NULL, NULL); } //----------------------------------------------------------------------- @@ -80,7 +73,7 @@ void LLListener_FMODSTUDIO::setVelocity(LLVector3 vel) { LLListener::setVelocity(vel); - mSystem->set3DListenerAttributes(0, NULL, (FMOD_VECTOR*)mVelocity.mV, (FMOD_VECTOR*)mListenAt.mV, (FMOD_VECTOR*)mListenUp.mV); + mSystem->set3DListenerAttributes(0, NULL, (FMOD_VECTOR*)mVelocity.mV, NULL, NULL); } //----------------------------------------------------------------------- @@ -94,20 +87,25 @@ void LLListener_FMODSTUDIO::orient(LLVector3 up, LLVector3 at) //----------------------------------------------------------------------- void LLListener_FMODSTUDIO::commitDeferredChanges() { + if(!mSystem) + { + return; + } + mSystem->update(); } void LLListener_FMODSTUDIO::setRolloffFactor(F32 factor) { - //An internal FMODEx optimization skips 3D updates if there have not been changes to the 3D sound environment. + //An internal FMOD Studio optimization skips 3D updates if there have not been changes to the 3D sound environment. //Sadly, a change in rolloff is not accounted for, thus we must touch the listener properties as well. - //In short: Changing the position ticks a dirtyflag inside fmodstudio, which makes it not skip 3D processing next update call. + //In short: Changing the position ticks a dirtyflag inside fmod studio, which makes it not skip 3D processing next update call. if(mRolloffFactor != factor) { - LLVector3 pos = mVelocity - LLVector3(0.f,0.f,.1f); - mSystem->set3DListenerAttributes(0, (FMOD_VECTOR*)pos.mV, NULL, NULL, NULL); - mSystem->set3DListenerAttributes(0, (FMOD_VECTOR*)mVelocity.mV, NULL, NULL, NULL); + LLVector3 tmp_pos = mPosition - LLVector3(0.f,0.f,.1f); + mSystem->set3DListenerAttributes(0, (FMOD_VECTOR*) tmp_pos.mV, NULL, NULL, NULL); + mSystem->set3DListenerAttributes(0, (FMOD_VECTOR*) mPosition.mV, NULL, NULL, NULL); } mRolloffFactor = factor; mSystem->set3DSettings(mDopplerFactor, 1.f, mRolloffFactor); diff --git a/indra/llaudio/lllistener_fmodstudio.h b/indra/llaudio/lllistener_fmodstudio.h index 516f4eae8..de9a5e9ca 100644 --- a/indra/llaudio/lllistener_fmodstudio.h +++ b/indra/llaudio/lllistener_fmodstudio.h @@ -48,7 +48,6 @@ class LLListener_FMODSTUDIO : public LLListener public: LLListener_FMODSTUDIO(FMOD::System *system); virtual ~LLListener_FMODSTUDIO(); - virtual void init(); virtual void translate(LLVector3 offset); virtual void setPosition(LLVector3 pos); diff --git a/indra/llaudio/lllistener_openal.cpp b/indra/llaudio/lllistener_openal.cpp index 462484e33..d1734a930 100644 --- a/indra/llaudio/lllistener_openal.cpp +++ b/indra/llaudio/lllistener_openal.cpp @@ -31,21 +31,15 @@ #include "lllistener_openal.h" LLListener_OpenAL::LLListener_OpenAL() + : LLListener(), + mRolloffFactor(1.f) { - init(); } LLListener_OpenAL::~LLListener_OpenAL() { } -void LLListener_OpenAL::init() -{ - // do inherited - LLListener::init(); - mRolloffFactor = 1.0f; -} - void LLListener_OpenAL::translate(LLVector3 offset) { //LL_INFOS() << "LLListener_OpenAL::translate() : " << offset << LL_ENDL; @@ -71,18 +65,20 @@ void LLListener_OpenAL::orient(LLVector3 up, LLVector3 at) void LLListener_OpenAL::commitDeferredChanges() { - ALfloat orientation[6]; - orientation[0] = mListenAt.mV[0]; - orientation[1] = mListenAt.mV[1]; - orientation[2] = mListenAt.mV[2]; - orientation[3] = mListenUp.mV[0]; - orientation[4] = mListenUp.mV[1]; - orientation[5] = mListenUp.mV[2]; + ALfloat orientation[] = { + mListenAt.mV[0], + mListenAt.mV[1], + mListenAt.mV[2], + mListenUp.mV[0], + mListenUp.mV[1], + mListenUp.mV[2], + }; - ALfloat velocity[3]; - velocity[0] = mVelocity.mV[0]; - velocity[1] = mVelocity.mV[1]; - velocity[2] = mVelocity.mV[2]; + ALfloat velocity[3] = { + mVelocity.mV[0], + mVelocity.mV[1], + mVelocity.mV[2], + }; alListenerfv(AL_ORIENTATION, orientation); alListenerfv(AL_POSITION, mPosition.mV); diff --git a/indra/llaudio/lllistener_openal.h b/indra/llaudio/lllistener_openal.h index 96af86d99..cb163b11a 100644 --- a/indra/llaudio/lllistener_openal.h +++ b/indra/llaudio/lllistener_openal.h @@ -38,7 +38,6 @@ class LLListener_OpenAL : public LLListener public: LLListener_OpenAL(); virtual ~LLListener_OpenAL(); - virtual void init(); virtual void translate(LLVector3 offset); virtual void setPosition(LLVector3 pos); diff --git a/indra/llaudio/llvorbisencode.cpp b/indra/llaudio/llvorbisencode.cpp index c0c9d6d6b..2e7fdb1db 100644 --- a/indra/llaudio/llvorbisencode.cpp +++ b/indra/llaudio/llvorbisencode.cpp @@ -32,7 +32,6 @@ #include "llerror.h" #include "llrand.h" #include "llmath.h" -#include "llapr.h" //#if LL_DARWIN // MBW -- XXX -- Getting rid of SecondLifeVorbis for now -- no fmod means no name collisions. @@ -81,18 +80,20 @@ S32 check_for_invalid_wav_formats(const std::string& in_fname, std::string& erro error_msg.clear(); - // ******************************** - LLAPRFile infile ; - infile.open(in_fname,LL_APR_RB); - // ******************************** - if (!infile.getFileHandle()) + //******************************** + llifstream instream(in_fname, std::ios::in | std::ios::binary); + //******************************** + if (!instream.is_open()) { error_msg = "CannotUploadSoundFile"; return(LLVORBISENC_SOURCE_OPEN_ERR); } - infile.read(wav_header, 44); - physical_file_size = infile.seek(APR_END,0); + instream.read((char*)wav_header, 44); + + instream.seekg(0, instream.end); + physical_file_size = (U32) instream.tellg(); + instream.seekg(0, instream.beg); if (strncmp((char *)&(wav_header[0]),"RIFF",4)) { @@ -112,8 +113,8 @@ S32 check_for_invalid_wav_formats(const std::string& in_fname, std::string& erro while ((file_pos + 8)< physical_file_size) { - infile.seek(APR_SET,file_pos); - infile.read(wav_header, 44); + instream.seekg(file_pos); + instream.read((char*)wav_header, 44); chunk_length = ((U32) wav_header[7] << 24) + ((U32) wav_header[6] << 16) @@ -122,7 +123,7 @@ S32 check_for_invalid_wav_formats(const std::string& in_fname, std::string& erro if (chunk_length > physical_file_size - file_pos - 4) { - infile.close(); + instream.close(); error_msg = "SoundFileInvalidChunkSize"; return(LLVORBISENC_CHUNK_SIZE_ERR); } @@ -153,9 +154,9 @@ S32 check_for_invalid_wav_formats(const std::string& in_fname, std::string& erro file_pos += (chunk_length + 8); chunk_length = 0; } - // **************** - infile.close(); - // **************** + //**************** + instream.close(); + //**************** if (!uncompressed_pcm) { @@ -233,20 +234,18 @@ S32 encode_vorbis_file(const std::string& in_fname, const std::string& out_fname S32 data_left = 0; - LLAPRFile infile ; - infile.open(in_fname,LL_APR_RB); - if (!infile.getFileHandle()) + llifstream instream(in_fname, std::ios::in | std::ios::binary); + if (!instream.is_open()) { - LL_WARNS() << "Couldn't open temporary ogg file for writing: " << in_fname + LL_WARNS() << "Couldn't open temporary ogg file for reading: " << in_fname << LL_ENDL; return(LLVORBISENC_SOURCE_OPEN_ERR); } - LLAPRFile outfile ; - outfile.open(out_fname,LL_APR_WPB); - if (!outfile.getFileHandle()) + llofstream outstream(out_fname, std::ios::out | std::ios::binary | std::ios::trunc); + if (!outstream.is_open()) { - LL_WARNS() << "Couldn't open upload sound file for reading: " << in_fname + LL_WARNS() << "Couldn't open upload sound file for writing: " << in_fname << LL_ENDL; return(LLVORBISENC_DEST_OPEN_ERR); } @@ -255,10 +254,10 @@ S32 encode_vorbis_file(const std::string& in_fname, const std::string& out_fname U32 chunk_length = 0; U32 file_pos = 12; // start at the first chunk (usually fmt but not always) - while (infile.eof() != APR_EOF) + while (!instream.eof()) { - infile.seek(APR_SET,file_pos); - infile.read(wav_header, 44); + instream.seekg(file_pos); + instream.read((char*)wav_header, 44); chunk_length = ((U32) wav_header[7] << 24) + ((U32) wav_header[6] << 16) @@ -278,7 +277,7 @@ S32 encode_vorbis_file(const std::string& in_fname, const std::string& out_fname } else if (!(strncmp((char *)&(wav_header[0]),"data",4))) { - infile.seek(APR_SET,file_pos+8); + instream.seekg(file_pos + 8); // leave the file pointer at the beginning of the data chunk data data_left = chunk_length; break; @@ -351,8 +350,8 @@ S32 encode_vorbis_file(const std::string& in_fname, const std::string& out_fname while(!eos){ int result=ogg_stream_flush(&os,&og); if(result==0)break; - outfile.write(og.header, og.header_len); - outfile.write(og.body, og.body_len); + outstream.write((char*)og.header, og.header_len); + outstream.write((char*)og.body, og.body_len); } } @@ -362,7 +361,8 @@ S32 encode_vorbis_file(const std::string& in_fname, const std::string& out_fname { long bytes_per_sample = bits_per_sample/8; - long bytes=(long)infile.read(readbuffer,llclamp((S32)(READ_BUFFER*num_channels*bytes_per_sample),0,data_left)); /* stereo hardwired here */ + instream.read((char*)readbuffer, llclamp((S32) (READ_BUFFER*num_channels*bytes_per_sample), 0, data_left)); /* stereo hardwired here */ + long bytes = (long) instream.gcount(); if (bytes==0) { @@ -470,8 +470,8 @@ S32 encode_vorbis_file(const std::string& in_fname, const std::string& out_fname if(result==0) break; - outfile.write(og.header, og.header_len); - outfile.write(og.body, og.body_len); + outstream.write((char*)og.header, og.header_len); + outstream.write((char*)og.body, og.body_len); /* this could be set above, but for illustrative purposes, I do it here (to show that vorbis does know where the stream ends) */