Timer.h
上传用户:xjjlds
上传日期:2015-12-05
资源大小:22823k
文件大小:8k
源码类别:

多媒体编程

开发平台:

Visual C++

  1. /*
  2.      File:       Timer.h
  3.  
  4.      Contains:   Time Manager interfaces.
  5.  
  6.      Version:    Technology: Mac OS 8.5
  7.                  Release:    QuickTime 6.0.2
  8.  
  9.      Copyright:  (c) 1985-2001 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:      For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __TIMER__
  18. #define __TIMER__
  19. #ifndef __CONDITIONALMACROS__
  20. #include "ConditionalMacros.h"
  21. #endif
  22. #ifndef __MACTYPES__
  23. #include "MacTypes.h"
  24. #endif
  25. #ifndef __OSUTILS__
  26. #include "OSUtils.h"
  27. #endif
  28. #if PRAGMA_ONCE
  29. #pragma once
  30. #endif
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. #if PRAGMA_IMPORT
  35. #pragma import on
  36. #endif
  37. #if PRAGMA_STRUCT_ALIGN
  38.     #pragma options align=mac68k
  39. #elif PRAGMA_STRUCT_PACKPUSH
  40.     #pragma pack(push, 2)
  41. #elif PRAGMA_STRUCT_PACK
  42.     #pragma pack(2)
  43. #endif
  44. enum {
  45.                                                                 /* high bit of qType is set if task is active */
  46.     kTMTaskActive               = (1L << 15)
  47. };
  48. typedef struct TMTask                   TMTask;
  49. typedef TMTask *                        TMTaskPtr;
  50. typedef CALLBACK_API( void , TimerProcPtr )(TMTaskPtr tmTaskPtr);
  51. /*
  52.     WARNING: TimerProcPtr uses register based parameters under classic 68k
  53.              and cannot be written in a high-level language without 
  54.              the help of mixed mode or assembly glue.
  55. */
  56. typedef REGISTER_UPP_TYPE(TimerProcPtr)                         TimerUPP;
  57. struct TMTask {
  58.     QElemPtr                        qLink;
  59.     short                           qType;
  60.     TimerUPP                        tmAddr;
  61.     long                            tmCount;
  62.     long                            tmWakeUp;
  63.     long                            tmReserved;
  64. };
  65.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  66.                                                                                             #pragma parameter InsTime(__A0)
  67.                                                                                             #endif
  68. EXTERN_API( void )
  69. InsTime                         (QElemPtr               tmTaskPtr)                          ONEWORDINLINE(0xA058);
  70.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  71.                                                                                             #pragma parameter InsXTime(__A0)
  72.                                                                                             #endif
  73. EXTERN_API( void )
  74. InsXTime                        (QElemPtr               tmTaskPtr)                          ONEWORDINLINE(0xA458);
  75.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  76.                                                                                             #pragma parameter PrimeTime(__A0, __D0)
  77.                                                                                             #endif
  78. EXTERN_API( void )
  79. PrimeTime                       (QElemPtr               tmTaskPtr,
  80.                                  long                   count)                              ONEWORDINLINE(0xA05A);
  81.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  82.                                                                                             #pragma parameter RmvTime(__A0)
  83.                                                                                             #endif
  84. EXTERN_API( void )
  85. RmvTime                         (QElemPtr               tmTaskPtr)                          ONEWORDINLINE(0xA059);
  86. /* InstallTimeTask, InstallXTimeTask, PrimeTimeTask and RemoveTimeTask work */
  87. /* just like InsTime, InsXTime, PrimeTime, and RmvTime except that they */
  88. /* return an OSErr result. */
  89. #if CALL_NOT_IN_CARBON
  90.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  91.                                                                                             #pragma parameter __D0 InstallTimeTask(__A0)
  92.                                                                                             #endif
  93. EXTERN_API( OSErr )
  94. InstallTimeTask                 (QElemPtr               tmTaskPtr)                          ONEWORDINLINE(0xA058);
  95.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  96.                                                                                             #pragma parameter __D0 InstallXTimeTask(__A0)
  97.                                                                                             #endif
  98. EXTERN_API( OSErr )
  99. InstallXTimeTask                (QElemPtr               tmTaskPtr)                          ONEWORDINLINE(0xA458);
  100.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  101.                                                                                             #pragma parameter __D0 PrimeTimeTask(__A0, __D0)
  102.                                                                                             #endif
  103. EXTERN_API( OSErr )
  104. PrimeTimeTask                   (QElemPtr               tmTaskPtr,
  105.                                  long                   count)                              ONEWORDINLINE(0xA05A);
  106.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  107.                                                                                             #pragma parameter __D0 RemoveTimeTask(__A0)
  108.                                                                                             #endif
  109. EXTERN_API( OSErr )
  110. RemoveTimeTask                  (QElemPtr               tmTaskPtr)                          ONEWORDINLINE(0xA059);
  111. #endif  /* CALL_NOT_IN_CARBON */
  112. EXTERN_API( void )
  113. Microseconds                    (UnsignedWide *         microTickCount)                     FOURWORDINLINE(0xA193, 0x225F, 0x22C8, 0x2280);
  114. #if OPAQUE_UPP_TYPES
  115.     EXTERN_API(TimerUPP)
  116.     NewTimerUPP                    (TimerProcPtr            userRoutine);
  117.     EXTERN_API(void)
  118.     DisposeTimerUPP                (TimerUPP                userUPP);
  119.     EXTERN_API(void)
  120.     InvokeTimerUPP                 (TMTaskPtr               tmTaskPtr,
  121.                                     TimerUPP                userUPP);
  122. #else
  123.     enum { uppTimerProcInfo = 0x0000B802 };                         /* register no_return_value Func(4_bytes:A1) */
  124.     #define NewTimerUPP(userRoutine)                                (TimerUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppTimerProcInfo, GetCurrentArchitecture())
  125.     #define DisposeTimerUPP(userUPP)                                DisposeRoutineDescriptor(userUPP)
  126.     #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  127.     #pragma parameter InvokeTimerUPP(__A1, __A0)
  128.     void InvokeTimerUPP(TMTaskPtr tmTaskPtr, TimerUPP userUPP) = 0x4E90;
  129.     #else
  130.         #define InvokeTimerUPP(tmTaskPtr, userUPP)                      CALL_ONE_PARAMETER_UPP((userUPP), uppTimerProcInfo, (tmTaskPtr))
  131.     #endif
  132. #endif
  133. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  134. #define NewTimerProc(userRoutine)                               NewTimerUPP(userRoutine)
  135. #define CallTimerProc(userRoutine, tmTaskPtr)                   InvokeTimerUPP(tmTaskPtr, userRoutine)
  136. #if PRAGMA_STRUCT_ALIGN
  137.     #pragma options align=reset
  138. #elif PRAGMA_STRUCT_PACKPUSH
  139.     #pragma pack(pop)
  140. #elif PRAGMA_STRUCT_PACK
  141.     #pragma pack()
  142. #endif
  143. #ifdef PRAGMA_IMPORT_OFF
  144. #pragma import off
  145. #elif PRAGMA_IMPORT
  146. #pragma import reset
  147. #endif
  148. #ifdef __cplusplus
  149. }
  150. #endif
  151. #endif /* __TIMER__ */