19,468
社区成员
发帖
与我相关
我的任务
分享
lDataLen = 230400; //你这完全是强暴,把人家的内存大小进行修改,但是人家的实际内存大小并没有任何改变
HRESULT CBallStream::FillBuffer(IMediaSample *pms)
{
BYTE *pData;
long lDataLen;
pms->GetPointer(&pData);
lDataLen = pms->GetSize();
if( m_bZeroMemory ) {
ZeroMemory( pData, lDataLen ); //已经对Sample的内存清为黑色
}
#if 1
BYTE *pTmpData;
pTmpData = new BYTE[230400]; //你这是自己分配的内存,而不是sample的,sample有自己的内存指针,pData
memset(pTmpData, 0x80, 230400); //把你自己的内存填充
pData = pTmpData; //把sample的内存指针指向你自己的内存,但是sample的内存并没有更改和释放,里面还是全是零
lDataLen = 230400; //你这完全是强暴,把人家的内存大小进行修改,但是人家的实际内存大小并没有任何改变
........
#endif
#if 1
delete [] pTmpData; //把你的内存释放,但是sample真正的内存并没任何改变
pTmpData = NULL;
#endif
return NOERROR;
} // FillBuffer
HRESULT CBallStream::FillBuffer(IMediaSample *pms)
{
BYTE *pData;
long lDataLen;
pms->GetPointer(&pData);
lDataLen = pms->GetSize();
// If true then we clear the output buffer and don't attempt to
// erase a previous drawing of the ball - this will be the case
// when we start running as the buffer will be full of rubbish
if( m_bZeroMemory ) {
ZeroMemory( pData, lDataLen );
}
#if 1
FillMemory(pData,0x80,lDataLen);//就这一句就可以
// The current time is the sample's start
CRefTime rtStart = m_rtSampleTime;
// Increment to find the finish time
m_rtSampleTime += (LONG)m_iRepeatTime;
pms->SetTime((REFERENCE_TIME *) &rtStart,(REFERENCE_TIME *) &m_rtSampleTime);
#endif
m_bZeroMemory = FALSE;
pms->SetSyncPoint(TRUE);
return NOERROR;
} // FillBuffer