diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2018-03-26 14:28:20 +0200 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2018-03-26 14:28:20 +0200 |
commit | 0a7f8a48a9161e16e1366d492655fd7df04f48a3 (patch) | |
tree | 7d957232d075b390f9bdccfddddc968a2a9214f6 /src/audio.cpp | |
parent | a016a156e76f7394c5632da325ab0b453cfb3b37 (diff) |
Destroy sounds that finished playing.
Diffstat (limited to 'src/audio.cpp')
-rw-r--r-- | src/audio.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/audio.cpp b/src/audio.cpp index 012c396..2f70fee 100644 --- a/src/audio.cpp +++ b/src/audio.cpp @@ -19,14 +19,21 @@ along with Minitrem. If not, see <http://www.gnu.org/licenses/>. namespace audio { +static std::list<sf::Sound> playing_sounds; + +void clean_sounds(void) +{ + playing_sounds.remove_if( [](sf::Sound &sound) { + return sound.getStatus() == sf::Sound::Stopped; + }); +} + void sound_t::load(const char *path) { printf("load %s\n", path); buffer.loadFromFile(path); } -static std::list<sf::Sound> playing_sounds; - void sound_t::play(void) { auto sound = playing_sounds.emplace(playing_sounds.end()); |