| 446 | ///////////////////////////////////////////////////////////////////////// |
| 447 | |
| 448 | HRESULT WmfMediaEngine::Invoke(IMFAsyncResult* pResult) |
| 449 | { |
| 450 | HRESULT hr = S_OK; |
| 451 | ::MediaEventType meType = MEUnknown; // Event type |
| 452 | |
| 453 | TComPtr<IMFMediaEvent> pEvent; |
| 454 | |
| 455 | // Get the event from the event queue. |
| 456 | CHECK_HR(hr = m_pSession->EndGetEvent(pResult, &pEvent)); |
| 457 | |
| 458 | // Get the event type. |
| 459 | CHECK_HR(hr = pEvent->GetType(&meType)); |
| 460 | |
| 461 | // If the session is closed, the application is waiting on the |
| 462 | // m_hCloseEvent event handle. Also, do not get any more |
| 463 | // events from the session. |
| 464 | |
| 465 | if (meType == MESessionClosed) |
| 466 | { |
| 467 | SetEvent(m_hCloseEvent); |
| 468 | } |
| 469 | else |
| 470 | { |
| 471 | // For all other events, ask the media session for the |
| 472 | // next event in the queue. |
| 473 | CHECK_HR(hr = m_pSession->BeginGetEvent(this, NULL)); |
| 474 | } |
| 475 | |
| 476 | // For most events, we post the event as a private window message to the |
| 477 | // application. This lets the application process the event on it's |
| 478 | // main thread. |
| 479 | |
| 480 | // However, if call to IMFMediaSession::Close is pending, it means the |
| 481 | // application is waiting on the m_hCloseEvent event handle. (Blocking |
| 482 | // call.) In that case, we simply discard the event. |
| 483 | |
| 484 | // NOTE: When IMFMediaSession::Close is called, MESessionClosed is NOT |
| 485 | // necessarily the next event that we will receive. We may receive |
| 486 | // any number of other events before receiving MESessionClosed. |
| 487 | if (!m_bClosePending) |
| 488 | { |
| 489 | HandleEvent(pEvent.Get()); |
| 490 | |
| 491 | // if (!m_hwndEvent) |
| 492 | // HandleEvent((WPARAM)pEvent.Get()); |
| 493 | // else |
| 494 | // PostMessage(m_hwndEvent, WM_APP_PLAYER_EVENT, (WPARAM)pEvent.Get(), (LPARAM)0); |
| 495 | } |
| 496 | |
| 497 | done: |
| 498 | // SAFE_RELEASE(pEvent); |
| 499 | return S_OK; |
| 500 | } |
| 501 | |
| 502 | void WmfMediaEngine::HandleVideoSample(const uint8_t* buf, size_t len) |
| 503 | { |