TCC89播放代码与 LOG 对应
阅读与测试 Telechips 平台下音频播放 Filter,同时对比 WinCE 下标准的 Overlay 音频播放过程。了解音频播放过程,记录如下:
(1)
1 CheckCoCreateInstance(hr, CLSID_FilterGraph, IID_IGraphBuilder, (void **)&mpGraph, TEXT("CLSID_FilterGraph fail")); 2 原型: BOOL CFilterControl::CheckCoCreateInstance(HRESULT &hr, REFCLSID rclsid, REFIID riid, LPVOID* ppv, LPCTSTR pszErrorMessage) 3 调用 CoCreateInstance 的代码 : hr = ::CoCreateInstance(rclsid, NULL, CLSCTX_INPROC_SERVER, riid, ppv);
加载模块: quartz.dll 加载模块: mmtimer.dll 加载模块: waveapic.dll
(2)
1 hr = CoCreateInstance((REFCLSID)CLSID_AudioRender, NULL, CLSCTX_INPROC, (REFIID)IID_IBaseFilter, (void **)&m_pAudioRenderFilter); 2 hr = mpGraph->AddFilter(m_pAudioRenderFilter,L"Audio Renderer"); 3 4 hr = mpGraph->AddFilter(m_pAudioOutputControlFilter,L"TCC Audio Output Control Filter");
加载模块: TCCAudioOutputControlFilter.dll
对应实现: TWS893x_200\Filters\TCCAudioOutputControlFilter\TCCAudioOutputControlFilter.cpp
1 CFactoryTemplate g_Templates[] = 2 { 3 { 4 L"TCC Audio Output Control Filter", 5 &CLSID_TCCAudioOutputControlFilter, 6 CAudioOutputControlFilter::CreateInstance, // Create a new instance of this class 7 NULL, 8 &sudTCCAudioOutputControlFilter 9 }, 10 };
(3)
1 hr = CoCreateInstance((REFCLSID)CLSID_TCCDEQ, NULL, CLSCTX_INPROC, (REFIID)IID_IBaseFilter, (void **)&m_pDEQFilter); 2 // DEQ Filter Add 3 if(SUCCEEDED(hr)) 4 hr = mpGraph->AddFilter(m_pDEQFilter,L"TCC DEQ Filter");
加载模块: TCCDEQFilter.dll
(4)
1 hr = mpGraph->RenderFile(FileName,NULL);
加载模块: TCCCDKAudioDecFilter.dll 加载模块: TCCCDKDemuxFilter.dll
[ CDK DEMUX ] Audio Demuxer is MP3 ======================================================== [ CDK DEMUX ]Start Time : 1999-10-29 07:21:08 [ CDK DEMUX ]Demux Type : AUDIO(8) [ CDK DEMUX ]Video Width : 0 [ CDK DEMUX ]Video Height : 0 [ CDK DEMUX ]Video Frame Rate : 0.00 [ CDK DEMUX ]Video BitRate : Unknown [ CDK DEMUX ]Extra Data Length : 0 [ CDK DEMUX ]Seekable : Seekable [ CDK DEMUX ]AspectRatio : 4 x 3 -------------------------------------------------------- [ CDK DEMUX ]Audio Track Num : 1 [0]Audio nFormatId : MP3(0x55) [0]Avg Bytes Per Sec : 16000 [0]Bits Per Sample : 16 [0]Block Align : 0 [0]nChannels : 2 [0]SamplePerSec : 44100 [0]nExtraDataLength : 0 -------------------------------------------------------- [ CDK DEMUX ]Total Subtitle Num : 0 [ CDK DEMUX ]Current Subtitle Num : 0 ======================================================== [ CDK AUDIO ][CCDKAudioDecFilter::CheckInputType,1180] AUDIO_ID_MP3 -------------------------------------------------------- [ CDK DEMUX ]Audio Stream ID : Audio0 [ CDK DEMUX ]Audio Ouptut Buffer Num : 128 [ CDK DEMUX ]Audio Ouptut 1 Buffer Size : 32[Kbytes] [ CDK DEMUX ]Audio Ouptut Buffer total Size : 4[Mbytes] -------------------------------------------------------- -------------------------------------------------------- [ CDK AUDIO ]Audio Ouptut Buffer Num : 16 [ CDK AUDIO ]Audio Ouptut 1 Buffer Size : 512[Kbytes] [ CDK AUDIO ]Audio Ouptut Buffer total Size : 8[Mbytes] -------------------------------------------------------- -------------------------------------------------------- [ CDK AUDIO ]Audio Ouptut Buffer Num : 16 [ CDK AUDIO ]Audio Ouptut 1 Buffer Size : 512[Kbytes] [ CDK AUDIO ]Audio Ouptut Buffer total Size : 8[Mbytes] --------------------------------------------------------
(5)
1 HRESULT hr = mpGraph->QueryInterface(IID_IMediaControl, (void **)&p_mc); 2 if (hr == S_OK) 3 { 4 hr = p_mc->Run(); 5 mIsRunning = TRUE; 6 if (FAILED(hr)) 7 printf("Fail : RunGraph(ret=0x%x)\r\n", hr); // Leo 失败后 mIsRunning 的值? 8 SAFE_RELEASE(p_mc); 9 }
[ CDK DEMUX ]CDK Audio DMX Seek Time : 0 ======================================================== [ CDK DEMUX ]Seek Position : 0(00:00:00) [ CDK DEMUX ]Real Position : 0(00:00:00) [ CDK DEMUX ]Seek duration : 3[ms] ========================================================
1 // + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2 // + + 微软标准 DirectShow 播放音频 3 IGraphBuilder *m_pGB; 4 IMediaControl *m_pMC; 5 IMediaEventEx *m_pME; 6 IBasicAudio *m_pBA; 7 IMediaSeeking *m_pMS; 8 9 // Initialize COM 10 if(CoInitializeEx(NULL,COINIT_MULTITHREADED) != S_OK) 11 { 12 goto END; 13 } 14 15 // Get the interface for DirectShow's GraphBuilder 16 if(CoCreateInstance(CLSID_FilterGraph,NULL,CLSCTX_INPROC_SERVER,IID_IGraphBuilder,(void **)&m_pGB) != S_OK) 17 { 18 goto END; 19 } 20 21 // Have the graph construct its the appropriate graph automatically 22 if(m_pGB->RenderFile(m_szFileName, NULL) != NOERROR) 23 { 24 goto END; 25 } 26 27 // QueryInterface for DirectShow interfaces 28 if(m_pGB->QueryInterface(IID_IMediaControl, (void **)&m_pMC) != NOERROR) 29 { 30 goto END; 31 } 32 if(m_pGB->QueryInterface(IID_IMediaEventEx, (void **)&m_pME) != NOERROR) 33 { 34 goto END; 35 } 36 if(m_pGB->QueryInterface(IID_IMediaSeeking, (void **)&m_pMS) != NOERROR) 37 { 38 goto END; 39 } 40 41 // Query for audio interfaces, which may not be relevant for video-only files 42 if(m_pGB->QueryInterface(IID_IBasicAudio, (void **)&m_pBA) != NOERROR) 43 { 44 goto END; 45 }