Changeset 669 for trunk/Music.pas


Ignore:
Timestamp:
Jul 13, 2025, 9:04:39 AM (13 hours ago)
Author:
chronos
Message:
  • Modified: Made loading music libraries optional.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Music.pas

    r668 r669  
    1919    InputLength: Integer;
    2020    AutoPlayNext: Boolean;
     21    LibrariesLoaded: Boolean;
    2122    function GetPlaying: Boolean;
    2223    procedure Initialize;
     
    7879    else
    7980    if uos_TestLoadLibrary(PChar(PortAudioFileName + '.2')) then
    80       PortAudioFileName := PortAudioFileName + '.2'
    81     else PortAudioFileName := '';
    82   end;
    83 
     81      PortAudioFileName := PortAudioFileName + '.2';
     82  end;
     83
     84  // Optionally load SndFile
    8485  if (SndFileFileName <> 'system') and (SndFileFileName <> '') then
    8586  if not uos_TestLoadLibrary(PChar(SndFileFileName)) then begin
     
    9394
    9495  if uos_LoadLib(PChar(PortAudioFileName), PChar(SndFileFileName), nil, nil,
    95     nil, nil, PChar(XmpFileName)) <> 0 then begin
    96       if uosLoadResult.PAloaderror = 1 then
    97         raise Exception.Create(PortAudioFileName + ' not found.');
    98       if uosLoadResult.PAloaderror = 2 then
    99         raise Exception.Create(PortAudioFileName + ' can''t be loaded.');
    100       if uosLoadResult.SFloaderror = 1 then
    101         raise Exception.Create(SndFileFileName + ' not found.');
    102       if uosLoadResult.SFloaderror = 2 then
    103         raise Exception.Create(SndFileFileName + ' can''t be loaded.');
    104       if uosLoadResult.XMloadError = 1 then
    105         raise Exception.Create(XmpFileName + ' not found.');
    106       if uosLoadResult.XMloadError = 2 then
    107         raise Exception.Create(XmpFileName + ' can''t be loaded.');
    108     end;
     96    nil, nil, PChar(XmpFileName)) = 0 then begin
     97    LibrariesLoaded := True;
     98  end else begin
     99    LibrariesLoaded := False;
     100    if uosLoadResult.PAloaderror = 1 then
     101      WriteLn(StdErr, 'Error: ' + PortAudioFileName + ' not found.');
     102    if uosLoadResult.PAloaderror = 2 then
     103      WriteLn(StdErr, 'Error: ' + PortAudioFileName + ' can''t be loaded.');
     104    if uosLoadResult.SFloaderror = 1 then
     105      WriteLn(StdErr, 'Error: ' + SndFileFileName + ' not found.');
     106    if uosLoadResult.SFloaderror = 2 then
     107      WriteLn(StdErr, 'Error: ' + SndFileFileName + ' can''t be loaded.');
     108    if uosLoadResult.XMloadError = 1 then
     109      WriteLn(StdErr, 'Error: ' + XmpFileName + ' not found.');
     110    if uosLoadResult.XMloadError = 2 then
     111      WriteLn(StdErr, 'Error: ' + XmpFileName + ' can''t be loaded.');
     112  end;
    109113
    110114  Initialized := True;
     
    204208begin
    205209  Initialize;
     210  if not LibrariesLoaded then Exit;
    206211
    207212  AutoPlayNext := False;
     
    237242procedure TMusicPlayer.Stop;
    238243begin
     244  Initialize;
     245  if not LibrariesLoaded then Exit;
     246
    239247  AutoPlayNext := False;
    240248  if PlayerIndex1 >= 0 then begin
Note: See TracChangeset for help on using the changeset viewer.