@ -50,9 +50,9 @@ namespace MWSound
, mListenerPos ( 0 , 0 , 0 )
, mListenerDir ( 1 , 0 , 0 )
, mListenerUp ( 0 , 0 , 1 )
, mPausedSoundTypes ( 0 )
, mUnderwaterSound ( nullptr )
, mNearWaterSound ( nullptr )
, mPlaybackPaused ( false )
{
mMasterVolume = Settings : : Manager : : getFloat ( " master volume " , " Sound " ) ;
mMasterVolume = std : : min ( std : : max ( mMasterVolume , 0.0f ) , 1.0f ) ;
@ -857,27 +857,52 @@ namespace MWSound
return false ;
}
void SoundManager : : pauseSounds ( int types )
void SoundManager : : pauseSounds ( BlockerType blocker , int types )
{
if ( mOutput - > isInitialized ( ) )
{
if ( mPausedSoundTypes [ blocker ] ! = 0 )
resumeSounds ( blocker ) ;
types = types & Type : : Mask ;
mOutput - > pauseSounds ( types ) ;
mPausedSoundTypes | = types ;
mPausedSoundTypes [ blocker ] = types ;
}
}
void SoundManager : : resumeSounds ( int types )
void SoundManager : : resumeSounds ( BlockerType blocker )
{
if ( mOutput - > isInitialized ( ) )
{
types = types & Type : : Mask & mPausedSoundTypes ;
mPausedSoundTypes [ blocker ] = 0 ;
int types = int ( Type : : Mask ) ;
for ( int currentBlocker = 0 ; currentBlocker < BlockerType : : MaxCount ; currentBlocker + + )
{
if ( currentBlocker ! = blocker )
types & = ~ mPausedSoundTypes [ currentBlocker ] ;
}
mOutput - > resumeSounds ( types ) ;
mPausedSoundTypes & = ~ types ;
}
}
void SoundManager : : pausePlayback ( )
{
if ( mPlaybackPaused )
return ;
mPlaybackPaused = true ;
mOutput - > pauseActiveDevice ( ) ;
}
void SoundManager : : resumePlayback ( )
{
if ( ! mPlaybackPaused )
return ;
mPlaybackPaused = false ;
mOutput - > resumeActiveDevice ( ) ;
}
void SoundManager : : updateRegionSound ( float duration )
{
@ -1201,7 +1226,7 @@ namespace MWSound
void SoundManager : : update ( float duration )
{
if ( ! mOutput - > isInitialized ( ) )
if ( ! mOutput - > isInitialized ( ) | | mPlaybackPaused )
return ;
updateSounds ( duration ) ;
@ -1399,5 +1424,7 @@ namespace MWSound
mUnusedStreams . push_back ( sound ) ;
}
mActiveTracks . clear ( ) ;
mPlaybackPaused = false ;
std : : fill ( std : : begin ( mPausedSoundTypes ) , std : : end ( mPausedSoundTypes ) , 0 ) ;
}
}