Changeset 533
- Timestamp:
- Aug 2, 2010, 11:30:35 PM (15 years ago)
- Location:
- OCO/trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
OCO/trunk/drv16/convert.h
r271 r533 1 1 #ifndef __CONVERT_H__ 2 2 #define __CONVERT_H__ 3 4 /* Comparison functions for handling wrapping */ 5 #define ARG1_IS_AFTER_ARG2(a,b) ((long)(b) - (long)(a) < 0) 6 #define ARG1_IS_BEFORE_ARG2(a,b) ARG1_IS_AFTER_ARG2(b,a) 7 8 #define ARG1_IS_AFTER_OR_EQUAL_TO_ARG2(a,b) ((long)(a) - (long)(b) >= 0) 9 #define ARG1_IS_BEFORE_OR_EQUAL_TO_ARG2(a,b) ARG1_IS_AFTER_OR_EQUAL_TO_ARG2(b,a) 3 10 4 11 //Use one page to temporarily hold converted wave data -
OCO/trunk/drv16/ioctl.cpp
r529 r533 3 3 /* SCCSID = %W% %E% */ 4 4 /**************************************************************************** 5 * 6 * Copyright (c) IBM Corporation 1994 - 1997. 7 * 8 * The following IBM OS/2 source code is provided to you solely for the 5 * * 6 * Copyright (c) IBM Corporation 1994 - 1997. * 7 * * 8 * The following IBM OS/2 source code is provided to you solely for the * 9 9 * the purpose of assisting you in your development of OS/2 device drivers. * 10 * You may use this code in accordance with the IBM License Agreement 11 * provided in the IBM Device Driver Source Kit for OS/2. 12 * 10 * You may use this code in accordance with the IBM License Agreement * 11 * provided in the IBM Device Driver Source Kit for OS/2. * 12 * * 13 13 ****************************************************************************/ 14 14 /**@internal %W% … … 18 18 * @version %I% 19 19 * @context Unless otherwise noted, all interfaces are Ring-0, 16-bit, 20 * 20 * <stack context>. 21 21 * @history 22 22 * … … 46 46 #include <daudio.h> 47 47 48 int numFreeStreams= ALSACAPS_MAXSTREAMS;48 int numFreeStreams = ALSACAPS_MAXSTREAMS; 49 49 50 50 /**@internal 51 * @param 52 * @return 51 * @param PREQPACKET pointer to the strategy request packet 52 * @return None But the Status in the request packet is updated on error 53 53 * @notes 54 54 * The Audio Init Ioctl only 2 things happen in here : … … 68 68 PFN_SHD pfnSHD = NULL; 69 69 70 71 72 73 70 // if this is an IDLE or De-Init request 71 // fetch the stream object based on the sysfilenum and turn on the 72 // stream idle bit in the stream state then write the sysfilenum 73 // into the request packet, set rc = 0 and return 74 74 if (p->sMode == IDLE) 75 75 { 76 77 78 79 80 81 82 } 83 84 85 86 87 88 89 90 91 92 93 94 95 96 76 pstream = FindStream_fromFile((ULONG) prp->s.ioctl.usSysFileNum); 77 if (pstream) 78 pstream->ulStreamState |= STREAM_IDLE; 79 p->pvReserved = (VOID FAR *) (ULONG)prp->s.ioctl.usSysFileNum; 80 p->sReturnCode = 0; 81 return; 82 } 83 // call FindStream_fromFile to see if there is already a stream 84 // for this sysfilenum. if there is then see if the idle bit is on, 85 // if the idle bit is on, reset it, then write the sysfilenum 86 // into the request packet, set rc = 0 and return 87 // MMPM sends idle down to a stream that is "losing" the hardware but 88 // should not go away. It usually is associated with an app losing 89 // focus. If the idle bit is not the stream is either not registered or 90 // is being "re-initted" in another mode or with different file 91 // attributes. "Re-initting" a stream is a total hack on the part 92 // of MMPM they should de-register the stream and then init a new 93 // stream but they don't . If anyone ever writes a VSD that behaves 94 // "correctly" then this code can be deleted. 95 // Either way delete the stream and build a new one with 96 // this request packet. 97 97 pstream = FindStream_fromFile((ULONG) prp->s.ioctl.usSysFileNum); 98 if (pstream) { 99 if (pstream->ulStreamState & STREAM_IDLE) { 100 pstream->ulStreamState &= STREAM_NOT_IDLE; 101 p->pvReserved = (VOID FAR *) (ULONG)prp->s.ioctl.usSysFileNum; 102 p->sReturnCode = 0; 103 return; 104 } 105 else { 98 if (pstream) { 99 if (pstream->ulStreamState & STREAM_IDLE) { 100 pstream->ulStreamState &= STREAM_NOT_IDLE; 101 p->pvReserved = (VOID FAR *) (ULONG)prp->s.ioctl.usSysFileNum; 102 p->sReturnCode = 0; 103 return; 104 } else { 106 105 #if 1 107 // Rudi: Workaround for MMPM device sharing bug108 if (pstream->ulStreamState & STREAM_STREAMING) {109 110 111 112 113 114 115 }106 // Rudi: Workaround for MMPM device sharing bug 107 if (pstream->ulStreamState & STREAM_STREAMING) { 108 CONTROL_PARM dummy; 109 pstream->PauseStream(&dummy); 110 pstream->ResumeStream(); 111 p->pvReserved = (VOID FAR *) (ULONG)prp->s.ioctl.usSysFileNum; 112 p->sReturnCode = 0; 113 return; 114 } 116 115 #endif 117 118 119 //a stream that was already registered120 121 if(pstream->pfnSHD) {122 123 124 125 126 127 116 //HACK BEGIN 117 //SvL: Save stream handle & SHD entrypoint in case MMPM2 reinitializes 118 // a stream that was already registered 119 //HACK END 120 if (pstream->pfnSHD) { 121 hstream = (USHORT)pstream->hstream; 122 pfnSHD = pstream->pfnSHD; 123 } 124 delete pstream; 125 } 126 } 128 127 129 128 // get the hardware type … … 131 130 HardwareType = GetHardwareType(p->sMode, (USHORT)p->ulOperation, LDev); 132 131 if (HardwareType == AUDIOHW_INVALID_DEVICE) { 133 134 135 136 } 137 138 132 p->sReturnCode = INVALID_REQUEST; 133 prp->usStatus |= RPERR; 134 return; 135 } 136 // make sure we have a Hardware object that can handle this 137 // data type and operation.. 139 138 pHWobj = GetHardwareDevice(HardwareType); 140 139 if (pHWobj == NULL) { 141 142 143 144 } 145 146 p->ulFlags = 0; 140 p->sReturnCode = INVALID_REQUEST; 141 prp->usStatus |= RPERR; 142 return; 143 } 144 145 p->ulFlags = 0; /* Zero the Flags */ 147 146 switch (HardwareType) 148 147 { 149 150 151 152 p->sDeviceID = ALSA_ID; /* Reported in VSD dll*/153 154 155 156 157 158 159 p->sDeviceID = ALSA_MIDI_ID; /* Reported in VSD dll*/160 161 162 163 164 165 166 167 168 169 170 171 148 case AUDIOHW_WAVE_PLAY: 149 case AUDIOHW_WAVE_CAPTURE: 150 pstream = new WAVESTREAM(HardwareType,p,prp->s.ioctl.usSysFileNum, MixerStreamId); 151 p->sDeviceID = ALSA_ID; /* Reported in VSD dll */ 152 break; 153 154 case AUDIOHW_FMSYNTH_PLAY: 155 if(devCaps[current_device].ulCaps & OSS32_CAPS_FMSYNTH_PLAYBACK) 156 { 157 pstream = new MIDISTREAM(HardwareType, prp->s.ioctl.usSysFileNum, MixerStreamId); 158 p->sDeviceID = ALSA_MIDI_ID; /* Reported in VSD dll */ 159 } 160 else { 161 p->sReturnCode = INVALID_REQUEST; 162 prp->usStatus |= RPERR; 163 return; 164 } 165 break; 166 167 default: 168 p->sReturnCode = INVALID_REQUEST; 169 prp->usStatus |= RPERR; 170 return; 172 171 } /* endswitch */ 173 172 174 p->ulFlags |= VOLUME;/* volume control is supported */175 p->ulFlags |= INPUT; /* Input select is supported*/176 p->ulFlags |= OUTPUT;/* Output select is supported */177 p->ulFlags |= MONITOR;/* Record Monitor is supported */173 p->ulFlags |= VOLUME; /* volume control is supported */ 174 p->ulFlags |= INPUT; /* Input select is supported */ 175 p->ulFlags |= OUTPUT; /* Output select is supported */ 176 p->ulFlags |= MONITOR; /* Record Monitor is supported */ 178 177 pstream->ulSysFileNum = prp->s.ioctl.usSysFileNum; 179 178 p->pvReserved = (VOID FAR *) (ULONG) prp->s.ioctl.usSysFileNum; 180 179 p->sReturnCode = 0; 181 // 180 // dprintf(("IoctlAudioInit: file nr: %lx", pstream->ulSysFileNum)); 182 181 183 182 //HACK BEGIN 184 183 if(pfnSHD) { 185 // 186 pstream->pfnSHD= pfnSHD;187 184 // dprintf(("Stream was previously registered; reregister it")); 185 pstream->pfnSHD = pfnSHD; 186 pstream->hstream = hstream; 188 187 } 189 188 //HACK END … … 192 191 193 192 /**@internal 194 * @param 195 * @return 193 * @param PREQPACKET pointer to the strategy request packet 194 * @return None But the Status in the request packet is updated on error 196 195 * @notes 197 196 */ … … 218 217 if (pHWobj) 219 218 { 220 221 222 223 224 225 p->ulDataType= WAVE_FORMAT_4S16;226 p->ulChannels= 2;227 228 229 230 231 219 pHWobj->DevCaps(p); 220 if (p->ulSupport != SUPPORT_SUCCESS) 221 { 222 //PS+++ filling to our parameters as say mmpm2.inf for returning error in this call 223 // (for HDA only!!!!!) 224 p->ulDataType = WAVE_FORMAT_4S16; 225 p->ulChannels = 2; 226 p->ulSamplingRate = HZ_44100; 227 // 228 //dprintf(("IACapability: Error support")); 229 prp->usStatus |= RPERR; 230 } 232 231 } 233 232 else { 234 233 //dprintf(("IACapability: Error get HW obj")); 235 236 237 p->ulDataType= WAVE_FORMAT_4S16;238 p->ulChannels= 2;239 240 241 242 234 //PS+++ filling to our parameters as say mmpm2.inf for returning error in this call 235 // (for HDA only!!!!!) 236 p->ulDataType = WAVE_FORMAT_4S16; 237 p->ulChannels = 2; 238 p->ulSamplingRate = HZ_44100; 239 // 240 p->ulSupport = UNSUPPORTED_DATATYPE; 241 prp->usStatus |= RPERR; 243 242 } 244 243 } 245 244 246 245 /**@internal IoctlAudioControl 247 * @param 248 * @return 246 * @param PREQPACKET pointer to the strategy request packet 247 * @return None But the Status in the request packet is updated on error 249 248 * @notes 250 249 * if it's AUDIO_CHANGE, just report success, otherwise report failure … … 258 257 LPMCI_AUDIO_CHANGE pAudChange; 259 258 LPMCI_TRACK_INFO pMasterVol; 260 PSTREAM 261 ULONG 262 ULONG 259 PSTREAM pStream; 260 ULONG volume; 261 ULONG addr; 263 262 264 263 if (p->usIOCtlRequest != AUDIO_CHANGE) 265 264 { 266 267 268 269 265 rprintf(("IAudioControl: Error support req:%x",p->usIOCtlRequest)); 266 p->sReturnCode = INVALID_REQUEST; 267 prp->usStatus |= RPERR | RPBADCMD; 268 return; 270 269 } 271 270 p->sReturnCode=0; … … 278 277 if(addr >= 0x10000UL) 279 278 { 280 281 282 283 279 rprintf(("Invalid MCI_AUDIO_CHANGE pnt %lx!!", (ULONG)pAudChange)); 280 p->sReturnCode = INVALID_REQUEST; 281 prp->usStatus |= RPERR | RPBADCMD; 282 return; 284 283 } 285 284 pMasterVol = (LPMCI_TRACK_INFO)pAudChange->pvDevInfo; … … 290 289 if(addr >= 0x10000UL) 291 290 { 292 293 294 295 291 rprintf(("Invalid MCI_TRACK_INFO pnt %lx!!", (ULONG)pMasterVol)); 292 p->sReturnCode = INVALID_REQUEST; 293 prp->usStatus |= RPERR | RPBADCMD; 294 return; 296 295 } 297 296 298 297 pStream = FindStream_fromFile((ULONG) prp->s.ioctl.usSysFileNum); 299 298 if(pStream == NULL) { 300 301 302 299 rprintf(("IAudioControl stream %lx not found!", (ULONG) prp->s.ioctl.usSysFileNum)); 300 DebugInt3(); 301 return; 303 302 } 304 303 if(pAudChange->lBalance != AUDIO_IGNORE) 305 304 pStream->SetProperty(PROPERTY_BALANCE, pAudChange->lBalance); 306 305 307 306 if (pAudChange->lVolume != AUDIO_IGNORE) 308 307 { 309 310 311 308 // stream volume ranges from 0 to 0x7FFFFFFF (linear) 309 volume = pAudChange->lVolume >> 16UL; 310 volume = (volume*OSS32_MAX_VOLUME)/0x7FFFUL; 312 311 //dprintf(("Set stream volume of %x to %d", prp->s.ioctl.usSysFileNum, volume)); 313 312 pStream->SetProperty(PROPERTY_VOLUME, MAKE_VOLUME_LR(volume, volume)); 314 313 } 315 314 316 315 if (pMasterVol && pMasterVol->usMasterVolume != AUDIO_IGNORE) 317 316 { 318 319 320 321 322 323 324 325 // 326 327 328 329 330 317 // master volume ranges from 0 to 0x7FFF (linear) 318 volume = pMasterVol->usMasterVolume; 319 volume = (volume*OSS32_MAX_VOLUME)/0x7FFFUL; 320 if (volume > OSS32_MAX_VOLUME) 321 { 322 volume = OSS32_MAX_VOLUME; 323 } 324 // dprintf(("IlAudioControl:Set MV to %d", volume)); 325 MixerSetVolume(MixerStreamId, OSS32_MIX_VOLUME_MASTER_FRONT, MAKE_VOLUME_LR(volume, volume)); 326 if(mixcaps.fuCtrlCaps & OSS32_MIX_FLAG(OSS32_MIX_VOLUME_MASTER_REAR)) 327 { 328 MixerSetVolume(MixerStreamId, OSS32_MIX_VOLUME_MASTER_REAR, MAKE_VOLUME_LR(volume, volume)); 329 } 331 330 } 332 331 if(!fRecSrcIOCTL90) { 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 // 356 357 358 359 332 for(int i=0;i<8;i++) 333 { 334 switch(pAudChange->rInputList[0].ulDevType) { 335 case NULL_INPUT: 336 break; //continue; 337 case STEREO_LINE_INPUT: 338 case LEFT_LINE_INPUT: 339 case RIGHT_LINE_INPUT: 340 pStream->SetProperty(PROPERTY_INPUTSRC, OSS32_MIX_RECSRC_LINE); 341 break; 342 343 case MIC_INPUT: 344 case BOOSTED_MIC_INPUT: 345 pStream->SetProperty(PROPERTY_INPUTSRC, OSS32_MIX_RECSRC_MIC); 346 break; 347 348 case PHONE_LINE_INPUT: 349 case HANDSET_INPUT: 350 case SYNTH_INPUT: 351 case DIGITAL_PHONE_LINE_INPUT: 352 case DIGITAL_HANDSET_INPUT: 353 case MIDI_IN_PORT: 354 // case LOOPBACK: 355 pStream->SetProperty(PROPERTY_INPUTSRC, OSS32_MIX_RECSRC_MIXER); 356 break; 357 } 358 } 360 359 } 361 360 if(!fRecGainIOCTL90 && pAudChange->lGain != AUDIO_IGNORE) { 362 363 364 365 366 367 368 // 369 361 // input ranges from 0 to 0x7FFFFFFF (linear) 362 volume = pAudChange->lGain >> 16UL; 363 volume = (volume*OSS32_MAX_VOLUME)/0x7FFFUL; 364 if(volume > OSS32_MAX_VOLUME) { 365 volume = OSS32_MAX_VOLUME; 366 } 367 // dprintf(("IAudioControl:Set IG of %x to %d", prp->s.ioctl.usSysFileNum, volume)); 368 pStream->SetProperty(PROPERTY_INPUTGAIN, MAKE_VOLUME_LR(volume, volume)); 370 369 } 371 370 } … … 374 373 void IoctlDirectAudio(PREQPACKET prp) 375 374 { 376 // 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 audioCaps.ulLength= sizeof(MCI_AUDIO_CAPS);392 393 audioCaps.ulChannels= pInit->sChannels;394 395 audioCaps.ulDataType= pInit->sMode;396 audioCaps.ulOperation= OPERATION_PLAY;397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 375 // dprintf(("IoctlDirectAudio Code:0x%x",prp->s.ioctl.bCode)); 376 if(prp->s.ioctl.bCode == DAUDIO_OPEN) 377 { 378 LPMCI_AUDIO_INIT pInit = (LPMCI_AUDIO_INIT) prp->s.ioctl.pvData; 379 PAUDIOHW pHWobj; 380 MCI_AUDIO_CAPS audioCaps; 381 PDWAVESTREAM pStream; 382 383 if(DevHelp_VerifyAccess(SELECTOROF(pInit), sizeof(MCI_AUDIO_INIT), OFFSETOF(pInit), VERIFY_READWRITE)) 384 { 385 rprintf(("Invalid MCI_AUDIO_INIT pnt %lx!!", (ULONG)pInit)); 386 prp->usStatus |= RPERR | RPBADCMD; 387 return; 388 } 389 390 audioCaps.ulLength = sizeof(MCI_AUDIO_CAPS); 391 audioCaps.ulSamplingRate = pInit->lSRate; 392 audioCaps.ulChannels = pInit->sChannels; 393 audioCaps.ulBitsPerSample = pInit->lBitsPerSRate; 394 audioCaps.ulDataType = pInit->sMode; 395 audioCaps.ulOperation = OPERATION_PLAY; 396 397 // get the pointer to the hardware object 398 // call DevCaps 399 // bailout if no hardware object is returned.. 400 pHWobj = GetHardwareDevice(AUDIOHW_WAVE_PLAY); 401 if (pHWobj) 402 { 403 pHWobj->DevCaps(&audioCaps); 404 if (audioCaps.ulSupport != SUPPORT_SUCCESS) 405 { 406 rprintf(("IDirectAudio: DevCaps failed")); 407 pInit->sReturnCode = INVALID_REQUEST; 408 prp->usStatus |= RPERR; 409 return; 410 } 411 } 412 else 413 { 414 rprintf(("IDirectAudio: HW DevCaps failed")); 415 pInit->sReturnCode = INVALID_REQUEST; 416 prp->usStatus |= RPERR; 417 return; 418 } 419 420 pStream = new DWAVESTREAM(AUDIOHW_WAVE_PLAY, pInit, prp->s.ioctl.usSysFileNum, MixerStreamId); 421 if(pStream == NULL) { 423 422 //dprintf(("IDirectAudio: pStream")); 424 425 426 427 428 429 430 431 432 423 DebugInt3(); 424 pInit->sReturnCode = INVALID_REQUEST; 425 prp->usStatus |= RPERR; 426 return; 427 } 428 429 if(!pStream->IsEverythingOk()) 430 { 431 delete pStream; 433 432 //dprintf(("IlDirectAudio: IsEverythingOk")); 434 435 436 437 438 439 pInit->ulFlags |= VOLUME; /* volume control is supported*/440 pInit->ulFlags |= INPUT; /* Input select is supported*/441 pInit->ulFlags |= OUTPUT; /* Output select is supported*/442 pInit->ulFlags |= MONITOR; /* Record Monitor is supported*/443 pInit->sDeviceID = ALSA_ID; /* Reported in VSD dll*/444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 audioCaps.ulLength= sizeof(MCI_AUDIO_CAPS);465 466 audioCaps.ulChannels= pInit->sChannels;467 468 audioCaps.ulDataType= pInit->sMode;469 audioCaps.ulOperation= OPERATION_PLAY;470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 433 DebugInt3(); 434 pInit->sReturnCode = INVALID_REQUEST; 435 prp->usStatus |= RPERR; 436 return; 437 } 438 pInit->ulFlags |= VOLUME; /* volume control is supported */ 439 pInit->ulFlags |= INPUT; /* Input select is supported */ 440 pInit->ulFlags |= OUTPUT; /* Output select is supported */ 441 pInit->ulFlags |= MONITOR; /* Record Monitor is supported */ 442 pInit->sDeviceID = ALSA_ID; /* Reported in VSD dll */ 443 pStream->ulSysFileNum = prp->s.ioctl.usSysFileNum; 444 pInit->pvReserved = (VOID FAR *) (ULONG) prp->s.ioctl.usSysFileNum; 445 pInit->sReturnCode = 0; 446 447 return; 448 } 449 else 450 if(prp->s.ioctl.bCode == DAUDIO_QUERYFORMAT) 451 { 452 LPMCI_AUDIO_INIT pInit = (LPMCI_AUDIO_INIT) prp->s.ioctl.pvData; 453 PAUDIOHW pHWobj; 454 MCI_AUDIO_CAPS audioCaps; 455 456 if(DevHelp_VerifyAccess(SELECTOROF(pInit), sizeof(MCI_AUDIO_INIT), OFFSETOF(pInit), VERIFY_READWRITE)) 457 { 458 rprintf(("Invalid MCI_AUDIO_INIT pnt %lx!!", (ULONG)pInit)); 459 prp->usStatus |= RPERR | RPBADCMD; 460 return; 461 } 462 463 audioCaps.ulLength = sizeof(MCI_AUDIO_CAPS); 464 audioCaps.ulSamplingRate = pInit->lSRate; 465 audioCaps.ulChannels = pInit->sChannels; 466 audioCaps.ulBitsPerSample = pInit->lBitsPerSRate; 467 audioCaps.ulDataType = pInit->sMode; 468 audioCaps.ulOperation = OPERATION_PLAY; 469 470 // get the pointer to the hardware object 471 // call DevCaps 472 // bailout if no hardware object is returned.. 473 pHWobj = GetHardwareDevice(AUDIOHW_WAVE_PLAY); 474 if (pHWobj) 475 { 476 pHWobj->DevCaps(&audioCaps); 477 if (audioCaps.ulSupport != SUPPORT_SUCCESS) 478 { 479 rprintf(("IlDirectAudio: DevCaps failed")); 480 prp->usStatus |= RPERR; 481 pInit->sReturnCode = INVALID_REQUEST; 482 return; 483 } 485 484 //dprintf(("IoctlDirectAudio ret0")); 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 485 pInit->sReturnCode = 0; 486 return; 487 } 488 else { 489 rprintf(("IoctlDirectAudio err req")); 490 pInit->sReturnCode = INVALID_REQUEST; 491 prp->usStatus |= RPERR; 492 return; 493 } 494 } 495 else 496 if(prp->s.ioctl.bCode == DAUDIO_QUERYCAPS) 497 { 498 LPOSS32_DEVCAPS lpCaps = (LPOSS32_DEVCAPS) prp->s.ioctl.pvData; 499 PWAVEAUDIO pHWobj; 500 501 if(DevHelp_VerifyAccess(SELECTOROF(lpCaps), sizeof(OSS32_DEVCAPS), OFFSETOF(lpCaps), VERIFY_READWRITE)) 502 { 503 rprintf(("Invalid OSS32_DEVCAPS pnt %lx!!", (ULONG)lpCaps)); 504 prp->usStatus |= RPERR | RPBADCMD; 505 return; 506 } 507 // get the pointer to the hardware object 508 // call DevCaps 509 // bailout if no hardware object is returned.. 510 pHWobj = (PWAVEAUDIO)GetHardwareDevice(AUDIOHW_WAVE_PLAY); 511 if (pHWobj) 512 { 513 pHWobj->DevCaps(lpCaps); 515 514 //dprintf(("IoctlDirectAudio ret1")); 516 517 518 519 520 515 return; 516 } 517 else 518 { 519 prp->usStatus |= RPERR; 521 520 //dprintf(("IoctlDirectAudio ret err1")); 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 ULONGrc = 0;538 539 540 541 542 543 544 545 546 547 548 521 return; 522 } 523 } 524 PSTREAM pStream; 525 526 pStream = FindStream_fromFile((ULONG) prp->s.ioctl.usSysFileNum); 527 if(pStream == NULL) 528 { 529 rprintf(("IDirectAudio stream %lx not found!", (ULONG) prp->s.ioctl.usSysFileNum)); 530 DebugInt3(); 531 prp->usStatus |= RPERR | RPBADCMD; 532 return; 533 } 534 535 LPDAUDIO_CMD pDAudioCmd = (LPDAUDIO_CMD) prp->s.ioctl.pvData; 536 ULONG rc = 0; 537 538 if(DevHelp_VerifyAccess(SELECTOROF(pDAudioCmd), sizeof(DAUDIO_CMD), OFFSETOF(pDAudioCmd), VERIFY_READWRITE)) 539 { 540 rprintf(("Invalid DAUDIO_CMD pnt %lx!!", (ULONG)pDAudioCmd)); 541 prp->usStatus |= RPERR | RPBADCMD; 542 return; 543 } 544 545 switch(prp->s.ioctl.bCode) 546 { 547 case DAUDIO_CLOSE: 549 548 //dprintf(("ID close")); 550 551 552 553 554 549 delete pStream; 550 break; 551 552 case DAUDIO_SETVOLUME: 553 { 555 554 //dprintf(("ID SetVolume")); 556 557 558 559 560 561 555 pStream->SetProperty(PROPERTY_VOLUME, MAKE_VOLUME_LR(pDAudioCmd->Vol.VolumeL, pDAudioCmd->Vol.VolumeR)); 556 break; 557 } 558 559 case DAUDIO_GETVOLUME: 560 { 562 561 //dprintf(("ID GetVolume")); 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 intfActive = pStream->isActive();588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 562 pDAudioCmd->Vol.VolumeL = GET_VOLUME_L(pStream->GetProperty(PROPERTY_VOLUME)); 563 pDAudioCmd->Vol.VolumeR = GET_VOLUME_R(pStream->GetProperty(PROPERTY_VOLUME)); 564 break; 565 } 566 567 case DAUDIO_START: 568 { 569 dprintf(("ID Start NF:%d",(USHORT)numFreeStreams)); 570 if(numFreeStreams > 0) 571 { 572 rc = pStream->StartStream(); 573 if(!rc) numFreeStreams--; 574 } 575 else 576 { 577 rprintf(("ID Start rc1")); 578 rc = 1; //fail 579 } 580 break; 581 } 582 583 case DAUDIO_STOP: 584 { 585 CONTROL_PARM cParm; 586 int fActive = pStream->isActive(); 587 588 dprintf(("ID Stop NF:%d",(USHORT)numFreeStreams)); 589 rc = pStream->StopStream(&cParm); 590 if(!rc && fActive) numFreeStreams++; 591 break; 592 } 593 594 case DAUDIO_PAUSE: 595 { 596 CONTROL_PARM cParm; 597 dprintf(("ID Pause")); 598 rc = pStream->PauseStream(&cParm); 599 break; 600 } 601 602 case DAUDIO_RESUME: 603 { 604 dprintf(("ID Resume")); 605 rc = pStream->ResumeStream(); 606 break; 607 } 608 609 case DAUDIO_GETPOS: 610 { 612 611 //dprintf(("ID GetPos")); 613 614 pDAudioCmd->Pos.ulWritePos= pStream->GetCurrentWritePos();615 616 617 618 619 612 pDAudioCmd->Pos.ulCurrentPos = pStream->GetCurrentPos(); 613 pDAudioCmd->Pos.ulWritePos = pStream->GetCurrentWritePos(); 614 break; 615 } 616 617 case DAUDIO_ADDBUFFER: 618 { 620 619 //dprintf(("ID AddBuffer")); 621 622 623 624 625 626 620 rc = pStream->Write((PSTREAMBUF)pDAudioCmd->Buffer.lpBuffer, pDAudioCmd->Buffer.ulBufferLength); 621 break; 622 } 623 624 case DAUDIO_SETPROPERTY: 625 { 627 626 //dprintf(("ID SetProp")); 628 629 630 631 632 633 634 627 rc = pStream->SetProperty((USHORT)pDAudioCmd->SetProperty.type, pDAudioCmd->SetProperty.value); 628 break; 629 } 630 631 case DAUDIO_REGISTER_THREAD: 632 { 633 DDCMDREGISTER reg; 635 634 636 635 //dprintf(("ID Reg")); 637 reg.ulFunction= DDCMD_REG_STREAM;638 reg.hStream= pDAudioCmd->Thread.hSemaphore;639 640 641 642 643 644 645 646 636 reg.ulFunction = DDCMD_REG_STREAM; 637 reg.hStream = pDAudioCmd->Thread.hSemaphore; 638 reg.ulSysFileNum = prp->s.ioctl.usSysFileNum; 639 reg.pSHDEntryPoint = NULL; 640 rc = pStream->Register(®); 641 break; 642 } 643 644 case DAUDIO_DEREGISTER_THREAD: 645 { 647 646 //dprintf(("ID DeReg")); 648 649 650 651 652 647 pStream->DeRegister(); 648 break; 649 } 650 651 case DAUDIO_QUERYVERSION: 653 652 //dprintf(("ID qVer")); 654 655 656 657 658 659 653 pDAudioCmd->Version.ulVersion = DAUDIO_VERSION; 654 break; 655 } 656 657 if(rc) 658 { 660 659 //dprintf(("IoctlDirectAudio ret err rc=%ld",rc)); 661 662 663 660 prp->usStatus |= RPERR | RPBADCMD; 661 return; 662 } 664 663 //dprintf(("IoctlDirectAudio ret Ok")); 665 664 return; 666 665 } 667 666 //****************************************************************************** 668 667 //****************************************************************************** 669 668 /**@internal 670 * @param 671 * @return 669 * @param PREQPACKET pointer to the strategy request packet 670 * @return None But the Status in the request packet is updated on error 672 671 * @notes 673 672 * StrategyIoctl is called from the strategy entry point to process IOCTL … … 681 680 extern "C" void StrategyIoctl(PREQPACKET prp, USHORT LDev) 682 681 { 683 682 dprintf(("StrategyIoctl:cat:0x%x, code:0x%x cd %d gd %d", prp->s.ioctl.bCategory, prp->s.ioctl.bCode, current_device, LDev)); 684 683 switch (prp->s.ioctl.bCategory) { 685 684 case DAUDIO_IOCTL_CAT: /* 0x91 */ 686 687 685 IoctlDirectAudio(prp); 686 break; 688 687 689 688 case MIXER_IOCTL_CAT: /* 0x90 */ 690 691 689 IoctlMixer(prp, LDev); 690 break; 692 691 693 692 case AUDIO_IOCTL_CAT: /* 0x80 */ -
OCO/trunk/drv16/waudio.cpp
r526 r533 1360 1360 ulBytesPerIRQ = pConfigInfo->ulPCMConsumeRate >> 6; // 64 interrupts per second 1361 1361 // we can tweak this as needed but generally this should do rjj 1362 #if 0 // commented out by DAZ 1362 1363 // make sure it's an even multiple of 64 1363 1364 ulBytesPerIRQ += 0x00000040; … … 1367 1368 ulBytesPerIRQ = 0x800; 1368 1369 } 1370 #endif 1369 1371 pConfigInfo->ulBytesPerIRQ = ulBytesPerIRQ; 1370 1372 dprintf4(("WAVEAUDIO::ConfigDev BytesPerIRQ:%ld",ulBytesPerIRQ)); -
OCO/trunk/drv16/wavestrm.cpp
r529 r533 55 55 USHORT WAVESTREAM::_vRealignBuffer(ULONG ulEndPos, PSTREAMBUFFER pBuffer) 56 56 { 57 if ( ulEndPos >= pBuffer->ulDonepos) { /* all of the data has been consumed */57 if (ARG1_IS_AFTER_OR_EQUAL_TO_ARG2(ulEndPos, pBuffer->ulDonepos)) { /* all of the data has been consumed */ 58 58 pBuffer->ulBuffpos = pBuffer->ulBuffsz; 59 59 pBuffer->ulDonepos = 0; … … 61 61 } 62 62 63 if ( ulEndPos >= (pBuffer->ulDonepos - pBuffer->ulBuffpos)) { /* some of the data has been consumed */63 if (ARG1_IS_AFTER_OR_EQUAL_TO_ARG2(ulEndPos, (pBuffer->ulDonepos - pBuffer->ulBuffpos))) { /* some of the data has been consumed */ 64 64 pBuffer->ulBuffpos = pBuffer->ulDonepos - ulEndPos; 65 65 pBuffer->ulBuffpos &= 0xFFFFFFFC; //keep it on a dword boundary … … 155 155 fUnderrun = TRUE; 156 156 _ulBytesProcessed = 0; 157 _ulLastPosition = 0; 157 158 _ulBytesWritten = 0; 158 159 } … … 175 176 176 177 _ulBytesProcessed = 0; 178 _ulLastPosition = 0; 177 179 _ulBytesWritten = 0; 178 180 ulStreamState = STREAM_STREAMING; … … 298 300 299 301 if (pahw->Transfer(StreamId, &_configinfo, pDataBuf, ulBuffLeft, &ulBytesWritten) == FALSE) { 300 // This could mean that the hardware has underrun TODO: implement underrun logic302 // This could mean that the hardware has underrun 301 303 rprintf(("WS::AB: pahw->Transfer failed")); 302 304 return (ULONG)-1; … … 304 306 //dprintf(("WS::AB: %lx of %lx bytes written", ulBytesWritten, ulBuffLeft)); 305 307 if (ulBytesWritten == 0) { 306 // This could mean that the hardware has underrun TODO: implement underrun logic308 // This could mean that the hardware has underrun 307 309 //rprintf(("WS::AddBuffer: 0 of %lx bytes written by transfer", ulBuffLeft)); 308 310 return (ULONG)-1; … … 322 324 return ulBytesWritten; 323 325 } 326 324 327 //****************************************************************************** 325 328 // Read data from the audio Buffer. … … 363 366 return TRUE; 364 367 } 368 365 369 //****************************************************************************** 366 370 // called by the irq function in the hardware object when we get an interrupt … … 377 381 { 378 382 PSTREAMBUFFER pTemp; 379 ULONG ulBytes ;383 ULONG ulBytes, ulDelta; 380 384 381 385 // get the stream position. if we get a bad rc or the position is 0 … … 391 395 return; 392 396 } 393 _ulBytesProcessed = ulBytes; 397 398 ulDelta = ulBytes - _ulLastPosition; 399 if (ulBytes < _ulLastPosition) { /* the byte counter in uniaud32 has wrapped */ 400 ulDelta = ulBytes; 401 if (_configinfo.ulBytesPerIRQ > ulDelta) ulDelta = _configinfo.ulBytesPerIRQ; 402 rprintf(("u32 wrap: BytesProcessed=%lx LastPosition=%lx Bytes=%lx Delta=%lx InProcess=%lx Done=%lx", 403 _ulBytesProcessed, _ulLastPosition, ulBytes, ulDelta, qhInProcess.IsElements(), qhDone.IsElements())); 404 } 405 406 _ulBytesProcessed += ulDelta; 407 _ulLastPosition = ulBytes; 394 408 395 409 if(!qhInProcess.IsElements() && !qhDone.IsElements()) { … … 407 421 // done playing the stream 408 422 if ((qhDone.Head() == qhDone.Tail()) && !qhInProcess.IsElements()) { /* only one buffer left */ 409 if ( _ulBytesProcessed < pTemp->ulDonepos) break;423 if (ARG1_IS_BEFORE_ARG2(_ulBytesProcessed, pTemp->ulDonepos)) break; 410 424 } else { /* not the last buffer */ 411 /* if the buffer is bigger than BytesPerIRQ and it's not finished yet, hang on to it */ 412 if (!usBufferMode && (_ulBytesProcessed < pTemp->ulDonepos)) break; 413 //if ((_ulBytesProcessed + _configinfo.ulBytesPerIRQ) < pTemp->ulDonepos) break; 425 /* if uniaud32 is not done playing the data hang on to the buffer */ 426 if (!usBufferMode && ARG1_IS_BEFORE_ARG2(_ulBytesProcessed, pTemp->ulDonepos)) break; 414 427 } 415 428 ReturnBuffer(); … … 485 498 ULONG Seconds, MilliSeconds, Overflow, Processed; 486 499 487 //PS++ optimize code488 500 Processed = _ulBytesProcessed; 489 if (ulStreamState == STREAM_STREAMING) // if the stream is active 490 { 491 if (ulStreamType & STREAM_WRITE) 492 { 493 if (pahw->GetPosition(StreamId, &_configinfo, &Processed) == FALSE) 494 { 495 //DebugInt3(); 496 Processed = _ulBytesProcessed; //last known position 497 } 501 if (ulStreamState == STREAM_STREAMING) { // if the stream is active 502 if (ulStreamType & STREAM_WRITE) { 503 if (pahw->GetPosition(StreamId, &_configinfo, &Processed) == FALSE) { 504 Processed = _ulBytesProcessed; 505 } 498 506 } 499 507 } 500 508 501 509 // if we haven't processed anything then just return _ulTimeBase 502 if(Processed == 0) 503 return(_ulTimeBase); 510 if(Processed == 0) return(_ulTimeBase); 504 511 505 512 Seconds = Processed / _configinfo.ulPCMConsumeRate; … … 515 522 ULONG Processed; 516 523 517 //PS++ optimize code518 524 Processed = _ulBytesProcessed; 519 if (ulStreamState == STREAM_STREAMING) // if the stream is active 520 { 521 if (ulStreamType & STREAM_WRITE) 522 { 523 if (pahw->GetPosition(StreamId, &_configinfo, &Processed) == FALSE) 524 { 525 if (ulStreamState == STREAM_STREAMING) { // if the stream is active 526 if (ulStreamType & STREAM_WRITE) { 527 if (pahw->GetPosition(StreamId, &_configinfo, &Processed) == FALSE) { 525 528 DebugInt3(); 526 529 Processed = _ulBytesProcessed; //last known position … … 590 593 591 594 _ulBytesProcessed = 0; 595 _ulLastPosition = 0; 592 596 _ulBytesWritten = 0; 593 597 fUnderrun = FALSE; … … 632 636 return NO_ERROR; 633 637 } 638 634 639 //silence wave stream before stopping it (removes clicks) 635 640 if(ulStreamType == STREAM_WAVE_PLAY) { … … 652 657 // DDCMD_ENABLE_EVENT the event time will get screwed up. rjj 653 658 _ulBytesProcessed = 0; 659 _ulLastPosition = 0; 654 660 _ulBytesWritten = 0; 655 661 return NO_ERROR; … … 659 665 ULONG WAVESTREAM::PauseStream(PCONTROL_PARM pControl) 660 666 { 661 ULONG ulEndPos;667 //DAZ ULONG ulEndPos; 662 668 663 669 if(ulStreamState == STREAM_PAUSED) { … … 668 674 } 669 675 670 pahw->GetPosition(StreamId, &_configinfo, &ulEndPos);676 //DAZ pahw->GetPosition(StreamId, &_configinfo, &ulEndPos); 671 677 //silence wave stream before stopping it (removes clicks) 672 678 pahw->SetVolume(StreamId, getMixerStreamId(), 0); … … 677 683 dprintf(("WS::PauseStream %lx", StreamId)); 678 684 679 _ulBytesProcessed = ulEndPos;680 681 _vRealignPausedBuffers( ulEndPos);685 //DAZ _ulBytesProcessed = ulEndPos; 686 687 _vRealignPausedBuffers(_ulBytesProcessed); 682 688 683 689 pControl->ulTime = GetCurrentTime(); 684 690 685 691 _ulBytesProcessed = 0; 692 _ulLastPosition = 0; 686 693 _ulBytesWritten = 0; 687 694 fUnderrun = FALSE; … … 755 762 _ulBytesWritten = 0; 756 763 _ulBytesProcessed = 0; 764 _ulLastPosition = 0; 757 765 _ulTimeBase = 0; 758 766 ulSavedInputGain = 0; -
OCO/trunk/drv16/wavestrm.hpp
r526 r533 63 63 ULONG _ulBytesWritten; // number of bytes transferred to uniaud32 64 64 ULONG _ulBytesProcessed; // number of bytes consumed or produced 65 ULONG _ulLastPosition; // Last position of consumed bytes 65 66 ULONG _ulTimeBase; // value in ms. MMPM sends for stream time 66 67 -
OCO/trunk/install/CHANGELOG.TXT
r510 r533 2 2 UNIAUD CHANGELOG 3 3 ================ 4 5 ===== Uniaud16 1.9.5 and Uniaud32 1.9.24/2.1.1 : July 31, 2010 ===== 6 7 * Added code to handle when uniaud32 processed byte counter wraps 8 (uniaud16) 9 10 * All above changes by David Azarewicz 11 12 ===== Uniaud16 1.9.4 and Uniaud32 1.9.24/2.1.1 : July 27, 2010 ===== 13 14 * Driver level underrun detection and attempted recovery removed 15 from Uniaud16. 16 17 * Xrun restart fixed in Uniaud32. 18 19 * PCI bus scan now scans all 256 busses rather than just 16. 20 Dynamic allocation of bus structure instead of static. 21 Other PCI bus scan bugs fixed. (uniaud32) 22 23 * Implemented wild card (PCI_ANY_ID) device matching in PCI bus 24 scan (uniaud32) 25 26 * Implemented wild card (PCI_ANY_ID) device matching in deregister 27 driver (uniaud32) 28 29 * Changed flush_workqueue to not hang on shutdown. (uniaud32) 30 31 * Added mixer quirk for Intel Gateway/eMachines with STAC 922x mixer 32 (uniaud32) 33 34 * All above changes by David Azarewicz 4 35 5 36 ===== 1.9.3 and 1.9.23 : July 10, 2010 ===== -
OCO/trunk/install/control.scr
r529 r533 25 25 ssgroup=0 26 26 ssname="mmbase" 27 ssversion="1.9. 4-SVNr529"27 ssversion="1.9.5-SVNr533" 28 28 sstermdll="ITERM.DLL" 29 29 sstermdllentry="ITermEntry" … … 43 43 ssgroup=17 44 44 ssname="OS/2 Universal Audio: Wave" 45 ssversion="1.9. 4-SVNr529"45 ssversion="1.9.5-SVNr533" 46 46 sssize=680 47 47 ssdll="genin.dll" -
OCO/trunk/uniaud.inc
r529 r533 7 7 # BUILDVERSION must be 3 parts, and only numbers like 5.44.108 8 8 # It is best that 2nd number is always 2 digits, eg at least 10 9 BUILDVERSION = 1.9. 49 BUILDVERSION = 1.9.5 10 10 11 11 # Fixpack version … … 13 13 # ex RC3 GA FIXPACK2 beta_47 14 14 # Comment out to avoid a fixpack line in bldlevel 15 FIXPACK = SVNr5 2915 FIXPACK = SVNr533 16 16 17 17 # ALSA BUILD VERSION
Note:
See TracChangeset
for help on using the changeset viewer.