diff options
author | Brad Payne (Vir Linden) <vir@lindenlab.com> | 2021-03-08 13:56:16 +0000 |
---|---|---|
committer | Brad Payne (Vir Linden) <vir@lindenlab.com> | 2021-03-08 13:56:16 +0000 |
commit | c83e740ef94e16ba85574454f3138905edecb029 (patch) | |
tree | 6e10779ff7b2df5194a3df9d100ba28d53883166 /indra/llaudio | |
parent | 2b385841f3031d599bdb226f0f859e51b09870f8 (diff) |
Revert "Merge branch 'master' of https://bitbucket.org/lindenlab/viewer into DRTVWR-519"
This reverts commit e61f485a04dc8c8ac6bcf6a24848359092884d14, reversing
changes made to 00c47d079f7e958e473ed4083a7f7691fa02dcd5.
Diffstat (limited to 'indra/llaudio')
-rw-r--r-- | indra/llaudio/CMakeLists.txt | 6 | ||||
-rw-r--r-- | indra/llaudio/llaudiodecodemgr.cpp | 58 | ||||
-rw-r--r-- | indra/llaudio/llaudiodecodemgr.h | 1 | ||||
-rw-r--r-- | indra/llaudio/llaudioengine.cpp | 15 | ||||
-rw-r--r-- | indra/llaudio/llaudioengine.h | 13 |
5 files changed, 61 insertions, 32 deletions
diff --git a/indra/llaudio/CMakeLists.txt b/indra/llaudio/CMakeLists.txt index 92a5cfe22f..558ede7bf6 100644 --- a/indra/llaudio/CMakeLists.txt +++ b/indra/llaudio/CMakeLists.txt @@ -9,14 +9,14 @@ include(OPENAL) include(LLCommon) include(LLMath) include(LLMessage) -include(LLFileSystem) +include(LLVFS) include_directories( ${LLAUDIO_INCLUDE_DIRS} ${LLCOMMON_INCLUDE_DIRS} ${LLMATH_INCLUDE_DIRS} ${LLMESSAGE_INCLUDE_DIRS} - ${LLFILESYSTEM_INCLUDE_DIRS} + ${LLVFS_INCLUDE_DIRS} ${OGG_INCLUDE_DIRS} ${VORBISENC_INCLUDE_DIRS} ${VORBISFILE_INCLUDE_DIRS} @@ -86,7 +86,7 @@ target_link_libraries( ${LLCOMMON_LIBRARIES} ${LLMATH_LIBRARIES} ${LLMESSAGE_LIBRARIES} - ${LLFILESYSTEM_LIBRARIES} + ${LLVFS_LIBRARIES} ${VORBISENC_LIBRARIES} ${VORBISFILE_LIBRARIES} ${VORBIS_LIBRARIES} diff --git a/indra/llaudio/llaudiodecodemgr.cpp b/indra/llaudio/llaudiodecodemgr.cpp index ff0aa6e76e..e7db84f6ab 100644 --- a/indra/llaudio/llaudiodecodemgr.cpp +++ b/indra/llaudio/llaudiodecodemgr.cpp @@ -29,7 +29,7 @@ #include "llaudioengine.h" #include "lllfsthread.h" -#include "llfilesystem.h" +#include "llvfile.h" #include "llstring.h" #include "lldir.h" #include "llendianswizzle.h" @@ -90,17 +90,19 @@ protected: LLUUID mUUID; std::vector<U8> mWAVBuffer; +#if !defined(USE_WAV_VFILE) std::string mOutFilename; LLLFSThread::handle_t mFileHandle; +#endif - LLFileSystem *mInFilep; + LLVFile *mInFilep; OggVorbis_File mVF; S32 mCurrentSection; }; -size_t cache_read(void *ptr, size_t size, size_t nmemb, void *datasource) +size_t vfs_read(void *ptr, size_t size, size_t nmemb, void *datasource) { - LLFileSystem *file = (LLFileSystem *)datasource; + LLVFile *file = (LLVFile *)datasource; if (file->read((U8*)ptr, (S32)(size * nmemb))) /*Flawfinder: ignore*/ { @@ -113,11 +115,11 @@ size_t cache_read(void *ptr, size_t size, size_t nmemb, void *datasource) } } -S32 cache_seek(void *datasource, ogg_int64_t offset, S32 whence) +S32 vfs_seek(void *datasource, ogg_int64_t offset, S32 whence) { - LLFileSystem *file = (LLFileSystem *)datasource; + LLVFile *file = (LLVFile *)datasource; - // cache has 31-bit files + // vfs has 31-bit files if (offset > S32_MAX) { return -1; @@ -135,7 +137,7 @@ S32 cache_seek(void *datasource, ogg_int64_t offset, S32 whence) origin = -1; break; default: - LL_ERRS("AudioEngine") << "Invalid whence argument to cache_seek" << LL_ENDL; + LL_ERRS("AudioEngine") << "Invalid whence argument to vfs_seek" << LL_ENDL; return -1; } @@ -149,16 +151,16 @@ S32 cache_seek(void *datasource, ogg_int64_t offset, S32 whence) } } -S32 cache_close (void *datasource) +S32 vfs_close (void *datasource) { - LLFileSystem *file = (LLFileSystem *)datasource; + LLVFile *file = (LLVFile *)datasource; delete file; return 0; } -long cache_tell (void *datasource) +long vfs_tell (void *datasource) { - LLFileSystem *file = (LLFileSystem *)datasource; + LLVFile *file = (LLVFile *)datasource; return file->tell(); } @@ -170,10 +172,11 @@ LLVorbisDecodeState::LLVorbisDecodeState(const LLUUID &uuid, const std::string & mUUID = uuid; mInFilep = NULL; mCurrentSection = 0; +#if !defined(USE_WAV_VFILE) mOutFilename = out_filename; mFileHandle = LLLFSThread::nullHandle(); - - // No default value for mVF, it's an ogg structure? +#endif + // No default value for mVF, it's an ogg structure? // Hey, let's zero it anyway, for predictability. memset(&mVF, 0, sizeof(mVF)); } @@ -190,15 +193,15 @@ LLVorbisDecodeState::~LLVorbisDecodeState() BOOL LLVorbisDecodeState::initDecode() { - ov_callbacks cache_callbacks; - cache_callbacks.read_func = cache_read; - cache_callbacks.seek_func = cache_seek; - cache_callbacks.close_func = cache_close; - cache_callbacks.tell_func = cache_tell; + ov_callbacks vfs_callbacks; + vfs_callbacks.read_func = vfs_read; + vfs_callbacks.seek_func = vfs_seek; + vfs_callbacks.close_func = vfs_close; + vfs_callbacks.tell_func = vfs_tell; LL_DEBUGS("AudioEngine") << "Initing decode from vfile: " << mUUID << LL_ENDL; - mInFilep = new LLFileSystem(mUUID, LLAssetType::AT_SOUND); + mInFilep = new LLVFile(gVFS, mUUID, LLAssetType::AT_SOUND); if (!mInFilep || !mInFilep->getSize()) { LL_WARNS("AudioEngine") << "unable to open vorbis source vfile for reading" << LL_ENDL; @@ -207,7 +210,7 @@ BOOL LLVorbisDecodeState::initDecode() return FALSE; } - S32 r = ov_open_callbacks(mInFilep, &mVF, NULL, 0, cache_callbacks); + S32 r = ov_open_callbacks(mInFilep, &mVF, NULL, 0, vfs_callbacks); if(r < 0) { LL_WARNS("AudioEngine") << r << " Input to vorbis decode does not appear to be an Ogg bitstream: " << mUUID << LL_ENDL; @@ -367,7 +370,7 @@ BOOL LLVorbisDecodeState::decodeSection() { if (!mInFilep) { - LL_WARNS("AudioEngine") << "No cache file to decode in vorbis!" << LL_ENDL; + LL_WARNS("AudioEngine") << "No VFS file to decode in vorbis!" << LL_ENDL; return TRUE; } if (mDone) @@ -417,7 +420,9 @@ BOOL LLVorbisDecodeState::finishDecode() return TRUE; // We've finished } +#if !defined(USE_WAV_VFILE) if (mFileHandle == LLLFSThread::nullHandle()) +#endif { ov_clear(&mVF); @@ -490,9 +495,11 @@ BOOL LLVorbisDecodeState::finishDecode() mValid = FALSE; return TRUE; // we've finished } +#if !defined(USE_WAV_VFILE) mBytesRead = -1; mFileHandle = LLLFSThread::sLocal->write(mOutFilename, &mWAVBuffer[0], 0, mWAVBuffer.size(), new WriteResponder(this)); +#endif } if (mFileHandle != LLLFSThread::nullHandle()) @@ -514,6 +521,11 @@ BOOL LLVorbisDecodeState::finishDecode() mDone = TRUE; +#if defined(USE_WAV_VFILE) + // write the data. + LLVFile output(gVFS, mUUID, LLAssetType::AT_SOUND_WAV); + output.write(&mWAVBuffer[0], mWAVBuffer.size()); +#endif LL_DEBUGS("AudioEngine") << "Finished decode for " << getUUID() << LL_ENDL; return TRUE; @@ -523,7 +535,7 @@ void LLVorbisDecodeState::flushBadFile() { if (mInFilep) { - LL_WARNS("AudioEngine") << "Flushing bad vorbis file from cache for " << mUUID << LL_ENDL; + LL_WARNS("AudioEngine") << "Flushing bad vorbis file from VFS for " << mUUID << LL_ENDL; mInFilep->remove(); } } diff --git a/indra/llaudio/llaudiodecodemgr.h b/indra/llaudio/llaudiodecodemgr.h index ceaff3f2d8..8228e20e8c 100644 --- a/indra/llaudio/llaudiodecodemgr.h +++ b/indra/llaudio/llaudiodecodemgr.h @@ -33,6 +33,7 @@ #include "llassettype.h" #include "llframetimer.h" +class LLVFS; class LLVorbisDecodeState; class LLAudioDecodeMgr diff --git a/indra/llaudio/llaudioengine.cpp b/indra/llaudio/llaudioengine.cpp index d35f249973..1d447f32ae 100644 --- a/indra/llaudio/llaudioengine.cpp +++ b/indra/llaudio/llaudioengine.cpp @@ -35,7 +35,7 @@ #include "sound_ids.h" // temporary hack for min/max distances -#include "llfilesystem.h" +#include "llvfs.h" #include "lldir.h" #include "llaudiodecodemgr.h" #include "llassetstorage.h" @@ -684,9 +684,13 @@ bool LLAudioEngine::preloadSound(const LLUUID &uuid) return true; } + // At some point we need to have the audio/asset system check the static VFS + // before it goes off and fetches stuff from the server. + //LL_WARNS() << "Used internal preload for non-local sound" << LL_ENDL; return false; } + bool LLAudioEngine::isWindEnabled() { return mEnableWind; @@ -1014,12 +1018,13 @@ bool LLAudioEngine::hasDecodedFile(const LLUUID &uuid) bool LLAudioEngine::hasLocalFile(const LLUUID &uuid) { - // See if it's in the cache. - bool have_local = LLFileSystem::getExists(uuid, LLAssetType::AT_SOUND); - LL_DEBUGS("AudioEngine") << "sound uuid " << uuid << " exists in cache" << LL_ENDL; + // See if it's in the VFS. + bool have_local = gVFS->getExists(uuid, LLAssetType::AT_SOUND); + LL_DEBUGS("AudioEngine") << "sound uuid "<<uuid<<" exists in VFS"<<LL_ENDL; return have_local; } + void LLAudioEngine::startNextTransfer() { //LL_INFOS() << "LLAudioEngine::startNextTransfer()" << LL_ENDL; @@ -1220,7 +1225,7 @@ void LLAudioEngine::startNextTransfer() // static -void LLAudioEngine::assetCallback(const LLUUID &uuid, LLAssetType::EType type, void *user_data, S32 result_code, LLExtStat ext_status) +void LLAudioEngine::assetCallback(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type, void *user_data, S32 result_code, LLExtStat ext_status) { if (!gAudiop) { diff --git a/indra/llaudio/llaudioengine.h b/indra/llaudio/llaudioengine.h index 577b36d667..97674f15f7 100644 --- a/indra/llaudio/llaudioengine.h +++ b/indra/llaudio/llaudioengine.h @@ -50,6 +50,15 @@ const F32 DEFAULT_MIN_DISTANCE = 2.0f; #define MAX_CHANNELS 30 #define MAX_BUFFERS 40 // Some extra for preloading, maybe? +// This define is intended to allow us to switch from os based wav +// file loading to vfs based wav file loading. The problem is that I +// am unconvinced that the LLWaveFile works for loading sounds from +// memory. So, until that is fixed up, changed, whatever, this remains +// undefined. +//#define USE_WAV_VFILE + +class LLVFS; + class LLAudioSource; class LLAudioData; class LLAudioChannel; @@ -58,9 +67,11 @@ class LLAudioBuffer; class LLStreamingAudioInterface; struct SoundData; + // // LLAudioEngine definition // + class LLAudioEngine { friend class LLAudioChannelOpenAL; // bleh. channel needs some listener methods. @@ -171,7 +182,7 @@ public: // Asset callback when we're retrieved a sound from the asset server. void startNextTransfer(); - static void assetCallback(const LLUUID &uuid, LLAssetType::EType type, void *user_data, S32 result_code, LLExtStat ext_status); + static void assetCallback(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type, void *user_data, S32 result_code, LLExtStat ext_status); friend class LLPipeline; // For debugging public: |