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