From af39f2e08b0503db723ae707a5c7278d8c85f812 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Tue, 1 Oct 2019 20:50:28 -0400 Subject: Audio component loading, getting ready to play --- src/audio.cpp | 25 +++++++++++++++++++++++++ src/audio.hpp | 3 +++ src/components/Audio.hpp | 17 +++++++++++++---- src/engine.cpp | 2 ++ src/script.cpp | 10 ++++++++++ 5 files changed, 53 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/audio.cpp b/src/audio.cpp index 975cfce..8bb1413 100644 --- a/src/audio.cpp +++ b/src/audio.cpp @@ -20,13 +20,19 @@ #include "audio.hpp" +#include +#include + AudioSystem::AudioSystem(void) : device(nullptr, [](ALCdevice *d) { alcCloseDevice(d); }), context(nullptr, [](ALCcontext *c) { alcDestroyContext(c); }) {} AudioSystem::~AudioSystem(void) { + alutExit(); + // Delete context before device + alcMakeContextCurrent(nullptr); context.reset(); device.reset(); } @@ -46,6 +52,9 @@ void AudioSystem::configure([[maybe_unused]] entityx::EntityManager& entities, context.reset(alcCreateContext(device.get(), nullptr)); if (!alcMakeContextCurrent(context.get())) return; // TODO Another uh oh + + if (alutInitWithoutContext(nullptr, nullptr) != AL_TRUE) + return; // TODO Third uh oh } void AudioSystem::update([[maybe_unused]] entityx::EntityManager& entities, @@ -56,10 +65,26 @@ void AudioSystem::update([[maybe_unused]] entityx::EntityManager& entities, void AudioSystem::receive(const entityx::ComponentAddedEvent