Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

210 lines
7.7 KiB

  1. //------------------------------------------------------------------------------
  2. // File: DXMPerf.h
  3. //
  4. // Desc: Macros for DirectShow performance logging.
  5. //
  6. //@@BEGIN_MSINTERNAL
  7. //
  8. // 2.0 15-NOV-1999 clorton Added support for WMI logging.
  9. // 2.1 25-JAN-2000 clorton Added dynamic loading of WMI logging
  10. // functions.
  11. // 25-OCT-2000 arthurz Cleanup.
  12. //@@END_MSINTERNAL
  13. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
  14. //------------------------------------------------------------------------------
  15. #ifndef _DXMPERF_H_
  16. #define _DXMPERF_H_
  17. #include <perfstruct.h>
  18. #include "perflog.h"
  19. #ifdef _IA64_
  20. extern "C" unsigned __int64 __getReg( int whichReg );
  21. #pragma intrinsic(__getReg)
  22. #endif // _IA64_
  23. inline ULONGLONG _RDTSC( void ) {
  24. #ifdef _X86_
  25. LARGE_INTEGER li;
  26. __asm {
  27. _emit 0x0F
  28. _emit 0x31
  29. mov li.LowPart,eax
  30. mov li.HighPart,edx
  31. }
  32. return li.QuadPart;
  33. #if 0 // This isn't tested yet
  34. #elif defined (_IA64_)
  35. #define INL_REGID_APITC 3116
  36. return __getReg( INL_REGID_APITC );
  37. #endif // 0
  38. #else // unsupported platform
  39. // not implemented on non x86/IA64 platforms
  40. return 0;
  41. #endif // _X86_/_IA64_
  42. }
  43. #define DXMPERF_VIDEOREND 0x00000001
  44. #define DXMPERF_AUDIOGLITCH 0x00000002
  45. //#define GETTIME_BIT 0x00000001
  46. //#define AUDIOREND_BIT 0x00000004
  47. //#define FRAMEDROP_BIT 0x00000008
  48. #define AUDIOBREAK_BIT 0x00000010
  49. #define PERFLOG_CTOR( name, iface )
  50. #define PERFLOG_DTOR( name, iface )
  51. #define PERFLOG_DELIVER( name, source, dest, sample, pmt )
  52. #define PERFLOG_RECEIVE( name, source, dest, sample, pmt )
  53. #define PERFLOG_RUN( name, iface, time, oldstate )
  54. #define PERFLOG_PAUSE( name, iface, oldstate )
  55. #define PERFLOG_STOP( name, iface, oldstate )
  56. #define PERFLOG_JOINGRAPH( name, iface, graph )
  57. #define PERFLOG_GETBUFFER( allocator, sample )
  58. #define PERFLOG_RELBUFFER( allocator, sample )
  59. #define PERFLOG_CONNECT( connector, connectee, status, pmt )
  60. #define PERFLOG_RXCONNECT( connector, connectee, status, pmt )
  61. #define PERFLOG_DISCONNECT( disconnector, disconnectee, status )
  62. #define PERFLOG_GETTIME( clock, time ) /*{ \
  63. PERFINFO_WMI_GETTIME perfData; \
  64. if (NULL != g_pTraceEvent) { \
  65. memset( &perfData, 0, sizeof( perfData ) ); \
  66. perfData.header.Size = sizeof( perfData ); \
  67. perfData.header.Flags = WNODE_FLAG_TRACED_GUID; \
  68. perfData.header.Guid = GUID_GETTIME; \
  69. perfData.data.cycleCounter = _RDTSC(); \
  70. perfData.data.dshowClock = (ULONGLONG) (time); \
  71. if (g_perfMasks[GETTIME_INDEX] & GETTIME_BIT) \
  72. (*g_pTraceEvent)( g_traceHandle, (PEVENT_TRACE_HEADER) &perfData ); \
  73. } \
  74. }*/
  75. #define PERFLOG_AUDIOREND( clocktime, sampletime, psample, bytetime, cbytes ) /*{ \
  76. PERFINFO_WMI_AVREND perfData; \
  77. if (NULL != g_pTraceEvent) { \
  78. memset( &perfData, 0, sizeof( perfData ) ); \
  79. perfData.header.Size = sizeof( perfData ); \
  80. perfData.header.Flags = WNODE_FLAG_TRACED_GUID; \
  81. perfData.header.Guid = GUID_AUDIOREND; \
  82. perfData.data.cycleCounter = _RDTSC(); \
  83. perfData.data.dshowClock = (clocktime); \
  84. perfData.data.sampleTime = (sampletime); \
  85. if (g_perfMasks[AUDIOREND_INDEX] & AUDIOREND_BIT) \
  86. (*g_pTraceEvent)( g_traceHandle, (PEVENT_TRACE_HEADER) &perfData ); \
  87. } \
  88. }*/
  89. #define PERFLOG_VIDEOREND( sampletime, clocktime, psample ) \
  90. if (PerflogEnableFlags & DXMPERF_VIDEOREND) { \
  91. PERFINFO_WMI_AVREND perfData; \
  92. memset( &perfData, 0, sizeof( perfData ) ); \
  93. perfData.header.Size = sizeof( perfData ); \
  94. perfData.header.Flags = WNODE_FLAG_TRACED_GUID; \
  95. perfData.header.Guid = GUID_VIDEOREND; \
  96. perfData.data.cycleCounter = _RDTSC(); \
  97. perfData.data.dshowClock = (clocktime); \
  98. perfData.data.sampleTime = (sampletime); \
  99. PerflogTraceEvent ((PEVENT_TRACE_HEADER) &perfData); \
  100. }
  101. #define PERFLOG_AUDIOGLITCH( instance, glitchtype, currenttime, previoustime ) \
  102. if (PerflogEnableFlags & DXMPERF_AUDIOGLITCH) { \
  103. PERFINFO_WMI_AUDIOGLITCH perfData; \
  104. memset( &perfData, 0, sizeof( perfData ) ); \
  105. perfData.header.Size = sizeof( perfData ); \
  106. perfData.header.Flags = WNODE_FLAG_TRACED_GUID; \
  107. perfData.header.Guid = GUID_DSOUNDGLITCH; \
  108. perfData.data.cycleCounter = _RDTSC(); \
  109. perfData.data.glitchType = (glitchtype); \
  110. perfData.data.sampleTime = (currenttime); \
  111. perfData.data.previousTime = (previoustime); \
  112. perfData.data.instanceId = (instance); \
  113. PerflogTraceEvent ((PEVENT_TRACE_HEADER) &perfData); \
  114. }
  115. #define PERFLOG_FRAMEDROP( sampletime, clocktime, psample, renderer ) /*{ \
  116. PERFINFO_WMI_FRAMEDROP perfData; \
  117. if (NULL != g_pTraceEvent) { \
  118. memset( &perfData, 0, sizeof( perfData ) ); \
  119. perfData.header.Size = sizeof( perfData ); \
  120. perfData.header.Flags = WNODE_FLAG_TRACED_GUID; \
  121. perfData.header.Guid = GUID_FRAMEDROP; \
  122. perfData.data.cycleCounter = _RDTSC(); \
  123. perfData.data.dshowClock = (clocktime); \
  124. perfData.data.frameTime = (sampletime); \
  125. if (g_perfMasks[FRAMEDROP_INDEX] & FRAMEDROP_BIT) \
  126. (*g_pTraceEvent)( g_traceHandle, (PEVENT_TRACE_HEADER) &perfData ); \
  127. } \
  128. }*/
  129. /*
  130. #define PERFLOG_AUDIOBREAK( nextwrite, writepos, msecs ) { \
  131. PERFINFO_WMI_AUDIOBREAK perfData; \
  132. if (NULL != g_pTraceEvent) { \
  133. memset( &perfData, 0, sizeof( perfData ) ); \
  134. perfData.header.Size = sizeof( perfData ); \
  135. perfData.header.Flags = WNODE_FLAG_TRACED_GUID; \
  136. perfData.header.Guid = GUID_AUDIOBREAK; \
  137. perfData.data.cycleCounter = _RDTSC(); \
  138. perfData.data.dshowClock = (writepos); \
  139. perfData.data.sampleTime = (nextwrite); \
  140. perfData.data.sampleDuration = (msecs); \
  141. if (g_perfMasks[AUDIOBREAK_INDEX] & AUDIOBREAK_BIT) \
  142. (*g_pTraceEvent)( g_traceHandle, (PEVENT_TRACE_HEADER) &perfData ); \
  143. } \
  144. }
  145. */
  146. #define PERFLOG_AUDIOBREAK( nextwrite, writepos, msecs ) \
  147. if (PerflogEnableFlags & AUDIOBREAK_BIT) { \
  148. PERFINFO_WMI_AUDIOBREAK perfData; \
  149. memset( &perfData, 0, sizeof( perfData ) ); \
  150. perfData.header.Size = sizeof( perfData ); \
  151. perfData.header.Flags = WNODE_FLAG_TRACED_GUID; \
  152. perfData.header.Guid = GUID_AUDIOBREAK; \
  153. perfData.data.cycleCounter = _RDTSC(); \
  154. perfData.data.dshowClock = (writepos); \
  155. perfData.data.sampleTime = (nextwrite); \
  156. perfData.data.sampleDuration = (msecs); \
  157. PerflogTraceEvent ((PEVENT_TRACE_HEADER) &perfData); \
  158. } \
  159. inline
  160. VOID PERFLOG_STREAMTRACE(
  161. ULONG Level,
  162. ULONG Id,
  163. ULONGLONG DShowClock,
  164. ULONGLONG Data1,
  165. ULONGLONG Data2,
  166. ULONGLONG Data3,
  167. ULONGLONG Data4
  168. )
  169. {
  170. if (Level <= PerflogModuleLevel)
  171. {
  172. PERFINFO_WMI_STREAMTRACE perfData;
  173. memset( &perfData, 0, sizeof( perfData ) );
  174. perfData.header.Size = sizeof( perfData );
  175. perfData.header.Flags = WNODE_FLAG_TRACED_GUID;
  176. perfData.header.Guid = GUID_STREAMTRACE;
  177. perfData.data.dshowClock = DShowClock;
  178. perfData.data.id = Id;
  179. perfData.data.data[0] = Data1;
  180. perfData.data.data[1] = Data2;
  181. perfData.data.data[2] = Data3;
  182. perfData.data.data[3] = Data4;
  183. PerflogTraceEvent((PEVENT_TRACE_HEADER) &perfData);
  184. }
  185. }
  186. #endif // _DXMPERF_H_