X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fengine%2Fe_sound_fmod.inc;h=430735c7c6ae56761d2fdd5713a0665f9eed31a7;hb=284b42d73c49f7218f2b446f3937bcf62aa7eaf9;hp=ceb0c0fc5f4b3d3c9caacbae0dd5028517315c9e;hpb=f24bb82523d35a2fd0789ccee551f2fe591dcd2b;p=d2df-sdl.git diff --git a/src/engine/e_sound_fmod.inc b/src/engine/e_sound_fmod.inc index ceb0c0f..430735c 100644 --- a/src/engine/e_sound_fmod.inc +++ b/src/engine/e_sound_fmod.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 @@ -50,7 +65,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; bLoop: Boolean): Boolean; function e_LoadSoundMem(pData: Pointer; Length: Integer; var ID: DWORD; bLoop: Boolean): Boolean; @@ -134,7 +149,7 @@ begin end; end; -function e_TrySS (Freq: Integer; forceNoSound: Boolean): Boolean; +function e_TrySS (Freq: Integer; forceNoSound: Integer): Boolean; var res: FMOD_RESULT; ver: Cardinal; @@ -175,25 +190,37 @@ begin Exit; end; - res := FMOD_System_Init(F_System, N_CHANNELS, FMOD_INIT_NORMAL, nil); - if res <> FMOD_OK then + if forceNoSound = 2 then begin - e_WriteLog('Error initializing FMOD system!', MSG_WARNING); - e_WriteLog(FMOD_ErrorString(res), MSG_WARNING); - - {$IFDEF LINUX} - res := TryInitWithOutput(FMOD_OUTPUTTYPE_ALSA, 'OUTPUTTYPE_ALSA'); - if res <> FMOD_OK then - res := TryInitWithOutput(FMOD_OUTPUTTYPE_OSS, 'OUTPUTTYPE_OSS'); - {$ENDIF} - if (res <> FMOD_OK) and not forceNoSound then Exit; - if res <> FMOD_OK then - res := TryInitWithOutput(FMOD_OUTPUTTYPE_NOSOUND, 'OUTPUTTYPE_NOSOUND'); + res := TryInitWithOutput(FMOD_OUTPUTTYPE_NOSOUND, 'OUTPUTTYPE_NOSOUND'); if res <> FMOD_OK then begin - e_WriteLog('FMOD: Giving up, can''t init any output.', MSG_FATALERROR); + e_WriteLog('FMOD: Giving up, can''t init with NOSOUND.', MSG_FATALERROR); Exit; end; + end + else + begin + res := FMOD_System_Init(F_System, N_CHANNELS, FMOD_INIT_NORMAL, nil); + if res <> FMOD_OK then + begin + e_WriteLog('Error initializing FMOD system!', MSG_WARNING); + e_WriteLog(FMOD_ErrorString(res), MSG_WARNING); + + {$IFDEF LINUX} + res := TryInitWithOutput(FMOD_OUTPUTTYPE_ALSA, 'OUTPUTTYPE_ALSA'); + if res <> FMOD_OK then + res := TryInitWithOutput(FMOD_OUTPUTTYPE_OSS, 'OUTPUTTYPE_OSS'); + {$ENDIF} + if (res <> FMOD_OK) and (forceNoSound <> 1) then Exit; + if res <> FMOD_OK then + res := TryInitWithOutput(FMOD_OUTPUTTYPE_NOSOUND, 'OUTPUTTYPE_NOSOUND'); + if res <> FMOD_OK then + begin + e_WriteLog('FMOD: Giving up, can''t init any output.', MSG_FATALERROR); + Exit; + end; + end; end; res := FMOD_System_GetOutput(F_System, output); @@ -222,10 +249,15 @@ begin Result := True; end; -function e_InitSoundSystem(): Boolean; +function e_InitSoundSystem(NoOutput: Boolean = False): Boolean; begin - Result := e_TrySS(48000, False); - if not Result then Result := e_TrySS(44100, True); + if NoOutput then + begin + Result := e_TrySS(48000, 2); + Exit; + end; + Result := e_TrySS(48000, 0); + if not Result then Result := e_TrySS(44100, 1); end; function FindESound(): DWORD; @@ -720,17 +752,15 @@ var res: FMOD_RESULT; begin + Result := False; + if FID = NO_SOUND_ID then Exit; + if e_SoundsArray[FID].nRefs >= gMaxSimSounds then begin Result := True; Exit; end; - Result := False; - - if FID = NO_SOUND_ID then - Exit; - res := FMOD_System_PlaySound(F_System, FMOD_CHANNEL_FREE, e_SoundsArray[FID].Sound, False, FChannel); if res <> FMOD_OK then