source: sbliveos2/trunk/drv16/strategy.cpp@ 148

Last change on this file since 148 was 147, checked in by sandervl, 25 years ago

Fixed wave volume, recording gain + wave recording

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 KB
Line 
1/* $Id: strategy.cpp 147 2000-04-24 19:45:21Z sandervl $ */
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 * The Strategy entry point lives here !!
17 * @version %I%
18 * @context Unless otherwise noted, all interfaces are Ring-0, 16-bit,
19 * kernel stack.
20 * @history
21 *
22 */
23extern "C" { // 16-bit header files are not C++ aware
24#define INCL_NOPMAPI
25#define INCL_DOSINFOSEG
26#include <os2.h>
27#include <audio.h>
28#include <os2medef.h>
29}
30
31#include <include.h>
32#include <devhelp.h>
33#include "strategy.h"
34#include "rtmidi.hpp" // Object definition
35#include "end.h"
36
37// #include "ioctl.h"
38#include "stream.hpp"
39#include "idc_vdd.h"
40#include <ossidc.h>
41#include <dbgos2.h>
42#include "ioctl.h"
43
44#pragma off (unreferenced)
45
46/*@external StrategyInitComplete
47 * Perform initialization tasks that require Ring 0 context or IDC with other
48 * drivers (InitComplete is called after all drivers are loaded). We perform
49 * RTMIDI registration here.
50 */
51
52void StrategyInitComplete(PREQPACKET prp)
53{
54 RTMIDI::vConnect();
55 if(OSS16_AttachToPdd() == FALSE) {
56 prp->usStatus = RPDONE | RPERR | RPGENFAIL;
57 return;
58 }
59 MixerInit();
60}
61
62/* TROPEZ_StrategyOpen
63 *
64 * Purpose: Worker rountine for the Strategy Open function.
65 *
66 * Notes: The Strategy Open doesn't require allocation of any resources,
67 * and the function is treated as a NOP. The first allocation of
68 * resources happens at Strategy IOCtl time, in the handler for
69 * the AudioInit IOCtl.
70 * Check to see if the VDD has claimed the hardware and return with
71 * the busy bit on the the request packett.
72 * Increment the InUseCount so we know that an OS/2 app has an
73 * instance open and we don't let the VDD take the hardware..
74 *
75 *
76 *
77 */
78void StrategyOpen(PREQPACKET prp)
79{
80 if (usVDDHasHardware) {
81 prp->usStatus = RPDONE | RPERR | RPBUSY;
82 }
83 else {
84 ++usInUseCount;
85 }
86}
87
88void StrategyClose(PREQPACKET prp)
89{
90 --usInUseCount;
91 PSTREAM pstream = FindStream_fromFile( prp->s.open_close.usSysFileNum );
92 if (pstream)
93 delete pstream;
94 else
95 ; //### Log unexpected condition.
96}
97
98void StrategyDeinstall(PREQPACKET prp)
99{
100
101 while (pAudioHWList->IsElements())
102 pAudioHWList->DestroyElement(pAudioHWList->PopHead());
103}
104
105#pragma on (unreferenced)
106
107void StrategyInit(PREQPACKET prp);
108extern "C" void StrategyIoctl(PREQPACKET prp, USHORT LDev);
109
110extern "C" void __far StrategyHandler(PREQPACKET prp);
111#pragma aux StrategyHandler parm [es bx];
112
113extern "C" void __far StrategyHandler(PREQPACKET prp)
114{
115
116 prp->usStatus = RPDONE;
117
118 switch (prp->bCommand) {
119 case STRATEGY_INIT:
120 StrategyInit(prp);
121 break;
122 case STRATEGY_OPEN:
123 StrategyOpen(prp);
124 break;
125 case STRATEGY_CLOSE:
126 StrategyClose(prp);
127 break;
128 case STRATEGY_GENIOCTL:
129 StrategyIoctl(prp, 0);
130 break;
131 case STRATEGY_DEINSTALL:
132 StrategyDeinstall(prp);
133 break;
134 case STRATEGY_INITCOMPLETE:
135 StrategyInitComplete(prp);
136 break;
137 default:
138 prp->usStatus = RPDONE | RPERR | RPGENFAIL;
139 }
140}
141
142extern "C" void __far StrategyHandler2(PREQPACKET prp);
143#pragma aux StrategyHandler2 parm [es bx];
144
145extern "C" void __far StrategyHandler2(PREQPACKET prp)
146{
147
148 prp->usStatus = RPDONE;
149
150 switch (prp->bCommand) {
151 case STRATEGY_INIT:
152 prp->usStatus = RPDONE;
153 prp->s.init_out.usCodeEnd = (USHORT) &end_of_text;
154 prp->s.init_out.usDataEnd = (USHORT) &end_of_heap;
155 break;
156 case STRATEGY_OPEN:
157 StrategyOpen(prp);
158 break;
159 case STRATEGY_CLOSE:
160 StrategyClose(prp);
161 break;
162 case STRATEGY_GENIOCTL:
163 StrategyIoctl(prp, 1);
164 break;
165 case STRATEGY_DEINSTALL:
166 StrategyDeinstall(prp);
167 break;
168 case STRATEGY_INITCOMPLETE:
169 prp->usStatus = RPDONE;
170 break;
171 default:
172 prp->usStatus = RPDONE | RPERR | RPGENFAIL;
173 }
174}
Note: See TracBrowser for help on using the repository browser.