|
void Mp3Player::Play()
{
CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC, IID_IGraphBuilder, (void **)&m_pGraph);
m_pGraph->QueryInterface(IID_IMediaControl, (void **)&m_pMediaControl);
m_pGraph->QueryInterface(IID_IMediaEventEx, (void **)&m_pIMediaEvent);
m_pGraph->RenderFile(fileName, NULL);
m_pIMediaEvent->WaitForCompletion(INFINITE,&evCode);
// 播放完毕,释放资源
m_pMediaControl->Stop();
SAFERELEASE(m_pGraph)
SAFERELEASE(m_pMediaControl)
SAFERELEASE(m_pIMediaEvent)
}
如上代码,初始化com库是在另外地方(构造函数里面),卸载则是在析构函数里。现在多次调用play方法,有很严重的内存泄露。用测试用例测试的时候,每调用一百次,内存减少几十到100多K。求ds方面的高人指点,万分感谢,分不多,这是全部分了,如果能解决问题,以后一定送分
|
|