Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InvalidOperationException while disposing WaveOutEvent #1184

Open
pedroivobraga opened this issue Sep 17, 2024 · 0 comments
Open

InvalidOperationException while disposing WaveOutEvent #1184

pedroivobraga opened this issue Sep 17, 2024 · 0 comments

Comments

@pedroivobraga
Copy link

I have a MixerProvider that mixes the loopback and the microphone; however, I'm experiencing an intermittent issue when disposing of the silent playback.

Into my dispose method, I'm getting the bellow exception:

System.InvalidOperationException: Handle is not initialized.
at System.Runtime.InteropServices.GCHandle.Free()
at NAudio.Wave.WaveOutBuffer.Dispose(Boolean disposing)
at NAudio.Wave.WaveOutEvent.DisposeBuffers()
at NAudio.Wave.WaveOutEvent.Dispose()
at EswLinphoneClient.Media.AudioMixerProvider.Dispose(Boolean disposing)

Dispose method:

    protected virtual void Dispose(bool disposing)
    {
        if (!disposedValue)
        {
            if (disposing)
            {
                _mixerProvider.RemoveAllMixerInputs();

                foreach (var source in _mixers.ToArray())
                {
                    source.Buffer.ClearBuffer();
                    //source.Input.Dispose(); Removed because we were experiencing the bellow error:
                    /*
                     Exception Info: System.NullReferenceException
                        at System.Runtime.InteropServices.Marshal.ReleaseComObject(System.Object)
                        at NAudio.CoreAudioApi.AudioClient.Dispose()
                        at NAudio.CoreAudioApi.WasapiCapture.Dispose()
                     */

                }

                _mixers.Clear();
                _silentPlayer?.Dispose();
            }
            disposedValue = true;
        }
    }

Do you have any idea that what could be causing such issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant