Author Topic: Bass.Net.dll fails on init BASS_ERROR_DRIVER  (Read 14587 times)

JumpyBASS

  • Posts: 27
I'm trying to use the Bass.Net.dll. Currently I have only one command which fails in BASS_ERROR_DRIVER:
Code: [Select]
Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero, Nothing) What is the problem?


Here's some other info which might be relevant:
- I tried to use the BassNet.Registration command before the init and it did remove the popup.
- I use VB2008Express in 64 bit Vista.
- I have placed Bass.Net.dll and the 64 bit version of the bass.dll in the same folder as the executable. Reference to Bass.Net.dll is also set.
- I have been able use the bass.dll without the Bass.Net.dll.


This the non .net version that works fine:
Code: [Select]
Declare Function BASS_Init Lib "bass.dll" (ByVal device As Integer, ByVal freq As UInteger, ByVal flags As UInteger, ByVal win As IntPtr, ByVal clsid As UInteger) As Boolean

BASS_Init(-1, 44100, BASS_DEVICE_DEFAULT, IntPtr.Zero, Nothing)

« Last Edit: 12 Mar '09 - 19:57 by JumpyBASS »

radio42

  • Posts: 4576
Re: Bass.Net.dll fails on init BASS_ERROR_DRIVER
« Reply #1 on: 12 Mar '09 - 20:10 »
Sounds strange!
Are you sure that there is no other verison flying around somewhere?

JumpyBASS

  • Posts: 27
Re: Bass.Net.dll fails on init BASS_ERROR_DRIVER
« Reply #2 on: 13 Mar '09 - 06:50 »
Sounds strange!
Are you sure that there is no other verison flying around somewhere?
I did do a search on the C-drive for bass*.dll and removed everything after uninstalling bass.net through the uninstaller - If that's what you ment? I have copies of the dlls and the XML in the same folder as my debug executable.

Using the bass.net.dll the function Bass.BASS_GetVersion returns 33817098 = 204020A = 2.4.2.10 which is same as the version in the bass.dll properties checked through windows explorer. The bass.net.dll version seems to be 2.4.4.0.

I also noticed that if I use the init function straight from the bass.dll and all other functions through the bass.net.dll then playing streams and everything else I have tested so far work.
« Last Edit: 13 Mar '09 - 09:09 by JumpyBASS »

Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: Bass.Net.dll fails on init BASS_ERROR_DRIVER
« Reply #3 on: 13 Mar '09 - 17:03 »
Code: [Select]
Declare Function BASS_Init Lib "bass.dll" (ByVal device As Integer, ByVal freq As UInteger, ByVal flags As UInteger, ByVal win As IntPtr, ByVal clsid As UInteger) As Boolean

That looks like the "clsid" parameter may be the problem. It's a pointer, so would be 64-bit in the Win64 BASS.DLL version, while "UInteger" is 32-bit I guess?

An invalid "clsid" would result in BASS_ERROR_DRIVER, if not a crash :)

JumpyBASS

  • Posts: 27
Re: Bass.Net.dll fails on init BASS_ERROR_DRIVER
« Reply #4 on: 13 Mar '09 - 17:18 »
That looks like the "clsid" parameter may be the problem. It's a pointer, so would be 64-bit in the Win64 BASS.DLL version, while "UInteger" is 32-bit I guess?

An invalid "clsid" would result in BASS_ERROR_DRIVER, if not a crash :)
Confused  ???

But that's the declaration that works. It's the function call on the bass.net.dll that doesn't work.

radio42

  • Posts: 4576
Re: Bass.Net.dll fails on init BASS_ERROR_DRIVER
« Reply #5 on: 13 Mar '09 - 17:27 »
Hmm, still really strange.
In BASS.NET there are actually two overloads declared:

bool BASS_Init(int device, int freq, BASSInit flags, IntPtr win, object clsid);
and
bool BASS_Init(int device, int freq, BASSInit flags, IntPtr win, Guid clsid);

So you might try the other one, to see, if that is working in 64-bit:
Code: [Select]
Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, Me.Handle, Guid.Empty)

JumpyBASS

  • Posts: 27
