From aa817c7cb4caad98628543c60eeb34909413dee2 Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Mon, 13 Sep 2010 17:18:52 -0700 Subject: Updated openal device loading and added debug info for startup --- linden/indra/llaudio/llaudioengine_openal.cpp | 69 +++++++++++++++++++++------ linden/indra/llaudio/llaudioengine_openal.h | 29 ++++++----- 2 files changed, 70 insertions(+), 28 deletions(-) (limited to 'linden') diff --git a/linden/indra/llaudio/llaudioengine_openal.cpp b/linden/indra/llaudio/llaudioengine_openal.cpp index 93bc42b..c33b992 100644 --- a/linden/indra/llaudio/llaudioengine_openal.cpp +++ b/linden/indra/llaudio/llaudioengine_openal.cpp @@ -48,7 +48,9 @@ LLAudioEngine_OpenAL::LLAudioEngine_OpenAL() mWindBufSamples(0), mWindBufBytes(0), mWindSource(AL_NONE), - mNumEmptyWindALBuffers(MAX_NUM_WIND_BUFFERS) + mNumEmptyWindALBuffers(MAX_NUM_WIND_BUFFERS), + mContext(NULL), + mDevice(NULL) { } @@ -69,30 +71,63 @@ bool LLAudioEngine_OpenAL::init(const S32 num_channels, void* userdata) return false; } + // check for extensions + if (alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT")) + { + llinfos << "Results for ALC_ENUMERATION_EXT:\n" + << ll_safe_string(alcGetString(NULL, ALC_DEVICE_SPECIFIER)) + << llendl; + } + + // initialize device + ALCdevice* mDevice = alcOpenDevice(NULL); + if (!mDevice) + { + llinfos << "OpenAL could not find an installed audio device. Aborting" << llendl; + ALCenum error = alcGetError(mDevice); + if (error != ALC_NO_ERROR) + { + llinfos << "ALC error:" << ll_safe_string(alcGetString(mDevice, error)) << llendl; + } + return false; + } + + // create context + ALCcontext* mContext = alcCreateContext(mDevice, NULL); + if (mContext != NULL) + { + alcMakeContextCurrent(mContext); + if (alGetError() != AL_NO_ERROR) + { + llinfos << "ALC error:" << alGetError() << ". Could not set current context!" << llendl; + } + } + else + { + llinfos << "ALC error: could not create context from device!" << llendl; + } + llinfos << "LLAudioEngine_OpenAL::init() OpenAL successfully initialized" << llendl; + llinfos << "ALC default device: " + << ll_safe_string(alcGetString(mDevice, ALC_DEFAULT_DEVICE_SPECIFIER)) + << llendl; + llinfos << "OpenAL version: " - << ll_safe_string(alGetString(AL_VERSION)) << llendl; + << ll_safe_string(alGetString(AL_VERSION)) << llendl; llinfos << "OpenAL vendor: " - << ll_safe_string(alGetString(AL_VENDOR)) << llendl; + << ll_safe_string(alGetString(AL_VENDOR)) << llendl; llinfos << "OpenAL renderer: " - << ll_safe_string(alGetString(AL_RENDERER)) << llendl; + << ll_safe_string(alGetString(AL_RENDERER)) << llendl; - ALint major = alutGetMajorVersion (); - ALint minor = alutGetMinorVersion (); + ALint major = alutGetMajorVersion(); + ALint minor = alutGetMinorVersion(); llinfos << "ALUT version: " << major << "." << minor << llendl; - ALCdevice *device = alcGetContextsDevice(alcGetCurrentContext()); - - alcGetIntegerv(device, ALC_MAJOR_VERSION, 1, &major); - alcGetIntegerv(device, ALC_MINOR_VERSION, 1, &minor); + alcGetIntegerv(mDevice, ALC_MAJOR_VERSION, 1, &major); + alcGetIntegerv(mDevice, ALC_MINOR_VERSION, 1, &minor); llinfos << "ALC version: " << major << "." << minor << llendl; - llinfos << "ALC default device: " - << ll_safe_string(alcGetString(device, - ALC_DEFAULT_DEVICE_SPECIFIER)) - << llendl; - return true; } @@ -148,6 +183,10 @@ void LLAudioEngine_OpenAL::shutdown() llwarns << "LLAudioEngine_OpenAL::shutdown() ALUT shutdown failed: " << alutGetErrorString (alutGetError ()) << llendl; } + alcMakeContextCurrent(NULL); + alcDestroyContext(mContext); + alcCloseDevice(mDevice); + llinfos << "LLAudioEngine_OpenAL::shutdown() OpenAL successfully shut down" << llendl; delete mListenerp; diff --git a/linden/indra/llaudio/llaudioengine_openal.h b/linden/indra/llaudio/llaudioengine_openal.h index 900bcb3..9b52b88 100644 --- a/linden/indra/llaudio/llaudioengine_openal.h +++ b/linden/indra/llaudio/llaudioengine_openal.h @@ -47,7 +47,7 @@ class LLAudioEngine_OpenAL : public LLAudioEngine virtual ~LLAudioEngine_OpenAL(); virtual bool init(const S32 num_channels, void *user_data); - virtual std::string getDriverName(bool verbose); + virtual std::string getDriverName(bool verbose); virtual void allocateListener(); virtual void shutdown(); @@ -62,17 +62,20 @@ class LLAudioEngine_OpenAL : public LLAudioEngine /*virtual*/ void updateWind(LLVector3 direction, F32 camera_altitude); private: - void * windDSP(void *newbuffer, int length); - typedef S16 WIND_SAMPLE_T; - LLWindGen *mWindGen; - S16 *mWindBuf; - U32 mWindBufFreq; - U32 mWindBufSamples; - U32 mWindBufBytes; - ALuint mWindSource; - int mNumEmptyWindALBuffers; - - static const int MAX_NUM_WIND_BUFFERS = 80; + void* windDSP(void *newbuffer, int length); + typedef S16 WIND_SAMPLE_T; + LLWindGen* mWindGen; + S16 *mWindBuf; + U32 mWindBufFreq; + U32 mWindBufSamples; + U32 mWindBufBytes; + ALuint mWindSource; + int mNumEmptyWindALBuffers; + + static const int MAX_NUM_WIND_BUFFERS = 80; + + ALCcontext* mContext; + ALCdevice* mDevice; }; class LLAudioChannelOpenAL : public LLAudioChannel @@ -91,7 +94,7 @@ class LLAudioChannelOpenAL : public LLAudioChannel /*virtual*/ void updateLoop(); ALuint mALSource; - ALint mLastSamplePos; + ALint mLastSamplePos; }; class LLAudioBufferOpenAL : public LLAudioBuffer{ -- cgit v1.1