public void WithDefaultOutputDevice() { var api = new SoundIO(); api.Connect(); try { api.FlushEvents(); var dev = api.GetOutputDevice(api.DefaultOutputDeviceIndex); Assert.AreNotEqual(0, dev.GetNearestSampleRate(1), "nearest sample rate is 0...?"); var wait = new ManualResetEvent(false); using (var stream = dev.CreateOutStream()) { stream.Open(); stream.WriteCallback = (min, max) => { int frameCount = max; var results = stream.BeginWrite(ref frameCount); for (int channel = 0; channel < stream.Layout.ChannelCount; channel += 1) { var area = results.GetArea(channel); // FIXME: do write samples area.Pointer += area.Step; } stream.EndWrite(); wait.Set(); }; stream.Start(); stream.Pause(true); wait.WaitOne(); } } finally { api.Disconnect(); } }
public void Dispose() { _instream?.Dispose(); _instream = null; Device?.RemoveReference(); Device = null; _api?.Disconnect(); _api?.Dispose(); }
public void Dispose() { Stop(); foreach (var device in Devices) { device.RemoveReference(); } api.Disconnect(); api.Dispose(); }
public void OnBackendDisconnect() { var api = new SoundIO(); string msg = null; int err = -1; api.OnBackendDisconnect = e => { msg = "disconnected"; err = e; }; api.Connect(); api.FlushEvents(); api.Disconnect(); Assert.AreEqual("disconnected", msg, "msg not set"); Assert.AreEqual(0, err, "either error occured or event not fired"); api.Dispose(); }
public void SoftwareLatencyOffset() { var api = new SoundIO(); api.Connect(); try { api.FlushEvents(); var dev = api.GetOutputDevice(api.DefaultOutputDeviceIndex); Assert.AreNotEqual(0, dev.GetNearestSampleRate(1), "nearest sample rate is 0...?"); using (var stream = dev.CreateOutStream()) { Assert.AreEqual(0, stream.SoftwareLatency, "existing non-zero latency...?"); stream.SoftwareLatency = 0.5; Assert.AreEqual(0.5, stream.SoftwareLatency, "wrong software latency"); } } finally { api.Disconnect(); } }
public void Devices() { var api = new SoundIO(); api.Connect(); try { api.FlushEvents(); Assert.IsTrue(api.DefaultInputDeviceIndex >= -1, "default input device index"); Assert.IsTrue(api.DefaultOutputDeviceIndex >= -1, "default output device index"); for (int i = 0; i < api.OutputDeviceCount; i++) { var dev = api.GetOutputDevice(i); } for (int i = 0; i < api.InputDeviceCount; i++) { var dev = api.GetInputDevice(i); } } finally { api.Disconnect(); } }
public void Properties() { var api = new SoundIO(); api.Connect(); try { api.FlushEvents(); var dev = api.GetOutputDevice(api.DefaultOutputDeviceIndex); foreach (var p in typeof(SoundIODevice).GetProperties()) { try { p.GetValue(dev); } catch (Exception ex) { Assert.Fail("Failed to get property " + p + " : " + ex); } } } finally { api.Disconnect(); api.Dispose(); } }
public void Properties() { var api = new SoundIO(); api.Connect(); try { api.FlushEvents(); var dev = api.GetInputDevice(api.DefaultInputDeviceIndex); using (var stream = dev.CreateInStream()) { foreach (var p in typeof(SoundIOInStream).GetProperties()) { try { p.GetValue(stream); } catch (Exception ex) { Assert.Fail("Failed to get property " + p + " : " + ex); } } } } finally { api.Disconnect(); api.Dispose(); } }
public void Properties() { var api = new SoundIO(); api.Connect(); try { api.FlushEvents(); var dev = api.GetOutputDevice(api.DefaultOutputDeviceIndex); using (var stream = dev.CreateOutStream()) { foreach (var p in typeof(SoundIOOutStream).GetProperties()) { try { switch (p.Name) { case "Layout": var cl = stream.Layout; foreach (var pcl in typeof(SoundIOChannelLayout).GetProperties()) { Console.Error.WriteLine(pcl + " : " + pcl.GetValue(cl)); } break; default: p.GetValue(stream); break; } } catch (Exception ex) { Assert.Fail("Failed to get property " + p + " : " + ex.InnerException); } } } } finally { api.Disconnect(); api.Dispose(); } }
public void WithDefaultOutputDevice() { var api = new SoundIO(); api.Connect(); try { api.FlushEvents(); var dev = api.GetOutputDevice(api.DefaultOutputDeviceIndex); Assert.AreNotEqual(0, dev.GetNearestSampleRate(1), "nearest sample rate is 0...?"); using (var stream = dev.CreateOutStream()) { stream.Open(); stream.WriteCallback = (min, max) => { int frameCount = max; stream.BeginWrite(ref frameCount); }; stream.Start(); stream.Pause(true); Thread.Sleep(50); stream.EndWrite(); } } finally { api.Disconnect(); } }
/// <summary> /// Releases the unmanaged resources used by the <see cref="SoundIoAudioOut" /> /// </summary> public void Dispose() { _trackPool.Dispose(); _audioContext.Disconnect(); _audioContext.Dispose(); }
/// <summary> /// Releases the unmanaged resources used by the <see cref="SoundIoAudioOut" /> /// </summary> public void Dispose() { m_TrackPool.Dispose(); m_AudioContext.Disconnect(); m_AudioContext.Dispose(); }