Quantcast
Channel: naudio Work Item Rss Feed
Viewing all articles
Browse latest Browse all 738

Commented Unassigned: Error with Stoprecording [16491]

$
0
0
Hi,

I developed a routine to produce sound with NAudio. When I stop the recording, I get the following error message:

INVALIDHANDLE CALLING WAVEINSTOP

Anyone know why?

Thx.

Here is my code:

Friend Sub StartCapture()
Try
_WaveInDevice = New WaveInEvent()
_WaveInDevice.DeviceNumber = 0
_WaveInDevice.WaveFormat = New WaveFormat(8000, 16, 1)
_WaveInDevice.NumberOfBuffers = 2
_WaveInDevice.BufferMilliseconds = 60
_WaveInDevice.StartRecording()
NbPaquetsAudioParPTT = 0
RaiseEvent OnDisplayMessage("Microphone opening...")
Catch Ex As Exception
RaiseEvent OnError("NaudioMicro", "StartCapture", Ex.Message, Ex.StackTrace)
End Try
End Sub

Friend Sub StopCapture()
Try
If _WaveInDevice IsNot Nothing Then
_WaveInDevice.StopRecording()
_WaveInDevice.Dispose()
_WaveInDevice = Nothing
End If
Catch Ex As Exception
RaiseEvent OnError("NaudioMicro", "StopCapture", Ex.Message, Ex.StackTrace)
End Try
End Sub

Private Sub _WaveInDevice_DataAvailable(ByVal sender As Object, ByVal e As NAudio.Wave.WaveInEventArgs) Handles _WaveInDevice.DataAvailable
NbPaquetsAudioParPTT += 1
RaiseEvent OnCaptured(e.Buffer, NbPaquetsAudioParPTT)
End Sub
































Comments: subscribe to RecordingStopped and dispose in there. StopRecording requests that recording stops, but it hasn't actually finished doing everything yet,

Viewing all articles
Browse latest Browse all 738

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>