{fViablePin =
fViablePin ||
IsEqualGUIDAligned(m_Descriptor.pInterfaces[i].Set, KSINTERFACESETID_Standard) &&
(m_Descriptor.pInterfaces[i].Id == KSINTERFACE_STANDARD_STREAMING) ;}
if (!fViablePin)
{DebugPrintf(TRACE_ERROR, TEXT("No standard streaming interfaces on the pin"));
hr = E_FAIL;}}
// Make sure at least one medium is standard streaming
if (SUCCEEDED(hr))
{fViablePin = FALSE;
for(ULONG i = 0; i < m_Descriptor.cInterfaces && !fViablePin; i++)
{fViablePin =
fViablePin ||
IsEqualGUIDAligned(m_Descriptor.pMediums[i].Set, KSMEDIUMSETID_Standard) &&
(m_Descriptor.pMediums[i].Id == KSMEDIUM_STANDARD_DEVIO) ;}
if (!fViablePin)
{DebugPrintf(TRACE_ERROR, TEXT("No standard streaming mediums on the pin"));
hr = E_FAIL;}}
// Make sure at least one datarange supports audio
if (SUCCEEDED(hr))
{fViablePin = FALSE;
PKSDATARANGE pDataRange = m_Descriptor.pDataRanges;
for(ULONG i = 0; i < m_Descriptor.cDataRanges; i++)
{fViablePin = fViablePin ||
IsEqualGUIDAligned(pDataRange->SubFormat, KSDATAFORMAT_SUBTYPE_MIDI) ||
IsEqualGUIDAligned(pDataRange->SubFormat, KSDATAFORMAT_SUBTYPE_WILDCARD);
if (fViablePin && IsEqualGUIDAligned(pDataRange->MajorFormat, KSDATAFORMAT_TYPE_MUSIC))
{// Copy the data range into the pin
PKSDATARANGE_MUSIC pCopyDataRangeAudio = new KSDATARANGE_MUSIC;
if( pCopyDataRangeAudio )
{PKSDATARANGE_MUSIC pDataRangeAudio = (PKSDATARANGE_MUSIC)pDataRange;
CopyMemory( pCopyDataRangeAudio, pDataRangeAudio, sizeof(KSDATARANGE_MUSIC) );
if (NULL == m_listDataRange.AddTail( pCopyDataRangeAudio ))
{delete pCopyDataRangeAudio;
pCopyDataRangeAudio = NULL;
DebugPrintf(TRACE_ERROR, TEXT("Unable to allocate list entry to save datarange in"));
hr = E_OUTOFMEMORY;}}
else
{DebugPrintf(TRACE_ERROR, TEXT("Unable to allocate memory to save datarange in"));
hr = E_OUTOFMEMORY;}}
pDataRange = (PKSDATARANGE)( ((PBYTE)pDataRange) + pDataRange->FormatSize);}
if (!fViablePin)
{DebugPrintf(TRACE_ERROR, TEXT("No audio dataranges on the pin"));
hr = E_FAIL;}}
TRACE_LEAVE_HRESULT(hr);
return hr;}
Что заменить:
CKsAudPin::~CKsAudPin(void)
{TRACE_ENTER();
KSDATARANGE_AUDIO *pKSDATARANGE_AUDIO;
CKsNode *pKsNode;
// Clear datarange list
while( m_listDataRange.RemoveHead(&pKSDATARANGE_AUDIO) )
{delete pKSDATARANGE_AUDIO;}
// Clear the node list
while( m_listNodes.RemoveHead(&pKsNode) )
{delete pKsNode;}
delete[] (BYTE *)m_pWaveFormatEx;
TRACE_LEAVE();
return;}
Заменить на:
CKsAudPin::~CKsAudPin(void)
{TRACE_ENTER();
KSDATARANGE_MUSIC * pKSDATARANGE_MUSIC;
CKsNode * pKsNode;
// Clear datarange list
while(m_listDataRange.RemoveHead(&pKSDATARANGE_MUSIC))
{delete pKSDATARANGE_MUSIC;}
// Clear the node list
while(m_listNodes.RemoveHead(&pKsNode))
{delete pKsNode;}
TRACE_LEAVE();
return;}
Что заменить:
CKsAudPin::CKsAudPin
(CKsAudFilter* pFilter,
ULONG nId,
HRESULT* phr
) : CKsPin(pFilter, nId, phr),
m_pAudFilter(pFilter),
m_pWaveFormatEx(NULL),
m_pksDataFormatWfx(NULL)
{TRACE_ENTER();
HRESULT hr = *phr;
if (SUCCEEDED(hr))
{hr = m_listDataRange.Initialize(1);
if (FAILED(hr))
DebugPrintf(TRACE_ERROR,TEXT("Failed to Initialize m_listDataRange"));}
if (SUCCEEDED(hr))
{hr = m_listNodes.Initialize(1);
if (FAILED(hr))
DebugPrintf(TRACE_ERROR,TEXT("Failed to Initialize m_listNodes"));}
// create a KSPIN_CONNECT structure to describe a waveformatex pin
if (SUCCEEDED(hr))
{m_cbPinCreateSize = sizeof(KSPIN_CONNECT) + sizeof(KSDATAFORMAT_WAVEFORMATEX);
m_pksPinCreate = (PKSPIN_CONNECT)new BYTE[m_cbPinCreateSize];
if (!m_pksPinCreate)
{DebugPrintf(TRACE_ERROR,TEXT("Failed to allocate m_pksPinCreate"));
hr = E_OUTOFMEMORY;}}
if (SUCCEEDED(hr))
{m_pksPinCreate->Interface.Set = KSINTERFACESETID_Standard;
m_pksPinCreate->Interface.Id = KSINTERFACE_STANDARD_STREAMING;
m_pksPinCreate->Interface.Flags = 0;
m_pksPinCreate->Medium.Set = KSMEDIUMSETID_Standard;
m_pksPinCreate->Medium.Id = KSMEDIUM_TYPE_ANYINSTANCE;
m_pksPinCreate->Medium.Flags = 0;
m_pksPinCreate->PinId = nId;
m_pksPinCreate->PinToHandle = NULL;
m_pksPinCreate->Priority.PriorityClass = KSPRIORITY_NORMAL;
m_pksPinCreate->Priority.PrioritySubClass = 1;
// point m_pksDataFormatWfx to just after the pConnect struct
PKSDATAFORMAT_WAVEFORMATEX pksDataFormatWfx = (PKSDATAFORMAT_WAVEFORMATEX)(m_pksPinCreate + 1);
// set up format for KSDATAFORMAT_WAVEFORMATEX
pksDataFormatWfx->DataFormat.FormatSize = sizeof(KSDATAFORMAT_WAVEFORMATEX);
pksDataFormatWfx->DataFormat.Flags = 0;
pksDataFormatWfx->DataFormat.Reserved = 0;
pksDataFormatWfx->DataFormat.MajorFormat = KSDATAFORMAT_TYPE_AUDIO;
pksDataFormatWfx->DataFormat.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
pksDataFormatWfx->DataFormat.Specifier = KSDATAFORMAT_SPECIFIER_WAVEFORMATEX;
m_pksDataFormatWfx = pksDataFormatWfx;}
// Initialize the Pin;
if (SUCCEEDED(hr))
{hr = CKsAudPin::Init();}
TRACE_LEAVE_HRESULT(hr);
*phr = hr;
return;}
Заменить на:
CKsAudPin::CKsAudPin
(CKsAudFilter* pFilter,
ULONG nId,
HRESULT* phr
) : CKsPin(pFilter, nId, phr),
m_pAudFilter(pFilter),
m_pksDataFormat(NULL)
{TRACE_ENTER();
HRESULT hr = *phr;
if (SUCCEEDED(hr))
{hr = m_listDataRange.Initialize(1);
if (FAILED(hr))
DebugPrintf(TRACE_ERROR,TEXT("Failed to Initialize m_listDataRange"));}
if (SUCCEEDED(hr))
{hr = m_listNodes.Initialize(1);
if (FAILED(hr))
DebugPrintf(TRACE_ERROR,TEXT("Failed to Initialize m_listNodes"));}
// create a KSPIN_CONNECT structure to describe a waveformatex pin
if (SUCCEEDED(hr))
{m_cbPinCreateSize = sizeof(KSPIN_CONNECT) + sizeof(KSDATAFORMAT);
m_pksPinCreate = (PKSPIN_CONNECT)new BYTE[m_cbPinCreateSize];
if (!m_pksPinCreate)
{DebugPrintf(TRACE_ERROR,TEXT("Failed to allocate m_pksPinCreate"));
hr = E_OUTOFMEMORY;}}
if (SUCCEEDED(hr))
{m_pksPinCreate->Interface.Set = KSINTERFACESETID_Standard;
m_pksPinCreate->Interface.Id = KSINTERFACE_STANDARD_STREAMING;
m_pksPinCreate->Interface.Flags = 0;
m_pksPinCreate->Medium.Set = KSMEDIUMSETID_Standard;
m_pksPinCreate->Medium.Id = KSMEDIUM_TYPE_ANYINSTANCE;
m_pksPinCreate->Medium.Flags = 0;
m_pksPinCreate->PinId = nId;
m_pksPinCreate->PinToHandle = NULL;
m_pksPinCreate->Priority.PriorityClass = KSPRIORITY_NORMAL;
m_pksPinCreate->Priority.PrioritySubClass = 1;
// point m_pksDataFormat to just after the pConnect struct
PKSDATAFORMAT pksDataFormat = (PKSDATAFORMAT)(m_pksPinCreate + 1);
// set up format for KSDATAFORMAT
pksDataFormat->FormatSize = sizeof(KSDATAFORMAT);
pksDataFormat->Flags = 0;
pksDataFormat->SampleSize = 0;
pksDataFormat->Reserved = 0;
pksDataFormat->MajorFormat = KSDATAFORMAT_TYPE_MUSIC;
pksDataFormat->SubFormat = KSDATAFORMAT_SUBTYPE_MIDI;
pksDataFormat->Specifier = KSDATAFORMAT_SPECIFIER_NONE;
m_pksDataFormat = pksDataFormat;}
// Initialize the Pin;
if (SUCCEEDED(hr))
{hr = CKsAudPin::Init();}
TRACE_LEAVE_HRESULT(hr);
*phr = hr;
return;}
В файле audpin.h
Что заменить:
TList<KSDATARANGE_AUDIO> m_listDataRange;
Заменить на:
TList<KSDATARANGE_MUSIC> m_listDataRange;
Что заменить:
BOOL IsFormatSupported(const WAVEFORMATEX* pwfx);
Заменить на:
BOOL IsFormatSupported();
Что заменить:
KSDATAFORMAT_WAVEFORMATEX* m_pksDataFormatWfx;
Заменить на:
KSDATAFORMAT * m_pksDataFormat;