Пример #1
0
bool SFXSound::_releaseVoice()
{
   if( !mVoice )
      return true;
      
   // Refuse to release a voice for a streaming buffer that
   // is not coming from a profile.  For streaming buffers, we will
   // have to release the buffer, too, and without a profile we don't
   // know how to recreate the stream.
   
   if( isStreaming() && !mTrack )
      return false;
      
   // If we're currently playing, transfer our playback position
   // to the playtimer so we can virtualize playback while not
   // having a voice.

   SFXStatus status = getLastStatus();
   if( status == SFXStatusPlaying || status == SFXStatusBlocked )
   {
      // Sync up the play timer with the voice's current position to make
      // sure we handle any lag that's cropped up.
      
      mPlayTimer.setPosition( mVoice->getPosition() );

      if( status == SFXStatusBlocked )
         status = SFXStatusPlaying;
   }

   mVoice = NULL;
   
   // If this is a streaming source, release our buffer, too.
   // Otherwise the voice will stick around as it is uniquely assigned to
   // the buffer.  When we get reassigned a voice, we will have to do
   // a full stream seek anyway, so it's no real loss here.
   
   if( isStreaming() )
      mBuffer = NULL;
   
   #ifdef DEBUG_SPEW
   Platform::outputDebugString( "[SFXSound] release voice for source '%i' (status: %s)",
      getId(), SFXStatusToString( status ) );
   #endif
   
   return true;
}
Пример #2
0
bool SFXSource::_setStatus( SFXStatus status )
{
   if ( mStatus == status )
      return false;

   mStatus = status;

   // Do the callback if we have it.

   const char* statusString = SFXStatusToString( mStatus );
   if ( mStatusCallback && mStatusCallback[0] )
      Con::executef( mStatusCallback, getIdString(), statusString );
   else if ( getNamespace() )
      Con::executef( this, "onStatusChange", statusString );

   return true;
}