Changeset 665


Ignore:
Timestamp:
Jul 9, 2025, 4:45:12 PM (7 hours ago)
Author:
chronos
Message:
  • Fixed: Playing music on Windows.
Location:
trunk
Files:
6 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Music.pas

    r664 r665  
    44
    55uses
    6   Classes, SysUtils, Dialogs, uos_flat;
     6  Classes, SysUtils, Dialogs, uos_flat, ctypes;
    77
    88type
     
    1919    AutoPlayNext: Boolean;
    2020    procedure Initialize;
    21     procedure EndPlay;
    22     procedure LoopEndProc;
     21    procedure EndPlay(PlayerIndex: cint32);
    2322    function GetNextPlaylistItem: string;
    2423    procedure PlayNext(Data: PtrInt);
     
    4645procedure TMusicPlayer.Initialize;
    4746var
    48   res: Integer;
    4947  SndFileFileName: string;
    5048  PortAudioFileName: string;
     
    5351  if Initialized then Exit;
    5452
     53  {$IFDEF UNIX}
    5554  SndFileFileName := 'libsndfile.so.1';
    5655  PortAudioFileName := 'libportaudio.so';
    5756  XmpFileName := 'libxmp.so.4';
     57  {$ELSE}
     58    {$if defined(cpu64)}
     59    SndFileFileName := 'LibSndFile-64.dll';
     60    PortAudioFileName := 'LibPortaudio-64.dll';
     61    XmpFileName := 'libxmp-64.dll';
     62    {$ELSE}
     63    SndFileFileName := 'LibSndFile-32.dll';
     64    PortAudioFileName := 'LibPortaudio-32.dll';
     65    XmpFileName := 'libxmp-32.dll';
     66    {$ENDIF}
     67  {$ENDIF}
    5868
    5969  if (SndFileFileName <> 'system') and  (SndFileFileName <> '') then
     
    6171   SndFileFileName := SndFileFileName + '.2';
    6272
    63   res := uos_LoadLib(PChar(PortAudioFileName), PChar(SndFileFileName), Nil, Nil,
    64     Nil, Nil, PChar(XmpFileName));
     73  if uos_LoadLib(PChar(PortAudioFileName), PChar(SndFileFileName), Nil, Nil,
     74    Nil, Nil, PChar(XmpFileName)) <> 0 then
     75    raise Exception.Create('Error while loading audio libraries.');
    6576
    6677  Initialized := True;
    6778end;
    6879
    69 procedure TMusicPlayer.EndPlay;
    70 begin
    71   if AutoPlayNext then Application.QueueAsyncCall(PlayNext, 0);
    72 end;
    73 
    74 procedure TMusicPlayer.LoopEndProc;
    75 var
    76   Position: Integer;
    77 begin
    78   Position := uos_InputPosition(PlayerIndex1, InputIndex1);
    79   if Position >= InputLength then
    80     Play;
     80procedure TMusicPlayer.EndPlay(PlayerIndex: cint32);
     81begin
     82  if AutoPlayNext and (PlayerIndex = PlayerIndex1) then Application.QueueAsyncCall(PlayNext, 0);
    8183end;
    8284
     
    152154
    153155  AutoPlayNext := False;
    154   //uos_Stop(PlayerIndex1);
    155   uos_StopAndWait(PlayerIndex1);
    156 
    157   //Inc(PlayerIndex1);
     156  uos_Stop(PlayerIndex1);
     157
     158  Inc(PlayerIndex1);
    158159
    159160  uos_CreatePlayer(PlayerIndex1);
  • trunk/Packages/Common/Languages/PixelPointer.cs.po

    r593 r665  
    2121msgid "Wrong bitmap size [width: %d, height: %d]"
    2222msgstr "Špatná velikost bitové mapy [šířka: %d, výška: %d]"
     23
  • trunk/Packages/Common/Languages/Table.cs.po

    r593 r665  
    1515msgid "Unsupported format"
    1616msgstr "Nepodporovaný formát"
     17
  • trunk/Packages/uos

    • Property svn:ignore set to
      lib
  • trunk/Packages/uos/uos.pas

    r664 r665  
    575575  {$else}
    576576  TProc = procedure  of object;
     577  TPlayerProc = procedure (PlayerIndex: cint32)  of object;
    577578  {$endif}
    578579
     
    762763      procedure DoTerminatePlayer;
    763764      procedure DoEndProc;
     765      procedure EndProcExecute;
    764766
    765767  {$IF DEFINED (mse)}
     
    795797
    796798      // Procedure of object to execute at end of thread
    797       EndProc: TProc;
     799      EndProc: TPlayerProc;
    798800
    799801      // Procedure to execute at end of thread (not of object)
     
    840842      // Stop playing and free thread
    841843      procedure Stop ();
    842 
    843       // Stop playing and free thread
    844       procedure StopAndWait ();
    845844
    846845      // Pause playing
     
    24712470      Status := 0;
    24722471    end;
    2473 end;
    2474 
    2475 procedure Tuos_Player.StopAndWait();
    2476 begin
    2477   Stop;
    2478   if Assigned(thethread) then thethread.WaitFor;
    24792472end;
    24802473
     
    97229715 {$IF not DEFINED (Library)}
    97239716  if EndProc <> nil then
    9724     thethread.{$IF DEFINED (usequeue)}Queue{$else}Synchronize{$endif} (thethread,EndProc);
     9717    thethread.{$IF DEFINED (usequeue)}Queue{$else}Synchronize{$endif} (thethread, @EndProcExecute);
    97259718 
    97269719  {$elseif not DEFINED (java)}
     
    97349727end;
    97359728
     9729procedure Tuos_Player.EndProcExecute;
     9730begin
     9731  EndProc(Index);
     9732end;
     9733
    97369734procedure Tuos_Player.DoTerminateNoFreePlayer;
    97379735var
     
    97919789  if EndProc <> nil then
    97929790  {$IF FPC_FULLVERSION>=20701}
    9793     thethread.{$IF DEFINED (usequeue)}Queue{$else}Synchronize{$endif} (thethread,EndProc);
     9791    thethread.{$IF DEFINED (usequeue)}Queue{$else}Synchronize{$endif} (thethread, @EndProcExecute);
    97949792  {$else}
    97959793  thethread.{$IF DEFINED (usequeue)}Queue{$else}Synchronize{$endif} (thethread,EndProc);
  • trunk/Packages/uos/uos_cdrom.pas

    r664 r665  
    643643end;
    644644
    645 Function CDROM_Close(var pCDROMI: PCDROMInfo): LongWord;
     645Function CDROM_Close(var pCDROMI: PCDROMInfo): Integer;
    646646Begin
    647647  Result := CDROM_UNKNOWNERR;
  • trunk/Packages/uos/uos_flat.pas

    r664 r665  
    197197  {$else}
    198198  TProc = procedure of object;
     199  TPlayerProc = procedure(PlayerIndex: cint32) of object;
    199200  {$endif}
    200201
     
    537538 // PlayerIndex : Index of an existing Player
    538539 // InIndex : Index of an existing Input
    539 procedure uos_EndProc(PlayerIndex: cint32; Proc: TProc);
     540procedure uos_EndProc(PlayerIndex: cint32; Proc: TPlayerProc);
    540541
    541542 // Assign the procedure (not of object) to execute at end, after loop
     
    917918 // Stop playing and free thread
    918919procedure uos_Stop(PlayerIndex: cint32);
    919 
    920 // Stop playing and free thread
    921 procedure uos_StopAndWait(PlayerIndex: cint32);
    922920
    923921// Pause playing
     
    22992297end;
    23002298
    2301 procedure uos_StopAndWait(PlayerIndex: cint32);
    2302 begin
    2303   if (length(uosPlayers) > 0) and (PlayerIndex < length(uosPlayers)) then
    2304     if uosPlayersStat[PlayerIndex] = 1 then
    2305       if Assigned(uosPlayers[PlayerIndex]) then
    2306         uosPlayers[PlayerIndex].StopAndWait()
    2307 {$IF DEFINED (mse)}
    2308 {$endif}
    2309   ;
    2310 end;
    2311 
    23122299procedure uos_Pause(PlayerIndex: cint32);// Pause playing
    23132300begin
     
    23282315end;
    23292316
    2330 procedure uos_EndProc(PlayerIndex: cint32; Proc: TProc);
     2317procedure uos_EndProc(PlayerIndex: cint32; Proc: TPlayerProc);
    23312318 // Assign the procedure of object to execute at end, after loop
    23322319 // PlayerIndex : Index of an existing Player
Note: See TracChangeset for help on using the changeset viewer.