From 92b7703265c83b9dfec702ada156d78fe4eb93ea Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 12 Jun 2012 17:32:22 +0200 Subject: WINTERMUTE: Add some loop-support to BSoundBuffer. --- engines/wintermute/Base/BSoundBuffer.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'engines/wintermute/Base') diff --git a/engines/wintermute/Base/BSoundBuffer.cpp b/engines/wintermute/Base/BSoundBuffer.cpp index 9751ad44c0..bbec1342c3 100644 --- a/engines/wintermute/Base/BSoundBuffer.cpp +++ b/engines/wintermute/Base/BSoundBuffer.cpp @@ -176,18 +176,24 @@ HRESULT CBSoundBuffer::LoadFromFile(const char *Filename, bool ForceReload) { ////////////////////////////////////////////////////////////////////////// -HRESULT CBSoundBuffer::Play(bool Looping, uint32 StartSample) { - // TODO: looping +HRESULT CBSoundBuffer::Play(bool looping, uint32 startSample) { + if (startSample != 0) { + warning("BSoundBuffer::Play - Should start playback at %d, but currently we don't", startSample); + } if (_stream) { - SetLooping(Looping); - g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, _handle, _stream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO); + if (looping) { + Audio::AudioStream *loopStream = Audio::makeLoopingAudioStream(_stream, 0); + g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, _handle, loopStream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::YES); + } else { + g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, _handle, _stream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::YES); + } } return S_OK; } ////////////////////////////////////////////////////////////////////////// void CBSoundBuffer::SetLooping(bool looping) { - warning("BSoundBuffer::SetLooping - not implemented yet"); + warning("BSoundBuffer::SetLooping(%d) - not implemented yet", looping); #if 0 _looping = looping; -- cgit v1.2.3