Errata

Developing Microsoft Media Foundation Applications

Errata for Developing Microsoft Media Foundation Applications

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
PDF Page 38
Code Listing

There seems to be two bugs here that casues the CloseSession method to never shut down an open session properly:

1. The CloseSession method stays in the critical section while waiting for the session to close. The Invoke method (page 33) then tries to enter the same critical section on another thread when the MESessionClosed event arrives, which causes a deadlock.

2. If you remove the deadlock, the CloseSession method has set m_state to PlayerState_Closing, which causes the Invoke-method (page 33) to not process the MESessionClosed event, so the m_closeCompleteEvent is never set.

Both of the above issues causes the WaitForSingleObject to always time out and CloseSession to return E_UNEXPECTED without calling m_pSession->Shutdown().

Magnus Larsson  May 13, 2013 
Printed Page 109
Source code

I don't understand code after else if statement.

else if(dwTypeIndex == 0)
{
// return the set output type
*ppType = m_pOutputType.Detach();
}

Why m_pOutputType detached, so internal pointer in m_pOutputType is set to NULL ? Shouldn't code call AddRef() to increase counter and assign m_pOutputType to ppType instead ?

Similar method GetOutputAvailableType() contains following code.

if (m_pInputType == NULL)
{
hr = GetSupportedMediaType(dwTypeIndex, &pmt);
BREAK_ON_FAIL(hr);

// return the resulting media type
*ppType = pmt;
(*ppType)->AddRef();
}
else
{
*ppType = m_pInputType;
(*ppType)->AddRef();
}

Here, I don't understand why AddRef() is called for pmt. Is it necessary to call AddRef() for COM object that was created in GetSupportedMediaType(). Shouldn't Detach() be called instead ?

Thanks in advance for clarification.

Timmy_A  Jan 29, 2012 
Printed Page 133
Code Comment at Top

In the code comments, the last sentence reads:

"Therefore set the chroma only if the x and y coordinates of the pixel are not divisible by 2."

Followed by the code:

"if(x%2 == 0 && y%2 == 0){ ... }"

The comment contradicts the code.

This typo is later made evident by the second paragraph below the code; specifically the last line:

"In other words, the chroma values are set only when x and y...are cleanly divisible by 2"

Andrew Johnson  Aug 15, 2013 
Printed Page 184
5th Item in List

The author attributed the function "DispatchSamples()" to the wrong class. He incorrectly wrote "AVFSource::DispatchSamples()" when he meant to write "AVFStream::DispatchSamples()"

This is made evident on page 186, where he lists the code itself.

Andrew Johnson  Aug 31, 2013 
Printed Page 340
Source Code

The following code snippet is a typo:

CComPtr<IAsyncState> pResult;
CComQIPtr<IAsyncState1> pResult1;

do {
hr = pResult1.CoCreateInstance(...)
pResult1 = pResult;
...
}

I believe the author intended to write:

pResult.CoCreateInstance(..)

instead of:

pResult1.CoCreateInstance(...)

This is evidenced by the second sentence in the paragraph immediately following the source code:

"The CComPtr::CoCreateInstance() method..."

But the author is instead calling CComQIPtr::CoCreateInstanceMethod()

Andrew Johnson  Jun 23, 2013