mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-22 17:53:53 +00:00
Make a skeleton Sound class
This commit is contained in:
parent
246b0266fb
commit
637617056b
3 changed files with 33 additions and 6 deletions
22
apps/openmw/mwsound/sound.hpp
Normal file
22
apps/openmw/mwsound/sound.hpp
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#ifndef GAME_SOUND_SOUND_H
|
||||||
|
#define GAME_SOUND_SOUND_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
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
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include "sound_output.hpp"
|
#include "sound_output.hpp"
|
||||||
#include "sound_decoder.hpp"
|
#include "sound_decoder.hpp"
|
||||||
|
#include "sound.hpp"
|
||||||
|
|
||||||
#include "openal_output.hpp"
|
#include "openal_output.hpp"
|
||||||
#define SOUND_OUT "OpenAL"
|
#define SOUND_OUT "OpenAL"
|
||||||
|
@ -143,15 +144,18 @@ namespace MWSound
|
||||||
|
|
||||||
void SoundManager::stopMusic()
|
void SoundManager::stopMusic()
|
||||||
{
|
{
|
||||||
|
if(mMusic)
|
||||||
|
mMusic->Stop();
|
||||||
setPlaylist();
|
setPlaylist();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SoundManager::streamMusicFull(const std::string& filename)
|
void SoundManager::streamMusicFull(const std::string& filename)
|
||||||
{
|
{
|
||||||
// Play the sound and tell it to stream, if possible. TODO:
|
if(mMusic)
|
||||||
// Store the reference, the jukebox will need to check status,
|
mMusic->Stop();
|
||||||
// control volume etc.
|
std::auto_ptr<Sound_Decoder> decoder(new DEFAULT_DECODER);
|
||||||
|
//mMusic.reset(Output->StreamSound(filename, decoder));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundManager::streamMusic(const std::string& filename)
|
void SoundManager::streamMusic(const std::string& filename)
|
||||||
|
@ -186,9 +190,7 @@ namespace MWSound
|
||||||
|
|
||||||
bool SoundManager::isMusicPlaying()
|
bool SoundManager::isMusicPlaying()
|
||||||
{
|
{
|
||||||
// HACK: Return true to prevent the engine from trying to keep playing
|
return mMusic && mMusic->isPlaying();
|
||||||
// music and tanking the framerate.
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SoundManager::setPlaylist(std::string playlist)
|
bool SoundManager::setPlaylist(std::string playlist)
|
||||||
|
|
|
@ -23,6 +23,7 @@ namespace MWSound
|
||||||
{
|
{
|
||||||
class Sound_Output;
|
class Sound_Output;
|
||||||
class Sound_Decoder;
|
class Sound_Decoder;
|
||||||
|
class Sound;
|
||||||
|
|
||||||
class SoundManager
|
class SoundManager
|
||||||
{
|
{
|
||||||
|
@ -36,6 +37,8 @@ namespace MWSound
|
||||||
|
|
||||||
std::auto_ptr<Sound_Output> Output;
|
std::auto_ptr<Sound_Output> Output;
|
||||||
|
|
||||||
|
boost::shared_ptr<Sound> mMusic;
|
||||||
|
|
||||||
void streamMusicFull(const std::string& filename);
|
void streamMusicFull(const std::string& filename);
|
||||||
///< Play a soundifle
|
///< Play a soundifle
|
||||||
/// \param absolute filename
|
/// \param absolute filename
|
||||||
|
|
Loading…
Reference in a new issue