Dynamic Loading ...

Started by Andrew Jameson,

Andrew Jameson

Hi,
Essentially this is a repost of a problem that I'm experiencing using BASS when dynamically loaded in Delphi.

if Load_BASSDLL(ApplicationPath, 'Bass.DLL') then begin
  if RT_BASS_Init(-1, 44100, BASS_DEVICE_3D or BASS_DEVICE_LEAVEVOL, 0) then begin
  ... initilazation stuff ...

What I'm finding is that occasionally the RT_BASS_Init fails to return ... essentially locking the application ...

My previous problem that I raised in another thread still persists ... if the program fails to unload the Bass.DLL then the next time the application runs the call to RT_BASS_Init returns false and there's no sound until I reboot the machine.

I'm using 98 and a somewhat old Creative Labs soundcard but I would consider my development machine to fairly representive of machines in common usage.

I'm just wondering whether I'm missing somethin in my initialization of Bass ... I've managed to reproduce the same problem in the supplied demos so I'm a little doubtful that this is the case.

Static loading of Bass seems to be fine but to be honest I've not thoroughly explored the usage of Bass in this mode.

Andrew


bernie

I have experienced similar problems under NT. It was about some streaming library. I have requested from Ian a custom build which was not linked against that .dll library and that solved that occasional watson.

Hth,
bernie

Ghostwalker

try this way:
Type
  TBASS_INIT = function(dev:integer;freq,flags:DWord;Win:HWND):boolean;stdcall;
//types for bass-functions
:
:

var
  dllhandle : HModule;
  BASSINIT : TBASS_INIT; //Type for the function
//variables for functions
     :
     :

procedure LoadBassDynamic;
begin
  dllhandle := loadLibrary(extractfilepath(application.exename)+'bass.dll');
if dllhandle <> 0 then
begin
  @BASSINIT := GetProcAdress(dllhandle,'BASS_Init');
  //The same with all needed functions from bass
    :
    :
end;
end;

Two things are essential. The "stdcall" parameter on typedef, and the @ on GetProcAdress.

Now you can use the Bass-Function. The DLL is dynamical readed at application runtime. i've worked with this way on BASS 1.7 and BASS 1.8 and it works fine.

if it still faileys, use BASS_ERRORGETCODE to get more information:)


Greetings

Ghostwalker

Andrew Jameson

Hi Ghostwalker !

Thanks guys for the response ... I feel a little more reassured to know that other have come across this problem ... even though that doesn't solve it !

I looked at your technique that you suggest for dynamic loading and I can't see any difference between your suggestion and that of the dynamic load that's implemented by the Dynamic_Bass.pas unit ...

Andrew

Ghostwalker

2 Things that may help.

1. check your compiler options (Assignable typed constance (or something like this) must be set !)

2. try the exact way as above. in BASS_DYNAMIC is something done with errorhandling.

Witch version of delphi do you use ?