本文整理汇总了C++中soundLock函数的典型用法代码示例。如果您正苦于以下问题:C++ soundLock函数的具体用法?C++ soundLock怎么用?C++ soundLock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了soundLock函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sound_al_update
/**
* @brief Updates the group sounds.
*/
void sound_al_update (void)
{
int i, j;
alGroup_t *g;
ALfloat d, v;
unsigned int t, f;
t = SDL_GetTicks();
for (i=0; i<al_ngroups; i++) {
g = &al_groups[i];
/* Handle fadeout. */
if (g->state != VOICE_FADEOUT)
continue;
/* Calculate fadeout. */
f = t - g->fade_timer;
if (f < SOUND_FADEOUT) {
d = 1. - (ALfloat) f / (ALfloat) SOUND_FADEOUT;
v = d * svolume * g->volume;
if (g->speed)
v *= svolume_speed;
soundLock();
for (j=0; j<g->nsources; j++)
alSourcef( g->sources[j], AL_GAIN, v );
/* Check for errors. */
al_checkErr();
soundUnlock();
}
/* Fadeout done. */
else {
soundLock();
v = svolume * g->volume;
if (g->speed)
v *= svolume_speed;
for (j=0; j<g->nsources; j++) {
alSourceStop( g->sources[j] );
alSourcei( g->sources[j], AL_BUFFER, AL_NONE );
alSourcef( g->sources[j], AL_GAIN, v );
}
/* Check for errors. */
al_checkErr();
soundUnlock();
/* Mark as done. */
g->state = VOICE_PLAYING;
}
}
}
示例2: sound_al_playGroup
/**
* @brief Plays a sound in a group.
*/
int sound_al_playGroup( int group, alSound *s, int once )
{
int i, j;
alGroup_t *g;
ALint state;
for (i=0; i<al_ngroups; i++) {
/* Find group. */
if (al_groups[i].id != group)
continue;
g = &al_groups[i];
g->state = VOICE_PLAYING;
soundLock();
for (j=0; j<g->nsources; j++) {
alGetSourcei( g->sources[j], AL_SOURCE_STATE, &state );
/* No free ones, just smash the last one. */
if (j == g->nsources-1) {
if (state != AL_STOPPED) {
alSourceStop( g->sources[j] );
alSourcef( g->sources[j], AL_GAIN, svolume );
}
}
/* Ignore playing/paused. */
else if ((state == AL_PLAYING) || (state == AL_PAUSED))
continue;
/* Attach buffer. */
alSourcei( g->sources[j], AL_BUFFER, s->u.al.buf );
/* Do not do positional sound. */
alSourcei( g->sources[j], AL_SOURCE_RELATIVE, AL_TRUE );
/* See if should loop. */
alSourcei( g->sources[j], AL_LOOPING, (once) ? AL_FALSE : AL_TRUE );
/* Start playing. */
alSourcePlay( g->sources[j] );
/* Check for errors. */
al_checkErr();
soundUnlock();
return 0;
}
soundUnlock();
WARN("Group '%d' has no free sounds.", group );
/* Group matched but not found. */
break;
}
if (i>=al_ngroups)
WARN("Group '%d' not found.", group);
return -1;
}
示例3: engineLock
void CCoreAudioAE::Shutdown()
{
CSingleLock engineLock(m_engineLock);
Stop();
Deinitialize();
/* free the streams */
CSingleLock streamLock(m_streamLock);
while (!m_streams.empty())
{
CCoreAudioAEStream *s = m_streams.front();
m_sounds.pop_front();
delete s;
}
/* free the sounds */
CSingleLock soundLock(m_soundLock);
while (!m_sounds.empty())
{
CCoreAudioAESound *s = m_sounds.front();
m_sounds.pop_front();
delete s;
}
delete HAL;
HAL = NULL;
}
示例4: music_al_exit
/**
* @brief Frees the music.
*/
void music_al_exit (void)
{
/* Kill the thread. */
music_kill();
SDL_WaitThread( music_player, NULL );
soundLock();
/* Free the music. */
alDeleteBuffers( 2, music_buffer );
alDeleteSources( 1, &music_source );
/* Check for errors. */
al_checkErr();
soundUnlock();
/* Free the buffer. */
if (music_buf != NULL)
free(music_buf);
music_buf = NULL;
/* Destroy the mutex. */
SDL_DestroyMutex( music_vorbis_lock );
SDL_DestroyMutex( music_state_lock );
SDL_DestroyCond( music_state_cond );
}
示例5: sound_al_updateListener
/**
* @brief Updates the listener.
*/
int sound_al_updateListener( double dir, double px, double py,
double vx, double vy )
{
double c, s;
ALfloat ori[6], pos[3], vel[3];
c = cos(dir);
s = sin(dir);
soundLock();
ori[0] = c;
ori[1] = s;
ori[2] = 0.;
ori[3] = 0.;
ori[4] = 0.;
ori[5] = 1.;
alListenerfv( AL_ORIENTATION, ori );
pos[0] = px;
pos[1] = py;
pos[2] = 0.;
alListenerfv( AL_POSITION, pos );
vel[0] = vx;
vel[1] = vy;
vel[2] = 0.;
alListenerfv( AL_VELOCITY, vel );
/* Check for errors. */
al_checkErr();
soundUnlock();
return 0;
}
示例6: sound_al_env
/**
* @brief Creates a sound environment.
*/
int sound_al_env( SoundEnv_t env, double param )
{
int i;
ALuint s;
ALfloat f;
soundLock();
switch (env) {
case SOUND_ENV_NORMAL:
/* Set global parameters. */
alSpeedOfSound( 3433. );
if (al_info.efx == AL_TRUE) {
/* Disconnect the effect. */
nalAuxiliaryEffectSloti( efx_directSlot,
AL_EFFECTSLOT_EFFECT, AL_EFFECT_NULL );
/* Set per-source parameters. */
for (i=0; i<source_ntotal; i++) {
s = source_total[i];
alSourcef( s, AL_AIR_ABSORPTION_FACTOR, 0. );
}
}
break;
case SOUND_ENV_NEBULA:
f = param / 1000.;
/* Set global parameters. */
alSpeedOfSound( 3433./(1. + f*2.) );
if (al_info.efx == AL_TRUE) {
if (al_info.efx_reverb == AL_TRUE) {
/* Tweak the reverb. */
nalEffectf( efx_reverb, AL_REVERB_DECAY_TIME, 10. );
nalEffectf( efx_reverb, AL_REVERB_DECAY_HFRATIO, 0.5 );
/* Connect the effect. */
nalAuxiliaryEffectSloti( efx_directSlot,
AL_EFFECTSLOT_EFFECT, efx_reverb );
}
/* Set per-source parameters. */
for (i=0; i<source_ntotal; i++) {
s = source_total[i];
alSourcef( s, AL_AIR_ABSORPTION_FACTOR, 3.*f );
}
}
break;
}
/* Check for errors. */
al_checkErr();
soundUnlock();
return 0;
}
示例7: sound_al_resume
/**
* @brief Resumes all sounds.
*/
void sound_al_resume (void)
{
soundLock();
al_resumev( source_ntotal, source_total );
/* Check for errors. */
al_checkErr();
soundUnlock();
}
示例8: sound_al_free
/**
* @brief Frees the source.
*/
void sound_al_free( alSound *snd )
{
soundLock();
/* free the stuff */
alDeleteBuffers( 1, &snd->u.al.buf );
soundUnlock();
}
示例9: sound_al_exit
/**
* @brief Cleans up after the sound subsytem.
*/
void sound_al_exit (void)
{
int i;
soundLock();
/* Free groups. */
for (i=0; i<al_ngroups; i++) {
if (al_groups[i].sources != NULL) {
free(al_groups[i].sources);
}
al_groups[i].sources = NULL;
al_groups[i].nsources = 0;
}
if (al_groups != NULL)
free(al_groups);
al_groups = NULL;
al_ngroups = 0;
/* Free stacks. */
if (source_all != NULL) {
alSourceStopv( source_nall, source_all );
alDeleteSources( source_nall, source_all );
free(source_all);
}
source_all = NULL;
source_nall = 0;
if (source_total)
free(source_total);
source_total = NULL;
source_ntotal = 0;
if (source_stack != NULL)
free(source_stack);
source_stack = NULL;
source_nstack = 0;
source_mstack = 0;
/* Clean up EFX stuff. */
if (al_info.efx == AL_TRUE) {
nalDeleteAuxiliaryEffectSlots( 1, &efx_directSlot );
if (al_info.efx_reverb == AL_TRUE)
nalDeleteEffects( 1, &efx_reverb );
if (al_info.efx_echo == AL_TRUE)
nalDeleteEffects( 1, &efx_echo );
}
/* Clean up global stuff. */
if (al_context) {
alcMakeContextCurrent(NULL);
alcDestroyContext( al_context );
}
if (al_device)
alcCloseDevice( al_device );
soundUnlock();
SDL_DestroyMutex( sound_lock );
}
示例10: texLock
void ResourceManager::unloadAll()
{
sf::Lock texLock( texMutex );
sf::Lock soundLock( soundMutex );
sf::Lock fontLock( fontMutex );
textures.clear();
soundBuffers.clear();
fonts.clear();
}
示例11: sound_al_setSpeed
/**
* @brief Set the playing speed.
*/
void sound_al_setSpeed( double s )
{
int i;
soundLock();
for (i=0; i<source_nall; i++)
alSourcef( source_all[i], AL_PITCH, s );
/* Check for errors. */
al_checkErr();
soundUnlock();
}
示例12: sound_al_resumeGroup
/**
* @brief Resumes a group.
*/
void sound_al_resumeGroup( int group )
{
alGroup_t *g;
g = sound_al_getGroup( group );
if (g == NULL)
return;
soundLock();
al_resumev( g->nsources, g->sources );
soundUnlock();
}
示例13: sound_al_stop
/**
* @brief Stops playing sound.
*/
void sound_al_stop( alVoice* voice )
{
soundLock();
if (voice->u.al.source != 0)
alSourceStop( voice->u.al.source );
/* Check for errors. */
al_checkErr();
soundUnlock();
}
示例14: sound_al_volume
/**
* @brief Sets all the sounds volume to vol
*/
int sound_al_volume( double vol )
{
int i;
svolume = (ALfloat) vol;
soundLock();
for (i=0; i<source_nall; i++)
alSourcef( source_all[i], AL_GAIN, svolume );
soundUnlock();
return 0;
}
示例15: sound_al_load
/**
* @brief Loads the sound.
*
* @param snd Sound to load.
* @param filename Name of the file to load into sound.
*/
int sound_al_load( alSound *snd, const char *filename )
{
int ret;
SDL_RWops *rw;
OggVorbis_File vf;
ALint freq, bits, channels, size;
/* get the file data buffer from packfile */
rw = ndata_rwops( filename );
/* Check to see if it's an OGG. */
if (ov_test_callbacks( rw, &vf, NULL, 0, sound_al_ovcall_noclose )==0) {
ret = sound_al_loadOgg( snd, &vf );
}
/* Otherwise try WAV. */
else {
/* Destroy the partially loaded vorbisfile. */
ov_clear(&vf);
/* Try to load Wav. */
ret = sound_al_loadWav( snd, rw );
}
/* Close RWops. */
SDL_RWclose(rw);
/* Failed to load. */
if (ret != 0) {
WARN("Failed to load sound file '%s'.", filename);
return ret;
}
soundLock();
/* Get the length of the sound. */
alGetBufferi( snd->u.al.buf, AL_FREQUENCY, &freq );
alGetBufferi( snd->u.al.buf, AL_BITS, &bits );
alGetBufferi( snd->u.al.buf, AL_CHANNELS, &channels );
alGetBufferi( snd->u.al.buf, AL_SIZE, &size );
if ((freq==0) || (bits==0) || (channels==0)) {
WARN("Something went wrong when loading sound file '%s'.", filename);
snd->length = 0;
}
else
snd->length = (double)size / (double)(freq * (bits/8) * channels);
/* Check for errors. */
al_checkErr();
soundUnlock();
return 0;
}