Re: Bass.Net.dll fails on init BASS_ERROR_DRIVER
« Reply #6 on: 13 Mar '09 - 17:43 »
-- you might try the other one, to see, if that is working in 64-bit:
Code: [Select]
Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, Me.Handle, Guid.Empty)

I tried it, but it didn't work.   :-\

WarMacre

  • Posts: 18
Re: Bass.Net.dll fails on init BASS_ERROR_DRIVER
« Reply #7 on: 17 Mar '09 - 05:37 »
Is it the following that might be failing?>:

Code: [Select]
BASSInit.BASS_DEVICE_DEFAULT
For some reason, BASS.NET may not be returning the correct driver parameters within Win64. Have you tried any of the other options with this particular enumeration to see if anything else works?!?

radio42

  • Posts: 4576
Re: Bass.Net.dll fails on init BASS_ERROR_DRIVER
« Reply #8 on: 17 Mar '09 - 08:42 »
Quote
For some reason, BASS.NET may not be returning the correct driver parameters within Win64
Can you be a bit more specific, since I did NOT discover any issues with 'incorrect' drive Parameters?!

JumpyBASS

  • Posts: 27
Re: Bass.Net.dll fails on init BASS_ERROR_DRIVER
« Reply #9 on: 17 Mar '09 - 15:16 »
This problem was solved on another thread. A new overload was added to the bass.net.dll version 2.4.4.1. The following init call works:
Code: [Select]
Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero, IntPtr.Zero)

WarMacre

  • Posts: 18
Re: Bass.Net.dll fails on init BASS_ERROR_DRIVER
« Reply #10 on: 17 Mar '09 - 18:19 »
radio42: I presumed because the error that was thrown was within BASS_ERROR_DRIVER that it was returning an invalid device or driver reference

radio42

  • Posts: 4576
Re: Bass.Net.dll fails on init BASS_ERROR_DRIVER
« Reply #11 on: 17 Mar '09 - 20:28 »
No.
As a background here is what Ian and me verified:
The last parameter of the BASS_Init call might denote a 'clsid'.
If that is a NULL pointer BASS will automatically select and use the DirectSound interface.
But if you give a non-NULL 'clsid', BASS will try to initialize that particular DirectSound interface, which is referenced by that 'clsid' (which is actually a Guid).

In the above case under x64, BASS_Init was called from VB.Net with the 'Nothing' keyword as the 'clsid'.
But Ian could verify, that on his side a non-NULL pointer was received which had a value of an invalid 'clsid' (00000000001DE930). And thus BASS needed to return the BASS_ERROR_DRIVER, since that value is not a valid DirectSound Guid.

So the question is really: Why does the 'Nothing' keyword in VB.Net result in a non-NULL value?!

We also verified this with other .Net languages. Using the C# 'null' keyword results in a real NULL pointer. Also using 'Nothing' with VB.Net under a x86 OS results in a real NULL pointer.
Just the combo VB.Net and x64 OS has this strange behavior!
So up until now I must assume, that this is a real bug in VB.Net on x64 OS!

WarMacre

  • Posts: 18
Re: Bass.Net.dll fails on init BASS_ERROR_DRIVER
« Reply #12 on: 17 Mar '09 - 21:04 »
Interesting.

However, 'Nothing' is not necessarily, well, nothing. For datatypes, 'Nothing' sets it's value to the default value of it's type.

For reference types, 'Nothing' does indeed mean nothing.

As the GUID is essentially a 128 bit integer - and a datatype - it's assigning it a strange default value.

WarMacre

  • Posts: 18
Re: Bass.Net.dll fails on init BASS_ERROR_DRIVER
« Reply #13 on: 17 Mar '09 - 21:28 »
I believe the problem is because the size of pointers within Win32 and Win64 are different.

As I understand it, to ensure compatibility with all platforms always use 64bit pointers or use scalable pointers, e.g. UINT_PTR.

I don't really know much about this and have just undertaken a little research, so forgive my ignorance is this is off-the-mark.

radio42

  • Posts: 4576
