1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-19 21:23:52 +00:00

Pass a decoder to the playStream sound output method

This commit is contained in:
Chris Robinson 2012-12-12 22:32:02 -08:00
parent 9c831d3039
commit 86bf6388c6
4 changed files with 12 additions and 10 deletions

View file

@ -764,7 +764,7 @@ MWBase::SoundPtr OpenAL_Output::playSound3D(const std::string &fname, const Ogre
}
MWBase::SoundPtr OpenAL_Output::streamSound(const std::string &fname, float volume, float pitch, int flags)
MWBase::SoundPtr OpenAL_Output::streamSound(DecoderPtr decoder, float volume, float pitch, int flags)
{
boost::shared_ptr<OpenAL_SoundStream> sound;
ALuint src;
@ -774,12 +774,10 @@ MWBase::SoundPtr OpenAL_Output::streamSound(const std::string &fname, float volu
src = mFreeSources.front();
mFreeSources.pop_front();
if((flags&MWBase::SoundManager::Play_Loop))
std::cout <<"Warning: cannot loop stream \""<<decoder->getName()<<"\""<< std::endl;
try
{
if((flags&MWBase::SoundManager::Play_Loop))
std::cout <<"Warning: cannot loop stream "<<fname<< std::endl;
DecoderPtr decoder = mManager.getDecoder();
decoder->open(fname);
sound.reset(new OpenAL_SoundStream(*this, src, decoder));
}
catch(std::exception &e)

View file

@ -47,8 +47,8 @@ namespace MWSound
virtual MWBase::SoundPtr playSound(const std::string &fname, float volume, float pitch, int flags);
virtual MWBase::SoundPtr playSound3D(const std::string &fname, const Ogre::Vector3 &pos,
float volume, float pitch, float min, float max, int flags);
virtual MWBase::SoundPtr streamSound(const std::string &fname, float volume, float pitch, int flags);
float volume, float pitch, float min, float max, int flags);
virtual MWBase::SoundPtr streamSound(DecoderPtr decoder, float volume, float pitch, int flags);
virtual void updateListener(const Ogre::Vector3 &pos, const Ogre::Vector3 &atdir, const Ogre::Vector3 &updir, Environment env);

View file

@ -26,8 +26,8 @@ namespace MWSound
virtual MWBase::SoundPtr playSound(const std::string &fname, float volume, float pitch, int flags) = 0;
virtual MWBase::SoundPtr playSound3D(const std::string &fname, const Ogre::Vector3 &pos,
float volume, float pitch, float min, float max, int flags) = 0;
virtual MWBase::SoundPtr streamSound(const std::string &fname, float volume, float pitch, int flags) = 0;
float volume, float pitch, float min, float max, int flags) = 0;
virtual MWBase::SoundPtr streamSound(DecoderPtr decoder, float volume, float pitch, int flags) = 0;
virtual void updateListener(const Ogre::Vector3 &pos, const Ogre::Vector3 &atdir, const Ogre::Vector3 &updir, Environment env) = 0;

View file

@ -167,7 +167,11 @@ namespace MWSound
{
float basevol = mMasterVolume * mMusicVolume;
stopMusic();
mMusic = mOutput->streamSound(filename, basevol, 1.0f, Play_NoEnv);
DecoderPtr decoder = getDecoder();
decoder->open(filename);
mMusic = mOutput->streamSound(decoder, basevol, 1.0f, Play_NoEnv);
mMusic->mBaseVolume = basevol;
mMusic->mFlags = Play_NoEnv;
}