[142] | 1 | /* $Id: event.cpp 142 2000-04-23 14:55:46Z ktk $ */
|
---|
| 2 |
|
---|
| 3 | /* SCCSID = %W% %E% */
|
---|
| 4 | /****************************************************************************
|
---|
| 5 | * *
|
---|
| 6 | * Copyright (c) IBM Corporation 1994 - 1997. *
|
---|
| 7 | * *
|
---|
| 8 | * The following IBM OS/2 source code is provided to you solely for the *
|
---|
| 9 | * the purpose of assisting you in your development of OS/2 device drivers. *
|
---|
| 10 | * You may use this code in accordance with the IBM License Agreement *
|
---|
| 11 | * provided in the IBM Device Driver Source Kit for OS/2. *
|
---|
| 12 | * *
|
---|
| 13 | ****************************************************************************/
|
---|
| 14 | /**@internal %W%
|
---|
| 15 | * @notes
|
---|
| 16 | * Member fucntions for the EVENT class.
|
---|
| 17 | * @version %I%
|
---|
| 18 | * @context Unless otherwise noted, all interfaces are Ring-0, 16-bit,
|
---|
| 19 | * <stack context>.
|
---|
| 20 | * @history
|
---|
| 21 | *
|
---|
| 22 | */
|
---|
| 23 | #define INCL_NOPMAPI
|
---|
| 24 | #define INCL_DOSERRORS // for ERROR_INVALID_FUNCTION
|
---|
| 25 | #include <os2.h>
|
---|
| 26 | #include <os2me.h>
|
---|
| 27 | #include <audio.h>
|
---|
| 28 | #ifndef DDCMD_REG_STREAM // shdd.h can't handle being included twice
|
---|
| 29 | #include <shdd.h>
|
---|
| 30 | #endif
|
---|
| 31 |
|
---|
| 32 | #include "stream.hpp"
|
---|
| 33 | #include "event.hpp"
|
---|
| 34 | #include <include.h>
|
---|
| 35 | #include "dbgos2.h"
|
---|
| 36 |
|
---|
| 37 | /**@internal Report
|
---|
| 38 | * @param None
|
---|
| 39 | * @return None
|
---|
| 40 | * @notes
|
---|
| 41 | * This function will report (return) an expired event to SHDD
|
---|
| 42 | */
|
---|
| 43 | void EVENT::Report(ULONG time)
|
---|
| 44 | {
|
---|
| 45 | ULONG ulPopTime;
|
---|
| 46 |
|
---|
| 47 | // update the streamtime in the event report msg
|
---|
| 48 | shdre.ulStreamTime = time;
|
---|
| 49 |
|
---|
| 50 | // set ulNextTime to -1 incase MMPM comes back in on
|
---|
| 51 | // this thread and clobbers this event
|
---|
| 52 | ulPopTime = ulNextTime;
|
---|
| 53 | ulNextTime = 0xFFFFFFFF;
|
---|
| 54 |
|
---|
| 55 | // send the event back to the SHDD
|
---|
| 56 | pstream->pfnSHD(&shdre);
|
---|
| 57 |
|
---|
| 58 | // if ulNextTime is still -1 then
|
---|
| 59 | // we can see if we need to recalculate ulNextTime
|
---|
| 60 | if (ulNextTime == 0xFFFFFFFF) {
|
---|
| 61 | // if this is a recurring event re-calculate ulNextTime
|
---|
| 62 | if (ulFlags) {
|
---|
| 63 | ulNextTime = ulRepeatTime + ulPopTime;
|
---|
| 64 | shdre.ulStreamTime = ulNextTime;
|
---|
| 65 | }
|
---|
| 66 | }
|
---|
| 67 | // tell the stream to find the next event to time out
|
---|
| 68 | pstream->SetNextEvent();
|
---|
| 69 | }
|
---|
| 70 |
|
---|
| 71 | HEVENT EVENT::GetHandle(void)
|
---|
| 72 | {
|
---|
| 73 | return(he);
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 | ULONG EVENT::GetEventTime(void)
|
---|
| 77 | {
|
---|
| 78 | return(ulNextTime);
|
---|
| 79 | }
|
---|
| 80 | /**@internal UpdateEvent
|
---|
| 81 | * @param PSTREAM the address of the stream that owns this event
|
---|
| 82 | * @param HEVENT the handle of this event
|
---|
| 83 | * @param PCONTROL_PARM the address of the control parm associated with
|
---|
| 84 | * this event
|
---|
| 85 | * @return None
|
---|
| 86 | * @notes
|
---|
| 87 | * "Updates" the event info when MMPM sends an Enable Event DDCMD and
|
---|
| 88 | * the event has already been created.
|
---|
| 89 | * Upon entry to this member function we could be touching values that
|
---|
| 90 | * the interrupt handler may look at so we will cli/sti around the whole thing
|
---|
| 91 | */
|
---|
| 92 | void EVENT::UpdateEvent(PSTREAM ps, HEVENT hevent, PCONTROL_PARM pcp)
|
---|
| 93 | {
|
---|
| 94 |
|
---|
| 95 | cli();
|
---|
| 96 | pstream=ps;
|
---|
| 97 | he=hevent;
|
---|
| 98 | ULONG currenttime;
|
---|
| 99 |
|
---|
| 100 | currenttime = ps->GetCurrentTime();
|
---|
| 101 | ulFlags = pcp->evcb.ulFlags & EVENT_RECURRING;
|
---|
| 102 |
|
---|
| 103 | if (ulFlags)
|
---|
| 104 | ulRepeatTime = pcp->ulTime - currenttime;
|
---|
| 105 |
|
---|
| 106 | ulNextTime = pcp->ulTime;
|
---|
| 107 | shdre.ulFunction = SHD_REPORT_EVENT;
|
---|
| 108 | shdre.hStream = pstream->hstream;
|
---|
| 109 | shdre.hEvent = he;
|
---|
| 110 | shdre.ulStreamTime = ulNextTime;
|
---|
| 111 | sti();
|
---|
| 112 | }
|
---|
| 113 | /**@internal EVENT
|
---|
| 114 | * @param PSTREAM the address of the stream that owns this event
|
---|
| 115 | * @param HEVENT the handle of this event
|
---|
| 116 | * @param PCONTROL_PARM the address of the control parm associated with
|
---|
| 117 | * this event
|
---|
| 118 | * @return None
|
---|
| 119 | * @notes
|
---|
| 120 | * the event class constructor
|
---|
| 121 | */
|
---|
| 122 | EVENT::EVENT(PSTREAM ps, HEVENT hevent, PCONTROL_PARM pcp)
|
---|
| 123 | {
|
---|
| 124 | UpdateEvent(ps, hevent, pcp);
|
---|
| 125 | ps->qhEvent.PushOnTail((PQUEUEELEMENT)this);
|
---|
| 126 | }
|
---|
| 127 | /**@internal FindEvent
|
---|
| 128 | * @param HEVENT event handle the caller is looking for
|
---|
| 129 | * @param PQUEUEHEAD the pointer the QUEUEHEAD for this EVENT
|
---|
| 130 | * @return PEVENT the pointer to the event in question
|
---|
| 131 | * @return NULL NULL if EVENT is not found
|
---|
| 132 | * @notes
|
---|
| 133 | * Globally scopped function that returns the pointer to a particular
|
---|
| 134 | * event on the event queue
|
---|
| 135 | */
|
---|
| 136 | PEVENT FindEvent(HEVENT he, PQUEUEHEAD pQH)
|
---|
| 137 | {
|
---|
| 138 | PQUEUEELEMENT pqe = pQH->Head();
|
---|
| 139 |
|
---|
| 140 | while (pqe) {
|
---|
| 141 | if (((PEVENT)pqe)->GetHandle() == he)
|
---|
| 142 | return (PEVENT)pqe;
|
---|
| 143 | pqe = pqe->pNext;
|
---|
| 144 | }
|
---|
| 145 | return NULL;
|
---|
| 146 | }
|
---|