Author Topic: BASS for ARM Linux  (Read 289308 times)

Ian @ un4seen

  • Administrator
  • Posts: 26108
Re: BASS for ARM Linux
« Reply #400 on: 20 Mar '20 - 16:31 »
The ARM Linux version of the BASSmix 2.4.10 release is up now in the 1st post.

Jan Rzepiszczak

  • Guest
BASS for ARM Linux
« Reply #401 on: 9 Jul '20 - 21:17 »
Hey,

I'm trying to write a program that will be playing music from the queue. Songs are in Matroska/WebM format. On Windows, there is no problem with playing it but when I try to create a stream on Raspberry Pi 4 I'm getting error "BASS_ERROR_FILEFORM". In theory, WebM should be played on Pi without problems.

Here is sample of my code
Code: [Select]
if (!Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero))
{
    throw new BassException("Bass library throw an error while initialization", Bass.BASS_ErrorGetCode());
}
_currentStream = Bass.BASS_StreamCreateURL(track.Url, 0, BASSFlag.BASS_DEFAULT, null, IntPtr.Zero);

The URL of a track I'm normally getting from YoutubeExplode, but here is one of track that I tried to play (I used BASS_StreamCreateFile method obviously):
https://mega.nz/file/L0kmgS7L#hAcNeKQuabexlJTyP57pKh6SUY0pK6uubLCKNxDg-G4

When I'm invoking Bass.SupportedStreamExtensions I'm getting *.mp3;*.ogg;*.wav;*.mp2;*.mp1;*.aiff;*.m2a;*.mpa;*.m1a;*.mpg;*.mpeg;*.aif;*.mp3pro;*.bwf;*.mus.

It is possible to play this format on Raspberry Pi?

Ian @ un4seen

  • Administrator
  • Posts: 26108
Re: BASS for ARM Linux
« Reply #402 on: 10 Jul '20 - 13:15 »
You will need the BASSWEBM and BASSOPUS add-ons to play that file. You can use BASS_PluginLoad to load them, like this:

Code: [Select]
Bass.BASS_PluginLoad("libbassopus.so");
Bass.BASS_PluginLoad("libbasswebm.so");

Please see the BASS_PluginLoad documentation for details.

Jan Rzepiszczak

  • Guest
BASS for ARM Linux
« Reply #403 on: 10 Jul '20 - 17:12 »
I've tried loading the libraries before but always got the BASS_ERROR_FILEOPEN error (if I tried on Windows I got the BASS_ERROR_FILEFORM error). However, if I started the compiled program instead of dotnet through mono I was able to load plugins. The problem, however, is that mono does not work with other libraries that I use, which is why I am forced to use dotnet (my program is targeting the net.core 3.1 framework)

Ian @ un4seen

  • Administrator
  • Posts: 26108
Re: BASS for ARM Linux
« Reply #404 on: 10 Jul '20 - 17:37 »
BASS_ERROR_FILEOPEN sounds like it was unable to find the add-ons. You could try providing the full path to them in the BASS_PluginLoad calls. BASS.Net also has a BASS_PluginLoadDirectory method that you could try (to load all add-ons in a directory).

Jan Rzepiszczak

  • Guest
Re: BASS for ARM Linux
« Reply #405 on: 10 Jul '20 - 18:07 »
I tried both options and both gave me the same results. I think it's finding libraries because if i tried load by
Code: [Select]
Bass.BASS_PluginLoadDirectory("./plugins");
for example libbassenc.so i enden with "Segmentation fault".
When I'm trying to load opus and webm libs by BASS_PluginLoadDirectory i'm getting null.

Ian @ un4seen

  • Administrator
  • Posts: 26108
Re: BASS for ARM Linux
« Reply #406 on: 13 Jul '20 - 15:08 »
Another thing to check is that you're trying to load the add-on libraries for the correct architecture/ABI, ie. the one matching your Linux distro. That will be one of "hardfp" or "aarch64" on RPi4.

Jan Rzepiszczak

  • Posts: 9
