by David S [dshiel at yahoo dot com] posted on 2004/05/30 |
|
After a successful call to Play(), a subsequent call to Play() with the same file causes an exception (however, no call stack is available) at the following line:
waveOutReset(Output);
For me, this happens under WinXp but not Win2k.
I can eliminate the error by inserting the following line in the Stop method:
m_Status = MediaStatus.Stopped;
...just before the check of the m_Status member in:
if (m_Status == MediaStatus.Stopped)
However, I would like your help finding the real solution.
------------
Here is my output window text:
before SoundSuccess.Play(). 30may04 DS
after SoundSuccess.Play(). 30may04 DS
before SoundSuccess.Stop(). 30may04 DS
Stop entry. m_Disposed = False 30may04 DS
Stop entry. m_Status = Stopped 30may04 DS
Stop exit. 30may04 DS
after SoundSuccess.Stop(). 30may04 DS
Close entry. m_Disposed = False 30may04 DS
MediaStatus = Stopped 30may04 DS
In Close, before calling mmioClose. 30may04 DS
30may04 DS. calling FreeHGlobal(m_Buffer[0])
30may04 DS. calling FreeHGlobal(m_Buffer[1])
30may04 DS. calling FreeHGlobal(m_Buffer[2])
30may04 DS. calling FreeHGlobal(m_Buffer[3])
30may04 DS. calling FreeHGlobal(m_Buffer[4])
In Close, before calling GC.SuppressFinalize. 30may04 DS
Close exit. 30may04 DS
Close entry. m_Disposed = False 30may04 DS
MediaStatus = Stopped 30may04 DS
In Close, before calling mmioClose. 30may04 DS
30may04 DS. calling FreeHGlobal(m_Buffer[0])
30may04 DS. calling FreeHGlobal(m_Buffer[1])
30may04 DS. calling FreeHGlobal(m_Buffer[2])
30may04 DS. calling FreeHGlobal(m_Buffer[3])
30may04 DS. calling FreeHGlobal(m_Buffer[4])
In Close, before calling GC.SuppressFinalize. 30may04 DS
Close exit. 30may04 DS
before SoundSuccess.Play(). 30may04 DS
after SoundSuccess.Play(). 30may04 DS
before SoundSuccess.Stop(). 30may04 DS
Stop entry. m_Disposed = False 30may04 DS
Stop entry. m_Status = Stopped 30may04 DS
Stop exit. 30may04 DS
after SoundSuccess.Stop(). 30may04 DS
Close entry. m_Disposed = False 30may04 DS
MediaStatus = Stopped 30may04 DS
In Close, before calling mmioClose. 30may04 DS
30may04 DS. calling FreeHGlobal(m_Buffer[0])
30may04 DS. calling FreeHGlobal(m_Buffer[1])
30may04 DS. calling FreeHGlobal(m_Buffer[2])
30may04 DS. calling FreeHGlobal(m_Buffer[3])
30may04 DS. calling FreeHGlobal(m_Buffer[4])
In Close, before calling GC.SuppressFinalize. 30may04 DS
Close exit. 30may04 DS
Close entry. m_Disposed = False 30may04 DS
MediaStatus = Playing 30may04 DS
In Close, before calling Stop. 30may04 DS
Stop entry. m_Disposed = False 30may04 DS
Stop entry. m_Status = Playing 30may04 DS
before waveOutReset(m_Output=2259968) 30may04 DS
An unhandled exception of type 'System.NullReferenceException' occurred in Unknown Module.
Additional information: Object reference not set to an instance of an object.
-----------------------------
Below is my altered method with debug writeline statements inserted, for your reference.
public void Stop()
{
Debug.WriteLine("Stop entry. m_Disposed = " + m_Disposed.ToString() + " 30may04 DS");
if (m_Disposed)
{
Debug.WriteLine("before throw new ObjectDisposedException. 30may04 DS");
throw new ObjectDisposedException(this.GetType().FullName);
}
Debug.WriteLine("Stop entry. m_Status = " + m_Status.ToString() + " 30may04 DS");
//new 30may04 DS testing as part of debugging
m_Status = MediaStatus.Stopped;
//
if (m_Status == MediaStatus.Stopped)
{
Debug.WriteLine("Stop exit. 30may04 DS");
return;
}
m_Stopping = 1;
//
//
//The following line(s) are causing an exception 30may04 DS
//It happens upon any ref to m_Output or Output from this point -- even in the WriteLine statement!
//
Debug.WriteLine("before waveOutReset(m_Output=" + m_Output.ToString() + ") 30may04 DS");
//waveOutReset(Output);
waveOutReset(m_Output);//testing 30may04 DS
Debug.WriteLine("after waveOutReset. 30may04 DS");
for (int i = 0; i < m_Header.Length; i++)
{
Debug.WriteLine("30may04 DS. calling waveOutUnprepareHeader(... m_Header[" + i.ToString() + "])");
waveOutUnprepareHeader(Output, ref m_Header[i], Marshal.SizeOf(m_Header[i]));
}
Debug.WriteLine("before calling waveOutClose 30may04 DS.");
waveOutClose(Output);
Debug.WriteLine("after calling waveOutClose 30may04 DS.");
Position = 0;
m_Status = MediaStatus.Stopped;
Debug.WriteLine("Stop exit. 30may04 DS");
} |