| 1 | /* $Id: event.cpp,v 1.1 2000/04/23 14:55:15 ktk Exp $ */
|
|---|
| 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 | /*Rudi: now inlined ...
|
|---|
| 72 | HEVENT EVENT::GetHandle(void)
|
|---|
| 73 | {
|
|---|
| 74 | return(he);
|
|---|
| 75 | }
|
|---|
| 76 |
|
|---|
| 77 | ULONG EVENT::GetEventTime(void)
|
|---|
| 78 | {
|
|---|
| 79 | return(ulNextTime);
|
|---|
| 80 | }
|
|---|
| 81 | */
|
|---|
| 82 |
|
|---|
| 83 | /**@internal UpdateEvent
|
|---|
| 84 | * @param PSTREAM the address of the stream that owns this event
|
|---|
| 85 | * @param HEVENT the handle of this event
|
|---|
| 86 | * @param PCONTROL_PARM the address of the control parm associated with
|
|---|
| 87 | * this event
|
|---|
| 88 | * @return None
|
|---|
| 89 | * @notes
|
|---|
| 90 | * "Updates" the event info when MMPM sends an Enable Event DDCMD and
|
|---|
| 91 | * the event has already been created.
|
|---|
| 92 | * Upon entry to this member function we could be touching values that
|
|---|
| 93 | * the interrupt handler may look at so we will cli/sti around the whole thing
|
|---|
| 94 | */
|
|---|
| 95 | void EVENT::UpdateEvent(PSTREAM ps, HEVENT hevent, PCONTROL_PARM pcp)
|
|---|
| 96 | {
|
|---|
| 97 |
|
|---|
| 98 | cli();
|
|---|
| 99 | pstream=ps;
|
|---|
| 100 | he=hevent;
|
|---|
| 101 | ULONG currenttime;
|
|---|
| 102 |
|
|---|
| 103 | currenttime = ps->GetCurrentTime();
|
|---|
| 104 | ulFlags = pcp->evcb.ulFlags & EVENT_RECURRING;
|
|---|
| 105 |
|
|---|
| 106 | if (ulFlags)
|
|---|
| 107 | ulRepeatTime = pcp->ulTime - currenttime;
|
|---|
| 108 |
|
|---|
| 109 | ulNextTime = pcp->ulTime;
|
|---|
| 110 | shdre.ulFunction = SHD_REPORT_EVENT;
|
|---|
| 111 | shdre.hStream = pstream->hstream;
|
|---|
| 112 | shdre.hEvent = he;
|
|---|
| 113 | shdre.ulStreamTime = ulNextTime;
|
|---|
| 114 | sti();
|
|---|
| 115 | }
|
|---|
| 116 | /**@internal EVENT
|
|---|
| 117 | * @param PSTREAM the address of the stream that owns this event
|
|---|
| 118 | * @param HEVENT the handle of this event
|
|---|
| 119 | * @param PCONTROL_PARM the address of the control parm associated with
|
|---|
| 120 | * this event
|
|---|
| 121 | * @return None
|
|---|
| 122 | * @notes
|
|---|
| 123 | * the event class constructor
|
|---|
| 124 | */
|
|---|
| 125 | EVENT::EVENT(PSTREAM ps, HEVENT hevent, PCONTROL_PARM pcp)
|
|---|
| 126 | {
|
|---|
| 127 | UpdateEvent(ps, hevent, pcp);
|
|---|
| 128 | ps->qhEvent.PushOnTail((PQUEUEELEMENT)this);
|
|---|
| 129 | }
|
|---|
| 130 | /**@internal FindEvent
|
|---|
| 131 | * @param HEVENT event handle the caller is looking for
|
|---|
| 132 | * @param PQUEUEHEAD the pointer the QUEUEHEAD for this EVENT
|
|---|
| 133 | * @return PEVENT the pointer to the event in question
|
|---|
| 134 | * @return NULL NULL if EVENT is not found
|
|---|
| 135 | * @notes
|
|---|
| 136 | * Globally scopped function that returns the pointer to a particular
|
|---|
| 137 | * event on the event queue
|
|---|
| 138 | */
|
|---|
| 139 | PEVENT FindEvent(HEVENT he, PQUEUEHEAD pQH)
|
|---|
| 140 | {
|
|---|
| 141 | PQUEUEELEMENT pqe = pQH->Head();
|
|---|
| 142 |
|
|---|
| 143 | while (pqe) {
|
|---|
| 144 | if (((PEVENT)pqe)->GetHandle() == he)
|
|---|
| 145 | return (PEVENT)pqe;
|
|---|
| 146 | pqe = pqe->pNext;
|
|---|
| 147 | }
|
|---|
| 148 | return NULL;
|
|---|
| 149 | }
|
|---|