Merge with develop

--HG--
branch : compatibility-develop
This commit is contained in:
kervala 2015-11-15 12:59:01 +01:00
commit 201de6998f
2 changed files with 11 additions and 3 deletions

View file

@ -32,7 +32,7 @@ using namespace NLMISC;
namespace NLSOUND { namespace NLSOUND {
CSourceXAudio2::CSourceXAudio2(CSoundDriverXAudio2 *soundDriver) CSourceXAudio2::CSourceXAudio2(CSoundDriverXAudio2 *soundDriver)
: _SoundDriver(soundDriver), _SourceVoice(NULL), _StaticBuffer(NULL), _OperationSet(soundDriver->getUniqueOperationSet()), : _SoundDriver(soundDriver), _SourceVoice(NULL), _StaticBuffer(NULL), _LastPreparedBuffer(NULL), _OperationSet(soundDriver->getUniqueOperationSet()),
_Format(IBuffer::FormatUnknown), _Frequency(0), _PlayStart(0), _Format(IBuffer::FormatUnknown), _Frequency(0), _PlayStart(0),
_Doppler(1.0f), _Pos(0.0f, 0.0f, 0.0f), _Relative(false), _Alpha(1.0), _Doppler(1.0f), _Pos(0.0f, 0.0f, 0.0f), _Relative(false), _Alpha(1.0),
_DirectDryVoice(NULL), _DirectFilterVoice(NULL), _EffectDryVoice(NULL), _EffectFilterVoice(NULL), _DirectDryVoice(NULL), _DirectFilterVoice(NULL), _EffectDryVoice(NULL), _EffectFilterVoice(NULL),
@ -407,6 +407,7 @@ void CSourceXAudio2::submitStreamingBuffer(IBuffer *buffer)
uint32 frequency; uint32 frequency;
buffer->getFormat(bufferFormat, channels, bitsPerSample, frequency); buffer->getFormat(bufferFormat, channels, bitsPerSample, frequency);
preparePlay(bufferFormat, channels, bitsPerSample, frequency); preparePlay(bufferFormat, channels, bitsPerSample, frequency);
_LastPreparedBuffer = NULL;
} }
submitBuffer(static_cast<CBufferXAudio2 *>(buffer)); submitBuffer(static_cast<CBufferXAudio2 *>(buffer));
@ -455,7 +456,8 @@ void CSourceXAudio2::setLooping(bool l)
if (FAILED(_SourceVoice->FlushSourceBuffers())) if (FAILED(_SourceVoice->FlushSourceBuffers()))
nlwarning(NLSOUND_XAUDIO2_PREFIX "FAILED FlushSourceBuffers"); nlwarning(NLSOUND_XAUDIO2_PREFIX "FAILED FlushSourceBuffers");
// resubmit with updated looping settings // resubmit with updated looping settings
submitBuffer(_StaticBuffer); if (_LastPreparedBuffer == _StaticBuffer)
submitBuffer(_StaticBuffer);
} }
else else
{ {
@ -478,7 +480,8 @@ void CSourceXAudio2::setLooping(bool l)
if (FAILED(_SourceVoice->FlushSourceBuffers())) if (FAILED(_SourceVoice->FlushSourceBuffers()))
nlwarning(NLSOUND_XAUDIO2_PREFIX "FAILED FlushSourceBuffers"); nlwarning(NLSOUND_XAUDIO2_PREFIX "FAILED FlushSourceBuffers");
// queue buffer with correct looping parameters // queue buffer with correct looping parameters
submitBuffer(_StaticBuffer); if (_LastPreparedBuffer == _StaticBuffer)
submitBuffer(_StaticBuffer);
} }
} }
} }
@ -635,6 +638,7 @@ bool CSourceXAudio2::play()
_StaticBuffer->getChannels(), _StaticBuffer->getChannels(),
_StaticBuffer->getBitsPerSample(), _StaticBuffer->getBitsPerSample(),
_StaticBuffer->getFrequency()); _StaticBuffer->getFrequency());
_LastPreparedBuffer = _StaticBuffer;
submitBuffer(_StaticBuffer); submitBuffer(_StaticBuffer);
_PlayStart = CTime::getLocalTime(); _PlayStart = CTime::getLocalTime();
if (SUCCEEDED(_SourceVoice->Start(0))) _IsPlaying = true; if (SUCCEEDED(_SourceVoice->Start(0))) _IsPlaying = true;
@ -663,6 +667,8 @@ void CSourceXAudio2::stop()
// stop source voice and remove pending buffers // stop source voice and remove pending buffers
_SoundDriver->getXAudio2()->CommitChanges(_OperationSet); _SoundDriver->getXAudio2()->CommitChanges(_OperationSet);
if (FAILED(_SourceVoice->ExitLoop()))
nlwarning(NLSOUND_XAUDIO2_PREFIX "FAILED ExitLoop");
if (FAILED(_SourceVoice->Stop(0))) if (FAILED(_SourceVoice->Stop(0)))
nlwarning(NLSOUND_XAUDIO2_PREFIX "FAILED Stop"); nlwarning(NLSOUND_XAUDIO2_PREFIX "FAILED Stop");
if (FAILED(_SourceVoice->FlushSourceBuffers())) if (FAILED(_SourceVoice->FlushSourceBuffers()))

View file

@ -41,6 +41,8 @@ private:
CSoundDriverXAudio2 *_SoundDriver; CSoundDriverXAudio2 *_SoundDriver;
/// Buffer that should be playing. /// Buffer that should be playing.
CBufferXAudio2 *_StaticBuffer; CBufferXAudio2 *_StaticBuffer;
/// Last buffer that was prepared for playing.
CBufferXAudio2 *_LastPreparedBuffer;
// -- Pointers -- // -- Pointers --
/// Source voice, can be NULL! /// Source voice, can be NULL!