Re: Bass.Net.dll fails on init BASS_ERROR_DRIVER
« Reply #14 on: 17 Mar '09 - 21:45 »
No, you last assumption might be the right one.
The have been 2 overloads for the BASS_Init call (now 3).
These are:
Code: [Select]
public static extern bool BASS_Init(int device, int freq, BASSInit flags, IntPtr win, Guid clsid);
and
public static extern bool BASS_Init(int device, int freq, BASSInit flags, IntPtr win, object clsid);

I guess all boils down to the fact, that VB is not fully type safe.
E.g. you can make the following assignment without any compiler error etc.:
Code: [Select]
Dim x As Int64 = 3
Dim y As IntPtr
y = x

So using the 'Nothing' keyword with BASS_Init might result in actually calling the 'wrong' overload.
Meaning the overload which expects the 'Guid' datatype.
And as you referred for a datatype - it's assigning it a strange default value.

For all other .Net languages the compiler would pick the correct overload, as any NULL keyword would pick the 'object' overload and NOT the 'Guid' overload, since a Guid is a struct and not a reference type.

I guess now I even more understand why I like C# more than VB ;-)
(beside all the other huge advantages when it comes to audio processing, e.g. C# can deal with unsafe pointer operations etc.)

However, I introduced a new, 3rd BASS_Init overload to overcome the VB.Net short commings:
Code: [Select]
public static extern bool BASS_Init(int device, int freq, BASSInit flags, IntPtr win, IntPtr clsid);
With this one even VB doesn't have a chance to pick the 'wrong' one.

WarMacre

  • Posts: 18
Re: Bass.Net.dll fails on init BASS_ERROR_DRIVER
« Reply #15 on: 17 Mar '09 - 22:02 »
LOL

VB? Not typesafe? Surely not!  :P

I always ensure that option strict and explicit are on as this MAKES me cast types correctly.

Also, an alternative to 'Nothing' in this instance we could have used 'System.Guid.Empty'. ;)

But the New method overloads are foolproof now.....right?  ;)
« Last Edit: 17 Mar '09 - 22:28 by WarMacre »

radio42

  • Posts: 4576
Re: Bass.Net.dll fails on init BASS_ERROR_DRIVER
« Reply #16 on: 17 Mar '09 - 22:23 »
Exactly!
But the 'System.Guid.Empty' is also not working, since that also doesn't deliver a real NULL pointer, but just an empty Guid struct with all elements set to zero - but BASS checks for a real NULL pointer.

WarMacre

  • Posts: 18
Re: Bass.Net.dll fails on init BASS_ERROR_DRIVER
« Reply #17 on: 17 Mar '09 - 22:34 »
I see. In that case, couldn't the GUID/CLSID be an OPTIONAL parameter. This way it can be left blank, rather than having to pass an argument to it, even if it is 'Nothing', 'Null' or empty?

radio42

  • Posts: 4576
Re: Bass.Net.dll fails on init BASS_ERROR_DRIVER
« Reply #18 on: 17 Mar '09 - 22:51 »
That might be a good idea to create a default overload without the 'clsid' param and one with it.
I might implement that maybe for one of the next releases...

steventcy

  • Guest
Re: Bass.Net.dll fails on init BASS_ERROR_DRIVER
« Reply #19 on: 2 Jul '09 - 15:23 »
I'm trying to use the Bass.Net.dll on Vista. Currently I have only one command which fails in BASS_ERROR_DRIVER:[/b]


Un4seen.Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero, Null) has invalid arguments
What is the problem?




[/quote]

JumpyBASS

  • Posts: 27
Re: Bass.Net.dll fails on init BASS_ERROR_DRIVER
« Reply #20 on: 2 Jul '09 - 16:36 »
I'm trying to use the Bass.Net.dll on Vista. Currently I have only one command which fails in BASS_ERROR_DRIVER:[/b]
Un4seen.Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero, Null) has invalid arguments
What is the problem?
Try:
Code: [Select]
Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero, IntPtr.Zero)

radio42

  • Posts: 4576
Re: Bass.Net.dll fails on init BASS_ERROR_DRIVER
« Reply #21 on: 2 Jul '09 - 17:03 »
Or just use the overload without the last parameter - since the overload using the "Guid" parameter should only be used, if you have a Guid.

However, BASS_ERROR_DRIVER suggests the following error: There is no available device driver... the device may already be in use.
So may be your device is just locked by another application?