diff options
Diffstat (limited to 'linden/indra/llaudio')
-rw-r--r-- | linden/indra/llaudio/llaudioengine_openal.cpp | 69 | ||||
-rw-r--r-- | linden/indra/llaudio/llaudioengine_openal.h | 29 |
2 files changed, 70 insertions, 28 deletions
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() | |||
48 | mWindBufSamples(0), | 48 | mWindBufSamples(0), |
49 | mWindBufBytes(0), | 49 | mWindBufBytes(0), |
50 | mWindSource(AL_NONE), | 50 | mWindSource(AL_NONE), |
51 | mNumEmptyWindALBuffers(MAX_NUM_WIND_BUFFERS) | 51 | mNumEmptyWindALBuffers(MAX_NUM_WIND_BUFFERS), |
52 | mContext(NULL), | ||
53 | mDevice(NULL) | ||
52 | { | 54 | { |
53 | } | 55 | } |
54 | 56 | ||
@@ -69,30 +71,63 @@ bool LLAudioEngine_OpenAL::init(const S32 num_channels, void* userdata) | |||
69 | return false; | 71 | return false; |
70 | } | 72 | } |
71 | 73 | ||
74 | // check for extensions | ||
75 | if (alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT")) | ||
76 | { | ||
77 | llinfos << "Results for ALC_ENUMERATION_EXT:\n" | ||
78 | << ll_safe_string(alcGetString(NULL, ALC_DEVICE_SPECIFIER)) | ||
79 | << llendl; | ||
80 | } | ||
81 | |||
82 | // initialize device | ||
83 | ALCdevice* mDevice = alcOpenDevice(NULL); | ||
84 | if (!mDevice) | ||
85 | { | ||
86 | llinfos << "OpenAL could not find an installed audio device. Aborting" << llendl; | ||
87 | ALCenum error = alcGetError(mDevice); | ||
88 | if (error != ALC_NO_ERROR) | ||
89 | { | ||
90 | llinfos << "ALC error:" << ll_safe_string(alcGetString(mDevice, error)) << llendl; | ||
91 | } | ||
92 | return false; | ||
93 | } | ||
94 | |||
95 | // create context | ||
96 | ALCcontext* mContext = alcCreateContext(mDevice, NULL); | ||
97 | if (mContext != NULL) | ||
98 | { | ||
99 | alcMakeContextCurrent(mContext); | ||
100 | if (alGetError() != AL_NO_ERROR) | ||
101 | { | ||
102 | llinfos << "ALC error:" << alGetError() << ". Could not set current context!" << llendl; | ||
103 | } | ||
104 | } | ||
105 | else | ||
106 | { | ||
107 | llinfos << "ALC error: could not create context from device!" << llendl; | ||
108 | } | ||
109 | |||
72 | llinfos << "LLAudioEngine_OpenAL::init() OpenAL successfully initialized" << llendl; | 110 | llinfos << "LLAudioEngine_OpenAL::init() OpenAL successfully initialized" << llendl; |
73 | 111 | ||
112 | llinfos << "ALC default device: " | ||
113 | << ll_safe_string(alcGetString(mDevice, ALC_DEFAULT_DEVICE_SPECIFIER)) | ||
114 | << llendl; | ||
115 | |||
74 | llinfos << "OpenAL version: " | 116 | llinfos << "OpenAL version: " |
75 | << ll_safe_string(alGetString(AL_VERSION)) << llendl; | 117 | << ll_safe_string(alGetString(AL_VERSION)) << llendl; |
76 | llinfos << "OpenAL vendor: " | 118 | llinfos << "OpenAL vendor: " |
77 | << ll_safe_string(alGetString(AL_VENDOR)) << llendl; | 119 | << ll_safe_string(alGetString(AL_VENDOR)) << llendl; |
78 | llinfos << "OpenAL renderer: " | 120 | llinfos << "OpenAL renderer: " |
79 | << ll_safe_string(alGetString(AL_RENDERER)) << llendl; | 121 | << ll_safe_string(alGetString(AL_RENDERER)) << llendl; |
80 | 122 | ||
81 | ALint major = alutGetMajorVersion (); | 123 | ALint major = alutGetMajorVersion(); |
82 | ALint minor = alutGetMinorVersion (); | 124 | ALint minor = alutGetMinorVersion(); |
83 | llinfos << "ALUT version: " << major << "." << minor << llendl; | 125 | llinfos << "ALUT version: " << major << "." << minor << llendl; |
84 | 126 | ||
85 | ALCdevice *device = alcGetContextsDevice(alcGetCurrentContext()); | 127 | alcGetIntegerv(mDevice, ALC_MAJOR_VERSION, 1, &major); |
86 | 128 | alcGetIntegerv(mDevice, ALC_MINOR_VERSION, 1, &minor); | |
87 | alcGetIntegerv(device, ALC_MAJOR_VERSION, 1, &major); | ||
88 | alcGetIntegerv(device, ALC_MINOR_VERSION, 1, &minor); | ||
89 | llinfos << "ALC version: " << major << "." << minor << llendl; | 129 | llinfos << "ALC version: " << major << "." << minor << llendl; |
90 | 130 | ||
91 | llinfos << "ALC default device: " | ||
92 | << ll_safe_string(alcGetString(device, | ||
93 | ALC_DEFAULT_DEVICE_SPECIFIER)) | ||
94 | << llendl; | ||
95 | |||
96 | return true; | 131 | return true; |
97 | } | 132 | } |
98 | 133 | ||
@@ -148,6 +183,10 @@ void LLAudioEngine_OpenAL::shutdown() | |||
148 | llwarns << "LLAudioEngine_OpenAL::shutdown() ALUT shutdown failed: " << alutGetErrorString (alutGetError ()) << llendl; | 183 | llwarns << "LLAudioEngine_OpenAL::shutdown() ALUT shutdown failed: " << alutGetErrorString (alutGetError ()) << llendl; |
149 | } | 184 | } |
150 | 185 | ||
186 | alcMakeContextCurrent(NULL); | ||
187 | alcDestroyContext(mContext); | ||
188 | alcCloseDevice(mDevice); | ||
189 | |||
151 | llinfos << "LLAudioEngine_OpenAL::shutdown() OpenAL successfully shut down" << llendl; | 190 | llinfos << "LLAudioEngine_OpenAL::shutdown() OpenAL successfully shut down" << llendl; |
152 | 191 | ||
153 | delete mListenerp; | 192 | 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 | |||
47 | virtual ~LLAudioEngine_OpenAL(); | 47 | virtual ~LLAudioEngine_OpenAL(); |
48 | 48 | ||
49 | virtual bool init(const S32 num_channels, void *user_data); | 49 | virtual bool init(const S32 num_channels, void *user_data); |
50 | virtual std::string getDriverName(bool verbose); | 50 | virtual std::string getDriverName(bool verbose); |
51 | virtual void allocateListener(); | 51 | virtual void allocateListener(); |
52 | 52 | ||
53 | virtual void shutdown(); | 53 | virtual void shutdown(); |
@@ -62,17 +62,20 @@ class LLAudioEngine_OpenAL : public LLAudioEngine | |||
62 | /*virtual*/ void updateWind(LLVector3 direction, F32 camera_altitude); | 62 | /*virtual*/ void updateWind(LLVector3 direction, F32 camera_altitude); |
63 | 63 | ||
64 | private: | 64 | private: |
65 | void * windDSP(void *newbuffer, int length); | 65 | void* windDSP(void *newbuffer, int length); |
66 | typedef S16 WIND_SAMPLE_T; | 66 | typedef S16 WIND_SAMPLE_T; |
67 | LLWindGen<WIND_SAMPLE_T> *mWindGen; | 67 | LLWindGen<WIND_SAMPLE_T>* mWindGen; |
68 | S16 *mWindBuf; | 68 | S16 *mWindBuf; |
69 | U32 mWindBufFreq; | 69 | U32 mWindBufFreq; |
70 | U32 mWindBufSamples; | 70 | U32 mWindBufSamples; |
71 | U32 mWindBufBytes; | 71 | U32 mWindBufBytes; |
72 | ALuint mWindSource; | 72 | ALuint mWindSource; |
73 | int mNumEmptyWindALBuffers; | 73 | int mNumEmptyWindALBuffers; |
74 | 74 | ||
75 | static const int MAX_NUM_WIND_BUFFERS = 80; | 75 | static const int MAX_NUM_WIND_BUFFERS = 80; |
76 | |||
77 | ALCcontext* mContext; | ||
78 | ALCdevice* mDevice; | ||
76 | }; | 79 | }; |
77 | 80 | ||
78 | class LLAudioChannelOpenAL : public LLAudioChannel | 81 | class LLAudioChannelOpenAL : public LLAudioChannel |
@@ -91,7 +94,7 @@ class LLAudioChannelOpenAL : public LLAudioChannel | |||
91 | /*virtual*/ void updateLoop(); | 94 | /*virtual*/ void updateLoop(); |
92 | 95 | ||
93 | ALuint mALSource; | 96 | ALuint mALSource; |
94 | ALint mLastSamplePos; | 97 | ALint mLastSamplePos; |
95 | }; | 98 | }; |
96 | 99 | ||
97 | class LLAudioBufferOpenAL : public LLAudioBuffer{ | 100 | class LLAudioBufferOpenAL : public LLAudioBuffer{ |