1 | /* $Id: auxos2.cpp,v 1.4 1999-06-19 10:54:47 sandervl Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * Auxilary multimedia OS/2 implementation
|
---|
5 | *
|
---|
6 | * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
|
---|
7 | *
|
---|
8 | *
|
---|
9 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
10 | *
|
---|
11 | */
|
---|
12 |
|
---|
13 | #define INCL_BASE
|
---|
14 | #define INCL_OS2MM
|
---|
15 | #include <os2wrap.h> //Odin32 OS/2 api wrappers
|
---|
16 | #include <os2me.h>
|
---|
17 | #include <string.h>
|
---|
18 |
|
---|
19 | #define OS2_ONLY
|
---|
20 | #include "win32type.h"
|
---|
21 | #include "misc.h"
|
---|
22 | #include "unicode.h"
|
---|
23 |
|
---|
24 | #include "aux.h"
|
---|
25 |
|
---|
26 | ULONG auxDeviceId = -1;
|
---|
27 |
|
---|
28 | /******************************************************************************/
|
---|
29 | /******************************************************************************/
|
---|
30 | BOOL auxOS2Open()
|
---|
31 | {
|
---|
32 | MCI_AMP_OPEN_PARMS AmpOpenParms;
|
---|
33 | APIRET rc;
|
---|
34 |
|
---|
35 | if(auxDeviceId != -1) {
|
---|
36 | return TRUE;
|
---|
37 | }
|
---|
38 | // Setup the open structure, pass the playlist and tell MCI_OPEN to use it
|
---|
39 | memset(&AmpOpenParms,0,sizeof(AmpOpenParms));
|
---|
40 |
|
---|
41 | AmpOpenParms.usDeviceID = ( USHORT ) 0;
|
---|
42 | AmpOpenParms.pszDeviceType = ( PSZ ) MCI_DEVTYPE_AUDIO_AMPMIX;
|
---|
43 |
|
---|
44 | rc = mciSendCommand(0, MCI_OPEN,
|
---|
45 | MCI_WAIT | MCI_OPEN_TYPE_ID | MCI_OPEN_SHAREABLE,
|
---|
46 | (PVOID) &AmpOpenParms,
|
---|
47 | 0);
|
---|
48 | if(rc) {
|
---|
49 | dprintf(("auxOpen: MCI_OPEN returned %X\n", rc));
|
---|
50 | return(FALSE);
|
---|
51 | }
|
---|
52 | auxDeviceId = AmpOpenParms.usDeviceID;
|
---|
53 | return(TRUE);
|
---|
54 | }
|
---|
55 | /******************************************************************************/
|
---|
56 | /******************************************************************************/
|
---|
57 | void auxOS2Close()
|
---|
58 | {
|
---|
59 | MCI_GENERIC_PARMS GenericParms;
|
---|
60 |
|
---|
61 | if(auxDeviceId == -1)
|
---|
62 | return;
|
---|
63 |
|
---|
64 | // Generic parameters
|
---|
65 | GenericParms.hwndCallback = 0; //hwndFrame
|
---|
66 |
|
---|
67 | // Close the device
|
---|
68 | mciSendCommand(auxDeviceId, MCI_CLOSE, MCI_WAIT, (PVOID)&GenericParms, 0);
|
---|
69 | }
|
---|
70 | /******************************************************************************/
|
---|
71 | /******************************************************************************/
|
---|
72 | DWORD auxOS2SetVolume(DWORD dwVolume)
|
---|
73 | {
|
---|
74 | MCI_MASTERAUDIO_PARMS maudio = {0};
|
---|
75 | APIRET rc;
|
---|
76 |
|
---|
77 | maudio.ulMasterVolume = (dwVolume*100)/65536; //TODO: Not correct, should be logartihmic
|
---|
78 | rc = mciSendCommand(auxDeviceId, MCI_MASTERAUDIO, MCI_MASTERVOL |
|
---|
79 | MCI_WAIT, (PVOID)&maudio,0);
|
---|
80 | if(rc) {
|
---|
81 | dprintf(("auxOS2SetVolume returned %X\n", rc));
|
---|
82 | }
|
---|
83 | return(0); //MMSYSERR_NOERROR
|
---|
84 | }
|
---|
85 | /******************************************************************************/
|
---|
86 | /******************************************************************************/
|
---|
87 | DWORD auxOS2GetVolume(DWORD *dwVolume)
|
---|
88 | {
|
---|
89 | MCI_MASTERAUDIO_PARMS maudio = {0};
|
---|
90 | APIRET rc;
|
---|
91 |
|
---|
92 | rc = mciSendCommand(auxDeviceId, MCI_MASTERAUDIO, MCI_QUERYCURRENTSETTING |
|
---|
93 | MCI_MASTERVOL | MCI_WAIT, (PVOID)&maudio,0);
|
---|
94 | if(rc) {
|
---|
95 | dprintf(("auxOS2GetVolume returned %X\n", rc));
|
---|
96 | }
|
---|
97 | *dwVolume = (maudio.ulReturn*65536)/100;
|
---|
98 | return(0); //MMSYSERR_NOERROR
|
---|
99 | }
|
---|
100 | /******************************************************************************/
|
---|
101 | /******************************************************************************/
|
---|