/* 0.0 - 2.0 in seconds */ void alReverbDelay_LOKI(ALuint sid, ALfloat param) { AL_source *src; if((param < 0.0) || (param > 2.0)) { /* * For this kludge, the scale is 2 * normalized. */ _alDebug(ALD_MAXIMUS, __FILE__, __LINE__, "alReverbDelay: invalid value %f", param); _alDCSetError(AL_INVALID_VALUE); return; } _alcDCLockContext(); src = _alDCGetSource(sid); if(src == NULL) { _alDebug(ALD_MAXIMUS, __FILE__, __LINE__, "alReverbScale: invalid source id %d", sid); _alDCSetError(AL_INVALID_NAME); return; } src->reverb_delay = param * canon_speed * _alGetChannelsFromFormat(canon_format); src->flags |= ALS_REVERB; _alcDCUnlockContext(); return; }
void alDistanceModel( ALenum distanceModel ) { AL_context *cc = _alcDCGetContext(); if( cc == NULL ) { _alDCSetError( AL_INVALID_OPERATION ); return; } _alcDCLockContext(); switch( distanceModel ) { case AL_NONE: case AL_INVERSE_DISTANCE: case AL_INVERSE_DISTANCE_CLAMPED: case AL_LINEAR_DISTANCE: case AL_LINEAR_DISTANCE_CLAMPED: case AL_EXPONENT_DISTANCE: case AL_EXPONENT_DISTANCE_CLAMPED: cc->distance_model = distanceModel; _alUpdateDistanceModel(cc); break; default: _alDCSetError( AL_INVALID_ENUM ); break; } _alcDCUnlockContext(); }
/* * alSourceUnqueueBuffers( ALuint sid, ALsizei n, ALuint *bids ) * * Unqueues first occurance of each bid in bids[0..n-1] from source named sid. */ void alSourceUnqueueBuffers( ALuint sid, ALsizei n, ALuint *bids ) { _alcDCLockContext(); _alSourceUnqueueBuffers( sid, n, bids ); _alcDCUnlockContext(); return; }
/* * alGetDoublev(ALenum param, ALdouble *dv ) * * Populated dv with the double representation for param. */ void alGetDoublev(ALenum param, ALdouble *dv ) { _alcDCLockContext(); _alGetDoublev( param, dv ); _alcDCUnlockContext(); return; }
/* * alDisable( ALenum param ) * * Disables param if possible for the current context. If param does not * specify a valid enabling token, AL_INVALID_ENUM is set. */ void alDisable( ALenum param ) { _alcDCLockContext(); _alDisable( param ); _alcDCUnlockContext(); return; }
/* * alGetBooleanv( ALenum param, ALboolean *bv ) * * Populated bv with the ALboolean representation for param. */ void alGetBooleanv( ALenum param, ALboolean *bv ) { _alcDCLockContext(); _alGetBooleanv( param, bv ); _alcDCUnlockContext(); return; }
void alPropagationSpeed(ALfloat value) { _alcDCLockContext(); _alPropagationSpeed(value); _alcDCUnlockContext(); return; }
/* * alGetIntegerv( ALenum param, ALint *iv ) * * Populated iv with the ALint representation for param. */ void alGetIntegerv( ALenum param, ALint *iv ) { _alcDCLockContext(); _alGetIntegerv( param, iv ); _alcDCUnlockContext(); return; }
/* * alGetFloatv( ALenum param, ALfloat *fv ) * * Populated fv with the ALfloat representation for param. */ void alGetFloatv( ALenum param, ALfloat *fv ) { _alcDCLockContext(); _alGetFloatv( param, fv ); _alcDCUnlockContext(); return; }
void alcSetAudioChannel_LOKI(ALuint channel, ALfloat volume) { AL_context *cc; _alcDCLockContext(); cc = _alcDCGetContext(); if(cc != NULL) { alcDeviceSetAudioChannel_( cc->write_device, channel, volume ); } _alcDCUnlockContext(); }
/* * alIsEnabled( ALenum param ) * * returns AL_TRUE if the attribute specified by param is enabled, AL_FALSE * otherwise. * * if param is not a valid enable/disable token, AL_ILLEGAL_ENUM is set. */ ALboolean alIsEnabled(ALenum param) { ALboolean retval; _alcDCLockContext(); retval = _alIsEnabled( param ); _alcDCUnlockContext(); return retval; }
const ALchar* alGetString( ALenum param ) { const ALchar *value; static ALchar extensions[1024]; /* TODO: Ugly and not thread-safe! */ AL_context *cc = _alcDCGetContext(); if( cc == NULL ) { _alDCSetError( AL_INVALID_OPERATION ); return NULL; } _alcDCLockContext(); switch (param) { case AL_VERSION: value = "1.1"; break; case AL_RENDERER: value = "OpenAL Sample Implementation"; break; case AL_VENDOR: value = "OpenAL Community"; break; case AL_EXTENSIONS: _alGetExtensionStrings( extensions, sizeof( extensions ) ); value = extensions; break; case AL_NO_ERROR: value = "No Error"; break; case AL_INVALID_NAME: value = "Invalid Name"; break; case AL_INVALID_ENUM: value = "Invalid Enum"; break; case AL_INVALID_VALUE: value = "Invalid Value"; break; case AL_INVALID_OPERATION: value = "Invalid Operation"; break; case AL_OUT_OF_MEMORY: value = "Out of Memory"; break; default: value = NULL; _alDCSetError( AL_INVALID_ENUM ); break; } _alcDCUnlockContext(); return value; }
ALfloat alcGetAudioChannel_LOKI(ALuint channel) { AL_context *cc; ALfloat retval = 0.0f; _alcDCLockContext(); cc = _alcDCGetContext(); if(cc != NULL) { retval = alcDeviceGetAudioChannel_( cc->write_device, channel ); } _alcDCUnlockContext(); return retval; }
void alDisable( ALenum param ) { AL_context *cc = _alcDCGetContext(); if( cc == NULL ) { _alDCSetError( AL_INVALID_OPERATION ); return; } _alcDCLockContext(); switch (param) { default: _alDCSetError( AL_INVALID_ENUM ); break; } _alcDCUnlockContext(); }
ALboolean alIsEnabled( ALenum param ) { AL_context *cc = _alcDCGetContext(); if( cc == NULL ) { _alDCSetError( AL_INVALID_OPERATION ); return AL_FALSE; } _alcDCLockContext(); switch (param) { default: _alDCSetError( AL_INVALID_ENUM ); break; } _alcDCUnlockContext(); return AL_FALSE; }
void alDopplerVelocity( ALfloat value ) { AL_context *cc = _alcDCGetContext(); if( cc == NULL ) { _alDCSetError( AL_INVALID_OPERATION ); return; } _alcDCLockContext(); if( value <= 0.0f ) { _alDCSetError( AL_INVALID_VALUE ); _alcDCUnlockContext(); return; } cc->doppler_velocity = value; _alcDCUnlockContext(); }
void alSpeedOfSound( ALfloat value ) { AL_context *cc = _alcDCGetContext(); if( cc == NULL ) { _alDCSetError( AL_INVALID_OPERATION ); return; } _alcDCLockContext(); if( value <= 0.0f ) { _alDCSetError( AL_INVALID_VALUE ); _alcDCUnlockContext(); return; } cc->speed_of_sound = value; _alcDCUnlockContext(); }
/* * alGenStreamingBuffers_LOKI * * Perform full allocation in buffers[0..n-1]. If full allocation * is not possible, the appropriate error is set and the function * returns. Each buffer id in a sucessful call can be used with * BufferAppendData. * * If n is 0, legal nop. If n < 0, set INVALID_VALUE and nop. * */ void alGenStreamingBuffers_LOKI( ALsizei n, ALuint *buffer) { AL_buffer *buf; int i; if(n == 0) { /* silently return */ return; } if(n < 0) { _alDebug(ALD_BUFFER, __FILE__, __LINE__, "alGenStreamingBuffers_LOKI: invalid n %d\n", n); _alcDCLockContext(); _alDCSetError( AL_INVALID_VALUE ); _alcDCUnlockContext(); return; } /* generate normal buffers */ alGenBuffers( n, buffer ); _alLockBuffer(); for( i = 0; i < n; i++ ) { buf = _alGetBuffer( buffer[i] ); if( buf == NULL ) { /* allocation must have failed */ _alUnlockBuffer(); return; } /* make sure to set the streaming flag */ buf->flags |= ALB_STREAMING; } _alUnlockBuffer(); return; }
/* * alGetError( void ) * * Returns the most recent error generated in the AL state machine. */ ALenum alGetError( void ) { AL_context *cc; int index; _alcDCLockContext(); cc = _alcDCGetContext(); if(cc == NULL) return 0; index = index2ErrorNo(cc->alErrorIndex); /* * In deference to the new spec, GetError clears the error * after reading it. */ cc->alErrorIndex = 0; _alcDCUnlockContext(); return index; }
/** * * alBufferWriteData_LOKI( ALuint bid, * ALenum format, * ALvoid *data, * ALsizei size, * ALsizei freq * ALenum internalFormat ) * * associates data with bid, with format hint * * If format is invalid, set AL_INVALID_ENUM. If bid is not a valid buffer * name, set AL_INVALID_NAME. If not enough memory is available to make a * copy of this data, set AL_OUT_OF_MEMORY. */ void alBufferWriteData_LOKI( ALuint bid, ALenum format, void *data, ALsizei size, ALsizei freq, ALenum internalFormat ) { AL_buffer *buf; unsigned int retsize; void *cdata; ALuint i; _alLockBuffer(); buf = _alGetBuffer(bid); if(buf == NULL) { _alDebug(ALD_BUFFER, __FILE__, __LINE__, "alBufferData: buffer id %d not valid", bid); _alDCSetError(AL_INVALID_NAME); _alUnlockBuffer(); return; } cdata = _alBufferCanonizeData(format, data, size, freq, internalFormat, buf->frequency, &retsize, AL_FALSE); if(cdata == NULL) { /* _alBufferCanonize Data should set error */ _alUnlockBuffer(); return; } if(buf->flags & ALB_STREAMING) { /* Streaming buffers cannot use alBufferData */ _alDCSetError(AL_INVALID_OPERATION); free(cdata); _alUnlockBuffer(); return; } buf->format = internalFormat; if(buf->size < retsize) { void *temp_copies[_ALC_MAX_CHANNELS] = { NULL }; ALboolean success = AL_TRUE; /* don't use realloc */ _alBufferFreeOrigBuffers(buf); for(i = 0; i < _alGetChannelsFromFormat(buf->format); i++) { temp_copies[i] = malloc(retsize); success = (temp_copies[i] != NULL) ? AL_TRUE : AL_FALSE; } if(!success) { free(cdata); for(i = 0; i < _alGetChannelsFromFormat(buf->format); i++) { free(temp_copies[i]); } /* JIV FIXME: lock context */ _alcDCLockContext(); _alDCSetError(AL_OUT_OF_MEMORY); _alcDCUnlockContext(); _alUnlockBuffer(); return; } switch(_alGetChannelsFromFormat(buf->format)) { case 1: for(i = 0; i < elementsof(buf->orig_buffers); i++) { buf->orig_buffers[i] = temp_copies[0]; } break; case 2: for(i = 0; i < elementsof(buf->orig_buffers); i += 2) { buf->orig_buffers[i] = temp_copies[0]; buf->orig_buffers[i+1] = temp_copies[1]; } break; case 4: assert(elementsof(buf->orig_buffers) >= 4); for(i = 0; i < elementsof(buf->orig_buffers); i += 4) { buf->orig_buffers[i] = temp_copies[0]; buf->orig_buffers[i+1] = temp_copies[1]; buf->orig_buffers[i+2] = temp_copies[2]; buf->orig_buffers[i+3] = temp_copies[3]; } break; case 6: assert(elementsof(buf->orig_buffers) >= 6); for(i = 0; i < elementsof(buf->orig_buffers); i += 6) { buf->orig_buffers[i] = temp_copies[0]; buf->orig_buffers[i+1] = temp_copies[1]; buf->orig_buffers[i+2] = temp_copies[2]; buf->orig_buffers[i+3] = temp_copies[3]; buf->orig_buffers[i+4] = temp_copies[4]; buf->orig_buffers[i+5] = temp_copies[5]; } break; default: /* well this is weird */ assert(0); break; } } _alMonoify((ALshort **) buf->orig_buffers, cdata, retsize / _alGetChannelsFromFormat(buf->format), buf->num_buffers, _alGetChannelsFromFormat(buf->format)); free(cdata); buf->size = retsize / _alGetChannelsFromFormat(buf->format); _alUnlockBuffer(); return; }
/* * alSourceQueueBuffers( ALuint sid, ALsizei numBuffers, ALuint *bids ) * * Queue bids[0..numBuffers-1] to the source named sid, setting * AL_INVALID_VALUE if numBuffers < 0, or AL_INVALID_NAME if either sid or and * bid in bids[0..numBuffers-1] is not a valid buffer. */ void alSourceQueueBuffers( ALuint sid, ALsizei numBuffers, ALuint *bids ) { AL_source *src; ALsizei i; if( numBuffers == 0) { /* with n == 0, we NOP */ return; } if( numBuffers < 0) { _alDebug(ALD_SOURCE, __FILE__, __LINE__, "alSourceQueueBuffers: illegal n value %d\n", numBuffers ); _alcDCLockContext(); _alDCSetError( AL_INVALID_VALUE ); _alcDCUnlockContext(); return; } SOURCELOCK(); src = _alDCGetSource( sid ); if( src == NULL ) { _alDCSetError( AL_INVALID_NAME ); _alDebug(ALD_SOURCE, __FILE__, __LINE__, "alSourceQueueBuffers: invalid sid %d\n", sid ); SOURCEUNLOCK(); return; } _alLockBuffer(); /* make sure that bids are valid */ for( i = 0; i < numBuffers; i++ ) { if( _alIsBuffer( bids[i] ) == AL_FALSE ) { /* * we have an invalid bid. bid 0 is okay but the * rest are not. */ if( bids[i] != 0 ) { _alUnlockBuffer(); _alDCSetError( AL_INVALID_NAME ); SOURCEUNLOCK(); return; } } } /* now, append the bids */ for( i = 0; i < numBuffers; i++ ) { if( bids[i] != 0 ) { /* * only append non-0 bids, because we don't * need them anyway. */ _alSourceQueueAppend( src, bids[i] ); } } /* we're done */ _alUnlockBuffer(); SOURCEUNLOCK(); return; }