mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-23 02:42:39 +01:00
Implement stopMusic method
This commit is contained in:
parent
861dbf0c2a
commit
5294b40c40
@ -33,6 +33,8 @@ class MADStream : public sf::SoundStream
|
||||
size_t currentBuffer = 0;
|
||||
ALuint alSource;
|
||||
|
||||
bool stopped = false;
|
||||
|
||||
static inline signed int scale(mad_fixed_t sample);
|
||||
static mad_flow ms_header(void* user, mad_header const* header);
|
||||
static mad_flow ms_input(void* user, mad_stream* stream);
|
||||
@ -50,6 +52,7 @@ public:
|
||||
|
||||
bool openFromFile(const std::string& loc);
|
||||
void play();
|
||||
void stop();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -26,6 +26,7 @@ public:
|
||||
|
||||
bool loadMusic(const std::string& name, const std::string& fileName);
|
||||
void playMusic(const std::string& name);
|
||||
void stopMusic(const std::string& name);
|
||||
|
||||
void pause(bool p);
|
||||
|
||||
|
@ -49,6 +49,10 @@ mad_flow MADStream::ms_output(void* user, mad_header const* header, mad_pcm* pcm
|
||||
|
||||
MADStream* self = static_cast<MADStream*>(user);
|
||||
|
||||
if (self->stopped) {
|
||||
return MAD_FLOW_STOP;
|
||||
}
|
||||
|
||||
int nsamples = pcm->length;
|
||||
mad_fixed_t const *left, *right;
|
||||
|
||||
@ -153,3 +157,9 @@ void MADStream::play()
|
||||
{
|
||||
alCheck(alSourcePlay(alSource));
|
||||
}
|
||||
|
||||
void MADStream::stop()
|
||||
{
|
||||
stopped = true;
|
||||
alCheck(alSourcePlay(alSource));
|
||||
}
|
||||
|
@ -136,6 +136,10 @@ void SoundManager::playMusic(const std::string& name)
|
||||
{
|
||||
musics[name].play();
|
||||
}
|
||||
void SoundManager::stopMusic(const std::string& name)
|
||||
{
|
||||
musics[name].stop();
|
||||
}
|
||||
|
||||
void SoundManager::pause(bool p)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user