コード例 #1
0
ファイル: al.c プロジェクト: jayschwa/q2pro
void AL_Update(void)
{
    int         i;
    channel_t   *ch;
    vec_t       orientation[6];

    if (!s_active) {
        return;
    }

    paintedtime = cl.time;

    // set listener parameters
    qalListener3f(AL_POSITION, AL_UnpackVector(listener_origin));
    AL_CopyVector(listener_forward, orientation);
    AL_CopyVector(listener_up, orientation + 3);
    qalListenerfv(AL_ORIENTATION, orientation);
    qalListenerf(AL_GAIN, s_volume->value);
    qalDistanceModel(AL_LINEAR_DISTANCE_CLAMPED);

    // update spatialization for dynamic sounds
    ch = channels;
    for (i = 0; i < s_numchannels; i++, ch++) {
        if (!ch->sfx)
            continue;

        if (ch->autosound) {
            // autosounds are regenerated fresh each frame
            if (ch->autoframe != s_framecount) {
                AL_StopChannel(ch);
                continue;
            }
        } else {
            ALenum state;

            qalGetError();
            qalGetSourcei(ch->srcnum, AL_SOURCE_STATE, &state);
            if (qalGetError() != AL_NO_ERROR || state == AL_STOPPED) {
                AL_StopChannel(ch);
                continue;
            }
        }

#ifdef _DEBUG
        if (s_show->integer) {
            Com_Printf("%.1f %s\n", ch->master_vol, ch->sfx->name);
            //    total++;
        }
#endif

        AL_Spatialize(ch);         // respatialize channel
    }

    s_framecount++;

    // add loopsounds
    AL_AddLoopSounds();

    AL_IssuePlaysounds();
}
コード例 #2
0
ファイル: openal.c プロジェクト: axltxl/hecatomb
 /*
  * Main update function. Called every frame,
  * performes all necessary calculations.
  */
 void
 AL_Update ( void )
 {
   q_int32_t i;
   channel_t *ch;
   vec_t orientation[6];
   paintedtime = cl.time;
   /* set listener (player) parameters */
   AL_CopyVector ( listener_forward, orientation );
   AL_CopyVector ( listener_up, orientation + 3 );
   qalListenerf ( AL_GAIN, s_volume->value );
   qalListenerf ( AL_MAX_GAIN, s_openal_maxgain->value );
   qalDistanceModel ( AL_LINEAR_DISTANCE_CLAMPED );
   qalListener3f ( AL_POSITION, AL_UnpackVector ( listener_origin ) );
   qalListenerfv ( AL_ORIENTATION, orientation );
   /* update spatialization for dynamic sounds */
   ch = channels;

   for ( i = 0; i < s_numchannels; i++, ch++ ) {
     if ( !ch->sfx ) {
       continue;
     }

     if ( ch->autosound ) {
       /* autosounds are regenerated fresh each frame */
       if ( ch->autoframe != s_framecount ) {
         AL_StopChannel ( ch );
         continue;
       }
     } else {
       ALenum state;
       qalGetError();
       qalGetSourcei ( ch->srcnum, AL_SOURCE_STATE, &state );

       if ( ( qalGetError() != AL_NO_ERROR ) || ( state == AL_STOPPED ) ) {
         AL_StopChannel ( ch );
         continue;
       }
     }

     if ( s_show->value ) {
       Com_Printf ( "%3i %s\n", ch->master_vol, ch->sfx->name );
     }

     /* respatialize channel */
     AL_Spatialize ( ch );
   }

   s_framecount++;
   /* add loopsounds */
   AL_AddLoopSounds();
   /* add music */
 #ifdef HT_WITH_OGG
   OGG_Stream();
 #endif
   AL_StreamUpdate();
   AL_IssuePlaysounds();
 }