source: trunk/stream_ioproc/source/testproc.c@ 4

Last change on this file since 4 was 4, checked in by stevenhl, 8 years ago

Import modifications from cwmm-0_2_9-work-01_10_2006.zip dated 2006-08-27

File size: 6.2 KB
Line 
1/* This program (install.c) is Public Domain */
2
3#define INCL_OS2MM
4#define INCL_DOS
5#include <os2.h>
6#include <os2me.h>
7#include <string.h>
8#include <stdlib.h>
9#include <stdio.h>
10#include "streamproc.h"
11
12
13//#include <minstall.h>
14//If you don't have minstall.h, this is all that is needed
15typedef struct _INSTMCISENDCOMMAND
16 {
17 USHORT wDeviceID;
18 USHORT wMessage;
19 ULONG dwParam1;
20 ULONG dwParam2;
21 USHORT wUserParm;
22 } INSTMCISENDCOMMAND;
23
24typedef INSTMCISENDCOMMAND *PINSTMCISENDCOMMAND;
25#define IM_MCI_SEND_COMMAND 0x057C
26#define IM_MCI_EXTENDED_SYSINFO 0x057E
27#define IM_LOG_ERROR 0x0573
28
29
30int deleteProc(char *Fourcc) {
31 MMINIFILEINFO mmIniFileInfo;
32 ULONG ulFlags = 0L;
33 ULONG rc;
34
35 memset( &mmIniFileInfo, '\0', sizeof(MMINIFILEINFO) );
36 mmIniFileInfo.fccIOProc = mmioStringToFOURCC(Fourcc,0);
37 ulFlags = MMIO_FINDPROC;
38 rc = mmioIniFileHandler( &mmIniFileInfo,
39 ulFlags);
40 if (rc) {
41 printf("Couldn't find IOProc %s. Code: %ld\n",Fourcc,rc);
42 return rc;
43 }
44
45 ulFlags = MMIO_REMOVEPROC;
46 rc = mmioIniFileHandler( &mmIniFileInfo,
47 ulFlags);
48 if (rc) {
49 printf("Couldn't remove IOProc %s. Code: %ld\n",Fourcc,rc);
50 return rc;
51 } else {
52 printf("Removed IOProc %s.\n",Fourcc);
53 } /* endif */
54
55 {
56 char dllname[DLLNAME_SIZE] = "DLL\\";
57 char fulldllname[DLLNAME_SIZE] = "";
58
59 strncat(dllname, mmIniFileInfo.szDLLName,sizeof(dllname));
60 strncat(dllname, ".DLL",sizeof(dllname));
61 rc = DosSearchPath(2,"MMBASE",dllname,fulldllname,sizeof(fulldllname));
62 if (rc) {
63 printf("Couldn't find %s. code:%ld\n", dllname,rc);
64 return rc;
65 }
66
67 rc = DosReplaceModule(fulldllname,NULL,NULL);
68 if (rc) {
69 printf("Couldn't unlock %s. code:%ld\n", fulldllname,rc);
70 } else {
71 printf("Unlocked %s.\n", fulldllname);
72 } /* endif */
73
74 rc = DosDelete(fulldllname);
75 if (rc) {
76 printf("Couldn't delete %s. code:%ld\n", fulldllname,rc);
77 return rc;
78 } else {
79 printf("Deleted %s.\n", fulldllname);
80 } /* endif */
81 }
82
83 return 0;
84}
85
86int queryNumStorageProcs(void)
87{
88 MMFORMATINFO mmfinfo;
89 LONG lNum=0;
90
91 printf("In %s().\n", __FUNCTION__);
92
93 memset( &mmfinfo, '\0', sizeof(MMFORMATINFO) );
94 // mmfinfo.ulIOProcType=MMIO_IOPROC_STORAGESYSTEM;
95 //mmfinfo.ulMediaType=MMIO_MEDIATYPE_AUDIO;
96
97 mmioQueryFormatCount(&mmfinfo, &lNum, 0, 0);
98 return lNum;
99}
100
101int queryNumFormatProcs(void)
102{
103 MMFORMATINFO mmfinfo;
104 LONG lNum=0;
105
106 memset( &mmfinfo, '\0', sizeof(MMFORMATINFO) );
107 mmfinfo.ulIOProcType=MMIO_IOPROC_STORAGESYSTEM;
108 mmfinfo.ulMediaType=MMIO_MEDIATYPE_AUDIO;
109
110 mmioQueryFormatCount(&mmfinfo, &lNum, 0, 0);
111 return lNum;
112}
113
114BOOL getFormats(LONG lNum)
115{
116 MMFORMATINFO mmfinfo;
117 PMMFORMATINFO pmmfi;
118
119 LONG lFormatsRead;
120 int a;
121
122 memset( &mmfinfo, '\0', sizeof(MMFORMATINFO) );
123 mmfinfo.ulIOProcType=MMIO_IOPROC_STORAGESYSTEM;
124 // mmfinfo.ulMediaType=MMIO_MEDIATYPE_AUDIO;
125
126 if((pmmfi=(PMMFORMATINFO)malloc(lNum*sizeof(MMFORMATINFO)))==NULLHANDLE)
127 return FALSE;
128
129 printf("mmioGetFormats() returned: %d \n",
130 mmioGetFormats(&mmfinfo, lNum, pmmfi, &lFormatsRead,0,0));
131
132 printf("Info for %d formats read.\n\n", lFormatsRead);
133
134 for(a=0;a<lFormatsRead;a++)
135 {
136 char name[1000];
137 LONG lBytesRead;
138
139 if(0==mmioGetFormatName(pmmfi, name, &lBytesRead, 0L, 0L))
140 {
141 name[lBytesRead]=0;
142 printf("%2d: %s\n", a+1, name);
143 }
144 else
145 printf("%2d: Can't get format name\n", a+1);
146 pmmfi++;
147 }
148 return TRUE;
149}
150
151int installProc(char * dllPath) {
152 MMINIFILEINFO mmIniFileInfo;
153 ULONG ulFlags = 0L;
154 ULONG rc;
155
156#if 0
157
158 memset( &mmIniFileInfo, '\0', sizeof(MMINIFILEINFO) );
159 mmIniFileInfo.fccIOProc = FOURCC_STREAM;//mmioStringToFOURCC(,0);
160 ulFlags = MMIO_FINDPROC;
161 rc = mmioIniFileHandler( &mmIniFileInfo,
162 ulFlags);
163 if (rc) {
164 printf("Couldn't find IOProc %s. Code: %ld\n",Fourcc,rc);
165 return rc;
166 }
167
168 ulFlags = MMIO_REMOVEPROC;
169 rc = mmioIniFileHandler( &mmIniFileInfo,
170 ulFlags);
171 if (rc) {
172 printf("Couldn't remove IOProc %s. Code: %ld\n",Fourcc,rc);
173 return rc;
174 } else {
175 printf("Removed IOProc %s.\n",Fourcc);
176 } /* endif */
177
178 {
179 char dllname[DLLNAME_SIZE] = "DLL\\";
180 char fulldllname[DLLNAME_SIZE] = "";
181
182 strncat(dllname, mmIniFileInfo.szDLLName,sizeof(dllname));
183 strncat(dllname, ".DLL",sizeof(dllname));
184 rc = DosSearchPath(2,"MMBASE",dllname,fulldllname,sizeof(fulldllname));
185 if (rc) {
186 printf("Couldn't find %s. code:%ld\n", dllname,rc);
187 return rc;
188 }
189
190 rc = DosReplaceModule(fulldllname,NULL,NULL);
191 if (rc) {
192 printf("Couldn't unlock %s. code:%ld\n", fulldllname,rc);
193 } else {
194 printf("Unlocked %s.\n", fulldllname);
195 } /* endif */
196
197 rc = DosDelete(fulldllname);
198 if (rc) {
199 printf("Couldn't delete %s. code:%ld\n", fulldllname,rc);
200 return rc;
201 } else {
202 printf("Deleted %s.\n", fulldllname);
203 } /* endif */
204 }
205#endif
206 return 0;
207}
208
209void checkForIOProc(FOURCC fourcc1)
210{
211 PMMIOPROC pIOProc1=NULLHANDLE;
212 ULONG ulFlags;
213
214 ulFlags= MMIO_FINDPROC;
215 pIOProc1= mmioInstallIOProc (fourcc1, pIOProc1, ulFlags);
216 // pIOProc1= mmioInstallIOProc (0x4745504a, pIOProc1, ulFlags);
217 if (!pIOProc1)
218 /* I/O Procedure NOT FOUND */
219 printf("IO-Proc NOT found 0x%x 0x%x\n", pIOProc1, fourcc1);
220 else
221 printf("IO-Proc found!!!\n");
222 /* I/O Procedure found */
223}
224int main(int argc, char **argv) {
225
226 printf("Test stream io proc...\n\n");
227
228 printf("Number of installed storage procs: %d\n", queryNumStorageProcs());
229 getFormats(queryNumStorageProcs());
230 checkForIOProc(mmioStringToFOURCC("WAVE",0));
231
232 // getFormats(45);
233 installProc("STREAMIO.DLL");
234 return 0;
235}
236
237
238
Note: See TracBrowser for help on using the repository browser.