Changed: #1031 Music is "stopped" when client is loading with OpenAL driver

This commit is contained in:
kervala 2010-07-28 20:28:16 +02:00
parent e38e41c707
commit 8a193abef3
3 changed files with 41 additions and 11 deletions

View file

@ -145,8 +145,9 @@ void CListenerAL::getOrientation( NLMISC::CVector& front, NLMISC::CVector& u
*/
void CListenerAL::setGain( float gain )
{
alListenerf( AL_GAIN, gain );
alTestError();
CSoundDriverAL::getInstance()->setGain(gain);
// alListenerf( AL_GAIN, gain );
// alTestError();
}
@ -155,14 +156,15 @@ void CListenerAL::setGain( float gain )
*/
float CListenerAL::getGain() const
{
ALfloat gain;
#ifdef NL_OS_WINDOWS
alGetListenerf( AL_GAIN, &gain );
#else
alGetListenerfv( AL_GAIN, &gain );
#endif
alTestError();
return gain;
return CSoundDriverAL::getInstance()->getGain();
// ALfloat gain;
//#ifdef NL_OS_WINDOWS
// alGetListenerf( AL_GAIN, &gain );
//#else
// alGetListenerfv( AL_GAIN, &gain );
//#endif
// alTestError();
// return gain;
}

View file

@ -173,7 +173,7 @@ uint32 NLSOUND_interfaceVersion ()
*/
CSoundDriverAL::CSoundDriverAL(ISoundDriver::IStringMapperProvider *stringMapper)
: _StringMapper(stringMapper), _AlDevice(NULL), _AlContext(NULL),
_NbExpBuffers(0), _NbExpSources(0), _RolloffFactor(1.f)
_NbExpBuffers(0), _NbExpSources(0), _RolloffFactor(1.f), _MasterGain(1.f)
{
alExtInit();
}
@ -698,6 +698,20 @@ void CSoundDriverAL::removeMusicChannel(CMusicChannelAL *musicChannel)
else nlwarning("AL: removeMusicChannel already called");
}
/// Set the gain
void CSoundDriverAL::setGain( float gain )
{
clamp(gain, 0.f, 1.f);
_MasterGain= gain;
// TODO: update all sources in not using manual rollof ?
}
/// Get the gain
float CSoundDriverAL::getGain()
{
return _MasterGain;
}
/// Delete a buffer or a source
bool CSoundDriverAL::deleteItem( ALuint name, TDeleteFunctionAL aldeletefunc, vector<ALuint>& names )
{

View file

@ -164,6 +164,17 @@ public:
/// (Internal) Remove music channel (should be called by the destructor of the music channel class).
void removeMusicChannel(CMusicChannelAL *musicChannel);
/** Set the gain (volume value inside [0 , 1]). (default: 1)
* 0.0 -> silence
* 0.5 -> -6dB
* 1.0 -> no attenuation
* values > 1 (amplification) not supported by most drivers
*/
void setGain( float gain );
/// Get the gain
float getGain();
protected:
/// Allocate nb new buffers or sources
@ -182,6 +193,9 @@ protected:
/// Delete a buffer or a source
bool deleteItem( ALuint name, TDeleteFunctionAL aldeletefunc, std::vector<ALuint>& names );
/// Master Volume [0,1]
float _MasterGain;
};