#if !defined(LD_OS_AUDIO_H_)
#define LD_OS_AUDIO_H_

typedef struct Audio_Data Audio_Data;
struct Audio_Data {
	S16 *samples;
	U32 n_frames;
};

typedef struct Audio_Track Audio_Track;
struct Audio_Track {
	B32 playing;

	Audio_Data *data;

	F32 volume;

	U32 n_played;
	U32 next; // to play if playing, free otherwise
};

typedef struct Audio_Context Audio_Context;
struct Audio_Context {
	SDL_AudioStream *stream;

	U32 n_tracks;
	Audio_Track tracks[16];

	U32 head;
	U32 free;

	F32 volume;

	U32 n_sounds;
	Audio_Data *sounds;
};

function void Audio_Init(M_Arena *arena, Audio_Context *audio, F32 volume);
function U32  Audio_Play(Audio_Context *audio, U32 index);

function void Audio_ChangeVolume(Audio_Context *audio, U32 handle, F32 volume);

#endif  // LD_OS_AUDIO_H_
