mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-10 09:19:01 +00:00
Changed: #1031 Music is "stopped" when client is loading with OpenAL driver
This commit is contained in:
parent
f768181706
commit
878996d64d
3 changed files with 41 additions and 11 deletions
|
@ -145,8 +145,9 @@ void CListenerAL::getOrientation( NLMISC::CVector& front, NLMISC::CVector& u
|
||||||
*/
|
*/
|
||||||
void CListenerAL::setGain( float gain )
|
void CListenerAL::setGain( float gain )
|
||||||
{
|
{
|
||||||
alListenerf( AL_GAIN, gain );
|
CSoundDriverAL::getInstance()->setGain(gain);
|
||||||
alTestError();
|
// alListenerf( AL_GAIN, gain );
|
||||||
|
// alTestError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -155,14 +156,15 @@ void CListenerAL::setGain( float gain )
|
||||||
*/
|
*/
|
||||||
float CListenerAL::getGain() const
|
float CListenerAL::getGain() const
|
||||||
{
|
{
|
||||||
ALfloat gain;
|
return CSoundDriverAL::getInstance()->getGain();
|
||||||
#ifdef NL_OS_WINDOWS
|
// ALfloat gain;
|
||||||
alGetListenerf( AL_GAIN, &gain );
|
//#ifdef NL_OS_WINDOWS
|
||||||
#else
|
// alGetListenerf( AL_GAIN, &gain );
|
||||||
alGetListenerfv( AL_GAIN, &gain );
|
//#else
|
||||||
#endif
|
// alGetListenerfv( AL_GAIN, &gain );
|
||||||
alTestError();
|
//#endif
|
||||||
return gain;
|
// alTestError();
|
||||||
|
// return gain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -173,7 +173,7 @@ uint32 NLSOUND_interfaceVersion ()
|
||||||
*/
|
*/
|
||||||
CSoundDriverAL::CSoundDriverAL(ISoundDriver::IStringMapperProvider *stringMapper)
|
CSoundDriverAL::CSoundDriverAL(ISoundDriver::IStringMapperProvider *stringMapper)
|
||||||
: _StringMapper(stringMapper), _AlDevice(NULL), _AlContext(NULL),
|
: _StringMapper(stringMapper), _AlDevice(NULL), _AlContext(NULL),
|
||||||
_NbExpBuffers(0), _NbExpSources(0), _RolloffFactor(1.f)
|
_NbExpBuffers(0), _NbExpSources(0), _RolloffFactor(1.f), _MasterGain(1.f)
|
||||||
{
|
{
|
||||||
alExtInit();
|
alExtInit();
|
||||||
}
|
}
|
||||||
|
@ -698,6 +698,20 @@ void CSoundDriverAL::removeMusicChannel(CMusicChannelAL *musicChannel)
|
||||||
else nlwarning("AL: removeMusicChannel already called");
|
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
|
/// Delete a buffer or a source
|
||||||
bool CSoundDriverAL::deleteItem( ALuint name, TDeleteFunctionAL aldeletefunc, vector<ALuint>& names )
|
bool CSoundDriverAL::deleteItem( ALuint name, TDeleteFunctionAL aldeletefunc, vector<ALuint>& names )
|
||||||
{
|
{
|
||||||
|
|
|
@ -164,6 +164,17 @@ public:
|
||||||
/// (Internal) Remove music channel (should be called by the destructor of the music channel class).
|
/// (Internal) Remove music channel (should be called by the destructor of the music channel class).
|
||||||
void removeMusicChannel(CMusicChannelAL *musicChannel);
|
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:
|
protected:
|
||||||
|
|
||||||
/// Allocate nb new buffers or sources
|
/// Allocate nb new buffers or sources
|
||||||
|
@ -182,6 +193,9 @@ protected:
|
||||||
|
|
||||||
/// Delete a buffer or a source
|
/// Delete a buffer or a source
|
||||||
bool deleteItem( ALuint name, TDeleteFunctionAL aldeletefunc, std::vector<ALuint>& names );
|
bool deleteItem( ALuint name, TDeleteFunctionAL aldeletefunc, std::vector<ALuint>& names );
|
||||||
|
|
||||||
|
/// Master Volume [0,1]
|
||||||
|
float _MasterGain;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue