Changeset 839 for trunk


Ignore:
Timestamp:
Mar 30, 2018, 10:19:28 AM (6 years ago)
Author:
roman
Message:
 
Location:
trunk/DirectShowSpy
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/DirectShowSpy/DirectShowSpy.vcxproj

    r831 r839  
    160160      <PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    161161      <MinimalRebuild>true</MinimalRebuild>
    162       <ExceptionHandling>Async</ExceptionHandling>
    163162      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
    164163      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
     
    206205      <PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    207206      <MinimalRebuild>true</MinimalRebuild>
    208       <ExceptionHandling>Async</ExceptionHandling>
    209207      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
    210208      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
     
    259257      <PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    260258      <StringPooling>true</StringPooling>
    261       <ExceptionHandling>Async</ExceptionHandling>
    262259      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
    263260      <PrecompiledHeader>Use</PrecompiledHeader>
     
    313310      <PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    314311      <StringPooling>true</StringPooling>
    315       <ExceptionHandling>Async</ExceptionHandling>
    316312      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
    317313      <PrecompiledHeader>Use</PrecompiledHeader>
     
    368364      <PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;_USRDLL;_TRACE=1;_TRACELEVEL=4;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    369365      <StringPooling>true</StringPooling>
    370       <ExceptionHandling>Async</ExceptionHandling>
    371366      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
    372367      <PrecompiledHeader>Use</PrecompiledHeader>
     
    422417      <PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;_USRDLL;_TRACE=1;_TRACELEVEL=4;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    423418      <StringPooling>true</StringPooling>
    424       <ExceptionHandling>Async</ExceptionHandling>
    425419      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
    426420      <PrecompiledHeader>Use</PrecompiledHeader>
  • trunk/DirectShowSpy/FilterGraphSpy.h

    r831 r839  
    638638        CComPtr<IUnknown> m_pSite;
    639639        CStringW m_sFriendlyName;
     640
     641        static VOID TraceProcessPerformance(LPCTSTR pszDescription = NULL, BOOL bForce = FALSE)
     642        {
     643                pszDescription;
     644                #if _DEVELOPMENT || _TRACE
     645                        const ULONG nTime = GetTickCount();
     646                        MEMORYSTATUSEX MemoryStatus = { sizeof MemoryStatus };
     647                        const BOOL bGlobalMemoryStatusExResult = GlobalMemoryStatusEx(&MemoryStatus);
     648                        PROCESS_MEMORY_COUNTERS_EX Counters = { sizeof Counters };
     649                        const BOOL bGetProcessMemoryInfoResult = GetProcessMemoryInfo(GetCurrentProcess(), (PROCESS_MEMORY_COUNTERS*) &Counters, sizeof Counters);
     650                        _A(bGlobalMemoryStatusExResult && bGetProcessMemoryInfoResult);
     651                        BOOL bReportGlobalMemoryStatusEx = FALSE, bReportGetProcessMemoryInfo = FALSE;
     652                        #pragma region Reduce Similar Traces
     653                        {
     654                                _A(_pAtlModule);
     655                                CComCritSecLock<CComCriticalSection> Lock(_pAtlModule->m_csStaticDataInitAndTypeInfo);
     656                                static ULONG g_nReportTime = 0;
     657                                static MEMORYSTATUSEX g_MemoryStatus;
     658                                static PROCESS_MEMORY_COUNTERS_EX g_Counters;
     659                                #if !defined(_DEBUG)
     660                                        if(bForce || !g_nReportTime || nTime - g_nReportTime >= 15 * 1000) // 15 seconds
     661                                        {
     662                                                bReportGlobalMemoryStatusEx = bGlobalMemoryStatusExResult;
     663                                                bReportGetProcessMemoryInfo = bGetProcessMemoryInfoResult;
     664                                        } else
     665                                        {
     666                                                #pragma region MEMORYSTATUSEX
     667                                                if(fabs(((DOUBLE) MemoryStatus.dwMemoryLoad - g_MemoryStatus.dwMemoryLoad) / ((MemoryStatus.dwMemoryLoad + g_MemoryStatus.dwMemoryLoad) / 2)) > 0.05) // 5%
     668                                                        bReportGlobalMemoryStatusEx = TRUE;
     669                                                else
     670                                                if(fabs(((DOUBLE) MemoryStatus.ullAvailVirtual - g_MemoryStatus.ullAvailVirtual) / ((MemoryStatus.ullAvailVirtual + g_MemoryStatus.ullAvailVirtual) / 2)) > 0.05) // 5%
     671                                                        bReportGlobalMemoryStatusEx = TRUE;
     672                                                #pragma endregion
     673                                                #pragma region PROCESS_MEMORY_COUNTERS_EX
     674                                                if(fabs(((DOUBLE) Counters.WorkingSetSize - g_Counters.WorkingSetSize) / ((Counters.WorkingSetSize + g_Counters.WorkingSetSize) / 2)) > 0.05) // 5%
     675                                                        bReportGetProcessMemoryInfo = TRUE;
     676                                                else
     677                                                if(fabs(((DOUBLE) Counters.PrivateUsage - g_Counters.PrivateUsage) / ((Counters.PrivateUsage + g_Counters.PrivateUsage) / 2)) > 0.05) // 5%
     678                                                        bReportGetProcessMemoryInfo = TRUE;
     679                                                #pragma endregion
     680                                        }
     681                                #else
     682                                        bReportGlobalMemoryStatusEx = bGlobalMemoryStatusExResult;
     683                                        bReportGetProcessMemoryInfo = bGetProcessMemoryInfoResult;
     684                                #endif // !defined(_DEBUG)
     685                                if(bReportGlobalMemoryStatusEx)
     686                                        g_MemoryStatus = MemoryStatus;
     687                                if(bReportGetProcessMemoryInfo)
     688                                        g_Counters = Counters;
     689                                if(bReportGlobalMemoryStatusEx || bReportGetProcessMemoryInfo)
     690                                        g_nReportTime = nTime;
     691                        }
     692                        #pragma endregion
     693                        CString sDescription = pszDescription;
     694                        if(!sDescription.IsEmpty())
     695                                sDescription.Append(_T(": "));
     696                        if(bReportGlobalMemoryStatusEx)
     697                        {
     698                                _Z2(atlTraceGeneral, 2, _T("%s") _T("Memory Status, ")
     699                                        _T("dwMemoryLoad %d") _T(", ")
     700                                        _T("ullTotalVirtual %s MB") _T(", ")
     701                                        _T("ullAvailVirtual %s MB (in use %s MB)") //_T(", ")
     702                                        _T("\n"),
     703                                        sDescription,
     704                                        MemoryStatus.dwMemoryLoad,
     705                                        _StringHelper::FormatNumber((LONGLONG) MemoryStatus.ullTotalVirtual >> 20),
     706                                        _StringHelper::FormatNumber((LONGLONG) MemoryStatus.ullAvailVirtual >> 20), _StringHelper::FormatNumber((LONGLONG) (MemoryStatus.ullTotalVirtual - MemoryStatus.ullAvailVirtual) >> 20),
     707                                        0);
     708                        }
     709                        if(bReportGetProcessMemoryInfo)
     710                        {
     711                                _Z2(atlTraceGeneral, 2, _T("%s") _T("Process Performance, ")
     712                                        _T("WorkingSetSize %s MB (peak %s MB)") _T(", ")
     713                                        _T("PrivateUsage %s MB") //_T(", ")
     714                                        _T("\n"),
     715                                        sDescription,
     716                                        _StringHelper::FormatNumber((LONGLONG) Counters.WorkingSetSize >> 20), _StringHelper::FormatNumber((LONGLONG) Counters.PeakWorkingSetSize >> 20),
     717                                        _StringHelper::FormatNumber((LONGLONG) Counters.PrivateUsage >> 20),
     718                                        0);
     719                        }
     720                #endif // _DEVELOPMENT || _TRACE
     721        }
    640722
    641723        BOOL IsAggregated() const
     
    11671249                return S_OK;
    11681250        }
     1251        STDMETHOD(CreateFilterGraphHelper)(IFilterGraphHelper** ppFilterGraphHelper) override
     1252        {
     1253                _Z4(atlTraceCOM, 4, _T("this 0x%p\n"), this);
     1254                _ATLTRY
     1255                {
     1256                        __D(ppFilterGraphHelper, E_POINTER);
     1257                        *ppFilterGraphHelper = NULL;
     1258                        CObjectPtr<CFilterGraphHelper> pFilterGraphHelper;
     1259                        pFilterGraphHelper.Construct()->SetFilterGraph(this);
     1260                        *ppFilterGraphHelper = pFilterGraphHelper.Detach();
     1261                }
     1262                _ATLCATCHALL()
     1263                {
     1264                        _Z_EXCEPTION();
     1265                }
     1266                return S_OK;
     1267        }
    11691268
    11701269// ISpyEx
     
    14021501                        OnRun(pT, &bDefault);
    14031502                HOOK_EPILOG()
     1503                TraceProcessPerformance(_T("Before IMediaControl::Run"));
    14041504                const HRESULT nRunResult = m_pInnerMediaControl->Run();
    14051505                _Z4_DSHRESULT(nRunResult);
     1506                TraceProcessPerformance(_T("After IMediaControl::Run"));
    14061507                return nRunResult;
    14071508        }
     
    14221523                        OnPause(pT, &bDefault);
    14231524                HOOK_EPILOG()
    1424                 return m_pInnerMediaControl->Pause();
     1525                TraceProcessPerformance(_T("Before IMediaControl::Pause"));
     1526                const HRESULT nPauseResult = m_pInnerMediaControl->Pause();
     1527                _Z4_DSHRESULT(nPauseResult);
     1528                TraceProcessPerformance(_T("After IMediaControl::Pause"));
     1529                return nPauseResult;
    14251530        }
    14261531        STDMETHOD(Stop)() override
     
    14301535                        OnStop(pT, &bDefault);
    14311536                HOOK_EPILOG()
    1432                 return m_pInnerMediaControl->Stop();
     1537                TraceProcessPerformance(_T("Before IMediaControl::Stop"));
     1538                const HRESULT nStopResult = m_pInnerMediaControl->Stop();
     1539                _Z4_DSHRESULT(nStopResult);
     1540                TraceProcessPerformance(_T("After IMediaControl::Stop"));
     1541                return nStopResult;
    14331542        }
    14341543        STDMETHOD(GetState)(LONG nTimeout, OAFilterState* pState) override
     
    15161625                        if(nEventCode == EC_ERRORABORTEX && nParameter2)
    15171626                                _Z4(atlTraceGeneral, 4, _T("nParameter2 \"%s\"\n"), CString((BSTR) nParameter2));
     1627                        TraceProcessPerformance(_FilterGraphHelper::FormatEventCode(nEventCode), TRUE);
    15181628                        static CConstIntegerRegistryValue g_nErrorAbortMiniDumpMode(_T("ErrorAbort MiniDump Mode")); // 0 Default (=1), 1 Disabled, 2 Enabled
    15191629                        if((DWORD) g_nErrorAbortMiniDumpMode == 2) // Enabled
  • trunk/DirectShowSpy/Module.idl

    r617 r839  
    6464                HRESULT RegisterComment([in] IUnknown* pBaseFilterUnknown, [in] const WCHAR* pszStreamName, [in] const WCHAR* pszComment, [in] USHORT nHighlight);
    6565        };
     66        interface IFilterGraphHelper;
    6667        [
    6768                object,
     
    8586                [id(8)] HRESULT ReadRunPropertyBag([in] IUnknown* pBaseFilterUnknown, [in] VARIANT_BOOL bAllowExtension, [out, retval] VARIANT* pvValue);
    8687                [id(9)] HRESULT CreateMediaSampleTrace([out, retval] IMediaSampleTrace** ppMediaSampleTrace);
     88                [id(10)] HRESULT CreateFilterGraphHelper([out, retval] IFilterGraphHelper** ppFilterGraphHelper);
    8789        };
    8890        [
  • trunk/DirectShowSpy/Module.ini

    r833 r839  
    44;Language=133 ;MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)
    55;Version String Format=%d.%d.%d.%d
    6 Current Build Number=2134
     6Current Build Number=2138
Note: See TracChangeset for help on using the changeset viewer.