forked from teamnwah/openmw-tes3coop
Pass a decoder to the playStream sound output method
This commit is contained in:
parent
9c831d3039
commit
86bf6388c6
4 changed files with 12 additions and 10 deletions
|
@ -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;
|
boost::shared_ptr<OpenAL_SoundStream> sound;
|
||||||
ALuint src;
|
ALuint src;
|
||||||
|
@ -774,12 +774,10 @@ MWBase::SoundPtr OpenAL_Output::streamSound(const std::string &fname, float volu
|
||||||
src = mFreeSources.front();
|
src = mFreeSources.front();
|
||||||
mFreeSources.pop_front();
|
mFreeSources.pop_front();
|
||||||
|
|
||||||
|
if((flags&MWBase::SoundManager::Play_Loop))
|
||||||
|
std::cout <<"Warning: cannot loop stream \""<<decoder->getName()<<"\""<< std::endl;
|
||||||
try
|
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));
|
sound.reset(new OpenAL_SoundStream(*this, src, decoder));
|
||||||
}
|
}
|
||||||
catch(std::exception &e)
|
catch(std::exception &e)
|
||||||
|
|
|
@ -47,8 +47,8 @@ namespace MWSound
|
||||||
|
|
||||||
virtual MWBase::SoundPtr playSound(const std::string &fname, float volume, float pitch, int flags);
|
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,
|
virtual MWBase::SoundPtr playSound3D(const std::string &fname, const Ogre::Vector3 &pos,
|
||||||
float volume, float pitch, float min, float max, int flags);
|
float volume, float pitch, float min, float max, int flags);
|
||||||
virtual MWBase::SoundPtr streamSound(const std::string &fname, float volume, float pitch, 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);
|
virtual void updateListener(const Ogre::Vector3 &pos, const Ogre::Vector3 &atdir, const Ogre::Vector3 &updir, Environment env);
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,8 @@ namespace MWSound
|
||||||
|
|
||||||
virtual MWBase::SoundPtr playSound(const std::string &fname, float volume, float pitch, int flags) = 0;
|
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,
|
virtual MWBase::SoundPtr playSound3D(const std::string &fname, const Ogre::Vector3 &pos,
|
||||||
float volume, float pitch, float min, float max, int flags) = 0;
|
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;
|
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;
|
virtual void updateListener(const Ogre::Vector3 &pos, const Ogre::Vector3 &atdir, const Ogre::Vector3 &updir, Environment env) = 0;
|
||||||
|
|
||||||
|
|
|
@ -167,7 +167,11 @@ namespace MWSound
|
||||||
{
|
{
|
||||||
float basevol = mMasterVolume * mMusicVolume;
|
float basevol = mMasterVolume * mMusicVolume;
|
||||||
stopMusic();
|
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->mBaseVolume = basevol;
|
||||||
mMusic->mFlags = Play_NoEnv;
|
mMusic->mFlags = Play_NoEnv;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue