hedgewars/uSound.pas
branchsdl2transition
changeset 9682 aa2431ed87b2
parent 9080 9b42757d7e71
child 11362 ed5a6478e710
equal deleted inserted replaced
9679:dfaa39674e1e 9682:aa2431ed87b2
   309         isSoundEnabled:= false;
   309         isSoundEnabled:= false;
   310         isMusicEnabled:= false;
   310         isMusicEnabled:= false;
   311     end;
   311     end;
   312 
   312 
   313     WriteToConsole('Init SDL_mixer... ');
   313     WriteToConsole('Init SDL_mixer... ');
   314     SDLTry(Mix_Init(MIX_INIT_OGG) <> 0, true);
   314     SDLTry(Mix_Init(MIX_INIT_OGG) <> 0, 'Mix_Init', true);
   315     WriteLnToConsole(msgOK);
   315     WriteLnToConsole(msgOK);
   316 
   316 
   317     Mix_AllocateChannels(Succ(chanTPU));
   317     Mix_AllocateChannels(Succ(chanTPU));
   318     ChangeVolume(cInitVolume);	
   318     ChangeVolume(cInitVolume);	
   319 end;
   319 end;
   411         if (defVoicepack^.chunks[snd] = nil) and (Soundz[snd].Path <> ptVoices) and (Soundz[snd].FileName <> '') then
   411         if (defVoicepack^.chunks[snd] = nil) and (Soundz[snd].Path <> ptVoices) and (Soundz[snd].FileName <> '') then
   412             begin
   412             begin
   413             s:= cPathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName;
   413             s:= cPathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName;
   414             WriteToConsole(msgLoading + s + ' ');
   414             WriteToConsole(msgLoading + s + ' ');
   415             defVoicepack^.chunks[snd]:= Mix_LoadWAV_RW(rwopsOpenRead(s), 1);
   415             defVoicepack^.chunks[snd]:= Mix_LoadWAV_RW(rwopsOpenRead(s), 1);
   416             SDLTry(defVoicepack^.chunks[snd] <> nil, true);
   416             SDLTry(defVoicepack^.chunks[snd] <> nil, 'Mix_LoadWAV_RW', true);
   417             WriteLnToConsole(msgOK);
   417             WriteLnToConsole(msgOK);
   418             end;
   418             end;
   419         lastChan[snd]:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], 0, -1)
   419         lastChan[snd]:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], 0, -1)
   420         end;
   420         end;
   421 end;
   421 end;
   507         if (defVoicepack^.chunks[snd] = nil) and (Soundz[snd].Path <> ptVoices) and (Soundz[snd].FileName <> '') then
   507         if (defVoicepack^.chunks[snd] = nil) and (Soundz[snd].Path <> ptVoices) and (Soundz[snd].FileName <> '') then
   508             begin
   508             begin
   509             s:= cPathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName;
   509             s:= cPathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName;
   510             WriteToConsole(msgLoading + s + ' ');
   510             WriteToConsole(msgLoading + s + ' ');
   511             defVoicepack^.chunks[snd]:= Mix_LoadWAV_RW(rwopsOpenRead(s), 1);
   511             defVoicepack^.chunks[snd]:= Mix_LoadWAV_RW(rwopsOpenRead(s), 1);
   512             SDLTry(defVoicepack^.chunks[snd] <> nil, true);
   512             SDLTry(defVoicepack^.chunks[snd] <> nil, 'Mix_LoadWAV_RW', true);
   513             WriteLnToConsole(msgOK);
   513             WriteLnToConsole(msgOK);
   514             end;
   514             end;
   515         if fadems > 0 then
   515         if fadems > 0 then
   516             LoopSoundV:= Mix_FadeInChannelTimed(-1, defVoicepack^.chunks[snd], -1, fadems, -1)
   516             LoopSoundV:= Mix_FadeInChannelTimed(-1, defVoicepack^.chunks[snd], -1, fadems, -1)
   517         else
   517         else
   557 
   557 
   558     s:= '/Music/' + MusicFN;
   558     s:= '/Music/' + MusicFN;
   559     WriteToConsole(msgLoading + s + ' ');
   559     WriteToConsole(msgLoading + s + ' ');
   560 
   560 
   561     Mus:= Mix_LoadMUS_RW(rwopsOpenRead(s));
   561     Mus:= Mix_LoadMUS_RW(rwopsOpenRead(s));
   562     SDLTry(Mus <> nil, false);
   562     SDLTry(Mus <> nil, 'Mix_LoadMUS_RW', false);
   563     WriteLnToConsole(msgOK);
   563     WriteLnToConsole(msgOK);
   564 
   564 
   565     SDLTry(Mix_FadeInMusic(Mus, -1, 3000) <> -1, false)
   565     SDLTry(Mix_FadeInMusic(Mus, -1, 3000) <> -1, 'Mix_FadeInMusic', false)
   566 end;
   566 end;
   567 
   567 
   568 procedure SetVolume(vol: LongInt);
   568 procedure SetVolume(vol: LongInt);
   569 begin
   569 begin
   570     cInitVolume:= vol;
   570     cInitVolume:= vol;