我在用VC++编写 windows media player 的 plug in
run 这个 code 的时候
有一个 错误不知道怎么解决
error 是 local function definitions are illegal
下面是 我编写的code
错误指向
error C2601: 'CEcho::ValidateMediaType' : local function definitions are illegal c:\documents and settings\--\my documents\visual studio 2005\projects\echo\echo\echo.cpp 1166
/////////////////////////////////////////////////////////////////////////////
// CEcho::ValidateMediaType
//
// Validate that the media type is acceptable
/////////////////////////////////////////////////////////////////////////////
HRESULT CEcho::ValidateMediaType(const DMO_MEDIA_TYPE *pmtTarget, const DMO_MEDIA_TYPE *pmtPartner)
{
// make sure the target media type has the fields we require
if( ( MEDIATYPE_Audio != pmtTarget->majortype ) ||
( FORMAT_WaveFormatEx != pmtTarget->formattype ) ||
( pmtTarget->cbFormat < sizeof( WAVEFORMATEX )) ||
( NULL == pmtTarget->pbFormat) )
{
return DMO_E_TYPE_NOT_ACCEPTED;
}
// make sure the wave header has the fields we require
WAVEFORMATEX *pWave = (WAVEFORMATEX *) pmtTarget->pbFormat;
if ((0 == pWave->nChannels) ||
(0 == pWave->nSamplesPerSec) ||
(0 == pWave->nAvgBytesPerSec) ||
(0 == pWave->nBlockAlign) ||
(0 == pWave->wBitsPerSample))
{
return DMO_E_TYPE_NOT_ACCEPTED;
}
// make sure this is a supported container size
if ((8 != pWave->wBitsPerSample) &&
(16 != pWave->wBitsPerSample))
{
return DMO_E_TYPE_NOT_ACCEPTED;
}
// make sure the wave format is acceptable
switch (pWave->wFormatTag)
{
case WAVE_FORMAT_PCM:
// make sure sample size is 8 or 16-bit
if ((8 != pWave->wBitsPerSample) &&
(16 != pWave->wBitsPerSample))
{
return DMO_E_TYPE_NOT_ACCEPTED;
}
break;
case WAVE_FORMAT_IEEE_FLOAT:
// make sure the input is sane
if (32 != pWave->wBitsPerSample)
{
return DMO_E_TYPE_NOT_ACCEPTED;
}
break;
case WAVE_FORMAT_EXTENSIBLE:
{
// Sample size is greater than 16-bit or is multichannel.
WAVEFORMATEXTENSIBLE *pWaveXT = (WAVEFORMATEXTENSIBLE *) pWave;
if (KSDATAFORMAT_SUBTYPE_PCM != pWaveXT->SubFormat)
{
return DMO_E_TYPE_NOT_ACCEPTED;
}
}
break;
default:
return DMO_E_TYPE_NOT_ACCEPTED;
break;
}
// if the partner media type is configured, make sure it matches the target.
// this is done because this plug-in requires the same input and output types
if (GUID_NULL != pmtPartner->majortype)
{
if ((pmtTarget->majortype != pmtPartner->majortype) ||
(pmtTarget->subtype != pmtPartner->subtype))
{
return DMO_E_TYPE_NOT_ACCEPTED;
}
// make sure the wave headers for the target and the partner match
WAVEFORMATEX *pPartnerWave = (WAVEFORMATEX *) pmtPartner->pbFormat;
if ((pWave->nChannels != pPartnerWave->nChannels) ||
(pWave->nSamplesPerSec != pPartnerWave->nSamplesPerSec) ||
(pWave->nAvgBytesPerSec != pPartnerWave->nAvgBytesPerSec) ||
(pWave->nBlockAlign != pPartnerWave->nBlockAlign) ||
(pWave->wBitsPerSample != pPartnerWave->wBitsPerSample) ||
(pWave->wFormatTag != pPartnerWave->wFormatTag))
{
return DMO_E_TYPE_NOT_ACCEPTED;
}
// make sure the waveformatextensible types are the same
if (pWave->wFormatTag == WAVE_FORMAT_EXTENSIBLE)
{
WAVEFORMATEXTENSIBLE *pWaveXT = (WAVEFORMATEXTENSIBLE *) pWave;
WAVEFORMATEXTENSIBLE *pPartnerWaveXT = (WAVEFORMATEXTENSIBLE *) pPartnerWave;
if (pWaveXT->SubFormat != pPartnerWaveXT->SubFormat)
{
return DMO_E_TYPE_NOT_ACCEPTED;
}
}
}
// media type is valid
return S_OK;
}
[此贴子已经被作者于2007-5-8 9:37:35编辑过]