// Called when the presentation clock restarts from the same position while paused.
HRESULT STDMETHODCALLTYPE EVRCustomPresenter::OnClockRestart(MFTIME hnsSystemTime)
{
  Log("EVRCustomPresenter::OnClockRestart");

  HRESULT hr = S_OK;

  CAutoLock lock(this);

  // We cannot restart the clock after shutdown.
  hr = CheckShutdown();
  CHECK_HR(hr, "EVRCustomPresenter::OnClockRestart cannot restart after shutdown");

  // The EVR calls OnClockRestart only while paused.
  assert(m_RenderState == RENDER_STATE_PAUSED);
  m_RenderState = RENDER_STATE_STARTED;

  // Possibly we are in the middle of frame-stepping OR we have samples waiting in the frame-step queue. 
  hr = StartFrameStep();
  CHECK_HR(hr, "EVRCustomPresenter::OnClockRestart EVRCustomPresenter::StartFrameStep() failed")

    // Now resume the presentation loop.
    ProcessOutputLoop();

  return hr;
}
Esempio n. 2
0
// Gets ready to frame step.
HRESULT EVRCustomPresenter::PrepareFrameStep(DWORD cSteps)
{
  HRESULT hr = S_OK;

  // Cache the step count.
  m_FrameStep.steps += cSteps;

  // Set the frame-step state. 
  m_FrameStep.state = FRAMESTEP_WAITING_START;

  // If the clock is are already running, we can start frame-stepping now. Otherwise, we will start when the clock starts.
  if (m_RenderState == RENDER_STATE_STARTED)
  {
    hr = StartFrameStep();       
  }

  return hr;
}
// Called when the presentation clock starts.
HRESULT STDMETHODCALLTYPE EVRCustomPresenter::OnClockStart(MFTIME hnsSystemTime, LONGLONG llClockStartOffset)
{
  Log("EVRCustomPresenter::OnClockStart (offset = %I64d)", llClockStartOffset);

  HRESULT hr = S_OK;

  CAutoLock lock(this);

  // We cannot start after shutdown
  hr = CheckShutdown();
  CHECK_HR(hr, "EVRCustomPresenter::OnClockRestart cannot start after shutdown");

  // Check if the clock is already active (not stopped). 
  if (IsActive())
  {
    m_RenderState = RENDER_STATE_STARTED;

    // If the clock position changes while the clock is active, it is a seek request. We need to flush all pending samples.
    if (llClockStartOffset != PRESENTATION_CURRENT_POSITION)
    {
      Flush();
    }
  }
  else
  {
    // The clock has started from the stopped state. 
    m_RenderState = RENDER_STATE_STARTED;

    // Possibly we are in the middle of frame-stepping or have samples waiting in the frame-step queue.
    hr = StartFrameStep();
    CHECK_HR(hr, "EVRCustomPresenter::OnClockRestart EVRCustomPresenter::StartFrameStep() failed");
  }

  // Now try to get new output samples from the mixer.
  ProcessOutputLoop();

  return hr;
}