diff options
Diffstat (limited to 'src/audio/audio.cc')
-rw-r--r-- | src/audio/audio.cc | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/audio/audio.cc b/src/audio/audio.cc index 729f3d2..8880780 100644 --- a/src/audio/audio.cc +++ b/src/audio/audio.cc @@ -71,12 +71,25 @@ void shutdown() void play(const char *name) { - Buffers::load(std::string(name)); + if (!audio_context) + return; - if (Sources::available(0)) { - alSourceRewind(Sources::ui()); - Buffers::bind(Sources::ui(), std::string(name)); - alSourcePlay(Sources::ui()); + size_t buffer = Buffers::load(std::string(name)); + + ALint state; + for (size_t i = 0; i < MAXUISOURCES; i++) { + ALuint source = Sources::source(i); + alGetSourcei(source , AL_SOURCE_STATE , &state); + if (state != AL_PLAYING) { + //alSourceRewind(Sources::source(i)); + Buffers::bind(source, buffer); + alSourcef(source, AL_PITCH, 1.0); + alSourcef(source, AL_GAIN, 1.0); + alSourcePlay(source); + + } else { + con_debug << "source " << Sources::source(i) << " playing!" << std::endl; + } } } |