Sync up llaudio/llaudioengine_fmodstudio.cpp: Compile now, please?

This commit is contained in:
Lirusaito
2016-03-28 07:50:48 -04:00
parent 89be63603a
commit 48e6e4eb98

View File

@@ -1,5 +1,5 @@
/** /**
* @file audioengine_FMODSTUDIO.cpp * @file audioengine_fmodstudio.cpp
* @brief Implementation of LLAudioEngine class abstracting the audio support as a FMOD 3D implementation * @brief Implementation of LLAudioEngine class abstracting the audio support as a FMOD 3D implementation
* *
* $LicenseInfo:firstyear=2002&license=viewergpl$ * $LicenseInfo:firstyear=2002&license=viewergpl$
@@ -79,7 +79,7 @@ bool attemptDelayLoad()
static bool sVerboseDebugging = false; static bool sVerboseDebugging = false;
FMOD_RESULT F_CALLBACK windCallback(FMOD_DSP_STATE *dsp_state, float *inbuffer, float *outbuffer, unsigned int length, int inchannels, int *outchannels); FMOD_RESULT F_CALLBACK windDSPCallback(FMOD_DSP_STATE *dsp_state, float *inbuffer, float *outbuffer, unsigned int length, int inchannels, int *outchannels);
FMOD::ChannelGroup *LLAudioEngine_FMODSTUDIO::mChannelGroups[LLAudioEngine::AUDIO_TYPE_COUNT] = {0}; FMOD::ChannelGroup *LLAudioEngine_FMODSTUDIO::mChannelGroups[LLAudioEngine::AUDIO_TYPE_COUNT] = {0};
@@ -248,7 +248,6 @@ LLAudioEngine_FMODSTUDIO::~LLAudioEngine_FMODSTUDIO()
{ {
} }
inline bool Check_FMOD_Error(FMOD_RESULT result, const char *string) inline bool Check_FMOD_Error(FMOD_RESULT result, const char *string)
{ {
if(result == FMOD_OK) if(result == FMOD_OK)
@@ -257,28 +256,6 @@ inline bool Check_FMOD_Error(FMOD_RESULT result, const char *string)
return true; return true;
} }
void* F_STDCALL decode_alloc(unsigned int size, FMOD_MEMORY_TYPE type, const char *sourcestr)
{
if(type & FMOD_MEMORY_STREAM_DECODE)
{
LL_INFOS("AudioImpl") << "Decode buffer size: " << size << LL_ENDL;
}
else if(type & FMOD_MEMORY_STREAM_FILE)
{
LL_INFOS("AudioImpl") << "Stream buffer size: " << size << LL_ENDL;
}
return new char[size];
}
void* F_STDCALL decode_realloc(void *ptr, unsigned int size, FMOD_MEMORY_TYPE type, const char *sourcestr)
{
memset(ptr,0,size);
return ptr;
}
void F_STDCALL decode_dealloc(void *ptr, FMOD_MEMORY_TYPE type, const char *sourcestr)
{
delete[] (char*)ptr;
}
bool LLAudioEngine_FMODSTUDIO::init(const S32 num_channels, void* userdata) bool LLAudioEngine_FMODSTUDIO::init(const S32 num_channels, void* userdata)
{ {
LL_WARNS("AudioImpl") << "BARKBARKBARK" << LL_ENDL; LL_WARNS("AudioImpl") << "BARKBARKBARK" << LL_ENDL;
@@ -288,14 +265,11 @@ bool LLAudioEngine_FMODSTUDIO::init(const S32 num_channels, void* userdata)
#endif #endif
U32 version = 0; U32 version = 0;
FMOD_RESULT result; FMOD_RESULT result;
LL_DEBUGS("AppInit") << "LLAudioEngine_FMODSTUDIO::init() initializing FMOD" << LL_ENDL; LL_DEBUGS("AppInit") << "LLAudioEngine_FMODSTUDIO::init() initializing FMOD" << LL_ENDL;
//result = FMOD::Memory_Initialize(NULL, 0, &decode_alloc, &decode_realloc, &decode_dealloc, FMOD_MEMORY_STREAM_DECODE | FMOD_MEMORY_STREAM_FILE);
//if(Check_FMOD_Error(result, "FMOD::Memory_Initialize"))
// return false;
result = FMOD::System_Create(&mSystem); result = FMOD::System_Create(&mSystem);
if(Check_FMOD_Error(result, "FMOD::System_Create")) if(Check_FMOD_Error(result, "FMOD::System_Create"))
return false; return false;
@@ -533,15 +507,16 @@ bool LLAudioEngine_FMODSTUDIO::initWind()
dspdesc.pluginsdkversion = FMOD_PLUGIN_SDK_VERSION; dspdesc.pluginsdkversion = FMOD_PLUGIN_SDK_VERSION;
strncpy(dspdesc.name,"Wind Unit", sizeof(dspdesc.name)); //Set name to "Wind Unit" strncpy(dspdesc.name,"Wind Unit", sizeof(dspdesc.name)); //Set name to "Wind Unit"
dspdesc.numoutputbuffers = 1; dspdesc.numoutputbuffers = 1;
dspdesc.read = &windCallback; //Assign callback. dspdesc.read = &windDSPCallback; //Assign callback.
if (Check_FMOD_Error(mSystem->createDSP(&dspdesc, &mWindDSP), "FMOD::createDSP") || !mWindDSP) if (Check_FMOD_Error(mSystem->createDSP(&dspdesc, &mWindDSP), "FMOD::createDSP") || !mWindDSP)
return false; return false;
int frequency = 44100; int frequency = 44100;
if (!Check_FMOD_Error(mSystem->getSoftwareFormat(&frequency, NULL, NULL), "FMOD::System::getSoftwareFormat")) FMOD_SPEAKERMODE mode;
if (!Check_FMOD_Error(mSystem->getSoftwareFormat(&frequency, &mode, NULL), "FMOD::System::getSoftwareFormat"))
{ {
mWindGen = new LLWindGen<MIXBUFFERFORMAT>((U32)frequency); mWindGen = new LLWindGen<MIXBUFFERFORMAT>((U32)frequency);
FMOD_SPEAKERMODE mode;
if (!Check_FMOD_Error(mWindDSP->setUserData((void*)mWindGen), "FMOD::DSP::setUserData") && 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->playDSP(mWindDSP, NULL, false, 0), "FMOD::System::playDSP") &&
!Check_FMOD_Error(mSystem->getSoftwareFormat(NULL, &mode, NULL), "FMOD::System::getSoftwareFormat") && !Check_FMOD_Error(mSystem->getSoftwareFormat(NULL, &mode, NULL), "FMOD::System::getSoftwareFormat") &&
@@ -686,6 +661,7 @@ bool LLAudioChannelFMODSTUDIO::updateBuffer()
return false; return false;
} }
// Actually play the sound. Start it off paused so we can do all the necessary // Actually play the sound. Start it off paused so we can do all the necessary
// setup. // setup.
if(!mChannelp) if(!mChannelp)
@@ -924,8 +900,7 @@ bool LLAudioBufferFMODSTUDIO::loadWAV(const std::string& filename)
} }
FMOD_MODE base_mode = FMOD_LOOP_NORMAL; FMOD_MODE base_mode = FMOD_LOOP_NORMAL;
FMOD_CREATESOUNDEXINFO exinfo; FMOD_CREATESOUNDEXINFO exinfo = {0};
memset(&exinfo,0,sizeof(exinfo));
exinfo.cbsize = sizeof(exinfo); exinfo.cbsize = sizeof(exinfo);
exinfo.suggestedsoundtype = FMOD_SOUND_TYPE_WAV; //Hint to speed up loading. exinfo.suggestedsoundtype = FMOD_SOUND_TYPE_WAV; //Hint to speed up loading.
// Load up the wav file into an fmod sample // Load up the wav file into an fmod sample
@@ -983,7 +958,7 @@ void LLAudioChannelFMODSTUDIO::set3DMode(bool use3d)
} }
FMOD_RESULT F_CALLBACK windCallback(FMOD_DSP_STATE *dsp_state, float *inbuffer, float *outbuffer, unsigned int length, int inchannels, int *outchannels) FMOD_RESULT F_CALLBACK windDSPCallback(FMOD_DSP_STATE *dsp_state, float *inbuffer, float *outbuffer, unsigned int length, int inchannels, int *outchannels)
{ {
// inbuffer = incomming data. // inbuffer = incomming data.
// newbuffer = outgoing data. AKA this DSP's output. // newbuffer = outgoing data. AKA this DSP's output.