Author Topic: Bass / BassMix and Docker  (Read 411 times)

Smoov

  • Posts: 18
Bass / BassMix and Docker
« on: 15 Feb '18 - 23:46 »
Working on building a sample application using Docker in a Linux container. We are using ManagedBass and ManagedBass.Mix nuget packages to be .net core compliant.  If we run the following application in a window .net core environment everything is ok.  Once we try this in a Linux contaner, things blow up. I'm not a linux guru so i'm looking for pointers..

My first question is should the Bass mixer work without ALSA?

And yes the obvious, the libbass.so and the libbassmix.so files are loading fine..

-----------------------------------------

Code: [Select]
using System;
using ManagedBass;
using ManagedBass.Mix;
using System.Threading;

namespace BassTest
{
    class Program
    {
        static void Main(string[] args)
        {
             //// Init BASS using the No Sound Device, Docker containers only have NO SOUND devices
            if (Bass.Init(0))
            {
                // The Following line works fine in Windows .net core, but EXIT immediately on a linux docker container..
                BassMix.CreateMixerStream(44100, 2, BassFlags.Float | BassFlags.MixerNonStop | BassFlags.Decode);
   
            }
            else Console.WriteLine("BASS could not be initialized!");
        }
    }
}

Ian @ un4seen

  • Administrator
  • Posts: 20845
Re: Bass / BassMix and Docker
« Reply #1 on: 16 Feb '18 - 15:47 »
Working on building a sample application using Docker in a Linux container. We are using ManagedBass and ManagedBass.Mix nuget packages to be .net core compliant.  If we run the following application in a window .net core environment everything is ok.  Once we try this in a Linux contaner, things blow up. I'm not a linux guru so i'm looking for pointers..

Just to be sure, when you say it "blows up", do you mean it crashes? In the posted code, it look like your app would exit straight after the BassMix.CreateMixerStream call, so the end result would be much the same whether the call succeeds or not. If you add a Console.WriteLine line for the BassMix.CreateMixerStream result, does that get shown?

If the app is crashing, does it still happen if you replace the BassMix.CreateMixerStream call with a BASS_Mixer_GetVersion call? If it still crashes then, do you get any info on that, eg. in the debugger?

My first question is should the Bass mixer work without ALSA?

Yes, you can still use BASSmix mixers with the BASS "no sound" device then.

Smoov

  • Posts: 18
Re: Bass / BassMix and Docker
« Reply #2 on: 21 Feb '18 - 17:59 »
Ian thanks for all the help.

For any of you writting .net core applications using ManageBass. The following code might be useful.
ManagedBass uses the [DllImport] attribute for exposing unmanaged code it C# managed code. Under Windows and OSX, there appears to be some dependency library management? Under linux depend dll or access to the dll's must be limited? So the following code example below should help solve the problem, by making sure the libbass.so is load into RTLD_GLOBAL space.

Code: [Select]
class Program
    {
        [DllImport("libdl.so")]
        static extern IntPtr dlopen(string filename, int flags);

        static void Main(string[] args)
        {
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                Console.WriteLine("Windows Load Library");
            }
            else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            {
                Console.WriteLine("Linux Load Library");
                Console.WriteLine("BASSLib: {0:X}", dlopen("libbass.so", 0x101)); // 0x101 = RTLD_GLOBAL+RTLD_LAZY
                //Console.WriteLine("BASSLibMix: {0:X}", dlopen("libbassmix.so", 0x101));
                //Console.WriteLine("BASSLibEnc: {0:X}", dlopen("libbassenc.so", 0x101));
                //Console.WriteLine("BASSLibFx: {0:X}", dlopen("libbass_fx.so", 0x101));
            }
            else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            {
                Console.WriteLine("OSX Load Library");
            }
            else
                throw new NotSupportedException();

            Console.WriteLine("MANAGEDBASS Library Version Checks");
            Console.WriteLine("BASS Version: {0:X}", ManagedBass.Bass.Version);
            Console.WriteLine("BASSEnc Version: {0:X}", ManagedBass.Enc.BassEnc.Version);
            Console.WriteLine("BASSFx Version: {0:X}", ManagedBass.Fx.BassFx.Version);
            Console.WriteLine("BASSMix Version: {0:X}", ManagedBass.Mix.BassMix.Version);
        }
    }

Smoov

  • Posts: 18
Re: Bass / BassMix and Docker
« Reply #3 on: 2 Mar '18 - 19:07 »
Ian,

Running into a few more issue on Docker (probably linux issue?).

We are trying to play audio from a AWS S3 bucket. On windows code base everything is smooth and works great..

In a Linux (Docker container) we keep getting a BASS_ERROR_SSL when we try to play on an "https" url. Is this a matter of the linux system missing a library?

NOTE: libssl should be accessible at
  • ./usr/lib/x86_64-linux-gnu/libssl.so.1.0.2
  • ./usr/lib/x86_64-linux-gnu/libssl.so.1.1

Results of our tests (Feel free to try this temporary link, but it will be deleted at some later date)

Running:
 BASS Version: 2.4.13.8
 BASSEnc Version: 2.4.13.1
 BASSFx Version: 2.4.11.1
 BASSMix Version: 2.4.9.0

Any advice on what we can check?
 

Ian @ un4seen

  • Administrator
  • Posts: 20845
Re: Bass / BassMix and Docker
« Reply #4 on: 5 Mar '18 - 16:46 »
On Linux, BASS currently looks for one of the following for HTTPS support:

   libssl.so
   libssl.so.10
   libssl.so.1.0.0

Installing the "openssl-devel" or "libssl-dev" package (depending on Linux flavour) should give you the "libssl.so" file/symlink.