DirectShow IGraphBuilder Render error 0x80040218 (VFW_E_CANNOT_RENDER)

1

I have the following problem:

On Windows 7, I try loading the contents of an *.mp3 file in memory and then play it using IGraphBuilder. This works well if I don't have certain applications running. If, however, I have BSPlayer open with an *.avi file or a game open, IGraphBuilder won't render the *.mp3 memory anymore. This does not happen if I have Winamp running, though.

I don't understand why this is happening, I'm suspecting that the input pins for DirectShow are all used? But when I run GraphEdt or similar applications together, they all work (play *.avi files or *.mp3 files in parallel), so there must be something I'm doing wrong in my program. Could you please help me out?

I have two classes: CMemStream and CMemReader, based on MS Windows 7.1 SDK's samples.

class CMemReader: public CAsyncReader

CMemReader doesn't do much, it just initializes the base class CAsyncReader.

class CMemStream: public CAsyncStream

CMemStream implements the SetPointer, Read, Size, Alignment, Lock, Unlock methods.

Here's the code (simplified):

IGraphBuilder *m_pGraphBuilder;
CMemStream *m_pMemStream;
CMemReader *m_pMemReader;

BYTE *m_pMemData = new BYTE[lSize];
// ... Fill in m_pMemData with the contents of an *.mp3 file
// lSize is the size of the file

m_pMemStream = new CMemStream(m_pMemData, lSize);

CMediaType mediaType;
mediaType.majortype = MEDIATYPE_Stream;
mediaType.subtype = MEDIASUBTYPE_MPEG1Audio;

HRESULT hResult;
m_pMemReader = new CMemReader(m_pMemStream, &mediaType, &hResult);

CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void**)&m_pGraphBuilder);

m_pGraphBuilder->AddFilter(m_pMemReader, NULL);
m_pMemReader->AddRef();
m_pGraphBuilder->Render(m_pMemReader->GetPin(0)); // THIS IS WHERE IT FAILS!
// The error is 0x80040218 (VFW_E_CANNOT_RENDER): No combination of filters could be found to render the stream.

I've also tried connecting the pins together, like so:

IBaseFilter *pFilter;
CoCreateInstance(CLSID_DSoundRender, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&pFilter);

m_pGraphBuilder->AddFilter(pFilter, NULL);

IEnumPins *pEnumPins;
IPin *pPin;
pFilter->EnumPins(&pEnumPins);
pEnumPins->Next(1, &pPin, 0);

m_pGraphBuilder->Connect(m_pMemReader->GetPin(0), pPin); // THIS IS WHERE IT ALSO FAILS!
// The error is 0x80040217 (VFW_E_CANNOT_CONNECT): No combination of intermediate filters could be found to make the connection.

I've also tried different combinations for the type and subtype of CMediaType, but none work.

If you have any idea or suggestion, if you could spot a problem, please let me know. Thank you!

c++
directshow
asked on Stack Overflow Apr 25, 2015 by ShereKhan

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0