public void FreeBass()
{
// This is run outside the command queue as it is required to be synchronous as it must be done
// before other players can start
lock (_syncRoot)
{
if (!_bassFreed)
{
Log.Info("BASS: Freeing BASS. Non-audio media playback requested.");
if (Config.MusicPlayer == AudioPlayer.Asio)
{
BassAsio.BASS_ASIO_Free();
}
if (Config.MusicPlayer == AudioPlayer.WasApi && BassWasapi.BASS_WASAPI_IsStarted())
{
try
{
Log.Debug("BASS: Stopping WASAPI Device");
if (!BassWasapi.BASS_WASAPI_Stop(true))
{
Log.Error("BASS: Error stopping WASAPI Device: {0}", Bass.BASS_ErrorGetCode());
}
if (!BassWasapi.BASS_WASAPI_Free())
{
Log.Error("BASS: Error freeing WASAPI: {0}", Bass.BASS_ErrorGetCode());
}
}
catch (Exception ex)
{
Log.Error("BASS: Exception freeing WASAPI. {0} {1}", ex.Message, ex.StackTrace);
}
}
if (_mixer != null)
{
_mixer.Dispose();
}
Bass.BASS_Free();
_bassFreed = true;
}
}
}