From 2f4c20a0b6fa0397d623d883ee48ba59563f1e2f Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 18 May 2008 19:22:39 +0000 Subject: standard hail --- src/audio/Makefile.am | 4 ++-- src/audio/audio.cc | 23 +++++++++++++---------- src/audio/buffers.cc | 2 +- src/audio/buffers.h | 3 ++- 4 files changed, 18 insertions(+), 14 deletions(-) (limited to 'src/audio') diff --git a/src/audio/Makefile.am b/src/audio/Makefile.am index d1524cf..f1116d8 100644 --- a/src/audio/Makefile.am +++ b/src/audio/Makefile.am @@ -2,5 +2,5 @@ INCLUDES = -I$(top_srcdir)/src METASOURCES = AUTO noinst_LTLIBRARIES = libaudio.la libaudio_la_LDFLAGS = -avoid-version -no-undefined -noinst_HEADERS = audio.h buffers.h pcm.h wav.h -libaudio_la_SOURCES = audio.cc buffers.cc pcm.cc wav.cc +noinst_HEADERS = audio.h buffers.h pcm.h sources.h wav.h +libaudio_la_SOURCES = audio.cc buffers.cc pcm.cc sources.cc wav.cc diff --git a/src/audio/audio.cc b/src/audio/audio.cc index 3bd3c62..308667b 100644 --- a/src/audio/audio.cc +++ b/src/audio/audio.cc @@ -7,6 +7,7 @@ #include "audio/audio.h" #include "audio/buffers.h" #include "audio/pcm.h" +#include "audio/sources.h" #include "sys/sys.h" namespace audio @@ -15,8 +16,6 @@ namespace audio ALCdevice *audio_device = 0; ALCcontext *audio_context = 0; -ALuint source = 0; - void init() { con_print << "^BInitializing audio..."; @@ -37,12 +36,12 @@ void init() alGetError(); Buffers::init(); + + Sources::init(); //con_debug << " device ^B" << alcGetString(audio_device, ALC_DEFAULT_DEVICE_SPECIFIER) << std::endl; - load("ui/chat"); - - // default sound source - alGenSources(1, &source); + load("com/chat"); + load("com/hail"); } void load (const char *name) @@ -54,6 +53,10 @@ void shutdown() { con_print << "^BShutting down audio..."; + Sources::shutdown(); + + Buffers::shutdown(); + if (audio_context) { alcMakeContextCurrent(0); alcDestroyContext(audio_context); @@ -64,14 +67,14 @@ void shutdown() alcCloseDevice(audio_device); audio_device = 0; } - - alDeleteSources(1, &source); } void play(const char *name) { - Buffers::bind(source, std::string(name)); - alSourcePlay(source); + if (Sources::available(0)) { + Buffers::bind(Sources::ui(), std::string(name)); + alSourcePlay(Sources::ui()); + } } } diff --git a/src/audio/buffers.cc b/src/audio/buffers.cc index 9223380..f7fbbb5 100644 --- a/src/audio/buffers.cc +++ b/src/audio/buffers.cc @@ -23,7 +23,7 @@ void Buffers::init() alGenBuffers(MAXBUFFERS, buffers); if ((error = alGetError()) != AL_NO_ERROR) { - con_warn << "Error " << error << " initializing OpenAL bufers!" << std::endl; + con_warn << "Error " << error << " initializing OpenAL buffers!" << std::endl; return; } } diff --git a/src/audio/buffers.h b/src/audio/buffers.h index e61ba7b..53137e9 100644 --- a/src/audio/buffers.h +++ b/src/audio/buffers.h @@ -23,7 +23,6 @@ class Buffers { public: static void init(); static void shutdown(); - static void clear(); /// find previously loaded PCM data static size_t find(std::string name); @@ -35,6 +34,8 @@ public: static void bind(ALuint source, std::string name); private: + static void clear(); + typedef std::map::iterator iterator; static std::map registry; -- cgit v1.2.3