BASS.NET API 2.4.17.7

Started by radio42,

radio42

I'l take a look at it again and fix that in the next version!

radio42

15.10.2018: Version 2.4.13.3 is out!

Note:
   - BASS: added support for v2.4.13.25
   - BASSWASAPI: added support for v2.4.2.1
   - BASS_FX: added support for v2.4.12.1
   - BASSenc: added support for v2.4.14.0
   - BASSenc_MP3: added support for v2.4.0.0
   - BASSenc_FLAC: added support for v2.4.1.1
   - BASSenc_OGG: added support for v2.4.0.0
   - BASSenc_OPUS: added support for v2.4.0.2
   - BASSASIO: added support for v1.3.1.9
   - BASSMIDI: added support for v2.4.11.14
   - BASSHLS: added support for 2.4.1.2
   - BASSDSD: added support for 2.4.1.2

Full Install:
 www.un4seen.com/filez/4/Bass24.Net.zip

Lib only:
 www.un4seen.com/filez/4/Bass24.Net_update.zip

teq

Hi! After update i still can't see BassEnc_Mp3

radio42

Sorry, I just made a rebuild, for some target's I indeed forgot to include it.
Please re-download and try again - it should now be available.

serkanp

hey radio42,
i need help on selecting correct component for dotnet core 2.x
not to enter duplicate entry, can you reply to the thread ?
http://www.un4seen.com/forum/?topic=18287.msg128549#msg128549

radio42

12.04.2019: Version 2.4.14.0 is out!

Note:
        - BASS: added support for v2.4.14.0
        - BASSMIDI: added support for v2.4.12.1

Full Install:
 www.un4seen.com/filez/4/Bass24.Net.zip

Lib only:
 www.un4seen.com/filez/4/Bass24.Net_update.zip


古川 正基

Where can I download 2.4.13.3?

radio42

24.09.2019: Version 2.4.14.1 is out!

Note:
        - Added support for .Net Core 2.1
        - Added support for .Net Standard 2.0

        - BASS: added support for v2.4.14.15
        - BASSWASAPI: added support for v2.4.2.3
        - BASS_FX: added support for v2.4.12.2
        - BASSenc: added support for v2.4.14.0
        - BASSASIO: added support for v1.4.0.0
        - BASSMIDI: added support for v2.4.12.4
        - BASSWEBM: added support for 2.4.0.0

Full Install:
 www.un4seen.com/filez/4/Bass24.Net.zip

Lib only:
 www.un4seen.com/filez/4/Bass24.Net_update.zip


Guest

Thank you so much.
I hope the next version will include BASSHLS v2.4.2.

radio42

The latest HLS Version should already be included.
Am I missing something here?

poqut

Thank you so much for .Net Core & Standard support.

I've tried both but I can't find EncoderLAME or EncoderWinampAACplus with them, is it known issue?

radio42

Yes, these are only supported in the standard .NET version.
You can use the new bassenc addons instead.
But I can take a look to add them in a next version (if possible)!

poqut

Thank you, it would be nice having them, they were making things more easy :) But for now I've managed to setup EncoderCMDLN for mp3, it works without any problem so far.

Btw Shoutcast was giving "No data is available for encoding 1252. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method" error, because .Net Core doesn't have all the encodings as .Net Framework. I've managed to install System.Text.Encoding.CodePages package and set it up on startup to register, so it's working now too. I just wanted to let you know, I have no idea where it's using 1252 but maybe it can use UTF8 instead that .Net Core have it already.

radio42

Well, SHOUTcast v1 uses the Windows-1252 code page as the default for title updates.
You might use the 'ForceUTF8TitleUpdates' property to force UTF-8.

However, I can take a look to use UTF-8 also as a default for .NET core for SHOUTcast.

radio42

Please re-download the latest version - I have modified the Broadcast classes for the .Net core and .Net standard version to include the missing Encoders (as mentioned above)!

poqut

Thanks, I've tried the updated version. It starts without any problems, I can listen the stream but after a few seconds it throws "An unhandled exception of type 'System.ExecutionEngineException' occurred in Bass.Net.dll"

I've tried to disable the notification and also ForceUTF8TitleUpdates both true and false to see if it's related but it still throws that error.

radio42

The problem may not actually be occurring in the line that throws an exception. This may just be a symptom of something that happened earlier.

The System.ExecutionEngineException exception is thrown when the CLR detects that something has gone horribly wrong. This can happen some considerable time after the problem occurred. This is because the exception is usually a result of corruption of internal data structures - the CLR discovers that something has got into a state that makes no sense. It throws an uncatchable exception because it's not safe to proceed.

So you might have some code in some completely unrelated part of the system that corrupts something, but this only becomes apparent when this particular piece of code runs.
Did you get a further or more detailed stack trace?

Unfortunately, this means you need to start casting the net a bit wider. Pretty much anything that uses either unsafe code, or COM interop is potentially suspect. This will be a long and tedious process, sadly. One way you might approach it is to try gradually simplifying the program: what's the smallest piece of code that can illustrate the problem? (E.g., if you put the code you've shown there into an application that contains nothing else except the simplest possible call to that method, does it still fail?)

poqut

Thank you for the explanation, sadly there is no more detailed info for now.

I made this separate project just to test broadcasting with Core & Standard nothing else but there are some custom classes to pass the stream info (server, port etc) & audio stuff. I will try to make it more simple and let you about the results.

Btw is there a way to use Encoder addons instead of command line encoders with Shoutcast?

radio42

Yes, you can create your own encoder classes and derive them from "BaseEncoder" and implement the details as you like...

The ready-build encoder classes all currently use the command-line encoders.

poqut

I found the issue, it was my bad that forgot to pass broadcast object so it was going to gc. Now everything works as expected without any problems.

And I made that encoder class as you said, it's just for broadcasting only and working fine so far. Can you please check if there is something I miss, I just wanted to be sure  :)

    public class EncoderMp3AddOn : BaseEncoder
    {
        public EncoderMp3AddOn(int channel) : base(channel)
        {
        }

        public override bool SupportsSTDOUT => true;

        public override BASSChannelType EncoderType => BASSChannelType.BASS_CTYPE_STREAM_MP3;

        public override string DefaultOutputExtension => ".mp3";

        public override string EncoderCommandLine => "";

        public override bool Start(ENCODEPROC proc, IntPtr user, bool paused)
        {
            var options = $"--noreplaygain -b {EffectiveBitrate}";

            var flags = BASSEncode.BASS_ENCODE_CAST_NOLIMIT | BASSEncode.BASS_ENCODE_PAUSE;

            EncoderHandle = BassEnc_Mp3.BASS_Encode_MP3_Start(ChannelHandle, options, flags, null, user);

            return EncoderHandle != 0;
        }
    }

radio42

Looks all fine - and if it is working no issues!

teq

#1521
Hi there! I'am using bass net with Unity, and everything was fine before i switched to 64 bit builds(Mono->IL2CPP).
My app is suddenly crashing(only on mobile device android), when i play tracks and saving cache to disk.
Here is my main streamHandle
streamHandle = Bass.BASS_StreamCreateURL(url,
0,
BASSFlag.BASS_STREAM_DECODE,
_trackDownloadProc,
IntPtr.Zero);
Then a create fx stream, cause i am using changing tempo and others features
streamTempoFX = BassFx.BASS_FX_TempoCreate(streamHandle , BASSFlag.BASS_FX_FREESOURCE);
If in BASS_StreamCreateURL i use null instead of _trackDownloadProc everything works fine, but with _trackDownloadProc app can crash, it happens in different times, and sometimes works really long, sometimes crashes on 5-6 track play.

Here is _trackDownloadProc
[AOT.MonoPInvokeCallback(typeof(MonoPMessageDelegate))]
    //private void TrackDownloadProc(IntPtr buffer, int length, IntPtr user)
    private static void TrackDownloadProc(IntPtr buffer, int length, IntPtr user)
    {
        if (_cachingTrackFilename.IsNullOrWhitespace())
        {
            return;
        }

        if (_fs == null)
        {
            _fs = File.OpenWrite(_cachingTrackFilename);
        }

        if (buffer == IntPtr.Zero)
        {
            _fs.Flush();
            _fs.Close();

            if (_fs != null)
            {
                ((IDisposable) _fs).Dispose();
            }

            if (lastStreamingTrackModel != null)
            {
                bool trackExist = File.Exists(@lastStreamingTrackModelFilePath);
                long trackFileSize = trackExist ? new FileInfo(@lastStreamingTrackModelFilePath).Length : 0;

                if (trackExist)
                {
                   
                    if (trackFileSize != lastStreamingTrackModel.fileSize)
                    {
                        try
                        {
                            FileManager.Instance.DeleteFile(lastStreamingTrackModelFilePath);
                        }
                        catch (Exception e)
                        {
                            Debug.LogError($"Error while delete not fully TrackDownloadProc track error = {e.Message}, lastStreamingTrackModelFilePath = {lastStreamingTrackModelFilePath}");
                            MyCrashlytics.Instance.LogNonFatal(new Exception("ClipPlayer TrackDownloadProc Error"), $"error = {e.Message}", true);
                        }
                    }
                    else
                    {
                        lastStreamingTrackModel.waitingLoading = false;
                        lastStreamingTrackModel.waitingForDownloading = false;
                        lastStreamingTrackModel.assetBundlesLoading = false;
                        lastStreamingTrackModel.loading = false;
                        lastStreamingTrackModel.loaded = true;
                        lastStreamingTrackModel.cached = true;
                    }
                }
                else
                {
                    lastStreamingTrackModel.waitingLoading = false;
                    lastStreamingTrackModel.waitingForDownloading = false;
                    lastStreamingTrackModel.loading = false;
                    lastStreamingTrackModel.loaded = false;
                    lastStreamingTrackModel.cached = false;
                }
            }
        }
        else
        {
            if (_trackLoadedData == null || _trackLoadedData.Length < length)
            {
                _trackLoadedData = new byte[length];
            }

            Marshal.Copy(buffer, _trackLoadedData, 0, length);
            _fs.Write(_trackLoadedData, 0, length);
        }
    }

Before each play iteration i make
Bass.BASS_ChannelStop(streamHandle );
Bass.BASS_StreamFree(streamHandle );
Bass.BASS_ChannelStop(streamTempoFX);
Bass.BASS_StreamFree(streamTempoFX);
Also, i set _trackLoadedData = null before each iteration.
I noticed that crash on mobile happens, when click between tracks very fast, so seems that something can not get in time. For example, if i click very fast in Editor i got this error, but not crash
IOException: Invalid handle to path "pathToFile"
System.IO.FileStream.FlushBuffer () (at <599589bf4ce248909b8a14cbe4a2034e>:0)
System.IO.FileStream.WriteInternal (System.Byte[] src, System.Int32 offset, System.Int32 count) (at <599589bf4ce248909b8a14cbe4a2034e>:0)
System.IO.FileStream.Write (System.Byte[] array, System.Int32 offset, System.Int32 count) (at <599589bf4ce248909b8a14cbe4a2034e>:0)
or ObjectDisposedException: Cannot access a disposed object.
Object name: 'Stream has been closed'.

on this line
_fs.Write(_trackLoadedData, 0, length);
I call BASS_StreamCreateURL() in different thread, cause it main it stucks the UI.
_trackDownloadProc = new DOWNLOADPROC(TrackDownloadProc); i tried in main and different thread, no matters.

So, i am curios what is going wrong. Unity IL2CPP bug(cause in Mono it works ok), or i doing something not safely. How should i properly handle multiple calls, i mean clean what i have to clean? =) My hunch is that, if i click play too fast between tracks that FileStream Write() continue use old, flushed file, so i need somehow quickly abort DOWNLOADPROC when click on new file. Thanks.

Guest

I tried the following program for HLS streaming, but got an error.
Bass.BASS_SetConfig (BASSConfig.BASS_CONFIG_HLS_DELAY, 15);
Is BASS.NET supported?

radio42

You need to cast the current value like this: (BASSConfig)0x10900

The constants will be added in the next version.

Guest