home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / audiopdd.zip / event.c < prev    next >
C/C++ Source or Header  |  1999-02-19  |  3KB  |  130 lines

  1. //
  2. // event.c
  3. // 27-Jan-99
  4. //
  5.  
  6. #include "cs40.h"
  7.  
  8.  
  9.  
  10.  
  11. #if 0
  12.  
  13. /**@internal Report
  14.  * @param    None
  15.  * @return   None
  16.  * @notes
  17.  * This function will report (return) an expired event to SHDD
  18.  */
  19. void EVENT::Report(ULONG time)
  20. {
  21.     ULONG ulPopTime;
  22.  
  23.     // update the streamtime in the event report msg
  24.    shdre.ulStreamTime = time;
  25.  
  26.    // set ulNextTime to -1 incase MMPM comes back in on
  27.    // this thread and clobbers this event
  28.    ulPopTime = ulNextTime;
  29.    ulNextTime = 0xFFFFFFFF;
  30.  
  31.    // do an event trace
  32.    pTrace->vLog(EVENT_RETURNED,he,time);
  33.  
  34.    // send the event back to the SHDD
  35.    pstream->pfnSHD(&shdre);
  36.  
  37.       // if ulNextTime is still -1 then
  38.       // we can see if we need to recalculate  ulNextTime
  39.    if (ulNextTime == 0xFFFFFFFF) {
  40.       // if this is a recurring event re-calculate ulNextTime
  41.       if (ulFlags) {
  42.          ulNextTime = ulRepeatTime + ulPopTime;
  43.          shdre.ulStreamTime = ulNextTime;
  44.       }
  45.    }
  46.    // tell the stream to find the next event to time out
  47.    pstream->SetNextEvent();
  48. }
  49.  
  50. HEVENT EVENT::GetHandle(void)
  51. {
  52.    return(he);
  53. }
  54.  
  55. ULONG  EVENT::GetEventTime(void)
  56. {
  57.    return(ulNextTime);
  58. }
  59. /**@internal UpdateEvent
  60.  * @param    PSTREAM        the address of the stream that owns this event
  61.  * @param    HEVENT         the handle of this event
  62.  * @param    PCONTROL_PARM  the address of the control parm associated with
  63.  *                          this event
  64.  * @return   None
  65.  * @notes
  66.  * "Updates" the event info when MMPM sends an Enable Event DDCMD and
  67.  * the event has already been created.
  68.  * Upon entry to this member function we could be touching values that
  69.  * the interrupt handler may look at so we will cli/sti around the whole thing
  70.  */
  71. void EVENT::UpdateEvent(PSTREAM ps, HEVENT hevent, PCONTROL_PARM pcp)
  72. {
  73.  
  74.    _cli_();
  75.    pstream=ps;
  76.    he=hevent;
  77.    ULONG currenttime;
  78.  
  79.    currenttime = ps->GetCurrentTime();
  80.    ulFlags = pcp->evcb.ulFlags & EVENT_RECURRING;
  81.  
  82.    if (ulFlags)
  83.       ulRepeatTime = pcp->ulTime - currenttime;
  84.  
  85.    ulNextTime = pcp->ulTime;
  86.    shdre.ulFunction = SHD_REPORT_EVENT;
  87.    shdre.hStream = pstream->hstream;
  88.    shdre.hEvent = he;
  89.    shdre.ulStreamTime = ulNextTime;
  90.    _sti_();
  91.    pTrace->vLog(DDCMD_EnableEvent,hevent,ulRepeatTime,pcp->evcb.ulType,
  92.                 pcp->evcb.ulFlags, ulNextTime);
  93.  
  94. }
  95. /**@internal EVENT
  96.  * @param    PSTREAM        the address of the stream that owns this event
  97.  * @param    HEVENT         the handle of this event
  98.  * @param    PCONTROL_PARM  the address of the control parm associated with
  99.  *                          this event
  100.  * @return   None
  101.  * @notes
  102.  * the event class constructor
  103.  */
  104. EVENT::EVENT(PSTREAM ps, HEVENT hevent, PCONTROL_PARM pcp)
  105. {
  106.    UpdateEvent(ps, hevent, pcp);
  107.    ps->qhEvent.PushOnTail((PQUEUEELEMENT)this);
  108. }
  109. /**@internal FindEvent
  110.  * @param    HEVENT  event handle the caller is looking for
  111.  * @param    PQUEUEHEAD the pointer the QUEUEHEAD for this EVENT
  112.  * @return   PEVENT  the pointer to the event in question
  113.  * @return   NULL    NULL if EVENT is not found
  114.  * @notes
  115.  * Globally scopped function that returns the pointer to a particular
  116.  * event on the event queue
  117.  */
  118. PEVENT FindEvent(HEVENT he, PQUEUEHEAD pQH)
  119. {
  120.    PQUEUEELEMENT pqe = pQH->Head();
  121.  
  122.    while (pqe) {
  123.       if (((PEVENT)pqe)->GetHandle() == he)
  124.          return (PEVENT)pqe;
  125.       pqe = pqe->pNext;
  126.    }
  127.    return NULL;
  128. }
  129. #endif
  130.