//
// Created by sebastian on 04.08.26.
//

#include "AudioDevice.h"

engine::audio::AudioDevice::AudioDevice() {
    m_device = alcOpenDevice(nullptr);
    if (!m_device) {
        throw std::runtime_error("Kein Audio-Device gefunden");
    }

    m_context = alcCreateContext(m_device, nullptr);
    if (!m_context) {
        throw std::runtime_error("Kein Audio-Context gefunden");
    }
    alcMakeContextCurrent(m_context);
}

engine::audio::AudioDevice::~AudioDevice() {
    alcMakeContextCurrent(nullptr);
    if (m_context) alcDestroyContext(m_context);
    if (m_device) alcCloseDevice(m_device);
}
