diff options
Diffstat (limited to 'src/audio')
-rw-r--r-- | src/audio/audio.cc | 15 | ||||
-rw-r--r-- | src/audio/audio.h | 3 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/audio/audio.cc b/src/audio/audio.cc index 304174c..3f505c0 100644 --- a/src/audio/audio.cc +++ b/src/audio/audio.cc @@ -193,6 +193,21 @@ size_t loop(size_t source_index, size_t buffer_index, float pitch, float gain) return buffer_index; } +size_t stop(size_t source_index) +{ + if (!audio_initialized) + return 0; + + ALuint source = Sources::source(source_index); + ALint srcstate = 0; + alGetSourcei(source , AL_SOURCE_STATE , &srcstate); + if (srcstate == AL_PLAYING) { + alSourceStop(source); + } + + return source_index; +} + size_t loop(size_t source_index, const char *name, float pitch, float gain) { if (!audio_initialized) diff --git a/src/audio/audio.h b/src/audio/audio.h index bab3402..f95e872 100644 --- a/src/audio/audio.h +++ b/src/audio/audio.h @@ -54,6 +54,9 @@ size_t loop(size_t source_index, const char *name, float pitch = 1.0f, float gai /// play a looping sound from a specified buffer on a specified source size_t loop(size_t source_index, size_t buffer_index, float pitch, float gain); +/// stop playback of a specific source +size_t stop(size_t source_index); + /// update source parameters void update_source(size_t source_index, math::Vector3f const & location, math::Vector3f const & velocity, float pitch = 1.0f, float gain = 1.0f); |