Switch from NAudio to CSCore.
1.1 --- a/Server/FormMain.cs Sun Nov 27 19:56:09 2016 +0100
1.2 +++ b/Server/FormMain.cs Mon Jan 02 15:50:50 2017 +0100
1.3 @@ -34,11 +34,12 @@
1.4 using System.Diagnostics;
1.5 using System.Deployment.Application;
1.6 using System.Reflection;
1.7 -//NAudio
1.8 -using NAudio.CoreAudioApi;
1.9 -using NAudio.CoreAudioApi.Interfaces;
1.10 using System.Runtime.InteropServices;
1.11 using System.Security;
1.12 +//CSCore
1.13 +using CSCore.CoreAudioAPI;
1.14 +
1.15 +// CEC
1.16 using CecSharp;
1.17 //Network
1.18 using NETWORKLIST;
1.19 @@ -48,6 +49,7 @@
1.20 using MiniDisplayInterop;
1.21 using SharpLib.Display;
1.22 using Ear = SharpLib.Ear;
1.23 +using CSCore.Win32;
1.24
1.25 namespace SharpDisplayManager
1.26 {
1.27 @@ -102,9 +104,10 @@
1.28 CoordinateTranslationDelegate iScreenX;
1.29 //Function pointer for pixel Y coordinate intercept
1.30 CoordinateTranslationDelegate iScreenY;
1.31 - //NAudio
1.32 + //CSCore
1.33 private MMDeviceEnumerator iMultiMediaDeviceEnumerator;
1.34 private MMDevice iMultiMediaDevice;
1.35 + private AudioEndpointVolume iAudioEndpointVolume;
1.36 //Network
1.37 private NetworkManager iNetworkManager;
1.38
1.39 @@ -215,7 +218,7 @@
1.40 this.Text += " - development";
1.41 }
1.42
1.43 - //NAudio
1.44 + //CSCore
1.45 iMultiMediaDeviceEnumerator = new MMDeviceEnumerator();
1.46 iMultiMediaDeviceEnumerator.RegisterEndpointNotificationCallback(this);
1.47 UpdateAudioDeviceAndMasterVolumeThreadSafe();
1.48 @@ -495,7 +498,7 @@
1.49 /// Receive volume change notification and reflect changes on our slider.
1.50 /// </summary>
1.51 /// <param name="data"></param>
1.52 - public void OnVolumeNotificationThreadSafe(AudioVolumeNotificationData data)
1.53 + public void OnVolumeNotificationThreadSafe(object sender, AudioEndpointVolumeCallbackEventArgs aEvent)
1.54 {
1.55 UpdateMasterVolumeThreadSafe();
1.56 }
1.57 @@ -508,9 +511,9 @@
1.58 private void trackBarMasterVolume_Scroll(object sender, EventArgs e)
1.59 {
1.60 //Just like Windows Volume Mixer we unmute if the volume is adjusted
1.61 - iMultiMediaDevice.AudioEndpointVolume.Mute = false;
1.62 + iAudioEndpointVolume.IsMuted = false;
1.63 //Set volume level according to our volume slider new position
1.64 - iMultiMediaDevice.AudioEndpointVolume.MasterVolumeLevelScalar = trackBarMasterVolume.Value/100.0f;
1.65 + iAudioEndpointVolume.MasterVolumeLevelScalar = trackBarMasterVolume.Value/100.0f;
1.66 }
1.67
1.68
1.69 @@ -521,7 +524,7 @@
1.70 /// <param name="e"></param>
1.71 private void checkBoxMute_CheckedChanged(object sender, EventArgs e)
1.72 {
1.73 - iMultiMediaDevice.AudioEndpointVolume.Mute = checkBoxMute.Checked;
1.74 + iAudioEndpointVolume.IsMuted = checkBoxMute.Checked;
1.75 }
1.76
1.77 /// <summary>
1.78 @@ -585,10 +588,10 @@
1.79 }
1.80
1.81 //Update volume slider
1.82 - float volumeLevelScalar = iMultiMediaDevice.AudioEndpointVolume.MasterVolumeLevelScalar;
1.83 + float volumeLevelScalar = iAudioEndpointVolume.MasterVolumeLevelScalar;
1.84 trackBarMasterVolume.Value = Convert.ToInt32(volumeLevelScalar*100);
1.85 //Update mute checkbox
1.86 - checkBoxMute.Checked = iMultiMediaDevice.AudioEndpointVolume.Mute;
1.87 + checkBoxMute.Checked = iAudioEndpointVolume.IsMuted;
1.88
1.89 //If our display connection is open we need to update its icons
1.90 if (iDisplay.IsOpen())
1.91 @@ -630,7 +633,7 @@
1.92 }
1.93
1.94 //Take care of our mute icon
1.95 - iDisplay.SetIconOnOff(MiniDisplay.IconType.Mute, iMultiMediaDevice.AudioEndpointVolume.Mute);
1.96 + iDisplay.SetIconOnOff(MiniDisplay.IconType.Mute, iAudioEndpointVolume.IsMuted);
1.97 }
1.98
1.99 }
1.100 @@ -651,8 +654,9 @@
1.101 //We are in the correct thread just go ahead.
1.102 try
1.103 {
1.104 - //Get our master volume
1.105 + //Get our master volume
1.106 iMultiMediaDevice = iMultiMediaDeviceEnumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia);
1.107 + iAudioEndpointVolume = AudioEndpointVolume.FromDevice(iMultiMediaDevice);
1.108 //Update our label
1.109 labelDefaultAudioDevice.Text = iMultiMediaDevice.FriendlyName;
1.110
1.111 @@ -660,7 +664,10 @@
1.112 UpdateMasterVolumeThreadSafe();
1.113
1.114 //Register to get volume modifications
1.115 - iMultiMediaDevice.AudioEndpointVolume.OnVolumeNotification += OnVolumeNotificationThreadSafe;
1.116 + AudioEndpointVolumeCallback callback = new AudioEndpointVolumeCallback();
1.117 + callback.NotifyRecived += OnVolumeNotificationThreadSafe;
1.118 + // Do we need to unregister?
1.119 + iAudioEndpointVolume.RegisterControlChangeNotify(callback);
1.120 //
1.121 trackBarMasterVolume.Enabled = true;
1.122 }
2.1 --- a/Server/SharpDisplayManager.csproj Sun Nov 27 19:56:09 2016 +0100
2.2 +++ b/Server/SharpDisplayManager.csproj Mon Jan 02 15:50:50 2017 +0100
2.3 @@ -111,6 +111,10 @@
2.4 <HintPath>..\packages\Loamen.agsXMPP.1.3.1\lib\net45\agsXMPP.dll</HintPath>
2.5 <Private>True</Private>
2.6 </Reference>
2.7 + <Reference Include="CSCore, Version=1.1.5992.18249, Culture=neutral, PublicKeyToken=5a08f2b6f4415dea, processorArchitecture=MSIL">
2.8 + <HintPath>..\packages\CSCore.1.1.0\lib\net35-client\CSCore.dll</HintPath>
2.9 + <Private>True</Private>
2.10 + </Reference>
2.11 <Reference Include="HarmonyHub, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
2.12 <HintPath>..\packages\SharpLibHarmony.0.7.0\lib\net451\HarmonyHub.dll</HintPath>
2.13 <Private>True</Private>
2.14 @@ -124,10 +128,6 @@
2.15 <HintPath>..\packages\LibMiniDisplay.1.1.8\lib\net20\MiniDisplayInterop.dll</HintPath>
2.16 <Private>True</Private>
2.17 </Reference>
2.18 - <Reference Include="NAudio, Version=1.7.3.0, Culture=neutral, processorArchitecture=MSIL">
2.19 - <SpecificVersion>False</SpecificVersion>
2.20 - <HintPath>..\packages\NAudio.1.7.3\lib\net35\NAudio.dll</HintPath>
2.21 - </Reference>
2.22 <Reference Include="SharpLibDisplay, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
2.23 <HintPath>..\packages\SharpLibDisplay.0.2.6\lib\net40\SharpLibDisplay.dll</HintPath>
2.24 <Private>True</Private>
3.1 --- a/Server/packages.config Sun Nov 27 19:56:09 2016 +0100
3.2 +++ b/Server/packages.config Mon Jan 02 15:50:50 2017 +0100
3.3 @@ -1,8 +1,8 @@
3.4 <?xml version="1.0" encoding="utf-8"?>
3.5 <packages>
3.6 + <package id="CSCore" version="1.1.0" targetFramework="net46" />
3.7 <package id="LibMiniDisplay" version="1.1.8" targetFramework="net46" />
3.8 <package id="Loamen.agsXMPP" version="1.3.1" targetFramework="net46" />
3.9 - <package id="NAudio" version="1.7.3" targetFramework="net45" />
3.10 <package id="SharpLibDisplay" version="0.2.6" targetFramework="net46" />
3.11 <package id="SharpLibHarmony" version="0.7.0" targetFramework="net46" />
3.12 <package id="SharpLibHid" version="1.4.2" targetFramework="net46" />