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

#include "SoundBuffer.h"

#include <dr_wav.h>
#include <stdexcept>

#include "AudioDevice.h"

namespace engine::audio {
    SoundBuffer::~SoundBuffer() {
        if (m_bufferID) alDeleteBuffers(1, &m_bufferID);
    }

    SoundBuffer::SoundBuffer(SoundBuffer &&other) noexcept : m_bufferID(other.m_bufferID) {
        other.m_bufferID = 0;
    }

    SoundBuffer & SoundBuffer::operator=(SoundBuffer &&other) noexcept {
        if (this != &other) {
            release();

            m_bufferID = other.m_bufferID;
            other.m_bufferID = 0;
        }

        return *this;
    }
} // engine