示例#1
0
文件: sound.c 项目: damajor/play-dune
static void Driver_Music_LoadFile(const char *musicName)
{
    Driver *music = g_driverMusic;
    Driver *sound = g_driverSound;

    Driver_Music_Stop();

    if (music->index == 0xFFFF) return;

    if (music->content == sound->content) {
        music->content         = NULL;
        music->filename        = NULL;
        music->contentMalloced = false;
    } else {
        Driver_UnloadFile(music);
    }

    if (sound->filename != NULL && musicName != NULL && strcasecmp(Drivers_GenerateFilename(musicName, music), sound->filename) == 0) {
        g_driverMusic->content         = g_driverSound->content;
        g_driverMusic->filename        = g_driverSound->filename;
        g_driverMusic->contentMalloced = g_driverSound->contentMalloced;

        return;
    }

    Driver_LoadFile(musicName, music);
}
示例#2
0
void Driver_Sound_LoadFile(const char *musicName)
{
	Driver *sound = g_driverSound;
	Driver *music = g_driverMusic;

	Driver_Sound_Stop();

	if (sound->index == 0xFFFF) return;

	if (sound->content == music->content) {
		sound->content         = NULL;
		sound->filename        = NULL;
		sound->contentMalloced = false;
	} else {
		Driver_UnloadFile(sound);
	}

	if (music->filename != NULL) {
		char *filename;

		filename = Drivers_GenerateFilename(musicName, sound);

		if (strcasecmp(filename, music->filename) == 0) {
			sound->content         = music->content;
			sound->filename        = music->filename;
			sound->contentMalloced = music->contentMalloced;
			return;
		}
	}

	Driver_LoadFile(musicName, sound);
}
示例#3
0
void Driver_LoadFile(const char *musicName, Driver *driver)
{
	char *filename;

	filename = Drivers_GenerateFilename(musicName, driver);

	if (filename == NULL) return;

	Driver_UnloadFile(driver);

	driver->filename = malloc(strlen(filename) + 1);
	strcpy(driver->filename, filename);

	driver->content = File_ReadWholeFile(filename);
	driver->contentMalloced = true;
}