fix: master volume not updating on playing sounds. (via smx)
This commit is contained in:
+1
-1
@@ -583,7 +583,7 @@ void RageSound::ApplyParams()
|
||||
m_pSource->SetProperty( "FadeInSeconds", m_Param.m_fFadeInSeconds );
|
||||
m_pSource->SetProperty( "FadeSeconds", m_Param.m_fFadeOutSeconds );
|
||||
|
||||
float fVolume = m_Param.m_Volume * SOUNDMAN->GetMixVolume();
|
||||
float fVolume = m_Param.m_Volume;
|
||||
if( !m_Param.m_bIsCriticalSound )
|
||||
fVolume *= m_Param.m_fAttractVolume;
|
||||
m_pSource->SetProperty( "Volume", fVolume );
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "Foreach.h"
|
||||
#include "LocalizedString.h"
|
||||
#include "Preference.h"
|
||||
#include "RageSoundReader_PostBuffering.h"
|
||||
|
||||
#include "arch/Sound/RageSoundDriver.h"
|
||||
|
||||
@@ -35,7 +36,7 @@ static Preference<RString> g_sSoundDrivers( "SoundDrivers", "" ); // "" == DEFAU
|
||||
|
||||
RageSoundManager *SOUNDMAN = NULL;
|
||||
|
||||
RageSoundManager::RageSoundManager(): m_pDriver(NULL), m_fMixVolume(1.0f),
|
||||
RageSoundManager::RageSoundManager(): m_pDriver(NULL),
|
||||
m_fVolumeOfNonCriticalSounds(1.0f) {}
|
||||
|
||||
static LocalizedString COULDNT_FIND_SOUND_DRIVER( "RageSoundManager", "Couldn't find a sound driver that works" );
|
||||
@@ -187,9 +188,7 @@ static Preference<float> g_fSoundVolume( "SoundVolume", 1.0f );
|
||||
|
||||
void RageSoundManager::SetMixVolume()
|
||||
{
|
||||
g_SoundManMutex.Lock(); /* lock for access to m_fMixVolume */
|
||||
m_fMixVolume = clamp( g_fSoundVolume.Get(), 0.0f, 1.0f );
|
||||
g_SoundManMutex.Unlock(); /* finished with m_fMixVolume */
|
||||
RageSoundReader_PostBuffering::SetMasterVolume( g_fSoundVolume.Get() );
|
||||
}
|
||||
|
||||
void RageSoundManager::SetVolumeOfNonCriticalSounds( float fVolumeOfNonCriticalSounds )
|
||||
|
||||
@@ -29,7 +29,6 @@ public:
|
||||
|
||||
void Init();
|
||||
|
||||
float GetMixVolume() const { return m_fMixVolume; }
|
||||
void SetMixVolume();
|
||||
float GetVolumeOfNonCriticalSounds() const { return m_fVolumeOfNonCriticalSounds; }
|
||||
void SetVolumeOfNonCriticalSounds( float fVolumeOfNonCriticalSounds );
|
||||
@@ -54,7 +53,6 @@ private:
|
||||
RageSoundDriver *m_pDriver;
|
||||
|
||||
/* Prefs: */
|
||||
float m_fMixVolume;
|
||||
float m_fVolumeOfNonCriticalSounds;
|
||||
// Swallow up warnings. If they must be used, define them.
|
||||
RageSoundManager& operator=(const RageSoundManager& rhs);
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
#include "global.h"
|
||||
#include "RageSoundReader_PostBuffering.h"
|
||||
#include "RageSoundUtil.h"
|
||||
#include "RageThreads.h"
|
||||
#include "RageUtil.h"
|
||||
|
||||
/*
|
||||
* This filter is normally inserted after extended buffering, implementing
|
||||
* properties that do not seek the sound, allowing these properties to be
|
||||
* changed with low latency.
|
||||
*/
|
||||
RageMutex g_Mutex("PostBuffering");
|
||||
static float g_fMasterVolume = 1.0f;
|
||||
|
||||
RageSoundReader_PostBuffering::RageSoundReader_PostBuffering( RageSoundReader *pSource ):
|
||||
RageSoundReader_Filter( pSource )
|
||||
@@ -14,6 +18,10 @@ RageSoundReader_PostBuffering::RageSoundReader_PostBuffering( RageSoundReader *p
|
||||
m_fVolume = 1.0f;
|
||||
}
|
||||
|
||||
void RageSoundReader_PostBuffering::SetMasterVolume(float fVolume) {
|
||||
LockMut(g_Mutex);
|
||||
g_fMasterVolume = fVolume;
|
||||
}
|
||||
|
||||
int RageSoundReader_PostBuffering::Read( float *pBuf, int iFrames )
|
||||
{
|
||||
@@ -21,8 +29,14 @@ int RageSoundReader_PostBuffering::Read( float *pBuf, int iFrames )
|
||||
if( iFrames < 0 )
|
||||
return iFrames;
|
||||
|
||||
if( m_fVolume != 1.0f )
|
||||
RageSoundUtil::Attenuate( pBuf, iFrames * this->GetNumChannels(), m_fVolume );
|
||||
// Combine the sound's volume with master volume.
|
||||
g_Mutex.Lock();
|
||||
float fVolume = m_fVolume * g_fMasterVolume;
|
||||
fVolume = clamp( fVolume, 0, 1 );
|
||||
g_Mutex.Unlock();
|
||||
|
||||
if( fVolume != 1.0f )
|
||||
RageSoundUtil::Attenuate( pBuf, iFrames * this->GetNumChannels(), fVolume );
|
||||
|
||||
return iFrames;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ class RageSoundReader_PostBuffering: public RageSoundReader_Filter
|
||||
public:
|
||||
RageSoundReader_PostBuffering( RageSoundReader *pSource );
|
||||
RageSoundReader_PostBuffering *Copy() const { return new RageSoundReader_PostBuffering(*this); }
|
||||
static void SetMasterVolume( float fVolume );
|
||||
virtual int Read( float *pBuf, int iFrames );
|
||||
virtual bool SetProperty( const RString &sProperty, float fValue );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user