# HG changeset patch
# User StephaneLenclud
# Date 1483368650 -3600
# Node ID 10de0c7c2fed751a0da5a6606a24c2e077cfdc58
# Parent 24aec939b2868659cc35cb4283eb73804c4a65d5
Switch from NAudio to CSCore.
diff -r 24aec939b286 -r 10de0c7c2fed Server/FormMain.cs
--- a/Server/FormMain.cs Sun Nov 27 19:56:09 2016 +0100
+++ b/Server/FormMain.cs Mon Jan 02 15:50:50 2017 +0100
@@ -34,11 +34,12 @@
using System.Diagnostics;
using System.Deployment.Application;
using System.Reflection;
-//NAudio
-using NAudio.CoreAudioApi;
-using NAudio.CoreAudioApi.Interfaces;
using System.Runtime.InteropServices;
using System.Security;
+//CSCore
+using CSCore.CoreAudioAPI;
+
+// CEC
using CecSharp;
//Network
using NETWORKLIST;
@@ -48,6 +49,7 @@
using MiniDisplayInterop;
using SharpLib.Display;
using Ear = SharpLib.Ear;
+using CSCore.Win32;
namespace SharpDisplayManager
{
@@ -102,9 +104,10 @@
CoordinateTranslationDelegate iScreenX;
//Function pointer for pixel Y coordinate intercept
CoordinateTranslationDelegate iScreenY;
- //NAudio
+ //CSCore
private MMDeviceEnumerator iMultiMediaDeviceEnumerator;
private MMDevice iMultiMediaDevice;
+ private AudioEndpointVolume iAudioEndpointVolume;
//Network
private NetworkManager iNetworkManager;
@@ -215,7 +218,7 @@
this.Text += " - development";
}
- //NAudio
+ //CSCore
iMultiMediaDeviceEnumerator = new MMDeviceEnumerator();
iMultiMediaDeviceEnumerator.RegisterEndpointNotificationCallback(this);
UpdateAudioDeviceAndMasterVolumeThreadSafe();
@@ -495,7 +498,7 @@
/// Receive volume change notification and reflect changes on our slider.
///
///
- public void OnVolumeNotificationThreadSafe(AudioVolumeNotificationData data)
+ public void OnVolumeNotificationThreadSafe(object sender, AudioEndpointVolumeCallbackEventArgs aEvent)
{
UpdateMasterVolumeThreadSafe();
}
@@ -508,9 +511,9 @@
private void trackBarMasterVolume_Scroll(object sender, EventArgs e)
{
//Just like Windows Volume Mixer we unmute if the volume is adjusted
- iMultiMediaDevice.AudioEndpointVolume.Mute = false;
+ iAudioEndpointVolume.IsMuted = false;
//Set volume level according to our volume slider new position
- iMultiMediaDevice.AudioEndpointVolume.MasterVolumeLevelScalar = trackBarMasterVolume.Value/100.0f;
+ iAudioEndpointVolume.MasterVolumeLevelScalar = trackBarMasterVolume.Value/100.0f;
}
@@ -521,7 +524,7 @@
///
private void checkBoxMute_CheckedChanged(object sender, EventArgs e)
{
- iMultiMediaDevice.AudioEndpointVolume.Mute = checkBoxMute.Checked;
+ iAudioEndpointVolume.IsMuted = checkBoxMute.Checked;
}
///
@@ -585,10 +588,10 @@
}
//Update volume slider
- float volumeLevelScalar = iMultiMediaDevice.AudioEndpointVolume.MasterVolumeLevelScalar;
+ float volumeLevelScalar = iAudioEndpointVolume.MasterVolumeLevelScalar;
trackBarMasterVolume.Value = Convert.ToInt32(volumeLevelScalar*100);
//Update mute checkbox
- checkBoxMute.Checked = iMultiMediaDevice.AudioEndpointVolume.Mute;
+ checkBoxMute.Checked = iAudioEndpointVolume.IsMuted;
//If our display connection is open we need to update its icons
if (iDisplay.IsOpen())
@@ -630,7 +633,7 @@
}
//Take care of our mute icon
- iDisplay.SetIconOnOff(MiniDisplay.IconType.Mute, iMultiMediaDevice.AudioEndpointVolume.Mute);
+ iDisplay.SetIconOnOff(MiniDisplay.IconType.Mute, iAudioEndpointVolume.IsMuted);
}
}
@@ -651,8 +654,9 @@
//We are in the correct thread just go ahead.
try
{
- //Get our master volume
+ //Get our master volume
iMultiMediaDevice = iMultiMediaDeviceEnumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia);
+ iAudioEndpointVolume = AudioEndpointVolume.FromDevice(iMultiMediaDevice);
//Update our label
labelDefaultAudioDevice.Text = iMultiMediaDevice.FriendlyName;
@@ -660,7 +664,10 @@
UpdateMasterVolumeThreadSafe();
//Register to get volume modifications
- iMultiMediaDevice.AudioEndpointVolume.OnVolumeNotification += OnVolumeNotificationThreadSafe;
+ AudioEndpointVolumeCallback callback = new AudioEndpointVolumeCallback();
+ callback.NotifyRecived += OnVolumeNotificationThreadSafe;
+ // Do we need to unregister?
+ iAudioEndpointVolume.RegisterControlChangeNotify(callback);
//
trackBarMasterVolume.Enabled = true;
}
diff -r 24aec939b286 -r 10de0c7c2fed Server/SharpDisplayManager.csproj
--- a/Server/SharpDisplayManager.csproj Sun Nov 27 19:56:09 2016 +0100
+++ b/Server/SharpDisplayManager.csproj Mon Jan 02 15:50:50 2017 +0100
@@ -111,6 +111,10 @@
..\packages\Loamen.agsXMPP.1.3.1\lib\net45\agsXMPP.dll
True
+
+ ..\packages\CSCore.1.1.0\lib\net35-client\CSCore.dll
+ True
+
..\packages\SharpLibHarmony.0.7.0\lib\net451\HarmonyHub.dll
True
@@ -124,10 +128,6 @@
..\packages\LibMiniDisplay.1.1.8\lib\net20\MiniDisplayInterop.dll
True
-
- False
- ..\packages\NAudio.1.7.3\lib\net35\NAudio.dll
-
..\packages\SharpLibDisplay.0.2.6\lib\net40\SharpLibDisplay.dll
True
diff -r 24aec939b286 -r 10de0c7c2fed Server/packages.config
--- a/Server/packages.config Sun Nov 27 19:56:09 2016 +0100
+++ b/Server/packages.config Mon Jan 02 15:50:50 2017 +0100
@@ -1,8 +1,8 @@
+
-