1
0

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