Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/audio
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-05-18 19:22:39 +0000
committerStijn Buys <ingar@osirion.org>2008-05-18 19:22:39 +0000
commit2f4c20a0b6fa0397d623d883ee48ba59563f1e2f (patch)
tree2186c4ada36a9bc832a89c662029d3b12bf1840e /src/audio
parentcc0a133a616aeff57887b27497e4a978b5697c04 (diff)
standard hail
Diffstat (limited to 'src/audio')
-rw-r--r--src/audio/Makefile.am4
-rw-r--r--src/audio/audio.cc23
-rw-r--r--src/audio/buffers.cc2
-rw-r--r--src/audio/buffers.h3
4 files changed, 18 insertions, 14 deletions
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<std::string, size_t>::iterator iterator;
static std::map<std::string, size_t> registry;