Changeset 21358 for trunk/src/winmm/waveoutbase.cpp
- Timestamp:
- Feb 22, 2010, 2:44:21 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/winmm/waveoutbase.cpp
r7196 r21358 14 14 */ 15 15 16 17 /**************************************************************************** 18 * Includes * 19 ****************************************************************************/ 20 21 16 /******************************************************************************/ 17 // Includes 18 /******************************************************************************/ 22 19 23 20 #define INCL_BASE … … 38 35 #include "dbglocal.h" 39 36 40 #ifndef min 41 #define min(a, b) ((a > b) ? b : a) 42 #endif 37 /******************************************************************************/ 38 /******************************************************************************/ 43 39 44 #ifndef max 45 #define max(a, b) ((a > b) ? a : b) 46 #endif 40 ULONG WaveOut::defvolume = 0xFFFFFFFF; 47 41 48 //TODO: mulaw, alaw & adpcm49 42 /******************************************************************************/ 50 43 /******************************************************************************/ … … 52 45 : WaveInOut(pwfx, fdwOpen, nCallback, dwInstance) 53 46 { 54 bytesPlayed = bytesCopied = bytesReturned = 0;55 56 47 volume = defvolume; 57 48 … … 67 58 int WaveOut::getNumDevices() 68 59 { 69 MCI_GENERIC_PARMS GenericParms;70 MCI_AMP_OPEN_PARMS AmpOpenParms;71 APIRET rc;60 MCI_AMP_OPEN_PARMS AmpOpenParms; 61 MCI_GENERIC_PARMS GenericParms = {0}; 62 APIRET rc; 72 63 73 // Setup the open structure, pass the playlist and tell MCI_OPEN to use it 74 memset(&AmpOpenParms,0,sizeof(AmpOpenParms)); 64 // Try to open the device to see if it's there 65 memset(&AmpOpenParms, 0, sizeof(AmpOpenParms)); 66 AmpOpenParms.usDeviceID = 0; 67 AmpOpenParms.pszDeviceType = (PSZ)MCI_DEVTYPE_AUDIO_AMPMIX; 75 68 76 AmpOpenParms.usDeviceID = ( USHORT ) 0; 77 AmpOpenParms.pszDeviceType = ( PSZ ) MCI_DEVTYPE_AUDIO_AMPMIX; 69 rc = mymciSendCommand(0, MCI_OPEN, 70 MCI_WAIT | MCI_OPEN_TYPE_ID | MCI_OPEN_SHAREABLE, 71 (PVOID) &AmpOpenParms, 0); 78 72 79 rc = mymciSendCommand(0, MCI_OPEN, 80 MCI_WAIT | MCI_OPEN_TYPE_ID | MCI_OPEN_SHAREABLE, 81 (PVOID) &AmpOpenParms, 82 0); 73 if (LOUSHORT(rc) != MCIERR_SUCCESS) 74 return 0; 83 75 84 if(rc) { 85 return 0; //no devices present 86 } 76 // Close the device 77 mymciSendCommand(AmpOpenParms.usDeviceID, MCI_CLOSE, 78 MCI_WAIT, 79 (PVOID)&GenericParms, 0); 87 80 88 // Generic parameters 89 GenericParms.hwndCallback = 0; //hwndFrame 90 91 // Close the device 92 mymciSendCommand(AmpOpenParms.usDeviceID, MCI_CLOSE, MCI_WAIT, (PVOID)&GenericParms, 0); 93 94 return 1; 81 return 1; 95 82 } 96 83 /******************************************************************************/ 97 //Called if waveOutSetVolume is called by the application with waveout handle NULL 98 //Sets the default volume of each waveout stream (until it's volume is changed 99 //with an appropriate waveOutSetVolume call) 84 /******************************************************************************/ 85 BOOL WaveOut::queryFormat(ULONG formatTag, ULONG nChannels, 86 ULONG nSamplesPerSec, ULONG wBitsPerSample) 87 { 88 APIRET rc; 89 BOOL winrc = TRUE; 90 MCI_OPEN_PARMS OpenParms; 91 MCI_WAVE_GETDEVCAPS_PARMS DevCapsParms; 92 MCI_GENERIC_PARMS GenericParms = {0}; 93 #ifdef DEBUG 94 char szError[64] = ""; 95 #endif 96 97 dprintf(("WINMM: WaveOut::queryFormat %x srate=%d, nchan=%d, bps=%d", formatTag, nSamplesPerSec, nChannels, wBitsPerSample)); 98 99 // Open the device. 100 memset(&OpenParms, 0, sizeof(OpenParms)); 101 OpenParms.pszDeviceType = (PSZ)MCI_DEVTYPE_WAVEFORM_AUDIO; 102 103 rc = mymciSendCommand(0, MCI_OPEN, 104 MCI_WAIT | MCI_OPEN_TYPE_ID, 105 (PVOID)&OpenParms, 0); 106 if (LOUSHORT(rc) != MCIERR_SUCCESS) { 107 #ifdef DEBUG 108 mymciGetErrorString(rc, szError, sizeof(szError)); 109 dprintf(("WINMM: WaveOut::queryFormat: %s\n", szError)); 110 #endif 111 return FALSE; 112 } 113 114 // See if the device can handle the specified format. 115 memset(&DevCapsParms, 0, sizeof(MCI_WAVE_GETDEVCAPS_PARMS)); 116 DevCapsParms.ulBitsPerSample = wBitsPerSample; 117 DevCapsParms.ulFormatTag = DATATYPE_WAVEFORM; 118 DevCapsParms.ulSamplesPerSec = nSamplesPerSec; 119 DevCapsParms.ulChannels = nChannels; 120 DevCapsParms.ulFormatMode = MCI_PLAY; 121 DevCapsParms.ulItem = MCI_GETDEVCAPS_WAVE_FORMAT; 122 123 rc = mymciSendCommand(OpenParms.usDeviceID, MCI_GETDEVCAPS, 124 MCI_WAIT | MCI_GETDEVCAPS_EXTENDED | MCI_GETDEVCAPS_ITEM, 125 (PVOID)&DevCapsParms, 0); 126 if (LOUSHORT(rc) != MCIERR_SUCCESS) { 127 #ifdef DEBUG 128 mymciGetErrorString(rc, szError, sizeof(szError)); 129 dprintf(("WINMM: WaveOut::queryFormat: %s\n", szError)); 130 #endif 131 winrc = FALSE; 132 } 133 134 // Close the device 135 rc = mymciSendCommand(OpenParms.usDeviceID, MCI_CLOSE, 136 MCI_WAIT, (PVOID)&GenericParms, 0); 137 if (LOUSHORT(rc) != MCIERR_SUCCESS) { 138 #ifdef DEBUG 139 mymciGetErrorString(rc, szError, sizeof(szError)); 140 dprintf(("WINMM: WaveOut::queryFormat: %s\n", szError)); 141 #endif 142 winrc = FALSE; 143 } 144 145 return winrc; 146 } 147 /******************************************************************************/ 148 // Called if waveOutSetVolume is called by the application with waveout handle NULL 149 // Sets the default volume of each waveout stream (until it's volume is changed 150 // with an appropriate waveOutSetVolume call) 100 151 /******************************************************************************/ 101 152 void WaveOut::setDefaultVolume(ULONG volume) … … 112 163 /******************************************************************************/ 113 164 /******************************************************************************/ 114 ULONG WaveOut::defvolume = 0xFFFFFFFF;115 165
Note:
See TracChangeset
for help on using the changeset viewer.