Final FMOD Studio upstream sync before merge
parent
904ee2dd90
commit
4268cc8c21
|
|
@ -118,7 +118,7 @@ void LLAudioEngine::setDefaults()
|
|||
}
|
||||
|
||||
|
||||
bool LLAudioEngine::init(const S32 num_channels, void* userdata)
|
||||
bool LLAudioEngine::init(const S32 num_channels, void* userdata, const std::string &app_title)
|
||||
{
|
||||
setDefaults();
|
||||
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ public:
|
|||
virtual ~LLAudioEngine();
|
||||
|
||||
// initialization/startup/shutdown
|
||||
virtual bool init(const S32 num_channels, void *userdata);
|
||||
virtual bool init(const S32 num_channels, void *userdata, const std::string &app_title);
|
||||
virtual std::string getDriverName(bool verbose) = 0;
|
||||
virtual void shutdown();
|
||||
|
||||
|
|
|
|||
|
|
@ -40,11 +40,10 @@
|
|||
#include "fmodstudio/fmod.hpp"
|
||||
#include "fmodstudio/fmod_errors.h"
|
||||
#include "lldir.h"
|
||||
#include "llapr.h"
|
||||
|
||||
#include "sound_ids.h"
|
||||
|
||||
#include "indra_constants.h"
|
||||
|
||||
const U32 EXTRA_SOUND_CHANNELS = 10;
|
||||
|
||||
FMOD_RESULT F_CALLBACK windCallback(FMOD_DSP_STATE *dsp_state, float *inbuffer, float *outbuffer, unsigned int length, int inchannels, int *outchannels);
|
||||
|
|
@ -153,7 +152,7 @@ LLAudioEngine_FMODSTUDIO::~LLAudioEngine_FMODSTUDIO()
|
|||
// mSystem gets cleaned up at shutdown()
|
||||
}
|
||||
|
||||
bool LLAudioEngine_FMODSTUDIO::init(const S32 num_channels, void* userdata)
|
||||
bool LLAudioEngine_FMODSTUDIO::init(const S32 num_channels, void* userdata, const std::string &app_title)
|
||||
{
|
||||
U32 version;
|
||||
FMOD_RESULT result;
|
||||
|
|
@ -165,7 +164,7 @@ bool LLAudioEngine_FMODSTUDIO::init(const S32 num_channels, void* userdata)
|
|||
return false;
|
||||
|
||||
//will call LLAudioEngine_FMODSTUDIO::allocateListener, which needs a valid mSystem pointer.
|
||||
LLAudioEngine::init(num_channels, userdata);
|
||||
LLAudioEngine::init(num_channels, userdata, app_title);
|
||||
|
||||
result = mSystem->getVersion(&version);
|
||||
Check_FMOD_Error(result, "FMOD::System::getVersion");
|
||||
|
|
@ -176,6 +175,8 @@ bool LLAudioEngine_FMODSTUDIO::init(const S32 num_channels, void* userdata)
|
|||
<< " expected:" << FMOD_VERSION << LL_ENDL;
|
||||
}
|
||||
|
||||
// In case we need to force sampling on stereo, use setSoftwareFormat here
|
||||
|
||||
// In this case, all sounds, PLUS wind and stream will be software.
|
||||
result = mSystem->setSoftwareChannels(num_channels + EXTRA_SOUND_CHANNELS);
|
||||
Check_FMOD_Error(result, "FMOD::System::setSoftwareChannels");
|
||||
|
|
@ -202,6 +203,8 @@ bool LLAudioEngine_FMODSTUDIO::init(const S32 num_channels, void* userdata)
|
|||
result = mSystem->setAdvancedSettings(&settings);
|
||||
Check_FMOD_Error(result, "FMOD::System::setAdvancedSettings");
|
||||
|
||||
// FMOD_INIT_THREAD_UNSAFE Disables thread safety for API calls.
|
||||
// Only use this if FMOD is being called from a single thread, and if Studio API is not being used.
|
||||
U32 fmod_flags = FMOD_INIT_NORMAL | FMOD_INIT_3D_RIGHTHANDED | FMOD_INIT_THREAD_UNSAFE;
|
||||
if (mEnableProfiler)
|
||||
{
|
||||
|
|
@ -218,7 +221,7 @@ bool LLAudioEngine_FMODSTUDIO::init(const S32 num_channels, void* userdata)
|
|||
{
|
||||
LL_DEBUGS("AppInit") << "Trying PulseAudio audio output..." << LL_ENDL;
|
||||
if ((result = mSystem->setOutput(FMOD_OUTPUTTYPE_PULSEAUDIO)) == FMOD_OK &&
|
||||
(result = mSystem->init(num_channels + EXTRA_SOUND_CHANNELS, fmod_flags, const_cast<char*>(APP_NAME.c_str()))) == FMOD_OK)
|
||||
(result = mSystem->init(num_channels + EXTRA_SOUND_CHANNELS, fmod_flags, const_cast<char*>(app_title.c_str()))) == FMOD_OK)
|
||||
{
|
||||
LL_DEBUGS("AppInit") << "PulseAudio output initialized OKAY" << LL_ENDL;
|
||||
audio_ok = true;
|
||||
|
|
@ -454,7 +457,6 @@ bool LLAudioEngine_FMODSTUDIO::initWind()
|
|||
memset(mWindDSPDesc, 0, sizeof(*mWindDSPDesc)); //Set everything to zero
|
||||
strncpy(mWindDSPDesc->name, "Wind Unit", sizeof(mWindDSPDesc->name));
|
||||
mWindDSPDesc->pluginsdkversion = FMOD_PLUGIN_SDK_VERSION;
|
||||
mWindDSPDesc->numoutputbuffers = 1;
|
||||
mWindDSPDesc->read = &windCallback; // Assign callback - may be called from arbitrary threads
|
||||
if (Check_FMOD_Error(mSystem->createDSP(mWindDSPDesc, &mWindDSP), "FMOD::createDSP"))
|
||||
return false;
|
||||
|
|
@ -591,37 +593,46 @@ LLAudioChannelFMODSTUDIO::~LLAudioChannelFMODSTUDIO()
|
|||
|
||||
bool LLAudioChannelFMODSTUDIO::updateBuffer()
|
||||
{
|
||||
if (mCurrentSourcep)
|
||||
if (!mCurrentSourcep)
|
||||
{
|
||||
if (LLAudioChannel::updateBuffer())
|
||||
// This channel isn't associated with any source, nothing
|
||||
// to be updated
|
||||
return false;
|
||||
}
|
||||
|
||||
if (LLAudioChannel::updateBuffer())
|
||||
{
|
||||
// Base class update returned true, which means that we need to actually
|
||||
// set up the channel for a different buffer.
|
||||
|
||||
LLAudioBufferFMODSTUDIO *bufferp = (LLAudioBufferFMODSTUDIO *)mCurrentSourcep->getCurrentBuffer();
|
||||
|
||||
// Grab the FMOD sample associated with the buffer
|
||||
FMOD::Sound *soundp = bufferp->getSound();
|
||||
if (!soundp)
|
||||
{
|
||||
// Base class update returned true, which means that we need to actually
|
||||
// set up the channel for a different buffer.
|
||||
|
||||
LLAudioBufferFMODSTUDIO *bufferp = (LLAudioBufferFMODSTUDIO *) mCurrentSourcep->getCurrentBuffer();
|
||||
|
||||
// Grab the FMOD sample associated with the buffer
|
||||
FMOD::Sound *soundp = bufferp->getSound();
|
||||
if (!soundp)
|
||||
{
|
||||
// This is bad, there should ALWAYS be a sound associated with a legit
|
||||
// buffer.
|
||||
LL_ERRS() << "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)
|
||||
{
|
||||
FMOD_RESULT result = getSystem()->playSound(soundp, nullptr, true, &mChannelp);
|
||||
Check_FMOD_Error(result, "FMOD::System::playSound");
|
||||
}
|
||||
|
||||
//LL_INFOS() << "Setting up channel " << std::hex << mChannelID << std::dec << LL_ENDL;
|
||||
// This is bad, there should ALWAYS be a sound associated with a legit
|
||||
// buffer.
|
||||
LL_ERRS() << "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)
|
||||
{
|
||||
FMOD_RESULT result = getSystem()->playSound(soundp, NULL /*free channel?*/, true, &mChannelp);
|
||||
Check_FMOD_Error(result, "FMOD::System::playSound");
|
||||
}
|
||||
|
||||
// Setting up channel mChannelID
|
||||
}
|
||||
|
||||
// If we have a source for the channel, we need to update its gain.
|
||||
if (mCurrentSourcep)
|
||||
{
|
||||
// SJB: warnings can spam and hurt framerate, disabling
|
||||
//FMOD_RESULT result;
|
||||
|
||||
mChannelp->setVolume(getSecondaryGain() * mCurrentSourcep->getGain());
|
||||
|
|
@ -630,17 +641,12 @@ bool LLAudioChannelFMODSTUDIO::updateBuffer()
|
|||
mChannelp->setMode(mCurrentSourcep->isLoop() ? FMOD_LOOP_NORMAL : FMOD_LOOP_OFF);
|
||||
/*if(Check_FMOD_Error(result, "FMOD::Channel::setMode"))
|
||||
{
|
||||
S32 index;
|
||||
mChannelp->getIndex(&index);
|
||||
LL_WARNS() << "Channel " << index << "Source ID: " << mCurrentSourcep->getID()
|
||||
<< " at " << mCurrentSourcep->getPositionGlobal() << LL_ENDL;
|
||||
S32 index;
|
||||
mChannelp->getIndex(&index);
|
||||
LL_WARNS() << "Channel " << index << "Source ID: " << mCurrentSourcep->getID()
|
||||
<< " at " << mCurrentSourcep->getPositionGlobal() << LL_ENDL;
|
||||
}*/
|
||||
}
|
||||
else
|
||||
{
|
||||
LL_DEBUGS() << "No source buffer!" << LL_ENDL;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -804,7 +810,7 @@ bool LLAudioBufferFMODSTUDIO::loadWAV(const std::string& filename)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!gDirUtilp->fileExists(filename))
|
||||
if (!LLAPRFile::isExist(filename, NULL, LL_APR_RPB))
|
||||
{
|
||||
// File not found, abort.
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ public:
|
|||
virtual ~LLAudioEngine_FMODSTUDIO();
|
||||
|
||||
// initialization/startup/shutdown
|
||||
virtual bool init(const S32 num_channels, void *user_data);
|
||||
virtual bool init(const S32 num_channels, void *user_data, const std::string &app_title);
|
||||
virtual std::string getDriverName(bool verbose);
|
||||
virtual void allocateListener();
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ LLAudioEngine_OpenAL::~LLAudioEngine_OpenAL()
|
|||
}
|
||||
|
||||
// virtual
|
||||
bool LLAudioEngine_OpenAL::init(const S32 num_channels, void* userdata)
|
||||
bool LLAudioEngine_OpenAL::init(const S32 num_channels, void* userdata, const std::string &app_title)
|
||||
{
|
||||
mWindGen = NULL;
|
||||
LLAudioEngine::init(num_channels, userdata);
|
||||
|
|
@ -241,6 +241,13 @@ bool LLAudioChannelOpenAL::isPlaying()
|
|||
|
||||
bool LLAudioChannelOpenAL::updateBuffer()
|
||||
{
|
||||
if (!mCurrentSourcep)
|
||||
{
|
||||
// This channel isn't associated with any source, nothing
|
||||
// to be updated
|
||||
return false;
|
||||
}
|
||||
|
||||
if (LLAudioChannel::updateBuffer())
|
||||
{
|
||||
// Base class update returned true, which means that we need to actually
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ class LLAudioEngine_OpenAL : public LLAudioEngine
|
|||
LLAudioEngine_OpenAL();
|
||||
virtual ~LLAudioEngine_OpenAL();
|
||||
|
||||
virtual bool init(const S32 num_channels, void *user_data);
|
||||
virtual std::string getDriverName(bool verbose);
|
||||
virtual bool init(const S32 num_channels, void *user_data, const std::string &app_title);
|
||||
virtual std::string getDriverName(bool verbose);
|
||||
virtual void allocateListener();
|
||||
|
||||
virtual void shutdown();
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ void LLListener_FMODSTUDIO::translate(LLVector3 offset)
|
|||
{
|
||||
LLListener::translate(offset);
|
||||
|
||||
mSystem->set3DListenerAttributes(0, (FMOD_VECTOR*)mPosition.mV, NULL, NULL, NULL);
|
||||
mSystem->set3DListenerAttributes(0, (FMOD_VECTOR*)mPosition.mV, NULL, (FMOD_VECTOR*)mListenAt.mV, (FMOD_VECTOR*)mListenUp.mV);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
|
@ -66,7 +66,7 @@ void LLListener_FMODSTUDIO::setPosition(LLVector3 pos)
|
|||
{
|
||||
LLListener::setPosition(pos);
|
||||
|
||||
mSystem->set3DListenerAttributes(0, (FMOD_VECTOR*)mPosition.mV, NULL, NULL, NULL);
|
||||
mSystem->set3DListenerAttributes(0, (FMOD_VECTOR*)mPosition.mV, NULL, (FMOD_VECTOR*)mListenAt.mV, (FMOD_VECTOR*)mListenUp.mV);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
|
@ -74,7 +74,7 @@ void LLListener_FMODSTUDIO::setVelocity(LLVector3 vel)
|
|||
{
|
||||
LLListener::setVelocity(vel);
|
||||
|
||||
mSystem->set3DListenerAttributes(0, NULL, (FMOD_VECTOR*)mVelocity.mV, NULL, NULL);
|
||||
mSystem->set3DListenerAttributes(0, NULL, (FMOD_VECTOR*)mVelocity.mV, (FMOD_VECTOR*)mListenAt.mV, (FMOD_VECTOR*)mListenUp.mV);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* @file listener_fmodstudio.h
|
||||
* @brief Description of LISTENER class abstracting the audio support
|
||||
* as an FMOD Studio implementation (windows and Linux)
|
||||
* as an FMOD 3D implementation
|
||||
*
|
||||
* $LicenseInfo:firstyear=2020&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
|
|
|
|||
|
|
@ -1011,7 +1011,7 @@ bool idle_startup()
|
|||
#else
|
||||
void* window_handle = NULL;
|
||||
#endif
|
||||
bool init = gAudiop->init(kAUDIO_NUM_SOURCES, window_handle);
|
||||
bool init = gAudiop->init(kAUDIO_NUM_SOURCES, window_handle, LLAppViewer::instance()->getSecondLifeTitle());
|
||||
if(init)
|
||||
{
|
||||
// <FS:Ansariel> Output device selection
|
||||
|
|
|
|||
Loading…
Reference in New Issue