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

NullReferenceException while disposing WasapiLoopbackCapture #1183

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

NullReferenceException while disposing WasapiLoopbackCapture #1183

pedroivobraga opened this issue Sep 17, 2024 · 0 comments

Comments

@pedroivobraga
Copy link

I have a MixerProvider capable of mixing loopback and microphone input, with the microphone recording being optional. However, I'm experiencing an intermittent issue when disposing of WasapiLoopbackCapture.

Into my dispose method, I'm getting the bellow exception:
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Runtime.InteropServices.Marshal.ReleaseComObject(Object o)
at NAudio.CoreAudioApi.AudioClient.Dispose()
at NAudio.CoreAudioApi.WasapiCapture.Dispose()
at EswLinphoneClient.Media.AudioMixerProvider.Dispose

Dispose method:

      if (!disposedValue)
      {

          if (disposing)
          {
              _mixerProvider.RemoveAllMixerInputs();

              foreach (var source in _mixers.ToArray())
              {
                  source.Buffer.ClearBuffer();
                  source.Input.Dispose(); //THIS DISPOSE IS CAUSING THE ERROR
              }

              _mixers.Clear();

              _silentPlayer?.Dispose();
              _timerLoopbackChecker?.Dispose();
              _timer?.Dispose();
              _device?.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