diff options
author | Jacek Antonelli | 2009-04-20 23:00:29 -0500 |
---|---|---|
committer | Jacek Antonelli | 2009-04-21 02:45:02 -0500 |
commit | f9cd5b9fbb2b1bee0243e5d9c3dc4cede8549828 (patch) | |
tree | 37c6b56b1058a308070a2ee8e8361ef6f2462549 /linden/indra/llaudio | |
parent | We'll use libopenal.1.dylib after all (yet again). (diff) | |
download | meta-impy-f9cd5b9fbb2b1bee0243e5d9c3dc4cede8549828.zip meta-impy-f9cd5b9fbb2b1bee0243e5d9c3dc4cede8549828.tar.gz meta-impy-f9cd5b9fbb2b1bee0243e5d9c3dc4cede8549828.tar.bz2 meta-impy-f9cd5b9fbb2b1bee0243e5d9c3dc4cede8549828.tar.xz |
Imported GreenLife Emerald Viewer's OpenAL code. It works!
Diffstat (limited to 'linden/indra/llaudio')
-rw-r--r-- | linden/indra/llaudio/audioengine_openal.cpp | 138 | ||||
-rw-r--r-- | linden/indra/llaudio/audioengine_openal.h | 10 |
2 files changed, 87 insertions, 61 deletions
diff --git a/linden/indra/llaudio/audioengine_openal.cpp b/linden/indra/llaudio/audioengine_openal.cpp index 6d9a242..a14b725 100644 --- a/linden/indra/llaudio/audioengine_openal.cpp +++ b/linden/indra/llaudio/audioengine_openal.cpp | |||
@@ -5,7 +5,7 @@ | |||
5 | * | 5 | * |
6 | * $LicenseInfo:firstyear=2002&license=viewergpl$ | 6 | * $LicenseInfo:firstyear=2002&license=viewergpl$ |
7 | * | 7 | * |
8 | * Copyright (c) 2002-2008, Linden Research, Inc. | 8 | * Copyright (c) 2002-2009, Linden Research, Inc. |
9 | * | 9 | * |
10 | * Second Life Viewer Source Code | 10 | * Second Life Viewer Source Code |
11 | * The source code in this file ("Source Code") is provided by Linden Lab | 11 | * The source code in this file ("Source Code") is provided by Linden Lab |
@@ -36,6 +36,7 @@ | |||
36 | #include "audioengine_openal.h" | 36 | #include "audioengine_openal.h" |
37 | #include "listener_openal.h" | 37 | #include "listener_openal.h" |
38 | 38 | ||
39 | |||
39 | LLAudioEngine_OpenAL::LLAudioEngine_OpenAL() | 40 | LLAudioEngine_OpenAL::LLAudioEngine_OpenAL() |
40 | : | 41 | : |
41 | mWindGen(NULL), | 42 | mWindGen(NULL), |
@@ -53,41 +54,67 @@ LLAudioEngine_OpenAL::~LLAudioEngine_OpenAL() | |||
53 | { | 54 | { |
54 | } | 55 | } |
55 | 56 | ||
57 | static ALboolean alutInitHelp(const char **errorstring) | ||
58 | { | ||
59 | ALboolean result = AL_FALSE; | ||
60 | ALenum err = AL_NO_ERROR; | ||
61 | #if LL_WINDOWS | ||
62 | __try { | ||
63 | result = alutInit(NULL, NULL); | ||
64 | err = alutGetError(); | ||
65 | alGetError(); // hit loading of wrap_oal.dll | ||
66 | if(!result) *errorstring = alutGetErrorString(err); | ||
67 | } __except( EXCEPTION_EXECUTE_HANDLER ) { | ||
68 | *errorstring = "[Exception]"; | ||
69 | result = AL_FALSE; | ||
70 | } | ||
71 | return result; | ||
72 | #else | ||
73 | result = alutInit(NULL, NULL); | ||
74 | if(!result) { | ||
75 | err = alutGetError(); | ||
76 | *errorstring = alutGetErrorString(err); | ||
77 | } | ||
78 | return result; | ||
79 | #endif | ||
80 | } | ||
81 | |||
56 | // virtual | 82 | // virtual |
57 | bool LLAudioEngine_OpenAL::init(const S32 num_channels, void* userdata) | 83 | bool LLAudioEngine_OpenAL::init(const S32 num_channels, void* userdata) |
58 | { | 84 | { |
85 | const char *errorstring = "(null)"; | ||
59 | mWindGen = NULL; | 86 | mWindGen = NULL; |
60 | LLAudioEngine::init(num_channels, userdata); | 87 | LLAudioEngine::init(num_channels, userdata); |
61 | 88 | ||
62 | if(!alutInit(NULL, NULL)) | 89 | if(!alutInitHelp(&errorstring)) |
63 | { | 90 | { |
64 | LL_WARNS("OpenAL") << "LLAudioEngine_OpenAL::init() ALUT initialization failed: " << alutGetErrorString (alutGetError ()) << LL_ENDL; | 91 | llwarns << "LLAudioEngine_OpenAL::init() ALUT initialization failed: " << errorstring << llendl; |
65 | return false; | 92 | return false; |
66 | } | 93 | } |
67 | 94 | ||
68 | LL_INFOS("OpenAL") << "LLAudioEngine_OpenAL::init() OpenAL successfully initialized" << LL_ENDL; | 95 | llinfos << "LLAudioEngine_OpenAL::init() OpenAL successfully initialized" << llendl; |
69 | 96 | ||
70 | LL_INFOS("OpenAL") << "OpenAL version: " | 97 | llinfos << "OpenAL version: " |
71 | << ll_safe_string(alGetString(AL_VERSION)) << LL_ENDL; | 98 | << ll_safe_string(alGetString(AL_VERSION)) << llendl; |
72 | LL_INFOS("OpenAL") << "OpenAL vendor: " | 99 | llinfos << "OpenAL vendor: " |
73 | << ll_safe_string(alGetString(AL_VENDOR)) << LL_ENDL; | 100 | << ll_safe_string(alGetString(AL_VENDOR)) << llendl; |
74 | LL_INFOS("OpenAL") << "OpenAL renderer: " | 101 | llinfos << "OpenAL renderer: " |
75 | << ll_safe_string(alGetString(AL_RENDERER)) << LL_ENDL; | 102 | << ll_safe_string(alGetString(AL_RENDERER)) << llendl; |
76 | 103 | ||
77 | ALint major = alutGetMajorVersion (); | 104 | ALint major = alutGetMajorVersion (); |
78 | ALint minor = alutGetMinorVersion (); | 105 | ALint minor = alutGetMinorVersion (); |
79 | LL_INFOS("OpenAL") << "ALUT version: " << major << "." << minor << LL_ENDL; | 106 | llinfos << "ALUT version: " << major << "." << minor << llendl; |
80 | 107 | ||
81 | ALCdevice *device = alcGetContextsDevice(alcGetCurrentContext()); | 108 | ALCdevice *device = alcGetContextsDevice(alcGetCurrentContext()); |
82 | 109 | ||
83 | alcGetIntegerv(device, ALC_MAJOR_VERSION, 1, &major); | 110 | alcGetIntegerv(device, ALC_MAJOR_VERSION, 1, &major); |
84 | alcGetIntegerv(device, ALC_MAJOR_VERSION, 1, &minor); | 111 | alcGetIntegerv(device, ALC_MAJOR_VERSION, 1, &minor); |
85 | LL_INFOS("OpenAL") << "ALC version: " << major << "." << minor << LL_ENDL; | 112 | llinfos << "ALC version: " << major << "." << minor << llendl; |
86 | 113 | ||
87 | LL_INFOS("OpenAL") << "ALC default device: " | 114 | llinfos << "ALC default device: " |
88 | << ll_safe_string(alcGetString(device, | 115 | << ll_safe_string(alcGetString(device, |
89 | ALC_DEFAULT_DEVICE_SPECIFIER)) | 116 | ALC_DEFAULT_DEVICE_SPECIFIER)) |
90 | << LL_ENDL; | 117 | << llendl; |
91 | 118 | ||
92 | return true; | 119 | return true; |
93 | } | 120 | } |
@@ -127,24 +154,24 @@ void LLAudioEngine_OpenAL::allocateListener() | |||
127 | mListenerp = (LLListener *) new LLListener_OpenAL(); | 154 | mListenerp = (LLListener *) new LLListener_OpenAL(); |
128 | if(!mListenerp) | 155 | if(!mListenerp) |
129 | { | 156 | { |
130 | LL_WARNS("OpenAL") << "LLAudioEngine_OpenAL::allocateListener() Listener creation failed" << LL_ENDL; | 157 | llwarns << "LLAudioEngine_OpenAL::allocateListener() Listener creation failed" << llendl; |
131 | } | 158 | } |
132 | } | 159 | } |
133 | 160 | ||
134 | // virtual | 161 | // virtual |
135 | void LLAudioEngine_OpenAL::shutdown() | 162 | void LLAudioEngine_OpenAL::shutdown() |
136 | { | 163 | { |
137 | LL_INFOS("OpenAL") << "About to LLAudioEngine::shutdown()" << LL_ENDL; | 164 | llinfos << "About to LLAudioEngine::shutdown()" << llendl; |
138 | LLAudioEngine::shutdown(); | 165 | LLAudioEngine::shutdown(); |
139 | 166 | ||
140 | LL_INFOS("OpenAL") << "About to alutExit()" << LL_ENDL; | 167 | llinfos << "About to alutExit()" << llendl; |
141 | if(!alutExit()) | 168 | if(!alutExit()) |
142 | { | 169 | { |
143 | LL_WARNS("OpenAL") << "Nuts." << LL_ENDL; | 170 | llwarns << "Nuts." << llendl; |
144 | LL_WARNS("OpenAL") << "LLAudioEngine_OpenAL::shutdown() ALUT shutdown failed: " << alutGetErrorString (alutGetError ()) << LL_ENDL; | 171 | llwarns << "LLAudioEngine_OpenAL::shutdown() ALUT shutdown failed: " << alutGetErrorString (alutGetError ()) << llendl; |
145 | } | 172 | } |
146 | 173 | ||
147 | LL_INFOS("OpenAL") << "LLAudioEngine_OpenAL::shutdown() OpenAL successfully shut down" << LL_ENDL; | 174 | llinfos << "LLAudioEngine_OpenAL::shutdown() OpenAL successfully shut down" << llendl; |
148 | 175 | ||
149 | delete mListenerp; | 176 | delete mListenerp; |
150 | mListenerp = NULL; | 177 | mListenerp = NULL; |
@@ -162,7 +189,7 @@ LLAudioChannel *LLAudioEngine_OpenAL::createChannel() | |||
162 | 189 | ||
163 | void LLAudioEngine_OpenAL::setInternalGain(F32 gain) | 190 | void LLAudioEngine_OpenAL::setInternalGain(F32 gain) |
164 | { | 191 | { |
165 | //LL_INFOS("OpenAL") << "LLAudioEngine_OpenAL::setInternalGain() Gain: " << gain << LL_ENDL; | 192 | //llinfos << "LLAudioEngine_OpenAL::setInternalGain() Gain: " << gain << llendl; |
166 | alListenerf(AL_GAIN, gain); | 193 | alListenerf(AL_GAIN, gain); |
167 | } | 194 | } |
168 | 195 | ||
@@ -172,17 +199,6 @@ LLAudioChannelOpenAL::LLAudioChannelOpenAL() | |||
172 | mLastSamplePos(0) | 199 | mLastSamplePos(0) |
173 | { | 200 | { |
174 | alGenSources(1, &mALSource); | 201 | alGenSources(1, &mALSource); |
175 | |||
176 | if( mALSource == AL_NONE ) | ||
177 | { | ||
178 | ALenum error = alGetError(); | ||
179 | if( error == AL_NO_ERROR ) | ||
180 | { | ||
181 | LL_WARNS("OpenAL") << "LLAudioChannelOpenAL::LLAudioChannelOpenAL() Could not generate mALSource, but no error is indicated!" << LL_ENDL; | ||
182 | } | ||
183 | LL_WARNS("OpenAL") << "LLAudioChannelOpenAL::LLAudioChannelOpenAL() Could not generate mALSource: (" << error << ") " << alGetString( error ) << LL_ENDL; | ||
184 | } | ||
185 | |||
186 | } | 202 | } |
187 | 203 | ||
188 | LLAudioChannelOpenAL::~LLAudioChannelOpenAL() | 204 | LLAudioChannelOpenAL::~LLAudioChannelOpenAL() |
@@ -201,7 +217,7 @@ void LLAudioChannelOpenAL::play() | |||
201 | { | 217 | { |
202 | if (mALSource == AL_NONE) | 218 | if (mALSource == AL_NONE) |
203 | { | 219 | { |
204 | LL_WARNS("OpenAL") << "Playing without a mALSource, aborting" << LL_ENDL; | 220 | llwarns << "Playing without a mALSource, aborting" << llendl; |
205 | return; | 221 | return; |
206 | } | 222 | } |
207 | 223 | ||
@@ -226,8 +242,8 @@ void LLAudioChannelOpenAL::playSynced(LLAudioChannel *channelp) | |||
226 | alGetSourcef(masterchannelp->mALSource, AL_SEC_OFFSET, | 242 | alGetSourcef(masterchannelp->mALSource, AL_SEC_OFFSET, |
227 | &master_offset); | 243 | &master_offset); |
228 | 244 | ||
229 | LL_INFOS("OpenAL") << "Syncing with master at " << master_offset | 245 | llinfos << "Syncing with master at " << master_offset |
230 | << "sec" << LL_ENDL; | 246 | << "sec" << llendl; |
231 | // *TODO: detect when this fails, maybe use AL_SAMPLE_ | 247 | // *TODO: detect when this fails, maybe use AL_SAMPLE_ |
232 | alSourcef(mALSource, AL_SEC_OFFSET, master_offset); | 248 | alSourcef(mALSource, AL_SEC_OFFSET, master_offset); |
233 | } | 249 | } |
@@ -309,14 +325,12 @@ void LLAudioChannelOpenAL::update3DPosition() | |||
309 | { | 325 | { |
310 | alSource3f(mALSource, AL_POSITION, 0.0, 0.0, 0.0); | 326 | alSource3f(mALSource, AL_POSITION, 0.0, 0.0, 0.0); |
311 | alSource3f(mALSource, AL_VELOCITY, 0.0, 0.0, 0.0); | 327 | alSource3f(mALSource, AL_VELOCITY, 0.0, 0.0, 0.0); |
312 | //alSource3f(mALSource, AL_DIRECTION, 0.0, 0.0, 0.0); | ||
313 | alSourcei (mALSource, AL_SOURCE_RELATIVE, AL_TRUE); | 328 | alSourcei (mALSource, AL_SOURCE_RELATIVE, AL_TRUE); |
314 | } else { | 329 | } else { |
315 | LLVector3 float_pos; | 330 | LLVector3 float_pos; |
316 | float_pos.setVec(mCurrentSourcep->getPositionGlobal()); | 331 | float_pos.setVec(mCurrentSourcep->getPositionGlobal()); |
317 | alSourcefv(mALSource, AL_POSITION, float_pos.mV); | 332 | alSourcefv(mALSource, AL_POSITION, float_pos.mV); |
318 | alSourcefv(mALSource, AL_VELOCITY, mCurrentSourcep->getVelocity().mV); | 333 | alSourcefv(mALSource, AL_VELOCITY, mCurrentSourcep->getVelocity().mV); |
319 | //alSource3f(mALSource, AL_DIRECTION, 0.0, 0.0, 0.0); | ||
320 | alSourcei (mALSource, AL_SOURCE_RELATIVE, AL_FALSE); | 334 | alSourcei (mALSource, AL_SOURCE_RELATIVE, AL_FALSE); |
321 | } | 335 | } |
322 | 336 | ||
@@ -351,18 +365,18 @@ bool LLAudioBufferOpenAL::loadWAV(const std::string& filename) | |||
351 | ALenum error = alutGetError(); | 365 | ALenum error = alutGetError(); |
352 | if (gDirUtilp->fileExists(filename)) | 366 | if (gDirUtilp->fileExists(filename)) |
353 | { | 367 | { |
354 | LL_WARNS("OpenAL") << | 368 | llwarns << |
355 | "LLAudioBufferOpenAL::loadWAV() Error loading " | 369 | "LLAudioBufferOpenAL::loadWAV() Error loading " |
356 | << filename | 370 | << filename |
357 | << " " << alutGetErrorString(error) << LL_ENDL; | 371 | << " " << alutGetErrorString(error) << llendl; |
358 | } | 372 | } |
359 | else | 373 | else |
360 | { | 374 | { |
361 | // It's common for the file to not actually exist. | 375 | // It's common for the file to not actually exist. |
362 | //LL_DEBUGS("OpenAL") << | 376 | lldebugs << |
363 | // "LLAudioBufferOpenAL::loadWAV() Error loading " | 377 | "LLAudioBufferOpenAL::loadWAV() Error loading " |
364 | // << filename | 378 | << filename |
365 | // << " " << alutGetErrorString(error) << LL_ENDL; | 379 | << " " << alutGetErrorString(error) << llendl; |
366 | } | 380 | } |
367 | return false; | 381 | return false; |
368 | } | 382 | } |
@@ -378,7 +392,7 @@ U32 LLAudioBufferOpenAL::getLength() | |||
378 | } | 392 | } |
379 | ALint length; | 393 | ALint length; |
380 | alGetBufferi(mALBuffer, AL_SIZE, &length); | 394 | alGetBufferi(mALBuffer, AL_SIZE, &length); |
381 | return length >> 2; | 395 | return length / 2; // convert size in bytes to size in (16-bit) samples |
382 | } | 396 | } |
383 | 397 | ||
384 | // ------------ | 398 | // ------------ |
@@ -386,7 +400,7 @@ U32 LLAudioBufferOpenAL::getLength() | |||
386 | void LLAudioEngine_OpenAL::initWind() | 400 | void LLAudioEngine_OpenAL::initWind() |
387 | { | 401 | { |
388 | ALenum error; | 402 | ALenum error; |
389 | LL_INFOS("OpenAL") << "LLAudioEngine_OpenAL::initWind() start" << LL_ENDL; | 403 | llinfos << "LLAudioEngine_OpenAL::initWind() start" << llendl; |
390 | 404 | ||
391 | mNumEmptyWindALBuffers = MAX_NUM_WIND_BUFFERS; | 405 | mNumEmptyWindALBuffers = MAX_NUM_WIND_BUFFERS; |
392 | 406 | ||
@@ -396,11 +410,10 @@ void LLAudioEngine_OpenAL::initWind() | |||
396 | 410 | ||
397 | if((error=alGetError()) != AL_NO_ERROR) | 411 | if((error=alGetError()) != AL_NO_ERROR) |
398 | { | 412 | { |
399 | LL_WARNS("OpenAL") << "LLAudioEngine_OpenAL::initWind() Error creating wind sources: "<<error<<LL_ENDL; | 413 | llwarns << "LLAudioEngine_OpenAL::initWind() Error creating wind sources: "<<error<<llendl; |
400 | } | 414 | } |
401 | 415 | ||
402 | mWindGen = new LLWindGen<WIND_SAMPLE_T>; | 416 | mWindGen = new LLWindGen<WIND_SAMPLE_T>; |
403 | const float WIND_BUFFER_SIZE_SEC = 0.05f; // 1/20th sec | ||
404 | 417 | ||
405 | mWindBufFreq = mWindGen->getInputSamplingRate(); | 418 | mWindBufFreq = mWindGen->getInputSamplingRate(); |
406 | mWindBufSamples = llceil(mWindBufFreq * WIND_BUFFER_SIZE_SEC); | 419 | mWindBufSamples = llceil(mWindBufFreq * WIND_BUFFER_SIZE_SEC); |
@@ -410,22 +423,22 @@ void LLAudioEngine_OpenAL::initWind() | |||
410 | 423 | ||
411 | if(mWindBuf==NULL) | 424 | if(mWindBuf==NULL) |
412 | { | 425 | { |
413 | LL_ERRS("OpenAL") << "LLAudioEngine_OpenAL::initWind() Error creating wind memory buffer" << LL_ENDL; | 426 | llerrs << "LLAudioEngine_OpenAL::initWind() Error creating wind memory buffer" << llendl; |
414 | mEnableWind=false; | 427 | mEnableWind=false; |
415 | } | 428 | } |
416 | 429 | ||
417 | LL_INFOS("OpenAL") << "LLAudioEngine_OpenAL::initWind() done" << LL_ENDL; | 430 | llinfos << "LLAudioEngine_OpenAL::initWind() done" << llendl; |
418 | } | 431 | } |
419 | 432 | ||
420 | void LLAudioEngine_OpenAL::cleanupWind() | 433 | void LLAudioEngine_OpenAL::cleanupWind() |
421 | { | 434 | { |
422 | LL_INFOS("OpenAL") << "LLAudioEngine_OpenAL::cleanupWind()" << LL_ENDL; | 435 | llinfos << "LLAudioEngine_OpenAL::cleanupWind()" << llendl; |
423 | 436 | ||
424 | if (mWindSource != AL_NONE) | 437 | if (mWindSource != AL_NONE) |
425 | { | 438 | { |
426 | // detach and delete all outstanding buffers on the wind source | 439 | // detach and delete all outstanding buffers on the wind source |
427 | alSourceStop(mWindSource); | 440 | alSourceStop(mWindSource); |
428 | int processed; | 441 | ALint processed; |
429 | alGetSourcei(mWindSource, AL_BUFFERS_PROCESSED, &processed); | 442 | alGetSourcei(mWindSource, AL_BUFFERS_PROCESSED, &processed); |
430 | while (processed--) | 443 | while (processed--) |
431 | { | 444 | { |
@@ -485,7 +498,7 @@ void LLAudioEngine_OpenAL::updateWind(LLVector3 wind_vec, F32 camera_altitude) | |||
485 | 498 | ||
486 | // ok lets make a wind buffer now | 499 | // ok lets make a wind buffer now |
487 | 500 | ||
488 | int processed, queued, unprocessed; | 501 | ALint processed, queued, unprocessed; |
489 | alGetSourcei(mWindSource, AL_BUFFERS_PROCESSED, &processed); | 502 | alGetSourcei(mWindSource, AL_BUFFERS_PROCESSED, &processed); |
490 | alGetSourcei(mWindSource, AL_BUFFERS_QUEUED, &queued); | 503 | alGetSourcei(mWindSource, AL_BUFFERS_QUEUED, &queued); |
491 | unprocessed = queued - processed; | 504 | unprocessed = queued - processed; |
@@ -495,18 +508,18 @@ void LLAudioEngine_OpenAL::updateWind(LLVector3 wind_vec, F32 camera_altitude) | |||
495 | mNumEmptyWindALBuffers = llmin(mNumEmptyWindALBuffers + processed * 3 - unprocessed, MAX_NUM_WIND_BUFFERS-unprocessed); | 508 | mNumEmptyWindALBuffers = llmin(mNumEmptyWindALBuffers + processed * 3 - unprocessed, MAX_NUM_WIND_BUFFERS-unprocessed); |
496 | mNumEmptyWindALBuffers = llmax(mNumEmptyWindALBuffers, 0); | 509 | mNumEmptyWindALBuffers = llmax(mNumEmptyWindALBuffers, 0); |
497 | 510 | ||
498 | //LL_INFOS("OpenAL") << "mNumEmptyWindALBuffers: " << mNumEmptyWindALBuffers <<" (" << unprocessed << ":" << processed << ")" << LL_ENDL; | 511 | //llinfos << "mNumEmptyWindALBuffers: " << mNumEmptyWindALBuffers <<" (" << unprocessed << ":" << processed << ")" << llendl; |
499 | 512 | ||
500 | while(processed--) // unqueue old buffers | 513 | while(processed--) // unqueue old buffers |
501 | { | 514 | { |
502 | ALuint buffer; | 515 | ALuint buffer; |
503 | int error; | 516 | ALenum error; |
504 | alGetError(); /* clear error */ | 517 | alGetError(); /* clear error */ |
505 | alSourceUnqueueBuffers(mWindSource, 1, &buffer); | 518 | alSourceUnqueueBuffers(mWindSource, 1, &buffer); |
506 | error = alGetError(); | 519 | error = alGetError(); |
507 | if(error != AL_NO_ERROR) | 520 | if(error != AL_NO_ERROR) |
508 | { | 521 | { |
509 | LL_WARNS("OpenAL") << "LLAudioEngine_OpenAL::updateWind() error swapping (unqueuing) buffers" << LL_ENDL; | 522 | llwarns << "LLAudioEngine_OpenAL::updateWind() error swapping (unqueuing) buffers" << llendl; |
510 | } | 523 | } |
511 | else | 524 | else |
512 | { | 525 | { |
@@ -522,7 +535,7 @@ void LLAudioEngine_OpenAL::updateWind(LLVector3 wind_vec, F32 camera_altitude) | |||
522 | alGenBuffers(1,&buffer); | 535 | alGenBuffers(1,&buffer); |
523 | if((error=alGetError()) != AL_NO_ERROR) | 536 | if((error=alGetError()) != AL_NO_ERROR) |
524 | { | 537 | { |
525 | LL_WARNS("OpenAL") << "LLAudioEngine_OpenAL::initWind() Error creating wind buffer: " << error << LL_ENDL; | 538 | llwarns << "LLAudioEngine_OpenAL::initWind() Error creating wind buffer: " << error << llendl; |
526 | break; | 539 | break; |
527 | } | 540 | } |
528 | 541 | ||
@@ -534,22 +547,27 @@ void LLAudioEngine_OpenAL::updateWind(LLVector3 wind_vec, F32 camera_altitude) | |||
534 | mWindBufFreq); | 547 | mWindBufFreq); |
535 | error = alGetError(); | 548 | error = alGetError(); |
536 | if(error != AL_NO_ERROR) | 549 | if(error != AL_NO_ERROR) |
537 | LL_WARNS("OpenAL") << "LLAudioEngine_OpenAL::updateWind() error swapping (bufferdata) buffers" << LL_ENDL; | 550 | { |
551 | llwarns << "LLAudioEngine_OpenAL::updateWind() error swapping (bufferdata) buffers" << llendl; | ||
552 | } | ||
538 | 553 | ||
539 | alSourceQueueBuffers(mWindSource, 1, &buffer); | 554 | alSourceQueueBuffers(mWindSource, 1, &buffer); |
540 | error = alGetError(); | 555 | error = alGetError(); |
541 | if(error != AL_NO_ERROR) | 556 | if(error != AL_NO_ERROR) |
542 | LL_WARNS("OpenAL") << "LLAudioEngine_OpenAL::updateWind() error swapping (queuing) buffers" << LL_ENDL; | 557 | { |
558 | llwarns << "LLAudioEngine_OpenAL::updateWind() error swapping (queuing) buffers" << llendl; | ||
559 | } | ||
543 | 560 | ||
544 | --mNumEmptyWindALBuffers; | 561 | --mNumEmptyWindALBuffers; |
545 | } | 562 | } |
546 | 563 | ||
547 | int playing; | 564 | ALint playing; |
548 | alGetSourcei(mWindSource, AL_SOURCE_STATE, &playing); | 565 | alGetSourcei(mWindSource, AL_SOURCE_STATE, &playing); |
549 | if(playing != AL_PLAYING) | 566 | if(playing != AL_PLAYING) |
550 | { | 567 | { |
551 | alSourcePlay(mWindSource); | 568 | alSourcePlay(mWindSource); |
552 | 569 | ||
553 | LL_INFOS("OpenAL") << "Wind had stopped - probably ran out of buffers - restarting: " << (unprocessed+mNumEmptyWindALBuffers) << " now queued." << LL_ENDL; | 570 | lldebugs << "Wind had stopped - probably ran out of buffers - restarting: " << (unprocessed+mNumEmptyWindALBuffers) << " now queued." << llendl; |
554 | } | 571 | } |
555 | } | 572 | } |
573 | |||
diff --git a/linden/indra/llaudio/audioengine_openal.h b/linden/indra/llaudio/audioengine_openal.h index 1f6dee4..70de9d4 100644 --- a/linden/indra/llaudio/audioengine_openal.h +++ b/linden/indra/llaudio/audioengine_openal.h | |||
@@ -6,7 +6,7 @@ | |||
6 | * | 6 | * |
7 | * $LicenseInfo:firstyear=2002&license=viewergpl$ | 7 | * $LicenseInfo:firstyear=2002&license=viewergpl$ |
8 | * | 8 | * |
9 | * Copyright (c) 2002-2008, Linden Research, Inc. | 9 | * Copyright (c) 2002-2009, Linden Research, Inc. |
10 | * | 10 | * |
11 | * Second Life Viewer Source Code | 11 | * Second Life Viewer Source Code |
12 | * The source code in this file ("Source Code") is provided by Linden Lab | 12 | * The source code in this file ("Source Code") is provided by Linden Lab |
@@ -39,6 +39,11 @@ | |||
39 | #include "listener_openal.h" | 39 | #include "listener_openal.h" |
40 | #include "windgen.h" | 40 | #include "windgen.h" |
41 | 41 | ||
42 | #if 1 | ||
43 | #define WIND_BUFFER_SIZE_SEC 0.05f | ||
44 | #endif | ||
45 | |||
46 | |||
42 | class LLAudioEngine_OpenAL : public LLAudioEngine | 47 | class LLAudioEngine_OpenAL : public LLAudioEngine |
43 | { | 48 | { |
44 | public: | 49 | public: |
@@ -72,6 +77,9 @@ class LLAudioEngine_OpenAL : public LLAudioEngine | |||
72 | int mNumEmptyWindALBuffers; | 77 | int mNumEmptyWindALBuffers; |
73 | 78 | ||
74 | static const int MAX_NUM_WIND_BUFFERS = 80; | 79 | static const int MAX_NUM_WIND_BUFFERS = 80; |
80 | #if 0 | ||
81 | static const float WIND_BUFFER_SIZE_SEC = 0.05f; // 1/20th sec | ||
82 | #endif | ||
75 | }; | 83 | }; |
76 | 84 | ||
77 | class LLAudioChannelOpenAL : public LLAudioChannel | 85 | class LLAudioChannelOpenAL : public LLAudioChannel |