Esempio n. 1
0
int Mix_EachSoundFont(int (*function)(const char*, void*), void *data)
{
	char *context, *path, *paths;
	const char* cpaths = Mix_GetSoundFonts();

	if (!cpaths) {
		Mix_SetError("No SoundFonts have been requested");
		return 0;
	}

	if (!(paths = SDL_strdup(cpaths))) {
		Mix_SetError("Insufficient memory to iterate over SoundFonts");
		return 0;
	}

#if defined(__MINGW32__) || defined(__MINGW64__)
	for (path = strtok(paths, ";"); path; path = strtok(NULL, ";")) {
#elif defined(_WIN32)
	for (path = strtok_s(paths, ";", &context); path; path = strtok_s(NULL, ";", &context)) {
#else
	for (path = strtok_r(paths, ":;", &context); path; path = strtok_r(NULL, ":;", &context)) {
#endif
		if (!function(path, data)) {
			SDL_free(paths);
			return 0;
		}
	}

	SDL_free(paths);
	return 1;
}
Esempio n. 2
0
static mrb_value
mrb_sdl2_mixer_get_sound_fonts(mrb_state *mrb, mrb_value self)
{
  return mrb_str_new_cstr(mrb, Mix_GetSoundFonts());
}