diff options
| -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> |
