/// <summary> /// Initializes a new instance of the AsyncAudioCapture class with the specified sample rate, channel and sampleType. /// </summary> /// <param name="sampleRate">The audio sample rate (8000 ~ 192000Hz).</param> /// <param name="channel">The audio channel type.</param> /// <param name="sampleType">The audio sample type.</param> /// <exception cref="ArgumentOutOfRangeException"> /// <paramref name="sampleRate"/> is less than <see cref="AudioCaptureBase.MinSampleRate"/>.<br/> /// -or-<br/> /// <paramref name="sampleRate"/> is greater than <see cref="AudioCaptureBase.MaxSampleRate"/>. /// </exception> /// <exception cref="ArgumentException"> /// <paramref name="channel"/> is invalid.<br/> /// -or-<br/> /// <paramref name="sampleType"/> is invalid. /// </exception> /// <exception cref="UnauthorizedAccessException">The required privilege is not specified.</exception> /// <exception cref="NotSupportedException">The system does not support microphone.</exception> /// <since_tizen> 3 </since_tizen> public AsyncAudioCapture(int sampleRate, AudioChannel channel, AudioSampleType sampleType) : base(sampleRate, channel, sampleType) { _streamCallback = (IntPtr handle, uint length, IntPtr _) => { OnInputDataAvailable(handle, length); }; AudioInput.SetStreamCallback(_handle, _streamCallback, IntPtr.Zero) .ThrowIfFailed("Failed to create instance."); }
/// <summary> /// Initializes a new instance of the AsyncAudioCapture class with the specified sample rate, channel and sampleType. /// </summary> /// <param name="sampleRate">The audio sample rate (8000 ~ 48000Hz).</param> /// <param name="channel">The audio channel type.</param> /// <param name="sampleType">The audio sample type.</param> /// <exception cref="ArgumentOutOfRangeException"> /// <paramref name="sampleRate"/> is less than <see cref="AudioCaptureBase.MinSampleRate"/>.<br/> /// -or-<br/> /// <paramref name="sampleRate"/> is greater than <see cref="AudioCaptureBase.MaxSampleRate"/>. /// </exception> /// <exception cref="ArgumentException"> /// <paramref name="channel"/> is invalid.<br/> /// -or-<br/> /// <paramref name="sampleType"/> is invalid. /// </exception> /// <exception cref="UnauthorizedAccessException">The required privilege is not specified.</exception> /// <exception cref="NotSupportedException">The system does not support microphone.</exception> /// <since_tizen> 3 </since_tizen> public AsyncAudioCapture(int sampleRate, AudioChannel channel, AudioSampleType sampleType) : base(sampleRate, channel, sampleType) { _streamCallback = (IntPtr handle, uint length, IntPtr _) => { OnInputDataAvailable(handle, length); }; AudioIOUtil.ThrowIfError( AudioInput.SetStreamCallback(_handle, _streamCallback, IntPtr.Zero), $"Failed to initialize a { nameof(AsyncAudioCapture) }"); }