diff options
| author | Konstantin <const@const.me> | 2023-02-03 12:56:28 +0100 |
|---|---|---|
| committer | Konstantin <const@const.me> | 2023-02-03 12:56:28 +0100 |
| commit | 85cf1096fb1c2d18f06a3f87af648c7bc3dbb487 (patch) | |
| tree | 13e0fa15363f0e23cecdc46a4bd0a3599a1df5e8 | |
| parent | 6238fc31c6a0a6004cfb6791a7bf85c829c8acc9 (diff) | |
Minor, .NET wrapper
| -rw-r--r-- | WhisperNet/API/iModel.cs | 1 | ||||
| -rw-r--r-- | WhisperNet/ExtensionMethods.cs | 14 |
2 files changed, 9 insertions, 6 deletions
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 /// <summary>Try to resolve integer token ID into string.</summary> /// <remarks>Don't call this method, use <see cref="ExtensionMethods.stringFromToken(iModel, int)" /> instead.</remarks> + [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 /// <summary>List capture devices</summary> public static CaptureDeviceId[]? listCaptureDevices( this iMediaFoundation mf ) { - List<CaptureDeviceId>? 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<CaptureDeviceId>( 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; } /// <summary>Open audio capture device</summary> |
