syncstr.h
上传用户:lctgjx
上传日期:2022-06-04
资源大小:8887k
文件大小:12k
源码类别:

流媒体/Mpeg4/MP4

开发平台:

Visual C++

  1. /* $Xorg: syncstr.h,v 1.4 2001/02/09 02:03:24 xorgcvs Exp $ */
  2. /*
  3. Copyright 1991, 1993, 1994, 1998  The Open Group
  4. Permission to use, copy, modify, distribute, and sell this software and its
  5. documentation for any purpose is hereby granted without fee, provided that
  6. the above copyright notice appear in all copies and that both that
  7. copyright notice and this permission notice appear in supporting
  8. documentation.
  9. The above copyright notice and this permission notice shall be included in
  10. all copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
  14. OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  15. AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  16. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  17. Except as contained in this notice, the name of The Open Group shall not be
  18. used in advertising or otherwise to promote the sale, use or other dealings
  19. in this Software without prior written authorization from The Open Group.
  20. */
  21. /***********************************************************
  22. Copyright 1991,1993 by Digital Equipment Corporation, Maynard, Massachusetts,
  23. and Olivetti Research Limited, Cambridge, England.
  24.                         All Rights Reserved
  25. Permission to use, copy, modify, and distribute this software and its 
  26. documentation for any purpose and without fee is hereby granted, 
  27. provided that the above copyright notice appear in all copies and that
  28. both that copyright notice and this permission notice appear in 
  29. supporting documentation, and that the names of Digital or Olivetti
  30. not be used in advertising or publicity pertaining to distribution of the
  31. software without specific, written prior permission.  
  32. DIGITAL AND OLIVETTI DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
  33. SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  34. FITNESS, IN NO EVENT SHALL THEY BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  35. CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  36. USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  37. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  38. PERFORMANCE OF THIS SOFTWARE.
  39. ******************************************************************/
  40. /* $XFree86: xc/include/extensions/syncstr.h,v 1.3 2003/07/16 01:38:24 dawes Exp $ */
  41. #ifndef _SYNCSTR_H_
  42. #define _SYNCSTR_H_
  43. #include "sync.h"
  44. #ifndef _SYNC_OS
  45. /* cover up types from sync.h to make sure they're the right size for
  46.  * protocol packaging.  These will be undef'ed after all the protocol
  47.  * structures are defined.
  48.  */
  49. #define XSyncCounter CARD32
  50. #define XSyncAlarm   CARD32
  51. /*
  52.  * Initialize
  53.  */
  54. typedef struct _xSyncInitialize {
  55.     CARD8 reqType;
  56.     CARD8 syncReqType;
  57.     CARD16 length B16;
  58.     CARD8 majorVersion;
  59.     CARD8 minorVersion;
  60.     CARD16 pad B16;
  61. } xSyncInitializeReq;
  62. #define sz_xSyncInitializeReq 8
  63. typedef struct {
  64.     BYTE type;
  65.     CARD8 unused;
  66.     CARD16 sequenceNumber B16;
  67.     CARD32 length B32;
  68.     CARD8 majorVersion;
  69.     CARD8 minorVersion;
  70.     CARD16 pad B16;
  71.     CARD32 pad0 B32;
  72.     CARD32 pad1 B32;
  73.     CARD32 pad2 B32;
  74.     CARD32 pad3 B32;
  75.     CARD32 pad4 B32;
  76. } xSyncInitializeReply;
  77. #define sz_xSyncInitializeReply 32
  78. /*
  79.  * ListSystemCounters
  80.  */
  81. typedef struct _xSyncListSystemCounters
  82. {
  83.     CARD8 reqType;
  84.     CARD8 syncReqType;
  85.     CARD16 length B16;
  86. } xSyncListSystemCountersReq;
  87. #define sz_xSyncListSystemCountersReq 4
  88. typedef struct {
  89.     BYTE type;
  90.     CARD8 unused;
  91.     CARD16 sequenceNumber B16;
  92.     CARD32 length B32;
  93.     INT32 nCounters B32;
  94.     CARD32 pad0 B32;
  95.     CARD32 pad1 B32;
  96.     CARD32 pad2 B32;
  97.     CARD32 pad3 B32;
  98.     CARD32 pad4 B32;
  99. } xSyncListSystemCountersReply;
  100. #define sz_xSyncListSystemCountersReply 32
  101. typedef struct {
  102.     XSyncCounter counter B32;
  103.     INT32 resolution_hi B32;
  104.     CARD32 resolution_lo B32;
  105.     CARD16 name_length B16;
  106. } xSyncSystemCounter;
  107. #define sz_xSyncSystemCounter 14
  108. /*
  109.  * Create Counter
  110.  */
  111. typedef struct _xSyncCreateCounterReq {
  112.     CARD8 reqType;
  113.     CARD8 syncReqType;
  114.     CARD16 length B16;
  115.     XSyncCounter cid B32;
  116.     INT32       initial_value_hi B32;
  117.     CARD32 initial_value_lo B32;
  118. } xSyncCreateCounterReq;
  119. #define sz_xSyncCreateCounterReq 16
  120. /*
  121.  * Change Counter
  122.  */
  123. typedef struct _xSyncChangeCounterReq {
  124.     CARD8 reqType;
  125.     CARD8 syncReqType;
  126.     CARD16 length B16;
  127.     XSyncCounter cid B32;
  128.     INT32       value_hi B32;
  129.     CARD32 value_lo B32;
  130. } xSyncChangeCounterReq;
  131. #define sz_xSyncChangeCounterReq 16
  132. /*
  133.  * Set Counter
  134.  */
  135. typedef struct _xSyncSetCounterReq {
  136.     CARD8 reqType;
  137.     CARD8 syncReqType;
  138.     CARD16 length B16;
  139.     XSyncCounter cid B32;
  140.     INT32       value_hi B32;
  141.     CARD32 value_lo B32;
  142. } xSyncSetCounterReq;
  143. #define sz_xSyncSetCounterReq 16
  144. /*
  145.  * Destroy Counter
  146.  */
  147. typedef struct _xSyncDestroyCounterReq {
  148.     CARD8 reqType;
  149.     CARD8 syncReqType;
  150.     CARD16 length B16;
  151.     XSyncCounter counter B32;
  152. } xSyncDestroyCounterReq;
  153. #define sz_xSyncDestroyCounterReq 8
  154. /*
  155.  * Query Counter
  156.  */
  157. typedef struct _xSyncQueryCounterReq {
  158.     CARD8 reqType;
  159.     CARD8 syncReqType;
  160.     CARD16 length B16;
  161.     XSyncCounter counter B32;
  162. } xSyncQueryCounterReq;
  163. #define sz_xSyncQueryCounterReq 8
  164. typedef struct {
  165.     BYTE type;
  166.     CARD8 unused;
  167.     CARD16 sequenceNumber B16;
  168.     CARD32 length B32;
  169.     INT32 value_hi B32;
  170.     CARD32 value_lo B32;
  171.     CARD32 pad0 B32;
  172.     CARD32 pad1 B32;
  173.     CARD32 pad2 B32;
  174.     CARD32 pad3 B32;
  175. } xSyncQueryCounterReply;
  176. #define sz_xSyncQueryCounterReply 32
  177. /*
  178.  * Await
  179.  */
  180. typedef struct _xSyncAwaitReq {
  181.     CARD8 reqType;
  182.     CARD8 syncReqType;
  183.     CARD16 length B16;
  184. } xSyncAwaitReq;
  185. #define sz_xSyncAwaitReq 4
  186. typedef struct _xSyncWaitCondition {
  187.     XSyncCounter counter B32;
  188.     CARD32 value_type B32;
  189.     INT32       wait_value_hi B32;
  190.     CARD32      wait_value_lo B32;
  191.     CARD32 test_type B32;
  192.     INT32 event_threshold_hi B32;
  193.     CARD32 event_threshold_lo B32;
  194. } xSyncWaitCondition;
  195. #define sz_xSyncWaitCondition 28
  196. /*
  197.  * Create Alarm
  198.  */
  199. typedef struct _xSyncCreateAlarmReq {
  200.     CARD8 reqType;
  201.     CARD8 syncReqType;
  202.     CARD16 length B16;
  203.     XSyncAlarm id B32;
  204.     CARD32      valueMask B32;
  205. } xSyncCreateAlarmReq;
  206. #define sz_xSyncCreateAlarmReq 12
  207. /*
  208.  * Destroy Alarm
  209.  */
  210. typedef struct _xSyncDestroyAlarmReq {
  211.     CARD8 reqType;
  212.     CARD8 syncReqType;
  213.     CARD16 length B16;
  214.     XSyncAlarm alarm B32;
  215. } xSyncDestroyAlarmReq;
  216. #define sz_xSyncDestroyAlarmReq 8
  217. /*
  218.  * Query Alarm
  219.  */
  220. typedef struct _xSyncQueryAlarmReq {
  221.     CARD8 reqType;
  222.     CARD8 syncReqType;
  223.     CARD16 length B16;
  224.     XSyncAlarm alarm B32;
  225. } xSyncQueryAlarmReq;
  226. #define sz_xSyncQueryAlarmReq 8
  227. typedef struct {
  228.     BYTE type;
  229.     CARD8 unused;
  230.     CARD16 sequenceNumber B16;
  231.     CARD32 length B32;
  232.     XSyncCounter counter B32;
  233.     CARD32 value_type B32;
  234.     INT32 wait_value_hi B32;
  235.     CARD32 wait_value_lo B32;
  236.     CARD32 test_type      B32;
  237.     INT32 delta_hi B32;
  238.     CARD32 delta_lo B32;
  239.     BOOL        events;
  240.     BYTE        state;
  241.     BYTE pad0;
  242.     BYTE pad1;
  243. } xSyncQueryAlarmReply;
  244. #define sz_xSyncQueryAlarmReply 40
  245. /*
  246.  * Change Alarm
  247.  */
  248. typedef struct _xSyncChangeAlarmReq {
  249.     CARD8 reqType;
  250.     CARD8 syncReqType;
  251.     CARD16 length B16;
  252.     XSyncAlarm alarm B32;
  253.     CARD32 valueMask B32;
  254. } xSyncChangeAlarmReq;
  255. #define sz_xSyncChangeAlarmReq 12
  256. /*
  257.  * SetPriority
  258.  */
  259. typedef struct _xSyncSetPriority{
  260.     CARD8    reqType;
  261.     CARD8    syncReqType;
  262.     CARD16   length B16;
  263.     CARD32   id B32;
  264.     INT32   priority B32;
  265. } xSyncSetPriorityReq;
  266. #define sz_xSyncSetPriorityReq      12
  267. /*
  268.  * Get Priority
  269.  */
  270. typedef struct _xSyncGetPriority{
  271.     CARD8    reqType;
  272.     CARD8    syncReqType;
  273.     CARD16   length B16;
  274.     CARD32   id B32; /*XXX XID? */
  275. } xSyncGetPriorityReq;
  276. #define sz_xSyncGetPriorityReq       8
  277. typedef struct {
  278.     BYTE type;
  279.     CARD8 unused;
  280.     CARD16 sequenceNumber B16;
  281.     CARD32 length B32;
  282.     INT32   priority B32;
  283.     CARD32   pad0 B32;
  284.     CARD32   pad1 B32;
  285.     CARD32   pad2 B32;
  286.     CARD32   pad3 B32;
  287.     CARD32   pad4 B32;
  288. } xSyncGetPriorityReply;
  289. #define sz_xSyncGetPriorityReply 32
  290. /*
  291.  * Events
  292.  */
  293. typedef struct _xSyncCounterNotifyEvent {
  294.     BYTE type;
  295.     BYTE kind;
  296.     CARD16 sequenceNumber B16;
  297.     XSyncCounter counter B32;
  298.     INT32 wait_value_hi B32;
  299.     CARD32 wait_value_lo B32;
  300.     INT32 counter_value_hi B32;
  301.     CARD32 counter_value_lo B32;
  302.     CARD32 time B32;
  303.     CARD16 count B16;
  304.     BOOL destroyed;
  305.     BYTE        pad0;
  306. } xSyncCounterNotifyEvent;
  307. typedef struct _xSyncAlarmNotifyEvent {
  308.     BYTE type;
  309.     BYTE kind;
  310.     CARD16 sequenceNumber B16;
  311.     XSyncAlarm alarm B32;
  312.     INT32 counter_value_hi B32;
  313.     CARD32 counter_value_lo B32;
  314.     INT32 alarm_value_hi B32;
  315.     CARD32 alarm_value_lo B32;
  316.     CARD32 time B32;
  317.     CARD8       state;
  318.     BYTE        pad0;
  319.     BYTE        pad1;
  320.     BYTE        pad2;
  321. } xSyncAlarmNotifyEvent;
  322. #undef XSyncCounter
  323. #undef XSyncAlarm
  324. #endif /* _SYNC_OS */
  325. #ifdef _SYNC_SERVER
  326. #define CARD64 XSyncValue /* XXX temporary! need real 64 bit values for Alpha */
  327. typedef struct _SyncCounter {
  328.     ClientPtr client; /* Owning client. 0 for system counters */
  329.     XSyncCounter id; /* resource ID */
  330.     CARD64 value; /* counter value */
  331.     struct _SyncTriggerList *pTriglist; /* list of triggers */
  332.     Bool beingDestroyed; /* in process of going away */
  333.     struct _SysCounterInfo *pSysCounterInfo; /* NULL if not a system counter */
  334. } SyncCounter;
  335. /*
  336.  * The System Counter interface
  337.  */
  338. typedef enum {
  339.     XSyncCounterNeverChanges,
  340.     XSyncCounterNeverIncreases,
  341.     XSyncCounterNeverDecreases,
  342.     XSyncCounterUnrestricted
  343. } SyncCounterType;
  344. typedef struct _SysCounterInfo {
  345.     char *name;
  346.     CARD64 resolution;
  347.     CARD64 bracket_greater;
  348.     CARD64 bracket_less;
  349.     SyncCounterType counterType;  /* how can this counter change */
  350.     void        (*QueryValue)(
  351.       pointer /*pCounter*/,
  352.       CARD64 * /*freshvalue*/
  353. );
  354.     void (*BracketValues)(
  355.  pointer /*pCounter*/,
  356.  CARD64 * /*lessthan*/,
  357.  CARD64 * /*greaterthan*/
  358. );
  359. } SysCounterInfo;
  360. typedef struct _SyncTrigger {
  361.     SyncCounter *pCounter;
  362.     CARD64 wait_value; /* wait value */
  363.     unsigned int value_type;     /* Absolute or Relative */
  364.     unsigned int test_type; /* transition or Comparision type */
  365.     CARD64 test_value; /* trigger event threshold value */
  366.     Bool (*CheckTrigger)(
  367. struct _SyncTrigger * /*pTrigger*/,
  368. CARD64 /*newval*/
  369. );
  370.     void (*TriggerFired)(
  371. struct _SyncTrigger * /*pTrigger*/
  372. );
  373.     void (*CounterDestroyed)(
  374. struct _SyncTrigger * /*pTrigger*/
  375.     );
  376. } SyncTrigger;
  377. typedef struct _SyncTriggerList {
  378.     SyncTrigger *pTrigger;
  379.     struct _SyncTriggerList *next;
  380. } SyncTriggerList;
  381. typedef struct _SyncAlarmClientList {
  382.     ClientPtr client;
  383.     XID delete_id;
  384.     struct _SyncAlarmClientList *next;
  385. } SyncAlarmClientList;
  386. typedef struct _SyncAlarm {
  387.     SyncTrigger trigger;
  388.     ClientPtr client;
  389.     XSyncAlarm  alarm_id;
  390.     CARD64 delta;
  391.     int events;
  392.     int state;
  393.     SyncAlarmClientList *pEventClients;
  394. } SyncAlarm;
  395. typedef struct {
  396.     ClientPtr client;
  397.     CARD32  delete_id;
  398.     int num_waitconditions;
  399. } SyncAwaitHeader;
  400. typedef struct {
  401.     SyncTrigger trigger;
  402.     CARD64 event_threshold;
  403.     SyncAwaitHeader *pHeader;
  404. } SyncAwait;
  405. typedef union {
  406.     SyncAwaitHeader header;
  407.     SyncAwait     await;
  408. } SyncAwaitUnion;
  409. extern pointer SyncCreateSystemCounter(
  410.     char * /* name */,
  411.     CARD64   /* inital_value */,
  412.     CARD64   /* resolution */,
  413.     SyncCounterType /* change characterization */,
  414.     void        (* /*QueryValue*/ ) (
  415.         pointer /* pCounter */,
  416.         CARD64 * /* pValue_return */), /* XXX prototype */
  417.     void        (* /*BracketValues*/) (
  418.         pointer /* pCounter */, 
  419.         CARD64 * /* pbracket_less */,
  420.         CARD64 * /* pbracket_greater */)
  421. );
  422. extern void SyncChangeCounter(
  423.     SyncCounter * /* pCounter*/,
  424.     CARD64   /* new_value */
  425. );
  426. extern void SyncDestroySystemCounter(
  427.     pointer pCounter
  428. );
  429. extern void InitServertime(void);
  430. #endif /* _SYNC_SERVER */
  431. #endif /* _SYNCSTR_H_ */