Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise METranformDrainComplete event in CHWMFT::OnDrain #227

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 36 additions & 7 deletions Samples/MediaFoundationTransformDecoder/cpp/CHWMFT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,15 +489,46 @@ HRESULT CHWMFT::OnDrain(
const UINT32 un32StreamID)
{
HRESULT hr = S_OK;

TraceString(CHMFTTracing::TRACE_INFORMATION, L"%S(): Enter", __FUNCTION__);

do
{
CAutoLock lock(&m_csLock);

m_dwStatus |= (MYMFT_STATUS_DRAINING);

if (m_pOutputSampleQueue->IsQueueEmpty())
{
IMFMediaEvent* pDrainCompleteEvent = NULL;
hr = MFCreateMediaEvent(METransformDrainComplete, GUID_NULL, S_OK, NULL, &pDrainCompleteEvent);
if (FAILED(hr))
{
break;
}
/*******************************
** Todo: This MFT only has one
** input stream, so the drain
** is always on stream zero.
** Update this is your MFT
** has more than one stream
*******************************/
hr = pDrainCompleteEvent->SetUINT32(MF_EVENT_MFT_INPUT_STREAM_ID, 0);
if (FAILED(hr))
{
break;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should also be another SAFERELEASE(pDrainCompleteEvent); if this SetUINT32 method fails to prevent a memory leak

}
/***************************************
** Since this in an internal function
** we know m_pEventQueue can never be
** NULL due to InitializeTransform()
***************************************/
hr = m_pEventQueue->QueueEvent(pDrainCompleteEvent);
SAFERELEASE(pDrainCompleteEvent);
if (FAILED(hr))
{
break;
}
}
else
{
m_dwStatus |= (MYMFT_STATUS_DRAINING);
}
/*******************************
** Todo: This MFT only has one
** input stream, so it does not
Expand All @@ -507,9 +538,7 @@ HRESULT CHWMFT::OnDrain(
** have to change this logic
*******************************/
}while(false);

TraceString(CHMFTTracing::TRACE_INFORMATION, L"%S(): Exit(hr=0x%x)", __FUNCTION__, hr);

return hr;
}

Expand Down