// Initialize music subsystem dboolean I_InitMusic(void) { // If SDL_mixer is not initialized, we have to initialize it // and have the responsibility to shut it down later on. if (!SDLIsInitialized()) if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) I_Error("Unable to set up sound: %s", SDL_GetError()); else if (Mix_OpenAudio(snd_samplerate, MIX_DEFAULT_FORMAT, CHANNELS, SAMPLECOUNT * snd_samplerate / 11025) < 0) { SDL_QuitSubSystem(SDL_INIT_AUDIO); I_Error("Error initializing SDL2_mixer: %s", Mix_GetError()); } SDL_PauseAudio(0); tempmusicfilename = M_TempFile(PACKAGE".mid"); sdl_was_initialized = true; music_initialized = true; // Once initialization is complete, the temporary Timidity config // file can be removed. RemoveTimidityConfig(); return music_initialized; }
// Initialize music subsystem static boolean I_SDL_InitMusic(void) { // If SDL_mixer is not initialized, we have to initialize it // and have the responsibility to shut it down later on. if (SDLIsInitialized()) { music_initialized = true; } else { if (SDL_Init(SDL_INIT_AUDIO) < 0) { fprintf(stderr, "Unable to set up sound.\n"); } else if (Mix_OpenAudio(snd_samplerate, AUDIO_S16SYS, 2, 1024) < 0) { fprintf(stderr, "Error initializing SDL_mixer: %s\n", Mix_GetError()); SDL_QuitSubSystem(SDL_INIT_AUDIO); } else { SDL_PauseAudio(0); sdl_was_initialized = true; music_initialized = true; } } #if defined(SDL_MIXER_VERSION_ATLEAST) #if SDL_MIXER_VERSION_ATLEAST(2,0,2) // Initialize SDL_Mixer for MIDI music playback Mix_Init(MIX_INIT_MID | MIX_INIT_FLAC | MIX_INIT_OGG | MIX_INIT_MP3); // [crispy] initialize some more audio formats #endif #endif // Once initialization is complete, the temporary Timidity config // file can be removed. RemoveTimidityConfig(); // If snd_musiccmd is set, we need to call Mix_SetMusicCMD to // configure an external music playback program. if (strlen(snd_musiccmd) > 0) { Mix_SetMusicCMD(snd_musiccmd); } #if defined(_WIN32) // [AM] Start up midiproc to handle playing MIDI music. I_MidiPipe_InitServer(); #endif return music_initialized; }