From 9caf289046ed2639f1935fb1c87133af4f7f6cac Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Mon, 12 Jan 2009 21:57:36 +0000 Subject: Fixes OpenAL reset sequence. --- src/audio/audio.cc | 8 +++++--- src/audio/buffers.cc | 20 +++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) (limited to 'src/audio') diff --git a/src/audio/audio.cc b/src/audio/audio.cc index 84c7e0e..2192e2f 100644 --- a/src/audio/audio.cc +++ b/src/audio/audio.cc @@ -60,9 +60,11 @@ void reset() { con_print << "^BInitializing audio..." << std::endl; - Sources::reset(); - Buffers::reset(); - + Sources::shutdown(); + Buffers::shutdown(); + Buffers::init(); + Sources::init(); + load("ui/nosnd"); load("ui/console"); } diff --git a/src/audio/buffers.cc b/src/audio/buffers.cc index 33c4dbf..df47d2a 100644 --- a/src/audio/buffers.cc +++ b/src/audio/buffers.cc @@ -19,11 +19,11 @@ ALuint Buffers::buffers[MAXBUFFERS]; void Buffers::init() { - int error; - clear(); - + clear(); + alGenBuffers(MAXBUFFERS, buffers); + int error; if ((error = alGetError()) != AL_NO_ERROR) { con_warn << "Error " << error << " initializing OpenAL buffers!" << std::endl; return; @@ -33,7 +33,13 @@ void Buffers::init() void Buffers::shutdown() { alDeleteBuffers(MAXBUFFERS, buffers); - + + int error; + if ((error = alGetError()) != AL_NO_ERROR) { + con_warn << "Error " << error << " clearing OpenAL buffers!" << std::endl; + return; + } + clear(); } @@ -46,8 +52,8 @@ void Buffers::clear() void Buffers::reset() { - shutdown(); - init(); + //shutdown(); + //init(); } size_t Buffers::load(std::string name) @@ -114,7 +120,7 @@ void Buffers::bind(ALuint source, size_t id) int error; alSourcei(source, AL_BUFFER, buffers[id]); if ((error = alGetError()) != AL_NO_ERROR) { - con_warn << "Error " << std::hex << error << " binding buffer " << buffers[id] << " to source " << source << std::endl; + con_warn << "Error " << error << " binding buffer " << buffers[id] << " to source " << source << std::endl; } } -- cgit v1.2.3