hedgewars/uSound.pas
changeset 11512 bd9a2f1b0080
parent 11505 3a4026fe7c18
child 11537 bf86c6cb9341
equal deleted inserted replaced
11511:24bef86e3f3a 11512:bd9a2f1b0080
   320         isSoundEnabled:= false;
   320         isSoundEnabled:= false;
   321         isMusicEnabled:= false;
   321         isMusicEnabled:= false;
   322     end;
   322     end;
   323 
   323 
   324     WriteToConsole('Init SDL_mixer... ');
   324     WriteToConsole('Init SDL_mixer... ');
   325     SDLTry(Mix_Init(MIX_INIT_OGG) <> 0, 'Mix_Init', true);
   325     if SDLCheck(Mix_Init(MIX_INIT_OGG) <> 0, 'Mix_Init', true) then exit;
   326     WriteLnToConsole(msgOK);
   326     WriteLnToConsole(msgOK);
   327 
   327 
   328     Mix_AllocateChannels(Succ(chanTPU));
   328     Mix_AllocateChannels(Succ(chanTPU));
   329     previousVolume:= cInitVolume;
   329     previousVolume:= cInitVolume;
   330     ChangeVolume(cInitVolume);
   330     ChangeVolume(cInitVolume);
   423         if (defVoicepack^.chunks[snd] = nil) and (Soundz[snd].Path <> ptVoices) and (Soundz[snd].FileName <> '') then
   423         if (defVoicepack^.chunks[snd] = nil) and (Soundz[snd].Path <> ptVoices) and (Soundz[snd].FileName <> '') then
   424             begin
   424             begin
   425             s:= cPathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName;
   425             s:= cPathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName;
   426             WriteToConsole(msgLoading + s + ' ');
   426             WriteToConsole(msgLoading + s + ' ');
   427             defVoicepack^.chunks[snd]:= Mix_LoadWAV_RW(rwopsOpenRead(s), 1);
   427             defVoicepack^.chunks[snd]:= Mix_LoadWAV_RW(rwopsOpenRead(s), 1);
   428             SDLTry(defVoicepack^.chunks[snd] <> nil, 'Mix_LoadWAV_RW', true);
   428             if not SDLCheck(defVoicepack^.chunks[snd] <> nil, 'Mix_LoadWAV_RW', true) then exit;
   429             WriteLnToConsole(msgOK);
   429             WriteLnToConsole(msgOK);
   430             end;
   430             end;
   431         lastChan[snd]:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], 0, -1)
   431         lastChan[snd]:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], 0, -1)
   432         end;
   432         end;
   433 end;
   433 end;
   522         if (defVoicepack^.chunks[snd] = nil) and (Soundz[snd].Path <> ptVoices) and (Soundz[snd].FileName <> '') then
   522         if (defVoicepack^.chunks[snd] = nil) and (Soundz[snd].Path <> ptVoices) and (Soundz[snd].FileName <> '') then
   523             begin
   523             begin
   524             s:= cPathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName;
   524             s:= cPathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName;
   525             WriteToConsole(msgLoading + s + ' ');
   525             WriteToConsole(msgLoading + s + ' ');
   526             defVoicepack^.chunks[snd]:= Mix_LoadWAV_RW(rwopsOpenRead(s), 1);
   526             defVoicepack^.chunks[snd]:= Mix_LoadWAV_RW(rwopsOpenRead(s), 1);
   527             SDLTry(defVoicepack^.chunks[snd] <> nil, 'Mix_LoadWAV_RW', true);
   527             if SDLCheck(defVoicepack^.chunks[snd] <> nil, 'Mix_LoadWAV_RW', true) then exit;
   528             WriteLnToConsole(msgOK);
   528             WriteLnToConsole(msgOK);
   529             end;
   529             end;
   530         if fadems > 0 then
   530         if fadems > 0 then
   531             LoopSoundV:= Mix_FadeInChannelTimed(-1, defVoicepack^.chunks[snd], -1, fadems, -1)
   531             LoopSoundV:= Mix_FadeInChannelTimed(-1, defVoicepack^.chunks[snd], -1, fadems, -1)
   532         else
   532         else
   573          s:= '/Music/' + SDMusicFN
   573          s:= '/Music/' + SDMusicFN
   574     else s:= '/Music/' + MusicFN;
   574     else s:= '/Music/' + MusicFN;
   575     WriteToConsole(msgLoading + s + ' ');
   575     WriteToConsole(msgLoading + s + ' ');
   576 
   576 
   577     Mus:= Mix_LoadMUS_RW(rwopsOpenRead(s));
   577     Mus:= Mix_LoadMUS_RW(rwopsOpenRead(s));
   578     SDLTry(Mus <> nil, 'Mix_LoadMUS_RW', false);
   578     SDLCheck(Mus <> nil, 'Mix_LoadMUS_RW', false);
   579     WriteLnToConsole(msgOK);
   579     WriteLnToConsole(msgOK);
   580 
   580 
   581     SDLTry(Mix_FadeInMusic(Mus, -1, 3000) <> -1, 'Mix_FadeInMusic', false)
   581     SDLCheck(Mix_FadeInMusic(Mus, -1, 3000) <> -1, 'Mix_FadeInMusic', false)
   582 end;
   582 end;
   583 
   583 
   584 procedure SetVolume(vol: LongInt);
   584 procedure SetVolume(vol: LongInt);
   585 begin
   585 begin
   586     cInitVolume:= vol;
   586     cInitVolume:= vol;