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

#ifndef COLORRACE_SOUNDBUFFER_H
#define COLORRACE_SOUNDBUFFER_H
#include <string>

#include "al.h"

namespace engine::audio {
    class SoundBuffer {
    public:
        explicit SoundBuffer(ALuint bufferID) : m_bufferID(bufferID) {}
        ~SoundBuffer();

        SoundBuffer(const SoundBuffer&) = delete;

        SoundBuffer& operator=(const SoundBuffer&) = delete;

        SoundBuffer(SoundBuffer&& other) noexcept;
        SoundBuffer& operator=(SoundBuffer&& other) noexcept;

        ALuint id() const {
            return m_bufferID;
        }
    private:
        ALuint m_bufferID = 0;

        void release() {
            if (m_bufferID != 0) {
                alDeleteBuffers(1, &m_bufferID);
                m_bufferID = 0;
            }
        }
    };
} // engine

#endif //COLORRACE_SOUNDBUFFER_H
