Exemplo n.º 1
0
        /// <summary>
        /// Waits for the specified event.
        /// </summary>
        /// <param name="desiredEventCode">event code to wait for</param>
        /// <param name="msTimeout">timeout</param>
        /// <param name="actuallyReceivedEventCode">The event actually received, or "0" if no event was received</param>
        /// <param name="param">1st parameter associated with event</param>
        /// <returns>True if the desired event was received. False if timed out, or different event received</returns>
        public bool WaitForEvent(EventCode desiredEventCode, int msTimeout, out EventCode actuallyReceivedEventCode, out int param)
        {
            bool restartTimer = false;

            if (_mediaSeekTimer.Enabled)
            {
                _mediaSeekTimer.Stop();
                restartTimer = true;
            }

            int    hr = 0;
            IntPtr lparam1, lparam2;

            hr = _mediaEvent.GetEvent(out actuallyReceivedEventCode, out lparam1, out lparam2, msTimeout);
            if (DsError.Succeeded(hr))
            {
                Debug.WriteLine("WaitForEvent got " + actuallyReceivedEventCode.ToString() + " 0x" + lparam1.ToString("X") + " 0x" + lparam2.ToString("X"));
                param = lparam1.ToInt32();
                _mediaEvent.FreeEventParams(actuallyReceivedEventCode, lparam1, lparam2);
            }
            else
            {
                actuallyReceivedEventCode = 0;
                param = 0;
            }

            if (restartTimer)
            {
                _mediaSeekTimer.Start();
            }

            return(DsError.Succeeded(hr) && (actuallyReceivedEventCode == desiredEventCode));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Wait X milliseconds for the graph to receive the EC_COMPLETE
 /// </summary>
 /// <param name="msTimeout">number of milliseconds to timeout before returning, or -1 for INFINITE</param>
 /// <returns>
 /// Complete - Operation completed.
 /// ErrorAbort - Error. Playback cannot continue.
 /// UserAbort - User terminated the operation.
 /// Unbuilt - Cannot execute this method
 /// 0 - graph is still running
 /// </returns>
 public EventCode WaitForCompletion(int msTimeout)
 {
     if (_mediaEvent != null)
     {
         EventCode e;
         int       hr = _mediaEvent.WaitForCompletion(msTimeout, out e);
         if (DsError.Succeeded(hr))
         {
             return(e);
         }
         else
         {
             return(0);
         }
     }
     return(EventCode.Unbuilt);
 }