dxmperf.h 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. //------------------------------------------------------------------------------
  2. // File: DXMPerf.h
  3. //
  4. // Desc: Macros for DirectShow performance logging.
  5. //
  6. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
  7. //------------------------------------------------------------------------------
  8. #ifndef _DXMPERF_H_
  9. #define _DXMPERF_H_
  10. #include <perfstruct.h>
  11. #include "perflog.h"
  12. #ifdef _IA64_
  13. extern "C" unsigned __int64 __getReg( int whichReg );
  14. #pragma intrinsic(__getReg)
  15. #endif // _IA64_
  16. inline ULONGLONG _RDTSC( void )
  17. {
  18. #ifdef _X86_
  19. LARGE_INTEGER li;
  20. __asm {
  21. _emit 0x0F
  22. _emit 0x31
  23. mov li.LowPart,eax
  24. mov li.HighPart,edx
  25. }
  26. return li.QuadPart;
  27. #if 0 // This isn't tested yet
  28. #elif defined (_IA64_)
  29. #define INL_REGID_APITC 3116
  30. return __getReg( INL_REGID_APITC );
  31. #endif // 0
  32. #else // unsupported platform
  33. // not implemented on non x86/IA64 platforms
  34. return 0;
  35. #endif // _X86_/_IA64_
  36. }
  37. #define DXMPERF_VIDEOREND 0x00000001
  38. #define DXMPERF_AUDIOGLITCH 0x00000002
  39. //#define GETTIME_BIT 0x00000001
  40. //#define AUDIOREND_BIT 0x00000004
  41. //#define FRAMEDROP_BIT 0x00000008
  42. #define AUDIOBREAK_BIT 0x00000010
  43. #define DXMPERF_AUDIORECV 0x00000020
  44. #define DXMPERF_AUDIOSLAVE 0x00000040
  45. #define DXMPERF_AUDIOBREAK 0x00000080
  46. #define PERFLOG_CTOR( name, iface )
  47. #define PERFLOG_DTOR( name, iface )
  48. #define PERFLOG_DELIVER( name, source, dest, sample, pmt )
  49. #define PERFLOG_RECEIVE( name, source, dest, sample, pmt )
  50. #define PERFLOG_RUN( name, iface, time, oldstate )
  51. #define PERFLOG_PAUSE( name, iface, oldstate )
  52. #define PERFLOG_STOP( name, iface, oldstate )
  53. #define PERFLOG_JOINGRAPH( name, iface, graph )
  54. #define PERFLOG_GETBUFFER( allocator, sample )
  55. #define PERFLOG_RELBUFFER( allocator, sample )
  56. #define PERFLOG_CONNECT( connector, connectee, status, pmt )
  57. #define PERFLOG_RXCONNECT( connector, connectee, status, pmt )
  58. #define PERFLOG_DISCONNECT( disconnector, disconnectee, status )
  59. #define PERFLOG_GETTIME( clock, time ) /*{ \
  60. PERFINFO_WMI_GETTIME perfData; \
  61. if (NULL != g_pTraceEvent) { \
  62. memset( &perfData, 0, sizeof( perfData ) ); \
  63. perfData.header.Size = sizeof( perfData ); \
  64. perfData.header.Flags = WNODE_FLAG_TRACED_GUID; \
  65. perfData.header.Guid = GUID_GETTIME; \
  66. perfData.data.cycleCounter = _RDTSC(); \
  67. perfData.data.dshowClock = (ULONGLONG) (time); \
  68. if (g_perfMasks[GETTIME_INDEX] & GETTIME_BIT) \
  69. (*g_pTraceEvent)( g_traceHandle, (PEVENT_TRACE_HEADER) &perfData ); \
  70. } \
  71. }*/
  72. #define PERFLOG_AUDIOREND( clocktime, sampletime, psample, bytetime, cbytes ) /*{ \
  73. PERFINFO_WMI_AVREND perfData; \
  74. if (NULL != g_pTraceEvent) { \
  75. memset( &perfData, 0, sizeof( perfData ) ); \
  76. perfData.header.Size = sizeof( perfData ); \
  77. perfData.header.Flags = WNODE_FLAG_TRACED_GUID; \
  78. perfData.header.Guid = GUID_AUDIOREND; \
  79. perfData.data.cycleCounter = _RDTSC(); \
  80. perfData.data.dshowClock = (clocktime); \
  81. perfData.data.sampleTime = (sampletime); \
  82. if (g_perfMasks[AUDIOREND_INDEX] & AUDIOREND_BIT) \
  83. (*g_pTraceEvent)( g_traceHandle, (PEVENT_TRACE_HEADER) &perfData ); \
  84. } \
  85. }*/
  86. #define PERFLOG_AUDIORECV(StreamTime,SampleStart,SampleStop,Discontinuity,Duration) \
  87. if (PerflogEnableFlags & DXMPERF_AUDIORECV) { \
  88. PERFINFO_WMI_AUDIORECV perfData; \
  89. memset( &perfData, 0, sizeof( perfData ) ); \
  90. perfData.header.Size = sizeof( perfData ); \
  91. perfData.header.Flags = WNODE_FLAG_TRACED_GUID; \
  92. perfData.header.Guid = GUID_AUDIORECV; \
  93. perfData.data.streamTime = StreamTime; \
  94. perfData.data.sampleStart = SampleStart; \
  95. perfData.data.sampleStop = SampleStop; \
  96. perfData.data.discontinuity = Discontinuity; \
  97. perfData.data.hwduration = Duration; \
  98. PerflogTraceEvent((PEVENT_TRACE_HEADER) &perfData); \
  99. }
  100. #define PERFLOG_AUDIOSLAVE(MasterClock,SlaveClock,ErrorAccum,LastHighErrorSeen,LastLowErrorSeen) \
  101. if (PerflogEnableFlags & DXMPERF_AUDIOSLAVE) { \
  102. PERFINFO_WMI_AUDIOSLAVE perfData; \
  103. memset( &perfData, 0, sizeof( perfData ) ); \
  104. perfData.header.Size = sizeof( perfData ); \
  105. perfData.header.Flags = WNODE_FLAG_TRACED_GUID; \
  106. perfData.header.Guid = GUID_AUDIOSLAVE; \
  107. perfData.data.masterClock = MasterClock; \
  108. perfData.data.slaveClock = SlaveClock; \
  109. perfData.data.errorAccum = ErrorAccum; \
  110. perfData.data.lastHighErrorSeen = LastHighErrorSeen;\
  111. perfData.data.lastLowErrorSeen = LastLowErrorSeen; \
  112. PerflogTraceEvent((PEVENT_TRACE_HEADER) &perfData); \
  113. }
  114. #define PERFLOG_AUDIOADDBREAK(IterNextWrite,OffsetNextWrite,IterWrite,OffsetWrite) \
  115. if (PerflogEnableFlags & DXMPERF_AUDIOBREAK) { \
  116. PERFINFO_WMI_AUDIOADDBREAK perfData; \
  117. memset( &perfData, 0, sizeof( perfData ) ); \
  118. perfData.header.Size = sizeof( perfData ); \
  119. perfData.header.Flags = WNODE_FLAG_TRACED_GUID; \
  120. perfData.header.Guid = GUID_AUDIOADDBREAK; \
  121. perfData.data.iterNextWrite = IterNextWrite; \
  122. perfData.data.offsetNextWrite = OffsetNextWrite; \
  123. perfData.data.iterWrite = IterWrite; \
  124. perfData.data.offsetWrite = OffsetWrite; \
  125. PerflogTraceEvent((PEVENT_TRACE_HEADER) &perfData); \
  126. }
  127. #define PERFLOG_VIDEOREND( sampletime, clocktime, psample ) \
  128. if (PerflogEnableFlags & DXMPERF_VIDEOREND) { \
  129. PERFINFO_WMI_AVREND perfData; \
  130. memset( &perfData, 0, sizeof( perfData ) ); \
  131. perfData.header.Size = sizeof( perfData ); \
  132. perfData.header.Flags = WNODE_FLAG_TRACED_GUID; \
  133. perfData.header.Guid = GUID_VIDEOREND; \
  134. perfData.data.cycleCounter = _RDTSC(); \
  135. perfData.data.dshowClock = (clocktime); \
  136. perfData.data.sampleTime = (sampletime); \
  137. PerflogTraceEvent ((PEVENT_TRACE_HEADER) &perfData); \
  138. }
  139. #define PERFLOG_AUDIOGLITCH( instance, glitchtype, currenttime, previoustime ) \
  140. if (PerflogEnableFlags & DXMPERF_AUDIOGLITCH) { \
  141. PERFINFO_WMI_AUDIOGLITCH perfData; \
  142. memset( &perfData, 0, sizeof( perfData ) ); \
  143. perfData.header.Size = sizeof( perfData ); \
  144. perfData.header.Flags = WNODE_FLAG_TRACED_GUID; \
  145. perfData.header.Guid = GUID_DSOUNDGLITCH; \
  146. perfData.data.cycleCounter = _RDTSC(); \
  147. perfData.data.glitchType = (glitchtype); \
  148. perfData.data.sampleTime = (currenttime); \
  149. perfData.data.previousTime = (previoustime); \
  150. perfData.data.instanceId = (instance); \
  151. PerflogTraceEvent ((PEVENT_TRACE_HEADER) &perfData); \
  152. }
  153. #define PERFLOG_FRAMEDROP( sampletime, clocktime, psample, renderer ) /*{ \
  154. PERFINFO_WMI_FRAMEDROP perfData; \
  155. if (NULL != g_pTraceEvent) { \
  156. memset( &perfData, 0, sizeof( perfData ) ); \
  157. perfData.header.Size = sizeof( perfData ); \
  158. perfData.header.Flags = WNODE_FLAG_TRACED_GUID; \
  159. perfData.header.Guid = GUID_FRAMEDROP; \
  160. perfData.data.cycleCounter = _RDTSC(); \
  161. perfData.data.dshowClock = (clocktime); \
  162. perfData.data.frameTime = (sampletime); \
  163. if (g_perfMasks[FRAMEDROP_INDEX] & FRAMEDROP_BIT) \
  164. (*g_pTraceEvent)( g_traceHandle, (PEVENT_TRACE_HEADER) &perfData ); \
  165. } \
  166. }*/
  167. /*
  168. #define PERFLOG_AUDIOBREAK( nextwrite, writepos, msecs ) { \
  169. PERFINFO_WMI_AUDIOBREAK perfData; \
  170. if (NULL != g_pTraceEvent) { \
  171. memset( &perfData, 0, sizeof( perfData ) ); \
  172. perfData.header.Size = sizeof( perfData ); \
  173. perfData.header.Flags = WNODE_FLAG_TRACED_GUID; \
  174. perfData.header.Guid = GUID_AUDIOBREAK; \
  175. perfData.data.cycleCounter = _RDTSC(); \
  176. perfData.data.dshowClock = (writepos); \
  177. perfData.data.sampleTime = (nextwrite); \
  178. perfData.data.sampleDuration = (msecs); \
  179. if (g_perfMasks[AUDIOBREAK_INDEX] & AUDIOBREAK_BIT) \
  180. (*g_pTraceEvent)( g_traceHandle, (PEVENT_TRACE_HEADER) &perfData ); \
  181. } \
  182. }
  183. */
  184. #define PERFLOG_AUDIOBREAK( nextwrite, writepos, msecs ) \
  185. if (PerflogEnableFlags & AUDIOBREAK_BIT) { \
  186. PERFINFO_WMI_AUDIOBREAK perfData; \
  187. memset( &perfData, 0, sizeof( perfData ) ); \
  188. perfData.header.Size = sizeof( perfData ); \
  189. perfData.header.Flags = WNODE_FLAG_TRACED_GUID; \
  190. perfData.header.Guid = GUID_AUDIOBREAK; \
  191. perfData.data.cycleCounter = _RDTSC(); \
  192. perfData.data.dshowClock = (writepos); \
  193. perfData.data.sampleTime = (nextwrite); \
  194. perfData.data.sampleDuration = (msecs); \
  195. PerflogTraceEvent ((PEVENT_TRACE_HEADER) &perfData); \
  196. } \
  197. inline
  198. VOID PERFLOG_STREAMTRACE(
  199. ULONG Level,
  200. ULONG Id,
  201. ULONGLONG DShowClock,
  202. ULONGLONG Data1,
  203. ULONGLONG Data2,
  204. ULONGLONG Data3,
  205. ULONGLONG Data4
  206. )
  207. {
  208. if (Level <= PerflogModuleLevel) {
  209. PERFINFO_WMI_STREAMTRACE perfData;
  210. memset( &perfData, 0, sizeof( perfData ) );
  211. perfData.header.Size = sizeof( perfData );
  212. perfData.header.Flags = WNODE_FLAG_TRACED_GUID;
  213. perfData.header.Guid = GUID_STREAMTRACE;
  214. perfData.data.dshowClock = DShowClock;
  215. perfData.data.id = Id;
  216. perfData.data.data[0] = Data1;
  217. perfData.data.data[1] = Data2;
  218. perfData.data.data[2] = Data3;
  219. perfData.data.data[3] = Data4;
  220. PerflogTraceEvent((PEVENT_TRACE_HEADER) &perfData);
  221. }
  222. }
  223. #endif // _DXMPERF_H_