From 086642246da49e0ad2de8857004e083081a14867 Mon Sep 17 00:00:00 2001
From: basisbit <basisbit@b956fd51-792f-4845-bead-9b4dfca2ff2c>
Date: Sun, 11 Oct 2015 22:15:05 +0000
Subject: * modified to support current Bass.dll which fixes sound-issues on
 windows 8 and newer ToDo: implement usage of Bass device latency for usage
 when syncing video playback and audio playback * implemented the
 split-feature for linux-users. see
 https://sourceforge.net/p/ultrastardx/patches/16/

git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@3141 b956fd51-792f-4845-bead-9b4dfca2ff2c
---
 src/media/UAudioPlayback_Bass.pas | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

(limited to 'src/media')

diff --git a/src/media/UAudioPlayback_Bass.pas b/src/media/UAudioPlayback_Bass.pas
index 36d84b22..f50e2aa0 100644
--- a/src/media/UAudioPlayback_Bass.pas
+++ b/src/media/UAudioPlayback_Bass.pas
@@ -45,7 +45,7 @@ uses
   UAudioCore_Bass,
   ULog,
   sdl,
-  bass,
+  Bass,
   SysUtils;
 
 type
@@ -172,8 +172,6 @@ var
   SourceFormatInfo: TAudioFormatInfo;
   FrameSize: integer;
   PadFrame: PByteArray;
-  //Info: BASS_INFO;
-  //Latency: double;
 begin
   Result := -1;
 
@@ -249,7 +247,6 @@ var
   FormatFlags: DWORD;
 begin
   Result := false;
-
   // close previous stream and reset state
   Reset();
 
@@ -365,13 +362,13 @@ begin
 end;
 
 function TBassPlaybackStream.GetLatency(): double;
+var
+  Info: BASS_INFO;
 begin
-  // TODO: should we consider output latency for synching (needs BASS_DEVICE_LATENCY)?
-  //if (BASS_GetInfo(Info)) then
-  //  Latency := Info.latency / 1000
-  //else
-  //  Latency := 0;
-  Result := 0; 
+  if (BASS_GetInfo(Info)) then
+    Result := Info.latency / 1000
+  else
+    Result := 0;
 end;
 
 function TBassPlaybackStream.GetVolume(): single;
@@ -706,9 +703,9 @@ begin
 
   //Log.BenchmarkStart(4);
   //Log.LogStatus('Initializing Playback Subsystem', 'Music Initialize');
-
+  BASS_SetConfig(BASS_CONFIG_DEV_DEFAULT, 1);
   // TODO: use BASS_DEVICE_LATENCY to determine the latency
-  if not BASS_Init(-1, 44100, 0, 0, nil) then
+  if not BASS_Init(-1, 44100, BASS_DEVICE_LATENCY, 0, nil) then
   begin
     Log.LogError('Could not initialize BASS', 'TAudioPlayback_Bass.InitializePlayback');
     Exit;
@@ -759,8 +756,13 @@ begin
 end;
 
 function TAudioPlayback_Bass.GetLatency(): double;
+var
+  Info: BASS_INFO;
 begin
-  Result := 0;
+  if (BASS_GetInfo(Info)) then
+    Result := Info.latency / 1000
+  else
+    Result := 0;
 end;
 
 
-- 
cgit v1.2.3