From 637617056b4a6015a151ce8342e57e312c40a662 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 17 Mar 2012 02:45:18 -0700 Subject: [PATCH] Make a skeleton Sound class --- apps/openmw/mwsound/sound.hpp | 22 ++++++++++++++++++++++ apps/openmw/mwsound/soundmanager.cpp | 14 ++++++++------ apps/openmw/mwsound/soundmanager.hpp | 3 +++ 3 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 apps/openmw/mwsound/sound.hpp diff --git a/apps/openmw/mwsound/sound.hpp b/apps/openmw/mwsound/sound.hpp new file mode 100644 index 0000000000..9d262416eb --- /dev/null +++ b/apps/openmw/mwsound/sound.hpp @@ -0,0 +1,22 @@ +#ifndef GAME_SOUND_SOUND_H +#define GAME_SOUND_SOUND_H + +#include + +namespace MWSound +{ + class Sound + { + virtual bool Play() = 0; + virtual void Stop() = 0; + virtual bool isPlaying() = 0; + + public: + virtual ~Sound() { } + + friend class OpenAL_Output; + friend class SoundManager; + }; +} + +#endif diff --git a/apps/openmw/mwsound/soundmanager.cpp b/apps/openmw/mwsound/soundmanager.cpp index 17dfa5ef5b..d231f1d4ad 100644 --- a/apps/openmw/mwsound/soundmanager.cpp +++ b/apps/openmw/mwsound/soundmanager.cpp @@ -14,6 +14,7 @@ #include "sound_output.hpp" #include "sound_decoder.hpp" +#include "sound.hpp" #include "openal_output.hpp" #define SOUND_OUT "OpenAL" @@ -143,15 +144,18 @@ namespace MWSound void SoundManager::stopMusic() { + if(mMusic) + mMusic->Stop(); setPlaylist(); } void SoundManager::streamMusicFull(const std::string& filename) { - // Play the sound and tell it to stream, if possible. TODO: - // Store the reference, the jukebox will need to check status, - // control volume etc. + if(mMusic) + mMusic->Stop(); + std::auto_ptr decoder(new DEFAULT_DECODER); + //mMusic.reset(Output->StreamSound(filename, decoder)); } void SoundManager::streamMusic(const std::string& filename) @@ -186,9 +190,7 @@ namespace MWSound bool SoundManager::isMusicPlaying() { - // HACK: Return true to prevent the engine from trying to keep playing - // music and tanking the framerate. - return true; + return mMusic && mMusic->isPlaying(); } bool SoundManager::setPlaylist(std::string playlist) diff --git a/apps/openmw/mwsound/soundmanager.hpp b/apps/openmw/mwsound/soundmanager.hpp index 5a58c60b77..709ab2817d 100644 --- a/apps/openmw/mwsound/soundmanager.hpp +++ b/apps/openmw/mwsound/soundmanager.hpp @@ -23,6 +23,7 @@ namespace MWSound { class Sound_Output; class Sound_Decoder; + class Sound; class SoundManager { @@ -36,6 +37,8 @@ namespace MWSound std::auto_ptr Output; + boost::shared_ptr mMusic; + void streamMusicFull(const std::string& filename); ///< Play a soundifle /// \param absolute filename