static Mix_Chunk *GetSFXChunk(int sound_id) { if (sound_chunks[sound_id].abuf == NULL) { if (!CacheSFX_SDL(sound_id)) return NULL; } else { // don't free the sound while it is playing! Z_ChangeTag(sound_chunks[sound_id].abuf, PU_STATIC); } return &sound_chunks[sound_id]; }
static boolean I_SDL_InitSound(void) { int i; // No sounds yet for (i = 0; i < NUMSFX; ++i) sound_chunks[i].abuf = NULL; for (i = 0; i < NUM_CHANNELS; ++i) channels_playing[i] = sfx_None; if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) return false; #if defined(SDL20) { const SDL_version *linked = Mix_Linked_Version(); if (linked->major != MIX_MAJOR_VERSION || linked->minor != MIX_MINOR_VERSION) I_Error("The wrong version of SDL2_MIXER.DLL was found. "PACKAGE_NAME" requires " "v%d.%d.%d, not v%d.%d.%d.", linked->major, linked->minor, linked->patch, MIX_MAJOR_VERSION, MIX_MINOR_VERSION, MIX_PATCHLEVEL); if (linked->patch != MIX_PATCHLEVEL) C_Warning("The wrong version of SDL2_MIXER.DLL was found. "PACKAGE_NAME" requires " "v%d.%d.%d, not v%d.%d.%d.", linked->major, linked->minor, linked->patch, MIX_MAJOR_VERSION, MIX_MINOR_VERSION, MIX_PATCHLEVEL); } #endif if (Mix_OpenAudio(snd_samplerate, AUDIO_S16SYS, 2, GetSliceSize()) < 0) return false; Mix_QuerySpec(&mixer_freq, &mixer_format, &mixer_channels); // precache sounds to avoid slowdown inside game for (i = 0; i < NUMSFX; i++) CacheSFX_SDL(i); Mix_AllocateChannels(NUM_CHANNELS); SDL_PauseAudio(0); sound_initialized = true; return true; }
static boolean I_SDL_InitSound(void) { int i; // No sounds yet for (i = 0; i < NUMSFX; ++i) sound_chunks[i].abuf = NULL; for (i = 0; i < NUM_CHANNELS; ++i) channels_playing[i] = sfx_None; if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) { fprintf(stderr, "Unable to set up sound.\n"); return false; } if (Mix_OpenAudio(snd_samplerate, AUDIO_S16SYS, 2, GetSliceSize()) < 0) { fprintf(stderr, "Error initializing SDL_mixer: %s\n", Mix_GetError()); return false; } Mix_QuerySpec(&mixer_freq, &mixer_format, &mixer_channels); // precache sounds to avoid slowdown inside game for (i = 0; i < NUMSFX; i++) CacheSFX_SDL(i); Mix_AllocateChannels(NUM_CHANNELS); SDL_PauseAudio(0); sound_initialized = true; return true; }