//------------------------------------------------------------------- // Name: Shutdown // Description: Shuts down the stream sink. //------------------------------------------------------------------- public void Shutdown() { int hr; Debug.Assert(!m_IsShutdown); GC.SuppressFinalize(this); if (m_pEventQueue != null) { hr = m_pEventQueue.Shutdown(); MFError.ThrowExceptionForHR(hr); } hr = MFExtern.MFUnlockWorkQueue(m_WorkQueueId); MFError.ThrowExceptionForHR(hr); m_SampleQueue.Clear(); SafeRelease(m_pSink); SafeRelease(m_pEventQueue); SafeRelease(m_pByteStream); SafeRelease(m_pCurrentType); SafeRelease(m_pFinalizeResult); m_pSink = null; m_pEventQueue = null; m_pByteStream = null; m_pCurrentType = null; m_pFinalizeResult = null; m_IsShutdown = true; }
int m_WorkQueueId; // ID of the work queue for asynchronous operations. #endregion Fields #region Constructors public CWavStream(CWavSink pParent, IMFByteStream pByteStream) { int hr; TRACE("CWavStream::CWavStream"); m_SampleQueue = new Queue(); m_state = State.TypeNotSet; m_IsShutdown = false; m_pSink = null; m_pEventQueue = null; m_pByteStream = null; m_pCurrentType = null; m_pFinalizeResult = null; m_StartTime = 0; m_cbDataWritten = 0; m_WorkQueueId = 0; Debug.Assert(pParent != null); Debug.Assert(pByteStream != null); MFByteStreamCapabilities dwCaps = MFByteStreamCapabilities.None; const MFByteStreamCapabilities dwRequiredCaps = (MFByteStreamCapabilities.IsWritable | MFByteStreamCapabilities.IsSeekable); // Make sure the byte stream has the necessary caps bits. hr = pByteStream.GetCapabilities(out dwCaps); MFError.ThrowExceptionForHR(hr); if ((dwCaps & dwRequiredCaps) != dwRequiredCaps) { throw new COMException("stream doesn't have required caps", E_Fail); } // Move the file pointer to leave room for the RIFF headers. hr = pByteStream.SetCurrentPosition(Marshal.SizeOf(typeof(WAV_FILE_HEADER))); MFError.ThrowExceptionForHR(hr); // Create the event queue helper. hr = MFExternAlt.MFCreateEventQueue(out m_pEventQueue); MFError.ThrowExceptionForHR(hr); // Allocate a new work queue for async operations. hr = MFExtern.MFAllocateWorkQueue(out m_WorkQueueId); MFError.ThrowExceptionForHR(hr); m_pByteStream = pByteStream; m_pSink = pParent; }
public void Dispose() { TRACE("CWavStream::Dispose"); SafeRelease(m_pEventQueue); SafeRelease(m_pByteStream); SafeRelease(m_pCurrentType); SafeRelease(m_pFinalizeResult); m_pEventQueue = null; m_pByteStream = null; m_pCurrentType = null; m_pFinalizeResult = null; //m_pSink.Dispose(); // break deadly embrace m_pSink = null; GC.SuppressFinalize(this); }