source: cmedia/trunk/Testapp/daudio.cpp

Last change on this file was 354, checked in by stevenhl, 17 years ago

Import untested baseline cmedia sources, work products and binaries
Binaries and work products should be deleted from repository.
once new builds are verified to work.

File size: 2.3 KB
Line 
1 #define INCL_DOSDEVIOCTL
2 #define INCL_DOSDEVICES
3#define INCL_DOSPROCESS
4#define INCL_VIO
5#define INCL_DOSMEMMGR
6#define INCL_DOSSESMGR
7#define INCL_DOSMISC
8#define INCL_DOSDEVICES
9#define INCL_DOS
10#define INCL_DOSMODULEMGR
11
12#include <os2.h>
13#include <audio.h>
14
15// C RunTime Header Files
16#include <stdio.h>
17#include <stdlib.h>
18#include <string.h>
19#include <malloc.h>
20#include <memory.h>
21
22#include <daudio.h>
23
24HFILE hSBLive = 0;
25
26int main(int argc, char *argv[])
27{
28 APIRET rc;
29 ULONG action;
30
31 rc = DosOpen( "CMPCI1$", &hSBLive, &action, 0,
32 FILE_NORMAL, FILE_OPEN, OPEN_ACCESS_READWRITE |
33 OPEN_SHARE_DENYNONE | OPEN_FLAGS_WRITE_THROUGH,
34 NULL );
35 if(rc) {
36 printf("DosOpen failed with error %d\n", rc);
37 return 1;
38 }
39
40 ULONG ParmLength = 0, DataLength;
41
42 MCI_AUDIO_INIT init = {0};
43 DataLength = sizeof(init);
44
45 init.lSRate = 44100;
46 init.lBitsPerSRate = 16;
47 init.sChannels = 2;
48 init.sMode = PCM;
49 rc = DosDevIOCtl(hSBLive, DAUDIO_IOCTL_CAT, DAUDIO_QUERYFORMAT, NULL, 0,
50 &ParmLength, &init, DataLength, &DataLength);
51
52 if(rc) {
53 printf("DosDevIOCtl failed with error %d\n", rc);
54 goto fail;
55 }
56 if(init.sReturnCode != 0) {
57 printf("init.sReturnCode = %d\n", init.sReturnCode);
58 goto fail;
59 }
60 printf("Query format successfull for %d hz, %d bps & %d channels\n", init.lSRate, init.lBitsPerSRate, init.sChannels);
61
62 printf("Creating stream..\n");
63 rc = DosDevIOCtl(hSBLive, DAUDIO_IOCTL_CAT, DAUDIO_OPEN, NULL, 0,
64 &ParmLength, &init, DataLength, &DataLength);
65 if(rc) {
66 printf("DosDevIOCtl failed with error %d\n", rc);
67 goto fail;
68 }
69
70 DAUDIO_CMD cmd;
71 DataLength = sizeof(cmd);
72
73
74 rc = DosDevIOCtl(hSBLive, DAUDIO_IOCTL_CAT, DAUDIO_GETPOS, NULL, 0,
75 &ParmLength, &cmd, DataLength, &DataLength);
76 if(rc) {
77 printf("DosDevIOCtl failed with error %d\n", rc);
78 goto fail;
79 }
80 printf("Current stream position = %d\n", cmd.Pos.ulCurrentPos);
81
82 rc = DosDevIOCtl(hSBLive, DAUDIO_IOCTL_CAT, DAUDIO_CLOSE, NULL, 0,
83 &ParmLength, &cmd, DataLength, &DataLength);
84
85 DosClose(hSBLive);
86 return 0;
87
88fail:
89 DosClose(hSBLive);
90 return 1;
91}
92
Note: See TracBrowser for help on using the repository browser.