1 | /* $Id: ssm_idc.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 | * @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 |
|
---|
33 | extern "C" ULONG __far __loadds __cdecl DDCMD_EntryPoint(PDDCMDCOMMON pCommon)
|
---|
34 | {
|
---|
35 | ULONG ulReturnCode = NO_ERROR;
|
---|
36 | PSTREAM pstream=FindStream(pCommon->hStream);
|
---|
37 |
|
---|
38 | switch (pCommon->ulFunction) {
|
---|
39 |
|
---|
40 | case DDCMD_SETUP: {
|
---|
41 | if (!pstream)
|
---|
42 | return ERROR_INVALID_STREAM;
|
---|
43 | PDDCMDSETUP p = (PDDCMDSETUP) pCommon;
|
---|
44 | SETUP_PARM __far *psp = (SETUP_PARM __far *) p->pSetupParm;
|
---|
45 | pstream->SetCurrentTime(psp->ulStreamTime);
|
---|
46 |
|
---|
47 | // if there is a flags field in the SETUP_PARM
|
---|
48 | // the tell MMPM it can send us 'RECURRING' events....
|
---|
49 | if (p->ulSetupParmSize > sizeof(ULONG)) {
|
---|
50 | psp->ulFlags = SETUP_RECURRING_EVENTS;
|
---|
51 | }
|
---|
52 | break;
|
---|
53 | }
|
---|
54 | case DDCMD_READ: {
|
---|
55 | PDDCMDREADWRITE p=(PDDCMDREADWRITE) pCommon;
|
---|
56 |
|
---|
57 |
|
---|
58 | if (!pstream)
|
---|
59 | return ERROR_INVALID_STREAM;
|
---|
60 | ulReturnCode =
|
---|
61 | pstream->Read((PSTREAMBUF) p->pBuffer,(unsigned) p->ulBufferSize);
|
---|
62 | if (ulReturnCode)
|
---|
63 | return ulReturnCode;
|
---|
64 | break;
|
---|
65 | }
|
---|
66 | case DDCMD_WRITE: {
|
---|
67 | PDDCMDREADWRITE p=(PDDCMDREADWRITE) pCommon;
|
---|
68 |
|
---|
69 | if (!pstream)
|
---|
70 | return ERROR_INVALID_STREAM;
|
---|
71 | ulReturnCode =
|
---|
72 | pstream->Write((PSTREAMBUF) p->pBuffer,(unsigned) p->ulBufferSize);
|
---|
73 | if (ulReturnCode)
|
---|
74 | return ulReturnCode;
|
---|
75 | break;
|
---|
76 | }
|
---|
77 | case DDCMD_STATUS: {
|
---|
78 |
|
---|
79 | PDDCMDSTATUS p = (PDDCMDSTATUS) pCommon;
|
---|
80 | PSTATUS_PARM p2 = (PSTATUS_PARM) p->pStatus;
|
---|
81 | if (!pstream)
|
---|
82 | return ERROR_INVALID_STREAM;
|
---|
83 | p2->ulTime = pstream->GetCurrentTime();
|
---|
84 | break;
|
---|
85 | }
|
---|
86 | case DDCMD_CONTROL: {
|
---|
87 | PDDCMDCONTROL p = (PDDCMDCONTROL) pCommon;
|
---|
88 | if (!pstream)
|
---|
89 | return ERROR_INVALID_STREAM;
|
---|
90 |
|
---|
91 | switch (p->ulCmd) {
|
---|
92 | case DDCMD_START:
|
---|
93 | return pstream->StartStream();
|
---|
94 | case DDCMD_STOP:
|
---|
95 | p->ulParmSize=sizeof(ULONG);
|
---|
96 | return pstream->StopStream((PCONTROL_PARM)p->pParm);
|
---|
97 | case DDCMD_PAUSE:
|
---|
98 | p->ulParmSize=sizeof(ULONG);
|
---|
99 | return pstream->PauseStream((PCONTROL_PARM)p->pParm);
|
---|
100 | case DDCMD_RESUME:
|
---|
101 | return pstream->ResumeStream();
|
---|
102 | case DDCMD_ENABLE_EVENT:
|
---|
103 | return pstream->EnableEvent(p);
|
---|
104 | case DDCMD_DISABLE_EVENT:
|
---|
105 | return pstream->DisableEvent(p);
|
---|
106 | case DDCMD_PAUSE_TIME:
|
---|
107 | return pstream->PauseStreamTime();
|
---|
108 | case DDCMD_RESUME_TIME:
|
---|
109 | return pstream->ResumeStreamTime();
|
---|
110 | default:
|
---|
111 | return ERROR_INVALID_REQUEST;
|
---|
112 | } /* endswitch */
|
---|
113 | }
|
---|
114 | case DDCMD_REG_STREAM: {
|
---|
115 | if (pstream)
|
---|
116 | return ERROR_HNDLR_REGISTERED;
|
---|
117 | pstream = FindStream_fromFile(((PDDCMDREGISTER) pCommon)->ulSysFileNum);
|
---|
118 | if (!pstream)
|
---|
119 | return ERROR_STREAM_CREATION;
|
---|
120 | ulReturnCode = pstream->Register((PDDCMDREGISTER) pCommon);
|
---|
121 | if (ulReturnCode)
|
---|
122 | return ERROR_STREAM_CREATION;
|
---|
123 | break;
|
---|
124 | }
|
---|
125 | case DDCMD_DEREG_STREAM:
|
---|
126 | if (!pstream)
|
---|
127 | return ERROR_INVALID_STREAM;
|
---|
128 | pstream->DeRegister();
|
---|
129 | break;
|
---|
130 | default:
|
---|
131 | return ERROR_INVALID_FUNCTION;
|
---|
132 | }
|
---|
133 |
|
---|
134 | return NO_ERROR;
|
---|
135 | }
|
---|