Delphi 2 & 3 - INT64

Started by DanaPaul,

DanaPaul

I've posted a Bass 1.8 Delphi header file that supports INT64 function return results for Delphi versions 2 and 3

http://members.aol.com/wtgdana/private/Bass/


fredvs

Hello

With Delphi 3:

      {$else USE_64_ASM}  Int64(-1)
     
        error : Undeclared identifier Int64
        Could not compile used unit "Bass.pas"

DanaPaul

Fred,

The conditional define for Delphi 3 is incorrect.  Change from...

{$ifdef VER120}
  {$define USE_64_ASM}
{$endif VER120}

To..

{$ifdef VER100}
  {$define USE_64_ASM}
{$endif VER100}
{$ifdef VER110}
  {$define USE_64_ASM}
{$endif VER110}

I've uploaded an updated header file.

Thanks :)

fredvs

Hi
I have try your new version, it compile but when i load the appliation :

error : Bass DLL entry point not found : Bass_Getversion.

DanaPaul

Quoteerror : Bass DLL entry point not found : Bass_Getversion

Hmmm... I can't duplicate this error.   :-/

I don't know if this would indicate anything wrong with the DLL version itself or the header file itself, but the error message you quoted has an incorrect function label.  It should be Bass_GetVersion, not Bass_Getversion.  The "V" in Version should be uppercase.  I have no idea why this may have changed during FTP download.  ???

Any suggestions?

fredvs

#5
Hi

It was GetVersion, sorry, i have do a mistake.

By the way, with the original bass.pas with comp modification, it works like charm.

I have change :
in Var
  QWORD = longint; ( Ian said to change it with "comp" if using Delphi 3, but it crash, when i do it)
in function :
Function BASS_ChannelBytes2Seconds(handle: DWORD; pos: comp): FLOAT; stdcall;external 'bass.dll' name 'BASS_ChannelBytes2Seconds';


function BASS_ChannelSetPosition(handle: DWORD; pos: comp): BOOL; stdcall; external 'bass.dll' name 'BASS_ChannelSetPosition';

DanaPaul


QuoteQWORD = longint; ( Ian said to change it with "comp" if using Delphi 3, but it crash, when i do it)

Understood.  This works because you manually changed the QWORD types in the function parameter lists to "COMP", which is a 64 bit Delphi integer type.  However, changing the generic "QWORD" type to a Delphi 4 byte integer type, instead of "COMP", renders the high 32 bits of these function results inaccessible.  Hence, the reason your app was crashing.

Even with manual editing that got you running, you may find a problem positioning or seeking within large media files, or integer overflow.

fredvs

Alright, then what is your suggetion, why do i receive the error mesage ?

nb : In your code i have load
 DWORD = cardinal;
if i let the {}, i get 'invalide floating point operation ' in my apps.

DanaPaul

Quotenb : In your code i have load
DWORD = cardinal; if i let the {}, i get 'invalide floating point operation ' in my apps.

Neither Cardinal nor DWord (defined as an "integer" in Windows.pas) are floating point types.  The problem with NAN (not-a-number) floating point validation is that the Floating Point Processor doesn't pop an immediate error.  Instead, this "Invalid Floating Point Operation" exception is popped the next time any floating point value (COMP) is processed.  All the more reason for exhaustive manual checking of possible NAN values or using a true 64 bit integer.  Solution?  Check your code.

Regarding the BASS_GetVersion problem you found earlier, you can download another copy of the header file.  I made a small change in the assignment of the untyped (dynamic) Proc pointers.

I have my fingers crossed :)



DanaPaul

Fred,

One more thought...  The Delphi flavor of the AudioEngine unit that comes with Bass has many errors (per chance you are still using it).  Specifically in the local variable type assignments that call position and seek functions in Bass.dll.  

In any event, I would look at these functions first.

DanaPaul

Apparently, Delphi places parameters on the stack, not in registers (the norm), when optimization is disabled to accomodate debug mode in the IDE.  I've uploaded an improved version that uses a local constant to retrieve these 64 bit return values.  Delphi 2 and 3 owners might be interested in the new header file.

fredvs

Sorry DanaPaul but i get Bass DLL entry point not found Bass_GetVersion also with the new bass_18.pas

(: JOBnik! :)

Hi ;D

Try: BASS_xxx
and not: Bass_xxx

Have fun!

8) JOBnik! 8)

DanaPaul

#13
Fred,

Simple, use LoadBassDll;

I suspect that Delphi 3 automatically initializes global Variables to nil.  If this is the case, this error message would be possible if you already have Bass.dll loaded when the Initialize section for the unit is executed.

Make sure that you call LoadBassDll (or do not include other Bass header files that automatically load Bass.dll in the same project so that the correct load library error message will be displayed).  Dynamic module loading and unloading (LoadModule API) uses a reference counter for mapped module usage. Useful if many controls or windows in your project use Bass.dll and you want the module to unload itself when not in use (I remember apps with a small footprint).
Example...

LoadBassDll  
Try
  {do some stuff here}
Finally
  UnloadBassDll
  end;

In the example above, if another section of your program is using Bass.dll the module will not be unloaded, instead its reference counter will be decremented.

fredvs

#14
Hi DanaPaul

Hi have sent to your email my Bass_D3.pas, perhaps it may help you (and me).

Do i have to change the code of my app to use your Bass.pas ?
(I have more than 50.000 lines, then i m a litle bit afraid)

DanaPaul


QuoteDo i have to change the code of my app to use your Bass.pas ? (I have more than 50.000 lines, then i m a litle bit afraid)

No, all that you really need is the load library call, LoadBassDll.  Other conventions remain the same, Bass_Init, Bass_GetVersion, etc.

fredvs

#16
Hello.

Not very well understand...

I do nothing before BASS_GetVersion() (it is in formcreate).

The only thing is that i use bass in the "uses" sector...

And i dont understand why my bass_D3.pas works so good... ::)

DanaPaul


QuoteI do nothing before BASS_GetVersion() (it is in formcreate).
The only thing is that i use bass in the "uses" sector...

The only change from above would be to add one line before BASS_GetVersion....

BassDllLoad
BASS_GetVersion()

QuoteAnd i dont understand why my bass_D3.pas works so good... ::)

It works because you truncated all 64 bit return values to 32 bits, and massaged the parameter lists.  If it ain't broke don't fix it, right Fred? :)

fredvs

Hi DanaPaul.

With BassDllLoad ;

I get "Undeclared identifier : "BassDllLoad" error.

In your bass.pas, what append with  DWORD = cardinal ?

You have cote it {}, perhaps there is the problem...

DanaPaul


QuoteWith BassDllLoad ; I get "Undeclared identifier : "BassDllLoad" error.

You need "Bass_18" in your unit uses clause.

QuoteIn your bass.pas, what append with  DWORD = cardinal ?
You have cote it {}, perhaps there is the problem...

Not likely.  You can restore the type assignment by removing the brackets {}