The reason for hardcoding the media type is that then I can prototype
the graph connection in graphedit without implementing a property page
for the filter.
If I try PCM audio I can make the filter connect.
I use the following code in GetMediaType:
static ADPCMCOEFSET MSADPCM_CoeffSet[] =
{
{256, 0}, {512, -256}, {0, 0}, {192, 64}, {240, 0}, {460, -208},
{392, -232}
};
HRESULT MyOutputPin::GetMediaType(int iPosition, CMediaType *pmt)
{
CAutoLock cAutoLock(m_pFilter->pStateLock());
if(iPosition == 0)
{
ADPCMWAVEFORMAT* adpcm = (ADPCMWAVEFORMAT*)pmt->AllocFormatBuffer
(50);
WAVEFORMATEX* pwfex = &(adpcm->wfx);
pwfex->wFormatTag = WAVE_FORMAT_ADPCM;
pwfex->nChannels = 2;
pwfex->nSamplesPerSec = 44100;
pwfex->wBitsPerSample = 8;
pwfex->nBlockAlign = (WORD)((pwfex->wBitsPerSample * pwfex-
>nChannels) / 8);
pwfex->nAvgBytesPerSec = pwfex->nBlockAlign * pwfex->nSamplesPerSec;
pwfex->cbSize = 32;
adpcm->wSamplesPerBlock = 2048;
adpcm->wNumCoef = 7;
memcpy(adpcm->aCoef, MSADPCM_CoeffSet, 14);
return CreateAudioMediaType(pwfex, pmt, FALSE);
}
return VFW_S_NO_MORE_ITEMS;
}
The DirectShow "synth" sample can output ADPCM but I don't manage to
make that code work in my output pin.
When I do "render pin" in graphedit I get the "no such interface"
error message. The error occurs here:
amfilter.cpp:1784
if (hr == NOERROR) {
m_Connected = pReceivePin;
m_Connected->AddRef();
hr = SetMediaType(pmt);
if (SUCCEEDED(hr)) {
// Here I get the error
hr = pReceivePin->ReceiveConnection((IPin *)this, pmt);
...