1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-31 22:45:35 +00:00

Allow specifying a type for the playTrack method

This commit is contained in:
Chris Robinson 2012-12-18 01:35:20 -08:00
parent 72ffceb206
commit a5356e194e
4 changed files with 9 additions and 8 deletions

View file

@ -34,15 +34,16 @@ namespace MWBase
class SoundManager class SoundManager
{ {
public: public:
/* These must all fit together */
enum PlayMode { enum PlayMode {
Play_Normal = 0, /* tracked, non-looping, multi-instance, environment */ Play_Normal = 0, /* tracked, non-looping, multi-instance, environment */
Play_Loop = 1<<0, /* Sound will continually loop until explicitly stopped */ Play_Loop = 1<<0, /* Sound will continually loop until explicitly stopped */
Play_NoEnv = 1<<1, /* Do not apply environment effects (eg, underwater filters) */ Play_NoEnv = 1<<1, /* Do not apply environment effects (eg, underwater filters) */
Play_NoTrack = 1<<2, /* (3D only) Play the sound at the given object's position Play_NoTrack = 1<<2 /* (3D only) Play the sound at the given object's position
* but do not keep it updated (the sound will not move with * but do not keep it updated (the sound will not move with
* the object and will not stop when the object is deleted. */ * the object and will not stop when the object is deleted. */
};
enum PlayType {
Play_TypeSfx = 0, /* Normal SFX sound */ Play_TypeSfx = 0, /* Normal SFX sound */
Play_TypeVoice = 1<<3, /* Voice sound */ Play_TypeVoice = 1<<3, /* Voice sound */
Play_TypeMusic = 1<<4, /* Music track */ Play_TypeMusic = 1<<4, /* Music track */
@ -97,7 +98,7 @@ namespace MWBase
virtual void stopSay(MWWorld::Ptr reference=MWWorld::Ptr()) = 0; virtual void stopSay(MWWorld::Ptr reference=MWWorld::Ptr()) = 0;
///< Stop an actor speaking ///< Stop an actor speaking
virtual SoundPtr playTrack(const MWSound::DecoderPtr& decoder) = 0; virtual SoundPtr playTrack(const MWSound::DecoderPtr& decoder, PlayType type) = 0;
///< Play a 2D audio track, using a custom decoder ///< Play a 2D audio track, using a custom decoder
virtual SoundPtr playSound(const std::string& soundId, float volume, float pitch, virtual SoundPtr playSound(const std::string& soundId, float volume, float pitch,

View file

@ -869,7 +869,7 @@ int VideoState::stream_open(int stream_index, AVFormatContext *pFormatCtx)
this->audio_st = pFormatCtx->streams + stream_index; this->audio_st = pFormatCtx->streams + stream_index;
decoder.reset(new MovieAudioDecoder(this)); decoder.reset(new MovieAudioDecoder(this));
this->AudioTrack = MWBase::Environment::get().getSoundManager()->playTrack(decoder); this->AudioTrack = MWBase::Environment::get().getSoundManager()->playTrack(decoder, MWBase::SoundManager::Play_TypeMovie);
if(!this->AudioTrack) if(!this->AudioTrack)
{ {
avcodec_close((*this->audio_st)->codec); avcodec_close((*this->audio_st)->codec);

View file

@ -268,14 +268,14 @@ namespace MWSound
} }
MWBase::SoundPtr SoundManager::playTrack(const DecoderPtr& decoder) MWBase::SoundPtr SoundManager::playTrack(const DecoderPtr& decoder, PlayType type)
{ {
MWBase::SoundPtr track; MWBase::SoundPtr track;
if(!mOutput->isInitialized()) if(!mOutput->isInitialized())
return track; return track;
try try
{ {
track = mOutput->streamSound(decoder, mMasterVolume, 1.0f, Play_NoEnv|Play_TypeMovie); track = mOutput->streamSound(decoder, mMasterVolume, 1.0f, Play_NoEnv|type);
} }
catch(std::exception &e) catch(std::exception &e)
{ {

View file

@ -103,7 +103,7 @@ namespace MWSound
virtual void stopSay(MWWorld::Ptr reference=MWWorld::Ptr()); virtual void stopSay(MWWorld::Ptr reference=MWWorld::Ptr());
///< Stop an actor speaking ///< Stop an actor speaking
virtual MWBase::SoundPtr playTrack(const DecoderPtr& decoder); virtual MWBase::SoundPtr playTrack(const DecoderPtr& decoder, PlayType type);
///< Play a 2D audio track, using a custom decoder ///< Play a 2D audio track, using a custom decoder
virtual MWBase::SoundPtr playSound(const std::string& soundId, float volume, float pitch, int mode=Play_Normal); virtual MWBase::SoundPtr playSound(const std::string& soundId, float volume, float pitch, int mode=Play_Normal);