本文整理汇总了C++中soundLock函数的典型用法代码示例。如果您正苦于以下问题:C++ soundLock函数的具体用法?C++ soundLock怎么用?C++ soundLock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了soundLock函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
}
}
开发者ID:naev,项目名称:naev,代码行数:52,代码来源:sound_openal.c
示例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;
}
开发者ID:AvanWolf,项目名称:naev,代码行数:63,代码来源:sound_openal.c
示例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;
}
开发者ID:AFFLUENTSOCIETY,项目名称:SPMC,代码行数:29,代码来源:CoreAudioAE.cpp
示例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 );
}
开发者ID:ekrumme,项目名称:naev,代码行数:30,代码来源:music_openal.c
示例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;
}
开发者ID:Delll,项目名称:naev,代码行数:37,代码来源:sound_openal.c
示例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;
}
开发者ID:Delll,项目名称:naev,代码行数:62,代码来源:sound_openal.c
示例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();
}
开发者ID:Delll,项目名称:naev,代码行数:11,代码来源:sound_openal.c
示例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();
}
开发者ID:Delll,项目名称:naev,代码行数:12,代码来源:sound_openal.c
示例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 );
}
开发者ID:s0be,项目名称:naev,代码行数:60,代码来源:sound_openal.c
示例10: texLock
void ResourceManager::unloadAll()
{
sf::Lock texLock( texMutex );
sf::Lock soundLock( soundMutex );
sf::Lock fontLock( fontMutex );
textures.clear();
soundBuffers.clear();
fonts.clear();
}
开发者ID:spacechase0,项目名称:Farming-Game,代码行数:10,代码来源:ResourceManager.cpp
示例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();
}
开发者ID:Delll,项目名称:naev,代码行数:13,代码来源:sound_openal.c
示例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();
}
开发者ID:naev,项目名称:naev,代码行数:14,代码来源:sound_openal.c
示例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();
}
开发者ID:Delll,项目名称:naev,代码行数:15,代码来源:sound_openal.c
示例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;
}
开发者ID:Delll,项目名称:naev,代码行数:15,代码来源:sound_openal.c
示例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;
}
开发者ID:Delll,项目名称:naev,代码行数:59,代码来源:sound_openal.c
示例16: sound_al_volume
/**
* @brief Sets all the sounds volume to vol
*/
int sound_al_volume( double vol )
{
int i;
svolume_lin = vol;
if (vol > 0.) /* Floor of -48 dB (0.00390625 amplitude) */
svolume = (ALfloat) 1 / pow(2, (1 - vol) * 8);
else
svolume = 0.;
soundLock();
for (i=0; i<source_nall; i++)
alSourcef( source_all[i], AL_GAIN, svolume );
soundUnlock();
return 0;
}
开发者ID:AvanWolf,项目名称:naev,代码行数:19,代码来源:sound_openal.c
示例17: al_playVoice
/**
* @brief Plays a voice.
*/
static int al_playVoice( alVoice *v, alSound *s,
ALfloat px, ALfloat py, ALfloat vx, ALfloat vy, ALint relative )
{
/* Must be below the limit. */
if (sound_speed > SOUND_SPEED_PLAY_LIMIT)
return 0;
/* Set up the source and buffer. */
v->u.al.source = sound_al_getSource();
if (v->u.al.source == 0)
return -1;
v->u.al.buffer = s->u.al.buf;
soundLock();
/* Attach buffer. */
alSourcei( v->u.al.source, AL_BUFFER, v->u.al.buffer );
/* Enable positional sound. */
alSourcei( v->u.al.source, AL_SOURCE_RELATIVE, relative );
/* Update position. */
v->u.al.pos[0] = px;
v->u.al.pos[1] = py;
v->u.al.pos[2] = 0.;
v->u.al.vel[0] = vx;
v->u.al.vel[1] = vy;
v->u.al.vel[2] = 0.;
/* Set up properties. */
alSourcef( v->u.al.source, AL_GAIN, svolume*svolume_speed );
alSourcefv( v->u.al.source, AL_POSITION, v->u.al.pos );
alSourcefv( v->u.al.source, AL_VELOCITY, v->u.al.vel );
/* Defaults just in case. */
alSourcei( v->u.al.source, AL_LOOPING, AL_FALSE );
/* Start playing. */
alSourcePlay( v->u.al.source );
/* Check for errors. */
al_checkErr();
soundUnlock();
return 0;
}
开发者ID:naev,项目名称:naev,代码行数:50,代码来源:sound_openal.c
示例18: music_al_init
/**
* @brief Initializes the OpenAL music subsystem.
*/
int music_al_init (void)
{
ALfloat v[] = { 0., 0., 0. };
/* Create threading mechanisms. */
music_state_cond = SDL_CreateCond();
music_state_lock = SDL_CreateMutex();
music_vorbis_lock = SDL_CreateMutex();
music_vorbis.rw = NULL; /* indication it's not loaded */
/* Create the buffer. */
music_bufSize = conf.al_bufsize * 1024;
music_buf = malloc( music_bufSize );
soundLock();
/* music_source created in sound_al_init. */
/* Generate buffers and sources. */
alGenBuffers( 2, music_buffer );
/* Set up OpenAL properties. */
alSourcef( music_source, AL_GAIN, music_vol );
alSourcei( music_source, AL_SOURCE_RELATIVE, AL_TRUE );
alSourcefv( music_source, AL_POSITION, v );
alSourcefv( music_source, AL_VELOCITY, v );
/* Check for errors. */
al_checkErr();
/* Set state to none. */
music_state = 0;
soundUnlock();
/*
* Start up thread and have it inform us when it already reaches the main loop.
*/
musicLock();
music_state = MUSIC_STATE_STARTUP;
music_player = SDL_CreateThread( music_thread, NULL );
SDL_CondWait( music_state_cond, music_state_lock );
musicUnlock();
return 0;
}
开发者ID:ekrumme,项目名称:naev,代码行数:49,代码来源:music_openal.c
示例19: sound_al_loadWav
/**
* @brief Loads a wav file from the rw if possible.
*
* @note Closes the rw.
*
* @param snd Sound to load wav into.
* @param rw Data for the wave.
*/
static int sound_al_loadWav( alSound *snd, SDL_RWops *rw )
{
SDL_AudioSpec wav_spec;
Uint32 wav_length;
Uint8 *wav_buffer;
ALenum format;
SDL_RWseek( rw, 0, SEEK_SET );
/* Load WAV. */
if (SDL_LoadWAV_RW( rw, 0, &wav_spec, &wav_buffer, &wav_length) == NULL) {
WARN(_("SDL_LoadWav_RW failed: %s"), SDL_GetError());
return -1;
}
/* Handle format. */
switch (wav_spec.format) {
case AUDIO_U8:
case AUDIO_S8:
format = (wav_spec.channels==1) ? AL_FORMAT_MONO8 : AL_FORMAT_STEREO8;
break;
case AUDIO_U16LSB:
case AUDIO_S16LSB:
format = (wav_spec.channels==1) ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16;
break;
case AUDIO_U16MSB:
case AUDIO_S16MSB:
WARN( _("Big endian WAVs unsupported!") );
return -1;
default:
WARN( _("Invalid WAV format!") );
return -1;
}
/* Load into openal. */
soundLock();
/* Create new buffer. */
alGenBuffers( 1, &snd->u.al.buf );
/* Put into the buffer. */
alBufferData( snd->u.al.buf, format, wav_buffer, wav_length, wav_spec.freq );
soundUnlock();
/* Clean up. */
free( wav_buffer );
return 0;
}
开发者ID:naev,项目名称:naev,代码行数:54,代码来源:sound_openal.c
示例20: sound_al_loadOgg
/**
* @brief Loads an ogg file from a tested format if possible.
*
* @param snd Sound to load ogg into.
* @param vf Vorbisfile containing the song.
*/
static int sound_al_loadOgg( alSound *snd, OggVorbis_File *vf )
{
int ret;
long i;
int section;
vorbis_info *info;
ALenum format;
ogg_int64_t len;
char *buf;
/* Finish opening the file. */
ret = ov_test_open(vf);
if (ret) {
WARN("Failed to finish loading OGG file: %s", vorbis_getErr(ret) );
return -1;
}
/* Get file information. */
info = ov_info( vf, -1 );
format = (info->channels == 1) ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16;
len = ov_pcm_total( vf, -1 ) * info->channels * 2;
/* Allocate memory. */
buf = malloc( len );
/* Fill buffer. */
i = 0;
while (i < len) {
/* Fill buffer with data in the 16 bit signed samples format. */
i += ov_read( vf, &buf[i], len-i, VORBIS_ENDIAN, 2, 1, §ion );
}
soundLock();
/* Create new buffer. */
alGenBuffers( 1, &snd->u.al.buf );
/* Put into buffer. */
alBufferData( snd->u.al.buf, format, buf, len, info->rate );
soundUnlock();
/* Clean up. */
free(buf);
ov_clear(vf);
return 0;
}
开发者ID:Delll,项目名称:naev,代码行数:51,代码来源:sound_openal.c
注:本文中的soundLock函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论