#ifndef _PIUMA_AUDIO_H_
#define _PIUMA_AUDIO_H_

#include "lib/types.h"
#include "platform.h"

typedef u64 track_id;

struct audio_track
{
	track_id id;
	p_audio_buffer data;
	u64 progress;
	bool playing;
	bool loop;
	bool free_on_finish;

	f32 volume;
};

struct audio_player
{
	audio_track *tracks;
	u32 track_count;
	u32 track_capacity;
	track_id next_id;

	u32 sample_rate;
};

enum audio_flags
{
	AUDIO_NONE = 0,
	AUDIO_LOOP = 1,
	AUDIO_PAUSED = 2,
	AUDIO_FREE_ON_FINISH = 4
};

void audio_init();
track_id audio_add_track(p_audio_buffer *data, u32 flags);
void audio_remove_track(track_id id);
void audio_pause_track(track_id id);
void audio_play_track(track_id id);
void audio_change_track_volume(track_id id, f32 volume);
audio_track *audio_track_from_id(track_id id);

#endif
