DEADSOFTWARE

simplify TSoundLoader interface
[d2df-sdl.git] / src / engine / e_soundfile_fluid.pas
index ba9671542c6ded021daad64b7d871d727392c204..fba2726d408d211e3fd32b453cf70dce4ab62513 100644 (file)
@@ -2,8 +2,7 @@
  *
  * 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.
+ * the Free Software Foundation, version 3 of the License ONLY.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -25,11 +24,11 @@ type
 
   TFluidLoader = class (TSoundLoader)
   public
-    function Load(Data: Pointer; Len: LongWord; SStreaming: Boolean): Boolean; override; overload;
-    function Load(FName: string; SStreaming: Boolean): Boolean; override; overload;
-    function SetPosition(Pos: LongWord): Boolean; override;
+    function Load(Data: Pointer; Len: LongWord; Loop: Boolean): Boolean; override; overload;
+    function Load(FName: string; Loop: Boolean): Boolean; override; overload;
+    function Finished(): Boolean; override;
+    function Restart(): Boolean; override;
     function FillBuffer(Buf: Pointer; Len: LongWord): LongWord; override;
-    function GetAll(var OutPtr: Pointer): LongWord; override;
     procedure Free(); override;
 
   private
@@ -115,7 +114,7 @@ end;
 
 (* TFluidLoader *)
 
-function TFluidLoader.Load(Data: Pointer; Len: LongWord; SStreaming: Boolean): Boolean;
+function TFluidLoader.Load(Data: Pointer; Len: LongWord; Loop: Boolean): Boolean;
 var
   Ret: cint;
 begin
@@ -147,8 +146,9 @@ begin
     end;
   end;
 
-  if FLooping then
+  if Loop then
     fluid_player_set_loop(FPlayer, -1);
+
   FFormat.SampleRate := 44100;
   FFormat.SampleBits := 16;
   FFormat.Channels := 2;
@@ -157,7 +157,7 @@ begin
   Result := True;
 end;
 
-function TFluidLoader.Load(FName: string; SStreaming: Boolean): Boolean;
+function TFluidLoader.Load(FName: string; Loop: Boolean): Boolean;
 var
   Ret: cint;
 begin
@@ -189,8 +189,9 @@ begin
     end;
   end;
 
-  if FLooping then
+  if Loop then
     fluid_player_set_loop(FPlayer, -1);
+
   FFormat.SampleRate := 44100;
   FFormat.SampleBits := 16;
   FFormat.Channels := 2;
@@ -199,9 +200,22 @@ begin
   Result := True;
 end;
 
-function TFluidLoader.SetPosition(Pos: LongWord): Boolean;
+function TFluidLoader.Finished(): Boolean;
 begin
-  Result := False; // unsupported?
+  Result := fluid_player_get_status(FPlayer) = FLUID_PLAYER_DONE;
+end;
+
+function TFluidLoader.Restart(): Boolean;
+begin
+  Result := False;
+  // fluid_player_seek() is only supported in full 2.x.x, and I ain't compiling that shit
+  // if (FSynth <> nil) and (FPlayer <> nil) then
+  // begin
+  //   fluid_synth_system_reset(FSynth);
+  //   fluid_player_seek(FPlayer, 0);
+  //   fluid_player_play(FPlayer);
+  //   Result := True;
+  // end;
 end;
 
 function TFluidLoader.FillBuffer(Buf: Pointer; Len: LongWord): LongWord;
@@ -214,11 +228,6 @@ begin
   if Ret = FLUID_OK then Result := Len;
 end;
 
-function TFluidLoader.GetAll(var OutPtr: Pointer): LongWord;
-begin
-  Result := 0; // midis are always streaming, so this don't make sense
-end;
-
 procedure TFluidLoader.Free();
 begin
   if FPlayer <> nil then