X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fengine%2Fe_sound_sdl.inc;h=4bac2308a9e6020d3af28e07a703a446732e5f5a;hb=7f60063e21b5764c01cf86883d2e1808af8b04ef;hp=eb039a21e26321a4c6abc43ddea930c9aed04bd5;hpb=f24bb82523d35a2fd0789ccee551f2fe591dcd2b;p=d2df-sdl.git diff --git a/src/engine/e_sound_sdl.inc b/src/engine/e_sound_sdl.inc index eb039a2..4bac230 100644 --- a/src/engine/e_sound_sdl.inc +++ b/src/engine/e_sound_sdl.inc @@ -1,3 +1,18 @@ +(* Copyright (C) DooM 2D:Forever Developers + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + *) interface uses @@ -53,7 +68,7 @@ type const NO_SOUND_ID = DWORD(-1); -function e_InitSoundSystem(): Boolean; +function e_InitSoundSystem(NoOutput: Boolean = False): Boolean; function e_LoadSound(FileName: string; var ID: DWORD; isMusic: Boolean): Boolean; function e_LoadSoundMem(pData: Pointer; Length: Integer; var ID: DWORD; isMusic: Boolean): Boolean; @@ -152,15 +167,20 @@ begin end; end; -function e_InitSoundSystem(): Boolean; +function e_InitSoundSystem(NoOutput: Boolean = False): Boolean; var res, i: Integer; + rfreq: Integer; + rformat: UInt16; + rchans: Integer; begin if SoundInitialized then begin Result := true; Exit end; Result := False; SoundInitialized := False; + if NoOutput then begin Result := true; Exit end; + // wow, this is actually MIDI player! // we need module player res := Mix_Init(MIX_INIT_FLAC or MIX_INIT_MOD or MIX_INIT_MODPLUG or MIX_INIT_MP3 or MIX_INIT_OGG or MIX_INIT_FLUIDSYNTH); @@ -172,8 +192,8 @@ begin if (res and MIX_INIT_OGG) <> 0 then e_WriteLog('SDL: OGG playback is active', MSG_NOTIFY); if (res and MIX_INIT_FLUIDSYNTH) <> 0 then e_WriteLog('SDL: FLUIDSYNTH playback is active', MSG_NOTIFY); - res := Mix_OpenAudio(48000, AUDIO_S16LSB, 2, 2048); - if res = -1 then res := Mix_OpenAudio(44100, AUDIO_S16LSB, 2, 2048); + e_WriteLog(Format('SDL: initializing mixer at %d with buffer %d', [gsSDLSampleRate, gsSDLBufferSize]), MSG_NOTIFY); + res := Mix_OpenAudio(gsSDLSampleRate, AUDIO_S16LSB, 2, gsSDLBufferSize); if res = -1 then begin e_WriteLog('Error initializing SDL mixer:', MSG_FATALERROR); @@ -181,6 +201,20 @@ begin Exit; end; + if Mix_QuerySpec(@rfreq, @rformat, @rchans) > 0 then + begin + e_WriteLog(Format('SDL: frequency=%d; format=%u; channels=%d', [rfreq, rformat, rchans]), MSG_NOTIFY); + end; + + for i := 0 to Mix_GetNumChunkDecoders()-1 do + begin + e_WriteLog(Format('SDL: chunk decoder %s is avalable', [Mix_GetChunkDecoder(i)]), MSG_NOTIFY); + end; + for i := 0 to Mix_GetNumMusicDecoders()-1 do + begin + e_WriteLog(Format('SDL: music decoder %s is avalable', [Mix_GetMusicDecoder(i)]), MSG_NOTIFY); + end; + Mix_AllocateChannels(N_CHANNELS); Mix_ChannelFinished(chanFinished);