From 85cf1096fb1c2d18f06a3f87af648c7bc3dbb487 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Fri, 3 Feb 2023 12:56:28 +0100 Subject: Minor, .NET wrapper --- WhisperNet/API/iModel.cs | 1 + WhisperNet/ExtensionMethods.cs | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'WhisperNet') diff --git a/WhisperNet/API/iModel.cs b/WhisperNet/API/iModel.cs index 9268870..0b7a76d 100644 --- a/WhisperNet/API/iModel.cs +++ b/WhisperNet/API/iModel.cs @@ -22,6 +22,7 @@ namespace Whisper /// Try to resolve integer token ID into string. /// Don't call this method, use instead. + [EditorBrowsable( EditorBrowsableState.Never )] IntPtr stringFromTokenInternal( int id ); } } \ No newline at end of file diff --git a/WhisperNet/ExtensionMethods.cs b/WhisperNet/ExtensionMethods.cs index 73ca15c..1bb594b 100644 --- a/WhisperNet/ExtensionMethods.cs +++ b/WhisperNet/ExtensionMethods.cs @@ -1,4 +1,5 @@ -using System.Runtime.InteropServices; +using System.Diagnostics; +using System.Runtime.InteropServices; using Whisper.Internal; namespace Whisper @@ -33,7 +34,7 @@ namespace Whisper /// List capture devices public static CaptureDeviceId[]? listCaptureDevices( this iMediaFoundation mf ) { - List? list = null; + CaptureDeviceId[]? result = null; pfnFoundCaptureDevices pfn = delegate ( int len, sCaptureDevice[]? arr, IntPtr pv ) { @@ -41,10 +42,11 @@ namespace Whisper { if( len == 0 || arr == null ) return 1; + Debug.Assert( len == arr.Length ); - list = new List( len ); - foreach( var i in arr ) - list.Add( new CaptureDeviceId( i ) ); + result = new CaptureDeviceId[ len ]; + for( int i = 0; i < len; i++ ) + result[ i ] = new CaptureDeviceId( arr[ i ] ); return 0; } catch( Exception ex ) @@ -56,7 +58,7 @@ namespace Whisper mf.listCaptureDevices( pfn, IntPtr.Zero ); - return list?.ToArray(); + return result; } /// Open audio capture device -- cgit v1.2.3