#include "sound.h"

/* Initializes a sound. */
bool
sound_init(Sound* self, const char* path)
{
	self->chunk = Mix_LoadWAV(path);

	if (!self->chunk)
		return false;

	self->isInit = true;

	return true;
}

/* Frees a sound. */
void
sound_free(Sound* self)
{
	if (self->isInit)
	{
		Mix_FreeChunk(self->chunk);
		self->isInit = false;
	}
}

/* Plays a sound, specifying a channel. */
void
sound_play(Sound* self, s32 channel)
{
	Mix_PlayChannel(-1, self->chunk, 0);
}

/* Stops a channel. */
void
sound_channel_stop(s32 channel)
{
	Mix_HaltChannel(channel);
}
