示例#1
0
void main_InitAudio(void) {
#ifdef USE_AUDIO
    if (audioinitialised) {
        return;
    }
    audioinitialised = 1;

    // get audio backend
    char* p = luastate_GetPreferredAudioBackend();

    // load FFmpeg if we happen to want it
    if (luastate_GetWantFFmpeg()) {
        audiosourceffmpeg_LoadFFmpeg();
    } else {
        audiosourceffmpeg_DisableFFmpeg();
    }

#if defined(USE_SDL_AUDIO) || defined(WINDOWS)
    char* error;

    // initialise audio - try 32bit first
    s16mixmode = 0;
#ifndef FORCES16AUDIO
    if (!audio_Init(&audiomixer_GetBuffer, 0, p, 0, &error)) {
        if (error) {
            free(error);
        }
#endif
        // try 16bit now
        s16mixmode = 1;
        if (!audio_Init(&audiomixer_GetBuffer, 0, p, 1, &error)) {
            printwarning("Warning: Failed to initialise audio: %s", error);
            if (error) {
                free(error);
            }
            // non-fatal: we will simulate audio manually:
            simulateaudio = 1;
            s16mixmode = 0;
        }
#ifndef FORCES16AUDIO
    }
#endif
    if (p) {
        free(p);
    }
#else  // USE_SDL_AUDIO || WINDOWS
    // simulate audio:
    simulateaudio = 1;
    s16mixmode = 0;
#endif  // USE_SDL_AUDIO || WINDOWS
#else // ifdef USE_AUDIO
    // we don't support any audio
    return;
#endif  // ifdef USE_AUDIO
}
示例#2
0
// ////////////////////////////////////////////////////////////////////////////
// ////////////////////////////////////////////////////////////////////////////
// Called once on program startup.
//
bool systemInitialise(void)
{
	if (!widgInitialise())
	{
		return false;
	}

	buildMapList();

	// Initialize render engine
	war_SetFog(war_GetFog());		// Set Fog mode based on user preferences
	if (!pie_Initialise())
	{
		debug(LOG_ERROR, "Unable to initialise renderer");
		return false;
	}
	
	if ( war_getSoundEnabled() )
	{
		if (!audio_Init(droidAudioTrackStopped))
		{
			debug(LOG_SOUND, "Could not initialise audio system: Continuing without audio");
		}
		if (war_GetMusicEnabled())
		{
			cdAudio_Open(UserMusicPath);
		}
	}
	else
	{
		debug(LOG_SOUND, "Sound disabled");
	}

	if (!dataInitLoadFuncs()) // Pass all the data loading functions to the framework library
	{
		return false;
	}

	if (!fpathInitialise())
	{
		return false;
	}

	// Initialize the iVis text rendering module
	iV_TextInit();

	iV_Reset();								// Reset the IV library.
	initLoadingScreen(true);

	readAIs();

	return true;
}
示例#3
0
// ////////////////////////////////////////////////////////////////////////////
// ////////////////////////////////////////////////////////////////////////////
// Called once on program startup.
//
bool systemInitialise(void)
{
	if (!widgInitialise())
	{
		return false;
	}

	buildMapList();

	// Initialize render engine
	if (!pie_Initialise())
	{
		debug(LOG_ERROR, "Unable to initialise renderer");
		return false;
	}

	if (!audio_Init(droidAudioTrackStopped, war_getSoundEnabled()))
	{
		debug(LOG_SOUND, "Continuing without audio");
	}
	if (war_getSoundEnabled() && war_GetMusicEnabled())
	{
		cdAudio_Open(UserMusicPath);
	}
	else
	{
		debug(LOG_SOUND, "Music disabled");
	}

	if (!dataInitLoadFuncs()) // Pass all the data loading functions to the framework library
	{
		return false;
	}

	if (!fpathInitialise())
	{
		return false;
	}

	// Initialize the iVis text rendering module
	iV_TextInit();

	// Fix badly named OpenGL functions. Must be done after iV_TextInit, to avoid the renames being clobbered by an extra glewInit() call.
	screen_EnableMissingFunctions();

	pie_InitRadar();
	iV_Reset();								// Reset the IV library.

	readAIs();

	return true;
}
示例#4
0
void audioTest()
{
	int i;

	for (i = 0; i < 10; i++)
	{
		// On non-debug builds prevent warnings about defining but not using dummyCB
		dummyCB(NULL);

		assert(audio_Shutdown());
		assert(audio_Init(dummyCB, true));
		assert(!audio_Disabled());
		audio_Update();
	}
	fprintf(stdout, "\tAudio self-test: PASSED\n");
}
示例#5
0
// ////////////////////////////////////////////////////////////////////////////
// ////////////////////////////////////////////////////////////////////////////
// Called once on program startup.
//
bool systemInitialise(void)
{
	if (!widgInitialise())
	{
		return false;
	}

	buildMapList();

	// Initialize render engine
	if (!pie_Initialise())
	{
		debug(LOG_ERROR, "Unable to initialise renderer");
		return false;
	}

	if (!audio_Init(droidAudioTrackStopped, war_getSoundEnabled()))
	{
		debug(LOG_SOUND, "Continuing without audio");
	}
	if (war_getSoundEnabled() && war_GetMusicEnabled())
	{
		cdAudio_Open(UserMusicPath);
	}
	else
	{
		debug(LOG_SOUND, "Music disabled");
	}

	if (!dataInitLoadFuncs()) // Pass all the data loading functions to the framework library
	{
		return false;
	}

	if (!fpathInitialise())
	{
		return false;
	}

	// Initialize the iVis text rendering module
	wzSceneBegin("Main menu loop");
	iV_TextInit();

	pie_InitRadar();

	return true;
}