BASS for ARM Linux
« Reply #407 on: 13 Jul '20 - 15:30 »
I checked all this libs many times and no one of them work if I use dotnet (for libbass.so I'm using harddp version). If I try run program by mono, so using .Net Framework except of .Net Core everything go well, but the other parts of my program are requiring  .Net Core. I think it is a problem with Bass.Net wrapper for .Net Core. Easiest solution i think is creating version of libbass.so with integrated webm and opus codecs out of the box.

The biggest problem for me is that i can't see any error logs except of error code provided by BASS_ErrorGetCode() method.

Ian @ un4seen

  • Administrator
  • Posts: 26108
Re: BASS for ARM Linux
« Reply #408 on: 13 Jul '20 - 16:39 »
I guess another possiblity is that you're running into this issue:

   www.un4seen.com/forum/?topic=18878

Try the "dlopen" code posted in that thread and see if it helps. If it doesn't help, you could also try loading an add-on library in the same way and call dlerror to get an error message, something like this:

Code: [Select]
[DllImport("libdl")]
static extern IntPtr dlopen(string filename, int flags);
[DllImport("libdl")]
static extern string dlerror();

...

dlopen("./libbasswebm.so", 0);
string error = dlerror();

Jan Rzepiszczak

  • Posts: 9
BASS for ARM Linux
« Reply #409 on: 13 Jul '20 - 17:16 »
I tried it and nothing, dlerror return null but dlopen return 0 when I try to load libbasswebm or libbassopus. When I use dlopen with libbass it's return nice pointer.

Ian @ un4seen

  • Administrator
  • Posts: 26108
Re: BASS for ARM Linux
« Reply #410 on: 14 Jul '20 - 14:44 »
If dlerror is returning NULL then I'm not sure how else you will be able to find out why exactly dlopen is failing. Just to be sure, if you change the return value type to "IntPtr", is it 0 then?

If I understand correctly, you are having the problems when using the Bass.Net.dll file from the "core" folder in the BASS.Net package, while the Bass.Net.Linux.dll file in the "Linux" folder is working fine? I'm not sure whether the "core" version supports Linux. I'll check with the BASS.Net developer.

radio42

  • Posts: 4839
Re: BASS for ARM Linux
« Reply #411 on: 15 Jul '20 - 13:40 »
I am not using ARM myself, so I have never used that myself, but I doubt, that you are the first one using it.
But you can also try the Linux build of Bass.Net, as I am not sure how Net core resolves the dll Extension on ARM ?!

Jan Rzepiszczak

  • Posts: 9
BASS for ARM Linux
« Reply #412 on: 15 Jul '20 - 14:19 »
I tried now running program on WSL Debian (x64) with dotnet with Bass.Net.dll (core) and with Bass.Net.Linux.dll and both cannot load libbasswebm and libbassopus (of course version for x64). I tried to compile for Any CPU and for x64, on linux by dotnet and on windows by Visual Studio 2019 and always i'm getting BASS_ERROR_FILEOPEN, if i'm trying to load plugins by Bass.BASS_PluginLoadDirectory("plugins/") i'm getting null instead of dictionary. The only solution that works for me is using Net.Framework instead of Net.Core and running program by mono instead of dotnet but other parts of my code are using Net.Core. If it is impossible to run bass library in that way i will have to try to rewrite code to net.Framework solutions and then run application with mono.

radio42

  • Posts: 4839
Re: BASS for ARM Linux
« Reply #413 on: 16 Jul '20 - 10:34 »
Note, the Bass.BASS_PluginLoadDirectory or the Bass_LoadMe methods will NOT work on all OSs eg. not on Linux, as they rely on a Windows method to load the add-ons.
So have you actually used and tried the Bass_PluginLoad method as Ian suggested in his post above?!
I assume, that on Linux this is the only supported way to do it!
Mono instead also wraps certain windows functions for compatibility, but .Net core doesn’t.

Jan Rzepiszczak

  • Posts: 9
Re: BASS for ARM Linux
« Reply #414 on: 16 Jul '20 - 10:37 »
Yes, I always try to load plugins first with the Bass_PluginLoad method.

radio42

  • Posts: 4839
Re: BASS for ARM Linux
« Reply #415 on: 16 Jul '20 - 12:59 »
That’s strange, as Bass_PluginLoad directly calls the native Bass method, without changes.

Jan Rzepiszczak

  • Posts: 9
BASS for ARM Linux
« Reply #416 on: 16 Jul '20 - 14:33 »
So I don't know where i should search for solution.
I wrote the simplest code to try code loading:
Code: [Select]
using System;
using Un4seen.Bass;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(Bass.BASS_PluginLoad("libbasswebm.so"));
            Console.WriteLine(Bass.BASS_PluginLoad("libbassopus.so"));
        }
    }
}

