directshow的音频采集的问题
下面的代码是我照着书上抄的,为什么没有在D盘生成a.wav文件
程序能弹出okokokok,为什么没有生成一个文件
IBaseFilter *pSrc=NULL,*pWavDest=NULL,*pWriter=NULL;
IFileSinkFilter *pSink=NULL;
IGraphBuilder * pGraph2;
HRESULT hr=CoCreateInstance(CLSID_FilterGraph,NULL,CLSCTX_INPROC_SERVER,
IID_IGraphBuilder,(void**)&pGraph2);
int n=m_audio_c.GetCurSel();
CString afn;
m_audio_c.GetLBText(n,afn);
char *aFriendlyName=(LPSTR)(LPCTSTR)afn;
pSrc=GetAudioInputFilter(aFriendlyName);
if(!pSrc)
{
MessageBox("没有发现音频采集设备");
}
else
{
hr=pGraph2->AddFilter(pSrc,L"Audio Capture Filter");
if(FAILED(hr))
{
MessageBox("音频设备初始化失败");
}
}
hr=AddFilterByCLSID(pGraph2,CLSID_WavDest,L"WavDest",
&pWavDest);
if(SUCCEEDED(hr))
{
hr=AddFilterByCLSID(pGraph2,CLSID_FileWriter,L"File Writer",&pWriter);
if(SUCCEEDED(hr))
{
pWriter->QueryInterface(IID_IFileSinkFilter,(void**)&pSink);
hr=pSink->SetFileName(L"d:\\a.wav",NULL);
if(SUCCEEDED(hr))
MessageBox("filename ok");
else
MessageBox("filename no");
IPin *pOut;
hr=GetUnconnectedPin(pSrc,PINDIR_OUTPUT,&pOut);
if(SUCCEEDED(hr))
{
IPin *pIn;
hr=GetUnconnectedPin(pWavDest,PINDIR_INPUT,&pIn);
if(SUCCEEDED(hr))
{
hr=pGraph2->Connect(pOut,pIn);
if(SUCCEEDED(hr))
{
IPin *pOut2;
hr=GetUnconnectedPin(pWavDest,PINDIR_OUTPUT,&pOut2);
if(SUCCEEDED(hr))
{
IPin *pIn2;
hr=GetUnconnectedPin(pWriter,PINDIR_INPUT,&pIn2);
if(SUCCEEDED(hr))
{
hr=pGraph2->Connect(pOut2,pIn2);
if(SUCCEEDED(hr))
{
MessageBox("okokokok");
}
else
MessageBox("no");
}
}
}
}
}
}
pSink->Release();
pWriter->Release();
}
else
MessageBox("no");
pSrc->Release();
pGraph2->Release();