#include "resource_sound.h"

/* Initializes sound resource. */
bool
resource_sound_init(Resources* self, SoundType type)
{
	if (!sound_init(&self->sounds[type], SOUND_PATHS[type]))
	{
		printf(STRING_RESOURCE_ERROR, SOUND_PATHS[type]);
		return false;
	}

	printf(STRING_RESOURCE_INIT, SOUND_PATHS[type]);

	return true;
}

/* Frees sound resources. */
void
resource_sound_free(Resources* self, SoundType type)
{
	if (self->sounds[type].isInit)
	{
		sound_free(&self->sounds[type]);

		printf(STRING_RESOURCE_FREE, SOUND_PATHS[type]);
	}
}

/* Given an array, initializes sound resources. */
void
resource_sound_state_init(Resources* self, const SoundType* types, u32 count)
{
	for (s32 i = 0; i < (s32)count; i++)
		resource_sound_init(self, types[i]);
}

/* Frees sound resources. */
void
resource_sound_state_free(Resources* self, const SoundType* types, u32 count)
{
	for (s32 i = 0; i < (s32)count; i++)
		resource_sound_free(self, types[i]);
}