And If I ran it with mono I'm getting proper output:
Code: [Select]
1
2

But If I try to run it with dotnet my output is:
Code: [Select]
0
0

I also tried to run it with dotnet on different linux machines but the effect is always the same.
Why on Windows are the codecs for WebM and Opus in the base file, but on Linux they are in separate files?

Jan Rzepiszczak

  • Posts: 9
Re: BASS for ARM Linux
« Reply #417 on: 16 Jul '20 - 14:47 »
It worth of mention that I have libs in /usr/lib and in the directory where I have other files of program. If i use Bass.BASS_PluginLoad("libbassopus.so") mono is using lib from /usr/lib and if I use Bass.BASS_PluginLoad("./ibbassopus.so") it is using libs in current directory. Dotnet in both cases cannot use libs (BASS_ERROR_FILEFORM).

Ian @ un4seen

  • Administrator
  • Posts: 26108
Re: BASS for ARM Linux
« Reply #418 on: 16 Jul '20 - 14:55 »
Why on Windows are the codecs for WebM and Opus in the base file, but on Linux they are in separate files?

BASS doesn't support WebM or Opus by itself (without the add-ons) on Windows either but it may be that you have Media Foundation support installed for them, which BASS can make use of. You can check that with BASS_ChannelGetInfo (see the "ctype" value).

It worth of mention that I have libs in /usr/lib and in the directory where I have other files of program. If i use Bass.BASS_PluginLoad("libbassopus.so") mono is using lib from /usr/lib and if I use Bass.BASS_PluginLoad("./ibbassopus.so") it is using libs in current directory. Dotnet in both cases cannot use libs (BASS_ERROR_FILEFORM).

Do you have the BASS libraries in /usr/lib? They should generally be placed in the same directory as your executable.

If it's still not working, I will send you a debug BASS version to get more info (hopefully a dlerror result).

Jan Rzepiszczak

  • Posts: 9
Re: BASS for ARM Linux
« Reply #419 on: 16 Jul '20 - 15:00 »
I have it in both places, in /usr/lib and next to executables.

Ian @ un4seen

  • Administrator
  • Posts: 26108
Re: BASS for ARM Linux
« Reply #420 on: 17 Jul '20 - 17:58 »
For anyone else that encounters this problem, it turns out it is actually the same issue as in this thread. BASS_PluginLoad should handle it automatically in the next release, but in the meantime the dlopen flags should be 0x105 rather than 0x104 in the workaround:

Code: [Select]
[DllImport("libdl")]
static extern IntPtr dlopen(String filename, int flags);

...

Bass.BASS_GetVersion(); // call/load BASS
dlopen("libbass.so", 0x105); // 0x105 = RTLD_NOLOAD + RTLD_GLOBAL + RTLD_LAZY

Raspberry PI 4

  • Guest
Re: BASS for ARM Linux
« Reply #421 on: 24 Jul '20 - 23:29 »
I am getting a BASS_ERROR_DEVICE on my new Raspberry PI 4. Sound works fine on it, so I have no clue why I get this error. Any thing I have to know about it? ???

Raspberry PI 4

  • Guest
Re: BASS for ARM Linux
« Reply #422 on: 25 Jul '20 - 15:56 »
Changed from raspbian to ubuntu 20.04. Seems to be a problem with raspbian.

Ian @ un4seen

  • Administrator
  • Posts: 26108
Re: BASS for ARM Linux
« Reply #423 on: 27 Jul '20 - 16:42 »
BASS_ERROR_DEVICE means the specified device device is invalid, ie. no such device number exists. What device number did you use in your BASS_Init call? If you happen to still have the Raspbian installation available, please try running "aplay -L" on it and see what that reports.

Ian @ un4seen

  • Administrator
  • Posts: 26108
Re: BASS for ARM Linux
« Reply #424 on: 3 Sep '20 - 15:51 »
The ARM Linux version of the BASSWV 2.4.7 release is up now in the 1st post. Please note the layout of the package has also changed slightly, with the softfp libraries moved to a "softfp" subfolder.