diff --git a/NAudio/CoreAudioApi/AudioCaptureClient.cs b/NAudio/CoreAudioApi/AudioCaptureClient.cs
index 6caaffbe..2a46155a 100644
--- a/NAudio/CoreAudioApi/AudioCaptureClient.cs
+++ b/NAudio/CoreAudioApi/AudioCaptureClient.cs
@@ -26,8 +26,7 @@ public IntPtr GetBuffer(
out long devicePosition,
out long qpcPosition)
{
- IntPtr bufferPointer;
- Marshal.ThrowExceptionForHR(audioCaptureClientInterface.GetBuffer(out bufferPointer, out numFramesToRead, out bufferFlags, out devicePosition, out qpcPosition));
+ Marshal.ThrowExceptionForHR(audioCaptureClientInterface.GetBuffer(out var bufferPointer, out numFramesToRead, out bufferFlags, out devicePosition, out qpcPosition));
return bufferPointer;
}
@@ -41,10 +40,7 @@ public IntPtr GetBuffer(
out int numFramesToRead,
out AudioClientBufferFlags bufferFlags)
{
- IntPtr bufferPointer;
- long devicePosition;
- long qpcPosition;
- Marshal.ThrowExceptionForHR(audioCaptureClientInterface.GetBuffer(out bufferPointer, out numFramesToRead, out bufferFlags, out devicePosition, out qpcPosition));
+ Marshal.ThrowExceptionForHR(audioCaptureClientInterface.GetBuffer(out var bufferPointer, out numFramesToRead, out bufferFlags, out _, out _));
return bufferPointer;
}
@@ -53,8 +49,7 @@ public IntPtr GetBuffer(
///
public int GetNextPacketSize()
{
- int numFramesInNextPacket;
- Marshal.ThrowExceptionForHR(audioCaptureClientInterface.GetNextPacketSize(out numFramesInNextPacket));
+ Marshal.ThrowExceptionForHR(audioCaptureClientInterface.GetNextPacketSize(out var numFramesInNextPacket));
return numFramesInNextPacket;
}
diff --git a/NAudio/CoreAudioApi/AudioClient.cs b/NAudio/CoreAudioApi/AudioClient.cs
index 37172b76..72d26e19 100644
--- a/NAudio/CoreAudioApi/AudioClient.cs
+++ b/NAudio/CoreAudioApi/AudioClient.cs
@@ -34,8 +34,7 @@ public WaveFormat MixFormat
{
if (mixFormat == null)
{
- IntPtr waveFormatPointer;
- Marshal.ThrowExceptionForHR(audioClientInterface.GetMixFormat(out waveFormatPointer));
+ Marshal.ThrowExceptionForHR(audioClientInterface.GetMixFormat(out var waveFormatPointer));
var waveFormat = WaveFormat.MarshalFromPtr(waveFormatPointer);
Marshal.FreeCoTaskMem(waveFormatPointer);
mixFormat = waveFormat;
@@ -83,13 +82,7 @@ public int BufferSize
///
/// Retrieves the maximum latency for the current stream and can be called any time after the stream has been initialized.
///
- public long StreamLatency
- {
- get
- {
- return audioClientInterface.GetStreamLatency();
- }
- }
+ public long StreamLatency => audioClientInterface.GetStreamLatency();
///
/// Retrieves the number of frames of padding in the endpoint buffer (must initialize first)
@@ -98,8 +91,7 @@ public int CurrentPadding
{
get
{
- int currentPadding;
- Marshal.ThrowExceptionForHR(audioClientInterface.GetCurrentPadding(out currentPadding));
+ Marshal.ThrowExceptionForHR(audioClientInterface.GetCurrentPadding(out var currentPadding));
return currentPadding;
}
}
@@ -112,9 +104,7 @@ public long DefaultDevicePeriod
{
get
{
- long defaultDevicePeriod;
- long minimumDevicePeriod;
- Marshal.ThrowExceptionForHR(audioClientInterface.GetDevicePeriod(out defaultDevicePeriod, out minimumDevicePeriod));
+ Marshal.ThrowExceptionForHR(audioClientInterface.GetDevicePeriod(out var defaultDevicePeriod, out _));
return defaultDevicePeriod;
}
}
@@ -127,9 +117,7 @@ public long MinimumDevicePeriod
{
get
{
- long defaultDevicePeriod;
- long minimumDevicePeriod;
- Marshal.ThrowExceptionForHR(audioClientInterface.GetDevicePeriod(out defaultDevicePeriod, out minimumDevicePeriod));
+ Marshal.ThrowExceptionForHR(audioClientInterface.GetDevicePeriod(out _, out var minimumDevicePeriod));
return minimumDevicePeriod;
}
}
@@ -158,9 +146,8 @@ public AudioStreamVolume AudioStreamVolume
}
if (audioStreamVolume == null)
{
- object audioStreamVolumeInterface;
var audioStreamVolumeGuid = new Guid("93014887-242D-4068-8A15-CF5E93B90FE3");
- Marshal.ThrowExceptionForHR(audioClientInterface.GetService(audioStreamVolumeGuid, out audioStreamVolumeInterface));
+ Marshal.ThrowExceptionForHR(audioClientInterface.GetService(audioStreamVolumeGuid, out var audioStreamVolumeInterface));
audioStreamVolume = new AudioStreamVolume((IAudioStreamVolume)audioStreamVolumeInterface);
}
return audioStreamVolume;
@@ -176,9 +163,8 @@ public AudioClockClient AudioClockClient
{
if (audioClockClient == null)
{
- object audioClockClientInterface;
var audioClockClientGuid = new Guid("CD63314F-3FBA-4a1b-812C-EF96358728E7");
- Marshal.ThrowExceptionForHR(audioClientInterface.GetService(audioClockClientGuid, out audioClockClientInterface));
+ Marshal.ThrowExceptionForHR(audioClientInterface.GetService(audioClockClientGuid, out var audioClockClientInterface));
audioClockClient = new AudioClockClient((IAudioClock)audioClockClientInterface);
}
return audioClockClient;
@@ -194,9 +180,8 @@ public AudioRenderClient AudioRenderClient
{
if (audioRenderClient == null)
{
- object audioRenderClientInterface;
var audioRenderClientGuid = new Guid("F294ACFC-3146-4483-A7BF-ADDCA7C260E2");
- Marshal.ThrowExceptionForHR(audioClientInterface.GetService(audioRenderClientGuid, out audioRenderClientInterface));
+ Marshal.ThrowExceptionForHR(audioClientInterface.GetService(audioRenderClientGuid, out var audioRenderClientInterface));
audioRenderClient = new AudioRenderClient((IAudioRenderClient)audioRenderClientInterface);
}
return audioRenderClient;
@@ -212,9 +197,8 @@ public AudioCaptureClient AudioCaptureClient
{
if (audioCaptureClient == null)
{
- object audioCaptureClientInterface;
var audioCaptureClientGuid = new Guid("c8adbd64-e71e-48a0-a4de-185c395cd317");
- Marshal.ThrowExceptionForHR(audioClientInterface.GetService(audioCaptureClientGuid, out audioCaptureClientInterface));
+ Marshal.ThrowExceptionForHR(audioClientInterface.GetService(audioCaptureClientGuid, out var audioCaptureClientInterface));
audioCaptureClient = new AudioCaptureClient((IAudioCaptureClient)audioCaptureClientInterface);
}
return audioCaptureClient;
@@ -230,8 +214,7 @@ public AudioCaptureClient AudioCaptureClient
public bool IsFormatSupported(AudioClientShareMode shareMode,
WaveFormat desiredFormat)
{
- WaveFormatExtensible closestMatchFormat;
- return IsFormatSupported(shareMode, desiredFormat, out closestMatchFormat);
+ return IsFormatSupported(shareMode, desiredFormat, out _);
}
private IntPtr GetPointerToPointer()
diff --git a/NAudio/CoreAudioApi/AudioClockClient.cs b/NAudio/CoreAudioApi/AudioClockClient.cs
index 6701a87d..a48392fe 100644
--- a/NAudio/CoreAudioApi/AudioClockClient.cs
+++ b/NAudio/CoreAudioApi/AudioClockClient.cs
@@ -27,8 +27,7 @@ public int Characteristics
{
get
{
- uint characteristics;
- Marshal.ThrowExceptionForHR(audioClockClientInterface.GetCharacteristics(out characteristics));
+ Marshal.ThrowExceptionForHR(audioClockClientInterface.GetCharacteristics(out var characteristics));
return (int)characteristics;
}
}
@@ -40,8 +39,7 @@ public ulong Frequency
{
get
{
- ulong freq;
- Marshal.ThrowExceptionForHR(audioClockClientInterface.GetFrequency(out freq));
+ Marshal.ThrowExceptionForHR(audioClockClientInterface.GetFrequency(out var freq));
return freq;
}
}
@@ -101,10 +99,7 @@ public ulong AdjustedPosition
///
/// Can Adjust Position
///
- public bool CanAdjustPosition
- {
- get { return Stopwatch.IsHighResolution; }
- }
+ public bool CanAdjustPosition => Stopwatch.IsHighResolution;
#region IDisposable Members
diff --git a/NAudio/CoreAudioApi/AudioEndpointVolume.cs b/NAudio/CoreAudioApi/AudioEndpointVolume.cs
index d68735a3..d0c304c5 100644
--- a/NAudio/CoreAudioApi/AudioEndpointVolume.cs
+++ b/NAudio/CoreAudioApi/AudioEndpointVolume.cs
@@ -32,10 +32,6 @@ namespace NAudio.CoreAudioApi
public class AudioEndpointVolume : IDisposable
{
private readonly IAudioEndpointVolume audioEndPointVolume;
- private readonly AudioEndpointVolumeChannels channels;
- private readonly AudioEndpointVolumeStepInformation stepInformation;
- private readonly AudioEndpointVolumeVolumeRange volumeRange;
- private readonly EEndpointHardwareSupport hardwareSupport;
private AudioEndpointVolumeCallback callBack;
private Guid notificationGuid = Guid.Empty;
@@ -44,14 +40,8 @@ public class AudioEndpointVolume : IDisposable
/// GUID to pass to AudioEndpointVolumeCallback
///
public Guid NotificationGuid {
- get
- {
- return notificationGuid;
- }
- set
- {
- notificationGuid = value;
- }
+ get => notificationGuid;
+ set => notificationGuid = value;
}
///
@@ -62,46 +52,22 @@ public Guid NotificationGuid {
///
/// Volume Range
///
- public AudioEndpointVolumeVolumeRange VolumeRange
- {
- get
- {
- return volumeRange;
- }
- }
+ public AudioEndpointVolumeVolumeRange VolumeRange { get; }
///
/// Hardware Support
///
- public EEndpointHardwareSupport HardwareSupport
- {
- get
- {
- return hardwareSupport;
- }
- }
+ public EEndpointHardwareSupport HardwareSupport { get; }
///
/// Step Information
///
- public AudioEndpointVolumeStepInformation StepInformation
- {
- get
- {
- return stepInformation;
- }
- }
+ public AudioEndpointVolumeStepInformation StepInformation { get; }
///
/// Channels
///
- public AudioEndpointVolumeChannels Channels
- {
- get
- {
- return channels;
- }
- }
+ public AudioEndpointVolumeChannels Channels { get; }
///
/// Master Volume Level
@@ -110,8 +76,7 @@ public float MasterVolumeLevel
{
get
{
- float result;
- Marshal.ThrowExceptionForHR(audioEndPointVolume.GetMasterVolumeLevel(out result));
+ Marshal.ThrowExceptionForHR(audioEndPointVolume.GetMasterVolumeLevel(out var result));
return result;
}
set
@@ -127,8 +92,7 @@ public float MasterVolumeLevelScalar
{
get
{
- float result;
- Marshal.ThrowExceptionForHR(audioEndPointVolume.GetMasterVolumeLevelScalar(out result));
+ Marshal.ThrowExceptionForHR(audioEndPointVolume.GetMasterVolumeLevelScalar(out var result));
return result;
}
set
@@ -144,8 +108,7 @@ public bool Mute
{
get
{
- bool result;
- Marshal.ThrowExceptionForHR(audioEndPointVolume.GetMute(out result));
+ Marshal.ThrowExceptionForHR(audioEndPointVolume.GetMute(out var result));
return result;
}
set
@@ -176,25 +139,19 @@ public void VolumeStepDown()
/// IAudioEndpointVolume COM interface
internal AudioEndpointVolume(IAudioEndpointVolume realEndpointVolume)
{
- uint hardwareSupp;
-
audioEndPointVolume = realEndpointVolume;
- channels = new AudioEndpointVolumeChannels(audioEndPointVolume);
- stepInformation = new AudioEndpointVolumeStepInformation(audioEndPointVolume);
- Marshal.ThrowExceptionForHR(audioEndPointVolume.QueryHardwareSupport(out hardwareSupp));
- hardwareSupport = (EEndpointHardwareSupport)hardwareSupp;
- volumeRange = new AudioEndpointVolumeVolumeRange(audioEndPointVolume);
+ Channels = new AudioEndpointVolumeChannels(audioEndPointVolume);
+ StepInformation = new AudioEndpointVolumeStepInformation(audioEndPointVolume);
+ Marshal.ThrowExceptionForHR(audioEndPointVolume.QueryHardwareSupport(out var hardwareSupp));
+ HardwareSupport = (EEndpointHardwareSupport)hardwareSupp;
+ VolumeRange = new AudioEndpointVolumeVolumeRange(audioEndPointVolume);
callBack = new AudioEndpointVolumeCallback(this);
Marshal.ThrowExceptionForHR(audioEndPointVolume.RegisterControlChangeNotify(callBack));
}
internal void FireNotification(AudioVolumeNotificationData notificationData)
{
- AudioEndpointVolumeNotificationDelegate del = OnVolumeNotification;
- if (del != null)
- {
- del(notificationData);
- }
+ OnVolumeNotification?.Invoke(notificationData);
}
#region IDisposable Members
diff --git a/NAudio/CoreAudioApi/AudioEndpointVolumeCallback.cs b/NAudio/CoreAudioApi/AudioEndpointVolumeCallback.cs
index 26518382..2ddc3f1b 100644
--- a/NAudio/CoreAudioApi/AudioEndpointVolumeCallback.cs
+++ b/NAudio/CoreAudioApi/AudioEndpointVolumeCallback.cs
@@ -25,7 +25,6 @@ 3. This notice may not be removed or altered from any source distribution.
using System;
using NAudio.CoreAudioApi.Interfaces;
-using System.Runtime.InteropServices;
using NAudio.Utils;
namespace NAudio.CoreAudioApi
diff --git a/NAudio/CoreAudioApi/AudioEndpointVolumeChannel.cs b/NAudio/CoreAudioApi/AudioEndpointVolumeChannel.cs
index e8b75347..8306c6bf 100644
--- a/NAudio/CoreAudioApi/AudioEndpointVolumeChannel.cs
+++ b/NAudio/CoreAudioApi/AudioEndpointVolumeChannel.cs
@@ -41,14 +41,8 @@ public class AudioEndpointVolumeChannel
///
public Guid NotificationGuid
{
- get
- {
- return notificationGuid;
- }
- set
- {
- notificationGuid = value;
- }
+ get => notificationGuid;
+ set => notificationGuid = value;
}
internal AudioEndpointVolumeChannel(IAudioEndpointVolume parent, int channel)
@@ -64,13 +58,12 @@ public float VolumeLevel
{
get
{
- float result;
- Marshal.ThrowExceptionForHR(audioEndpointVolume.GetChannelVolumeLevel(channel,out result));
+ Marshal.ThrowExceptionForHR(audioEndpointVolume.GetChannelVolumeLevel(channel,out var result));
return result;
}
set
{
- Marshal.ThrowExceptionForHR(audioEndpointVolume.SetChannelVolumeLevel(channel, value, ref this.notificationGuid));
+ Marshal.ThrowExceptionForHR(audioEndpointVolume.SetChannelVolumeLevel(channel, value, ref notificationGuid));
}
}
@@ -81,13 +74,12 @@ public float VolumeLevelScalar
{
get
{
- float result;
- Marshal.ThrowExceptionForHR(audioEndpointVolume.GetChannelVolumeLevelScalar(channel, out result));
+ Marshal.ThrowExceptionForHR(audioEndpointVolume.GetChannelVolumeLevelScalar(channel, out var result));
return result;
}
set
{
- Marshal.ThrowExceptionForHR(audioEndpointVolume.SetChannelVolumeLevelScalar(channel, value, ref this.notificationGuid));
+ Marshal.ThrowExceptionForHR(audioEndpointVolume.SetChannelVolumeLevelScalar(channel, value, ref notificationGuid));
}
}
diff --git a/NAudio/CoreAudioApi/AudioEndpointVolumeChannels.cs b/NAudio/CoreAudioApi/AudioEndpointVolumeChannels.cs
index fbaff1a0..a5c36eaf 100644
--- a/NAudio/CoreAudioApi/AudioEndpointVolumeChannels.cs
+++ b/NAudio/CoreAudioApi/AudioEndpointVolumeChannels.cs
@@ -41,8 +41,7 @@ public int Count
{
get
{
- int result;
- Marshal.ThrowExceptionForHR(audioEndPointVolume.GetChannelCount(out result));
+ Marshal.ThrowExceptionForHR(audioEndPointVolume.GetChannelCount(out var result));
return result;
}
}
@@ -50,22 +49,15 @@ public int Count
///
/// Indexer - get a specific channel
///
- public AudioEndpointVolumeChannel this[int index]
- {
- get
- {
- return channels[index];
- }
- }
+ public AudioEndpointVolumeChannel this[int index] => channels[index];
internal AudioEndpointVolumeChannels(IAudioEndpointVolume parent)
{
- int ChannelCount;
audioEndPointVolume = parent;
- ChannelCount = Count;
- channels = new AudioEndpointVolumeChannel[ChannelCount];
- for (int i = 0; i < ChannelCount; i++)
+ var channelCount = Count;
+ channels = new AudioEndpointVolumeChannel[channelCount];
+ for (int i = 0; i < channelCount; i++)
{
channels[i] = new AudioEndpointVolumeChannel(audioEndPointVolume, i);
}
diff --git a/NAudio/CoreAudioApi/AudioEndpointVolumeStepInformation.cs b/NAudio/CoreAudioApi/AudioEndpointVolumeStepInformation.cs
index 0269aaf9..5432ae3b 100644
--- a/NAudio/CoreAudioApi/AudioEndpointVolumeStepInformation.cs
+++ b/NAudio/CoreAudioApi/AudioEndpointVolumeStepInformation.cs
@@ -41,17 +41,11 @@ internal AudioEndpointVolumeStepInformation(IAudioEndpointVolume parent)
///
/// Step
///
- public uint Step
- {
- get { return step; }
- }
+ public uint Step => step;
///
/// StepCount
///
- public uint StepCount
- {
- get { return stepCount; }
- }
+ public uint StepCount => stepCount;
}
}
diff --git a/NAudio/CoreAudioApi/AudioEndpointVolumeVolumeRange.cs b/NAudio/CoreAudioApi/AudioEndpointVolumeVolumeRange.cs
index 4454a103..f9c6b14b 100644
--- a/NAudio/CoreAudioApi/AudioEndpointVolumeVolumeRange.cs
+++ b/NAudio/CoreAudioApi/AudioEndpointVolumeVolumeRange.cs
@@ -20,7 +20,6 @@ misrepresented as being the original source code.
3. This notice may not be removed or altered from any source distribution.
*/
// modified for NAudio
-using System;
using NAudio.CoreAudioApi.Interfaces;
using System.Runtime.InteropServices;
@@ -43,25 +42,16 @@ internal AudioEndpointVolumeVolumeRange(IAudioEndpointVolume parent)
///
/// Minimum Decibels
///
- public float MinDecibels
- {
- get { return volumeMinDecibels; }
- }
+ public float MinDecibels => volumeMinDecibels;
///
/// Maximum Decibels
///
- public float MaxDecibels
- {
- get { return volumeMaxDecibels; }
- }
+ public float MaxDecibels => volumeMaxDecibels;
///
/// Increment Decibels
///
- public float IncrementDecibels
- {
- get { return volumeIncrementDecibels; }
- }
+ public float IncrementDecibels => volumeIncrementDecibels;
}
}
diff --git a/NAudio/CoreAudioApi/AudioMeterInformation.cs b/NAudio/CoreAudioApi/AudioMeterInformation.cs
index 3f724904..32ecbb4e 100644
--- a/NAudio/CoreAudioApi/AudioMeterInformation.cs
+++ b/NAudio/CoreAudioApi/AudioMeterInformation.cs
@@ -31,41 +31,25 @@ namespace NAudio.CoreAudioApi
public class AudioMeterInformation
{
private readonly IAudioMeterInformation audioMeterInformation;
- private readonly EEndpointHardwareSupport hardwareSupport;
- private readonly AudioMeterInformationChannels channels;
internal AudioMeterInformation(IAudioMeterInformation realInterface)
{
- int hardwareSupp;
-
audioMeterInformation = realInterface;
- Marshal.ThrowExceptionForHR(audioMeterInformation.QueryHardwareSupport(out hardwareSupp));
- hardwareSupport = (EEndpointHardwareSupport)hardwareSupp;
- channels = new AudioMeterInformationChannels(audioMeterInformation);
+ Marshal.ThrowExceptionForHR(audioMeterInformation.QueryHardwareSupport(out var hardwareSupp));
+ HardwareSupport = (EEndpointHardwareSupport)hardwareSupp;
+ PeakValues = new AudioMeterInformationChannels(audioMeterInformation);
}
///
/// Peak Values
///
- public AudioMeterInformationChannels PeakValues
- {
- get
- {
- return channels;
- }
- }
+ public AudioMeterInformationChannels PeakValues { get; }
///
/// Hardware Support
///
- public EEndpointHardwareSupport HardwareSupport
- {
- get
- {
- return hardwareSupport;
- }
- }
+ public EEndpointHardwareSupport HardwareSupport { get; }
///
/// Master Peak Value
@@ -74,8 +58,7 @@ public float MasterPeakValue
{
get
{
- float result;
- Marshal.ThrowExceptionForHR(audioMeterInformation.GetPeakValue(out result));
+ Marshal.ThrowExceptionForHR(audioMeterInformation.GetPeakValue(out var result));
return result;
}
}
diff --git a/NAudio/CoreAudioApi/AudioMeterInformationChannels.cs b/NAudio/CoreAudioApi/AudioMeterInformationChannels.cs
index 668927c4..2bb41809 100644
--- a/NAudio/CoreAudioApi/AudioMeterInformationChannels.cs
+++ b/NAudio/CoreAudioApi/AudioMeterInformationChannels.cs
@@ -39,8 +39,7 @@ public int Count
{
get
{
- int result;
- Marshal.ThrowExceptionForHR(audioMeterInformation.GetMeteringChannelCount(out result));
+ Marshal.ThrowExceptionForHR(audioMeterInformation.GetMeteringChannelCount(out var result));
return result;
}
}
diff --git a/NAudio/CoreAudioApi/AudioRenderClient.cs b/NAudio/CoreAudioApi/AudioRenderClient.cs
index f380715d..e9ed5336 100644
--- a/NAudio/CoreAudioApi/AudioRenderClient.cs
+++ b/NAudio/CoreAudioApi/AudioRenderClient.cs
@@ -23,8 +23,7 @@ internal AudioRenderClient(IAudioRenderClient audioRenderClientInterface)
/// Pointer to the buffer
public IntPtr GetBuffer(int numFramesRequested)
{
- IntPtr bufferPointer;
- Marshal.ThrowExceptionForHR(audioRenderClientInterface.GetBuffer(numFramesRequested, out bufferPointer));
+ Marshal.ThrowExceptionForHR(audioRenderClientInterface.GetBuffer(numFramesRequested, out var bufferPointer));
return bufferPointer;
}
diff --git a/NAudio/CoreAudioApi/AudioSessionControl.cs b/NAudio/CoreAudioApi/AudioSessionControl.cs
index 8644535b..8afd7e77 100644
--- a/NAudio/CoreAudioApi/AudioSessionControl.cs
+++ b/NAudio/CoreAudioApi/AudioSessionControl.cs
@@ -80,9 +80,7 @@ public AudioSessionState State
{
get
{
- AudioSessionState state;
-
- Marshal.ThrowExceptionForHR(audioSessionControlInterface.GetState(out state));
+ Marshal.ThrowExceptionForHR(audioSessionControlInterface.GetState(out var state));
return state;
}
@@ -95,9 +93,7 @@ public string DisplayName
{
get
{
- string displayName;
-
- Marshal.ThrowExceptionForHR(audioSessionControlInterface.GetDisplayName(out displayName));
+ Marshal.ThrowExceptionForHR(audioSessionControlInterface.GetDisplayName(out var displayName));
return displayName;
}
@@ -117,9 +113,7 @@ public string IconPath
{
get
{
- string iconPath;
-
- Marshal.ThrowExceptionForHR(audioSessionControlInterface.GetIconPath(out iconPath));
+ Marshal.ThrowExceptionForHR(audioSessionControlInterface.GetIconPath(out var iconPath));
return iconPath;
}
@@ -140,8 +134,7 @@ public string GetSessionIdentifier
get
{
if (audioSessionControlInterface2 == null) throw new InvalidOperationException("Not supported on this version of Windows");
- string str;
- Marshal.ThrowExceptionForHR(audioSessionControlInterface2.GetSessionIdentifier(out str));
+ Marshal.ThrowExceptionForHR(audioSessionControlInterface2.GetSessionIdentifier(out var str));
return str;
}
}
@@ -154,8 +147,7 @@ public string GetSessionInstanceIdentifier
get
{
if (audioSessionControlInterface2 == null) throw new InvalidOperationException("Not supported on this version of Windows");
- string str;
- Marshal.ThrowExceptionForHR(audioSessionControlInterface2.GetSessionInstanceIdentifier(out str));
+ Marshal.ThrowExceptionForHR(audioSessionControlInterface2.GetSessionInstanceIdentifier(out var str));
return str;
}
}
@@ -168,8 +160,7 @@ public uint GetProcessID
get
{
if (audioSessionControlInterface2 == null) throw new InvalidOperationException("Not supported on this version of Windows");
- uint pid;
- Marshal.ThrowExceptionForHR(audioSessionControlInterface2.GetProcessId(out pid));
+ Marshal.ThrowExceptionForHR(audioSessionControlInterface2.GetProcessId(out var pid));
return pid;
}
}
@@ -192,9 +183,7 @@ public bool IsSystemSoundsSession
///
public Guid GetGroupingParam()
{
- Guid groupingId;
-
- Marshal.ThrowExceptionForHR(audioSessionControlInterface.GetGroupingParam(out groupingId));
+ Marshal.ThrowExceptionForHR(audioSessionControlInterface.GetGroupingParam(out var groupingId));
return groupingId;
}
diff --git a/NAudio/CoreAudioApi/AudioSessionManager.cs b/NAudio/CoreAudioApi/AudioSessionManager.cs
index 95f51821..e668a390 100644
--- a/NAudio/CoreAudioApi/AudioSessionManager.cs
+++ b/NAudio/CoreAudioApi/AudioSessionManager.cs
@@ -53,9 +53,7 @@ public SimpleAudioVolume SimpleAudioVolume
{
if (simpleAudioVolume == null)
{
- ISimpleAudioVolume simpleAudioInterface;
-
- audioSessionInterface.GetSimpleAudioVolume(Guid.Empty, 0, out simpleAudioInterface);
+ audioSessionInterface.GetSimpleAudioVolume(Guid.Empty, 0, out var simpleAudioInterface);
simpleAudioVolume = new SimpleAudioVolume(simpleAudioInterface);
}
@@ -73,9 +71,7 @@ public AudioSessionControl AudioSessionControl
{
if (audioSessionControl == null)
{
- IAudioSessionControl audioSessionControlInterface;
-
- audioSessionInterface.GetAudioSessionControl(Guid.Empty, 0, out audioSessionControlInterface);
+ audioSessionInterface.GetAudioSessionControl(Guid.Empty, 0, out var audioSessionControlInterface);
audioSessionControl = new AudioSessionControl(audioSessionControlInterface);
}
@@ -97,8 +93,7 @@ public void RefreshSessions()
if (audioSessionInterface2 != null)
{
- IAudioSessionEnumerator sessionEnum;
- Marshal.ThrowExceptionForHR(audioSessionInterface2.GetSessionEnumerator(out sessionEnum));
+ Marshal.ThrowExceptionForHR(audioSessionInterface2.GetSessionEnumerator(out var sessionEnum));
sessions = new SessionCollection(sessionEnum);
audioSessionNotification = new AudioSessionNotification(this);
diff --git a/NAudio/CoreAudioApi/AudioStreamVolume.cs b/NAudio/CoreAudioApi/AudioStreamVolume.cs
index 54f1b395..ed88c171 100644
--- a/NAudio/CoreAudioApi/AudioStreamVolume.cs
+++ b/NAudio/CoreAudioApi/AudioStreamVolume.cs
@@ -1,10 +1,7 @@
using NAudio.CoreAudioApi.Interfaces;
using System;
-using System.Collections.Generic;
using System.Globalization;
-using System.Linq;
using System.Runtime.InteropServices;
-using System.Text;
namespace NAudio.CoreAudioApi
{
@@ -40,10 +37,8 @@ private void CheckChannelIndex(int channelIndex, string parameter)
/// An array of volume levels between 0.0 and 1.0 for each channel in the audio stream.
public float[] GetAllVolumes()
{
- uint channels;
- float[] levels;
- Marshal.ThrowExceptionForHR(audioStreamVolumeInterface.GetChannelCount(out channels));
- levels = new float[channels];
+ Marshal.ThrowExceptionForHR(audioStreamVolumeInterface.GetChannelCount(out var channels));
+ var levels = new float[channels];
Marshal.ThrowExceptionForHR(audioStreamVolumeInterface.GetAllVolumes(channels, levels));
return levels;
}
@@ -55,8 +50,7 @@ public int ChannelCount
{
get
{
- uint channels;
- Marshal.ThrowExceptionForHR(audioStreamVolumeInterface.GetChannelCount(out channels));
+ Marshal.ThrowExceptionForHR(audioStreamVolumeInterface.GetChannelCount(out var channels));
unchecked
{
return (int)channels;
@@ -74,12 +68,11 @@ public float GetChannelVolume(int channelIndex)
CheckChannelIndex(channelIndex, "channelIndex");
uint index;
- float level;
unchecked
{
index = (uint)channelIndex;
}
- Marshal.ThrowExceptionForHR(audioStreamVolumeInterface.GetChannelVolume(index, out level));
+ Marshal.ThrowExceptionForHR(audioStreamVolumeInterface.GetChannelVolume(index, out var level));
return level;
}
@@ -99,20 +92,20 @@ public void SetAllVolumes(float[] levels)
int channelCount = ChannelCount;
if (levels == null)
{
- throw new ArgumentNullException("levels");
+ throw new ArgumentNullException(nameof(levels));
}
if (levels.Length != channelCount)
{
throw new ArgumentOutOfRangeException(
- "levels",
+ nameof(levels),
String.Format(CultureInfo.InvariantCulture, "SetAllVolumes MUST be supplied with a volume level for ALL channels. The AudioStream has {0} channels and you supplied {1} channels.",
channelCount, levels.Length));
}
for (int i = 0; i < levels.Length; i++)
{
float level = levels[i];
- if (level < 0.0f) throw new ArgumentOutOfRangeException("levels", "All volumes must be between 0.0 and 1.0. Invalid volume at index: " + i.ToString());
- if (level > 1.0f) throw new ArgumentOutOfRangeException("levels", "All volumes must be between 0.0 and 1.0. Invalid volume at index: " + i.ToString());
+ if (level < 0.0f) throw new ArgumentOutOfRangeException(nameof(levels), "All volumes must be between 0.0 and 1.0. Invalid volume at index: " + i.ToString());
+ if (level > 1.0f) throw new ArgumentOutOfRangeException(nameof(levels), "All volumes must be between 0.0 and 1.0. Invalid volume at index: " + i.ToString());
}
unchecked
{
@@ -129,8 +122,8 @@ public void SetChannelVolume(int index, float level)
{
CheckChannelIndex(index, "index");
- if (level < 0.0f) throw new ArgumentOutOfRangeException("level", "Volume must be between 0.0 and 1.0");
- if (level > 1.0f) throw new ArgumentOutOfRangeException("level", "Volume must be between 0.0 and 1.0");
+ if (level < 0.0f) throw new ArgumentOutOfRangeException(nameof(level), "Volume must be between 0.0 and 1.0");
+ if (level > 1.0f) throw new ArgumentOutOfRangeException(nameof(level), "Volume must be between 0.0 and 1.0");
unchecked
{
Marshal.ThrowExceptionForHR(audioStreamVolumeInterface.SetChannelVolume((uint)index, level));
diff --git a/NAudio/CoreAudioApi/AudioVolumeNotificationData.cs b/NAudio/CoreAudioApi/AudioVolumeNotificationData.cs
index 33a04dae..38bc535f 100644
--- a/NAudio/CoreAudioApi/AudioVolumeNotificationData.cs
+++ b/NAudio/CoreAudioApi/AudioVolumeNotificationData.cs
@@ -28,60 +28,35 @@ namespace NAudio.CoreAudioApi
///
public class AudioVolumeNotificationData
{
- private readonly Guid eventContext;
- private readonly bool muted;
- private readonly float masterVolume;
- private readonly int channels;
- private readonly float[] channelVolume;
- private readonly Guid guid;
-
///
/// Event Context
///
- public Guid EventContext
- {
- get { return eventContext; }
- }
+ public Guid EventContext { get; }
///
/// Muted
///
- public bool Muted
- {
- get { return muted; }
- }
+ public bool Muted { get; }
///
/// Guid that raised the event
///
- public Guid Guid
- {
- get { return guid; }
- }
+ public Guid Guid { get; }
///
/// Master Volume
///
- public float MasterVolume
- {
- get { return masterVolume; }
- }
+ public float MasterVolume { get; }
///
/// Channels
///
- public int Channels
- {
- get { return channels; }
- }
+ public int Channels { get; }
///
/// Channel Volume
///
- public float[] ChannelVolume
- {
- get { return channelVolume; }
- }
+ public float[] ChannelVolume { get; }
///
/// Audio Volume Notification Data
@@ -93,12 +68,12 @@ public float[] ChannelVolume
///
public AudioVolumeNotificationData(Guid eventContext, bool muted, float masterVolume, float[] channelVolume, Guid guid)
{
- this.eventContext = eventContext;
- this.muted = muted;
- this.masterVolume = masterVolume;
- channels = channelVolume.Length;
- this.channelVolume = channelVolume;
- this.guid = guid;
+ EventContext = eventContext;
+ Muted = muted;
+ MasterVolume = masterVolume;
+ Channels = channelVolume.Length;
+ ChannelVolume = channelVolume;
+ Guid = guid;
}
}
}
diff --git a/NAudio/CoreAudioApi/DataFlow.cs b/NAudio/CoreAudioApi/DataFlow.cs
index b7dbd334..a634d5fe 100644
--- a/NAudio/CoreAudioApi/DataFlow.cs
+++ b/NAudio/CoreAudioApi/DataFlow.cs
@@ -1,6 +1,4 @@
-using System;
-
-namespace NAudio.CoreAudioApi
+namespace NAudio.CoreAudioApi
{
///
/// The EDataFlow enumeration defines constants that indicate the direction
diff --git a/NAudio/CoreAudioApi/Interfaces/AudioVolumeNotificationDataStruct.cs b/NAudio/CoreAudioApi/Interfaces/AudioVolumeNotificationDataStruct.cs
index 19d48391..c68aa207 100644
--- a/NAudio/CoreAudioApi/Interfaces/AudioVolumeNotificationDataStruct.cs
+++ b/NAudio/CoreAudioApi/Interfaces/AudioVolumeNotificationDataStruct.cs
@@ -21,6 +21,7 @@ 3. This notice may not be removed or altered from any source distribution.
*/
using System;
+// ReSharper disable InconsistentNaming
namespace NAudio.CoreAudioApi.Interfaces
{
@@ -31,22 +32,5 @@ internal struct AudioVolumeNotificationDataStruct
public float fMasterVolume;
public uint nChannels;
public float ChannelVolume;
-
- //Code Should Compile at warning level4 without any warnings,
- //However this struct will give us Warning CS0649: Field [Fieldname]
- //is never assigned to, and will always have its default value
- //You can disable CS0649 in the project options but that will disable
- //the warning for the whole project, it's a nice warning and we do want
- //it in other places so we make a nice dummy function to keep the compiler
- //happy.
- private void FixCS0649()
- {
- guidEventContext = Guid.Empty;
- bMuted = false;
- fMasterVolume = 0;
- nChannels = 0;
- ChannelVolume = 0;
- }
-
}
}
diff --git a/NAudio/CoreAudioApi/Interfaces/Blob.cs b/NAudio/CoreAudioApi/Interfaces/Blob.cs
index d1e72716..c7e459e3 100644
--- a/NAudio/CoreAudioApi/Interfaces/Blob.cs
+++ b/NAudio/CoreAudioApi/Interfaces/Blob.cs
@@ -21,9 +21,6 @@ 3. This notice may not be removed or altered from any source distribution.
*/
// Adapted for NAudio
using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Runtime.InteropServices;
namespace NAudio.CoreAudioApi.Interfaces
{
@@ -40,19 +37,5 @@ public struct Blob
/// Pointer to buffer storing data.
///
public IntPtr Data;
-
- //Code Should Compile at warning level4 without any warnings,
- //However this struct will give us Warning CS0649: Field [Fieldname]
- //is never assigned to, and will always have its default value
- //You can disable CS0649 in the project options but that will disable
- //the warning for the whole project, it's a nice warning and we do want
- //it in other places so we make a nice dummy function to keep the compiler
- //happy.
- private void FixCS0649()
- {
- Length = 0;
- Data = IntPtr.Zero;
- }
}
-}
-
+}
\ No newline at end of file
diff --git a/NAudio/CoreAudioApi/Interfaces/ClsCtx.cs b/NAudio/CoreAudioApi/Interfaces/ClsCtx.cs
index 13ab7ae6..b51cffe3 100644
--- a/NAudio/CoreAudioApi/Interfaces/ClsCtx.cs
+++ b/NAudio/CoreAudioApi/Interfaces/ClsCtx.cs
@@ -1,6 +1,5 @@
using System;
-using System.Collections.Generic;
-using System.Text;
+// ReSharper disable InconsistentNaming
namespace NAudio.CoreAudioApi.Interfaces
{
diff --git a/NAudio/CoreAudioApi/Interfaces/ErrorCodes.cs b/NAudio/CoreAudioApi/Interfaces/ErrorCodes.cs
index 4791bcf1..093a997d 100644
--- a/NAudio/CoreAudioApi/Interfaces/ErrorCodes.cs
+++ b/NAudio/CoreAudioApi/Interfaces/ErrorCodes.cs
@@ -1,6 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Text;
using NAudio.Utils;
namespace NAudio.CoreAudioApi.Interfaces
@@ -29,8 +27,7 @@ public enum AudioClientErrors
}
static class ErrorCodes
- {
- // AUDCLNT_ERR(n) MAKE_HRESULT(SEVERITY_ERROR, FACILITY_AUDCLNT, n)
+ { // AUDCLNT_ERR(n) MAKE_HRESULT(SEVERITY_ERROR, FACILITY_AUDCLNT, n)
// AUDCLNT_SUCCESS(n) MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_AUDCLNT, n)
// ReSharper disable InconsistentNaming
public const int SEVERITY_ERROR = 1;
@@ -58,7 +55,6 @@ static class ErrorCodes
public static readonly int AUDCLNT_E_BUFFER_SIZE_ERROR = HResult.MAKE_HRESULT(SEVERITY_ERROR, FACILITY_AUDCLNT, 0x016);
public static readonly int AUDCLNT_E_CPUUSAGE_EXCEEDED = HResult.MAKE_HRESULT(SEVERITY_ERROR, FACILITY_AUDCLNT, 0x017);
public static readonly int AUDCLNT_E_RESOURCES_INVALIDATED = unchecked((int) 0x88890026);
- // ReSharper restore InconsistentNaming
/*static readonly int AUDCLNT_S_BUFFER_EMPTY AUDCLNT_SUCCESS(0x001)
static readonly int AUDCLNT_S_THREAD_ALREADY_REGISTERED AUDCLNT_SUCCESS(0x002)
static readonly int AUDCLNT_S_POSITION_STALLED AUDCLNT_SUCCESS(0x003)*/
diff --git a/NAudio/CoreAudioApi/Interfaces/IAudioCaptureClient.cs b/NAudio/CoreAudioApi/Interfaces/IAudioCaptureClient.cs
index d8c04e69..57d76187 100644
--- a/NAudio/CoreAudioApi/Interfaces/IAudioCaptureClient.cs
+++ b/NAudio/CoreAudioApi/Interfaces/IAudioCaptureClient.cs
@@ -1,6 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Text;
using System.Runtime.InteropServices;
namespace NAudio.CoreAudioApi.Interfaces
diff --git a/NAudio/CoreAudioApi/Interfaces/IAudioClock2.cs b/NAudio/CoreAudioApi/Interfaces/IAudioClock2.cs
index 951f78f9..ec6436e2 100644
--- a/NAudio/CoreAudioApi/Interfaces/IAudioClock2.cs
+++ b/NAudio/CoreAudioApi/Interfaces/IAudioClock2.cs
@@ -1,6 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Text;
using System.Runtime.InteropServices;
namespace NAudio.CoreAudioApi.Interfaces
diff --git a/NAudio/CoreAudioApi/Interfaces/IAudioEndpointVolume.cs b/NAudio/CoreAudioApi/Interfaces/IAudioEndpointVolume.cs
index 2e4b9d01..9e50895d 100644
--- a/NAudio/CoreAudioApi/Interfaces/IAudioEndpointVolume.cs
+++ b/NAudio/CoreAudioApi/Interfaces/IAudioEndpointVolume.cs
@@ -20,8 +20,6 @@ misrepresented as being the original source code.
3. This notice may not be removed or altered from any source distribution.
*/
using System;
-using System.Collections.Generic;
-using System.Text;
using System.Runtime.InteropServices;
namespace NAudio.CoreAudioApi.Interfaces
diff --git a/NAudio/CoreAudioApi/Interfaces/IAudioEndpointVolumeCallback.cs b/NAudio/CoreAudioApi/Interfaces/IAudioEndpointVolumeCallback.cs
index 6515a1a7..9cc299ab 100644
--- a/NAudio/CoreAudioApi/Interfaces/IAudioEndpointVolumeCallback.cs
+++ b/NAudio/CoreAudioApi/Interfaces/IAudioEndpointVolumeCallback.cs
@@ -23,8 +23,6 @@ 3. This notice may not be removed or altered from any source distribution.
*/
using System;
-using System.Collections.Generic;
-using System.Text;
using System.Runtime.InteropServices;
namespace NAudio.CoreAudioApi.Interfaces
diff --git a/NAudio/CoreAudioApi/Interfaces/IAudioSessionEnumerator.cs b/NAudio/CoreAudioApi/Interfaces/IAudioSessionEnumerator.cs
index b1214ef2..aed27b4e 100644
--- a/NAudio/CoreAudioApi/Interfaces/IAudioSessionEnumerator.cs
+++ b/NAudio/CoreAudioApi/Interfaces/IAudioSessionEnumerator.cs
@@ -1,8 +1,6 @@
using System;
-using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
-using System.Text;
namespace NAudio.CoreAudioApi.Interfaces
{
diff --git a/NAudio/CoreAudioApi/Interfaces/IAudioSessionManager.cs b/NAudio/CoreAudioApi/Interfaces/IAudioSessionManager.cs
index ee0e3116..7756aa53 100644
--- a/NAudio/CoreAudioApi/Interfaces/IAudioSessionManager.cs
+++ b/NAudio/CoreAudioApi/Interfaces/IAudioSessionManager.cs
@@ -100,7 +100,7 @@ [In] [MarshalAs(UnmanagedType.U4)] UInt32 streamFlags,
int UnregisterSessionNotification(IAudioSessionNotification sessionNotification);
[PreserveSig]
- int RegisterDuckNotification(string sessionID, IAudioSessionNotification audioVolumeDuckNotification);
+ int RegisterDuckNotification(string sessionId, IAudioSessionNotification audioVolumeDuckNotification);
[PreserveSig]
int UnregisterDuckNotification(IntPtr audioVolumeDuckNotification);
diff --git a/NAudio/CoreAudioApi/Interfaces/IAudioSessionNotification.cs b/NAudio/CoreAudioApi/Interfaces/IAudioSessionNotification.cs
index 44ec2286..dbef75b0 100644
--- a/NAudio/CoreAudioApi/Interfaces/IAudioSessionNotification.cs
+++ b/NAudio/CoreAudioApi/Interfaces/IAudioSessionNotification.cs
@@ -1,8 +1,6 @@
using System;
-using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
-using System.Text;
namespace NAudio.CoreAudioApi.Interfaces
{
@@ -21,6 +19,6 @@ public interface IAudioSessionNotification
/// session being added
/// An HRESULT code indicating whether the operation succeeded of failed.
[PreserveSig]
- int OnSessionCreated(Interfaces.IAudioSessionControl newSession);
+ int OnSessionCreated(IAudioSessionControl newSession);
}
}
diff --git a/NAudio/CoreAudioApi/Interfaces/IAudioStreamVolume.cs b/NAudio/CoreAudioApi/Interfaces/IAudioStreamVolume.cs
index 57b63af7..59b85b08 100644
--- a/NAudio/CoreAudioApi/Interfaces/IAudioStreamVolume.cs
+++ b/NAudio/CoreAudioApi/Interfaces/IAudioStreamVolume.cs
@@ -1,8 +1,6 @@
using System;
-using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
-using System.Text;
namespace NAudio.CoreAudioApi.Interfaces
{
diff --git a/NAudio/CoreAudioApi/Interfaces/IMMDevice.cs b/NAudio/CoreAudioApi/Interfaces/IMMDevice.cs
index b734b425..e4cb923b 100644
--- a/NAudio/CoreAudioApi/Interfaces/IMMDevice.cs
+++ b/NAudio/CoreAudioApi/Interfaces/IMMDevice.cs
@@ -1,6 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Text;
using System.Runtime.InteropServices;
namespace NAudio.CoreAudioApi.Interfaces
diff --git a/NAudio/CoreAudioApi/Interfaces/IMMDeviceCollection.cs b/NAudio/CoreAudioApi/Interfaces/IMMDeviceCollection.cs
index 6a9402a6..be1b459a 100644
--- a/NAudio/CoreAudioApi/Interfaces/IMMDeviceCollection.cs
+++ b/NAudio/CoreAudioApi/Interfaces/IMMDeviceCollection.cs
@@ -1,6 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Text;
using System.Runtime.InteropServices;
namespace NAudio.CoreAudioApi.Interfaces
diff --git a/NAudio/CoreAudioApi/Interfaces/IMMDeviceEnumerator.cs b/NAudio/CoreAudioApi/Interfaces/IMMDeviceEnumerator.cs
index 80e3c2a6..315fb929 100644
--- a/NAudio/CoreAudioApi/Interfaces/IMMDeviceEnumerator.cs
+++ b/NAudio/CoreAudioApi/Interfaces/IMMDeviceEnumerator.cs
@@ -1,6 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Text;
using System.Runtime.InteropServices;
namespace NAudio.CoreAudioApi.Interfaces
diff --git a/NAudio/CoreAudioApi/Interfaces/IMMEndpoint.cs b/NAudio/CoreAudioApi/Interfaces/IMMEndpoint.cs
index 4d7c8b66..3201e800 100644
--- a/NAudio/CoreAudioApi/Interfaces/IMMEndpoint.cs
+++ b/NAudio/CoreAudioApi/Interfaces/IMMEndpoint.cs
@@ -1,6 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Text;
using System.Runtime.InteropServices;
namespace NAudio.CoreAudioApi.Interfaces
diff --git a/NAudio/CoreAudioApi/Interfaces/IMMNotificationClient.cs b/NAudio/CoreAudioApi/Interfaces/IMMNotificationClient.cs
index 91071854..8c8678b8 100644
--- a/NAudio/CoreAudioApi/Interfaces/IMMNotificationClient.cs
+++ b/NAudio/CoreAudioApi/Interfaces/IMMNotificationClient.cs
@@ -1,6 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Text;
using System.Runtime.InteropServices;
namespace NAudio.CoreAudioApi.Interfaces
diff --git a/NAudio/CoreAudioApi/Interfaces/IPropertyStore.cs b/NAudio/CoreAudioApi/Interfaces/IPropertyStore.cs
index 4d6e8f35..5b701854 100644
--- a/NAudio/CoreAudioApi/Interfaces/IPropertyStore.cs
+++ b/NAudio/CoreAudioApi/Interfaces/IPropertyStore.cs
@@ -1,6 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Text;
using System.Runtime.InteropServices;
namespace NAudio.CoreAudioApi.Interfaces
diff --git a/NAudio/CoreAudioApi/Interfaces/MMDeviceEnumeratorComObject.cs b/NAudio/CoreAudioApi/Interfaces/MMDeviceEnumeratorComObject.cs
index a144fe72..b5ea09e9 100644
--- a/NAudio/CoreAudioApi/Interfaces/MMDeviceEnumeratorComObject.cs
+++ b/NAudio/CoreAudioApi/Interfaces/MMDeviceEnumeratorComObject.cs
@@ -1,6 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Text;
using System.Runtime.InteropServices;
namespace NAudio.CoreAudioApi.Interfaces
diff --git a/NAudio/CoreAudioApi/Interfaces/StorageAccessMode.cs b/NAudio/CoreAudioApi/Interfaces/StorageAccessMode.cs
index a829178a..570f9bef 100644
--- a/NAudio/CoreAudioApi/Interfaces/StorageAccessMode.cs
+++ b/NAudio/CoreAudioApi/Interfaces/StorageAccessMode.cs
@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace NAudio.CoreAudioApi.Interfaces
+namespace NAudio.CoreAudioApi.Interfaces
{
///
/// MMDevice STGM enumeration
diff --git a/NAudio/CoreAudioApi/MMDevice.cs b/NAudio/CoreAudioApi/MMDevice.cs
index 96dae4a3..b7e5a450 100644
--- a/NAudio/CoreAudioApi/MMDevice.cs
+++ b/NAudio/CoreAudioApi/MMDevice.cs
@@ -42,10 +42,12 @@ public class MMDevice : IDisposable
#endregion
#region Guids
+ // ReSharper disable InconsistentNaming
private static Guid IID_IAudioMeterInformation = new Guid("C02216F6-8C67-4B5B-9D00-D008E73E0064");
private static Guid IID_IAudioEndpointVolume = new Guid("5CDF2C82-841E-4546-9722-0CF74078229A");
private static Guid IID_IAudioClient = new Guid("1CB9AD4C-DBFA-4c32-B178-C2F568A703B2");
private static Guid IDD_IAudioSessionManager = new Guid("BFA971F1-4D5E-40BB-935E-967039BFBEE4");
+ // ReSharper restore InconsistentNaming
#endregion
#region Init
@@ -56,36 +58,31 @@ public class MMDevice : IDisposable
/// Administrative client is required for Write and ReadWrite modes.
public void GetPropertyInformation(StorageAccessMode stgmAccess = StorageAccessMode.Read)
{
- IPropertyStore propstore;
- Marshal.ThrowExceptionForHR(deviceInterface.OpenPropertyStore(stgmAccess, out propstore));
+ Marshal.ThrowExceptionForHR(deviceInterface.OpenPropertyStore(stgmAccess, out var propstore));
propertyStore = new PropertyStore(propstore);
}
private AudioClient GetAudioClient()
{
- object result;
- Marshal.ThrowExceptionForHR(deviceInterface.Activate(ref IID_IAudioClient, ClsCtx.ALL, IntPtr.Zero, out result));
+ Marshal.ThrowExceptionForHR(deviceInterface.Activate(ref IID_IAudioClient, ClsCtx.ALL, IntPtr.Zero, out var result));
return new AudioClient(result as IAudioClient);
}
private void GetAudioMeterInformation()
{
- object result;
- Marshal.ThrowExceptionForHR(deviceInterface.Activate(ref IID_IAudioMeterInformation, ClsCtx.ALL, IntPtr.Zero, out result));
+ Marshal.ThrowExceptionForHR(deviceInterface.Activate(ref IID_IAudioMeterInformation, ClsCtx.ALL, IntPtr.Zero, out var result));
audioMeterInformation = new AudioMeterInformation(result as IAudioMeterInformation);
}
private void GetAudioEndpointVolume()
{
- object result;
- Marshal.ThrowExceptionForHR(deviceInterface.Activate(ref IID_IAudioEndpointVolume, ClsCtx.ALL, IntPtr.Zero, out result));
+ Marshal.ThrowExceptionForHR(deviceInterface.Activate(ref IID_IAudioEndpointVolume, ClsCtx.ALL, IntPtr.Zero, out var result));
audioEndpointVolume = new AudioEndpointVolume(result as IAudioEndpointVolume);
}
private void GetAudioSessionManager()
{
- object result;
- Marshal.ThrowExceptionForHR(deviceInterface.Activate(ref IDD_IAudioSessionManager, ClsCtx.ALL, IntPtr.Zero, out result));
+ Marshal.ThrowExceptionForHR(deviceInterface.Activate(ref IDD_IAudioSessionManager, ClsCtx.ALL, IntPtr.Zero, out var result));
audioSessionManager = new AudioSessionManager(result as IAudioSessionManager);
}
#endregion
@@ -94,16 +91,10 @@ private void GetAudioSessionManager()
///
/// Audio Client
+ /// Makes a new one each call to allow caller to manage when to dispose
+ /// n.b. should probably not be a property anymore
///
- public AudioClient AudioClient
- {
- get
- {
- // now makes a new one each call to allow caller to manage when to dispose
- // n.b. should probably not be a property anymore
- return GetAudioClient();
- }
- }
+ public AudioClient AudioClient => GetAudioClient();
///
/// Audio Meter Information
@@ -218,8 +209,8 @@ public string IconPath
{
return (string)propertyStore[PropertyKeys.PKEY_Device_IconPath].Value;
}
- else
- return "Unknown";
+
+ return "Unknown";
}
}
@@ -230,8 +221,7 @@ public string ID
{
get
{
- string result;
- Marshal.ThrowExceptionForHR(deviceInterface.GetId(out result));
+ Marshal.ThrowExceptionForHR(deviceInterface.GetId(out var result));
return result;
}
}
@@ -243,9 +233,8 @@ public DataFlow DataFlow
{
get
{
- DataFlow result;
var ep = deviceInterface as IMMEndpoint;
- ep.GetDataFlow(out result);
+ ep.GetDataFlow(out var result);
return result;
}
}
@@ -257,8 +246,7 @@ public DeviceState State
{
get
{
- DeviceState result;
- Marshal.ThrowExceptionForHR(deviceInterface.GetState(out result));
+ Marshal.ThrowExceptionForHR(deviceInterface.GetState(out var result));
return result;
}
}
diff --git a/NAudio/CoreAudioApi/MMDeviceCollection.cs b/NAudio/CoreAudioApi/MMDeviceCollection.cs
index 14dede86..8c151f28 100644
--- a/NAudio/CoreAudioApi/MMDeviceCollection.cs
+++ b/NAudio/CoreAudioApi/MMDeviceCollection.cs
@@ -32,7 +32,7 @@ namespace NAudio.CoreAudioApi
///
public class MMDeviceCollection : IEnumerable
{
- private IMMDeviceCollection _MMDeviceCollection;
+ private readonly IMMDeviceCollection mmDeviceCollection;
///
/// Device count
@@ -41,8 +41,7 @@ public int Count
{
get
{
- int result;
- Marshal.ThrowExceptionForHR(_MMDeviceCollection.GetCount(out result));
+ Marshal.ThrowExceptionForHR(mmDeviceCollection.GetCount(out var result));
return result;
}
}
@@ -56,15 +55,14 @@ public MMDevice this[int index]
{
get
{
- IMMDevice result;
- _MMDeviceCollection.Item(index, out result);
+ mmDeviceCollection.Item(index, out var result);
return new MMDevice(result);
}
}
internal MMDeviceCollection(IMMDeviceCollection parent)
{
- _MMDeviceCollection = parent;
+ mmDeviceCollection = parent;
}
#region IEnumerable Members
diff --git a/NAudio/CoreAudioApi/MMDeviceEnumerator.cs b/NAudio/CoreAudioApi/MMDeviceEnumerator.cs
index 64bf8731..38274791 100644
--- a/NAudio/CoreAudioApi/MMDeviceEnumerator.cs
+++ b/NAudio/CoreAudioApi/MMDeviceEnumerator.cs
@@ -56,8 +56,7 @@ public MMDeviceEnumerator()
/// Device Collection
public MMDeviceCollection EnumerateAudioEndPoints(DataFlow dataFlow, DeviceState dwStateMask)
{
- IMMDeviceCollection result;
- Marshal.ThrowExceptionForHR(realEnumerator.EnumAudioEndpoints(dataFlow, dwStateMask, out result));
+ Marshal.ThrowExceptionForHR(realEnumerator.EnumAudioEndpoints(dataFlow, dwStateMask, out var result));
return new MMDeviceCollection(result);
}
@@ -69,8 +68,7 @@ public MMDeviceCollection EnumerateAudioEndPoints(DataFlow dataFlow, DeviceState
/// Device
public MMDevice GetDefaultAudioEndpoint(DataFlow dataFlow, Role role)
{
- IMMDevice device = null;
- Marshal.ThrowExceptionForHR(((IMMDeviceEnumerator)realEnumerator).GetDefaultAudioEndpoint(dataFlow, role, out device));
+ Marshal.ThrowExceptionForHR(((IMMDeviceEnumerator)realEnumerator).GetDefaultAudioEndpoint(dataFlow, role, out var device));
return new MMDevice(device);
}
@@ -83,8 +81,7 @@ public MMDevice GetDefaultAudioEndpoint(DataFlow dataFlow, Role role)
public bool HasDefaultAudioEndpoint(DataFlow dataFlow, Role role)
{
const int E_NOTFOUND = unchecked((int)0x80070490);
- IMMDevice device = null;
- int hresult = ((IMMDeviceEnumerator)realEnumerator).GetDefaultAudioEndpoint(dataFlow, role, out device);
+ int hresult = ((IMMDeviceEnumerator)realEnumerator).GetDefaultAudioEndpoint(dataFlow, role, out var device);
if (hresult == 0x0)
{
Marshal.ReleaseComObject(device);
@@ -105,8 +102,7 @@ public bool HasDefaultAudioEndpoint(DataFlow dataFlow, Role role)
/// Device
public MMDevice GetDevice(string id)
{
- IMMDevice device = null;
- Marshal.ThrowExceptionForHR(((IMMDeviceEnumerator)realEnumerator).GetDevice(id, out device));
+ Marshal.ThrowExceptionForHR(((IMMDeviceEnumerator)realEnumerator).GetDevice(id, out var device));
return new MMDevice(device);
}
diff --git a/NAudio/CoreAudioApi/PropVariant.cs b/NAudio/CoreAudioApi/PropVariant.cs
index 780ac109..732739bd 100644
--- a/NAudio/CoreAudioApi/PropVariant.cs
+++ b/NAudio/CoreAudioApi/PropVariant.cs
@@ -220,12 +220,9 @@ public T[] GetBlobAsArrayOf()
///
/// Gets the type of data in this PropVariant
///
- public VarEnum DataType
- {
- get { return (VarEnum) vt; }
- }
+ public VarEnum DataType => (VarEnum) vt;
- ///
+ ///
/// Property value
///
public object Value
diff --git a/NAudio/CoreAudioApi/PropertyKeys.cs b/NAudio/CoreAudioApi/PropertyKeys.cs
index eee6901e..167fd9f0 100644
--- a/NAudio/CoreAudioApi/PropertyKeys.cs
+++ b/NAudio/CoreAudioApi/PropertyKeys.cs
@@ -20,6 +20,7 @@ misrepresented as being the original source code.
3. This notice may not be removed or altered from any source distribution.
*/
using System;
+// ReSharper disable InconsistentNaming
namespace NAudio.CoreAudioApi
{
diff --git a/NAudio/CoreAudioApi/PropertyStore.cs b/NAudio/CoreAudioApi/PropertyStore.cs
index d2b0db43..2a8198c7 100644
--- a/NAudio/CoreAudioApi/PropertyStore.cs
+++ b/NAudio/CoreAudioApi/PropertyStore.cs
@@ -40,8 +40,7 @@ public int Count
{
get
{
- int result;
- Marshal.ThrowExceptionForHR(storeInterface.GetCount(out result));
+ Marshal.ThrowExceptionForHR(storeInterface.GetCount(out var result));
return result;
}
}
@@ -55,9 +54,8 @@ public PropertyStoreProperty this[int index]
{
get
{
- PropVariant result;
PropertyKey key = Get(index);
- Marshal.ThrowExceptionForHR(storeInterface.GetValue(ref key, out result));
+ Marshal.ThrowExceptionForHR(storeInterface.GetValue(ref key, out var result));
return new PropertyStoreProperty(key, result);
}
}
@@ -89,13 +87,12 @@ public PropertyStoreProperty this[PropertyKey key]
{
get
{
- PropVariant result;
for (int i = 0; i < Count; i++)
{
PropertyKey ikey = Get(i);
if ((ikey.formatId == key.formatId) && (ikey.propertyId == key.propertyId))
{
- Marshal.ThrowExceptionForHR(storeInterface.GetValue(ref ikey, out result));
+ Marshal.ThrowExceptionForHR(storeInterface.GetValue(ref ikey, out var result));
return new PropertyStoreProperty(ikey, result);
}
}
@@ -110,8 +107,7 @@ public PropertyStoreProperty this[PropertyKey key]
/// Property key
public PropertyKey Get(int index)
{
- PropertyKey key;
- Marshal.ThrowExceptionForHR(storeInterface.GetAt(index, out key));
+ Marshal.ThrowExceptionForHR(storeInterface.GetAt(index, out var key));
return key;
}
@@ -122,9 +118,8 @@ public PropertyKey Get(int index)
/// Property value
public PropVariant GetValue(int index)
{
- PropVariant result;
PropertyKey key = Get(index);
- Marshal.ThrowExceptionForHR(storeInterface.GetValue(ref key, out result));
+ Marshal.ThrowExceptionForHR(storeInterface.GetValue(ref key, out var result));
return result;
}
@@ -152,7 +147,7 @@ public void Commit()
/// IPropertyStore COM interface
internal PropertyStore(IPropertyStore store)
{
- this.storeInterface = store;
+ storeInterface = store;
}
}
}
diff --git a/NAudio/CoreAudioApi/PropertyStoreProperty.cs b/NAudio/CoreAudioApi/PropertyStoreProperty.cs
index 9abf9425..9a42cf82 100644
--- a/NAudio/CoreAudioApi/PropertyStoreProperty.cs
+++ b/NAudio/CoreAudioApi/PropertyStoreProperty.cs
@@ -21,8 +21,6 @@ 3. This notice may not be removed or altered from any source distribution.
*/
// modified from Ray Molenkamp's original
-
-using System;
using NAudio.CoreAudioApi.Interfaces;
namespace NAudio.CoreAudioApi
@@ -32,30 +30,23 @@ namespace NAudio.CoreAudioApi
///
public class PropertyStoreProperty
{
- private readonly PropertyKey propertyKey;
private PropVariant propertyValue;
internal PropertyStoreProperty(PropertyKey key, PropVariant value)
{
- propertyKey = key;
+ Key = key;
propertyValue = value;
}
///
/// Property Key
///
- public PropertyKey Key
- {
- get { return propertyKey; }
- }
+ public PropertyKey Key { get; }
///
/// Property Value
///
- public object Value
- {
- get { return propertyValue.Value; }
- }
+ public object Value => propertyValue.Value;
}
}
diff --git a/NAudio/CoreAudioApi/SessionCollection.cs b/NAudio/CoreAudioApi/SessionCollection.cs
index 6a485ab7..36b946a8 100644
--- a/NAudio/CoreAudioApi/SessionCollection.cs
+++ b/NAudio/CoreAudioApi/SessionCollection.cs
@@ -26,8 +26,7 @@ public AudioSessionControl this[int index]
{
get
{
- IAudioSessionControl result;
- Marshal.ThrowExceptionForHR(audioSessionEnumerator.GetSession(index, out result));
+ Marshal.ThrowExceptionForHR(audioSessionEnumerator.GetSession(index, out var result));
return new AudioSessionControl(result);
}
}
@@ -39,8 +38,7 @@ public int Count
{
get
{
- int result;
- Marshal.ThrowExceptionForHR(audioSessionEnumerator.GetCount(out result));
+ Marshal.ThrowExceptionForHR(audioSessionEnumerator.GetCount(out var result));
return result;
}
}
diff --git a/NAudio/CoreAudioApi/SimpleAudioVolume.cs b/NAudio/CoreAudioApi/SimpleAudioVolume.cs
index f2c77d4c..232bcdcf 100644
--- a/NAudio/CoreAudioApi/SimpleAudioVolume.cs
+++ b/NAudio/CoreAudioApi/SimpleAudioVolume.cs
@@ -53,8 +53,7 @@ public float Volume
{
get
{
- float result;
- Marshal.ThrowExceptionForHR(simpleAudioVolume.GetMasterVolume(out result));
+ Marshal.ThrowExceptionForHR(simpleAudioVolume.GetMasterVolume(out var result));
return result;
}
set
@@ -74,10 +73,7 @@ public bool Mute
{
get
{
- bool result;
-
- Marshal.ThrowExceptionForHR(simpleAudioVolume.GetMute(out result));
-
+ Marshal.ThrowExceptionForHR(simpleAudioVolume.GetMute(out var result));
return result;
}
set