Author Topic: .Net Core(Mono) Linux not working  (Read 518 times)

BigGranu

  • Posts: 4
.Net Core(Mono) Linux not working
« on: 24 Jul '19 - 22:27 »
Hallo,
i hope anybody can help me.

I develop on Win10 with Visual Studio 2019.
My Server is Ubuntu 18.04 and the libbass.so is in /usr/local/lib.

A small c++ Test get a good result.
Code: [Select]
#include <cstddef>
#include <cstdio>
#include "bass.h"
#include <iostream>

int main()
{   
    int v = BASS_GetVersion();
    char* url = "http://streams.br.de/bayern3_2.m3u";
    BASS_CHANNELINFO info;

    BASS_Init(0, 44100, 0, 0, nullptr);
    BASS_SetConfig(BASS_CONFIG_NET_PLAYLIST, 1);
    BASS_SetConfig(BASS_CONFIG_NET_PREBUF_WAIT, 0);

    HSTREAM ch = BASS_StreamCreateURL(url, 0, BASS_STREAM_BLOCK | BASS_STREAM_STATUS | BASS_STREAM_AUTOFREE, nullptr, nullptr);

    BASS_ChannelGetInfo(ch, &info);
    BASS_StreamFree(ch);

    printf("Version: %i\n", v);
    printf("Channels: %i\n", info.chans);
    getchar();
    return 0;
}
Version: 33820161
Channels: 2

My .NetCore Test on the same Machine
Code: [Select]
using System;
using Un4seen.Bass;

namespace BassTests
{
    class Program
    {
        static void Main()
        {
            var v = Bass.BASS_GetVersion();
            var url = "http://streams.br.de/bayern3_2.m3u";
            var info = new BASS_CHANNELINFO();

            Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
            Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_NET_PLAYLIST, 1);
            Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_NET_PREBUF_WAIT, 0);

            var ch = Bass.BASS_StreamCreateURL(url, 0,
                BASSFlag.BASS_STREAM_BLOCK | BASSFlag.BASS_STREAM_STATUS | BASSFlag.BASS_STREAM_AUTOFREE, null,
                IntPtr.Zero);

            Bass.BASS_ChannelGetInfo(ch, info);
            Bass.BASS_StreamFree(ch);

            Console.WriteLine("Version: " + v);
            Console.WriteLine("Channels: " + info.chans);
            Console.ReadKey();
        }
    }
}
get on Wondows all Ok.
Version: 33820160
Channels: 2

on Ubuntu
Version: 33820161
Channels: 0

I have it also tested with a local .mp3.
Than all ok but Ubuntu says Init_Error.

What am I doing wrong?  ???




Ian @ un4seen

  • Administrator
  • Posts: 22829
Re: .Net Core(Mono) Linux not working
« Reply #1 on: 25 Jul '19 - 13:57 »
The "Channels: 0" line suggests to me that the BASS_StreamCreateURL call failed. What is the return value of that call, and if it's 0, what is the error code from BASS_ErrorGetCode? It looks like your test stream is MP3, so also confirm whether you're using the standard or "mp3-free" BASS version. If the latter, you will the libmpg123 library installed on Linux for MP3 support.

BigGranu

  • Posts: 4
Re: .Net Core(Mono) Linux not working
« Reply #2 on: 25 Jul '19 - 19:16 »
I use the normal Version.
The Errorcode ist BASS_ERROR_INIT.

I use in all 3 cases the same url.
On Ubuntu with the libbass.so C++ - All OK.
On Ubuntu with the libbass.so Core App - Not OK.
On win with the bass.dll Core App - All Ok.

I use the Bass.Net.Linux.dll as .Net Wrapper.

Apparently the Core App can use the libbass.so.
I can read the Version and the Errorcode.

Does the URL need to be reformatted in .Net under Linux?
However, it is the same string as in th C++ App?  ???

Now i see, the BASS_INIT says BASS_ERROR_DX.
« Last Edit: 25 Jul '19 - 19:28 by BigGranu »

BigGranu

  • Posts: 4
Re: .Net Core(Mono) Linux not working
« Reply #3 on: 25 Jul '19 - 23:32 »
After i see the BASS_ERROR_DX i will test any things.
The Solution is install the ALSA lib and create a special config for no Audio Devices.
I have post the full Solution with the needed stepps to Github.

I dont wy the C++ use ather libs as the .Net?
And i also dont now, how can i set this Thread as Solved?

Ian @ un4seen

  • Administrator
  • Posts: 22829
Re: .Net Core(Mono) Linux not working
« Reply #4 on: 26 Jul '19 - 15:15 »
I just noticed that the big difference in your C++ and C# code is that the C++ code is using the "No Sound" device (device=0 in the BASS_Init call), which doesn't require a soundcard. If you don't want to hear the stream playback then you can just stick to using that device. Alternatively, you could fallback to it:

Code: [Select]
if (!BASS_Init(-1, 44100, 0, NULL, NULL)) // try default device
BASS_Init(0, 44100, 0, NULL, NULL)) // fallback to "no sound" device

BigGranu

  • Posts: 4
Re: .Net Core(Mono) Linux not working
« Reply #5 on: 26 Jul '19 - 18:30 »
 :o Yes. Now i see it. Thank you.