From 601b0d735cb7cfba45a09a3c4ad9333f158d056f Mon Sep 17 00:00:00 2001 From: Stevo John Date: Fri, 16 Aug 2024 18:52:26 +0100 Subject: [PATCH] WIP --- src/Zen.System/Modules/Audio/Engines/Bass/ManagedBass.cs | 3 +++ src/Zen.System/Modules/Audio/Engines/BassAudioEngine.cs | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Zen.System/Modules/Audio/Engines/Bass/ManagedBass.cs b/src/Zen.System/Modules/Audio/Engines/Bass/ManagedBass.cs index adc7750a..e9039ac7 100644 --- a/src/Zen.System/Modules/Audio/Engines/Bass/ManagedBass.cs +++ b/src/Zen.System/Modules/Audio/Engines/Bass/ManagedBass.cs @@ -29,5 +29,8 @@ public static class ManagedBass [return: MarshalAs((UnmanagedType) 2)] public static extern bool BASS_Free(); + [DllImport("Libraries/libbass")] + public static extern int BASS_ErrorGetCode(); + public delegate void SyncProc(int handle, int channel, int data, IntPtr user); } \ No newline at end of file diff --git a/src/Zen.System/Modules/Audio/Engines/BassAudioEngine.cs b/src/Zen.System/Modules/Audio/Engines/BassAudioEngine.cs index 71e8ecbf..53f351ac 100644 --- a/src/Zen.System/Modules/Audio/Engines/BassAudioEngine.cs +++ b/src/Zen.System/Modules/Audio/Engines/BassAudioEngine.cs @@ -81,14 +81,18 @@ private void Initialise() { if (! ManagedBass.BASS_Init(-1, Constants.SampleRate, BassInit.BASS_DEVICE_MONO, IntPtr.Zero)) { - throw new BassException("Error initialising BASS library."); + var code = ManagedBass.BASS_ErrorGetCode(); + + throw new BassException($"Error {code} initialising BASS library."); } _sampleHandle = ManagedBass.BASS_SampleCreate(Constants.DefaultBufferSize * 4, Constants.SampleRate, 1, 1, BassFlag.BASS_SAMPLE_FLOAT); if (_sampleHandle == 0) { - throw new BassException("Error creating BASS sample."); + var code = ManagedBass.BASS_ErrorGetCode(); + + throw new BassException($"Error {code} creating BASS sample."); } } catch (Exception exception)