Commit 00f7aeee authored by Martin Finkel's avatar Martin Finkel

Add Equalizer IDisposable implementation

parent 103ad604
using LibVLCSharp.Shared;
using NUnit.Framework;
using System;
namespace LibVLCSharp.Tests
{
......@@ -13,5 +14,14 @@ namespace LibVLCSharp.Tests
equalizer.SetAmp(-1, 1);
Assert.AreEqual(-1, equalizer.Amp(1));
}
[Test]
public void DisposeEqualizer()
{
var equalizer = new Equalizer();
equalizer.SetAmp(-1, 1);
equalizer.Dispose();
Assert.AreEqual(IntPtr.Zero, equalizer.NativeReference);
}
}
}
\ No newline at end of file
......@@ -3,6 +3,9 @@ using System.Runtime.InteropServices;
namespace LibVLCSharp.Shared
{
/// <summary>
/// Equalizer settings can be applied to a media player using this type
/// </summary>
public class Equalizer : Internal
{
struct Native
......@@ -139,5 +142,18 @@ namespace LibVLCSharp.Shared
/// <param name="index">index index of the band, counting from zero</param>
/// <returns>equalizer band frequency (Hz), or -1 if there is no such band</returns>
public float BandFrequency(uint index) => Native.LibVLCAudioEqualizerGetBandFrequency(index);
protected override void Dispose(bool disposing)
{
if (IsDisposed || NativeReference == IntPtr.Zero)
return;
base.Dispose(disposing);
}
~Equalizer()
{
Dispose(false);
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment