File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ namespace NAudio.CoreAudioApi
30
30
/// </summary>
31
31
public class AudioMeterInformationChannels
32
32
{
33
- readonly IAudioMeterInformation audioMeterInformation ;
33
+ private readonly IAudioMeterInformation audioMeterInformation ;
34
34
35
35
/// <summary>
36
36
/// Metering Channel Count
@@ -54,8 +54,14 @@ public float this[int index]
54
54
{
55
55
get
56
56
{
57
+ var channels = Count ;
58
+ if ( index >= channels )
59
+ {
60
+ throw new ArgumentOutOfRangeException ( nameof ( index ) ,
61
+ $ "Peak index cannot be greater than number of channels ({ channels } )") ;
62
+ }
57
63
var peakValues = new float [ Count ] ;
58
- GCHandle Params = GCHandle . Alloc ( peakValues , GCHandleType . Pinned ) ;
64
+ var Params = GCHandle . Alloc ( peakValues , GCHandleType . Pinned ) ;
59
65
Marshal . ThrowExceptionForHR ( audioMeterInformation . GetChannelsPeakValues ( peakValues . Length , Params . AddrOfPinnedObject ( ) ) ) ;
60
66
Params . Free ( ) ;
61
67
return peakValues [ index ] ;
You can’t perform that action at this time.
0 commit comments