WaveIn / WaveOut and WaveInSafeHandle /WaveOutSafeHandle modifications

Oct 25, 2016 at 9:41 AM
Hello to everyone.
After having exception (with message "handle safe is closed") calling Close method of WaveIn and WaveOut classes I've done modification to this files.

This is for WaveIn
public void Close()
          {
                lock (this.startStopLock)
                {
                     if (this.handle != null)
                     {
                          if (!this.handle.IsClosed && !this.handle.IsInvalid)
                          {
                                this.Stop();
                                //this.handle.Close();
                                NativeMethods.Throw(
                                    NativeMethods.waveInClose(this.handle),
                                    NativeMethods.ErrorSource.WaveIn);
                          }

                          this.handle = null;
                     }
                }
          }
This is for in WaveInSafeHandle
protected override bool ReleaseHandle()
        {
            MMSYSERROR ret = MMSYSERROR.MMSYSERR_NOERROR; //NativeMethods.waveInClose(this);
            return ret == MMSYSERROR.MMSYSERR_NOERROR;
        }
After having done this modification the Exception was no more raised and I don't have any other problem with Open / Close methods.

I'd like to have suggestions and advice about these changes (are they correct?).

Bye