Changeset 8506 for trunk/src/winmm/mixeros2.cpp
- Timestamp:
- May 28, 2002, 3:35:02 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/winmm/mixeros2.cpp
r8493 r8506 1 /* $Id: mixeros2.cpp,v 1. 5 2002-05-26 10:52:31sandervl Exp $ */1 /* $Id: mixeros2.cpp,v 1.6 2002-05-28 13:35:02 sandervl Exp $ */ 2 2 3 3 /* … … 32 32 static HFILE hPDDMix = 0; 33 33 static char mixerApiMap[256] = {0}; 34 static int szVolumeLevels[MIX_CTRL_MAX][2] = {0}; 34 35 35 36 /******************************************************************************/ … … 56 57 } 57 58 59 memset(szVolumeLevels, -1, sizeof(szVolumeLevels)); 58 60 return TRUE; 59 61 } … … 126 128 idx = RECORDGAINSET; 127 129 break; 128 129 130 default: 130 131 return -1; … … 147 148 /******************************************************************************/ 148 149 /******************************************************************************/ 149 BOOL OSLibMixSetVolume(DWORD dwControl, BOOL fMute, DWORD dwVolLeft, DWORD dwVolRight) 150 BOOL OSLibMixSetVolume(DWORD dwControl, DWORD dwVolLeft, DWORD dwVolRight) 151 { 152 DWORD dwFunc, dwIOCT90VolLeft, dwIOCT90VolRight; 153 MIXSTRUCT mixstruct; 154 155 //TODO: implement master volume with MMPM2 156 if(dwControl == MIX_CTRL_VOL_OUT_LINE) { 157 return TRUE; 158 } 159 160 //wave in recording levels are virtual controls as there is only 161 //one control for recording gain 162 switch(dwControl) { 163 case MIX_CTRL_VOL_IN_W_MONO: 164 case MIX_CTRL_VOL_IN_W_PHONE: 165 case MIX_CTRL_VOL_IN_W_MIC: 166 case MIX_CTRL_VOL_IN_W_LINE: 167 case MIX_CTRL_VOL_IN_W_CD: 168 case MIX_CTRL_VOL_IN_W_VIDEO: 169 case MIX_CTRL_VOL_IN_W_AUX: 170 case MIX_CTRL_VOL_IN_W_PCM: 171 szVolumeLevels[dwControl][0] = dwVolLeft; 172 szVolumeLevels[dwControl][1] = dwVolRight; 173 break; 174 } 175 dwFunc = OSLibMixGetIndex(dwControl); 176 if(dwFunc == -1) { 177 return FALSE; 178 } 179 dwFunc += MONOINSET; 180 181 //first get current mute value 182 if(mixerapiIOCTL90(hPDDMix, dwFunc-MONOINSET+MONOINQUERY, &mixstruct, sizeof(mixstruct)) == FALSE) { 183 return FALSE; 184 } 185 186 if(dwVolLeft > MIXER_WIN32_MAX_VOLUME || dwVolRight > MIXER_WIN32_MAX_VOLUME) { 187 dprintf(("OSLibMixSetVolume: Volume (%d,%d) out of RANGE!!", dwVolLeft, dwVolRight)); 188 return FALSE; 189 } 190 if(dwControl == MIX_CTRL_OUT_L_TREBLE) { 191 //get bass value (right = treble, left = bass) 192 OSLibMixGetVolume(MIX_CTRL_OUT_L_BASS, &dwVolLeft, NULL); 193 } 194 else 195 if(dwControl == MIX_CTRL_OUT_L_BASS) { 196 //get treble value (right = treble, left = bass) 197 OSLibMixGetVolume(MIX_CTRL_OUT_L_TREBLE, &dwVolRight, NULL); 198 } 199 200 dwIOCT90VolLeft = WIN32_TO_IOCTL90_VOLUME(dwVolLeft); 201 dwIOCT90VolRight = WIN32_TO_IOCTL90_VOLUME(dwVolRight); 202 203 if(mixstruct.VolumeL == dwIOCT90VolLeft && 204 mixstruct.VolumeR == dwIOCT90VolRight) 205 { 206 return TRUE; //nothing to do 207 } 208 //change volume levels 209 mixstruct.VolumeL = dwIOCT90VolLeft; 210 mixstruct.VolumeR = dwIOCT90VolRight; 211 212 if(mixerapiIOCTL90(hPDDMix, dwFunc, &mixstruct, sizeof(mixstruct)) == TRUE) { 213 return TRUE; 214 } 215 dprintf(("OSLibMixSetVolume: mixerapiIOCTL90 %d failed!!", dwFunc)); 216 return FALSE; 217 } 218 /******************************************************************************/ 219 /******************************************************************************/ 220 BOOL OSLibMixSetMute(DWORD dwControl, BOOL fMute) 150 221 { 151 222 DWORD dwFunc; … … 153 224 154 225 //TODO: implement master volume with MMPM2 155 if(dwControl == MIX_CTRL_ VOL_OUT_LINE || dwControl == MIX_CTRL_MUTE_OUT_LINE) {226 if(dwControl == MIX_CTRL_MUTE_OUT_LINE) { 156 227 return TRUE; 157 228 } … … 163 234 dwFunc += MONOINSET; 164 235 165 if(dwVolLeft > MIXER_IOCTL90_MAX_VOLUME || dwVolRight > MIXER_IOCTL90_MAX_VOLUME) { 166 dprintf(("OSLibMixSetVolume: Volume (%d,%d) out of RANGE!!", dwVolLeft, dwVolRight)); 167 return FALSE; 168 } 169 mixstruct.Mute = fMute; 170 mixstruct.VolumeL = WIN32_TO_IOCTL90_VOLUME(dwVolLeft); 171 mixstruct.VolumeR = WIN32_TO_IOCTL90_VOLUME(dwVolRight); 236 //first get current volume levels 237 if(mixerapiIOCTL90(hPDDMix, dwFunc-MONOINSET+MONOINQUERY, &mixstruct, sizeof(mixstruct)) == FALSE) { 238 return FALSE; 239 } 240 241 if(mixstruct.Mute == fMute) { 242 return TRUE; //nothing to do 243 } 244 245 //change mute 246 mixstruct.Mute = fMute; 172 247 173 248 if(mixerapiIOCTL90(hPDDMix, dwFunc, &mixstruct, sizeof(mixstruct)) == TRUE) { … … 179 254 /******************************************************************************/ 180 255 /******************************************************************************/ 181 BOOL OSLibMixGetVolume(DWORD dwControl, BOOL *pfMute,DWORD *pdwVolLeft, DWORD *pdwVolRight)256 BOOL OSLibMixGetVolume(DWORD dwControl, DWORD *pdwVolLeft, DWORD *pdwVolRight) 182 257 { 183 258 DWORD dwFunc; … … 185 260 186 261 //TODO: implement master volume with MMPM2 187 if(dwControl == MIX_CTRL_VOL_OUT_LINE || dwControl == MIX_CTRL_MUTE_OUT_LINE) { 188 if(pfMute) *pfMute = 0; 262 if(dwControl == MIX_CTRL_VOL_OUT_LINE) { 189 263 if(pdwVolLeft) *pdwVolLeft = 50000; 190 264 if(pdwVolRight) *pdwVolRight = 50000; … … 192 266 } 193 267 268 //wave in recording levels are virtual controls as there is only 269 //one control for recording gain 270 switch(dwControl) { 271 case MIX_CTRL_VOL_IN_W_MONO: 272 case MIX_CTRL_VOL_IN_W_PHONE: 273 case MIX_CTRL_VOL_IN_W_MIC: 274 case MIX_CTRL_VOL_IN_W_LINE: 275 case MIX_CTRL_VOL_IN_W_CD: 276 case MIX_CTRL_VOL_IN_W_VIDEO: 277 case MIX_CTRL_VOL_IN_W_AUX: 278 case MIX_CTRL_VOL_IN_W_PCM: 279 if(szVolumeLevels[dwControl][0] != -1) { 280 if(pdwVolLeft) *pdwVolLeft = szVolumeLevels[dwControl][0]; 281 if(pdwVolRight) *pdwVolRight = szVolumeLevels[dwControl][1]; 282 return TRUE; 283 } 284 break; 285 } 286 194 287 dwFunc = OSLibMixGetIndex(dwControl); 195 288 if(dwFunc == -1) { … … 207 300 mixstruct.VolumeR = min(MIXER_IOCTL90_MAX_VOLUME, mixstruct.VolumeR); 208 301 209 if(pfMute) *pfMute = mixstruct.Mute; 210 if(pdwVolLeft) *pdwVolLeft = IOCTL90_TO_WIN32_VOLUME(mixstruct.VolumeL); 211 if(pdwVolRight) *pdwVolRight = IOCTL90_TO_WIN32_VOLUME(mixstruct.VolumeR); 212 302 if(dwControl == MIX_CTRL_OUT_L_TREBLE) { 303 mixstruct.VolumeL = mixstruct.VolumeR; //right = treble, left = bass 304 } 305 else 306 if(dwControl == MIX_CTRL_OUT_L_BASS) { 307 mixstruct.VolumeR = mixstruct.VolumeL; //right = treble, left = bass 308 } 309 310 //save volume levels 311 szVolumeLevels[dwControl][0] = IOCTL90_TO_WIN32_VOLUME(mixstruct.VolumeL); 312 szVolumeLevels[dwControl][1] = IOCTL90_TO_WIN32_VOLUME(mixstruct.VolumeR); 313 314 if(pdwVolLeft) *pdwVolLeft = szVolumeLevels[dwControl][0]; 315 if(pdwVolRight) *pdwVolRight = szVolumeLevels[dwControl][1]; 316 317 return TRUE; 318 } 319 /******************************************************************************/ 320 /******************************************************************************/ 321 BOOL OSLibMixGetMute(DWORD dwControl, BOOL *pfMute) 322 { 323 DWORD dwFunc; 324 MIXSTRUCT mixstruct; 325 326 //TODO: implement master volume with MMPM2 327 if(dwControl == MIX_CTRL_MUTE_OUT_LINE) { 328 if(pfMute) *pfMute = 0; 329 return TRUE; 330 } 331 dwFunc = OSLibMixGetIndex(dwControl); 332 if(dwFunc == -1) { 333 return FALSE; 334 } 335 dwFunc += MONOINQUERY; 336 337 if(mixerapiIOCTL90(hPDDMix, dwFunc, &mixstruct, sizeof(mixstruct)) == FALSE) { 338 return FALSE; 339 } 340 if(pfMute) *pfMute = mixstruct.Mute; 213 341 return TRUE; 214 342 } … … 273 401 BOOL OSLibMixIsRecSourcePresent(DWORD dwRecSrc) 274 402 { 275 DWORD dwOldRecSrc, dwVolL, dwVolR; 276 277 if(OSLibMixGetRecSource(&dwOldRecSrc, &dwVolL, &dwVolR) == FALSE) { 278 return FALSE; 279 } 280 if(OSLibMixSetRecSource(dwRecSrc, dwVolL, dwVolR) == FALSE) { 281 return FALSE; 282 } 283 OSLibMixSetRecSource(dwOldRecSrc, dwVolL, dwVolR); 403 if(OSLibMixSetRecSource(dwRecSrc) == FALSE) { 404 return FALSE; 405 } 284 406 return TRUE; 285 407 } 286 408 /******************************************************************************/ 287 409 /******************************************************************************/ 288 BOOL OSLibMixSetRecSource(DWORD dwRecSrc , DWORD dwVolL, DWORD dwVolR)289 { 290 DWORD idx;410 BOOL OSLibMixSetRecSource(DWORD dwRecSrc) 411 { 412 DWORD idx, volidx; 291 413 MIXSTRUCT mixstruct; 414 DWORD dwVolL, dwVolR; 292 415 293 416 switch(dwRecSrc) { 294 417 case MIXER_SRC_IN_W_MIC: 295 418 idx = I90SRC_MIC; 419 volidx = MIX_CTRL_VOL_IN_W_MIC; 296 420 break; 297 421 case MIXER_SRC_IN_W_CD: 298 422 idx = I90SRC_CD; 423 volidx = MIX_CTRL_VOL_IN_W_CD; 299 424 break; 300 425 case MIXER_SRC_IN_W_VIDEO: 301 426 idx = I90SRC_VIDEO; 427 volidx = MIX_CTRL_VOL_IN_W_VIDEO; 302 428 break; 303 429 case MIXER_SRC_IN_W_AUX: 304 430 idx = I90SRC_AUX; 431 volidx = MIX_CTRL_VOL_IN_W_AUX; 305 432 break; 306 433 case MIXER_SRC_IN_W_LINE: 307 434 idx = I90SRC_LINE; 435 volidx = MIX_CTRL_VOL_IN_W_LINE; 308 436 break; 309 437 case MIXER_SRC_IN_W_PHONE: 310 438 idx = I90SRC_PHONE; 439 volidx = MIX_CTRL_VOL_IN_W_PHONE; 311 440 break; 312 441 default: … … 316 445 mixstruct.VolumeL = idx; 317 446 447 //select recording source 318 448 if(mixerapiIOCTL90(hPDDMix, RECORDSRCSET, &mixstruct, sizeof(mixstruct)) == FALSE) { 319 449 dprintf(("OSLibMixSetRecSource: mixerapiIOCTL90 RECORDSRCSET failed!!")); … … 321 451 } 322 452 323 mixstruct.Mute = 0; 453 dwVolL = szVolumeLevels[volidx][0]; 454 dwVolR = szVolumeLevels[volidx][1]; 324 455 mixstruct.VolumeL = WIN32_TO_IOCTL90_VOLUME(dwVolL); 325 456 mixstruct.VolumeR = WIN32_TO_IOCTL90_VOLUME(dwVolR); 457 mixstruct.Mute = 0; 458 459 //set recording gain to that of the selected source 326 460 if(mixerapiIOCTL90(hPDDMix, RECORDGAINSET, &mixstruct, sizeof(mixstruct)) == FALSE) { 327 461 dprintf(("OSLibMixSetRecSource: mixerapiIOCTL90 RECORDGAINSET failed!!")); … … 332 466 /******************************************************************************/ 333 467 /******************************************************************************/ 334 BOOL OSLibMixGetRecSource(DWORD *pdwRecSrc , DWORD *pdwVolL, DWORD *pdwVolR)468 BOOL OSLibMixGetRecSource(DWORD *pdwRecSrc) 335 469 { 336 470 DWORD idx; … … 366 500 if(pdwRecSrc) { 367 501 *pdwRecSrc = idx; 368 }369 if(mixerapiIOCTL90(hPDDMix, RECORDGAINQUERY, &mixstruct, sizeof(mixstruct)) == FALSE) {370 dprintf(("OSLibMixSetRecSource: mixerapiIOCTL90 RECORDGAINQUERY failed!!"));371 return FALSE;372 }373 if(pdwVolL) {374 *pdwVolL = IOCTL90_TO_WIN32_VOLUME(mixstruct.VolumeL);375 }376 if(pdwVolR) {377 *pdwVolR = IOCTL90_TO_WIN32_VOLUME(mixstruct.VolumeR);378 502 } 379 503 return TRUE;
Note:
See TracChangeset
for help on using the changeset viewer.