public static void FreeResources() { #if __MonoCS__ //mono specific code for linux. FreeMe is not available and not needed. #else //for Windows Bass.FreeMe(); BassMix.FreeMe(); BassFlac.FreeMe(); #endif }
public static int GetFlacStream(Stream stream) { stream.Seek(0, SeekOrigin.Begin); byte[] buffer = Utility.GetBytesFromStream(stream, stream.Length); long length = buffer.Length; GCHandle _hGCFile; // now create a pinned handle, so that the Garbage Collector will not move this object _hGCFile = GCHandle.Alloc(buffer, GCHandleType.Pinned); // create the flac stream (AddrOfPinnedObject delivers the necessary IntPtr) int handle = BassFlac.BASS_FLAC_StreamCreateFile(_hGCFile.AddrOfPinnedObject(), 0L, length, BASSFlag.BASS_STREAM_DECODE); return(handle); }
public static void InitResources(IntPtr win, string bassEmail, string bassCode) { //This function shall only be executed once! At least NUnit has a problem if executed multiple times. if (isInitialized) { return; } string targetPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); //if (Utils.Is64Bit) // targetPath = Path.Combine(targetPath, "libs/x64"); //else // targetPath = Path.Combine(targetPath, "libs/x86"); if (!string.IsNullOrEmpty(bassEmail) && !string.IsNullOrEmpty(bassCode)) { BassNet.Registration(bassEmail, bassCode); } if (Utility.IsWindowsOS()) { #if __MonoCS__ //mono specific code for linux. LoadMe is not available and not needed. #else //for Windows Bass.LoadMe(); BassMix.LoadMe(); BassFlac.LoadMe(); BassAac.LoadMe(); #endif } bool isBassInit = Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, win); if (!isBassInit) { throw new ApplicationException("Some errors occurred while initializing audio dll"); } isInitialized = true; }