/* ================= S_AL_SrcKill ================= */ static void S_AL_SrcKill(srcHandle_t src) { // I'm not touching it. Unlock it first. if(srcList[src].isLocked) return; // Stop it if it's playing if(srcList[src].isActive) qalSourceStop(srcList[src].alSource); // Remove the entity association if((srcList[src].isLooping) && (srcList[src].entity != -1)) { int ent = srcList[src].entity; entityList[ent].srcAllocated = qfalse; entityList[ent].srcIndex = -1; entityList[ent].loopAddedThisFrame = qfalse; entityList[ent].startLoopingSound = qfalse; } // Remove the buffer qalSourcei(srcList[src].alSource, AL_BUFFER, 0); srcList[src].sfx = 0; srcList[src].lastUsedTime = 0; srcList[src].priority = 0; srcList[src].entity = -1; srcList[src].channel = -1; srcList[src].isActive = qfalse; srcList[src].isLocked = qfalse; srcList[src].isLooping = qfalse; srcList[src].isTracking = qfalse; srcList[src].local = qfalse; }
/* ================= S_AL_StopBackgroundTrack ================= */ static void S_AL_StopBackgroundTrack( void ) { int num; if(!musicPlaying) return; // Stop playing qalSourceStop(musicSource); // De-queue the musicBuffers qalGetSourcei(musicSource, AL_BUFFERS_PROCESSED, &num); if(num < NUM_MUSIC_BUFFERS) Com_Printf(S_COLOR_YELLOW "WARNING: fewer than NUM_MUSIC_BUFFERS buffers can be unqueued\n"); qalSourceUnqueueBuffers(musicSource, NUM_MUSIC_BUFFERS, musicBuffers); // Destroy the musicBuffers qalDeleteBuffers(NUM_MUSIC_BUFFERS, musicBuffers); // Free the musicSource S_AL_MusicSourceFree(); // Unload the stream S_AL_CloseMusicFiles(); musicPlaying = qfalse; }
void al_stream_update() { int processed; ALint state; if ( source_handle == -1 ) { return; } // Un-queue any buffers, and delete them qalGetSourcei( source, AL_BUFFERS_PROCESSED, &processed ); if ( processed ) { while ( processed-- ) { ALuint buffer; qalSourceUnqueueBuffers( source, 1, &buffer ); qalDeleteBuffers( 1, &buffer ); } } // If it's stopped, release the source qalGetSourcei( source, AL_SOURCE_STATE, &state ); if ( state == AL_STOPPED ) { is_playing = qfalse; qalSourceStop( source ); free_channel(); } }
void S_StopBackgroundTrack( void ) { bgTrack_t *next; if( source ) qalSourceStop( source ); if( alloced_buffers ) { qalSourceUnqueueBuffers( source, MUSIC_BUFFERS, buffers ); qalDeleteBuffers( MUSIC_BUFFERS, buffers ); alloced_buffers = queued_buffers = qfalse; } music_source_free(); qalGetError(); while( s_bgTrackHead ) { next = s_bgTrackHead->anext; S_CloseMusicTrack( s_bgTrackHead ); S_Free( s_bgTrackHead ); s_bgTrackHead = next; } s_bgTrack = NULL; s_bgTrackHead = NULL; s_bgTrackBuffering = qfalse; s_bgTrackPaused = qfalse; }
void SndAl_StopBackgroundTrack( void ) { if ( !mus_playing ) { return; } // Stop playing qalSourceStop( source ); // De-queue the buffers qalSourceUnqueueBuffers( source, BUFFERS, buffers ); // Destroy the buffers qalDeleteBuffers( BUFFERS, buffers ); // Free the source al_mus_source_free(); // Unload the stream if ( mus_stream ) { si.StreamClose( mus_stream ); } mus_stream = NULL; mus_playing = qfalse; }
/* ================= S_AL_StreamDie ================= */ static void S_AL_StreamDie( void ) { if(streamSourceHandle == -1) return; streamPlaying = qfalse; qalSourceStop(streamSource); S_AL_FreeStreamChannel(); }
void AL_StopChannel( channel_t *ch ) { if (s_show->value > 1) Com_Printf("%s: %s\n", __func__, ch->sfx->name ); // stop it qalSourceStop( ch->srcnum ); qalSourcei( ch->srcnum, AL_BUFFER, AL_NONE ); memset (ch, 0, sizeof(*ch)); }
void al_stream_die() { if ( source_handle == -1 ) { return; } is_playing = qfalse; qalSourceStop( source ); free_channel(); }
void AL_StopChannel( channel_t *ch ) { #ifdef _DEBUG if (s_show->integer > 1) Com_Printf("%s: %s\n", __func__, ch->sfx->name ); #endif // stop it qalSourceStop( ch->srcnum ); qalSourcei( ch->srcnum, AL_BUFFER, AL_NONE ); memset (ch, 0, sizeof(*ch)); }
/* ================= S_AL_StreamDie ================= */ static void S_AL_StreamDie( int stream ) { if ((stream < 0) || (stream >= MAX_RAW_STREAMS)) return; if(streamSourceHandles[stream] == -1) return; streamPlaying[stream] = qfalse; qalSourceStop(streamSources[stream]); S_AL_FreeStreamChannel(stream); }
/* * Silence / stop all OpenAL streams */ static void AL_StreamDie ( void ) { q_int32_t numBuffers; streamPlaying = false; qalSourceStop ( streamSource ); /* Un-queue any buffers, and delete them */ qalGetSourcei ( streamSource, AL_BUFFERS_QUEUED, &numBuffers ); while ( numBuffers-- ) { ALuint buffer; qalSourceUnqueueBuffers ( streamSource, 1, &buffer ); qalDeleteBuffers ( 1, &buffer ); active_buffers--; } }
/* * source_kill */ static void source_kill( src_t *src ) { if( src->isLocked ) return; if( src->isActive ) qalSourceStop( src->source ); qalSourcei( src->source, AL_BUFFER, AL_NONE ); src->sfx = 0; src->lastUse = 0; src->priority = 0; src->entNum = -1; src->channel = -1; src->fvol = 1; src->isActive = qfalse; src->isLocked = qfalse; src->isLooping = qfalse; src->isTracking = qfalse; }
/* * S_ShutdownSources */ void S_ShutdownSources( void ) { int i; if( !src_inited ) return; // Destroy all the sources for( i = 0; i < src_count; i++ ) { qalSourceStop( srclist[i].source ); qalDeleteSources( 1, &srclist[i].source ); } memset( srclist, 0, sizeof( srclist ) ); S_Free( entlist ); entlist = NULL; src_inited = qfalse; }
/* ================= S_AL_SrcShutdown ================= */ static void S_AL_SrcShutdown( void ) { int i; if(!alSourcesInitialised) return; // Destroy all the sources for(i = 0; i < srcCount; i++) { if(srcList[i].isLocked) Com_DPrintf( S_COLOR_YELLOW "WARNING: Source %d is locked\n", i); qalSourceStop(srcList[i].alSource); qalDeleteSources(1, &srcList[i].alSource); } memset(srcList, 0, sizeof(srcList)); alSourcesInitialised = qfalse; }
/* ================= S_AL_StopBackgroundTrack ================= */ static void S_AL_StopBackgroundTrack( void ) { if(!musicPlaying) return; // Stop playing qalSourceStop(musicSource); // De-queue the musicBuffers qalSourceUnqueueBuffers(musicSource, NUM_MUSIC_BUFFERS, musicBuffers); // Destroy the musicBuffers qalDeleteBuffers(NUM_MUSIC_BUFFERS, musicBuffers); // Free the musicSource S_AL_MusicSourceFree(); // Unload the stream S_AL_CloseMusicFiles(); musicPlaying = qfalse; }
/* ================= S_AL_SrcUpdate Update state (move things around, manage sources, and so on) ================= */ static void S_AL_SrcUpdate( void ) { int i; int entityNum; ALint state; src_t *curSource; for(i = 0; i < srcCount; i++) { entityNum = srcList[i].entity; curSource = &srcList[i]; if(curSource->isLocked) continue; if(!curSource->isActive) continue; // Update source parameters if((s_alGain->modified)||(s_volume->modified)) curSource->curGain = s_alGain->value * s_volume->value; if((s_alRolloff->modified)&&(!curSource->local)) qalSourcef(curSource->alSource, AL_ROLLOFF_FACTOR, s_alRolloff->value); if(s_alMinDistance->modified) qalSourcef(curSource->alSource, AL_REFERENCE_DISTANCE, s_alMinDistance->value); if(curSource->isLooping) { sentity_t *sent = &entityList[ entityNum ]; // If a looping effect hasn't been touched this frame, kill it if(sent->loopAddedThisFrame) { // The sound has changed without an intervening removal if(curSource->isActive && !sent->startLoopingSound && curSource->sfx != sent->loopSfx) { qalSourceStop(curSource->alSource); qalSourcei(curSource->alSource, AL_BUFFER, 0); sent->startLoopingSound = qtrue; } // The sound hasn't been started yet if(sent->startLoopingSound) { S_AL_SrcSetup(i, sent->loopSfx, sent->loopPriority, entityNum, -1, curSource->local); curSource->isLooping = qtrue; qalSourcei(curSource->alSource, AL_LOOPING, AL_TRUE); qalSourcePlay(curSource->alSource); sent->startLoopingSound = qfalse; } // Update locality if(curSource->local) { qalSourcei(curSource->alSource, AL_SOURCE_RELATIVE, AL_TRUE); qalSourcef(curSource->alSource, AL_ROLLOFF_FACTOR, 0.0f); } else { qalSourcei(curSource->alSource, AL_SOURCE_RELATIVE, AL_FALSE); qalSourcef(curSource->alSource, AL_ROLLOFF_FACTOR, s_alRolloff->value); } } else S_AL_SrcKill( i ); continue; } // Check if it's done, and flag it qalGetSourcei(curSource->alSource, AL_SOURCE_STATE, &state); if(state == AL_STOPPED) { S_AL_SrcKill(i); continue; } // Query relativity of source, don't move if it's true qalGetSourcei(curSource->alSource, AL_SOURCE_RELATIVE, &state); // See if it needs to be moved if(curSource->isTracking && !state) { qalSourcefv(curSource->alSource, AL_POSITION, entityList[entityNum].origin); S_AL_ScaleGain(curSource, entityList[entityNum].origin); } } }