mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-27 01:06:19 +00:00
Fixed: Always commit 3d positioning when calling play on sources. This avoids having to wait for update call. Sources no longer cause loud noise when ryzom client finishes loading
This commit is contained in:
parent
55a95afef0
commit
a87afeb44b
5 changed files with 69 additions and 14 deletions
|
@ -353,7 +353,7 @@ public:
|
|||
* In streaming mode, the time spent during buffer outruns is not
|
||||
* counted towards the playback time, and the playback time is
|
||||
* be the current time position in the entire submitted queue.
|
||||
* When using static buffers, the result is the tot time that the
|
||||
* When using static buffers, the result is the total time that the
|
||||
* attached buffer has been playing. If the source is looping, the
|
||||
* time will be the total of all playbacks of the buffer.
|
||||
* When the source is stopped, this will return the time where the
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace NLSOUND {
|
|||
CSourceAL::CSourceAL(CSoundDriverAL *soundDriver) :
|
||||
_SoundDriver(NULL), _Buffer(NULL), _Source(AL_NONE),
|
||||
_DirectFilter(AL_FILTER_NULL), _EffectFilter(AL_FILTER_NULL),
|
||||
_IsPlaying(false), _IsPaused(false), _StartTime(0),
|
||||
_IsPlaying(false), _IsPaused(false), _StartTime(0), _IsStreaming(false),
|
||||
_Pos(0.0f, 0.0f, 0.0f), _Gain(NLSOUND_DEFAULT_GAIN), _Alpha(1.0),
|
||||
_MinDistance(1.0f), _MaxDistance(numeric_limits<float>::max()),
|
||||
_Effect(NULL), _Direct(true),
|
||||
|
@ -100,7 +100,7 @@ void CSourceAL::updateManualRolloff()
|
|||
}
|
||||
|
||||
/// Enable or disable streaming mode. Source must be stopped to call this.
|
||||
void CSourceAL::setStreaming(bool /* streaming */)
|
||||
void CSourceAL::setStreaming(bool streaming)
|
||||
{
|
||||
nlassert(isStopped());
|
||||
|
||||
|
@ -108,6 +108,7 @@ void CSourceAL::setStreaming(bool /* streaming */)
|
|||
alSourcei(_Source, AL_BUFFER, AL_NONE);
|
||||
alTestError();
|
||||
_Buffer = NULL;
|
||||
_IsStreaming = streaming;
|
||||
}
|
||||
|
||||
/* Set the buffer that will be played (no streaming)
|
||||
|
@ -209,28 +210,36 @@ bool CSourceAL::getLooping() const
|
|||
/// Play the static buffer (or stream in and play)
|
||||
bool CSourceAL::play()
|
||||
{
|
||||
if ( _Buffer != NULL )
|
||||
// Commit 3D changes before starting play
|
||||
if (_SoundDriver->getOption(ISoundDriver::OptionManualRolloff))
|
||||
updateManualRolloff();
|
||||
|
||||
if (_Buffer)
|
||||
{
|
||||
// Static playing mode
|
||||
_IsPaused = false;
|
||||
alSourcePlay(_Source);
|
||||
_IsPlaying = alGetError() == AL_NO_ERROR;
|
||||
_IsPlaying = (alGetError() == AL_NO_ERROR);
|
||||
if (_IsPlaying)
|
||||
_StartTime = CTime::getLocalTime();
|
||||
return _IsPlaying;
|
||||
}
|
||||
else
|
||||
else if (_IsStreaming)
|
||||
{
|
||||
// TODO: Verify streaming mode?
|
||||
_IsPaused = false;
|
||||
alSourcePlay(_Source);
|
||||
_IsPlaying = true;
|
||||
_IsPlaying = (alGetError() == AL_NO_ERROR);
|
||||
if (_IsPlaying)
|
||||
_StartTime = CTime::getLocalTime(); // TODO: Played time should freeze when buffering fails, and be calculated based on the number of buffers played plus passed time. This is necessary for synchronizing animation with sound.
|
||||
return true;
|
||||
return _IsPlaying;
|
||||
// Streaming mode
|
||||
//nlwarning("AL: Cannot play null buffer; streaming not implemented" );
|
||||
//nlstop;
|
||||
}
|
||||
else
|
||||
{
|
||||
nlwarning("Invalid play call, not streaming and no static buffer assigned");
|
||||
}
|
||||
}
|
||||
|
||||
/// Stop playing
|
||||
|
|
|
@ -60,6 +60,8 @@ private:
|
|||
bool _IsPaused;
|
||||
NLMISC::TTime _StartTime;
|
||||
|
||||
bool _IsStreaming;
|
||||
|
||||
NLMISC::CVector _Pos;
|
||||
float _Gain;
|
||||
double _Alpha;
|
||||
|
|
|
@ -494,6 +494,8 @@ bool CSourceXAudio2::initFormat(IBuffer::TBufferFormat bufferFormat, uint8 chann
|
|||
setupVoiceSends();
|
||||
_SoundDriver->getXAudio2()->CommitChanges(_OperationSet);
|
||||
|
||||
// Also commit any 3D settings that were already done
|
||||
commit3DChanges();
|
||||
|
||||
// test
|
||||
//XAUDIO2_VOICE_DETAILS voice_details;
|
||||
|
@ -581,6 +583,11 @@ bool CSourceXAudio2::play()
|
|||
{
|
||||
// nldebug(NLSOUND_XAUDIO2_PREFIX "play");
|
||||
|
||||
// Commit 3D changes before starting play
|
||||
if (_SourceVoice)
|
||||
commit3DChanges();
|
||||
// else it is commit by the preparePlay > initFormat function
|
||||
|
||||
if (_IsPaused)
|
||||
{
|
||||
if (SUCCEEDED(_SourceVoice->Start(0))) _IsPaused = false;
|
||||
|
|
|
@ -183,8 +183,17 @@ void CStreamSource::play()
|
|||
// pSource->setPos( _Position, false);
|
||||
pSource->setPos(getVirtualPos(), false);
|
||||
pSource->setMinMaxDistances(m_StreamSound->getMinDistance(), m_StreamSound->getMaxDistance(), false);
|
||||
if (!m_Buffers[0]->isStereo())
|
||||
{
|
||||
setDirection(_Direction); // because there is a workaround inside
|
||||
pSource->setVelocity(_Velocity);
|
||||
}
|
||||
else
|
||||
{
|
||||
pSource->setDirection(NLMISC::CVector::Null);
|
||||
pSource->setCone(float(Pi * 2), float(Pi * 2), 1.0f);
|
||||
pSource->setVelocity(NLMISC::CVector::Null);
|
||||
}
|
||||
pSource->setGain(getFinalGain());
|
||||
pSource->setSourceRelativeMode(_RelativeMode);
|
||||
// pSource->setLooping(_Looping);
|
||||
|
@ -223,6 +232,34 @@ void CStreamSource::play()
|
|||
{
|
||||
CSourceCommon::play();
|
||||
m_WaitingForPlay = false;
|
||||
#if 1
|
||||
// Dump source info
|
||||
nlwarning("--- DUMP SOURCE INFO ---");
|
||||
nlwarning(" * getLooping: %s", getPhysicalSource()->getLooping() ? "YES" : "NO");
|
||||
nlwarning(" * isPlaying: %s", getPhysicalSource()->isPlaying() ? "YES" : "NO");
|
||||
nlwarning(" * isStopped: %s", getPhysicalSource()->isStopped() ? "YES" : "NO");
|
||||
nlwarning(" * isPaused: %s", getPhysicalSource()->isPaused() ? "YES" : "NO");
|
||||
nlwarning(" * getPos: %f, %f, %f", getPhysicalSource()->getPos().x, getPhysicalSource()->getPos().y, getPhysicalSource()->getPos().z);
|
||||
NLMISC::CVector v;
|
||||
getPhysicalSource()->getVelocity(v);
|
||||
nlwarning(" * getVelocity: %f, %f, %f", v.x, v.y, v.z);
|
||||
getPhysicalSource()->getDirection(v);
|
||||
nlwarning(" * getDirection: %f, %f, %f", v.x, v.y, v.z);
|
||||
nlwarning(" * getGain: %f", getPhysicalSource()->getGain());
|
||||
nlwarning(" * getPitch: %f", getPhysicalSource()->getPitch());
|
||||
nlwarning(" * getSourceRelativeMode: %s", getPhysicalSource()->getSourceRelativeMode() ? "YES" : "NO");
|
||||
float a, b, c;
|
||||
getPhysicalSource()->getMinMaxDistances(a, b);
|
||||
nlwarning(" * getMinMaxDistances: %f, %f", a, b);
|
||||
getPhysicalSource()->getCone(a, b, c);
|
||||
nlwarning(" * getCone: %f, %f", a, b, c);
|
||||
nlwarning(" * getDirect: %s", getPhysicalSource()->getDirect() ? "YES" : "NO");
|
||||
nlwarning(" * getDirectGain: %f", getPhysicalSource()->getDirectGain());
|
||||
nlwarning(" * isDirectFilterEnabled: %s", getPhysicalSource()->isDirectFilterEnabled() ? "YES" : "NO");
|
||||
nlwarning(" * getEffect: %s", getPhysicalSource()->getEffect() ? "YES" : "NO");
|
||||
nlwarning(" * getEffectGain: %f", getPhysicalSource()->getEffectGain());
|
||||
nlwarning(" * isEffectFilterEnabled: %s", getPhysicalSource()->isEffectFilterEnabled() ? "YES" : "NO");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue