When using BASS_DSD_StreamCreateFile to create a dsd file stream in Ubuntu 20.04, error occurs:
libbassdsd.so: undefined symbol: BASS_GetVersion
My code:
namespace MusicFans.Linux.Models{
public class Bass
{
public const string BassAssembly = "./libbass.so";
[DllImport(Bass.BassAssembly)]
public static extern uint BASS_StreamCreateFileUser (uint system, uint flags, BASS_FILEPROCS proc, uint user);
// HSTREAM BASSDEF(BASS_StreamCreateFileUser)(DWORD system, DWORD flags, const BASS_FILEPROCS *proc, void *user);
//HSTREAM BASSDEF(BASS_StreamCreateFile)(BOOL mem, const void *file, QWORD offset, QWORD length, DWORD flags);
[DllImport(Bass.BassAssembly)]
public static extern uint BASS_StreamCreateFile(bool mem, IntPtr file,uint offset,uint length,uint flags);
[DllImport(Bass.BassAssembly)]
public static extern bool BASS_ChannelPlay(uint handle, bool restart);
[DllImport(Bass.BassAssembly)]
public static extern uint BASS_Init(int device, uint freq, uint flags, uint win, IntPtr dsguid);
// BOOL BASSDEF(BASS_Init)(int device, DWORD freq, DWORD flags, void *win, const void *dsguid);
public delegate void BASS_FILEPROCS(int Handle, int Channel, int Data, IntPtr User);
[DllImport(Bass.BassAssembly)]
// int BASSDEF(BASS_ErrorGetCode)();
public static extern int BASS_ErrorGetCode();
}
public class BassDsd
{
public const string BassAssembly = "./libbassdsd.so";
[DllImport(BassDsd.BassAssembly)]
public static extern uint BASS_DSD_StreamCreateFileUser (uint system, uint flags, BASS_FILEPROCS proc, uint user);
// HSTREAM BASSDEF(BASS_APE_StreamCreateFileUser)(DWORD system, DWORD flags, const BASS_FILEPROCS *proc, void *user);
// HSTREAM BASSDSDDEF(BASS_DSD_StreamCreateFile)(BOOL mem, const void *file, QWORD offset, QWORD length, DWORD flags, DWORD freq);
[DllImport(BassDsd.BassAssembly)]
public static extern uint BASS_DSD_StreamCreateFile(bool mem, IntPtr file,uint offset,uint length,uint flags, uint freq);
[DllImport(BassDsd.BassAssembly)]
public static extern bool BASS_ChannelPlay(uint handle, bool restart);
[DllImport(Bass.BassAssembly)]
public static extern uint BASS_Init(int device, uint freq, uint flags, uint win, IntPtr dsguid);
// BOOL BASSDEF(BASS_Init)(int device, DWORD freq, DWORD flags, void *win, const void *dsguid);
public delegate void BASS_FILEPROCS(int Handle, int Channel, int Data, IntPtr User);
}
......
public class MainWindowViewModel : ViewModelBase
public void OnClickCommand()
{
// play music
uint code = Bass.BASS_Init(-1, 44100, BASS_DeviceInfo.BASS_DEVICE_DEFAULT, win: 0,IntPtr.Zero);
if (code == 0)
{
Console.WriteLine("Error returned from BASS_INIT");
}
else
{
Console.WriteLine("BASS_INIT OK");
}
// Error here:
uint stream = BassDsd.BASS_DSD_StreamCreateFile(false, System.Runtime.InteropServices.Marshal.StringToHGlobalAuto("test.dsf") , 0, 0, BASSSample.BASS_SAMPLE_FLOAT, 88200);
if (stream == 0)
{
int err = Bass.BASS_ErrorGetCode();
Console.WriteLine("StreamCreateFile error:"+ err);
}
/*
try
{
GCHandle handle = GCHandle.Alloc(Player.current);
ret = Bass.BASS_ChannelSetSync(stream, BASSSync.BASS_SYNC_END | BASSSync.BASS_SYNC_MIXTIME, 0, _mySync, (IntPtr)handle);
// ret = utilityImplement.BASS_ChannelSetSync2(stream,0,0,_mySync,IntPtr.Zero);
Debug.WriteLine("setsync ret = " + ret);
}
catch
{
var error2 = Bass.BASS_ErrorGetCode();
Debug.WriteLine("chanelsetsync error:" + ret);
}
*/
BassDsd.BASS_ChannelPlay(stream, false);
string[] resNames = Assembly.GetExecutingAssembly().GetManifestResourceNames();
Console.WriteLine("ManifestResourceNames:");
foreach (string resName in resNames)
Console.WriteLine(resName);
}
}
}
Error occurs at:
uint stream = BassDsd.BASS_DSD_StreamCreateFile(false, System.Runtime.InteropServices.Marshal.StringToHGlobalAuto("test.dsf") , 0, 0, BASSSample.BASS_SAMPLE_FLOAT, 88200);
How to deal with this?