| 1 | /* $Id: ssm_idc.cpp,v 1.1 2000/04/23 14:55:20 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 | * @version %I%
|
|---|
| 17 | * @context Unless otherwise noted, all interfaces are Ring-0, 16-bit,
|
|---|
| 18 | * <stack context>.
|
|---|
| 19 | * @history
|
|---|
| 20 | *
|
|---|
| 21 | */
|
|---|
| 22 | #define INCL_NOPMAPI
|
|---|
| 23 | #define INCL_DOSERRORS // for ERROR_INVALID_FUNCTION
|
|---|
| 24 | #include <os2.h>
|
|---|
| 25 | #include <os2me.h>
|
|---|
| 26 | #include <audio.h>
|
|---|
| 27 |
|
|---|
| 28 | #include "midistrm.hpp"
|
|---|
| 29 | #include "event.hpp"
|
|---|
| 30 | #include <include.h>
|
|---|
| 31 |
|
|---|
| 32 | #include <devhelp.h>
|
|---|
| 33 | #include "trace.h"
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 | /*
|
|---|
| 37 | #define DDCMD_SETUP 0L
|
|---|
| 38 | #define DDCMD_READ 1L
|
|---|
| 39 | #define DDCMD_WRITE 2L
|
|---|
| 40 | #define DDCMD_STATUS 3L
|
|---|
| 41 | #define DDCMD_CONTROL 4L
|
|---|
| 42 | #define DDCMD_REG_STREAM 5L
|
|---|
| 43 | #define DDCMD_DEREG_STREAM 6L
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 | #define DDCMD_START 1 start device
|
|---|
| 47 | #define DDCMD_STOP 2 stop device and return current posi
|
|---|
| 48 | #define DDCMD_PAUSE 3 pause device and return current pos
|
|---|
| 49 | #define DDCMD_RESUME 4 resume device
|
|---|
| 50 | #define DDCMD_ENABLE_EVENT 5 ask PDD to create this event
|
|---|
| 51 | #define DDCMD_DISABLE_EVENT 6 ask PDD to purge this event
|
|---|
| 52 | #define DDCMD_PAUSE_TIME 7 pause time keeping, but not the str
|
|---|
| 53 | #define DDCMD_RESUME_TIME 8 resume time keeping.
|
|---|
| 54 | */
|
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 | extern "C" ULONG __far __loadds __cdecl DDCMD_EntryPoint(PDDCMDCOMMON pCommon)
|
|---|
| 58 | {
|
|---|
| 59 | ULONG ulReturnCode = NO_ERROR;
|
|---|
| 60 | PSTREAM pstream=FindStream(pCommon->hStream);
|
|---|
| 61 |
|
|---|
| 62 | #ifndef NOTRACE
|
|---|
| 63 | struct { ULONG hStream; ULONG ulStream; ULONG ulFunction; ULONG ulParameter; } TraceData;
|
|---|
| 64 |
|
|---|
| 65 | if( pCommon->ulFunction != DDCMD_READ &&
|
|---|
| 66 | pCommon->ulFunction != DDCMD_WRITE &&
|
|---|
| 67 | pCommon->ulFunction != DDCMD_STATUS )
|
|---|
| 68 | {
|
|---|
| 69 | TraceData.hStream = pCommon->hStream;
|
|---|
| 70 | TraceData.ulStream = (ULONG)pstream;
|
|---|
| 71 | TraceData.ulFunction = pCommon->ulFunction;
|
|---|
| 72 | TraceData.ulParameter = 0;
|
|---|
| 73 | if( pCommon->ulFunction != DDCMD_CONTROL ) SYSTRACE(241, 10, TraceData);
|
|---|
| 74 | }
|
|---|
| 75 | #endif
|
|---|
| 76 |
|
|---|
| 77 | switch (pCommon->ulFunction) {
|
|---|
| 78 |
|
|---|
| 79 | case DDCMD_SETUP: {
|
|---|
| 80 | if (!pstream)
|
|---|
| 81 | return ERROR_INVALID_STREAM;
|
|---|
| 82 | PDDCMDSETUP p = (PDDCMDSETUP) pCommon;
|
|---|
| 83 | SETUP_PARM __far *psp = (SETUP_PARM __far *) p->pSetupParm;
|
|---|
| 84 | pstream->SetCurrentTime(psp->ulStreamTime);
|
|---|
| 85 |
|
|---|
| 86 | // if there is a flags field in the SETUP_PARM
|
|---|
| 87 | // the tell MMPM it can send us 'RECURRING' events....
|
|---|
| 88 | if (p->ulSetupParmSize > sizeof(ULONG)) {
|
|---|
| 89 | psp->ulFlags = SETUP_RECURRING_EVENTS;
|
|---|
| 90 | }
|
|---|
| 91 | break;
|
|---|
| 92 | }
|
|---|
| 93 | case DDCMD_READ: {
|
|---|
| 94 | PDDCMDREADWRITE p=(PDDCMDREADWRITE) pCommon;
|
|---|
| 95 |
|
|---|
| 96 | if (!pstream)
|
|---|
| 97 | return ERROR_INVALID_STREAM;
|
|---|
| 98 | ulReturnCode =
|
|---|
| 99 | pstream->Read((PSTREAMBUF) p->pBuffer,(unsigned) p->ulBufferSize);
|
|---|
| 100 | if (ulReturnCode)
|
|---|
| 101 | return ulReturnCode;
|
|---|
| 102 | break;
|
|---|
| 103 | }
|
|---|
| 104 | case DDCMD_WRITE: {
|
|---|
| 105 | PDDCMDREADWRITE p=(PDDCMDREADWRITE) pCommon;
|
|---|
| 106 |
|
|---|
| 107 | if (!pstream)
|
|---|
| 108 | return ERROR_INVALID_STREAM;
|
|---|
| 109 | ulReturnCode =
|
|---|
| 110 | pstream->Write((PSTREAMBUF) p->pBuffer,(unsigned) p->ulBufferSize);
|
|---|
| 111 | if (ulReturnCode)
|
|---|
| 112 | return ulReturnCode;
|
|---|
| 113 | break;
|
|---|
| 114 | }
|
|---|
| 115 | case DDCMD_STATUS: {
|
|---|
| 116 | PDDCMDSTATUS p = (PDDCMDSTATUS) pCommon;
|
|---|
| 117 | PSTATUS_PARM p2 = (PSTATUS_PARM) p->pStatus;
|
|---|
| 118 |
|
|---|
| 119 | if (!pstream)
|
|---|
| 120 | return ERROR_INVALID_STREAM;
|
|---|
| 121 | p2->ulTime = pstream->GetCurrentTime();
|
|---|
| 122 | break;
|
|---|
| 123 | }
|
|---|
| 124 | case DDCMD_CONTROL: {
|
|---|
| 125 | PDDCMDCONTROL p = (PDDCMDCONTROL) pCommon;
|
|---|
| 126 |
|
|---|
| 127 | if (!pstream)
|
|---|
| 128 | return ERROR_INVALID_STREAM;
|
|---|
| 129 |
|
|---|
| 130 | #ifndef NOTRACE
|
|---|
| 131 | TraceData.ulParameter = p->ulCmd;
|
|---|
| 132 | SYSTRACE(241, 11, TraceData);
|
|---|
| 133 | #endif
|
|---|
| 134 |
|
|---|
| 135 | switch (p->ulCmd) {
|
|---|
| 136 | case DDCMD_START:
|
|---|
| 137 | return pstream->StartStream();
|
|---|
| 138 | case DDCMD_STOP:
|
|---|
| 139 | p->ulParmSize=sizeof(ULONG);
|
|---|
| 140 | return pstream->StopStream((PCONTROL_PARM)p->pParm);
|
|---|
| 141 | case DDCMD_PAUSE:
|
|---|
| 142 | p->ulParmSize=sizeof(ULONG);
|
|---|
| 143 | return pstream->PauseStream((PCONTROL_PARM)p->pParm);
|
|---|
| 144 | case DDCMD_RESUME:
|
|---|
| 145 | return pstream->ResumeStream();
|
|---|
| 146 | case DDCMD_ENABLE_EVENT:
|
|---|
| 147 | return pstream->EnableEvent(p);
|
|---|
| 148 | case DDCMD_DISABLE_EVENT:
|
|---|
| 149 | return pstream->DisableEvent(p);
|
|---|
| 150 | case DDCMD_PAUSE_TIME:
|
|---|
| 151 | return pstream->PauseStreamTime();
|
|---|
| 152 | case DDCMD_RESUME_TIME:
|
|---|
| 153 | return pstream->ResumeStreamTime();
|
|---|
| 154 | default:
|
|---|
| 155 | return ERROR_INVALID_REQUEST;
|
|---|
| 156 | } /* endswitch */
|
|---|
| 157 | }
|
|---|
| 158 | case DDCMD_REG_STREAM: {
|
|---|
| 159 | if (pstream)
|
|---|
| 160 | return ERROR_HNDLR_REGISTERED;
|
|---|
| 161 | pstream = FindStream_fromFile((USHORT)((PDDCMDREGISTER) pCommon)->ulSysFileNum);
|
|---|
| 162 | if (!pstream)
|
|---|
| 163 | return ERROR_STREAM_CREATION;
|
|---|
| 164 | ulReturnCode = pstream->Register((PDDCMDREGISTER) pCommon);
|
|---|
| 165 | if (ulReturnCode)
|
|---|
| 166 | return ERROR_STREAM_CREATION;
|
|---|
| 167 | break;
|
|---|
| 168 | }
|
|---|
| 169 | case DDCMD_DEREG_STREAM:
|
|---|
| 170 | if (!pstream)
|
|---|
| 171 | return ERROR_INVALID_STREAM;
|
|---|
| 172 | pstream->DeRegister();
|
|---|
| 173 | break;
|
|---|
| 174 | default:
|
|---|
| 175 | return ERROR_INVALID_FUNCTION;
|
|---|
| 176 | }
|
|---|
| 177 |
|
|---|
| 178 | return NO_ERROR;
|
|---|
| 179 | }
|
|---|
| 180 |
|
|---|
| 181 |
|
|---|