| 1 | /* $Id: waveoutbase.cpp,v 1.1 2001-03-23 16:23:45 sandervl Exp $ */ | 
|---|
| 2 |  | 
|---|
| 3 | /* | 
|---|
| 4 | * Wave playback class (DART) | 
|---|
| 5 | * | 
|---|
| 6 | * Copyright 1998-2001 Sander van Leeuwen (sandervl@xs4all.nl) | 
|---|
| 7 | * | 
|---|
| 8 | * | 
|---|
| 9 | * Project Odin Software License can be found in LICENSE.TXT | 
|---|
| 10 | * | 
|---|
| 11 | * Note: | 
|---|
| 12 | * 2000/11/24 PH MCI_MIXSETUP_PARMS->pMixWrite does alter FS: selector! | 
|---|
| 13 | * | 
|---|
| 14 | */ | 
|---|
| 15 |  | 
|---|
| 16 |  | 
|---|
| 17 | /**************************************************************************** | 
|---|
| 18 | * Includes                                                                 * | 
|---|
| 19 | ****************************************************************************/ | 
|---|
| 20 |  | 
|---|
| 21 |  | 
|---|
| 22 |  | 
|---|
| 23 | #define  INCL_BASE | 
|---|
| 24 | #define  INCL_OS2MM | 
|---|
| 25 | #include <os2wrap.h>   //Odin32 OS/2 api wrappers | 
|---|
| 26 | #include <os2mewrap.h> //Odin32 OS/2 MMPM/2 api wrappers | 
|---|
| 27 | #include <stdlib.h> | 
|---|
| 28 | #include <string.h> | 
|---|
| 29 | #define  OS2_ONLY | 
|---|
| 30 | #include <win32api.h> | 
|---|
| 31 | #include <wprocess.h> | 
|---|
| 32 |  | 
|---|
| 33 | #include "misc.h" | 
|---|
| 34 | #include "waveoutbase.h" | 
|---|
| 35 |  | 
|---|
| 36 | #define DBG_LOCALLOG    DBG_waveoutbase | 
|---|
| 37 | #include "dbglocal.h" | 
|---|
| 38 |  | 
|---|
| 39 | #ifndef min | 
|---|
| 40 | #define min(a, b) ((a > b) ? b : a) | 
|---|
| 41 | #endif | 
|---|
| 42 |  | 
|---|
| 43 | #ifndef max | 
|---|
| 44 | #define max(a, b) ((a > b) ? a : b) | 
|---|
| 45 | #endif | 
|---|
| 46 |  | 
|---|
| 47 | //TODO: mulaw, alaw & adpcm | 
|---|
| 48 | /******************************************************************************/ | 
|---|
| 49 | /******************************************************************************/ | 
|---|
| 50 | WaveOut::WaveOut(LPWAVEFORMATEX pwfx, ULONG fdwOpen, ULONG nCallback, ULONG dwInstance) | 
|---|
| 51 | : WaveInOut(pwfx, fdwOpen, nCallback, dwInstance) | 
|---|
| 52 | { | 
|---|
| 53 | bytesPlayed = bytesCopied = bytesReturned = 0; | 
|---|
| 54 |  | 
|---|
| 55 | volume = defvolume; | 
|---|
| 56 |  | 
|---|
| 57 | dprintf(("waveOutOpen: samplerate %d, numChan %d bps %d (%d), format %x", SampleRate, nChannels, BitsPerSample, pwfx->nBlockAlign, pwfx->wFormatTag)); | 
|---|
| 58 | } | 
|---|
| 59 | /******************************************************************************/ | 
|---|
| 60 | /******************************************************************************/ | 
|---|
| 61 | WaveOut::~WaveOut() | 
|---|
| 62 | { | 
|---|
| 63 | } | 
|---|
| 64 | /******************************************************************************/ | 
|---|
| 65 | /******************************************************************************/ | 
|---|
| 66 | int WaveOut::getNumDevices() | 
|---|
| 67 | { | 
|---|
| 68 | MCI_GENERIC_PARMS  GenericParms; | 
|---|
| 69 | MCI_AMP_OPEN_PARMS AmpOpenParms; | 
|---|
| 70 | APIRET rc; | 
|---|
| 71 |  | 
|---|
| 72 | // Setup the open structure, pass the playlist and tell MCI_OPEN to use it | 
|---|
| 73 | memset(&AmpOpenParms,0,sizeof(AmpOpenParms)); | 
|---|
| 74 |  | 
|---|
| 75 | AmpOpenParms.usDeviceID = ( USHORT ) 0; | 
|---|
| 76 | AmpOpenParms.pszDeviceType = ( PSZ ) MCI_DEVTYPE_AUDIO_AMPMIX; | 
|---|
| 77 |  | 
|---|
| 78 | rc = mciSendCommand(0, MCI_OPEN, | 
|---|
| 79 | MCI_WAIT | MCI_OPEN_TYPE_ID | MCI_OPEN_SHAREABLE, | 
|---|
| 80 | (PVOID) &AmpOpenParms, | 
|---|
| 81 | 0); | 
|---|
| 82 |  | 
|---|
| 83 | if(rc) { | 
|---|
| 84 | return 0; //no devices present | 
|---|
| 85 | } | 
|---|
| 86 |  | 
|---|
| 87 | // Generic parameters | 
|---|
| 88 | GenericParms.hwndCallback = 0;   //hwndFrame | 
|---|
| 89 |  | 
|---|
| 90 | // Close the device | 
|---|
| 91 | mciSendCommand(AmpOpenParms.usDeviceID, MCI_CLOSE, MCI_WAIT, (PVOID)&GenericParms, 0); | 
|---|
| 92 |  | 
|---|
| 93 | return 1; | 
|---|
| 94 | } | 
|---|
| 95 | /******************************************************************************/ | 
|---|
| 96 | //Called if waveOutSetVolume is called by the application with waveout handle NULL | 
|---|
| 97 | //Sets the default volume of each waveout stream (until it's volume is changed | 
|---|
| 98 | //with an appropriate waveOutSetVolume call) | 
|---|
| 99 | /******************************************************************************/ | 
|---|
| 100 | void WaveOut::setDefaultVolume(ULONG volume) | 
|---|
| 101 | { | 
|---|
| 102 | defvolume = volume; | 
|---|
| 103 | } | 
|---|
| 104 | /******************************************************************************/ | 
|---|
| 105 | /******************************************************************************/ | 
|---|
| 106 | ULONG WaveOut::defvolume = 0xFFFFFFFF; | 
|---|
| 107 |  | 
|---|