Changeset 526
- Timestamp:
- Jul 22, 2010, 9:33:17 PM (15 years ago)
- Location:
- OCO/trunk
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
OCO/trunk/drv16/audiohw.cpp
r486 r526 227 227 PAUDIOHW pEle = (PAUDIOHW)pAudioHWList->Head(); 228 228 while (pEle != NULL) { 229 #ifdef DEBUG 230 // dprintf(("dev type: %d",pEle->ulDeviceType)); 231 #endif 229 //dprintf(("dev type: %d",pEle->ulDeviceType)); 232 230 if (pEle->ulDeviceType == Devicetype) 233 231 return(pEle); -
OCO/trunk/drv16/dwavestrm.cpp
r483 r526 46 46 if (pStream == NULL) 47 47 { 48 dprintf(("HookHandler stream %lx not found!", (ULONG) ulSysFileNum));48 rprintf(("HookHandler stream %lx not found!", (ULONG) ulSysFileNum)); 49 49 DebugInt3(); 50 50 return; … … 56 56 rc = DevHelp_PostEventSem(pStream->hSem); 57 57 if(rc != 0) { 58 dprintf(("DevHlp_PostEventSem returned %d", rc));58 rprintf(("DevHlp_PostEventSem returned %d", rc)); 59 59 } 60 60 } … … 80 80 pStreamBuf = new STREAMBUFFER(uLength, (PSTREAMBUF)0, fLooping); 81 81 if(pStreamBuf == NULL) { 82 dprintf(("DWAVESTREAM::Write StreamBuf"));82 rprintf(("DWAVESTREAM::Write StreamBuf")); 83 83 DebugInt3(); 84 84 return 1; … … 89 89 rc = DevHelp_VirtToLin(SELECTOROF(pLock), OFFSETOF(pLock), &linLock); 90 90 if(rc) { 91 dprintf(("DWAVESTREAM::Write VirtToLin"));91 rprintf(("DWAVESTREAM::Write VirtToLin")); 92 92 DebugInt3(); 93 93 delete pStreamBuf; … … 97 97 rc = DevHelp_VMLock(VMDHL_LONG | VMDHL_WRITE, (LIN)pbuf, uLength, -1L, linLock, (PULONG)&PageListCount); 98 98 if(rc) { 99 dprintf(("DWAVESTREAM::Write VMLock"));99 rprintf(("DWAVESTREAM::Write VMLock")); 100 100 DebugInt3(); 101 101 delete pStreamBuf; … … 105 105 rc = DevHelp_VMProcessToGlobal(VMDHGP_WRITE, (LIN)pbuf, uLength, (PLIN)&linAddr); 106 106 if(rc) { 107 dprintf(("DWAVESTREAM::Write ProcToGlob"));107 rprintf(("DWAVESTREAM::Write ProcToGlob")); 108 108 DebugInt3(); 109 109 DevHelp_VMUnLock(linLock); … … 143 143 hSem = pReg->hStream; 144 144 145 #ifdef DEBUG146 145 dprintf(("DWAVESTREAM::Register")); 147 #endif148 146 if(DevHelp_OpenEventSem(hSem) != 0) { 149 dprintf(("DevHlp_OpenEventSem %lx failed!", hSem));147 rprintf(("DevHlp_OpenEventSem %lx failed!", hSem)); 150 148 hSem = 0; 151 149 return 1; … … 158 156 { 159 157 if(DevHelp_CloseEventSem(hSem) != 0) { 160 dprintf(("DevHlp_CloseEventSemaphore %lx failed!", hSem));158 rprintf(("DevHlp_CloseEventSemaphore %lx failed!", hSem)); 161 159 return; 162 160 } … … 168 166 ULONG DWAVESTREAM::StartStream(void) 169 167 { 170 #ifdef DEBUG171 168 dprintf(("DWAVESTREAM::StartStream")); 172 #endif173 169 return WAVESTREAM::StartStream(); 174 170 } 175 171 //***************************************************************************** 176 172 //***************************************************************************** 177 void DWAVESTREAM::AddBuffers( BOOL fFirst)173 void DWAVESTREAM::AddBuffers(SHORT sFirst) 178 174 { 179 175 PSTREAMBUFFER pTemp = (PSTREAMBUFFER)qhDone.Tail(); 180 176 ULONG space, Buff_left, byteswritten; 181 177 182 #ifdef DEBUG183 178 dprintf(("DW::AddBuffers")); 184 #endif185 179 if (!pTemp) pTemp = (PSTREAMBUFFER)qhInProcess.Tail(); 186 180 … … 190 184 if (pahw->GetPosition(StreamId, &_configinfo, &space) != OSSERR_SUCCESS) 191 185 { 192 dprintf(("DWAVESTREAM::AddBuffers GetPositions"));186 rprintf(("DWAVESTREAM::AddBuffers GetPositions")); 193 187 DebugInt3(); 194 188 return; 195 189 } 196 if( fFirst)190 if(sFirst) 197 191 { 198 192 space = min(space, 4*_configinfo.ulFragsize); … … 222 216 else 223 217 { 224 WAVESTREAM::AddBuffers( fFirst);218 WAVESTREAM::AddBuffers(sFirst); 225 219 } 226 220 } … … 284 278 WAVESTREAM(streamtype, pinit, filesysnum, mixerStreamId), fError(FALSE), hCtxHook(0), hSem(0) 285 279 { 286 #ifdef DEBUG287 280 dprintf(("DWS::DWS Init")); 288 #endif289 281 if (DevHelp_AllocateCtxHook((NPFN)HookHandlerAsm, &hCtxHook)) 290 282 { 291 dprintf(("DWAVESTREAM::DWAVESTREAM AllocCtx"));283 rprintf(("DWAVESTREAM::DWAVESTREAM AllocCtx")); 292 284 DebugInt3(); 293 285 fError = TRUE; … … 307 299 APIRET rc = DevHelp_PostEventSem(hSem); 308 300 if(rc != 0) { 309 dprintf(("DevHlp_PostEventSem returned %d", rc));301 rprintf(("DevHlp_PostEventSem returned %d", rc)); 310 302 } 311 303 if(DevHelp_CloseEventSem(hSem) != 0) { 312 dprintf(("DevHlp_CloseEventSemaphore %lx failed!", hSem));304 rprintf(("DevHlp_CloseEventSemaphore %lx failed!", hSem)); 313 305 } 314 306 } -
OCO/trunk/drv16/dwavestrm.hpp
r33 r526 59 59 virtual void ReturnBuffer(void); // returns one buffer 60 60 61 virtual void AddBuffers( BOOL fFirst); // Initialize the audio buffer object61 virtual void AddBuffers(SHORT sFirst); // Initialize the audio buffer object 62 62 63 63 QUEUEHEAD qhReturn; //queue with buffers to be returned -
OCO/trunk/drv16/fmsynth.cpp
r483 r526 48 48 if(OSS16_MidiOpen(current_device, FM_SEND, pStreamId) != OSSERR_SUCCESS) 49 49 { 50 dprintf(("FMSYNTH::Open: OSS16_MidiOpen failed!!"));50 rprintf(("FMSYNTH::Open: OSS16_MidiOpen failed!!")); 51 51 DebugInt3(); 52 52 midiOutStreamId = 0; … … 69 69 #if 0 70 70 if(OSS16_MidiClose(StreamId) != OSSERR_SUCCESS) { 71 dprintf(("FMSYNTH::close: OSS16_MidiClose failed!!"));71 rprintf(("FMSYNTH::close: OSS16_MidiClose failed!!")); 72 72 DebugInt3(); 73 73 return FALSE; … … 121 121 { 122 122 if(MixerSetVolume(mixerStreamId, OSS32_MIX_VOLUME_MIDI, ulVolume) != TRUE) { 123 dprintf(("FMSYNTH::SetVolume: MixerSetVolume failed!!"));123 rprintf(("FMSYNTH::SetVolume: MixerSetVolume failed!!")); 124 124 //not necessarily fatal; maybe there is no volume control for midi 125 125 } -
OCO/trunk/drv16/init.cpp
r483 r526 110 110 //functions have been moved into a seperate code segment) 111 111 if(DevHelp_Lock(SELECTOROF(dbgptr), LOCKTYPE_LONG_ANYMEM, 0, &lockhandle)) { 112 dprintf(("DevHelp_Lock failed on debug selector"));112 rprintf(("DevHelp_Lock failed on debug selector")); 113 113 DebugInt3(); 114 114 return; -
OCO/trunk/drv16/ioctl.cpp
r486 r526 202 202 ULONG ulDevicetype; 203 203 204 #ifdef DEBUG205 204 dprintf(("IACapability: src type: 0x%lx, op %d",p->ulDataType, (USHORT)p->ulOperation)); 206 #endif207 205 208 206 // get the hardware device type based on the datatype and operation 209 207 ulDevicetype = GetHardwareType((USHORT)p->ulDataType,(USHORT)p->ulOperation,LDev); 210 208 211 #ifdef DEBUG 212 // dprintf(("IACapability: dev type: %ld, ldev %d",ulDevicetype, LDev)); 213 #endif 209 //dprintf(("IACapability: dev type: %ld, ldev %d",ulDevicetype, LDev)); 214 210 215 211 // Tell the caller we support this IOCTL … … 231 227 p->ulSamplingRate = HZ_44100; 232 228 // 233 dprintf(("IACapability: Error support"));229 rprintf(("IACapability: Error support")); 234 230 prp->usStatus |= RPERR; 235 231 } 236 232 } 237 233 else { 238 #ifdef DEBUG 239 // dprintf(("IACapability: Error get HW obj")); 240 #endif 234 //dprintf(("IACapability: Error get HW obj")); 241 235 //PS+++ filling to our parameters as say mmpm2.inf for returning error in this call 242 236 // (for HDA only!!!!!) … … 270 264 if (p->usIOCtlRequest != AUDIO_CHANGE) 271 265 { 272 dprintf(("IAudioControl: Error support req:%x",p->usIOCtlRequest));266 rprintf(("IAudioControl: Error support req:%x",p->usIOCtlRequest)); 273 267 p->sReturnCode = INVALID_REQUEST; 274 268 prp->usStatus |= RPERR | RPBADCMD; … … 284 278 if(addr >= 0x10000UL) 285 279 { 286 dprintf(("Invalid MCI_AUDIO_CHANGE pnt %lx!!", (ULONG)pAudChange));280 rprintf(("Invalid MCI_AUDIO_CHANGE pnt %lx!!", (ULONG)pAudChange)); 287 281 p->sReturnCode = INVALID_REQUEST; 288 282 prp->usStatus |= RPERR | RPBADCMD; … … 296 290 if(addr >= 0x10000UL) 297 291 { 298 dprintf(("Invalid MCI_TRACK_INFO pnt %lx!!", (ULONG)pMasterVol));292 rprintf(("Invalid MCI_TRACK_INFO pnt %lx!!", (ULONG)pMasterVol)); 299 293 p->sReturnCode = INVALID_REQUEST; 300 294 prp->usStatus |= RPERR | RPBADCMD; … … 304 298 pStream = FindStream_fromFile((ULONG) prp->s.ioctl.usSysFileNum); 305 299 if(pStream == NULL) { 306 dprintf(("IAudioControl stream %lx not found!", (ULONG) prp->s.ioctl.usSysFileNum));300 rprintf(("IAudioControl stream %lx not found!", (ULONG) prp->s.ioctl.usSysFileNum)); 307 301 DebugInt3(); 308 302 return; … … 316 310 volume = pAudChange->lVolume >> 16UL; 317 311 volume = (volume*OSS32_MAX_VOLUME)/0x7FFFUL; 318 //dprintf(("Set stream volume of %x to %d", prp->s.ioctl.usSysFileNum, volume));312 //dprintf(("Set stream volume of %x to %d", prp->s.ioctl.usSysFileNum, volume)); 319 313 pStream->SetProperty(PROPERTY_VOLUME, MAKE_VOLUME_LR(volume, volume)); 320 314 } … … 390 384 if(DevHelp_VerifyAccess(SELECTOROF(pInit), sizeof(MCI_AUDIO_INIT), OFFSETOF(pInit), VERIFY_READWRITE)) 391 385 { 392 dprintf(("Invalid MCI_AUDIO_INIT pnt %lx!!", (ULONG)pInit));386 rprintf(("Invalid MCI_AUDIO_INIT pnt %lx!!", (ULONG)pInit)); 393 387 prp->usStatus |= RPERR | RPBADCMD; 394 388 return; … … 411 405 if (audioCaps.ulSupport != SUPPORT_SUCCESS) 412 406 { 413 dprintf(("IDirectAudio: DevCaps failed"));407 rprintf(("IDirectAudio: DevCaps failed")); 414 408 pInit->sReturnCode = INVALID_REQUEST; 415 409 prp->usStatus |= RPERR; … … 419 413 else 420 414 { 421 dprintf(("IDirectAudio: HW DevCaps failed"));415 rprintf(("IDirectAudio: HW DevCaps failed")); 422 416 pInit->sReturnCode = INVALID_REQUEST; 423 417 prp->usStatus |= RPERR; … … 427 421 pStream = new DWAVESTREAM(AUDIOHW_WAVE_PLAY, pInit, prp->s.ioctl.usSysFileNum, MixerStreamId); 428 422 if(pStream == NULL) { 429 //dprintf(("IDirectAudio: pStream"));423 //dprintf(("IDirectAudio: pStream")); 430 424 DebugInt3(); 431 425 pInit->sReturnCode = INVALID_REQUEST; … … 437 431 { 438 432 delete pStream; 439 //dprintf(("IlDirectAudio: IsEverythingOk"));433 //dprintf(("IlDirectAudio: IsEverythingOk")); 440 434 DebugInt3(); 441 435 pInit->sReturnCode = INVALID_REQUEST; … … 463 457 if(DevHelp_VerifyAccess(SELECTOROF(pInit), sizeof(MCI_AUDIO_INIT), OFFSETOF(pInit), VERIFY_READWRITE)) 464 458 { 465 dprintf(("Invalid MCI_AUDIO_INIT pnt %lx!!", (ULONG)pInit));459 rprintf(("Invalid MCI_AUDIO_INIT pnt %lx!!", (ULONG)pInit)); 466 460 prp->usStatus |= RPERR | RPBADCMD; 467 461 return; … … 484 478 if (audioCaps.ulSupport != SUPPORT_SUCCESS) 485 479 { 486 dprintf(("IlDirectAudio: DevCaps failed"));480 rprintf(("IlDirectAudio: DevCaps failed")); 487 481 prp->usStatus |= RPERR; 488 482 pInit->sReturnCode = INVALID_REQUEST; 489 483 return; 490 484 } 491 //dprintf(("IoctlDirectAudio ret0"));485 //dprintf(("IoctlDirectAudio ret0")); 492 486 pInit->sReturnCode = 0; 493 487 return; 494 488 } 495 489 else { 496 dprintf(("IoctlDirectAudio err req"));490 rprintf(("IoctlDirectAudio err req")); 497 491 pInit->sReturnCode = INVALID_REQUEST; 498 492 prp->usStatus |= RPERR; … … 508 502 if(DevHelp_VerifyAccess(SELECTOROF(lpCaps), sizeof(OSS32_DEVCAPS), OFFSETOF(lpCaps), VERIFY_READWRITE)) 509 503 { 510 dprintf(("Invalid OSS32_DEVCAPS pnt %lx!!", (ULONG)lpCaps));504 rprintf(("Invalid OSS32_DEVCAPS pnt %lx!!", (ULONG)lpCaps)); 511 505 prp->usStatus |= RPERR | RPBADCMD; 512 506 return; … … 519 513 { 520 514 pHWobj->DevCaps(lpCaps); 521 //dprintf(("IoctlDirectAudio ret1"));515 //dprintf(("IoctlDirectAudio ret1")); 522 516 return; 523 517 } … … 525 519 { 526 520 prp->usStatus |= RPERR; 527 //dprintf(("IoctlDirectAudio ret err1"));521 //dprintf(("IoctlDirectAudio ret err1")); 528 522 return; 529 523 } … … 534 528 if(pStream == NULL) 535 529 { 536 dprintf(("IDirectAudio stream %lx not found!", (ULONG) prp->s.ioctl.usSysFileNum));530 rprintf(("IDirectAudio stream %lx not found!", (ULONG) prp->s.ioctl.usSysFileNum)); 537 531 DebugInt3(); 538 532 prp->usStatus |= RPERR | RPBADCMD; … … 545 539 if(DevHelp_VerifyAccess(SELECTOROF(pDAudioCmd), sizeof(DAUDIO_CMD), OFFSETOF(pDAudioCmd), VERIFY_READWRITE)) 546 540 { 547 dprintf(("Invalid DAUDIO_CMD pnt %lx!!", (ULONG)pDAudioCmd));541 rprintf(("Invalid DAUDIO_CMD pnt %lx!!", (ULONG)pDAudioCmd)); 548 542 prp->usStatus |= RPERR | RPBADCMD; 549 543 return; … … 553 547 { 554 548 case DAUDIO_CLOSE: 555 //dprintf(("ID close"));549 //dprintf(("ID close")); 556 550 delete pStream; 557 551 break; … … 559 553 case DAUDIO_SETVOLUME: 560 554 { 561 //dprintf(("ID SetVolume"));555 //dprintf(("ID SetVolume")); 562 556 pStream->SetProperty(PROPERTY_VOLUME, MAKE_VOLUME_LR(pDAudioCmd->Vol.VolumeL, pDAudioCmd->Vol.VolumeR)); 563 557 break; … … 566 560 case DAUDIO_GETVOLUME: 567 561 { 568 //dprintf(("ID GetVolume"));562 //dprintf(("ID GetVolume")); 569 563 pDAudioCmd->Vol.VolumeL = GET_VOLUME_L(pStream->GetProperty(PROPERTY_VOLUME)); 570 564 pDAudioCmd->Vol.VolumeR = GET_VOLUME_R(pStream->GetProperty(PROPERTY_VOLUME)); … … 582 576 else 583 577 { 584 dprintf(("ID Start rc1"));578 rprintf(("ID Start rc1")); 585 579 rc = 1; //fail 586 580 } … … 616 610 case DAUDIO_GETPOS: 617 611 { 618 //dprintf(("ID GetPos"));612 //dprintf(("ID GetPos")); 619 613 pDAudioCmd->Pos.ulCurrentPos = pStream->GetCurrentPos(); 620 614 pDAudioCmd->Pos.ulWritePos = pStream->GetCurrentWritePos(); … … 624 618 case DAUDIO_ADDBUFFER: 625 619 { 626 //dprintf(("ID AddBuffer"));620 //dprintf(("ID AddBuffer")); 627 621 rc = pStream->Write((PSTREAMBUF)pDAudioCmd->Buffer.lpBuffer, pDAudioCmd->Buffer.ulBufferLength); 628 622 break; … … 631 625 case DAUDIO_SETPROPERTY: 632 626 { 633 //dprintf(("ID SetProp"));627 //dprintf(("ID SetProp")); 634 628 rc = pStream->SetProperty((USHORT)pDAudioCmd->SetProperty.type, pDAudioCmd->SetProperty.value); 635 629 break; … … 640 634 DDCMDREGISTER reg; 641 635 642 //dprintf(("ID Reg"));636 //dprintf(("ID Reg")); 643 637 reg.ulFunction = DDCMD_REG_STREAM; 644 638 reg.hStream = pDAudioCmd->Thread.hSemaphore; … … 651 645 case DAUDIO_DEREGISTER_THREAD: 652 646 { 653 //dprintf(("ID DeReg"));647 //dprintf(("ID DeReg")); 654 648 pStream->DeRegister(); 655 649 break; … … 657 651 658 652 case DAUDIO_QUERYVERSION: 659 //dprintf(("ID qVer"));653 //dprintf(("ID qVer")); 660 654 pDAudioCmd->Version.ulVersion = DAUDIO_VERSION; 661 655 break; … … 664 658 if(rc) 665 659 { 666 //dprintf(("IoctlDirectAudio ret err rc=%ld",rc));660 //dprintf(("IoctlDirectAudio ret err rc=%ld",rc)); 667 661 prp->usStatus |= RPERR | RPBADCMD; 668 662 return; 669 663 } 670 //dprintf(("IoctlDirectAudio ret Ok"));664 //dprintf(("IoctlDirectAudio ret Ok")); 671 665 return; 672 666 } … … 687 681 extern "C" void StrategyIoctl(PREQPACKET prp, USHORT LDev) 688 682 { 689 #ifdef DEBUG690 683 dprintf(("StrategyIoctl:cat:0x%x, code:0x%x cd %d gd %d", prp->s.ioctl.bCategory, prp->s.ioctl.bCode, current_device, LDev)); 691 #endif692 684 switch (prp->s.ioctl.bCategory) { 693 685 case DAUDIO_IOCTL_CAT: /* 0x91 */ … … 721 713 } 722 714 723 #ifdef DEBUG 724 dprintf(("StrategyIoctl:ret:0x%x", (USHORT)prp->usStatus)); 725 #endif 715 //dprintf(("StrategyIoctl:ret:0x%x", (USHORT)prp->usStatus)); 726 716 return; 727 717 } -
OCO/trunk/drv16/maudio.cpp
r468 r526 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% 15 * 15 * MIDI audio hardware object implementation. 16 16 * @version %I% 17 17 * @context 18 * 18 * Unless otherwise noted, all interfaces are Ring-0, 16-bit, kernel stack. 19 19 * @notes 20 20 * @history … … 25 25 #include <os2medef.h> 26 26 #include <audio.h> 27 #include "midi_idc.h" 27 #include "midi_idc.h" // RTMIDI interfaces 28 28 #include "maudio.hpp" 29 29 #include <dbgos2.h> … … 37 37 { 38 38 39 pCaps->ulSupport 39 pCaps->ulSupport = SUPPORT_SUCCESS; 40 40 pCaps->ulDataSubType = SUBTYPE_NONE; 41 41 pCaps->ulResourceUnits = 1; 42 42 pCaps->ulResourceClass = 1; 43 pCaps->fCanRecord 44 pCaps->ulFlags = INPUT |// Input select is supported45 OUTPUT |// Output select is supported46 MONITOR |// Monitor is supported47 VOLUME;// Volume control is supported43 pCaps->fCanRecord = FALSE; 44 pCaps->ulFlags = INPUT | // Input select is supported 45 OUTPUT | // Output select is supported 46 MONITOR | // Monitor is supported 47 VOLUME; // Volume control is supported 48 48 } 49 49 //****************************************************************************** … … 59 59 { 60 60 for (int iChannel=0; iChannel<16; iChannel++) { 61 writeByte(StreamId, (BYTE) (0xB0 + iChannel));// channel mode62 writeByte(StreamId, 123);// all notes off63 61 writeByte(StreamId, (BYTE) (0xB0 + iChannel)); // channel mode 62 writeByte(StreamId, 123); // all notes off 63 writeByte(StreamId, 0); 64 64 } 65 65 … … 72 72 int MIDIAUDIO::writeByte(OSSSTREAMID StreamId, BYTE b) 73 73 { 74 return 0; 74 return 0; // Failure. 75 75 } 76 76 //****************************************************************************** … … 78 78 int MIDIAUDIO::readByte(OSSSTREAMID StreamId) 79 79 { 80 return -1; 80 return -1; // Failure. 81 81 } 82 82 //****************************************************************************** … … 108 108 BOOL MIDIAUDIO::SetVolume(OSSSTREAMID StreamId, OSSSTREAMID mixerStreamId, ULONG ulVolume) 109 109 { 110 110 return FALSE; 111 111 } 112 112 //****************************************************************************** 113 113 //****************************************************************************** 114 int MIDIAUDIO::Pause(OSSSTREAMID StreamId) 114 int MIDIAUDIO::Pause(OSSSTREAMID StreamId) // Pause the operation 115 115 { 116 //dprintf(("DUMMY MIDIAUDIO::Pause"));117 118 116 //dprintf(("DUMMY MIDIAUDIO::Pause")); 117 DebugInt3(); 118 return 0; 119 119 } 120 120 //****************************************************************************** 121 121 //****************************************************************************** 122 int MIDIAUDIO::Resume(OSSSTREAMID StreamId) 122 int MIDIAUDIO::Resume(OSSSTREAMID StreamId) // Resume the operation 123 123 { 124 //dprintf(("DUMMY MIDIAUDIO::Resume"));125 126 124 //dprintf(("DUMMY MIDIAUDIO::Resume")); 125 DebugInt3(); 126 return 0; 127 127 } 128 128 //****************************************************************************** … … 130 130 void MIDIAUDIO::noteOff(OSSSTREAMID StreamId, BYTE mchan, BYTE note, BYTE velocity ) 131 131 { 132 //dprintf2(("MIDIAUDIO::noteOff %d %d %d", mchan, note, velocity));133 134 135 132 //dprintf2(("MIDIAUDIO::noteOff %d %d %d", mchan, note, velocity)); 133 if(OSS16_MidiNoteOff(StreamId, mchan, note, velocity) != OSSERR_SUCCESS) { 134 DebugInt3(); 135 } 136 136 } 137 137 //****************************************************************************** … … 139 139 void MIDIAUDIO::noteOn(OSSSTREAMID StreamId, BYTE mchan, BYTE note, BYTE velocity ) 140 140 { 141 //dprintf2(("MIDIAUDIO::noteOn %d %d %d", mchan, note, velocity));142 143 144 141 //dprintf2(("MIDIAUDIO::noteOn %d %d %d", mchan, note, velocity)); 142 if(OSS16_MidiNoteOn(StreamId, mchan, note, velocity) != OSSERR_SUCCESS) { 143 DebugInt3(); 144 } 145 145 } 146 146 //****************************************************************************** … … 148 148 void MIDIAUDIO::polyphonicPressure(OSSSTREAMID StreamId, BYTE mchan, BYTE note, BYTE value ) 149 149 { 150 //dprintf2(("MIDIAUDIO::polyphonicPressure %d %d %d", mchan, note, value));151 152 153 150 //dprintf2(("MIDIAUDIO::polyphonicPressure %d %d %d", mchan, note, value)); 151 if(OSS16_MidiKeyPressure(StreamId, mchan, note, value) != OSSERR_SUCCESS) { 152 DebugInt3(); 153 } 154 154 } 155 155 //****************************************************************************** … … 157 157 void MIDIAUDIO::controlChange(OSSSTREAMID StreamId, BYTE mchan, BYTE control_number, BYTE value ) 158 158 { 159 //dprintf2(("MIDIAUDIO::controlChange %d %d %d", mchan, control_number, value));160 161 162 159 //dprintf2(("MIDIAUDIO::controlChange %d %d %d", mchan, control_number, value)); 160 if(OSS16_MidiControlChange(StreamId, mchan, control_number, value) != OSSERR_SUCCESS) { 161 DebugInt3(); 162 } 163 163 } 164 164 //****************************************************************************** … … 166 166 void MIDIAUDIO::programChange(OSSSTREAMID StreamId, BYTE mchan, BYTE program_number ) 167 167 { 168 //dprintf2(("MIDIAUDIO::programChange %d %d", mchan, program_number));169 170 171 168 //dprintf2(("MIDIAUDIO::programChange %d %d", mchan, program_number)); 169 if(OSS16_MidiProgramChange(StreamId, mchan, program_number) != OSSERR_SUCCESS) { 170 DebugInt3(); 171 } 172 172 } 173 173 //****************************************************************************** … … 175 175 void MIDIAUDIO::channelPressure(OSSSTREAMID StreamId, BYTE mchan, BYTE value ) 176 176 { 177 //dprintf2(("MIDIAUDIO::channelPressure %d %d", mchan, value));178 179 180 177 //dprintf2(("MIDIAUDIO::channelPressure %d %d", mchan, value)); 178 if(OSS16_MidiChannelPressure(StreamId, mchan, value) != OSSERR_SUCCESS) { 179 DebugInt3(); 180 } 181 181 } 182 182 //****************************************************************************** … … 184 184 void MIDIAUDIO::pitchBend(OSSSTREAMID StreamId, BYTE mchan, BYTE value_lsb, BYTE value_msb) 185 185 { 186 //dprintf2(("MIDIAUDIO::pitchBend %d %d %d", mchan, value_lsb, value_msb));187 188 189 186 //dprintf2(("MIDIAUDIO::pitchBend %d %d %d", mchan, value_lsb, value_msb)); 187 if(OSS16_MidiKeyPressure(StreamId, mchan, value_lsb, value_msb) != OSSERR_SUCCESS) { 188 DebugInt3(); 189 } 190 190 } 191 191 //****************************************************************************** -
OCO/trunk/drv16/midistrm.cpp
r468 r526 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% 15 15 * @notes 16 * 17 * 16 * MIDISTREAM class implementation. The Midi Stream class is derived 17 * from the Stream class. 18 18 * @version %I% 19 19 * @context Unless otherwise noted, all interfaces are Ring-0, 16-bit, 20 * 20 * kernel stack. 21 21 * @history 22 22 * 23 23 */ 24 24 #define INCL_NOPMAPI 25 #define INCL_DOSERRORS 25 #define INCL_DOSERRORS // for ERROR_INVALID_FUNCTION 26 26 #include <os2.h> 27 27 #include <os2me.h> 28 #include <audio.h> 28 #include <audio.h> // for #define MIDI 29 29 30 30 #include <include.h> … … 39 39 USHORT MIDISTREAM::_usBitNumber[ NUM_MidiChannels ] = 40 40 { 0x0001, 0x0002, 0x0004, 0x0008, 41 42 43 41 0x0010, 0x0020, 0x0040, 0x0080, 42 0x0100, 0x0200, 0x0400, 0x0800, 43 0x1000, 0x2000, 0x4000, 0x8000 }; 44 44 45 45 46 46 /**@internal CalcDelay 47 * @param 48 * @return 47 * @param None 48 * @return None 49 49 * @notes 50 * 51 *---------------------------------------------------------- == 52 * 53 * 54 * 55 * 56 * 57 * 50 * 600,000,000 microseconds/10 minutes 51 *---------------------------------------------------------- == X microseconds/clock 52 * usCPQNnum 53 * (ulTempo beats/10 min) * ( 24 * ------------- clocks/beat ) 54 * usCPQNden 55 * 56 * 57 * 25,000,000 * usCPQNden 58 58 *== -------------------------- 59 * 59 * ulTempo * usCPQNnum 60 60 * 61 61 * where 62 62 * usCPQNden = ((usCPQN & 0x3F) + 1) * 3 63 * usCPQNnum = 1 64 * 65 * 63 * usCPQNnum = 1 if bit 6 of usCPQN is set 64 * 65 * or 66 66 * 67 67 * usCPQNden = 1 68 * usCPQNnum = usCPQN + 1 68 * usCPQNnum = usCPQN + 1 if bit 6 is not set 69 69 */ 70 70 void MIDISTREAM::CalcDelay(void) … … 72 72 ULONG ul; 73 73 74 if (usCPQN & 0x40) { 75 76 77 74 if (usCPQN & 0x40) { // bit 6 is set if it's a denominator 75 ul = 25000000 * ((usCPQN & 0x3F) + 1); 76 ulPerClock = ul / ulTempo; 77 ulPerClock *= 3; 78 78 } else { 79 80 79 ul = ulTempo * (usCPQN+1); 80 ulPerClock = 25000000 / ul; 81 81 } 82 82 } … … 84 84 85 85 /**@external MIDISTRM::Process 86 * 87 * 86 * Consume MIDI bytes from the MMPM/2 stream buffers and send 87 * them off to the MIDI parser to be interpreted. 88 88 * @param void 89 89 * @return void 90 90 * @notes Runs at Task time on a global context hook; does not run 91 * on an interrupt level.Interacts with the Timer object defined92 * 93 * 91 * on an interrupt level. Interacts with the Timer object defined 92 * for this stream to obtain current time and to request next Stream 93 * time to be scheduled. 94 94 */ 95 95 void MIDISTREAM::Process( void ) 96 96 { 97 ULONG ulNewTime; 98 ULONG ulElapsedTime; 97 ULONG ulNewTime; // Time, in mSec, on entry. 98 ULONG ulElapsedTime; // Elapsed time, last tick to this one. 99 99 100 100 // Update time variables. 101 101 ulNewTime = ((MIDIAUDIO*) pahw)->getTimer()->ulGetTime(); 102 102 if ( ulNewTime > _ulLastProcess ) 103 103 ulElapsedTime = ulNewTime - _ulLastProcess; 104 104 else 105 105 ulElapsedTime = 0; 106 106 107 107 _ulLastProcess = ulNewTime; 108 108 ulCurrentTime = ulNewTime; 109 109 110 if (qhInProcess.IsElements() == 0) 111 112 113 if (ulStreamState == STREAM_PAUSED) 114 110 if (qhInProcess.IsElements() == 0) // no buffers to process? 111 return; 112 113 if (ulStreamState == STREAM_PAUSED) // is the stream paused? 114 return; 115 115 116 116 ProcessEvents(); … … 123 123 124 124 while (lWait <= 0 && qhInProcess.IsElements()) { 125 126 127 128 129 130 131 132 125 parse(*(pbuff + (pstreambuff->ulBuffpos)++)); 126 127 if (pstreambuff->ulBuffpos >= buffsz) { 128 qhDone.PushOnTail(qhInProcess.PopHead()); 129 pstreambuff = (PSTREAMBUFFER) qhInProcess.Head(); 130 pbuff = pstreambuff->pBuffptr; 131 buffsz = pstreambuff->ulBuffsz; 132 } 133 133 } 134 134 while (qhDone.IsElements()) 135 135 ReturnBuffer(); 136 136 137 137 // Determine next time to run. If we submit a time that has already … … 163 163 } 164 164 /**@internal MIDISTREAM::_allNotesOff 165 * 165 * Shut off all notes that are currently playing. 166 166 * @param None. 167 167 * @return void 168 168 * @notes This function walks the _notesOn array and shuts off any note 169 * 169 * that is flagged as being actively played. 170 170 */ 171 171 void MIDISTREAM::_allNotesOff( void ) 172 172 { 173 173 for ( USHORT noteNum=0; noteNum < NUM_MidiNotes; ++noteNum) 174 175 176 177 178 179 pahw->noteOff(StreamId,(BYTE)mchan, (BYTE)noteNum, 0 );180 181 174 if (_notesOn[noteNum]) 175 // This note number is playing on one or more channels. 176 // Shut the note off on all channels on which it is playing. 177 for ( USHORT mchan=0; mchan < NUM_MidiChannels; ++mchan) 178 if (_notesOn[noteNum] & _usBitNumber[mchan]) { 179 pahw->noteOff(StreamId, (BYTE)mchan, (BYTE)noteNum, 0 ); 180 _notesOn[noteNum] &= ~(_usBitNumber[mchan]); 181 } 182 182 } 183 183 //****************************************************************************** … … 185 185 ULONG MIDISTREAM::StartStream(void) 186 186 { 187 //dprintf(("MIDISTREAM::StartStream %lx %lx", (void far *)this, StreamId));188 189 state = S_Init;// Reset parser state.190 message.clear();// Clear current message.191 192 193 194 195 196 197 198 199 200 201 187 //dprintf(("MIDISTREAM::StartStream %lx %lx", (void far *)this, StreamId)); 188 189 state = S_Init; // Reset parser state. 190 message.clear(); // Clear current message. 191 lWait = 0; //SvL, reset this too 192 193 pahw->getTimer()->vSetTime(ulCurrentTime); 194 if (!pahw->Start(StreamId)) { 195 DebugInt3(); 196 return ERROR_START_STREAM; 197 } 198 199 ulStreamState = STREAM_STREAMING; 200 pahw->SetVolume(StreamId, getMixerStreamId(), volume); 201 return NO_ERROR; 202 202 } 203 203 //****************************************************************************** … … 205 205 ULONG MIDISTREAM::StopStream(PCONTROL_PARM pControl) 206 206 { 207 208 //dprintf(("MIDISTREAM::StopStream %lx (already stopped)", StreamId));209 210 211 212 213 //dprintf(("MIDISTREAM::StopStream %lx %lx", (void far *)this, StreamId));214 215 216 217 218 219 207 if(ulStreamState == STREAM_STOPPED) { 208 //dprintf(("MIDISTREAM::StopStream %lx (already stopped)", StreamId)); 209 pControl->ulTime = GetCurrentTime(); 210 return NO_ERROR; 211 } 212 213 //dprintf(("MIDISTREAM::StopStream %lx %lx", (void far *)this, StreamId)); 214 ulStreamState = STREAM_STOPPED; 215 pahw->Stop(StreamId); 216 _allNotesOff(); 217 ReturnBuffers(); 218 pControl->ulTime = GetCurrentTime(); 219 return NO_ERROR; 220 220 } 221 221 //****************************************************************************** … … 223 223 ULONG MIDISTREAM::PauseStream(PCONTROL_PARM pControl) 224 224 { 225 //dprintf(("MIDISTREAM::PauseStream %lx %lx", (void far *)this, StreamId));226 if (ulStreamState == STREAM_PAUSED) {// is the stream paused?227 228 229 230 231 232 233 234 235 225 //dprintf(("MIDISTREAM::PauseStream %lx %lx", (void far *)this, StreamId)); 226 if (ulStreamState == STREAM_PAUSED) { // is the stream paused? 227 DebugInt3(); 228 return ERROR_INVALID_SEQUENCE; 229 } 230 231 pahw->Stop(StreamId); 232 _allNotesOff(); 233 pControl->ulTime = GetCurrentTime(); 234 ulStreamState = STREAM_PAUSED; 235 return NO_ERROR; 236 236 } 237 237 //****************************************************************************** … … 239 239 ULONG MIDISTREAM::ResumeStream(void) 240 240 { 241 //dprintf(("MIDISTREAM::ResumeStream %lx %lx", (void far *)this, StreamId));242 if (ulStreamState != STREAM_PAUSED) {// is the stream paused?243 244 245 246 247 state = S_Init;// Reset parser state.248 message.clear();// Clear current message.249 250 251 252 253 241 //dprintf(("MIDISTREAM::ResumeStream %lx %lx", (void far *)this, StreamId)); 242 if (ulStreamState != STREAM_PAUSED) { // is the stream paused? 243 DebugInt3(); 244 return ERROR_INVALID_SEQUENCE; 245 } 246 247 state = S_Init; // Reset parser state. 248 message.clear(); // Clear current message. 249 pahw->getTimer()->vSetTime(ulCurrentTime); 250 pahw->Start(StreamId); 251 pahw->SetVolume(StreamId, getMixerStreamId(), volume); 252 ulStreamState = STREAM_STREAMING; 253 return NO_ERROR; 254 254 } 255 255 //****************************************************************************** … … 257 257 BOOL MIDISTREAM::SetProperty(int type, ULONG value, ULONG reserved) 258 258 { 259 260 261 volume = value; 262 263 264 265 266 267 268 269 270 259 switch(type) { 260 case PROPERTY_VOLUME: 261 volume = value; 262 if(ulStreamState == STREAM_STREAMING) { 263 pahw->SetVolume(StreamId, getMixerStreamId(), volume); 264 } 265 break; 266 267 default: 268 return STREAM::SetProperty(type, value, reserved); 269 } 270 return TRUE; 271 271 } 272 272 //****************************************************************************** … … 275 275 STREAM(streamtype, filesysnum, mixerStreamId) 276 276 { 277 //dprintf(("MIDISTREAM::ctor"));278 279 280 281 282 283 // 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 277 //dprintf(("MIDISTREAM::ctor")); 278 279 // get the pointer to the hardware object 280 pahw = (MIDIAUDIO *)GetHardwareDevice(streamtype); 281 if(pahw) { 282 if(pahw->Open(0, streamtype, filesysnum, &StreamId) == FALSE) { 283 // dprintf(("MIDISTREAM ctor: open failed!!")); 284 DebugInt3(); 285 } 286 } 287 else DebugInt3(); 288 289 // Initialize tempo & scheduling information. 290 ulTempo = 1200; 291 usCPQN = 0; 292 CalcDelay(); 293 lWait = 0; 294 _ulLastProcess = 0; 295 296 // Reset the parser. 297 state = S_Init; 298 message.clear(); 299 300 // Reset our tracking of which notes are currently on. 301 for (int i=0; i<NUM_MidiNotes; ++i) 302 _notesOn[ i ] = 0; 303 303 } 304 304 //****************************************************************************** … … 306 306 MIDISTREAM::~MIDISTREAM() 307 307 { 308 309 310 311 } 312 //****************************************************************************** 313 //****************************************************************************** 314 308 if(StreamId && pahw) { 309 pahw->Close(StreamId); 310 } 311 } 312 //****************************************************************************** 313 //****************************************************************************** 314 -
OCO/trunk/drv16/mixer.cpp
r486 r526 116 116 if(DevHelp_VerifyAccess(SELECTOROF(pMixStruct), sizeof(MIXSTRUCT), OFFSETOF(pMixStruct), VERIFY_READWRITE)) 117 117 { 118 dprintf(("Invalid IOCTL90 pointer %lx!!", (ULONG)pMixStruct));118 rprintf(("Invalid IOCTL90 pointer %lx!!", (ULONG)pMixStruct)); 119 119 prp->usStatus |= RPERR | RPBADCMD; 120 120 return; … … 144 144 if(DevHelp_VerifyAccess(SELECTOROF(pMixStruct), sizeof(MIXSTRUCT), OFFSETOF(pMixStruct), VERIFY_READONLY)) 145 145 { 146 dprintf(("Invalid IOCTL90 pointer %lx!!", (ULONG)pMixStruct));146 rprintf(("Invalid IOCTL90 pointer %lx!!", (ULONG)pMixStruct)); 147 147 prp->usStatus |= RPERR | RPBADCMD; 148 148 return; … … 192 192 // case I90SRC_RES6: 193 193 default: 194 dprintf(("IoctlMixer: Unk VolL:%lx", (ULONG)pMixStruct->VolumeL));194 rprintf(("IoctlMixer: Unk VolL:%lx", (ULONG)pMixStruct->VolumeL)); 195 195 break; 196 196 } … … 253 253 if(DevHelp_VerifyAccess(SELECTOROF(pIoctlData), sizeof(ULONG), OFFSETOF(pIoctlData), VERIFY_READWRITE)) 254 254 { 255 dprintf(("Invalid IOCTL90 pointer %lx!!", (ULONG)pIoctlData));255 rprintf(("Invalid IOCTL90 pointer %lx!!", (ULONG)pIoctlData)); 256 256 prp->usStatus |= RPERR | RPBADCMD; 257 257 return; … … 263 263 if(DevHelp_VerifyAccess(SELECTOROF(pIoctlMap), sizeof(ALSAIOCTLMap), OFFSETOF(pIoctlMap), VERIFY_READWRITE)) 264 264 { 265 dprintf(("Invalid IOCTL90 pointer %lx!!", (ULONG)pMixStruct));265 rprintf(("Invalid IOCTL90 pointer %lx!!", (ULONG)pMixStruct)); 266 266 prp->usStatus |= RPERR | RPBADCMD; 267 267 return; … … 277 277 if(DevHelp_VerifyAccess(SELECTOROF(pIoctlData), sizeof(ULONG), OFFSETOF(pIoctlData), VERIFY_READONLY)) 278 278 { 279 dprintf(("Invalid IOCTL90 pointer %lx!!", (ULONG)pIoctlData));279 rprintf(("Invalid IOCTL90 pointer %lx!!", (ULONG)pIoctlData)); 280 280 prp->usStatus |= RPERR | RPBADCMD; 281 281 return; … … 286 286 if(hMixerNotifySem != 0) { 287 287 if(DevHelp_OpenEventSem(hMixerNotifySem) != 0) { 288 dprintf(("CALLBACKREG: DevHlp_OpenEventSem %lx failed!", hMixerNotifySem));288 rprintf(("CALLBACKREG: DevHlp_OpenEventSem %lx failed!", hMixerNotifySem)); 289 289 prp->usStatus |= RPERR | RPBADCMD; 290 290 return; … … 294 294 if(oldsem) { 295 295 if(DevHelp_CloseEventSem(oldsem) != 0) { 296 dprintf(("CALLBACKREG: DevHlp_OpenEventSem %lx failed!", oldsem));296 rprintf(("CALLBACKREG: DevHlp_OpenEventSem %lx failed!", oldsem)); 297 297 prp->usStatus |= RPERR | RPBADCMD; 298 298 return; … … 304 304 // case MSGBUF: 305 305 default: 306 dprintf(("IoctlMixer: bad code:%lx", (ULONG)prp->s.ioctl.bCode));306 rprintf(("IoctlMixer: bad code:%lx", (ULONG)prp->s.ioctl.bCode)); 307 307 prp->usStatus |= RPERR | RPBADCMD; 308 308 return; … … 317 317 fSetWaveVolume = FALSE; 318 318 //if per-stream volume not supported, change PCM volume instead 319 //dprintf(("Setting PCM volume instead")); 319 320 return MixerSetVolume(mixerStreamId, OSS32_MIX_VOLUME_PCM, Volume, fFlags); 320 321 } … … 358 359 359 360 if(OSS16_MixSetVolume(mixerStreamId, (USHORT)ulControl, ulVolume) != OSSERR_SUCCESS) { 360 dprintf(("MixerSetVolume: OSS16_MixSetVolume failed!!"));361 rprintf(("MixerSetVolume: OSS16_MixSetVolume failed!!")); 361 362 return FALSE; 362 363 } … … 506 507 507 508 if(OSS16_MixSetProperty(mixerStreamId, (USHORT)ulControl, ulALSAValue) != OSSERR_SUCCESS) { 508 dprintf(("MixerSetProperty: OSS16_MixSetProperty failed!!"));509 rprintf(("MixerSetProperty: OSS16_MixSetProperty failed!!")); 509 510 return FALSE; 510 511 } … … 592 593 rc = DevHelp_PostEventSem(hMixerNotifySem); 593 594 if(rc != 0) { 594 dprintf(("MixerNotifyChange: DevHlp_PostEventSem returned %d", rc));595 rprintf(("MixerNotifyChange: DevHlp_PostEventSem returned %d", rc)); 595 596 } 596 597 rc = DevHelp_VirtToLin(SELECTOROF(pNumPosts), OFFSETOF(pNumPosts), &linaddr); … … 602 603 rc = DevHelp_ResetEventSem(hMixerNotifySem, linaddr); 603 604 if(rc != 0) { 604 dprintf(("MixerNotifyChange: DevHelp_ResetEventSem returned %d", rc));605 rprintf(("MixerNotifyChange: DevHelp_ResetEventSem returned %d", rc)); 605 606 } 606 607 } … … 651 652 } 652 653 if(mixcaps.fuCtrlCaps & OSS32_MIX_FLAG(OSS32_MIX_VOLUME_MIDI)) { 653 dprintf(("MixerInit: MIX_VOLUME_MIDI not processed"));654 rprintf(("MixerInit: MIX_VOLUME_MIDI not processed")); 654 655 } 655 656 if(mixcaps.fuCtrlCaps & OSS32_MIX_FLAG(OSS32_MIX_VOLUME_LINEIN)) { … … 729 730 mixinfo.VolumeR = mixinfo.VolumeL = 80; 730 731 IoctlMixer(&rp, LDev); 731 //dprintf(("MixerInit: MIX_VOLUME_HEADPHONE not processed"));732 //dprintf(("MixerInit: MIX_VOLUME_HEADPHONE not processed")); 732 733 } 733 734 if(mixcaps.fuCtrlCaps & OSS32_MIX_FLAG(OSS32_MIX_VOLUME_AUX)) { -
OCO/trunk/drv16/mpu401.cpp
r478 r526 61 61 strcpy( szRTMIDI_Name, szName ); // Setup instance name. 62 62 strcat( szRTMIDI_Name, szSuffix ); // Append ASCII number to instance name. 63 //dprintf(("rtmidi name [%s]",szRTMIDI_Name));63 //dprintf(("rtmidi name [%s]",szRTMIDI_Name)); 64 64 ulRTMIDI_Caps = MIDICAPSA_INPUT | MIDICAPSA_OUTPUT; // Set RTMIDI caps. 65 65 midiOutStreamId = 0; … … 72 72 { 73 73 // dprintf(("MPU_401::open")); 74 if(midiOutStreamId == 0) 74 if(midiOutStreamId == 0) 75 75 { 76 76 //vladest if(OSS16_MidiOpen(OSS32_DEFAULT_MPU401_DEVICE, MPU401_SEND, pStreamId) != OSSERR_SUCCESS) -
OCO/trunk/drv16/ossidc16.cpp
r508 r526 5 5 */ 6 6 7 extern "C" { 7 extern "C" { // 16-bit header files are not C++ aware 8 8 #define INCL_16 9 9 #define INCL_DOSINFOSEG … … 33 33 34 34 void DumpDeviceCaps (LPOSS32_DEVCAPS pDevCaps); 35 void DumpWaveCaps 36 void DumpMixerCaps 35 void DumpWaveCaps (LPWAVE_CAPS pWaveCaps); 36 void DumpMixerCaps (LPOSS32_MIXCAPS pMixCaps); 37 37 #endif 38 38 … … 56 56 // Attach to the 32 bits OSS driver 57 57 if(DevHelp_AttachDD((NPSZ)"ALSA32$ ",(NPBYTE)&IDCTable)) { 58 58 return FALSE; 59 59 } 60 60 idcpacket.init.handler16 = (ULONG)(VOID FAR *)OSSIDC_ENTRY; … … 77 77 IDC32_PACKET idcpacket; 78 78 OSS32_DEVCAPS devcaps; 79 OSSRET 80 81 _fmemset(&idcpacket, 0, sizeof(idcpacket)); 82 83 idcpacket.fileid 79 OSSRET ret; 80 81 _fmemset(&idcpacket, 0, sizeof(idcpacket)); 82 83 idcpacket.fileid = 0x666; 84 84 idcpacket.devcaps.devicenr = devicenr; 85 85 idcpacket.devcaps.pDevCaps = (ULONG)&devcaps; … … 87 87 88 88 #ifdef DEBUG 89 90 91 92 89 if (ret == OSSERR_SUCCESS) 90 DumpDeviceCaps (&devcaps); 91 else 92 dprintf (("IDC32_OSS32_QUERYDEVCAPS - FAILED!")); 93 93 #endif 94 94 … … 123 123 { 124 124 IDC32_PACKET idcpacket; 125 OSSRET 126 127 _fmemset(&idcpacket, 0, sizeof(idcpacket)); 128 129 idcpacket.fileid 130 idcpacket.open.devicenr 125 OSSRET ret; 126 127 _fmemset(&idcpacket, 0, sizeof(idcpacket)); 128 129 idcpacket.fileid = ulSysFileNum; 130 idcpacket.open.devicenr = devicenr; 131 131 idcpacket.open.streamtype = (ulStreamType == STREAM_WAVE_PLAY) ? OSS32_STREAM_WAVEOUT : OSS32_STREAM_WAVEIN; 132 132 ret = CallOSS32(IDC32_WAVE_OPEN, &idcpacket); … … 216 216 if(SELECTOROF(pHwParams) != _SS()) 217 217 {//must be located on the stack! 218 219 220 218 dprintf(("OSS16_WaveSetFormat error. Invalid stack segment for parameters...")); 219 DebugInt3(); 220 return OSSERR_INVALID_PARAMETER; 221 221 } 222 222 223 idcpacket.fileid 224 idcpacket.streamid 223 idcpacket.fileid = FindStreamFileId_fromStreamId(StreamId); 224 idcpacket.streamid = StreamId; 225 225 idcpacket.sethwparams.hwparams = (ULONG)pHwParams; 226 226 return CallOSS32(IDC32_WAVE_SETHWPARAMS, &idcpacket); … … 229 229 //****************************************************************************** 230 230 OSSRET DBGCALLCONV OSS16_WaveAddBuffer(OSSSTREAMID StreamId, LINEAR pBuffer, ULONG size, 231 232 { 233 IDC32_PACKET idcpacket; 234 OSSRET 235 236 _fmemset(&idcpacket, 0, sizeof(idcpacket)); 237 238 idcpacket.fileid 239 idcpacket.streamid 231 ULONG FAR *lpBytesTransferred) 232 { 233 IDC32_PACKET idcpacket; 234 OSSRET ret; 235 236 _fmemset(&idcpacket, 0, sizeof(idcpacket)); 237 238 idcpacket.fileid = FindStreamFileId_fromStreamId(StreamId); 239 idcpacket.streamid = StreamId; 240 240 idcpacket.buffer.buffer = pBuffer; 241 241 idcpacket.buffer.size = size; … … 250 250 { 251 251 IDC32_PACKET idcpacket; 252 OSSRET 253 254 _fmemset(&idcpacket, 0, sizeof(idcpacket)); 255 256 idcpacket.fileid 257 idcpacket.streamid 252 OSSRET ret; 253 254 _fmemset(&idcpacket, 0, sizeof(idcpacket)); 255 256 idcpacket.fileid = FindStreamFileId_fromStreamId(StreamId); 257 idcpacket.streamid = StreamId; 258 258 ret = CallOSS32(IDC32_WAVE_GETPOS, &idcpacket); 259 259 … … 266 266 { 267 267 IDC32_PACKET idcpacket; 268 OSSRET 269 270 _fmemset(&idcpacket, 0, sizeof(idcpacket)); 271 272 idcpacket.fileid 273 idcpacket.streamid 268 OSSRET ret; 269 270 _fmemset(&idcpacket, 0, sizeof(idcpacket)); 271 272 idcpacket.fileid = FindStreamFileId_fromStreamId(StreamId); 273 idcpacket.streamid = StreamId; 274 274 ret = CallOSS32(IDC32_WAVE_GETSPACE, &idcpacket); 275 275 … … 282 282 { 283 283 IDC32_PACKET idcpacket; 284 OSSRET 285 286 _fmemset(&idcpacket, 0, sizeof(idcpacket)); 287 288 idcpacket.fileid 289 idcpacket.streamid 284 OSSRET ret; 285 286 _fmemset(&idcpacket, 0, sizeof(idcpacket)); 287 288 idcpacket.fileid = FindStreamFileId_fromStreamId(StreamId); 289 idcpacket.streamid = StreamId; 290 290 ret = CallOSS32(IDC32_WAVE_GETHWPTR, &idcpacket); 291 291 … … 298 298 { 299 299 IDC32_PACKET idcpacket; 300 OSSRET 301 302 _fmemset(&idcpacket, 0, sizeof(idcpacket)); 303 304 idcpacket.fileid 305 idcpacket.streamid 300 OSSRET ret; 301 302 _fmemset(&idcpacket, 0, sizeof(idcpacket)); 303 304 idcpacket.fileid = FindStreamFileId_fromStreamId(StreamId); 305 idcpacket.streamid = StreamId; 306 306 ret = CallOSS32(IDC32_WAVE_GETSTATUS, &idcpacket); 307 307 … … 317 317 _fmemset(&idcpacket, 0, sizeof(idcpacket)); 318 318 319 idcpacket.fileid 320 idcpacket.streamid 319 idcpacket.fileid = FindStreamFileId_fromStreamId(StreamId); 320 idcpacket.streamid = StreamId; 321 321 idcpacket.setwavevol.volume = volume; 322 322 return CallOSS32(IDC32_WAVE_SETVOLUME, &idcpacket); … … 327 327 { 328 328 IDC32_PACKET idcpacket; 329 OSSRET 329 OSSRET ret; 330 330 331 331 dprintf(("OSS16_MidiOpen. type: %d",midiType)); 332 332 _fmemset(&idcpacket, 0, sizeof(idcpacket)); 333 333 334 idcpacket.fileid 335 idcpacket.open.devicenr 334 idcpacket.fileid = 0x666; //TODO 335 idcpacket.open.devicenr = devicenr; 336 336 switch(midiType) { 337 337 case MPU401_RECEIVE: 338 339 338 idcpacket.open.streamtype = OSS32_STREAM_MPU401_MIDIIN; 339 break; 340 340 case MPU401_SEND: 341 342 341 idcpacket.open.streamtype = OSS32_STREAM_MPU401_MIDIOUT; 342 break; 343 343 case FM_SEND: 344 345 344 idcpacket.open.streamtype = OSS32_STREAM_FM_MIDIOUT; 345 break; 346 346 case WAVETABLE_SEND: 347 348 347 idcpacket.open.streamtype = OSS32_STREAM_WAVETABLE_MIDIOUT; 348 break; 349 349 } 350 350 ret = CallOSS32(IDC32_MIDI_OPEN, &idcpacket); … … 361 361 _fmemset(&idcpacket, 0, sizeof(idcpacket)); 362 362 363 idcpacket.fileid 364 idcpacket.streamid 363 idcpacket.fileid = 0x666; //TODO 364 idcpacket.streamid = StreamId; 365 365 idcpacket.midiwrite.midiByte = midiByte; 366 366 return CallOSS32(IDC32_MIDI_WRITE, &idcpacket); … … 371 371 { 372 372 IDC32_PACKET idcpacket; 373 OSSRET 374 375 // 373 OSSRET ret; 374 375 // dprintf(("OSS16_MidiRead. id: %d",StreamId)); 376 376 _fmemset(&idcpacket, 0, sizeof(idcpacket)); 377 377 378 378 if(SELECTOROF(buffer) != _SS()) 379 379 {//must be located on the stack! 380 381 380 DebugInt3(); 381 return OSSERR_INVALID_PARAMETER; 382 382 } 383 383 384 idcpacket.fileid = 0x666;//TODO385 idcpacket.streamid 384 idcpacket.fileid = 0x666; //TODO 385 idcpacket.streamid = StreamId; 386 386 idcpacket.midiread.buffer = (ULONG)buffer; 387 387 idcpacket.midiread.bufsize = bufsize; … … 397 397 IDC32_PACKET idcpacket; 398 398 OSS32_MIDICAPS midiCaps; 399 OSSRET 399 OSSRET ret; 400 400 401 401 dprintf(("OSS16_MidiQueryCaps. id: %d",streamid)); … … 530 530 { 531 531 IDC32_PACKET idcpacket; 532 OSSRET 533 534 _fmemset(&idcpacket, 0, sizeof(idcpacket)); 535 536 idcpacket.fileid 537 idcpacket.open.devicenr 532 OSSRET ret; 533 534 _fmemset(&idcpacket, 0, sizeof(idcpacket)); 535 536 idcpacket.fileid = 0x766; //TODO 537 idcpacket.open.devicenr = devicenr; 538 538 ret = CallOSS32(IDC32_MIXER_OPEN, &idcpacket); 539 539 *pStreamId = idcpacket.streamid; … … 560 560 _fmemset(&idcpacket, 0, sizeof(idcpacket)); 561 561 562 idcpacket.fileid 563 idcpacket.streamid 562 idcpacket.fileid = 0x766; //TODO 563 idcpacket.streamid = StreamId; 564 564 idcpacket.mixvol.line = usLine; 565 565 idcpacket.mixvol.volume = ulVolume; … … 572 572 { 573 573 IDC32_PACKET idcpacket; 574 OSSRET 575 576 _fmemset(&idcpacket, 0, sizeof(idcpacket)); 577 578 idcpacket.fileid 579 idcpacket.streamid 574 OSSRET ret; 575 576 _fmemset(&idcpacket, 0, sizeof(idcpacket)); 577 578 idcpacket.fileid = 0x766; //TODO 579 idcpacket.streamid = StreamId; 580 580 idcpacket.mixvol.line = usLine; 581 581 … … 592 592 _fmemset(&idcpacket, 0, sizeof(idcpacket)); 593 593 594 idcpacket.fileid = 0x766;//TODO595 idcpacket.streamid 594 idcpacket.fileid = 0x766; //TODO 595 idcpacket.streamid = StreamId; 596 596 idcpacket.mixprop.property = usProperty; 597 idcpacket.mixprop.value 597 idcpacket.mixprop.value = ulValue; 598 598 599 599 return CallOSS32(IDC32_MIXER_SETPROPERTY, &idcpacket); … … 603 603 OSSRET DBGCALLCONV OSS16_MixGetProperty(OSSSTREAMID StreamId, USHORT usProperty, ULONG FAR *pValue) 604 604 { 605 606 OSSRETret;607 608 609 610 idcpacket.fileid= 0x766; //TODO611 idcpacket.streamid= StreamId;612 613 614 615 616 605 IDC32_PACKET idcpacket; 606 OSSRET ret; 607 608 _fmemset(&idcpacket, 0, sizeof(idcpacket)); 609 610 idcpacket.fileid = 0x766; //TODO 611 idcpacket.streamid = StreamId; 612 idcpacket.mixprop.property = usProperty; 613 614 ret = CallOSS32(IDC32_MIXER_GETPROPERTY, &idcpacket); 615 *pValue = idcpacket.mixprop.value; 616 return ret; 617 617 } 618 618 //****************************************************************************** … … 620 620 OSSRET DBGCALLCONV OSS16_MixQueryCaps(OSSSTREAMID Streamid, OSS32_MIXCAPS FAR *pCaps) 621 621 { 622 IDC32_PACKETidcpacket;623 624 OSSRETret;625 626 627 628 629 630 631 622 IDC32_PACKET idcpacket; 623 OSS32_MIXCAPS mixerCaps; 624 OSSRET ret; 625 626 _fmemset(&idcpacket, 0, sizeof(idcpacket)); 627 628 idcpacket.fileid = 0x766; //TODO 629 idcpacket.streamid = Streamid; 630 idcpacket.mixcaps.pCaps = (ULONG)&mixerCaps; 631 ret = CallOSS32(IDC32_MIXER_QUERYCAPS, &idcpacket); 632 632 633 633 #ifdef DEBUG 634 635 636 637 634 if (ret == OSSERR_SUCCESS) 635 DumpMixerCaps (&mixerCaps); 636 else 637 dprintf (("IDC32_MIXER_QUERYCAPS - FAILED!")); 638 638 #endif 639 639 640 641 640 _fmemcpy(pCaps, &mixerCaps, sizeof(mixerCaps)); 641 return ret; 642 642 } 643 643 //****************************************************************************** … … 646 646 OSSRET CallOSS32(USHORT cmd, IDC32_PACKET FAR *pIDCPacket) 647 647 { 648 649 650 651 652 653 654 655 656 657 658 659 660 661 // 662 663 664 665 666 667 668 669 670 671 672 673 674 675 648 ULONG rc = 0; 649 ULONG idcptr = (ULONG)IDCTable.ProtIDCEntry; 650 ULONG idcparm; 651 652 if(idcptr == 0) 653 return OSSERR_ACCESS_DENIED; 654 655 if(SELECTOROF(pIDCPacket) != _SS()) { 656 dprintf(("CallOSS32 error. Invalid stack segment for parameters...")); 657 DebugInt3(); 658 return OSSERR_INVALID_PARAMETER; 659 } 660 661 // dprintf(("CallOSS32. cmd: %d", cmd)); 662 663 idcparm = (ULONG)pIDCPacket; 664 665 _asm { 666 pusha 667 mov cx, cmd 668 mov dx, word ptr [idcparm+2] 669 mov bx, word ptr [idcparm] 670 call dword ptr [idcptr] 671 mov word ptr rc, ax 672 mov word ptr [rc+2], dx 673 popa 674 } 675 return(rc); 676 676 } 677 677 //****************************************************************************** … … 683 683 { 684 684 IDC32_PACKET idcpacket; 685 ULONG 686 687 _fmemset(&idcpacket, 0, sizeof(idcpacket)); 688 689 690 691 692 693 idcpacket.buffer.buffer 685 ULONG buffer; 686 687 _fmemset(&idcpacket, 0, sizeof(idcpacket)); 688 689 if (DevHelp_VirtToLin(SELECTOROF(debstr),OFFSETOF(debstr),&buffer)) 690 return OSSERR_INVALID_PARAMETER; 691 692 693 idcpacket.buffer.buffer = (ULONG)buffer; 694 694 idcpacket.buffer.size = bufsize; 695 695 return CallOSS32(IDC32_DEBUG_STRING, &idcpacket); … … 704 704 #pragma on (unreferenced) 705 705 { 706 //dprintf(("OSSIDC cmd:%lx param1:%lx param2:%lx", cmd, param1, param2)); 707 switch(cmd & 0xFFFF) 708 { 709 case IDC16_INIT: 710 break; 711 712 case IDC16_EXIT: 713 DestroyStreams(); 714 IDCTable.ProtIDCEntry = 0; 715 break; 716 case IDC16_MIDI_IRQ: 717 MPU_401::processIrq(0); 718 break; 719 720 case IDC16_CLOSE_UNI16: 721 { 722 force_closed = 1; 723 #ifdef DEBUG 724 dprintf(("IDC16_CLOSE_UNI16")); 725 #endif 726 pWavePlay->Close(0); 727 //WAVEAUDIO::WavePlayClose(); 728 break; 729 } 730 case IDC16_PROCESS: 731 { 732 PWAVESTREAM pStream; 706 //dprintf(("OSSIDC cmd:%lx param1:%lx param2:%lx", cmd, param1, param2)); 707 switch(cmd & 0xFFFF) 708 { 709 case IDC16_INIT: 710 break; 711 712 case IDC16_EXIT: 713 DestroyStreams(); 714 IDCTable.ProtIDCEntry = 0; 715 break; 716 case IDC16_MIDI_IRQ: 717 MPU_401::processIrq(0); 718 break; 719 720 case IDC16_CLOSE_UNI16: 721 { 722 force_closed = 1; 723 dprintf(("IDC16_CLOSE_UNI16")); 724 pWavePlay->Close(0); 725 //WAVEAUDIO::WavePlayClose(); 726 break; 727 } 728 case IDC16_PROCESS: 729 { 730 PWAVESTREAM pStream; 733 731 //dprintf(("IDC16_PROCESS, %d", param1)); 734 //Signal all active wave playback streams to update their status 735 pStream = (PWAVESTREAM)FindFirstActiveStream(STREAM_WAVE_PLAY); 736 while(pStream) 737 { 738 pStream->Process(); 739 pStream = (PWAVESTREAM)FindNextActiveStream(STREAM_WAVE_PLAY, pStream); 740 } 741 //Signal all active wave capture streams to update their status 742 pStream = (PWAVESTREAM)FindFirstActiveStream(STREAM_WAVE_CAPTURE); 743 while(pStream) 744 { 745 pStream->Process(); 746 pStream = (PWAVESTREAM)FindNextActiveStream(STREAM_WAVE_CAPTURE, pStream); 747 } 748 //dprintf(("IDC16_PROCESS end")); 749 break; 750 } 751 752 } 753 return 0; 732 //Signal all active wave playback streams to update their status 733 pStream = (PWAVESTREAM)FindFirstActiveStream(STREAM_WAVE_PLAY); 734 while(pStream) { 735 pStream->Process(); 736 pStream = (PWAVESTREAM)FindNextActiveStream(STREAM_WAVE_PLAY, pStream); 737 } 738 //Signal all active wave capture streams to update their status 739 pStream = (PWAVESTREAM)FindFirstActiveStream(STREAM_WAVE_CAPTURE); 740 while(pStream) { 741 pStream->Process(); 742 pStream = (PWAVESTREAM)FindNextActiveStream(STREAM_WAVE_CAPTURE, pStream); 743 } 744 //dprintf(("IDC16_PROCESS end")); 745 break; 746 } 747 748 } 749 return 0; 754 750 } 755 751 //****************************************************************************** … … 760 756 void DumpMixerCaps (LPOSS32_MIXCAPS pMixCaps) 761 757 { 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 758 dprintf (("\nMixerCaps")); 759 dprintf ((" name '%s'", pMixCaps->name)); 760 dprintf ((" fuCtrlCaps %lxh", pMixCaps->fuCtrlCaps)); 761 if (pMixCaps->fuCtrlCaps & OSS32_MIX_FLAG (OSS32_MIX_VOLUME_MASTER_FRONT)) 762 dprintf ((" OSS32_MIX_VOLUME_MASTER_FRONT")); 763 if (pMixCaps->fuCtrlCaps & OSS32_MIX_FLAG (OSS32_MIX_VOLUME_MASTER_REAR)) 764 dprintf ((" OSS32_MIX_VOLUME_MASTER_REAR")); 765 if (pMixCaps->fuCtrlCaps & OSS32_MIX_FLAG (OSS32_MIX_VOLUME_PCM)) 766 dprintf ((" OSS32_MIX_VOLUME_PCM")); 767 if (pMixCaps->fuCtrlCaps & OSS32_MIX_FLAG (OSS32_MIX_VOLUME_MIDI)) 768 dprintf ((" OSS32_MIX_VOLUME_MIDI")); 769 if (pMixCaps->fuCtrlCaps & OSS32_MIX_FLAG (OSS32_MIX_VOLUME_LINEIN)) 770 dprintf ((" OSS32_MIX_VOLUME_LINEIN")); 771 if (pMixCaps->fuCtrlCaps & OSS32_MIX_FLAG (OSS32_MIX_VOLUME_MIC)) 772 dprintf ((" OSS32_MIX_VOLUME_MIC")); 773 if (pMixCaps->fuCtrlCaps & OSS32_MIX_FLAG (OSS32_MIX_VOLUME_CD)) 774 dprintf ((" OSS32_MIX_VOLUME_CD")); 775 if (pMixCaps->fuCtrlCaps & OSS32_MIX_FLAG (OSS32_MIX_VOLUME_SPDIF)) 776 dprintf ((" OSS32_MIX_VOLUME_SPDIF")); 777 if (pMixCaps->fuCtrlCaps & OSS32_MIX_FLAG (OSS32_MIX_VOLUME_VIDEO)) 778 dprintf ((" OSS32_MIX_VOLUME_VIDEO")); 779 if (pMixCaps->fuCtrlCaps & OSS32_MIX_FLAG (OSS32_MIX_VOLUME_SPEAKER)) 780 dprintf ((" OSS32_MIX_VOLUME_SPEAKER")); 781 if (pMixCaps->fuCtrlCaps & OSS32_MIX_FLAG (OSS32_MIX_VOLUME_PHONE)) 782 dprintf ((" OSS32_MIX_VOLUME_PHONE")); 783 if (pMixCaps->fuCtrlCaps & OSS32_MIX_FLAG (OSS32_MIX_VOLUME_HEADPHONE)) 784 dprintf ((" OSS32_MIX_VOLUME_HEADPHONE")); 785 if (pMixCaps->fuCtrlCaps & OSS32_MIX_FLAG (OSS32_MIX_VOLUME_AUX)) 786 dprintf ((" OSS32_MIX_VOLUME_AUX")); 787 if (pMixCaps->fuCtrlCaps & OSS32_MIX_FLAG (OSS32_MIX_VOLUME_CAPTURE)) 788 dprintf ((" OSS32_MIX_VOLUME_CAPTURE")); 789 if (pMixCaps->fuCtrlCaps & OSS32_MIX_FLAG (OSS32_MIX_INPUTSRC)) 790 dprintf ((" OSS32_MIX_INPUTSRC")); 791 if (pMixCaps->fuCtrlCaps & OSS32_MIX_FLAG (OSS32_MIX_LEVEL_BASS)) 792 dprintf ((" OSS32_MIX_LEVEL_BASS")); 793 if (pMixCaps->fuCtrlCaps & OSS32_MIX_FLAG (OSS32_MIX_LEVEL_TREBLE)) 794 dprintf ((" OSS32_MIX_LEVEL_TREBLE")); 795 if (pMixCaps->fuCtrlCaps & OSS32_MIX_FLAG (OSS32_MIX_LEVEL_3DCENTER)) 796 dprintf ((" OSS32_MIX_LEVEL_3DCENTER")); 797 if (pMixCaps->fuCtrlCaps & OSS32_MIX_FLAG (OSS32_MIX_LEVEL_3DDEPTH)) 798 dprintf ((" OSS32_MIX_LEVEL_3DDEPTH")); 799 if (pMixCaps->fuCtrlCaps & OSS32_MIX_FLAG (OSS32_MIX_SWITCH_MICBOOST)) 800 dprintf ((" OSS32_MIX_SWITCH_MICBOOST")); 801 802 803 dprintf ((" fuRecCaps %lxh", pMixCaps->fuRecCaps)); 804 if (pMixCaps->fuRecCaps & OSS32_MIX_FLAG (OSS32_MIX_RECSRC_MIC)) 805 dprintf ((" OSS32_MIX_RECSRC_MIC")); 806 if (pMixCaps->fuRecCaps & OSS32_MIX_FLAG (OSS32_MIX_RECSRC_CD)) 807 dprintf ((" OSS32_MIX_RECSRC_CD")); 808 if (pMixCaps->fuRecCaps & OSS32_MIX_FLAG (OSS32_MIX_RECSRC_LINE)) 809 dprintf ((" OSS32_MIX_RECSRC_LINE")); 810 if (pMixCaps->fuRecCaps & OSS32_MIX_FLAG (OSS32_MIX_RECSRC_VIDEO)) 811 dprintf ((" OSS32_MIX_RECSRC_VIDEO")); 812 if (pMixCaps->fuRecCaps & OSS32_MIX_FLAG (OSS32_MIX_RECSRC_AUX)) 813 dprintf ((" OSS32_MIX_RECSRC_AUX")); 814 if (pMixCaps->fuRecCaps & OSS32_MIX_FLAG (OSS32_MIX_RECSRC_MIXER)) 815 dprintf ((" OSS32_MIX_RECSRC_MIXER")); 816 if (pMixCaps->fuRecCaps & OSS32_MIX_FLAG (OSS32_MIX_RECSRC_MIXER_MONO)) 817 dprintf ((" OSS32_MIX_RECSRC_MIXER_MONO")); 818 if (pMixCaps->fuRecCaps & OSS32_MIX_FLAG (OSS32_MIX_RECSRC_PHONE)) 819 dprintf ((" OSS32_MIX_RECSRC_PHONE")); 820 if (pMixCaps->fuRecCaps & OSS32_MIX_FLAG (OSS32_MIX_RECSRC_SYNTH)) 821 dprintf ((" OSS32_MIX_RECSRC_SYNTH")); 826 822 } 827 823 //****************************************************************************** … … 829 825 void DumpDeviceCaps (LPOSS32_DEVCAPS pDevCaps) 830 826 { 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 827 dprintf (("\nDeviceCaps")); 828 dprintf ((" nrDevices %d", pDevCaps->nrDevices)); 829 830 dprintf ((" ulCaps %uxh", pDevCaps->ulCaps)); 831 if (pDevCaps->ulCaps & OSS32_CAPS_WAVE_PLAYBACK) 832 dprintf ((" OSS32_CAPS_WAVE_PLAYBACK")); 833 if (pDevCaps->ulCaps & OSS32_CAPS_WAVE_CAPTURE) 834 dprintf ((" OSS32_CAPS_WAVE_CAPTURE")); 835 if (pDevCaps->ulCaps & OSS32_CAPS_FMSYNTH_PLAYBACK) 836 dprintf ((" OSS32_CAPS_FMSYNTH_PLAYBACK")); 837 if (pDevCaps->ulCaps & OSS32_CAPS_WAVETABLE_PLAYBACK) 838 dprintf ((" OSS32_CAPS_WAVETABLE_PLAYBACK")); 839 if (pDevCaps->ulCaps & OSS32_CAPS_MPU401_PLAYBACK) 840 dprintf ((" OSS32_CAPS_MPU401_PLAYBACK")); 841 if (pDevCaps->ulCaps & OSS32_CAPS_MPU401_CAPTURE) 842 dprintf ((" OSS32_CAPS_MPU401_CAPTURE")); 843 844 dprintf ((" szDeviceName %s", (char far*)pDevCaps->szDeviceName)); 845 dprintf ((" szMixerName %s", (char far*)pDevCaps->szMixerName)); 846 847 848 dprintf (("WaveOutCaps")); 849 DumpWaveCaps (&pDevCaps->waveOutCaps); 850 851 dprintf (("WaveInCaps")); 852 DumpWaveCaps (&pDevCaps->waveInCaps); 857 853 } 858 854 //****************************************************************************** … … 860 856 void DumpWaveCaps (LPWAVE_CAPS pWaveCaps) 861 857 { 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 858 dprintf ((" nrStreams %d", pWaveCaps->nrStreams)); 859 dprintf ((" ulMinChannels %ld", pWaveCaps->ulMinChannels)); 860 dprintf ((" ulMaxChannels %ld", pWaveCaps->ulMaxChannels)); 861 dprintf ((" ulChanFlags %lxh", pWaveCaps->ulChanFlags)); 862 if (pWaveCaps->ulChanFlags & OSS32_CAPS_PCM_CHAN_MONO) 863 dprintf ((" OSS32_CAPS_PCM_CHAN_MONO")); 864 if (pWaveCaps->ulChanFlags & OSS32_CAPS_PCM_CHAN_STEREO) 865 dprintf ((" OSS32_CAPS_PCM_CHAN_STEREO")); 866 if (pWaveCaps->ulChanFlags & OSS32_CAPS_PCM_CHAN_QUAD) 867 dprintf ((" OSS32_CAPS_PCM_CHAN_QUAD")); 868 if (pWaveCaps->ulChanFlags & OSS32_CAPS_PCM_CHAN_5_1) 869 dprintf ((" OSS32_CAPS_PCM_CHAN_5_1")); 870 871 872 dprintf ((" ulMinRate %ld", pWaveCaps->ulMinRate)); 873 dprintf ((" ulMaxRate %ld", pWaveCaps->ulMaxRate)); 874 875 dprintf ((" ulRateFlags %lxh", pWaveCaps->ulRateFlags)); 876 if (pWaveCaps->ulRateFlags & OSS32_CAPS_PCM_RATE_5512) 877 dprintf ((" OSS32_CAPS_PCM_RATE_5512")); 878 if (pWaveCaps->ulRateFlags & OSS32_CAPS_PCM_RATE_8000) 879 dprintf ((" OSS32_CAPS_PCM_RATE_8000")); 880 if (pWaveCaps->ulRateFlags & OSS32_CAPS_PCM_RATE_11025) 881 dprintf ((" OSS32_CAPS_PCM_RATE_11025")); 882 if (pWaveCaps->ulRateFlags & OSS32_CAPS_PCM_RATE_16000) 883 dprintf ((" OSS32_CAPS_PCM_RATE_16000")); 884 if (pWaveCaps->ulRateFlags & OSS32_CAPS_PCM_RATE_22050) 885 dprintf ((" OSS32_CAPS_PCM_RATE_22050")); 886 if (pWaveCaps->ulRateFlags & OSS32_CAPS_PCM_RATE_32000) 887 dprintf ((" OSS32_CAPS_PCM_RATE_32000")); 888 if (pWaveCaps->ulRateFlags & OSS32_CAPS_PCM_RATE_44100) 889 dprintf ((" OSS32_CAPS_PCM_RATE_44100")); 890 if (pWaveCaps->ulRateFlags & OSS32_CAPS_PCM_RATE_48000) 891 dprintf ((" OSS32_CAPS_PCM_RATE_48000")); 892 if (pWaveCaps->ulRateFlags & OSS32_CAPS_PCM_RATE_64000) 893 dprintf ((" OSS32_CAPS_PCM_RATE_64000")); 894 if (pWaveCaps->ulRateFlags & OSS32_CAPS_PCM_RATE_88200) 895 dprintf ((" OSS32_CAPS_PCM_RATE_88200")); 896 if (pWaveCaps->ulRateFlags & OSS32_CAPS_PCM_RATE_96000) 897 dprintf ((" OSS32_CAPS_PCM_RATE_96000")); 898 if (pWaveCaps->ulRateFlags & OSS32_CAPS_PCM_RATE_176400) 899 dprintf ((" OSS32_CAPS_PCM_RATE_176400")); 900 if (pWaveCaps->ulRateFlags & OSS32_CAPS_PCM_RATE_192000) 901 dprintf ((" OSS32_CAPS_PCM_RATE_192000")); 902 if (pWaveCaps->ulRateFlags & OSS32_CAPS_PCM_RATE_HALFDUPLEX) 903 dprintf ((" OSS32_CAPS_PCM_RATE_HALFDUPLEX")); 904 if (pWaveCaps->ulRateFlags & OSS32_CAPS_PCM_RATE_CONTINUOUS) 905 dprintf ((" OSS32_CAPS_PCM_RATE_CONTINUOUS")); 906 if (pWaveCaps->ulRateFlags & OSS32_CAPS_PCM_RATE_KNOT) 907 dprintf ((" OSS32_CAPS_PCM_RATE_KNOT")); 908 909 910 dprintf ((" ulDataFormats %lxh", pWaveCaps->ulDataFormats)); 911 if (pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_S8) 912 dprintf ((" OSS32_CAPS_PCM_FORMAT_S8")); 913 if (pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_U8) 914 dprintf ((" OSS32_CAPS_PCM_FORMAT_U8")); 915 if (pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_S16_LE) 916 dprintf ((" OSS32_CAPS_PCM_FORMAT_S16_LE")); 917 if (pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_S16_BE) 918 dprintf ((" OSS32_CAPS_PCM_FORMAT_S16_BE")); 919 if (pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_U16_LE) 920 dprintf ((" OSS32_CAPS_PCM_FORMAT_U16_LE")); 921 if (pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_U16_BE) 922 dprintf ((" OSS32_CAPS_PCM_FORMAT_U16_BE")); 923 if (pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_S24_LE) 924 dprintf ((" OSS32_CAPS_PCM_FORMAT_S24_LE")); 925 if (pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_S24_BE) 926 dprintf ((" OSS32_CAPS_PCM_FORMAT_S24_BE")); 927 if (pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_U24_LE) 928 dprintf ((" OSS32_CAPS_PCM_FORMAT_U24_LE")); 929 if (pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_U24_BE) 930 dprintf ((" OSS32_CAPS_PCM_FORMAT_U24_BE")); 931 if (pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_S32_LE) 932 dprintf ((" OSS32_CAPS_PCM_FORMAT_S32_LE")); 933 if (pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_S32_BE) 934 dprintf ((" OSS32_CAPS_PCM_FORMAT_S32_BE")); 935 if (pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_U32_LE) 936 dprintf ((" OSS32_CAPS_PCM_FORMAT_U32_LE")); 937 if (pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_U32_BE) 938 dprintf ((" OSS32_CAPS_PCM_FORMAT_U32_BE")); 939 if (pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_MULAW) 940 dprintf ((" OSS32_CAPS_PCM_FORMAT_MULAW")); 941 if (pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_ALAW) 942 dprintf ((" OSS32_CAPS_PCM_FORMAT_ALAW")); 943 if (pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_ADPCM) 944 dprintf ((" OSS32_CAPS_PCM_FORMAT_ADPCM")); 945 if (pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_MPEG) 946 dprintf ((" OSS32_CAPS_PCM_FORMAT_MPEG")); 951 947 } 952 948 //****************************************************************************** -
OCO/trunk/drv16/rtmidi.cpp
r483 r526 61 61 62 62 if (DevHelp_AttachDD((NPSZ) "MIDI$ ", (NPBYTE) &DDTable)) { 63 dprintf(("rtmidi: error attaching to MIDI.SYS"));63 rprintf(("rtmidi: error attaching to MIDI.SYS")); 64 64 return; 65 65 } … … 74 74 DDTable.pfn( ® ); 75 75 if (SELECTOROF(reg.pfnRegisterA) != SELECTOROF(DDTable.pfn)) { 76 dprintf(("rtmidi: invalid selector for pfnRegisterA"));76 rprintf(("rtmidi: invalid selector for pfnRegisterA")); 77 77 return; 78 78 } … … 136 136 return MIDIERRA_HW_FAILED; 137 137 } 138 #ifdef DEBUG139 138 // dprintf(("rtmidi: Open. Mode: %d",usMode)); 140 #endif141 139 switch (usMode) { 142 140 case MIDIMODE_OPEN_RECEIVE: … … 144 142 pma->midiOutStreamId = pma->RTMIDI_OpenReceive(); 145 143 if(!pma->midiOutStreamId) return MIDIERRA_HW_FAILED; 146 #ifdef DEBUG147 144 // dprintf(("rtmidi: Receive openened. stream: %d",pma->midiOutStreamId)); 148 #endif149 145 return 0; 150 146 } … … 153 149 pma->midiInStreamId = pma->RTMIDI_OpenSend(); 154 150 if(!pma->midiInStreamId) return MIDIERRA_HW_FAILED; 155 #ifdef DEBUG156 151 // dprintf(("rtmidi: Send openened. stream: %d",pma->midiInStreamId)); 157 #endif158 152 return 0; 159 153 } -
OCO/trunk/drv16/strategy.cpp
r497 r526 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% … … 17 17 * @version %I% 18 18 * @context Unless otherwise noted, all interfaces are Ring-0, 16-bit, 19 * 19 * kernel stack. 20 20 * @history 21 21 * 22 22 */ 23 extern "C" { 23 extern "C" { // 16-bit header files are not C++ aware 24 24 #define INCL_NOPMAPI 25 25 #define INCL_DOSINFOSEG … … 33 33 #include <devhelp.h> 34 34 #include "strategy.h" 35 #include "rtmidi.hpp" 35 #include "rtmidi.hpp" // Object definition 36 36 #include "end.h" 37 37 … … 84 84 extern "C" char szAZX[]; 85 85 86 static char *pszIntelICH 86 static char *pszIntelICH = (char *)szINTEL_ICH; 87 87 static char *pszSigmatel9721_23 = (char *)szSIGMATEL_9721_23; 88 static char *pszSBLive 89 static char *pszCMedia 90 static char *pszCrystal4281 91 static char *pszALS4000 92 static char *pszCrystal46XX 93 static char *pszVIA82XX 94 static char *pszESS1938 95 static char *pszVORTEX 96 static char *pszES1371 97 static char *pszES1370 98 static char *pszYAMAHA 99 static char *pszMAESTRO 100 static char *pszMAESTRO3 101 static char *pszALLEGRO 102 static char *pszALI5451 103 static char *pszSI7012 104 static char *pszALI5455 105 static char *pszNVIDIA 106 static char *pszAMD 107 static char *pszTRIDENT 108 static char *pszNEOMAGIC 109 static char *pszFM801 110 static char *pszATIIXP 111 static char *pszAUDIGYLS 112 static char *pszBT87X 113 static char *pszAZX 88 static char *pszSBLive = (char *)szSBLIVE; 89 static char *pszCMedia = (char *)szCMEDIA; 90 static char *pszCrystal4281 = (char *)szCS4281; 91 static char *pszALS4000 = (char *)szALS4000; 92 static char *pszCrystal46XX = (char *)szCS46XX; 93 static char *pszVIA82XX = (char *)szVIA82XX; 94 static char *pszESS1938 = (char *)szESS1938; 95 static char *pszVORTEX = (char *)szVORTEX; 96 static char *pszES1371 = (char *)szES1371; 97 static char *pszES1370 = (char *)szES1370; 98 static char *pszYAMAHA = (char *)szYAMAHA; 99 static char *pszMAESTRO = (char *)szMAESTRO; 100 static char *pszMAESTRO3 = (char *)szMAESTRO3; 101 static char *pszALLEGRO = (char *)szALLEGRO; 102 static char *pszALI5451 = (char *)szALI5451; 103 static char *pszSI7012 = (char *)szSI7012; 104 static char *pszALI5455 = (char *)szALI5455; 105 static char *pszNVIDIA = (char *)szNVIDIA; 106 static char *pszAMD = (char *)szAMD; 107 static char *pszTRIDENT = (char *)szTRIDENT; 108 static char *pszNEOMAGIC = (char *)szNEOMAGIC; 109 static char *pszFM801 = (char *)szFM801; 110 static char *pszATIIXP = (char *)szATIIXP; 111 static char *pszAUDIGYLS = (char *)szAUDIGYLS; 112 static char *pszBT87X = (char *)szBT87X; 113 static char *pszAZX = (char *)szAZX; 114 114 #endif /* ENABLE_HW_CERTIFICATION */ 115 115 116 BOOL fNoHardware= FALSE;116 BOOL fNoHardware = FALSE; 117 117 118 118 extern void DBGCALLCONV APM_Init(); … … 126 126 int d; 127 127 for (;;) 128 129 // 130 131 132 133 134 128 { 129 // d = (int)(unsigned char)*string1 - (int)(unsigned char)(*string2 ^ 0x81); 130 d = (int)(unsigned char)*string1 - (int)(unsigned char)*string2; 131 if (d != 0 || *string1 == 0 || *string2 == 0) 132 return d; 133 ++string1; ++string2; 134 } 135 135 } 136 136 //****************************************************************************** … … 141 141 142 142 while (count != 0) 143 144 //d = (int)(unsigned char)*string1 - (int)(unsigned char)(*string2 ^ 0x81);145 146 147 148 149 150 143 { 144 // d = (int)(unsigned char)*string1 - (int)(unsigned char)(*string2 ^ 0x81); 145 d = (int)(unsigned char)*string1 - (int)(unsigned char)*string2; 146 if (d != 0 || *string1 == 0 || *string2 == 0) 147 return d; 148 ++string1; ++string2; 149 --count; 150 } 151 151 return 0; 152 152 } … … 160 160 if(OSS16_AttachToPdd() != OSSERR_SUCCESS) 161 161 { 162 163 // 164 162 DebugInt3(); 163 // DevHelp_Beep(500, 100); 164 goto failure; 165 165 } 166 166 … … 168 168 if(OSS16_QueryDevCaps(current_device, &devCaps[0]) != OSSERR_SUCCESS) 169 169 { 170 171 //DevHelp_Beep(2000, 100);172 170 DebugInt3(); 171 // DevHelp_Beep(2000, 100); 172 goto failure; 173 173 } 174 174 dprintf(("Device 0 name: %s", (char FAR *)devCaps[0].szDeviceName)); 175 175 if(devCaps[0].nrDevices > OSS32_MAX_AUDIOCARDS) 176 176 { 177 178 177 DebugInt3(); 178 devCaps[0].nrDevices = OSS32_MAX_AUDIOCARDS; 179 179 } 180 180 //Get caps of other devices (if present) 181 181 for(i=1;i<devCaps[0].nrDevices;i++) 182 182 { 183 184 185 186 183 if(OSS16_QueryDevCaps(i, &devCaps[i]) != OSSERR_SUCCESS) { 184 DebugInt3(); 185 goto failure; 186 } 187 187 } 188 188 … … 191 191 //Check for certified audiocard/chipsets 192 192 if(!xorstrncmp(devCaps[0].szDeviceName, pszIntelICH, 6) || 193 194 195 196 197 { 198 193 !xorstrcmp(devCaps[0].szDeviceName, pszSI7012) || 194 !xorstrcmp(devCaps[0].szDeviceName, pszALI5455) || 195 !xorstrncmp(devCaps[0].szDeviceName, pszNVIDIA, 6) || 196 !xorstrcmp(devCaps[0].szDeviceName, pszAMD)) 197 { 198 soundCard = INTELICH; 199 199 } 200 200 else 201 201 if(!xorstrcmp(devCaps[0].szDeviceName, pszSBLive)) 202 202 { 203 203 soundCard = SBLIVE; 204 204 } 205 205 else 206 206 if(!xorstrncmp(devCaps[0].szDeviceName, pszCMedia, 11)) 207 207 { 208 208 soundCard = CMEDIA; 209 209 } 210 210 else 211 211 if(!xorstrcmp(devCaps[0].szDeviceName, pszCrystal4281)) 212 212 { 213 213 soundCard = CS4281; 214 214 } 215 215 else 216 216 if(!xorstrcmp(devCaps[0].szDeviceName, pszALS4000)) 217 217 { 218 219 220 221 222 218 //hardware not completely full duplex; sample rates must be identical if 219 //both playback & recording active 220 devCaps[0].waveInCaps.ulRateFlags |= OSS32_CAPS_PCM_RATE_HALFDUPLEX; 221 devCaps[0].waveOutCaps.ulRateFlags |= OSS32_CAPS_PCM_RATE_HALFDUPLEX; 222 soundCard = ALS4000; 223 223 } 224 224 else 225 225 if(!xorstrcmp(devCaps[0].szDeviceName, pszCrystal46XX)) 226 226 { 227 227 soundCard = CS46XX; 228 228 } 229 229 else 230 230 if(!xorstrncmp(devCaps[0].szDeviceName, pszVIA82XX, 6)) 231 231 { 232 232 soundCard = VIA82XX; 233 233 } 234 234 else 235 235 if(!xorstrcmp(devCaps[0].szDeviceName, pszESS1938)) 236 236 { 237 237 soundCard = ESS1938; 238 238 } 239 239 else 240 240 if(!xorstrncmp(devCaps[0].szDeviceName, pszVORTEX, 6)) 241 241 { 242 242 soundCard = VORTEX; 243 243 } 244 244 else 245 245 if(!xorstrncmp(devCaps[0].szDeviceName, pszYAMAHA,6)) 246 246 { 247 247 soundCard = YAMAHA; 248 248 } 249 249 else 250 250 if(!xorstrcmp(devCaps[0].szDeviceName, pszMAESTRO)) 251 251 { 252 253 } 254 else 255 256 257 { 258 259 } 260 else 261 262 263 { 264 252 soundCard = MAESTRO; 253 } 254 else 255 if(!xorstrcmp(devCaps[0].szDeviceName, pszMAESTRO3) || 256 !xorstrcmp(devCaps[0].szDeviceName, pszALLEGRO)) 257 { 258 soundCard = MAESTRO3; 259 } 260 else 261 if(!xorstrncmp(devCaps[0].szDeviceName, pszES1371, 6) || 262 !xorstrncmp(devCaps[0].szDeviceName, pszES1370, 6)) 263 { 264 soundCard = ENSONIQ; 265 265 } 266 266 else 267 267 if(!xorstrcmp(devCaps[0].szDeviceName, pszALI5451)) 268 268 { 269 269 soundCard = ALI5451; 270 270 } 271 271 else 272 272 if(!xorstrncmp(devCaps[0].szDeviceName, pszTRIDENT,7)) 273 273 { 274 274 soundCard = TRIDENT; 275 275 } 276 276 else 277 277 if(!xorstrncmp(devCaps[0].szDeviceName, pszNEOMAGIC,5)) 278 278 { 279 279 soundCard = NEOMAGIC; 280 280 } 281 281 else 282 282 if(!xorstrncmp(devCaps[0].szDeviceName, pszFM801,5)) 283 283 { 284 284 soundCard = FM801; 285 285 } 286 286 else 287 287 if(!xorstrncmp(devCaps[0].szDeviceName, pszATIIXP,7)) 288 288 { 289 289 soundCard = ATIIXP; 290 290 } 291 291 else 292 292 if(!xorstrncmp(devCaps[0].szDeviceName, pszAUDIGYLS,6)) 293 293 { 294 294 soundCard = AUDIGYLS; 295 295 } 296 296 else 297 297 if(!xorstrncmp(devCaps[0].szDeviceName, pszBT87X,5)) 298 298 { 299 299 soundCard = BT87X; 300 300 } 301 301 else 302 302 if(!xorstrncmp(devCaps[0].szDeviceName, pszAZX,9)) 303 303 { 304 304 soundCard = AZX; 305 305 } 306 306 else { 307 // printk("Soundcard %s not supported", (char FAR *)devCaps[0].szDeviceName); 308 dprintf(("Soundcard %s not supported", (char FAR *)devCaps[0].szDeviceName)); 309 // DevHelp_Beep(1000, 50); 310 DebugInt3(); 311 goto failure; 307 rprintf(("Soundcard %s not supported", (char FAR *)devCaps[0].szDeviceName)); 308 //DevHelp_Beep(1000, 50); 309 DebugInt3(); 310 goto failure; 312 311 } 313 312 #endif /* ENABLE_HW_CERTIFICATION */ … … 315 314 316 315 failure: 317 // 318 319 316 // DevHelp_Beep(1000, 50); 317 fNoHardware = TRUE; 318 return FALSE; 320 319 } 321 320 … … 329 328 { 330 329 if(InitializeAudio() == FALSE) { 331 330 return; 332 331 } 333 332 if(fNoHardware) return; … … 338 337 if(devCaps[0].ulCaps & OSS32_CAPS_FMSYNTH_PLAYBACK) 339 338 { 340 341 342 343 344 345 346 347 348 349 350 351 339 dprintf(("Creating FM Synthesizer device")); 340 341 // Build a FMSYNTH object. First create a timer, then the HW object. 342 TIMER* pFMSynthTimer = 343 new TIMER( NULL, MIDI_TimerInterval, STREAM_FMSYNTH_PLAY ); 344 if (pFMSynthTimer->eState() != TIMER_Disabled) 345 new FMSYNTH( pFMSynthTimer ); 346 347 SetHardwareType(AUDIOHW_FMSYNTH_PLAY, MIDI, OPERATION_PLAY, 1); 348 SetHardwareType(AUDIOHW_FMSYNTH_PLAY, DATATYPE_MIDI, OPERATION_PLAY, 1); 349 // MIDI on Warp 3 350 SetHardwareType(AUDIOHW_FMSYNTH_PLAY, DATATYPE_NULL, OPERATION_PLAY, 1); 352 351 } 353 352 354 353 if((devCaps[0].ulCaps & OSS32_CAPS_MPU401_PLAYBACK) && 355 356 { 357 358 359 360 361 // vladestnew TIMER(NULL, MIDI_TimerInterval, STREAM_MPU401_PLAY );362 363 364 365 366 367 // 368 // 369 370 371 372 373 354 (devCaps[0].ulCaps & OSS32_CAPS_MPU401_CAPTURE)) 355 { 356 dprintf(("Creating MPU401 device")); 357 358 // Build the MPU401 object. First create a timer, then the HW object. 359 TIMER* pMPUTimer = 360 // vladest new TIMER(NULL, MIDI_TimerInterval, STREAM_MPU401_PLAY ); 361 new TIMER(NULL, MIDI_TimerInterval, STREAM_MPU401_CAPTURE ); 362 363 if (pMPUTimer->eState() != TIMER_Disabled) 364 new MPU_401(pMPUTimer); 365 366 // SetHardwareType(AUDIOHW_MPU401_PLAY, MIDI, OPERATION_PLAY, 0); 367 // SetHardwareType(AUDIOHW_MPU401_PLAY, DATATYPE_MIDI, OPERATION_PLAY, 0); 368 369 SetHardwareType(AUDIOHW_MPU401_CAPTURE, MIDI, OPERATION_RECORD, 0); 370 SetHardwareType(AUDIOHW_MPU401_CAPTURE, DATATYPE_MIDI, OPERATION_RECORD, 0); 371 372 RTMIDI::vConnect(); 374 373 } 375 374 APM_Init(); … … 380 379 * Purpose: Worker rountine for the Strategy Open function. 381 380 * 382 * Notes: 383 * and the function is treated as a NOP.The first allocation of384 * 385 * 386 * 387 * 388 * 389 * 381 * Notes: The Strategy Open doesn't require allocation of any resources, 382 * and the function is treated as a NOP. The first allocation of 383 * resources happens at Strategy IOCtl time, in the handler for 384 * the AudioInit IOCtl. 385 * Check to see if the VDD has claimed the hardware and return with 386 * the busy bit on the the request packet. 387 * Increment the InUseCount so we know that an OS/2 app has an 388 * instance open and we don't let the VDD take the hardware.. 390 389 * 391 390 * … … 395 394 { 396 395 if (usVDDHasHardware) { 397 396 prp->usStatus = RPDONE | RPERR | RPBUSY; 398 397 } 399 398 else { 400 399 ++usInUseCount; 401 400 } 402 401 } … … 405 404 void StrategyClose(PREQPACKET prp) 406 405 { 407 408 409 410 411 412 dprintf(("Close NULL stream"));;//### Log unexpected condition.406 --usInUseCount; 407 PSTREAM pstream = FindStream_fromFile( prp->s.open_close.usSysFileNum ); 408 if (pstream) 409 delete pstream; 410 else 411 dprintf(("Close NULL stream"));; //### Log unexpected condition. 413 412 } 414 413 //****************************************************************************** … … 416 415 void StrategyDeinstall(PREQPACKET prp) 417 416 { 418 419 417 while (pAudioHWList->IsElements()) 418 pAudioHWList->DestroyElement(pAudioHWList->PopHead()); 420 419 } 421 420 //****************************************************************************** … … 423 422 void StrategyShutdown(PREQPACKET prp) 424 423 { 425 424 dprintf(("StrategyShutdown %d", prp->s.shutdown.Function)); 426 425 } 427 426 //****************************************************************************** … … 446 445 447 446 if(fNoHardware) { 448 449 447 prp->usStatus = RPDONE | RPERR | RPGENFAIL; 448 return; 450 449 } 451 450 … … 455 454 456 455 switch (prp->bCommand) { 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 dprintf(("Strategy Unk:0x%x", prp->bCommand));480 456 case STRATEGY_INIT: 457 StrategyInit(prp); 458 break; 459 case STRATEGY_OPEN: 460 StrategyOpen(prp); 461 break; 462 case STRATEGY_CLOSE: 463 StrategyClose(prp); 464 break; 465 case STRATEGY_GENIOCTL: 466 StrategyIoctl(prp, 0); 467 break; 468 case STRATEGY_DEINSTALL: 469 StrategyDeinstall(prp); 470 break; 471 case STRATEGY_INITCOMPLETE: 472 StrategyInitComplete(prp); 473 break; 474 case STRATEGY_SHUTDOWN: 475 StrategyShutdown(prp); 476 break; 477 default: 478 rprintf(("Strategy Unk:0x%x", prp->bCommand)); 479 prp->usStatus = RPDONE | RPERR | RPGENFAIL; 481 480 } 482 481 #ifdef DEBUG … … 493 492 494 493 if(fNoHardware) { 495 496 497 498 499 500 494 prp->usStatus = RPDONE | RPERR | RPGENFAIL; 495 if(prp->bCommand == STRATEGY_INIT) { 496 prp->s.init_out.usCodeEnd = 0; 497 prp->s.init_out.usDataEnd = 0; 498 } 499 return; 501 500 } 502 501 … … 506 505 507 506 switch (prp->bCommand) { 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 507 case STRATEGY_INIT: 508 prp->usStatus = RPDONE; 509 prp->s.init_out.usCodeEnd = (USHORT) &end_of_text; 510 prp->s.init_out.usDataEnd = (USHORT) &end_of_heap; 511 break; 512 case STRATEGY_OPEN: 513 StrategyOpen(prp); 514 break; 515 case STRATEGY_CLOSE: 516 StrategyClose(prp); 517 break; 518 case STRATEGY_GENIOCTL: 519 StrategyIoctl(prp, 1); 520 break; 521 case STRATEGY_DEINSTALL: 522 StrategyDeinstall(prp); 523 break; 524 case STRATEGY_INITCOMPLETE: 525 prp->usStatus = RPDONE; 526 break; 527 default: 528 prp->usStatus = RPDONE | RPERR | RPGENFAIL; 530 529 } 531 530 #ifdef DEBUG -
OCO/trunk/drv16/waudio.cpp
r496 r526 2 2 /* SCCSID = %W% %E% */ 3 3 /**************************************************************************** 4 * 5 * Copyright (c) IBM Corporation 1994 - 1997. 6 * 7 * The following IBM OS/2 source code is provided to you solely for the 4 * * 5 * Copyright (c) IBM Corporation 1994 - 1997. * 6 * * 7 * The following IBM OS/2 source code is provided to you solely for the * 8 8 * the purpose of assisting you in your development of OS/2 device drivers. * 9 * You may use this code in accordance with the IBM License Agreement 10 * provided in the IBM Device Driver Source Kit for OS/2. 11 * 9 * You may use this code in accordance with the IBM License Agreement * 10 * provided in the IBM Device Driver Source Kit for OS/2. * 11 * * 12 12 ****************************************************************************/ 13 13 /**@internal %W% 14 14 * @notes 15 * 16 * 17 * 15 * The default for 8 bps is unsigned and signed for > 8 bps 16 * The default byte order for > 8 bps is little endian 17 * (important for devices that support both formats) 18 18 * 19 19 * @version %I% 20 20 * @context Unless otherwise noted, all interfaces are Ring-0, 16-bit, 21 * 21 * <stack context>. 22 22 * @history 23 23 * … … 86 86 // 87 87 ULONG aaulWave[NUMFREQS][BPSTYPES][MONOSTEREO] = { 88 WAVE_FORMAT_1M08, /* 11.025kHz, 8-bitMono */89 WAVE_FORMAT_1S08, /* 11.025kHz, 8-bitStereo */90 91 92 93 94 95 96 WAVE_FORMAT_2M08, /* 22.05kHz , 8-bitMono */97 WAVE_FORMAT_2S08, /* 22.05kHz , 8-bitStereo */98 99 100 101 102 103 104 WAVE_FORMAT_4M08, /* 44.1kHz , 8-bitMono */105 WAVE_FORMAT_4S08, /* 44.1kHz , 8-bitStereo */106 107 108 109 110 111 112 WAVE_FORMAT_8M08, /* 8.0kHz , 8-bitMono */113 WAVE_FORMAT_8S08, /* 8.0kHz , 8-bitStereo */114 115 116 117 118 119 WAVE_FORMAT_8S16/* 8.0kHz , 32-bit Stereo */ //TODO: what else can we fill in?120 88 WAVE_FORMAT_1M08, /* 11.025kHz, 8-bit Mono */ 89 WAVE_FORMAT_1S08, /* 11.025kHz, 8-bit Stereo */ 90 WAVE_FORMAT_1M16, /* 11.025kHz, 16-bit Mono */ 91 WAVE_FORMAT_1S16, /* 11.025kHz, 16-bit Stereo */ 92 WAVE_FORMAT_1M16, /* 11.025kHz, 24-bit Mono */ //TODO: what else can we fill in? 93 WAVE_FORMAT_1S16, /* 11.025kHz, 24-bit Stereo */ //TODO: what else can we fill in? 94 WAVE_FORMAT_1M16, /* 11.025kHz, 32-bit Mono */ //TODO: what else can we fill in? 95 WAVE_FORMAT_1S16, /* 11.025kHz, 32-bit Stereo */ //TODO: what else can we fill in? 96 WAVE_FORMAT_2M08, /* 22.05kHz , 8-bit Mono */ 97 WAVE_FORMAT_2S08, /* 22.05kHz , 8-bit Stereo */ 98 WAVE_FORMAT_2M16, /* 22.05kHz , 16-bit Mono */ 99 WAVE_FORMAT_2S16, /* 22.05kHz , 16-bit Stereo */ 100 WAVE_FORMAT_2M16, /* 22.05kHz , 24-bit Mono */ //TODO: what else can we fill in? 101 WAVE_FORMAT_2S16, /* 22.05kHz , 24-bit Stereo */ //TODO: what else can we fill in? 102 WAVE_FORMAT_2M16, /* 22.05kHz , 32-bit Mono */ //TODO: what else can we fill in? 103 WAVE_FORMAT_2S16, /* 22.05kHz , 32-bit Stereo */ //TODO: what else can we fill in? 104 WAVE_FORMAT_4M08, /* 44.1kHz , 8-bit Mono */ 105 WAVE_FORMAT_4S08, /* 44.1kHz , 8-bit Stereo */ 106 WAVE_FORMAT_4M16, /* 44.1kHz , 16-bit Mono */ 107 WAVE_FORMAT_4S16, /* 44.1kHz , 16-bit Stereo */ 108 WAVE_FORMAT_4M16, /* 44.1kHz , 24-bit Mono */ //TODO: what else can we fill in? 109 WAVE_FORMAT_4S16, /* 44.1kHz , 24-bit Stereo */ //TODO: what else can we fill in? 110 WAVE_FORMAT_4M16, /* 44.1kHz , 32-bit Mono */ //TODO: what else can we fill in? 111 WAVE_FORMAT_4S16, /* 44.1kHz , 32-bit Stereo */ //TODO: what else can we fill in? 112 WAVE_FORMAT_8M08, /* 8.0kHz , 8-bit Mono */ 113 WAVE_FORMAT_8S08, /* 8.0kHz , 8-bit Stereo */ 114 WAVE_FORMAT_8M16, /* 8.0kHz , 16-bit Mono */ 115 WAVE_FORMAT_8S16, /* 8.0kHz , 16-bit Stereo */ 116 WAVE_FORMAT_8M16, /* 8.0kHz , 24-bit Mono */ //TODO: what else can we fill in? 117 WAVE_FORMAT_8S16, /* 8.0kHz , 24-bit Stereo */ //TODO: what else can we fill in? 118 WAVE_FORMAT_8M16, /* 8.0kHz , 32-bit Mono */ //TODO: what else can we fill in? 119 WAVE_FORMAT_8S16 /* 8.0kHz , 32-bit Stereo */ //TODO: what else can we fill in? 120 }; 121 121 122 122 // … … 125 125 // _usfind_matching_sample_rate) and the number of channels 126 126 ULONG aaulAlaw[NUMFREQS][MONOSTEREO] = { 127 ALAW_8B11KM,/* 8bit 11kHz mono*/128 ALAW_8B11KS,/* 8bit 11kHz stereo*/129 ALAW_8B22KM,/* 8bit 22kHz mono*/130 ALAW_8B22KS,/* 8bit 22kHz stereo*/131 ALAW_8B44KM,/* 8bit 44kHz mono*/132 ALAW_8B44KS,/* 8bit 44kHz stereo*/133 ALAW_8B8KM ,/* 8bit 8kHz mono*/134 ALAW_8B8KS/* 8bit 8kHz stereo*/135 127 ALAW_8B11KM, /* 8bit 11kHz mono*/ 128 ALAW_8B11KS, /* 8bit 11kHz stereo*/ 129 ALAW_8B22KM, /* 8bit 22kHz mono*/ 130 ALAW_8B22KS, /* 8bit 22kHz stereo*/ 131 ALAW_8B44KM, /* 8bit 44kHz mono*/ 132 ALAW_8B44KS, /* 8bit 44kHz stereo*/ 133 ALAW_8B8KM , /* 8bit 8kHz mono*/ 134 ALAW_8B8KS /* 8bit 8kHz stereo*/ 135 }; 136 136 // 137 137 // the following 2-D array defines the subtypes for DATATYPE_MULAW … … 139 139 // _usfind_matching_sample_rate) and the number of channels 140 140 ULONG aaulMulaw[NUMFREQS][MONOSTEREO] = { 141 MULAW_8B11KM,/* 8bit 11kHz mono*/142 MULAW_8B11KS,/* 8bit 11kHz stereo*/143 MULAW_8B22KM,/* 8bit 22kHz mono*/144 MULAW_8B22KS,/* 8bit 22kHz stereo*/145 MULAW_8B44KM,/* 8bit 44kHz mono*/146 MULAW_8B44KS,/* 8bit 44kHz stereo*/147 MULAW_8B8KM ,/* 8bit 8kHz mono*/148 MULAW_8B8KS/* 8bit 8kHz stereo*/149 141 MULAW_8B11KM, /* 8bit 11kHz mono*/ 142 MULAW_8B11KS, /* 8bit 11kHz stereo*/ 143 MULAW_8B22KM, /* 8bit 22kHz mono*/ 144 MULAW_8B22KS, /* 8bit 22kHz stereo*/ 145 MULAW_8B44KM, /* 8bit 44kHz mono*/ 146 MULAW_8B44KS, /* 8bit 44kHz stereo*/ 147 MULAW_8B8KM , /* 8bit 8kHz mono*/ 148 MULAW_8B8KS /* 8bit 8kHz stereo*/ 149 }; 150 150 151 151 // … … 161 161 162 162 WAVEAUDIO::WAVEAUDIO(ULONG devicetype, ULONG ulDeviceNr) : 163 164 { 165 166 167 163 AUDIOHW(devicetype) 164 { 165 this->ulDeviceNr = ulDeviceNr; 166 167 StreamId = 0; 168 168 } 169 169 170 170 /**@internal _usfind_matching_sample_rate 171 * @param 172 * @param 171 * @param PULONG pulSampleRate 172 * @param PULONG pSampleRates 173 173 * @return 174 174 * @notes … … 182 182 USHORT WAVEAUDIO::_usfind_matching_sample_rate(PULONG pulSampleRate, int nrSampleRates, PULONG pSampleRates) 183 183 { 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 184 ULONG ulMinDistance = 0x7fffffff; 185 USHORT usMatching; 186 USHORT us; 187 188 if(nrSampleRates == 0) { 189 nrSampleRates = 4; 190 pSampleRates = aulSuppSampleRates; 191 } 192 for ( us = 0; us < nrSampleRates; us++ ) { 193 ULONG ulDistance = distance( *pulSampleRate, pSampleRates[us] ); 194 if (ulDistance < ulMinDistance) { 195 ulMinDistance = ulDistance; 196 usMatching = us; 197 } 198 } 199 *pulSampleRate = pSampleRates[usMatching]; 200 return usMatching; 201 201 } 202 202 //****************************************************************************** … … 208 208 ULONG WAVEAUDIO::QueryDataFlags(ULONG ulOperation, ULONG ulDataType, ULONG ulBitsPerSample) 209 209 { 210 ULONG 210 ULONG ulFlags; 211 211 PWAVE_CAPS pWaveCaps; 212 212 213 ulFlags = FIXED 214 213 ulFlags = FIXED | // Fixed length data 214 LEFT_ALIGNED; // Left align bits on byte bndry (for samples < 8 bits; TODO) 215 215 216 216 if(ulOperation == OPERATION_PLAY) { 217 217 pWaveCaps = &devCaps[ulDeviceNr].waveOutCaps; 218 218 } 219 219 else pWaveCaps = &devCaps[ulDeviceNr].waveInCaps; … … 223 223 case DATATYPE_WAVEFORM: 224 224 case PCM: 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 225 //NOTE1: The default for 8 bps is unsigned and signed for > 8 bps !!! 226 //NOTE2: The default byte order for > 8 bps is little endian 227 228 switch(ulBitsPerSample) 229 { 230 case 8: 231 //default = unsigned 232 break; 233 case 16: 234 //default = signed 235 ulFlags |= TWOS_COMPLEMENT; 236 237 if(!(pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_16BPS_LE)) 238 { 239 ulFlags |= BIG_ENDIAN; 240 } 241 //else little endian 242 break; 243 case 24: 244 if(pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_24BPS_SIGNED) 245 { 246 ulFlags |= TWOS_COMPLEMENT; 247 } 248 //else unsigned 249 250 if(!(pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_24BPS_LE)) 251 { 252 ulFlags |= BIG_ENDIAN; 253 } 254 //else little endian 255 break; 256 case 32: 257 if(pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_32BPS_SIGNED) 258 { 259 ulFlags |= TWOS_COMPLEMENT; 260 } 261 //else unsigned 262 263 if(!(pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_32BPS_LE)) 264 { 265 ulFlags |= BIG_ENDIAN; 266 } 267 //else little endian 268 break; 269 }//switch BPS 270 break; 271 271 272 272 case DATATYPE_ALAW: 273 273 case DATATYPE_RIFF_ALAW: 274 274 case A_LAW: 275 275 break; 276 276 277 277 case DATATYPE_MULAW: 278 278 case DATATYPE_RIFF_MULAW: 279 279 case MU_LAW: 280 280 break; 281 281 282 282 case DATATYPE_ADPCM_AVC: 283 283 case DATATYPE_CT_ADPCM: 284 284 break; 285 285 286 286 default: 287 288 287 DebugInt3(); 288 return 0; 289 289 } 290 290 return ulFlags; … … 294 294 //****************************************************************************** 295 295 ULONG WAVEAUDIO::QueryOSSDataFormat(ULONG ulOperation, ULONG ulDataType, 296 296 ULONG ulBitsPerSample) 297 297 { 298 298 ULONG ulDataFormat; … … 300 300 301 301 if(ulOperation == OPERATION_PLAY) { 302 302 pWaveCaps = &devCaps[ulDeviceNr].waveOutCaps; 303 303 } 304 304 else pWaveCaps = &devCaps[ulDeviceNr].waveInCaps; … … 308 308 case DATATYPE_WAVEFORM: 309 309 case PCM: 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 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 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 310 //NOTE1: The default for 8 bps is unsigned and signed for > 8 bps !!! 311 //NOTE2: The default byte order for > 8 bps is little endian 312 switch(ulBitsPerSample) 313 { 314 case 8: 315 //Default is unsigned, so check that first 316 if(pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_U8) 317 { 318 ulDataFormat = OSS32_PCM_FORMAT_U8; 319 } 320 else ulDataFormat = OSS32_PCM_FORMAT_S8; 321 break; 322 323 case 16: 324 //Default is signed, so check that first 325 if(pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_16BPS_SIGNED) 326 {//signed LE or BE 327 //Default is LE, so check that first 328 if(pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_16BPS_LE) 329 { 330 ulDataFormat = OSS32_PCM_FORMAT_S16_LE; 331 } 332 else ulDataFormat = OSS32_PCM_FORMAT_S16_BE; 333 } 334 else 335 {//unsigned LE or BE 336 //Default is LE, so check that first 337 if(pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_16BPS_LE) 338 { 339 ulDataFormat = OSS32_PCM_FORMAT_U16_LE; 340 } 341 else ulDataFormat = OSS32_PCM_FORMAT_U16_BE; 342 } 343 break; 344 345 case 24: 346 //Default is signed, so check that first 347 if(pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_24BPS_SIGNED) 348 {//signed LE or BE 349 //Default is LE, so check that first 350 if(pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_24BPS_LE) 351 { 352 ulDataFormat = OSS32_PCM_FORMAT_S24_LE; 353 } 354 else ulDataFormat = OSS32_PCM_FORMAT_S24_BE; 355 } 356 else 357 {//unsigned LE or BE 358 //Default is LE, so check that first 359 if(pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_24BPS_LE) 360 { 361 ulDataFormat = OSS32_PCM_FORMAT_U24_LE; 362 } 363 else ulDataFormat = OSS32_PCM_FORMAT_U24_BE; 364 } 365 break; 366 367 case 32: 368 //Default is signed, so check that first 369 if(pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_32BPS_SIGNED) 370 {//signed LE or BE 371 //Default is LE, so check that first 372 if(pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_32BPS_LE) 373 { 374 ulDataFormat = OSS32_PCM_FORMAT_S32_LE; 375 } 376 else ulDataFormat = OSS32_PCM_FORMAT_S32_BE; 377 } 378 else 379 {//unsigned LE or BE 380 //Default is LE, so check that first 381 if(pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_32BPS_LE) 382 { 383 ulDataFormat = OSS32_PCM_FORMAT_U32_LE; 384 } 385 else ulDataFormat = OSS32_PCM_FORMAT_U32_BE; 386 } 387 break; 388 }//switch BPS 389 break; 390 390 391 391 case DATATYPE_ALAW: 392 392 case DATATYPE_RIFF_ALAW: 393 393 case A_LAW: 394 395 394 ulDataFormat = OSS32_PCM_FORMAT_ALAW; 395 break; 396 396 397 397 case DATATYPE_MULAW: 398 398 case DATATYPE_RIFF_MULAW: 399 399 case MU_LAW: 400 401 400 ulDataFormat = OSS32_PCM_FORMAT_MULAW; 401 break; 402 402 403 403 case DATATYPE_ADPCM_AVC: 404 404 case DATATYPE_CT_ADPCM: 405 406 405 ulDataFormat = OSS32_PCM_FORMAT_ADPCM; 406 break; 407 407 408 408 default: 409 dprintf(("DataFormat wrong:%x",ulBitsPerSample));410 411 409 rprintf(("DataFormat wrong:%x",ulBitsPerSample)); 410 DebugInt3(); 411 return 0; 412 412 } 413 413 return ulDataFormat; //flag to format type … … 417 417 //****************************************************************************** 418 418 BOOL WAVEAUDIO::SetupConversion(PWAVECONFIGINFO pConfigInfo, 419 420 421 { 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 else usConversion |= CONVERT_UNSIGNED;//unsigned to unsigned488 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 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,0);//factor 1560 561 // 562 563 564 565 566 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,0);//factor 1567 568 // 569 570 571 572 573 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(1,0);//factor 2574 575 // 576 577 578 579 580 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(1,0);//factor 2581 582 // 583 584 585 586 587 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(1,0);//factor 2588 589 // 590 591 592 593 594 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(1,0);//factor 2595 596 597 598 599 600 601 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(2,0);//factor 4602 603 604 605 606 607 608 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(2,0);//factor 4609 610 611 612 613 614 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,1);//factor 0.5615 616 617 618 619 620 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,1);//factor 0.5621 622 623 624 625 626 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,1);//factor 0.5627 628 629 630 631 632 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,1);//factor 0.5633 634 635 636 637 638 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,0);//factor 1639 640 641 642 643 644 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,0);//factor 1645 646 647 648 649 650 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,0);//factor 1651 652 653 654 655 656 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,0);//factor 1657 658 659 660 661 662 663 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,0);//factor 1664 665 666 667 668 669 670 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,1);//factor 0.5671 672 673 674 675 676 677 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,1);//factor 0.5678 679 680 681 682 683 684 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(1,0);//factor 2685 686 687 688 689 690 691 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(1,0);//factor 2692 693 694 695 696 697 698 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,0);//factor 1699 700 701 702 703 704 705 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,0);//factor 1706 707 708 709 710 711 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,1);//factor 0.5712 713 714 715 716 717 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,1);//factor 0.5718 719 720 721 722 723 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,1);//factor 0.5724 725 726 727 728 729 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,1);//factor 0.5730 731 732 733 734 735 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,2);//factor 0.25736 737 738 739 740 741 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,2);//factor 0.25742 743 744 745 746 747 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,2);//factor 0.25748 749 750 751 752 753 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,2);//factor 0.25754 755 756 757 758 759 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,0);//factor 1760 761 762 763 764 765 766 767 768 769 //sample rate...770 771 772 773 774 775 pConfigInfo->ulFixedSampleRate= pWaveStream->GetProperty(PROPERTY_FREQUENCY);776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 419 ULONG ulOperation, ULONG ulDataType, 420 ULONG ulNumChannels, ULONG ulBitsPerSample) 421 { 422 USHORT usConversion; 423 PWAVE_CAPS pWaveCaps; 424 ULONG ulNrSampleRates; 425 426 usConversion = CONVERT_NONE; 427 428 if(ulOperation == OPERATION_PLAY) { 429 pWaveCaps = &devCaps[ulDeviceNr].waveOutCaps; 430 } 431 else pWaveCaps = &devCaps[ulDeviceNr].waveInCaps; 432 433 //Check if hardware only supports one sample rate; if true, then we perform 434 //manual sample rate conversion before sending buffers to the ALSA driver 435 FindMatchingSampleRate(pConfigInfo->ulSampleRate, pWaveCaps->ulRateFlags, &ulNrSampleRates, &pConfigInfo->ulFixedSampleRate); 436 if(ulNrSampleRates <= 2 && pConfigInfo->ulSampleRate != pConfigInfo->ulFixedSampleRate) { 437 pConfigInfo->fSampleRateConversion = TRUE; 438 } 439 else { 440 pConfigInfo->fSampleRateConversion = FALSE; 441 } 442 443 //check if mono/stereo conversion is necessary 444 if(ulNumChannels < pWaveCaps->ulMinChannels) { 445 if(ulNumChannels == 1) { 446 if(ulOperation == OPERATION_PLAY) 447 usConversion |= CONVERT_MONO_STEREO; 448 else usConversion |= CONVERT_STEREO_MONO; 449 } 450 else DebugInt3(); 451 } 452 else 453 if(ulNumChannels > pWaveCaps->ulMaxChannels) { 454 if(ulNumChannels == 2) { 455 if(ulOperation == OPERATION_PLAY) 456 usConversion |= CONVERT_STEREO_MONO; 457 else usConversion |= CONVERT_MONO_STEREO; 458 } 459 else DebugInt3(); 460 } 461 462 //check for sample bit conversion 463 switch(ulDataType) { 464 case DATATYPE_NULL: //Warp 3 buggy data type 465 case DATATYPE_WAVEFORM: 466 case PCM: 467 switch(ulBitsPerSample) 468 { 469 case 8: 470 if(!(pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_8BPS)) 471 { 472 if(!(pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_16BPS)) { 473 DebugInt3(); 474 return FALSE; 475 } 476 if(ulOperation == OPERATION_PLAY) 477 usConversion |= CONVERT_8_16; 478 else usConversion |= CONVERT_16_8; 479 480 if(pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_16BPS_SIGNED) 481 { 482 if(ulOperation == OPERATION_PLAY) { 483 usConversion |= CONVERT_UNSIGNED_TO_SIGNED; 484 } 485 else usConversion |= CONVERT_SIGNED_TO_UNSIGNED; 486 } 487 else usConversion |= CONVERT_UNSIGNED; //unsigned to unsigned 488 } 489 else 490 if(!(pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_U8) && 491 (pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_S8)) 492 { 493 if(ulOperation == OPERATION_PLAY) 494 usConversion |= (CONVERT_UNSIGNED_TO_SIGNED | CONVERT_8BPS); 495 else usConversion |= (CONVERT_SIGNED_TO_UNSIGNED | CONVERT_8BPS); 496 } 497 else { 498 if(usConversion != CONVERT_NONE) { 499 usConversion |= (CONVERT_8BPS | CONVERT_UNSIGNED); 500 } 501 } 502 break; 503 504 case 16: 505 if(!(pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_16BPS)) 506 { 507 if(!(pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_8BPS)) { 508 DebugInt3(); 509 return FALSE; 510 } 511 if(ulOperation == OPERATION_PLAY) 512 usConversion |= CONVERT_16_8; 513 else usConversion |= CONVERT_8_16; 514 515 if(pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_U8) 516 { 517 if(ulOperation == OPERATION_PLAY) { 518 usConversion |= CONVERT_SIGNED_TO_UNSIGNED; 519 } 520 else usConversion |= CONVERT_UNSIGNED_TO_SIGNED; 521 } 522 else usConversion |= CONVERT_SIGNED; //signed to signed 523 } 524 else 525 if(!(pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_16BPS_SIGNED) && 526 (pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_16BPS_UNSIGNED)) 527 { 528 if(ulOperation == OPERATION_PLAY) 529 usConversion |= (CONVERT_SIGNED_TO_UNSIGNED | CONVERT_16BPS); 530 else usConversion |= (CONVERT_UNSIGNED_TO_SIGNED | CONVERT_16BPS); 531 } 532 else { 533 if(usConversion != CONVERT_NONE) { 534 usConversion |= (CONVERT_16BPS | CONVERT_SIGNED); 535 } 536 } 537 break; 538 } 539 break; 540 541 case DATATYPE_ALAW: 542 case DATATYPE_RIFF_ALAW: 543 case A_LAW: 544 case DATATYPE_MULAW: 545 case DATATYPE_RIFF_MULAW: 546 case MU_LAW: 547 case DATATYPE_ADPCM_AVC: 548 case DATATYPE_CT_ADPCM: 549 default: 550 DebugInt3(); 551 return FALSE; 552 } 553 554 pConfigInfo->usConversion = usConversion; 555 556 switch(usConversion) { 557 case CONVERT_NONE: 558 pConfigInfo->usConversion = CONVERT_NONE; 559 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,0); //factor 1 560 pConfigInfo->pfnConvert = ConvertNone; 561 // dprintf(("CNV_NONE")); 562 break; 563 564 case CONVERT_8_UNSIGNED_TO_8_SIGNED: 565 case CONVERT_8_SIGNED_TO_8_UNSIGNED: 566 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,0); //factor 1 567 pConfigInfo->pfnConvert = Convert8To8SignChange; 568 // dprintf(("CNV_8_U_TO_8_S/CNV_8_S_TO_8_U")); 569 break; 570 571 case CONVERT_8_UNSIGNED_TO_8_UNSIGNED_MONO_STEREO: 572 case CONVERT_8_SIGNED_TO_8_SIGNED_MONO_STEREO: 573 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(1,0); //factor 2 574 pConfigInfo->pfnConvert = Convert8MonoTo8Stereo; 575 // dprintf(("CNV_8_U_TO_8_U_MN_ST/CNV_8_S_TO_8_S_MN_ST")); 576 break; 577 578 case CONVERT_8_SIGNED_TO_8_UNSIGNED_MONO_STEREO: 579 case CONVERT_8_UNSIGNED_TO_8_SIGNED_MONO_STEREO: 580 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(1,0); //factor 2 581 pConfigInfo->pfnConvert = Convert8MonoTo8StereoSignChange; 582 // dprintf(("CNV_8_S_TO_8_U_MN_ST/CNV_8_U_TO_8_S_MN_ST")); 583 break; 584 585 case CONVERT_8_SIGNED_TO_16_SIGNED: 586 case CONVERT_8_UNSIGNED_TO_16_UNSIGNED: 587 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(1,0); //factor 2 588 pConfigInfo->pfnConvert = Convert8To16; 589 // dprintf(("CNV_8_S_TO_16_S/CNV_8_U_TO_16_U")); 590 break; 591 592 case CONVERT_8_SIGNED_TO_16_UNSIGNED: 593 case CONVERT_8_UNSIGNED_TO_16_SIGNED: 594 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(1,0); //factor 2 595 pConfigInfo->pfnConvert = Convert8To16SignChange; 596 //dprintf(("CNV_8_S_TO_16_U/CNV_8_U_TO_16_S")); 597 break; 598 599 case CONVERT_8_SIGNED_TO_16_SIGNED_MONO_STEREO: 600 case CONVERT_8_UNSIGNED_TO_16_UNSIGNED_MONO_STEREO: 601 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(2,0); //factor 4 602 pConfigInfo->pfnConvert = Convert8MonoTo16Stereo; 603 //dprintf(("CNV_8_S_TO_16_S_MN_ST/CNV_8_U_TO_16_U_MN_ST")); 604 break; 605 606 case CONVERT_8_SIGNED_TO_16_UNSIGNED_MONO_STEREO: 607 case CONVERT_8_UNSIGNED_TO_16_SIGNED_MONO_STEREO: 608 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(2,0); //factor 4 609 pConfigInfo->pfnConvert = Convert8MonoTo16StereoSignChange; 610 //dprintf(("CNV_8_S_TO_16_U_MN_ST/CNV_8_U_TO_16_S_MN_ST")); 611 break; 612 613 case CONVERT_8_UNSIGNED_TO_8_UNSIGNED_STEREO_MONO: 614 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,1); //factor 0.5 615 pConfigInfo->pfnConvert = Convert8UnsignedTo8UnsignedStereoMono; 616 //dprintf(("CNV_8_U_TO_8_U_ST_MN")); 617 break; 618 619 case CONVERT_8_SIGNED_TO_8_SIGNED_STEREO_MONO: 620 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,1); //factor 0.5 621 pConfigInfo->pfnConvert = Convert8SignedTo8SignedStereoMono; 622 //dprintf(("CNV_8_S_TO_8_S_ST_MN")); 623 break; 624 625 case CONVERT_8_UNSIGNED_TO_8_SIGNED_STEREO_MONO: 626 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,1); //factor 0.5 627 pConfigInfo->pfnConvert = Convert8UnsignedTo8SignedStereoMono; 628 //dprintf(("CNV_8_U_TO_8_S_ST_MN")); 629 break; 630 631 case CONVERT_8_SIGNED_TO_8_UNSIGNED_STEREO_MONO: 632 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,1); //factor 0.5 633 pConfigInfo->pfnConvert = Convert8SignedTo8UnsignedStereoMono; 634 //dprintf(("CNV_8_S_TO_8_U_ST_MN")); 635 break; 636 637 case CONVERT_8_UNSIGNED_TO_16_UNSIGNED_STEREO_MONO: 638 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,0); //factor 1 639 pConfigInfo->pfnConvert = Convert8UnsignedTo16UnsignedStereoMono; 640 //dprintf(("CNV_8_U_TO_16_U_ST_MN")); 641 break; 642 643 case CONVERT_8_UNSIGNED_TO_16_SIGNED_STEREO_MONO: 644 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,0); //factor 1 645 pConfigInfo->pfnConvert = Convert8UnsignedTo16SignedStereoMono; 646 //dprintf(("CNV_8_U_TO_16_S_ST_MN")); 647 break; 648 649 case CONVERT_8_SIGNED_TO_16_SIGNED_STEREO_MONO: 650 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,0); //factor 1 651 pConfigInfo->pfnConvert = Convert8SignedTo16SignedStereoMono; 652 //dprintf(("CNV_8_S_TO_16_S_ST_MN")); 653 break; 654 655 case CONVERT_8_SIGNED_TO_16_UNSIGNED_STEREO_MONO: 656 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,0); //factor 1 657 pConfigInfo->pfnConvert = Convert8SignedTo16UnsignedStereoMono; 658 //dprintf(("CNV_8_S_TO_16_U_ST_MN")); 659 break; 660 661 case CONVERT_16_UNSIGNED_TO_16_SIGNED: 662 case CONVERT_16_SIGNED_TO_16_UNSIGNED: 663 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,0); //factor 1 664 pConfigInfo->pfnConvert = Convert16To16SignChange; 665 //dprintf(("CNV_16_U_TO_16_S/CNV_16_S_TO_16_U")); 666 break; 667 668 case CONVERT_16_UNSIGNED_TO_8_UNSIGNED: 669 case CONVERT_16_SIGNED_TO_8_SIGNED: 670 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,1); //factor 0.5 671 pConfigInfo->pfnConvert = Convert16To8; 672 //dprintf(("CNV_16_U_TO_8_U/CNV_16_S_TO_8_S")); 673 break; 674 675 case CONVERT_16_UNSIGNED_TO_8_SIGNED: 676 case CONVERT_16_SIGNED_TO_8_UNSIGNED: 677 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,1); //factor 0.5 678 pConfigInfo->pfnConvert = Convert16To8SignChange; 679 //dprintf(("CNV_16_U_TO_8_S/CNV_16_S_TO_8_U")); 680 break; 681 682 case CONVERT_16_UNSIGNED_TO_16_UNSIGNED_MONO_STEREO: 683 case CONVERT_16_SIGNED_TO_16_SIGNED_MONO_STEREO: 684 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(1,0); //factor 2 685 pConfigInfo->pfnConvert = Convert16MonoTo16Stereo; 686 //dprintf(("CNV_16_U_TO_16_U_MN_ST/CNV_16_S_TO_16_S_MN_ST")); 687 break; 688 689 case CONVERT_16_UNSIGNED_TO_16_SIGNED_MONO_STEREO: 690 case CONVERT_16_SIGNED_TO_16_UNSIGNED_MONO_STEREO: 691 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(1,0); //factor 2 692 pConfigInfo->pfnConvert = Convert16MonoTo16StereoSignChange; 693 //dprintf(("CNV_16_U_TO_16_S_MN_ST/CNV_16_S_TO_16_U_MN_ST")); 694 break; 695 696 case CONVERT_16_UNSIGNED_TO_8_UNSIGNED_MONO_STEREO: 697 case CONVERT_16_SIGNED_TO_8_UNSIGNED_MONO_STEREO: 698 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,0); //factor 1 699 pConfigInfo->pfnConvert = Convert16MonoTo8Stereo; 700 //dprintf(("CNV_16_U_TO_8_U_MONO_ST/CNV_16_S_TO_8_U_MN_ST")); 701 break; 702 703 case CONVERT_16_UNSIGNED_TO_8_SIGNED_MONO_STEREO: 704 case CONVERT_16_SIGNED_TO_8_SIGNED_MONO_STEREO: 705 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,0); //factor 1 706 pConfigInfo->pfnConvert = Convert16MonoTo8StereoSignChange; 707 //dprintf(("CNV_16_U_TO_8_S_MN_ST/CNV_16_S_TO_8_S_MN_ST")); 708 break; 709 710 case CONVERT_16_UNSIGNED_TO_16_SIGNED_STEREO_MONO: 711 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,1); //factor 0.5 712 pConfigInfo->pfnConvert = Convert16UnsignedTo16SignedStereoMono; 713 //dprintf(("CNV_16_U_TO_16_S_ST_MN")); 714 break; 715 716 case CONVERT_16_UNSIGNED_TO_16_UNSIGNED_STEREO_MONO: 717 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,1); //factor 0.5 718 pConfigInfo->pfnConvert = Convert16UnsignedTo16UnsignedStereoMono; 719 //dprintf(("CNV_16_U_TO_16_U_ST_MN")); 720 break; 721 722 case CONVERT_16_SIGNED_TO_16_SIGNED_STEREO_MONO: 723 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,1); //factor 0.5 724 pConfigInfo->pfnConvert = Convert16SignedTo16SignedStereoMono; 725 //dprintf(("CNV_16_S_TO_16_S_ST_MN")); 726 break; 727 728 case CONVERT_16_SIGNED_TO_16_UNSIGNED_STEREO_MONO: 729 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,1); //factor 0.5 730 pConfigInfo->pfnConvert = Convert16SignedTo16UnsignedStereoMono; 731 //dprintf(("CNV_16_S_TO_16_U_ST_MN")); 732 break; 733 734 case CONVERT_16_UNSIGNED_TO_8_UNSIGNED_STEREO_MONO: 735 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,2); //factor 0.25 736 pConfigInfo->pfnConvert = Convert16UnsignedTo8UnsignedStereoMono; 737 //dprintf(("CNV_16_U_TO_8_U_ST_MN")); 738 break; 739 740 case CONVERT_16_UNSIGNED_TO_8_SIGNED_STEREO_MONO: 741 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,2); //factor 0.25 742 pConfigInfo->pfnConvert = Convert16UnsignedTo8SignedStereoMono; 743 //dprintf(("CNV_16_U_TO_8_S_ST_MN")); 744 break; 745 746 case CONVERT_16_SIGNED_TO_8_SIGNED_STEREO_MONO: 747 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,2); //factor 0.25 748 pConfigInfo->pfnConvert = Convert16SignedTo8SignedStereoMono; 749 //dprintf(("CNV_16_S_TO_8_S_ST_MN")); 750 break; 751 752 case CONVERT_16_SIGNED_TO_8_UNSIGNED_STEREO_MONO: 753 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,2); //factor 0.25 754 pConfigInfo->pfnConvert = Convert16SignedTo8UnsignedStereoMono; 755 //dprintf(("CNV_16_S_TO_8_U_ST_MN")); 756 break; 757 758 default: 759 pConfigInfo->ulConversionFactor = CONVERSION_FACTOR(0,0); //factor 1 760 pConfigInfo->pfnConvert = NULL; 761 DebugInt3(); 762 return FALSE; 763 } 764 765 dprintf(("Cnv factor %lx", pConfigInfo->ulConversionFactor)); 766 767 //Some hardware can't do full duplex with different sample rates (e.g. ALS4000) 768 //NOTE: This isn't going to be pretty if the other active stream has a much lower 769 // sample rate... 770 if(pWaveCaps->ulRateFlags & OSS32_CAPS_PCM_RATE_HALFDUPLEX) { 771 WAVESTREAM *pWaveStream; 772 773 pWaveStream = (WAVESTREAM *)FindActiveStream((ulOperation == OPERATION_PLAY) ? STREAM_WAVE_CAPTURE : STREAM_WAVE_PLAY); 774 if(pWaveStream != NULL) { 775 pConfigInfo->ulFixedSampleRate = pWaveStream->GetProperty(PROPERTY_FREQUENCY); 776 pConfigInfo->fSampleRateConversion = TRUE; 777 dprintf(("Force sample rate cnv for legacy hardware -> %d", pConfigInfo->ulFixedSampleRate)); 778 } 779 } 780 781 if(pConfigInfo->fSampleRateConversion) 782 { 783 if(QuerySampleFormat(ulOperation, pConfigInfo) == TRUE) 784 { 785 if(pConfigInfo->ulHwBitsPerSample == 8) { 786 if(pConfigInfo->ulHwNumChannels == 2) { 787 pConfigInfo->pfnSRateConv = SRateConvert8Stereo; 788 } 789 else pConfigInfo->pfnSRateConv = SRateConvert8Mono; 790 } 791 else 792 if(pConfigInfo->ulHwBitsPerSample == 16) { 793 if(pConfigInfo->ulHwNumChannels == 2) { 794 pConfigInfo->pfnSRateConv = SRateConvert16Stereo; 795 } 796 else pConfigInfo->pfnSRateConv = SRateConvert16Mono; 797 } 798 else { 799 pConfigInfo->pfnSRateConv = NULL; 800 DebugInt3(); 801 } 802 pConfigInfo->ulSRatePosition = 0; 803 if(ulOperation == OPERATION_PLAY) { 804 pConfigInfo->ulSRateIncrement = SRATE_CALC_INCREMENT(pConfigInfo->ulFixedSampleRate, pConfigInfo->ulSampleRate); 805 } 806 else pConfigInfo->ulSRateIncrement = SRATE_CALC_INCREMENT_INVERT(pConfigInfo->ulFixedSampleRate, pConfigInfo->ulSampleRate); 807 808 dprintf(("Sample rate cnv: increment %ld", pConfigInfo->ulSRateIncrement)); 809 } 810 else { 811 pConfigInfo->pfnSRateConv = NULL; 812 DebugInt3(); 813 return FALSE; 814 } 815 } 816 return TRUE; 817 817 } 818 818 //****************************************************************************** … … 822 822 BOOL WAVEAUDIO::QuerySampleFormat(ULONG ulOperation, PWAVECONFIGINFO pConfigInfo) 823 823 { 824 if(pConfigInfo->ulHwBitsPerSample) { 825 //already determined; 826 return TRUE; 827 } 828 if(pConfigInfo->fSampleRateConversion) 829 { 830 pConfigInfo->ulHwSampleRate = pConfigInfo->ulFixedSampleRate; 831 #ifdef DEBUG 832 dprintf(("WA::QuerySampleFormat: SampleRate1 %d", pConfigInfo->ulHwSampleRate)); 833 #endif 834 } 835 else 836 { 837 pConfigInfo->ulHwSampleRate = pConfigInfo->ulSampleRate; 838 #ifdef DEBUG 839 dprintf(("WA::QuerySampleFormat: SampleRate2 %d", pConfigInfo->ulHwSampleRate)); 840 #endif 841 } 842 843 pConfigInfo->ulHwBitsPerSample = pConfigInfo->ulBitsPerSample; 844 pConfigInfo->ulHwNumChannels = pConfigInfo->ulNumChannels; 845 846 switch(pConfigInfo->usConversion) { 847 case CONVERT_NONE: 848 case CONVERT_8_UNSIGNED_TO_8_SIGNED: 849 case CONVERT_8_SIGNED_TO_8_UNSIGNED: 850 case CONVERT_16_UNSIGNED_TO_16_SIGNED: 851 case CONVERT_16_SIGNED_TO_16_UNSIGNED: 852 //no change 853 break; 854 855 case CONVERT_8_UNSIGNED_TO_8_SIGNED_MONO_STEREO: 856 case CONVERT_8_SIGNED_TO_8_UNSIGNED_MONO_STEREO: 857 case CONVERT_8_UNSIGNED_TO_8_UNSIGNED_MONO_STEREO: 858 case CONVERT_8_SIGNED_TO_8_SIGNED_MONO_STEREO: 859 case CONVERT_16_UNSIGNED_TO_16_SIGNED_MONO_STEREO: 860 case CONVERT_16_SIGNED_TO_16_UNSIGNED_MONO_STEREO: 861 case CONVERT_16_UNSIGNED_TO_16_UNSIGNED_MONO_STEREO: 862 case CONVERT_16_SIGNED_TO_16_SIGNED_MONO_STEREO: 863 if(ulOperation == OPERATION_PLAY) { 864 pConfigInfo->ulHwNumChannels = 2; 865 } 866 else pConfigInfo->ulHwNumChannels = 1; 867 break; 868 869 case CONVERT_8_UNSIGNED_TO_8_SIGNED_STEREO_MONO: 870 case CONVERT_8_SIGNED_TO_8_UNSIGNED_STEREO_MONO: 871 case CONVERT_8_UNSIGNED_TO_8_UNSIGNED_STEREO_MONO: 872 case CONVERT_8_SIGNED_TO_8_SIGNED_STEREO_MONO: 873 case CONVERT_16_UNSIGNED_TO_16_UNSIGNED_STEREO_MONO: 874 case CONVERT_16_SIGNED_TO_16_SIGNED_STEREO_MONO: 875 case CONVERT_16_UNSIGNED_TO_16_SIGNED_STEREO_MONO: 876 case CONVERT_16_SIGNED_TO_16_UNSIGNED_STEREO_MONO: 877 if(ulOperation == OPERATION_PLAY) { 878 pConfigInfo->ulHwNumChannels = 1; 879 } 880 else pConfigInfo->ulHwNumChannels = 2; 881 break; 882 883 case CONVERT_8_UNSIGNED_TO_16_UNSIGNED: 884 case CONVERT_8_UNSIGNED_TO_16_SIGNED: 885 case CONVERT_8_SIGNED_TO_16_SIGNED: 886 case CONVERT_8_SIGNED_TO_16_UNSIGNED: 887 if(ulOperation == OPERATION_PLAY) { 888 pConfigInfo->ulHwBitsPerSample = 16; 889 } 890 else pConfigInfo->ulHwBitsPerSample = 8; 891 break; 892 893 case CONVERT_8_UNSIGNED_TO_16_UNSIGNED_STEREO_MONO: 894 case CONVERT_8_UNSIGNED_TO_16_SIGNED_STEREO_MONO: 895 case CONVERT_8_SIGNED_TO_16_SIGNED_STEREO_MONO: 896 case CONVERT_8_SIGNED_TO_16_UNSIGNED_STEREO_MONO: 897 if(ulOperation == OPERATION_PLAY) { 898 pConfigInfo->ulHwBitsPerSample = 16; 899 pConfigInfo->ulHwNumChannels = 1; 900 } 901 else { 902 pConfigInfo->ulHwBitsPerSample = 8; 903 pConfigInfo->ulHwNumChannels = 2; 904 } 905 break; 906 907 case CONVERT_8_UNSIGNED_TO_16_UNSIGNED_MONO_STEREO: 908 case CONVERT_8_UNSIGNED_TO_16_SIGNED_MONO_STEREO: 909 case CONVERT_8_SIGNED_TO_16_SIGNED_MONO_STEREO: 910 case CONVERT_8_SIGNED_TO_16_UNSIGNED_MONO_STEREO: 911 if(ulOperation == OPERATION_PLAY) { 912 pConfigInfo->ulHwBitsPerSample = 16; 913 pConfigInfo->ulHwNumChannels = 2; 914 } 915 else { 916 pConfigInfo->ulHwBitsPerSample = 8; 917 pConfigInfo->ulHwNumChannels = 1; 918 } 919 break; 920 921 case CONVERT_16_UNSIGNED_TO_8_UNSIGNED: 922 case CONVERT_16_UNSIGNED_TO_8_SIGNED: 923 case CONVERT_16_SIGNED_TO_8_SIGNED: 924 case CONVERT_16_SIGNED_TO_8_UNSIGNED: 925 if(ulOperation == OPERATION_PLAY) { 926 pConfigInfo->ulHwBitsPerSample = 8; 927 } 928 else pConfigInfo->ulHwBitsPerSample = 16; 929 break; 930 931 case CONVERT_16_UNSIGNED_TO_8_UNSIGNED_MONO_STEREO: 932 case CONVERT_16_UNSIGNED_TO_8_SIGNED_MONO_STEREO: 933 case CONVERT_16_SIGNED_TO_8_SIGNED_MONO_STEREO: 934 case CONVERT_16_SIGNED_TO_8_UNSIGNED_MONO_STEREO: 935 if(ulOperation == OPERATION_PLAY) { 936 pConfigInfo->ulHwBitsPerSample = 8; 937 pConfigInfo->ulHwNumChannels = 2; 938 } 939 else { 940 pConfigInfo->ulHwBitsPerSample = 16; 941 pConfigInfo->ulHwNumChannels = 1; 942 } 943 break; 944 945 case CONVERT_16_UNSIGNED_TO_8_UNSIGNED_STEREO_MONO: 946 case CONVERT_16_UNSIGNED_TO_8_SIGNED_STEREO_MONO: 947 case CONVERT_16_SIGNED_TO_8_SIGNED_STEREO_MONO: 948 case CONVERT_16_SIGNED_TO_8_UNSIGNED_STEREO_MONO: 949 if(ulOperation == OPERATION_PLAY) { 950 pConfigInfo->ulHwBitsPerSample = 8; 951 pConfigInfo->ulHwNumChannels = 1; 952 } 953 else { 954 pConfigInfo->ulHwBitsPerSample = 16; 955 pConfigInfo->ulHwNumChannels = 2; 956 } 957 break; 958 959 default: 960 DebugInt3(); 961 return FALSE; 962 } 963 964 pConfigInfo->ulHwSampleSize = (pConfigInfo->ulHwBitsPerSample * pConfigInfo->ulHwNumChannels) / 8; 965 return TRUE; 824 if(pConfigInfo->ulHwBitsPerSample) { 825 //already determined; 826 return TRUE; 827 } 828 if(pConfigInfo->fSampleRateConversion) 829 { 830 pConfigInfo->ulHwSampleRate = pConfigInfo->ulFixedSampleRate; 831 dprintf(("WA::QuerySampleFormat: SampleRate1 %d", pConfigInfo->ulHwSampleRate)); 832 } 833 else 834 { 835 pConfigInfo->ulHwSampleRate = pConfigInfo->ulSampleRate; 836 dprintf(("WA::QuerySampleFormat: SampleRate2 %d", pConfigInfo->ulHwSampleRate)); 837 } 838 839 pConfigInfo->ulHwBitsPerSample = pConfigInfo->ulBitsPerSample; 840 pConfigInfo->ulHwNumChannels = pConfigInfo->ulNumChannels; 841 842 switch(pConfigInfo->usConversion) { 843 case CONVERT_NONE: 844 case CONVERT_8_UNSIGNED_TO_8_SIGNED: 845 case CONVERT_8_SIGNED_TO_8_UNSIGNED: 846 case CONVERT_16_UNSIGNED_TO_16_SIGNED: 847 case CONVERT_16_SIGNED_TO_16_UNSIGNED: 848 //no change 849 break; 850 851 case CONVERT_8_UNSIGNED_TO_8_SIGNED_MONO_STEREO: 852 case CONVERT_8_SIGNED_TO_8_UNSIGNED_MONO_STEREO: 853 case CONVERT_8_UNSIGNED_TO_8_UNSIGNED_MONO_STEREO: 854 case CONVERT_8_SIGNED_TO_8_SIGNED_MONO_STEREO: 855 case CONVERT_16_UNSIGNED_TO_16_SIGNED_MONO_STEREO: 856 case CONVERT_16_SIGNED_TO_16_UNSIGNED_MONO_STEREO: 857 case CONVERT_16_UNSIGNED_TO_16_UNSIGNED_MONO_STEREO: 858 case CONVERT_16_SIGNED_TO_16_SIGNED_MONO_STEREO: 859 if(ulOperation == OPERATION_PLAY) { 860 pConfigInfo->ulHwNumChannels = 2; 861 } 862 else pConfigInfo->ulHwNumChannels = 1; 863 break; 864 865 case CONVERT_8_UNSIGNED_TO_8_SIGNED_STEREO_MONO: 866 case CONVERT_8_SIGNED_TO_8_UNSIGNED_STEREO_MONO: 867 case CONVERT_8_UNSIGNED_TO_8_UNSIGNED_STEREO_MONO: 868 case CONVERT_8_SIGNED_TO_8_SIGNED_STEREO_MONO: 869 case CONVERT_16_UNSIGNED_TO_16_UNSIGNED_STEREO_MONO: 870 case CONVERT_16_SIGNED_TO_16_SIGNED_STEREO_MONO: 871 case CONVERT_16_UNSIGNED_TO_16_SIGNED_STEREO_MONO: 872 case CONVERT_16_SIGNED_TO_16_UNSIGNED_STEREO_MONO: 873 if(ulOperation == OPERATION_PLAY) { 874 pConfigInfo->ulHwNumChannels = 1; 875 } 876 else pConfigInfo->ulHwNumChannels = 2; 877 break; 878 879 case CONVERT_8_UNSIGNED_TO_16_UNSIGNED: 880 case CONVERT_8_UNSIGNED_TO_16_SIGNED: 881 case CONVERT_8_SIGNED_TO_16_SIGNED: 882 case CONVERT_8_SIGNED_TO_16_UNSIGNED: 883 if(ulOperation == OPERATION_PLAY) { 884 pConfigInfo->ulHwBitsPerSample = 16; 885 } 886 else pConfigInfo->ulHwBitsPerSample = 8; 887 break; 888 889 case CONVERT_8_UNSIGNED_TO_16_UNSIGNED_STEREO_MONO: 890 case CONVERT_8_UNSIGNED_TO_16_SIGNED_STEREO_MONO: 891 case CONVERT_8_SIGNED_TO_16_SIGNED_STEREO_MONO: 892 case CONVERT_8_SIGNED_TO_16_UNSIGNED_STEREO_MONO: 893 if(ulOperation == OPERATION_PLAY) { 894 pConfigInfo->ulHwBitsPerSample = 16; 895 pConfigInfo->ulHwNumChannels = 1; 896 } 897 else { 898 pConfigInfo->ulHwBitsPerSample = 8; 899 pConfigInfo->ulHwNumChannels = 2; 900 } 901 break; 902 903 case CONVERT_8_UNSIGNED_TO_16_UNSIGNED_MONO_STEREO: 904 case CONVERT_8_UNSIGNED_TO_16_SIGNED_MONO_STEREO: 905 case CONVERT_8_SIGNED_TO_16_SIGNED_MONO_STEREO: 906 case CONVERT_8_SIGNED_TO_16_UNSIGNED_MONO_STEREO: 907 if(ulOperation == OPERATION_PLAY) { 908 pConfigInfo->ulHwBitsPerSample = 16; 909 pConfigInfo->ulHwNumChannels = 2; 910 } 911 else { 912 pConfigInfo->ulHwBitsPerSample = 8; 913 pConfigInfo->ulHwNumChannels = 1; 914 } 915 break; 916 917 case CONVERT_16_UNSIGNED_TO_8_UNSIGNED: 918 case CONVERT_16_UNSIGNED_TO_8_SIGNED: 919 case CONVERT_16_SIGNED_TO_8_SIGNED: 920 case CONVERT_16_SIGNED_TO_8_UNSIGNED: 921 if(ulOperation == OPERATION_PLAY) { 922 pConfigInfo->ulHwBitsPerSample = 8; 923 } 924 else pConfigInfo->ulHwBitsPerSample = 16; 925 break; 926 927 case CONVERT_16_UNSIGNED_TO_8_UNSIGNED_MONO_STEREO: 928 case CONVERT_16_UNSIGNED_TO_8_SIGNED_MONO_STEREO: 929 case CONVERT_16_SIGNED_TO_8_SIGNED_MONO_STEREO: 930 case CONVERT_16_SIGNED_TO_8_UNSIGNED_MONO_STEREO: 931 if(ulOperation == OPERATION_PLAY) { 932 pConfigInfo->ulHwBitsPerSample = 8; 933 pConfigInfo->ulHwNumChannels = 2; 934 } 935 else { 936 pConfigInfo->ulHwBitsPerSample = 16; 937 pConfigInfo->ulHwNumChannels = 1; 938 } 939 break; 940 941 case CONVERT_16_UNSIGNED_TO_8_UNSIGNED_STEREO_MONO: 942 case CONVERT_16_UNSIGNED_TO_8_SIGNED_STEREO_MONO: 943 case CONVERT_16_SIGNED_TO_8_SIGNED_STEREO_MONO: 944 case CONVERT_16_SIGNED_TO_8_UNSIGNED_STEREO_MONO: 945 if(ulOperation == OPERATION_PLAY) { 946 pConfigInfo->ulHwBitsPerSample = 8; 947 pConfigInfo->ulHwNumChannels = 1; 948 } 949 else { 950 pConfigInfo->ulHwBitsPerSample = 16; 951 pConfigInfo->ulHwNumChannels = 2; 952 } 953 break; 954 955 default: 956 DebugInt3(); 957 return FALSE; 958 } 959 960 pConfigInfo->ulHwSampleSize = (pConfigInfo->ulHwBitsPerSample * pConfigInfo->ulHwNumChannels) / 8; 961 return TRUE; 966 962 } 967 963 //****************************************************************************** … … 969 965 //****************************************************************************** 970 966 ULONG WAVEAUDIO::FindMatchingSampleRate(ULONG ulSampleRate, ULONG ulOSSSRateFlags, 971 972 { 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 967 ULONG FAR *pulNrSampleRates, ULONG FAR *pulFixedSampleRate) 968 { 969 ULONG sampleRates[31]; 970 int nrSampleRates = 0; 971 972 if(pulFixedSampleRate) { 973 *pulFixedSampleRate = -1; 974 } 975 if(ulOSSSRateFlags & OSS32_CAPS_PCM_RATE_5512) { 976 sampleRates[nrSampleRates++] = 5512; 977 } 978 if(ulOSSSRateFlags & OSS32_CAPS_PCM_RATE_8000) { 979 sampleRates[nrSampleRates++] = 8000; 980 } 981 if(ulOSSSRateFlags & OSS32_CAPS_PCM_RATE_11025) { 982 sampleRates[nrSampleRates++] = 11025; 983 } 984 if(ulOSSSRateFlags & OSS32_CAPS_PCM_RATE_16000) { 985 sampleRates[nrSampleRates++] = 16000; 986 } 987 if(ulOSSSRateFlags & OSS32_CAPS_PCM_RATE_22050) { 988 sampleRates[nrSampleRates++] = 22050; 989 } 990 if(ulOSSSRateFlags & OSS32_CAPS_PCM_RATE_32000) { 991 sampleRates[nrSampleRates++] = 32000; 992 } 993 if(ulOSSSRateFlags & OSS32_CAPS_PCM_RATE_44100) { 994 sampleRates[nrSampleRates++] = 44100; 995 } 996 if(ulOSSSRateFlags & OSS32_CAPS_PCM_RATE_48000) { 997 sampleRates[nrSampleRates++] = 48000; 998 } 999 if(ulOSSSRateFlags & OSS32_CAPS_PCM_RATE_64000) { 1000 sampleRates[nrSampleRates++] = 64000; 1001 } 1002 if(ulOSSSRateFlags & OSS32_CAPS_PCM_RATE_88200) { 1003 sampleRates[nrSampleRates++] = 88200; 1004 } 1005 if(ulOSSSRateFlags & OSS32_CAPS_PCM_RATE_96000) { 1006 sampleRates[nrSampleRates++] = 96000; 1007 } 1008 if(ulOSSSRateFlags & OSS32_CAPS_PCM_RATE_176400) { 1009 sampleRates[nrSampleRates++] = 176400; 1010 } 1011 if(ulOSSSRateFlags & OSS32_CAPS_PCM_RATE_192000) { 1012 sampleRates[nrSampleRates++] = 192000; 1013 } 1014 if(nrSampleRates > 2) { 1015 _usfind_matching_sample_rate(&ulSampleRate, nrSampleRates, (ULONG FAR *)sampleRates); 1016 } 1017 else { 1018 //fixed rate -> we support all sample rates by manually performing sample rate conversion 1019 if(nrSampleRates <= 2 && pulFixedSampleRate) { 1020 //sampleRates[0] = 44100; /* hardware set to 44100 */ 1021 *pulFixedSampleRate = sampleRates[0]; 1022 nrSampleRates = 1; 1023 } 1024 } 1025 1026 *pulNrSampleRates = nrSampleRates; 1027 return ulSampleRate; 1032 1028 } 1033 1029 … … 1040 1036 void WAVEAUDIO::DevCaps(PAUDIO_CAPS pCaps) 1041 1037 { 1042 USHORT usSampleRateIndex; 1043 ULONG ulSampleRate; 1044 PWAVE_CAPS pWaveCaps; 1045 1038 USHORT usSampleRateIndex; 1039 ULONG ulSampleRate; 1040 PWAVE_CAPS pWaveCaps; 1041 1042 dprintf(("WAVEAUDIO::DevCaps1")); 1043 1044 pCaps->ulFlags = 0; 1045 1046 // This device driver supports Playback or Record Operations 1047 // anything else makes no sence. Note: This a per stream operation so 1048 // even if this sevice can do full-duplex, it can not do PLAY_AND_RECORD 1049 1050 if ( pCaps->ulOperation != OPERATION_PLAY && 1051 pCaps->ulOperation != OPERATION_RECORD ) 1052 { 1053 dprintf(("DevCaps1 not play/record")); 1054 pCaps->ulSupport = UNSUPPORTED_OPERATION; 1055 return; 1056 } 1057 1058 if(pCaps->ulOperation == OPERATION_PLAY) 1059 { 1060 pWaveCaps = &devCaps[ulDeviceNr].waveOutCaps; 1061 } 1062 else pWaveCaps = &devCaps[ulDeviceNr].waveInCaps; 1063 1064 // We always support stereo and mono 1065 if (pCaps->ulChannels != 1 && pCaps->ulChannels != 2) 1066 { 1067 if(pCaps->ulChannels > pWaveCaps->ulMaxChannels) 1068 { 1069 dprintf(("DevCaps1 not channel")); 1070 pCaps->ulSupport = UNSUPPORTED_CHANNELS; 1071 return; 1072 } 1073 } 1074 if (pCaps->ulSamplingRate == 0) 1075 { 1076 dprintf(("DevCaps1 not rate")); 1077 pCaps->ulSupport = UNSUPPORTED_RATE; 1078 return; 1079 } 1080 1081 //Determine supported rates 1082 ulSampleRate = pCaps->ulSamplingRate; //save the sampling rate called with 1083 1084 if(pWaveCaps->ulRateFlags & OSS32_CAPS_PCM_RATE_CONTINUOUS) 1085 {//supports all sample rates from min to max 1086 if (ulSampleRate < pWaveCaps->ulMinRate) { 1087 ulSampleRate = pWaveCaps->ulMinRate; 1088 } 1089 else 1090 if(ulSampleRate > pWaveCaps->ulMaxRate) { 1091 ulSampleRate = pWaveCaps->ulMaxRate; 1092 } 1093 } 1094 else { 1095 ULONG ulNrSampleRates; 1096 1097 ulSampleRate = FindMatchingSampleRate(ulSampleRate, pWaveCaps->ulRateFlags, &ulNrSampleRates); 1098 } 1099 1100 // If we don't support the requested samplerate, then fill in the best fit flag. 1101 if (ulSampleRate != pCaps->ulSamplingRate) 1102 pCaps->ulFlags |= BESTFIT_PROVIDED; 1103 1104 // find out the closest sampling rate (may or may not be the same ) 1105 // from one of the following: 11025Hz, 22050Hz, 44100Hz and 8000Hz 1106 // _usfind_matching_sample_rate will update pCaps->ulSamplingRate if there 1107 // is not an exact match. 1108 usSampleRateIndex = _usfind_matching_sample_rate(&pCaps->ulSamplingRate); 1109 1110 //query flags for this wave data format 1111 pCaps->ulFlags |= QueryDataFlags(pCaps->ulOperation, pCaps->ulDataType, pCaps->ulBitsPerSample); 1112 1113 // Determine the ulDataSubType and update any format specific flags 1114 // Note: All data types have more than one value. 1115 switch ( pCaps->ulDataType ) 1116 { 1117 case DATATYPE_NULL: //Warp 3 buggy data type 1118 case DATATYPE_WAVEFORM: 1119 case PCM: 1120 // supported bits per sample are 8 (for unsigned PCM, u-law or A-law ) 1121 // and 16 (for 2's complement PCM) 1122 switch(pCaps->ulBitsPerSample) { 1123 case 8: 1124 case 16: 1125 //NOTE: We always support 8 & 16 bits playback & recording; if the card 1126 // can't handle one of these formats, then we'll convert the 1127 // wave data ourselves (same for mono/stereo). 1128 break; 1129 case 24: 1130 if(!(pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_24BPS)) 1131 { 1132 dprintf(("DevCaps1 not 24BPS")); 1133 pCaps->ulSupport = UNSUPPORTED_BPS; 1134 return; 1135 } 1136 break; 1137 case 32: 1138 if(!(pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_32BPS)) 1139 { 1140 pCaps->ulSupport = UNSUPPORTED_BPS; 1141 dprintf(("DevCaps1 not 32BPS")); 1142 return; 1143 } 1144 break; 1145 default: 1146 dprintf(("DevCaps1 not BPS %d",(USHORT)pCaps->ulBitsPerSample)); 1147 pCaps->ulSupport = UNSUPPORTED_BPS; 1148 return; 1149 } 1150 1151 // determine subtype for PCM: 1152 pCaps->ulDataSubType = aaulWave[usSampleRateIndex] 1153 [(pCaps->ulBitsPerSample-8)/8] 1154 [pCaps->ulChannels-1]; 1155 break; 1156 1157 case DATATYPE_ALAW: 1158 case DATATYPE_RIFF_ALAW: 1159 case A_LAW: 1160 if(!(pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_ALAW)) 1161 { 1162 dprintf(("DevCaps1 not ALAW")); 1163 pCaps->ulSupport = UNSUPPORTED_DATATYPE; 1164 return; 1165 } 1166 // supported bits per sample are 8 (for unsigned PCM, u-law or A-law ) 1167 if (pCaps->ulBitsPerSample != 8) 1168 { 1169 dprintf(("DevCaps1 not ALAW BPS8")); 1170 pCaps->ulSupport = UNSUPPORTED_BPS; 1171 return; 1172 } 1173 // determine subtype for A_LAW 1174 pCaps->ulDataSubType = aaulAlaw[usSampleRateIndex][pCaps->ulChannels-1]; 1175 break; 1176 1177 case DATATYPE_MULAW: 1178 case DATATYPE_RIFF_MULAW: 1179 case MU_LAW: 1180 if(!(pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_MULAW)) 1181 { 1182 dprintf(("DevCaps1 not MULAW")); 1183 pCaps->ulSupport = UNSUPPORTED_DATATYPE; 1184 return; 1185 } 1186 // supported bits per sample are 8 (for unsigned PCM, u-law or A-law ) 1187 if (pCaps->ulBitsPerSample != 8) 1188 { 1189 dprintf(("DevCaps1 not MULAW BPS8")); 1190 pCaps->ulSupport = UNSUPPORTED_BPS; 1191 return; 1192 } 1193 // determine subtype for MU_LAW 1194 pCaps->ulDataSubType = aaulMulaw[usSampleRateIndex][pCaps->ulChannels-1]; 1195 break; 1196 1197 case DATATYPE_ADPCM_AVC: 1198 case DATATYPE_CT_ADPCM: 1199 if(!(pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_ADPCM)) 1200 { 1201 dprintf(("DevCaps1 not ADPCM")); 1202 pCaps->ulSupport = UNSUPPORTED_DATATYPE; 1203 return; 1204 } 1205 // supported bits per sample are 4 1206 if (pCaps->ulBitsPerSample != 4) 1207 { 1208 dprintf(("DevCaps1 not ADPCM BPS4")); 1209 pCaps->ulSupport = UNSUPPORTED_BPS; 1210 return; 1211 } 1212 // determine subtype for ADPCM 1213 pCaps->ulDataSubType = aaulMulaw[usSampleRateIndex][pCaps->ulChannels-1]; 1214 break; 1215 1216 default: 1217 dprintf(("DevCaps1 not dattype")); 1218 pCaps->ulSupport = UNSUPPORTED_DATATYPE; 1219 return; 1220 } // end switch 1221 1222 pCaps->ulFlags |= FIXED | // Fixed length data 1223 LEFT_ALIGNED | // Left align bits on byte bndry 1224 INPUT | // Input select is supported 1225 OUTPUT | // Output select is supported 1226 MONITOR | // Monitor is supported 1227 VOLUME; // Volume control is supported 1228 1229 // Full Duplex Enabling Stuff here !! 1230 // The number of resource units is described in the MMPM2.INI 1231 // This can be thought of the number of active streams the 1232 // driver can manage at one time. We list this number as 2. 1233 // we tell MMPM here how many of these units THIS stream will consume. 1234 // The answer is so simple it's brilliant, (Thanks to Joe Nord at Crystal 1235 // Semi) If we are enabled to do full-duplex this stream will consume 1 1236 // unit, If we are not enabled to do full-duplex this stream will consume 2 1237 // (or all the available units) 1238 // Along with the resource units, we defined 2 resources classes, 1239 // one for playback and one for capture. We tell MMPM (in the MMPM2.INI) 1240 // that we can handle doing 1 playback and 1 capture stream or 1 capture and 1241 // one playback stream at the same time. (Valid Resource combos in the 1242 // MMPM2.INI) check if we are a playback or capture and set the correct 1243 // resource class (Playback = 1, Capture = 2) 1244 1245 if(pCaps->ulOperation == OPERATION_PLAY) 1246 { 1247 if(pWaveCaps->nrStreams) { 1248 pCaps->ulResourceUnits = OSS32_MAX_WAVE_PLAYBACK_STREAMS/pWaveCaps->nrStreams; 1249 } 1250 else { 1251 DebugInt3(); //should never happen! 1252 pCaps->ulResourceUnits = OSS32_MAX_WAVE_PLAYBACK_STREAMS; 1253 } 1254 dprintf(("RU used by playback stream: %d", (int)pCaps->ulResourceUnits)); 1255 } 1256 else { 1257 if(pWaveCaps->nrStreams < OSS32_MAX_WAVE_CAPTURE_STREAMS) { 1258 DebugInt3(); 1259 } 1260 pCaps->ulResourceUnits = 1; 1261 } 1262 1263 if ( pCaps->ulOperation == OPERATION_PLAY) 1264 pCaps->ulResourceClass = 1; 1265 else 1266 pCaps->ulResourceClass = 2; 1267 pCaps->fCanRecord = 1; // Yes Virgina we can record 1268 pCaps->ulBlockAlign = 1; // Block alignment for this mode 1269 1270 //return success 1271 pCaps->ulSupport = SUPPORT_SUCCESS; 1272 dprintf(("WAVEAUDIO::DevCaps %ld %ld %ld ", pCaps->ulBitsPerSample, pCaps->ulSamplingRate, pCaps->ulChannels)); 1273 dprintf(("Op %ld ResourceClass %ld ResourceUnits %ld", pCaps->ulOperation, pCaps->ulResourceClass, pCaps->ulResourceUnits)); 1274 dprintf(("Data type %ld, data subtype %ld", pCaps->ulDataType, pCaps->ulDataSubType)); 1046 1275 #ifdef DEBUG 1047 dprintf(("WAVEAUDIO::DevCaps1")); 1048 #endif 1049 1050 pCaps->ulFlags = 0; 1051 1052 // This device driver supports Playback or Record Operations 1053 // anything else makes no sence. Note: This a per stream operation so 1054 // even if this sevice can do full-duplex, it can not do PLAY_AND_RECORD 1055 1056 if ( pCaps->ulOperation != OPERATION_PLAY && 1057 pCaps->ulOperation != OPERATION_RECORD ) 1058 { 1059 dprintf(("DevCaps1 not play/record")); 1060 pCaps->ulSupport = UNSUPPORTED_OPERATION; 1061 return; 1062 } 1063 1064 if(pCaps->ulOperation == OPERATION_PLAY) 1065 { 1066 pWaveCaps = &devCaps[ulDeviceNr].waveOutCaps; 1067 } 1068 else pWaveCaps = &devCaps[ulDeviceNr].waveInCaps; 1069 1070 // We always support stereo and mono 1071 if (pCaps->ulChannels != 1 && pCaps->ulChannels != 2) 1072 { 1073 if(pCaps->ulChannels > pWaveCaps->ulMaxChannels) 1074 { 1075 dprintf(("DevCaps1 not channel")); 1076 pCaps->ulSupport = UNSUPPORTED_CHANNELS; 1077 return; 1078 } 1079 } 1080 if (pCaps->ulSamplingRate == 0) 1081 { 1082 dprintf(("DevCaps1 not rate")); 1083 pCaps->ulSupport = UNSUPPORTED_RATE; 1084 return; 1085 } 1086 1087 //Determine supported rates 1088 ulSampleRate = pCaps->ulSamplingRate; //save the sampling rate called with 1089 1090 if(pWaveCaps->ulRateFlags & OSS32_CAPS_PCM_RATE_CONTINUOUS) 1091 {//supports all sample rates from min to max 1092 if (ulSampleRate < pWaveCaps->ulMinRate) { 1093 ulSampleRate = pWaveCaps->ulMinRate; 1094 } 1095 else 1096 if(ulSampleRate > pWaveCaps->ulMaxRate) { 1097 ulSampleRate = pWaveCaps->ulMaxRate; 1098 } 1099 } 1100 else { 1101 ULONG ulNrSampleRates; 1102 1103 ulSampleRate = FindMatchingSampleRate(ulSampleRate, pWaveCaps->ulRateFlags, &ulNrSampleRates); 1104 } 1105 1106 // If we don't support the requested samplerate, then fill in the best fit flag. 1107 if (ulSampleRate != pCaps->ulSamplingRate) 1108 pCaps->ulFlags |= BESTFIT_PROVIDED; 1109 1110 // find out the closest sampling rate (may or may not be the same ) 1111 // from one of the following: 11025Hz, 22050Hz, 44100Hz and 8000Hz 1112 // _usfind_matching_sample_rate will update pCaps->ulSamplingRate if there 1113 // is not an exact match. 1114 usSampleRateIndex = _usfind_matching_sample_rate(&pCaps->ulSamplingRate); 1115 1116 //query flags for this wave data format 1117 pCaps->ulFlags |= QueryDataFlags(pCaps->ulOperation, pCaps->ulDataType, pCaps->ulBitsPerSample); 1118 1119 // Determine the ulDataSubType and update any format specific flags 1120 // Note: All data types have more than one value. 1121 switch ( pCaps->ulDataType ) 1122 { 1123 case DATATYPE_NULL: //Warp 3 buggy data type 1124 case DATATYPE_WAVEFORM: 1125 case PCM: 1126 // supported bits per sample are 8 (for unsigned PCM, u-law or A-law ) 1127 // and 16 (for 2's complement PCM) 1128 switch(pCaps->ulBitsPerSample) { 1129 case 8: 1130 case 16: 1131 //NOTE: We always support 8 & 16 bits playback & recording; if the card 1132 // can't handle one of these formats, then we'll convert the 1133 // wave data ourselves (same for mono/stereo). 1134 break; 1135 case 24: 1136 if(!(pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_24BPS)) 1137 { 1138 dprintf(("DevCaps1 not 24BPS")); 1139 pCaps->ulSupport = UNSUPPORTED_BPS; 1140 return; 1141 } 1142 break; 1143 case 32: 1144 if(!(pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_32BPS)) 1145 { 1146 pCaps->ulSupport = UNSUPPORTED_BPS; 1147 dprintf(("DevCaps1 not 32BPS")); 1148 return; 1149 } 1150 break; 1151 default: 1152 dprintf(("DevCaps1 not BPS %d",(USHORT)pCaps->ulBitsPerSample)); 1153 pCaps->ulSupport = UNSUPPORTED_BPS; 1154 return; 1155 } 1156 1157 // determine subtype for PCM: 1158 pCaps->ulDataSubType = aaulWave[usSampleRateIndex] 1159 [(pCaps->ulBitsPerSample-8)/8] 1160 [pCaps->ulChannels-1]; 1161 break; 1162 1163 case DATATYPE_ALAW: 1164 case DATATYPE_RIFF_ALAW: 1165 case A_LAW: 1166 if(!(pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_ALAW)) 1167 { 1168 dprintf(("DevCaps1 not ALAW")); 1169 pCaps->ulSupport = UNSUPPORTED_DATATYPE; 1170 return; 1171 } 1172 // supported bits per sample are 8 (for unsigned PCM, u-law or A-law ) 1173 if (pCaps->ulBitsPerSample != 8) 1174 { 1175 dprintf(("DevCaps1 not ALAW BPS8")); 1176 pCaps->ulSupport = UNSUPPORTED_BPS; 1177 return; 1178 } 1179 // determine subtype for A_LAW 1180 pCaps->ulDataSubType = aaulAlaw[usSampleRateIndex][pCaps->ulChannels-1]; 1181 break; 1182 1183 case DATATYPE_MULAW: 1184 case DATATYPE_RIFF_MULAW: 1185 case MU_LAW: 1186 if(!(pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_MULAW)) 1187 { 1188 dprintf(("DevCaps1 not MULAW")); 1189 pCaps->ulSupport = UNSUPPORTED_DATATYPE; 1190 return; 1191 } 1192 // supported bits per sample are 8 (for unsigned PCM, u-law or A-law ) 1193 if (pCaps->ulBitsPerSample != 8) 1194 { 1195 dprintf(("DevCaps1 not MULAW BPS8")); 1196 pCaps->ulSupport = UNSUPPORTED_BPS; 1197 return; 1198 } 1199 // determine subtype for MU_LAW 1200 pCaps->ulDataSubType = aaulMulaw[usSampleRateIndex][pCaps->ulChannels-1]; 1201 break; 1202 1203 case DATATYPE_ADPCM_AVC: 1204 case DATATYPE_CT_ADPCM: 1205 if(!(pWaveCaps->ulDataFormats & OSS32_CAPS_PCM_FORMAT_ADPCM)) 1206 { 1207 dprintf(("DevCaps1 not ADPCM")); 1208 pCaps->ulSupport = UNSUPPORTED_DATATYPE; 1209 return; 1210 } 1211 // supported bits per sample are 4 1212 if (pCaps->ulBitsPerSample != 4) 1213 { 1214 dprintf(("DevCaps1 not ADPCM BPS4")); 1215 pCaps->ulSupport = UNSUPPORTED_BPS; 1216 return; 1217 } 1218 // determine subtype for ADPCM 1219 pCaps->ulDataSubType = aaulMulaw[usSampleRateIndex][pCaps->ulChannels-1]; 1220 break; 1221 1222 default: 1223 dprintf(("DevCaps1 not dattype")); 1224 pCaps->ulSupport = UNSUPPORTED_DATATYPE; 1225 return; 1226 } // end switch 1227 1228 pCaps->ulFlags |= FIXED | // Fixed length data 1229 LEFT_ALIGNED | // Left align bits on byte bndry 1230 INPUT | // Input select is supported 1231 OUTPUT | // Output select is supported 1232 MONITOR | // Monitor is supported 1233 VOLUME; // Volume control is supported 1234 1235 // Full Duplex Enabling Stuff here !! 1236 // The number of resource units is described in the MMPM2.INI 1237 // This can be thought of the number of active streams the 1238 // driver can manage at one time. We list this number as 2. 1239 // we tell MMPM here how many of these units THIS stream will consume. 1240 // The answer is so simple it's brilliant, (Thanks to Joe Nord at Crystal 1241 // Semi) If we are enabled to do full-duplex this stream will consume 1 1242 // unit, If we are not enabled to do full-duplex this stream will consume 2 1243 // (or all the available units) 1244 // Along with the resource units, we defined 2 resources classes, 1245 // one for playback and one for capture. We tell MMPM (in the MMPM2.INI) 1246 // that we can handle doing 1 playback and 1 capture stream or 1 capture and 1247 // one playback stream at the same time. (Valid Resource combos in the 1248 // MMPM2.INI) check if we are a playback or capture and set the correct 1249 // resource class (Playback = 1, Capture = 2) 1250 1251 if(pCaps->ulOperation == OPERATION_PLAY) 1252 { 1253 if(pWaveCaps->nrStreams) { 1254 pCaps->ulResourceUnits = OSS32_MAX_WAVE_PLAYBACK_STREAMS/pWaveCaps->nrStreams; 1255 } 1256 else { 1257 DebugInt3(); //should never happen! 1258 pCaps->ulResourceUnits = OSS32_MAX_WAVE_PLAYBACK_STREAMS; 1259 } 1260 dprintf(("RU used by playback stream: %d", (int)pCaps->ulResourceUnits)); 1261 } 1262 else { 1263 if(pWaveCaps->nrStreams < OSS32_MAX_WAVE_CAPTURE_STREAMS) { 1264 DebugInt3(); 1265 } 1266 pCaps->ulResourceUnits = 1; 1267 } 1268 1269 if ( pCaps->ulOperation == OPERATION_PLAY) 1270 pCaps->ulResourceClass = 1; 1271 else 1272 pCaps->ulResourceClass = 2; 1273 pCaps->fCanRecord = 1; // Yes Virgina we can record 1274 pCaps->ulBlockAlign = 1; // Block alignment for this mode 1275 1276 //return success 1277 pCaps->ulSupport = SUPPORT_SUCCESS; 1278 dprintf(("WAVEAUDIO::DevCaps %ld %ld %ld ", pCaps->ulBitsPerSample, pCaps->ulSamplingRate, pCaps->ulChannels)); 1279 dprintf(("Op %ld ResourceClass %ld ResourceUnits %ld", pCaps->ulOperation, pCaps->ulResourceClass, pCaps->ulResourceUnits)); 1280 dprintf(("Data type %ld, data subtype %ld", pCaps->ulDataType, pCaps->ulDataSubType)); 1281 #ifdef DEBUG 1282 dprintf(("Flags:")); 1283 1284 for(int i=0;i<32;i++) { 1285 if(pCaps->ulFlags & (1UL << (ULONG)i)) { 1286 dprintf(("%s", szCapsFlags[i])); 1287 } 1288 } 1276 dprintf(("Flags:")); 1277 1278 for(int i=0;i<32;i++) { 1279 if(pCaps->ulFlags & (1UL << (ULONG)i)) { 1280 dprintf(("%s", szCapsFlags[i])); 1281 } 1282 } 1289 1283 #endif 1290 1284 } … … 1297 1291 void WAVEAUDIO::DevCaps(LPOSS32_DEVCAPS lpCaps) 1298 1292 { 1299 #ifdef DEBUG 1300 dprintf(("WAVEAUDIO::DevCaps")); 1301 #endif 1302 ddmemmov(lpCaps, &devCaps[current_device], sizeof(OSS32_DEVCAPS)); 1293 //dprintf(("WAVEAUDIO::DevCaps")); 1294 ddmemmov(lpCaps, &devCaps[current_device], sizeof(OSS32_DEVCAPS)); 1303 1295 } 1304 1296 … … 1313 1305 #pragma on (unreferenced) 1314 1306 { 1315 ULONG ulBytesPerIRQ; 1316 1317 #ifdef DEBUG 1318 //dprintf(("WAVEAUDIO::ConfigDev")); 1319 #endif 1320 //Reset sample rate conversion position 1321 pConfigInfo->ulSRatePosition = 0; 1322 1323 // Set the clock select bits (_ucClockData) 1324 1325 // Set up _ucFormatData and write usSilence for the WAVESTREAM 1326 switch (pConfigInfo->ulDataType) { 1327 case DATATYPE_NULL: //Warp 3 buggy data type 1328 case DATATYPE_WAVEFORM: 1329 case PCM: 1330 if (pConfigInfo->ulBitsPerSample == 16) { 1331 pConfigInfo->usSilence = 0x0000; 1332 } 1333 else { 1334 pConfigInfo->usSilence = 0x8080; 1335 } 1336 break; 1337 1338 case DATATYPE_ALAW: 1339 case DATATYPE_RIFF_ALAW: 1340 case A_LAW: 1341 pConfigInfo->usSilence = 0x5555; 1342 break; 1343 1344 case DATATYPE_MULAW: 1345 case DATATYPE_RIFF_MULAW: 1346 case MU_LAW: 1347 pConfigInfo->usSilence = 0x7F7F; 1348 break; 1349 } /* endswitch */ 1350 1351 // Calculate the PCMConsumeRate 1352 // The consume rate is the number of bytes consumed by this data format 1353 // per second. It calculated by taking the following equation: 1354 // sampling rate * (BitsPerSample/8) * NumChannels 1355 // This info is returned to the WAVESTREAM and used to calculate stream time 1356 1357 pConfigInfo->ulSampleSize = (pConfigInfo->ulBitsPerSample*pConfigInfo->ulNumChannels)/8; 1358 pConfigInfo->ulPCMConsumeRate = pConfigInfo->ulSampleRate * pConfigInfo->ulSampleSize; 1359 1360 // Calculate the BytesPerIRQ 1361 // The BytesPerIRQ is the number of bytes consumed by this data format 1362 // for every interrupt generated by the codec. 1363 // This information is returned to the WAVESTREAM which uses it in 1364 // buffer management decisions.... 1365 // basic formula is (sampling rate * ((BitsPerSample * NumChannels) /8) / Number of Interrupts per Second 1366 // or pConfigInfo->ulPCMConsumeRate / Number of Interrupts Per Second 1367 // rjj Fix for Bug #18 28082008 1368 1369 //ulBytesPerIRQ = pConfigInfo->ulPCMConsumeRate >> 5; // 32 interrupts per second 1370 ulBytesPerIRQ = pConfigInfo->ulPCMConsumeRate >> 6; // 64 interrupts per second 1371 // we can tweak this as needed but generally this should do rjj 1372 // make sure it's an even multiple of 64 1373 ulBytesPerIRQ += 0x00000040; 1374 ulBytesPerIRQ &= 0xFFFFFFC0; 1375 1376 if (ulBytesPerIRQ > 0x800) { 1377 ulBytesPerIRQ = 0x800; 1378 } 1379 pConfigInfo->ulBytesPerIRQ = ulBytesPerIRQ; 1380 dprintf4(("WAVEAUDIO::ConfigDev BytesPerIRQ:%ld",ulBytesPerIRQ)); 1381 1382 1383 return TRUE; 1307 ULONG ulBytesPerIRQ; 1308 1309 //dprintf(("WAVEAUDIO::ConfigDev")); 1310 //Reset sample rate conversion position 1311 pConfigInfo->ulSRatePosition = 0; 1312 1313 // Set the clock select bits (_ucClockData) 1314 1315 // Set up _ucFormatData and write usSilence for the WAVESTREAM 1316 switch (pConfigInfo->ulDataType) { 1317 case DATATYPE_NULL: //Warp 3 buggy data type 1318 case DATATYPE_WAVEFORM: 1319 case PCM: 1320 if (pConfigInfo->ulBitsPerSample == 16) { 1321 pConfigInfo->usSilence = 0x0000; 1322 } 1323 else { 1324 pConfigInfo->usSilence = 0x8080; 1325 } 1326 break; 1327 1328 case DATATYPE_ALAW: 1329 case DATATYPE_RIFF_ALAW: 1330 case A_LAW: 1331 pConfigInfo->usSilence = 0x5555; 1332 break; 1333 1334 case DATATYPE_MULAW: 1335 case DATATYPE_RIFF_MULAW: 1336 case MU_LAW: 1337 pConfigInfo->usSilence = 0x7F7F; 1338 break; 1339 } /* endswitch */ 1340 1341 // Calculate the PCMConsumeRate 1342 // The consume rate is the number of bytes consumed by this data format 1343 // per second. It calculated by taking the following equation: 1344 // sampling rate * (BitsPerSample/8) * NumChannels 1345 // This info is returned to the WAVESTREAM and used to calculate stream time 1346 1347 pConfigInfo->ulSampleSize = (pConfigInfo->ulBitsPerSample*pConfigInfo->ulNumChannels)/8; 1348 pConfigInfo->ulPCMConsumeRate = pConfigInfo->ulSampleRate * pConfigInfo->ulSampleSize; 1349 1350 // Calculate the BytesPerIRQ 1351 // The BytesPerIRQ is the number of bytes consumed by this data format 1352 // for every interrupt generated by the codec. 1353 // This information is returned to the WAVESTREAM which uses it in 1354 // buffer management decisions.... 1355 // basic formula is (sampling rate * ((BitsPerSample * NumChannels) /8) / Number of Interrupts per Second 1356 // or pConfigInfo->ulPCMConsumeRate / Number of Interrupts Per Second 1357 // rjj Fix for Bug #18 28082008 1358 1359 //ulBytesPerIRQ = pConfigInfo->ulPCMConsumeRate >> 5; // 32 interrupts per second 1360 ulBytesPerIRQ = pConfigInfo->ulPCMConsumeRate >> 6; // 64 interrupts per second 1361 // we can tweak this as needed but generally this should do rjj 1362 // make sure it's an even multiple of 64 1363 ulBytesPerIRQ += 0x00000040; 1364 ulBytesPerIRQ &= 0xFFFFFFC0; 1365 1366 if (ulBytesPerIRQ > 0x800) { 1367 ulBytesPerIRQ = 0x800; 1368 } 1369 pConfigInfo->ulBytesPerIRQ = ulBytesPerIRQ; 1370 dprintf4(("WAVEAUDIO::ConfigDev BytesPerIRQ:%ld",ulBytesPerIRQ)); 1371 1372 1373 return TRUE; 1384 1374 } 1385 1375 /**@internal Pause 1386 * @param 1387 * @return 1376 * @param None 1377 * @return int 1 1388 1378 * @notes 1389 1379 * stub function pause is implemented as a stop by the stream … … 1396 1386 } 1397 1387 /**@internal Resume 1398 * @param 1399 * @return 1388 * @param None 1389 * @return int 1 1400 1390 * @notes 1401 1391 * stub function resume is implemented as a start by the stream … … 1405 1395 #pragma on (unreferenced) 1406 1396 { 1407 1397 return 1; 1408 1398 } 1409 1399 /******************************************************************************/ 1410 /* WAVEAUDIO::Start(void) 1411 /* 1400 /* WAVEAUDIO::Start(void) */ 1401 /* */ 1412 1402 /******************************************************************************/ 1413 1403 int WAVEAUDIO::Start(OSSSTREAMID StreamId) 1414 1404 { 1415 #ifdef DEBUG 1416 // dprintf(("WAVEAUDIO::Start")); 1417 #endif 1418 1419 return OSS16_WaveStart(StreamId) == OSSERR_SUCCESS; 1405 //dprintf(("WAVEAUDIO::Start")); 1406 1407 return OSS16_WaveStart(StreamId) == OSSERR_SUCCESS; 1420 1408 } 1421 1409 1422 1410 /******************************************************************************/ 1423 /* WAVEAUDIO::Stop(void) 1424 /* 1411 /* WAVEAUDIO::Stop(void) */ 1412 /* */ 1425 1413 /******************************************************************************/ 1426 1414 int WAVEAUDIO::Stop(OSSSTREAMID StreamId) 1427 1415 { 1428 #ifdef DEBUG 1429 // dprintf(("WAVEAUDIO::Stop")); 1430 #endif 1431 1432 if(OSS16_WaveStop(StreamId) != OSSERR_SUCCESS) 1433 { 1434 DebugInt3(); 1435 return FALSE; 1436 } 1437 //Reset cleans up waveout instance 1438 if(OSS16_WaveReset(StreamId) != OSSERR_SUCCESS) 1439 { 1440 DebugInt3(); 1441 return FALSE; 1442 } 1443 return TRUE; 1416 //dprintf(("WAVEAUDIO::Stop")); 1417 1418 if(OSS16_WaveStop(StreamId) != OSSERR_SUCCESS) 1419 { 1420 DebugInt3(); 1421 return FALSE; 1422 } 1423 //Reset cleans up waveout instance 1424 if(OSS16_WaveReset(StreamId) != OSSERR_SUCCESS) 1425 { 1426 DebugInt3(); 1427 return FALSE; 1428 } 1429 return TRUE; 1444 1430 } 1445 1431 /******************************************************************************/ 1446 /* WAVEAUDIO::Prepare(void) 1447 /* 1432 /* WAVEAUDIO::Prepare(void) */ 1433 /* */ 1448 1434 /******************************************************************************/ 1449 1435 int WAVEAUDIO::Prepare(OSSSTREAMID StreamId) 1450 1436 { 1451 #ifdef DEBUG 1452 // dprintf(("WAVEAUDIO::Prepare")); 1453 #endif 1454 1455 if(OSS16_WavePrepare(StreamId) != OSSERR_SUCCESS) { 1456 DebugInt3(); 1457 return FALSE; 1458 } 1459 return TRUE; 1437 //dprintf(("WAVEAUDIO::Prepare")); 1438 1439 if(OSS16_WavePrepare(StreamId) != OSSERR_SUCCESS) { 1440 DebugInt3(); 1441 return FALSE; 1442 } 1443 return TRUE; 1460 1444 } 1461 1445 //****************************************************************************** … … 1463 1447 ULONG WAVEAUDIO::ConvertPosition(ULONG length, PWAVECONFIGINFO pConfigInfo) 1464 1448 { 1465 1466 1467 1468 1469 1470 1471 1472 1449 ULONG newlen; 1450 1451 newlen = CONVERT_LENGTH(length, pConfigInfo->ulConversionFactor); 1452 1453 if(newlen && pConfigInfo->fSampleRateConversion) { 1454 newlen = SRATE_CONVERT_POSITION(newlen, pConfigInfo->ulSampleRate, pConfigInfo->ulHwSampleRate); 1455 } 1456 return newlen; 1473 1457 } 1474 1458 //****************************************************************************** … … 1476 1460 ULONG WAVEAUDIO::ConvertPositionInvert(ULONG length, PWAVECONFIGINFO pConfigInfo) 1477 1461 { 1478 1479 1480 1481 1482 1483 1484 1485 1462 ULONG newlen; 1463 1464 newlen = CONVERT_LENGTH(length, CONVERSION_INVERT(pConfigInfo->ulConversionFactor)); 1465 1466 if(newlen && pConfigInfo->fSampleRateConversion) { 1467 newlen = SRATE_CONVERT_POSITION(newlen, pConfigInfo->ulSampleRate, pConfigInfo->ulHwSampleRate); 1468 } 1469 return newlen; 1486 1470 } 1487 1471 //****************************************************************************** … … 1490 1474 ULONG WAVEAUDIO::ConvertLength(ULONG length, PWAVECONFIGINFO pConfigInfo) 1491 1475 { 1492 1493 1494 1476 ULONG newlen; 1477 1478 newlen = CONVERT_LENGTH(length, pConfigInfo->ulConversionFactor); 1495 1479 1496 1480 //PS+++ 1497 1481 #ifdef WhatIsIt 1498 1499 1500 DebugInt3();//this shouldn't happen!!1501 1502 1482 if(newlen >= 4UL*1024UL*1024UL) { 1483 //oh, oh 1484 DebugInt3(); //this shouldn't happen!! 1485 return newlen; 1486 } 1503 1487 #endif 1504 1505 1506 1507 1508 1509 } 1510 1511 #define CONVERT_POSITION_INVERT(pos, ulFactor) 1512 #define CONVERT_LENGTH_INVERT(pos, ulFactor) 1488 if(newlen && pConfigInfo->fSampleRateConversion) { 1489 newlen = SRATE_CONVERT_LENGTH(newlen, pConfigInfo->ulSRatePosition, 1490 pConfigInfo->ulSRateIncrement); 1491 } 1492 return newlen; 1493 } 1494 1495 #define CONVERT_POSITION_INVERT(pos, ulFactor) ( ( pos << CONVERSION_RSHIFT(ulFactor)) >> CONVERSION_LSHIFT(ulFactor) ) 1496 #define CONVERT_LENGTH_INVERT(pos, ulFactor) CONVERT_POSITION_INVERT(pos, ulFactor) 1513 1497 //****************************************************************************** 1514 1498 //NOTE: Can only be used for small numbers (up to about 4mb)!! (overflow) … … 1516 1500 ULONG WAVEAUDIO::ConvertLengthInvert(ULONG length, PWAVECONFIGINFO pConfigInfo) 1517 1501 { 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 // 1545 1546 // 1547 1548 } 1549 //****************************************************************************** 1550 //****************************************************************************** 1551 1502 ULONG newlen,tmp,len; 1503 1504 if (!length) return 0; 1505 1506 len = length; 1507 1508 if (pConfigInfo->fSampleRateConversion) 1509 { 1510 tmp = SRATE_CONVERT_LENGTH_INVERT(len, pConfigInfo->ulSRatePosition, pConfigInfo->ulSRateIncrement); 1511 if (tmp && (len != SRATE_CONVERT_LENGTH (tmp, pConfigInfo->ulSRatePosition, pConfigInfo->ulSRateIncrement))) 1512 tmp--; 1513 } 1514 else 1515 tmp = len; 1516 1517 if (!tmp) return 0; 1518 1519 if (pConfigInfo->usConversion != CONVERT_NONE) 1520 { 1521 newlen = CONVERT_LENGTH_INVERT (tmp, pConfigInfo->ulConversionFactor); 1522 if (newlen && (tmp != CONVERT_LENGTH (newlen, pConfigInfo->ulConversionFactor)) ) 1523 newlen--; 1524 } 1525 else 1526 newlen = tmp; 1527 1528 // if ( newlen > length ) dprintf(("!!!!Back len %ld tmp %ld new %ld",length,tmp,newlen )); 1529 1530 // dprintf(("Overflow len %ld in:%ld inc:%ld pos:%lx",length, len, pConfigInfo->ulSRateIncrement, pConfigInfo->ulSRatePosition)); 1531 return newlen; 1532 } 1533 //****************************************************************************** 1534 //****************************************************************************** 1535 -
OCO/trunk/drv16/waveplay.cpp
r507 r526 2 2 /* SCCSID = %W% %E% */ 3 3 /**************************************************************************** 4 * 5 * Copyright (c) IBM Corporation 1994 - 1997. 6 * 7 * The following IBM OS/2 source code is provided to you solely for the 4 * * 5 * Copyright (c) IBM Corporation 1994 - 1997. * 6 * * 7 * The following IBM OS/2 source code is provided to you solely for the * 8 8 * the purpose of assisting you in your development of OS/2 device drivers. * 9 * You may use this code in accordance with the IBM License Agreement 10 * provided in the IBM Device Driver Source Kit for OS/2. 11 * 9 * You may use this code in accordance with the IBM License Agreement * 10 * provided in the IBM Device Driver Source Kit for OS/2. * 11 * * 12 12 ****************************************************************************/ 13 13 /**@internal %W% … … 15 15 * @version %I% 16 16 * @context Unless otherwise noted, all interfaces are Ring-0, 16-bit, 17 * 17 * <stack context>. 18 18 * @history 19 19 * … … 44 44 extern "C" 45 45 { 46 47 46 ULONG open_strategy = 0UL; 47 ULONG LastSpace=0; 48 48 //int force_close(void); 49 49 } … … 59 59 BOOL WAVEPLAY::Open(ULONG ulDevice, ULONG ulStreamType, ULONG ulSysFileNum, OSSSTREAMID FAR *pStreamId) 60 60 { 61 61 ULONG ret; 62 62 //dprintf(("WAVEPLAY::Open %lx",StreamId)); 63 64 63 if (fAPMSuspend) 64 { 65 65 //dprintf(("WAVEPLAY::Open. Suspend state")); 66 67 68 69 70 71 72 73 dprintf(("OSS16_WaveOpen failed!!"));74 66 apm_resume(); 67 } 68 69 if(StreamId == 0UL) 70 { 71 if((ret = OSS16_WaveOpen(ulDevice, ulStreamType, ulSysFileNum, pStreamId)) != OSSERR_SUCCESS) 72 { 73 rprintf(("OSS16_WaveOpen failed!!")); 74 DebugInt3(); 75 75 //StreamId = 0; 76 76 //waveOpened = 0; 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 77 return FALSE; 78 } else 79 waveOpened++; 80 //if the device only supports one active stream, then it is shared by 81 //all wave stream instances. MMPM/2 takes care of proper sharing for us 82 //if the device supports multiple active streams, then we always open 83 //a new ALSA stream 84 //if(devCaps[ulDevice].waveOutCaps.nrStreams == 1) { 85 StreamId = *pStreamId; 86 //} 87 ulDeviceSave = ulDevice; 88 ulStreamTypeSave = ulStreamType; 89 ulSysFileNumSave = ulSysFileNum; 90 } 91 else { 92 *pStreamId = StreamId; 93 } 94 return TRUE; 95 95 } 96 96 … … 101 101 //dprintf(("WAVEPLAY::Close stream: %lx, %lx, os: %lx", StreamId, waveOpened,open_strategy)); 102 102 #if 0 // fixme to be gone? 103 104 105 106 107 108 109 110 103 //if ((open_strategy & 1)) 104 //if (waveOpened == 1) 105 if (force_closed) 106 { 107 waveOpened--; 108 StreamId = 0UL; 109 open_strategy = 0UL; 110 force_closed = 0; 111 111 //dprintf(("WAVEPLAY::Closed stream: %lx, %lx, os: %lx", StreamId, waveOpened,open_strategy)); 112 113 114 112 return TRUE; 113 } 114 else 115 115 #endif // fixme to be gone? 116 117 /* Setting DISABLE_STREAM_REUSE will close the open stream here. 116 { 117 /* Setting DISABLE_STREAM_REUSE will close the open stream here. */ 118 118 /* If left unset, the idea is the open stream will be reused instead. */ 119 /* FIXME: Does it make sense that a Close function does not close 120 /* anything? 119 /* FIXME: Does it make sense that a Close function does not close */ 120 /* anything? */ 121 121 #ifdef DISABLE_STREAM_REUSE 122 123 124 125 126 127 128 122 if(devCaps[ulDeviceNr].waveOutCaps.nrStreams > 1) 123 { 124 if (OSS16_WaveClose(StreamIdl) == OSSERR_SUCCESS) 125 { 126 waveOpened--; 127 StreamId = 0UL; 128 open_strategy = 0UL; 129 129 dprintf(("OSS16_WAVECLOSE: Success")); 130 131 132 133 134 } 135 136 130 return TRUE; 131 } else { 132 dprintf(("OSS16_WAVECLOSE: Error")); 133 return FALSE; 134 } 135 } 136 else 137 137 #else /* !DISABLE_STREAM_REUSE */ 138 138 if (StreamIdl == NULL) return FALSE; 139 139 #endif /* DISABLE_STREAM_REUSE */ 140 141 140 return TRUE; 141 } 142 142 } 143 143 //****************************************************************************** … … 145 145 BOOL WAVEPLAY::ConfigDev(OSSSTREAMID StreamId, PWAVECONFIGINFO pConfigInfo, ULONG ulFirstBufSize) 146 146 { 147 148 ULONGfragsize;149 intsamplesize;150 ULONGulPCMConsumeRate;151 USHORTrc;152 153 154 155 147 OSS32_HWPARAMS hwparam; 148 ULONG fragsize; 149 int samplesize; 150 ULONG ulPCMConsumeRate; 151 USHORT rc; 152 153 154 if (fAPMSuspend) 155 { 156 156 //dprintf(("WAVEPLAY::ConfigDev. Suspend state")); 157 158 159 160 161 162 163 164 165 dprintf(("WAVEPLAY::ConfigDev. Error reopening stream"));166 167 168 169 170 171 172 173 174 175 176 177 178 179 dprintf(("Arg - shouldn't happen"));180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 hwparam.ulPeriodSize= fragsize;221 222 223 224 hwparam.ulSampleRate= pConfigInfo->ulHwSampleRate;225 226 hwparam.ulNumChannels= pConfigInfo->ulHwNumChannels;227 hwparam.ulDataType= QueryOSSDataFormat(OPERATION_PLAY, pConfigInfo->ulDataType, pConfigInfo->ulHwBitsPerSample);228 229 230 231 232 233 234 235 236 // 237 // 238 // 239 240 241 157 apm_resume(); 158 } 159 160 if (StreamId == NULL) 161 { 162 WAVEPLAY::Open(ulDeviceSave, ulStreamTypeSave, ulSysFileNumSave, &StreamId); 163 if (StreamId == NULL) 164 { 165 rprintf(("WAVEPLAY::ConfigDev. Error reopening stream")); 166 return FALSE; 167 } 168 } 169 dprintf4(("WAVEPLAY::ConfigDev SampleRate %ld", pConfigInfo->ulHwSampleRate)); 170 dprintf4(("WAVEPLAY::ConfigDev ulFirstBufSize=%lx ulFragsize=%lx", ulFirstBufSize, pConfigInfo->ulFragsize)); 171 172 if(ulFirstBufSize == 0) 173 { 174 ulFirstBufSize = pConfigInfo->ulFragsize; //no conversion required (see below) 175 if (ulFirstBufSize == 0) 176 { 177 DebugInt3(); 178 ulFirstBufSize = 8192; //should never happen! 179 rprintf(("Arg - shouldn't happen")); 180 } 181 } 182 else 183 { 184 //convert size of first buffer 185 ulFirstBufSize = ConvertLength(ulFirstBufSize, pConfigInfo); 186 dprintf4(("ulFirstBufSize %lx", ulFirstBufSize)); 187 } 188 //Must call this method (i.e. resets sample rate conversion position) 189 WAVEAUDIO::ConfigDev(StreamId, pConfigInfo, ulFirstBufSize); 190 191 //get real sample format used to program the audio hardware (taking conversion into account) 192 QuerySampleFormat(OPERATION_PLAY, pConfigInfo); 193 194 //convert consume rate 195 ulPCMConsumeRate = ConvertLength(pConfigInfo->ulPCMConsumeRate, pConfigInfo); 196 dprintf4(("cons rate %lx buf size %lx init rate %ld", ulPCMConsumeRate, ulFirstBufSize, pConfigInfo->ulHwSampleRate)); 197 198 fragsize = ulPCMConsumeRate/64; //start with 64 irqs/sec 2756 199 200 //if the buffer is smaller than our predefined fragmentsize (*2), then correct it 201 //I assume here that buffers sizes don't radically change (except the last one) 202 //while playing a stream. If they do get a lot smaller, then we'll run into problems. 203 //There's nothing we can do about it as the fragment size can't be changed 204 //while the stream is playing. 205 ULONG minimumsize = ulFirstBufSize/2; //650 206 if(minimumsize && minimumsize < fragsize) 207 { 208 while(minimumsize < fragsize) fragsize = fragsize / 2; // 209 210 if(fragsize < ulPCMConsumeRate/256) 211 {//lower limit; don't accept extremely small buffers 212 fragsize = ulPCMConsumeRate/256; 213 } 214 } 215 samplesize = (int)pConfigInfo->ulHwSampleSize; 216 217 //round to nearest 64 byte boundary 218 fragsize = (fragsize + 63) & ~(63); 219 220 hwparam.ulPeriodSize = fragsize; 221 pConfigInfo->ulFragsize = fragsize; 222 223 dprintf4(("fragsize %lx", fragsize)); 224 hwparam.ulSampleRate = pConfigInfo->ulHwSampleRate; 225 hwparam.ulBitsPerSample = pConfigInfo->ulHwBitsPerSample; 226 hwparam.ulNumChannels = pConfigInfo->ulHwNumChannels; 227 hwparam.ulDataType = QueryOSSDataFormat(OPERATION_PLAY, pConfigInfo->ulDataType, pConfigInfo->ulHwBitsPerSample); 228 rc = (USHORT)OSS16_WaveSetFormat(StreamId, &hwparam); 229 dprintf4(("WAVEPLAY:ConfigDev:OSS16_WaveSetFormat . rc = %d",rc)); 230 dprintf4(("samp rate=%ld bps=%ld channels=%ld type=%ld", hwparam.ulSampleRate, hwparam.ulBitsPerSample, hwparam.ulNumChannels, hwparam.ulDataType)); 231 232 if( rc != OSSERR_SUCCESS) { 233 dprintf(("WAVEPLAY:ConfigDev: rc %d",rc)); 234 DebugInt3(); 235 // vladest 236 // OSS16_WaveClose(StreamId); 237 // StreamId = 0; 238 // waveOpened = 0; 239 return FALSE; 240 } 241 return TRUE; 242 242 } 243 243 //****************************************************************************** … … 246 246 //****************************************************************************** 247 247 BOOL WAVEPLAY::Transfer(OSSSTREAMID StreamId, PWAVECONFIGINFO pConfigInfo, 248 249 250 { 251 252 253 254 255 248 LINEAR pUserBuffer, ULONG ulBytesToTransfer, 249 ULONG FAR *pulBytesTransferred) 250 { 251 *pulBytesTransferred = 0; 252 253 //dprintf(("WAVEPLAY::Transfer %ld",ulBytesToTransfer)); 254 255 if (fAPMSuspend) { 256 256 //dprintf(("WAVEPLAY::Transfer. Suspend state")); 257 258 259 260 261 262 257 apm_resume(); 258 } 259 260 if (!ulBytesToTransfer) { 261 return TRUE; 262 } 263 263 264 264 //if (!waveOpened) return TRUE; 265 265 266 267 268 269 270 dprintf(("Transfer.False. NoConv ulB %ld tr:%ld",ulBytesToTransfer,*pulBytesTransferred));271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 266 if(pConfigInfo->usConversion == CONVERT_NONE) 267 { 268 if (AddBuffer(StreamId, pConfigInfo, pUserBuffer, ulBytesToTransfer, pulBytesTransferred) == FALSE) 269 { 270 rprintf(("Transfer failed. NoConv ulB %ld tr:%ld",ulBytesToTransfer,*pulBytesTransferred)); 271 *pulBytesTransferred = 0; 272 return FALSE; 273 } 274 } 275 else 276 { 277 if(pConfigInfo->pfnConvert) 278 { 279 ULONG ulCvtBufferSize; 280 281 //bytes to convert is bounded by bytes to transfer & max conversion buffer size 282 ulCvtBufferSize = CONVERT_LENGTH(ulBytesToTransfer, pConfigInfo->ulConversionFactor); 283 ulCvtBufferSize = min(CONVERSION_BUFFER_SIZE, ulCvtBufferSize); 284 285 //convert back from conversion to 'real' 286 ulBytesToTransfer = CONVERT_LENGTH(ulCvtBufferSize, CONVERSION_INVERT(pConfigInfo->ulConversionFactor)); 287 288 if(ulBytesToTransfer & (pConfigInfo->ulSampleSize-1)) 289 { 290 dprintf(("Transfer New ulBr %ld" , ulBytesToTransfer)); 291 291 //DebugInt3(); 292 293 294 295 296 297 298 299 300 301 302 303 304 305 292 ulBytesToTransfer = ulBytesToTransfer & ~(pConfigInfo->ulSampleSize-1); 293 dprintf(("Transfer New ulBr %ld" , ulBytesToTransfer)); 294 } 295 pConfigInfo->pfnConvert(pUserBuffer, ulBytesToTransfer, pConfigInfo->pConversionBuffer); 296 if(AddBuffer(StreamId, pConfigInfo, pConfigInfo->pConversionBuffer, ulCvtBufferSize, pulBytesTransferred) == FALSE) 297 { 298 *pulBytesTransferred = 0; 299 return FALSE; 300 } 301 //convert back from conversion to 'real' 302 *pulBytesTransferred = CONVERT_LENGTH(*pulBytesTransferred, CONVERSION_INVERT(pConfigInfo->ulConversionFactor)); 303 if(*pulBytesTransferred & (pConfigInfo->ulSampleSize-1)) 304 { 305 dprintf(("Transfer New pulBr %ld" , pulBytesTransferred)); 306 306 //DebugInt3(); 307 308 309 310 311 dprintf(("Transfer Zero pConfigInfo->pfnConvert"));307 } 308 } 309 else 310 { 311 rprintf(("Transfer Zero pConfigInfo->pfnConvert")); 312 312 //DebugInt3(); 313 314 315 316 313 return FALSE; 314 } 315 } 316 return TRUE; 317 317 } 318 318 //****************************************************************************** … … 320 320 //****************************************************************************** 321 321 BOOL WAVEPLAY::AddBuffer(OSSSTREAMID StreamId, PWAVECONFIGINFO pConfigInfo, LINEAR pUserBuffer, 322 323 { 324 325 322 ULONG ulBytesToTransfer, ULONG FAR *pulBytesTransferred) 323 { 324 OSSRET rc; 325 ULONG Space; 326 326 //if (!waveOpened) return TRUE; 327 327 328 328 //PS Here is inrerrupt time.... 329 329 if (fAPMSuspend) { 330 330 //dprintf(("WAVEPLAY::AddBuffer. Suspend state")); 331 apm_resume(); 332 //return FALSE; 333 } 334 335 if (pConfigInfo->fSampleRateConversion) 336 { 337 ULONG ulCvtBufferSize, ulSampleCount, ulHwSampleCount; 338 LONG lSRatePosition; 339 340 //bytes to convert is bounded by bytes to transfer & max conversion buffer size 341 ulCvtBufferSize = SRATE_CONVERT_LENGTH(ulBytesToTransfer, pConfigInfo->ulSRatePosition, pConfigInfo->ulSRateIncrement); 342 ulCvtBufferSize = min(CONVERSION_BUFFER_SIZE, ulCvtBufferSize); 343 //round to sample boundary 344 ulCvtBufferSize &= ~(pConfigInfo->ulHwSampleSize - 1); 345 346 if(ulCvtBufferSize == 0) 347 { 348 *pulBytesTransferred = ulBytesToTransfer; 349 if(pConfigInfo->ulSRatePosition >= pConfigInfo->ulSRateIncrement) 350 { 351 pConfigInfo->ulSRatePosition -= pConfigInfo->ulSRateIncrement; 352 } 353 return TRUE; 354 } 355 pConfigInfo->pfnSRateConv(pUserBuffer, ulCvtBufferSize, pConfigInfo->pSRateConvBuffer, 356 pConfigInfo->ulSRatePosition, pConfigInfo->ulSRateIncrement); 357 OSS16_WaveGetSpace(StreamId, &Space); 358 if (ulCvtBufferSize > Space) 359 { 360 dprintf(("WPLAY::AddBuffer need %ld space:%ld", ulCvtBufferSize, Space)); 361 if (Space < pConfigInfo->ulBytesPerIRQ) 362 { 363 return TRUE; 364 } 365 366 if (ulCvtBufferSize > Space) 367 ulCvtBufferSize = Space & ~(pConfigInfo->ulHwSampleSize - 1); 368 } 369 if ((rc = OSS16_WaveAddBuffer(StreamId, pConfigInfo->pSRateConvBuffer, ulCvtBufferSize, pulBytesTransferred)) != OSSERR_SUCCESS 370 || *pulBytesTransferred == 0) 371 { 372 if(rc == OSSERR_BUFFER_FULL) 373 { 374 GetSpace(StreamId, pConfigInfo, &Space); 375 dprintf(("WPLAY::AddBuffer; %ld %x failed due to full buffer free space:%ld", ulCvtBufferSize, (USHORT)rc,Space)); 376 } 377 #ifdef DEBUG 378 else 379 dprintf(("WPLAY::AddBuffer; %ld rc=%x failed", ulCvtBufferSize, (USHORT)rc)); 380 #endif 381 *pulBytesTransferred = 0; 382 return FALSE; 383 } 384 ulHwSampleCount = *pulBytesTransferred/pConfigInfo->ulHwSampleSize; 385 386 //convert back from conversion to 'real' 387 ulSampleCount = SRATE_CONVERT_LENGTH_INVERT(ulHwSampleCount, 388 pConfigInfo->ulSRatePosition, 389 pConfigInfo->ulSRateIncrement); 390 391 //update sample rate position 392 393 lSRatePosition = (LONG)(pConfigInfo->ulSRatePosition + ulHwSampleCount * pConfigInfo->ulSRateIncrement); 394 lSRatePosition = lSRatePosition - (LONG)ulSampleCount*(LONG)SRATE_SHIFT_VALUE; 395 396 // if the last sample is still needed for the next run, then adjust sample count and 397 // sample rate conversion position 398 if(lSRatePosition < 0) 399 { 400 dprintf4(("WAVEPLAY::AddBuffer; sratepos < 0")); 401 dprintf4(("ulHwSampleCount %lx pConfigInfo->ulSRateIncrement %lx ulSampleCount %lx", ulHwSampleCount, pConfigInfo->ulSRateIncrement, ulSampleCount)); 402 pConfigInfo->ulSRatePosition = 0; 403 } 404 else 405 { 406 pConfigInfo->ulSRatePosition = (ULONG)lSRatePosition; 407 } 408 *pulBytesTransferred = ulSampleCount*pConfigInfo->ulHwSampleSize; 409 } 410 else 411 { 412 if( (rc=OSS16_WaveAddBuffer(StreamId, pUserBuffer, ulBytesToTransfer, pulBytesTransferred)) != OSSERR_SUCCESS) 413 { 414 *pulBytesTransferred = 0; 415 dprintf(("WPLAY::AddBuffer; OSS16_WaveAddBuffer failed due to an error rc=%x",(USHORT)rc)); 416 dprintf(("StreamID:%x PUB:%lx BtTr:%ld",(USHORT)StreamId, pUserBuffer, ulBytesToTransfer)); 417 return FALSE; 418 } 419 } 420 return TRUE; 331 apm_resume(); 332 //return FALSE; 333 } 334 335 if (pConfigInfo->fSampleRateConversion) 336 { 337 ULONG ulCvtBufferSize, ulSampleCount, ulHwSampleCount; 338 LONG lSRatePosition; 339 340 //bytes to convert is bounded by bytes to transfer & max conversion buffer size 341 ulCvtBufferSize = SRATE_CONVERT_LENGTH(ulBytesToTransfer, pConfigInfo->ulSRatePosition, pConfigInfo->ulSRateIncrement); 342 ulCvtBufferSize = min(CONVERSION_BUFFER_SIZE, ulCvtBufferSize); 343 //round to sample boundary 344 ulCvtBufferSize &= ~(pConfigInfo->ulHwSampleSize - 1); 345 346 if(ulCvtBufferSize == 0) 347 { 348 *pulBytesTransferred = ulBytesToTransfer; 349 if(pConfigInfo->ulSRatePosition >= pConfigInfo->ulSRateIncrement) 350 { 351 pConfigInfo->ulSRatePosition -= pConfigInfo->ulSRateIncrement; 352 } 353 return TRUE; 354 } 355 pConfigInfo->pfnSRateConv(pUserBuffer, ulCvtBufferSize, pConfigInfo->pSRateConvBuffer, 356 pConfigInfo->ulSRatePosition, pConfigInfo->ulSRateIncrement); 357 OSS16_WaveGetSpace(StreamId, &Space); 358 if (ulCvtBufferSize > Space) 359 { 360 dprintf(("WPLAY::AddBuffer need %ld space:%ld", ulCvtBufferSize, Space)); 361 if (Space < pConfigInfo->ulBytesPerIRQ) 362 { 363 return TRUE; 364 } 365 366 if (ulCvtBufferSize > Space) 367 ulCvtBufferSize = Space & ~(pConfigInfo->ulHwSampleSize - 1); 368 } 369 if ((rc = OSS16_WaveAddBuffer(StreamId, pConfigInfo->pSRateConvBuffer, ulCvtBufferSize, pulBytesTransferred)) != OSSERR_SUCCESS 370 || *pulBytesTransferred == 0) 371 { 372 if(rc == OSSERR_BUFFER_FULL) { 373 GetSpace(StreamId, pConfigInfo, &Space); 374 rprintf(("WPLAY::AddBuffer; %ld %x failed due to full buffer free space:%ld", ulCvtBufferSize, (USHORT)rc,Space)); 375 } else { 376 rprintf(("WPLAY::AddBuffer; %ld rc=%x failed", ulCvtBufferSize, (USHORT)rc)); 377 } 378 *pulBytesTransferred = 0; 379 return FALSE; 380 } 381 ulHwSampleCount = *pulBytesTransferred/pConfigInfo->ulHwSampleSize; 382 383 //convert back from conversion to 'real' 384 ulSampleCount = SRATE_CONVERT_LENGTH_INVERT(ulHwSampleCount, 385 pConfigInfo->ulSRatePosition, 386 pConfigInfo->ulSRateIncrement); 387 388 //update sample rate position 389 390 lSRatePosition = (LONG)(pConfigInfo->ulSRatePosition + ulHwSampleCount * pConfigInfo->ulSRateIncrement); 391 lSRatePosition = lSRatePosition - (LONG)ulSampleCount*(LONG)SRATE_SHIFT_VALUE; 392 393 // if the last sample is still needed for the next run, then adjust sample count and 394 // sample rate conversion position 395 if(lSRatePosition < 0) 396 { 397 dprintf4(("WAVEPLAY::AddBuffer; sratepos < 0")); 398 dprintf4(("ulHwSampleCount %lx pConfigInfo->ulSRateIncrement %lx ulSampleCount %lx", ulHwSampleCount, pConfigInfo->ulSRateIncrement, ulSampleCount)); 399 pConfigInfo->ulSRatePosition = 0; 400 } 401 else 402 { 403 pConfigInfo->ulSRatePosition = (ULONG)lSRatePosition; 404 } 405 *pulBytesTransferred = ulSampleCount*pConfigInfo->ulHwSampleSize; 406 } 407 else 408 { 409 if( (rc=OSS16_WaveAddBuffer(StreamId, pUserBuffer, ulBytesToTransfer, pulBytesTransferred)) != OSSERR_SUCCESS) 410 { 411 *pulBytesTransferred = 0; 412 rprintf(("WPLAY::AddBuffer; OSS16_WaveAddBuffer failed due to an error rc=%x",(USHORT)rc)); 413 dprintf(("StreamID:%x PUB:%lx BtTr:%ld",(USHORT)StreamId, pUserBuffer, ulBytesToTransfer)); 414 return FALSE; 415 } 416 } 417 return TRUE; 421 418 } 422 419 //****************************************************************************** … … 425 422 BOOL WAVEPLAY::GetPosition(OSSSTREAMID StreamId, PWAVECONFIGINFO pConfigInfo, ULONG FAR *pulStreamPosition) 426 423 { 427 428 429 //if (!waveOpened) return TRUE;430 431 432 433 dprintf(("WAVEPLAY::GetPosition: Failed"));434 435 436 437 *pulStreamPosition= ConvertPositionInvert(ulCurBytesProcessed, pConfigInfo);438 439 440 424 ULONG ulCurBytesProcessed; 425 426 //if (!waveOpened) return TRUE; 427 428 if(OSS16_WaveGetPos(StreamId, &ulCurBytesProcessed) != OSSERR_SUCCESS) { 429 *pulStreamPosition = 0; 430 rprintf(("WAVEPLAY::GetPosition: Failed")); 431 return FALSE; 432 } 433 434 *pulStreamPosition = ConvertPositionInvert(ulCurBytesProcessed, pConfigInfo); 435 //round to sample boundary 436 *pulStreamPosition &= ~(pConfigInfo->ulSampleSize - 1); 437 return TRUE; 441 438 } 442 439 //****************************************************************************** … … 445 442 BOOL WAVEPLAY::GetSpace(OSSSTREAMID StreamId, PWAVECONFIGINFO pConfigInfo, ULONG FAR *pulStreamSpace) 446 443 { 447 448 449 //if (!waveOpened) return TRUE;450 451 452 453 454 dprintf(("WAVEPLAY::GetSpace: Failed"));455 456 457 458 //dprintf(("GetSpace: len %ld",space));459 460 461 462 444 ULONG space,cvt; 445 446 //if (!waveOpened) return TRUE; 447 448 if(OSS16_WaveGetSpace(StreamId, &space) != OSSERR_SUCCESS) 449 { 450 *pulStreamSpace = 0; 451 rprintf(("WAVEPLAY::GetSpace: Failed")); 452 return FALSE; 453 } 454 455 //dprintf(("GetSpace: len %ld",space)); 456 cvt = ConvertLengthInvert(space, pConfigInfo); 457 //round to sample boundary 458 *pulStreamSpace =cvt & ( ~(pConfigInfo->ulSampleSize - 1)); 459 return TRUE; 463 460 } 464 461 //****************************************************************************** … … 467 464 BOOL WAVEPLAY::GetHwPtr(OSSSTREAMID StreamId, PWAVECONFIGINFO pConfigInfo, ULONG FAR *pulHwPtr) 468 465 { 469 470 471 472 473 474 dprintf(("WAVEPLAY::WaveGetHwPtr: Failed"));475 476 477 478 479 480 481 466 ULONG space,cvt; 467 468 if(OSS16_WaveGetHwPtr(StreamId, &space) != OSSERR_SUCCESS) 469 { 470 *pulHwPtr = 0; 471 rprintf(("WAVEPLAY::WaveGetHwPtr: Failed")); 472 return FALSE; 473 } 474 475 cvt = ConvertLengthInvert(space, pConfigInfo); 476 //round to sample boundary 477 *pulHwPtr = cvt & (~(pConfigInfo->ulSampleSize - 1)); 478 return TRUE; 482 479 } 483 480 //****************************************************************************** … … 486 483 BOOL WAVEPLAY::SetVolume(OSSSTREAMID StreamId, OSSSTREAMID mixerStreamId, ULONG ulVolume) 487 484 { 488 485 return MixerSetWaveVolume(mixerStreamId, StreamId, ulVolume); 489 486 } 490 487 //****************************************************************************** … … 494 491 #pragma on (unreferenced) 495 492 { 496 493 return MixerQueryVolume(mixerStreamId, OSS32_MIX_VOLUME_CAPTURE); 497 494 } 498 495 //****************************************************************************** … … 502 499 #pragma on (unreferenced) 503 500 { 504 505 501 DebugInt3(); 502 return FALSE; 506 503 } 507 504 … … 509 506 #pragma data_seg ("_initdata","endds"); 510 507 /******************************************************************************/ 511 /* WAVEPLAY::WAVEPLAY(USHORT PrimeDma, USHORT SecDma, USHORT Irq) 512 /* The constructor, basicly passes the resources info up the stream to the 513 /* "parent classes" and calles _vSetup which constructs all the resource 514 /* class objects we need to run. 515 /* 508 /* WAVEPLAY::WAVEPLAY(USHORT PrimeDma, USHORT SecDma, USHORT Irq) */ 509 /* The constructor, basicly passes the resources info up the stream to the */ 510 /* "parent classes" and calles _vSetup which constructs all the resource */ 511 /* class objects we need to run. */ 512 /* */ 516 513 /******************************************************************************/ 517 514 -
OCO/trunk/drv16/waverec.cpp
r483 r526 45 45 if(OSS16_WaveOpen(ulDevice, ulStreamType, ulSysFileNum, pStreamId) != OSSERR_SUCCESS) 46 46 { 47 dprintf(("OSS16_WaveOpen failed!!"));47 rprintf(("OSS16_WaveOpen failed!!")); 48 48 DebugInt3(); 49 49 StreamId = 0; … … 139 139 hwparam.ulDataType = QueryOSSDataFormat(OPERATION_RECORD, pConfigInfo->ulDataType, pConfigInfo->ulHwBitsPerSample); 140 140 if(OSS16_WaveSetFormat(StreamId, &hwparam) != OSSERR_SUCCESS) { 141 dprintf(("WAVEREC::ConfigDev: WaveSetFormat failed"));141 rprintf(("WAVEREC::ConfigDev: WaveSetFormat failed")); 142 142 DebugInt3(); 143 143 return FALSE; … … 152 152 ULONG FAR *pulBytesTransferred) 153 153 { 154 #ifdef DEBUG155 154 //dprintf(("WAVEREC::Transfer %lx bytes", ulBytesToTransfer)); 156 #endif157 155 if(pConfigInfo->usConversion == CONVERT_NONE) 158 156 { … … 308 306 if(OSS16_WaveGetHwPtr(StreamId, &space) != OSSERR_SUCCESS) { 309 307 *pulHwPtr = 0; 310 #ifdef DEBUG 311 dprintf(("OSS16_WAVEREC::WaveGetHwPtr: Failed")); 312 #endif /* DEBUG */ 308 rprintf(("OSS16_WAVEREC::WaveGetHwPtr: Failed")); 313 309 return FALSE; 314 310 } -
OCO/trunk/drv16/wavestrm.cpp
r486 r526 1 1 /* SCCSID = %W% %E% */ 2 2 /**************************************************************************** 3 * 4 * Copyright (c) IBM Corporation 1994 - 1997. 5 * 6 * The following IBM OS/2 source code is provided to you solely for the 3 * * 4 * Copyright (c) IBM Corporation 1994 - 1997. * 5 * * 6 * The following IBM OS/2 source code is provided to you solely for the * 7 7 * the purpose of assisting you in your development of OS/2 device drivers. * 8 * You may use this code in accordance with the IBM License Agreement 9 * provided in the IBM Device Driver Source Kit for OS/2. 10 * 8 * You may use this code in accordance with the IBM License Agreement * 9 * provided in the IBM Device Driver Source Kit for OS/2. * 10 * * 11 11 ****************************************************************************/ 12 12 /**@internal %W% … … 14 14 * @version %I% 15 15 * @context Unless otherwise noted, all interfaces are Ring-0, 16-bit, 16 * 16 * <stack context>. 17 17 * @history 18 18 * 19 19 */ 20 20 #define INCL_NOPMAPI 21 #define INCL_DOSERRORS 21 #define INCL_DOSERRORS // for ERROR_INVALID_FUNCTION 22 22 #include <os2.h> 23 23 #include <os2me.h> 24 #include <audio.h> 24 #include <audio.h> // for #define MIDI 25 25 #include <string.h> 26 26 #include <include.h> … … 42 42 extern "C" ULONG __cdecl __saveregs OSSIDC_EntryPoint(ULONG cmd, ULONG param1, ULONG param2); 43 43 44 45 //****************************************************************************** 46 // _vRealignBuffer 47 // called just after a wave stream pause on a playback. 48 // Gets the end position of the stream when paused and a pointer to a 49 // STREAMBUFFER. Basicly this function looks at the streambuffer and if 44 #define SNDRV_PCM_STATE_XRUN 4 /* stream reached an xrun */ 45 46 //****************************************************************************** 47 // _vRealignBuffer 48 // called just after a wave stream pause on a playback. 49 // Gets the end position of the stream when paused and a pointer to a 50 // STREAMBUFFER. Basicly this function looks at the streambuffer and if 50 51 // there is any unplayed data in it it adjusts the bufpos counter. 51 52 // the donepos counter is ALWAYS set to zero. It will return 0 if all 52 53 // the data has been played and 1 if there is still some data left. 53 54 //****************************************************************************** 54 USHORT 55 USHORT WAVESTREAM::_vRealignBuffer(ULONG ulEndPos, PSTREAMBUFFER pBuffer) 55 56 { 56 57 if (ulEndPos >= pBuffer->ulDonepos) { /* all of the data has been consumed */ … … 115 116 } 116 117 117 // if there are buffer eon the done queue, pop them off the head and118 // if there are buffers on the done queue, pop them off the head and 118 119 // push them on the head of qhTempHead. This will reorder them so 119 120 // that the more recently used ones will be in the front of the queue. … … 122 123 // be returned) so put it on the Tail of the done queue. 123 124 // If the rc is 1 then put it on the head of the InProcess queue. 124 125 125 while (qhDone.IsElements()) { 126 126 pTempHead->PushOnHead(qhDone.PopHead()); … … 130 130 { 131 131 usRC = _vRealignBuffer(ulEndPos, (PSTREAMBUFFER)pTempHead->Head()); 132 if (usRC) 132 if (usRC) { 133 133 qhInProcess.PushOnHead(pTempHead->PopHead()); 134 else 135 qhDone.PushOnTail(pTempHead->PopHead()); 134 } else { 135 qhDone.PushOnHead(pTempHead->PopHead()); 136 } 136 137 } 137 138 while (qhDone.IsElements()) { … … 142 143 break; 143 144 } /* endswitch */ 145 delete pTempHead; // free the memory 146 } 147 148 void WAVESTREAM::_vUnderrunStop(PCHAR pchStr) 149 { 150 if (ulStreamState == STREAM_STOPPED) return; 151 rprintf(("%s: Underrun-stop", pchStr)); 152 //pahw->SetVolume(StreamId, getMixerStreamId(), 0); 153 pahw->Stop(StreamId); 154 ulStreamState = STREAM_STOPPED; 155 fUnderrun = TRUE; 156 _ulBytesProcessed = 0; 157 _ulBytesWritten = 0; 158 } 159 160 ULONG WAVESTREAM::_vUnderrunStart(void) 161 { 162 if (ulStreamState == STREAM_STREAMING) return 0; 163 rprintf(("Underrun-start")); 164 PSTREAMBUFFER pTemp = (PSTREAMBUFFER)qhInProcess.Head(); 165 // if(pahw->ConfigDev(StreamId, &_configinfo, (pTemp) ? pTemp->ulBuffsz : 0) == FALSE) { 166 // rprintf(("WS::Write: ConfigDev failed")); 167 // return ERROR_INSUFF_BUFFER; 168 // } 169 _configinfo.ulSRatePosition = 0; 170 // prepare wave device for playback/recording 171 if(pahw->Prepare(StreamId) == FALSE) { 172 rprintf(("WS::UR Start: Prepare failed")); 173 return ERROR_START_STREAM; 174 } 175 176 _ulBytesProcessed = 0; 177 _ulBytesWritten = 0; 178 ulStreamState = STREAM_STREAMING; 179 fUnderrun = FALSE; 180 //if (ulStreamType == STREAM_WAVE_PLAY) pahw->SetVolume(StreamId, getMixerStreamId(), volume); 181 return 0; 144 182 } 145 183 … … 150 188 // if this is a write stream call _vFillAudioBuf 151 189 //****************************************************************************** 190 static short sAddBuffersInProcess = 0; 191 static short sDbgSave; 152 192 #pragma off (unreferenced) 153 void WAVESTREAM::AddBuffers( BOOL fFirst)193 void WAVESTREAM::AddBuffers(SHORT sFirst) 154 194 #pragma on (unreferenced) 155 195 { 156 196 ULONG ulSpace, ulBytesWritten; 157 197 ULONG ulDAZ; 158 159 //dgprintf(("WS:AddBuffers First=%d, SampleSize=%lx", fFirst, _configinfo.ulSampleSize)); 160 161 ulBytesWritten = 0; 162 if (ulStreamType & STREAM_WRITE) 163 { 164 // get the space available in the hardware buffer 165 // only call GetSpace once because the amount of free space in 166 // the hardware buffer is a moving target and calling it more than once 167 // could keep us in this loop writing 4 or 8 bytes at a time. 168 // In extream cases we will stay stuck in this loop long enough to casue a trap rjj 169 if (pahw->GetSpace(StreamId, &_configinfo, &ulSpace) == FALSE) 170 { 171 dgprintf(("WAVESTREAM::AddBuffers GetSpace failed")); 172 return; 173 } 174 ulSpace &= (~(_configinfo.ulSampleSize - 1)); 198 ULONG ulStatus; 199 200 //dprintf(("WS:AddBuffers First=%d, SampleSize=%lx", sFirst, _configinfo.ulSampleSize)); 201 202 if (sAddBuffersInProcess) { 203 // This routine cannot be reentered 204 // Some systems generate an extra interrupt causing this routine to be reentered 205 // so we ignore the call that causes us to be reentered 206 rprintf(("WS::ABS InProcess Now=%x Save=%x", sFirst, sDbgSave)); 207 return; 208 } 209 sAddBuffersInProcess++; 210 sDbgSave = sFirst; 211 212 ulBytesWritten = 0; 213 if (ulStreamType & STREAM_WRITE) 214 { 215 // get the space available in the hardware buffer 216 // only call GetSpace once because the amount of free space in 217 // the hardware buffer is a moving target and calling it more than once 218 // could keep us in this loop writing 4 or 8 bytes at a time. 219 // In extream cases we will stay stuck in this loop long enough to casue a trap rjj 220 if (pahw->GetSpace(StreamId, &_configinfo, &ulSpace) == FALSE) { 221 rprintf(("WS::ABS GetSpace failed")); 222 return; 223 } 224 ulSpace &= (~(_configinfo.ulSampleSize - 1)); 225 #if 1 226 /* DAZ testing -- underrun detection */ 227 if (ulSpace == 0) { 228 OSS16_WaveGetStatus(StreamId, &ulStatus); 229 rprintf(("WS::ABS ulSpace=0 state=%lx u32status=%lx", ulStreamState, ulStatus)); 230 231 _vUnderrunStop("WS:ABS"); 232 _vUnderrunStart(); 233 234 if (pahw->GetSpace(StreamId, &_configinfo, &ulSpace) == FALSE) { 235 rprintf(("WS::ABS GetSpace failed")); 236 return; 237 } 238 ulSpace &= (~(_configinfo.ulSampleSize - 1)); 239 if (ulSpace ==0) rprintf(("WS::ABS still no space")); 240 } 241 #endif 175 242 ulDAZ = 0; 176 177 243 while (ulSpace && qhInProcess.IsElements()) 244 { 178 245 if (ulDAZ++ > 20) { 179 dgprintf(("WAVESTREAM::AddBuffers DAZ break")); // Temporary hack to prevent lockups when uniaud32 stops (underrun) 246 rprintf(("WS::ABS DAZ break")); // Temporary hack to prevent lockups when uniaud32 stops (underrun) 247 int3(); /* should never happen */ 180 248 break; 181 249 } 182 // First time is in task time. For I7 need to give time for interrupt time 183 if (fFirst == TRUE) //PS+++ 184 { 185 //cli(); 186 DevHelp_ProcBlock (0x5541, 20, 0); // ok since the first call is at task time 187 ulBytesWritten = AddBuffer(ulSpace); 188 return; 250 ulBytesWritten = AddBuffer(ulSpace); 251 if (ulBytesWritten == (ULONG)-1) { 252 OSS16_WaveGetStatus(StreamId, &ulStatus); 253 rprintf(("WS::ABS AddBuffer returns -1 u32Status=%lx", ulStatus)); 254 break; 189 255 } 190 ulBytesWritten = AddBuffer(ulSpace); 191 if (ulBytesWritten == (ULONG)-1) break; 192 ulSpace -= ulBytesWritten; 193 ulSpace &= ( ~(_configinfo.ulSampleSize - 1)); 194 } 195 196 } 197 } 198 199 //****************************************************************************** 200 // write one buffer to the audio buffer 1 201 // the caller of this function MUST make sure it ok to write the audio buffer.. 202 // _AudioBufWrite will not check if there is room in the audio buffer of if 203 // there are buffers on pHead... BEWARE 256 ulSpace -= ulBytesWritten; 257 ulSpace &= ( ~(_configinfo.ulSampleSize - 1)); 258 } 259 // if (ulSpace) { 260 // dprintf(("WAVESTREAM::AddBuffers done. ulSpace=%lx", ulSpace)); 261 // } 262 } 263 sAddBuffersInProcess--; 264 } 265 266 //****************************************************************************** 267 // write one buffer to the audio buffer in uniaud32 204 268 //****************************************************************************** 205 269 ULONG WAVESTREAM::AddBuffer(ULONG ulSpace) 206 270 { 207 208 209 271 PSTREAMBUFFER pTemp = (PSTREAMBUFFER)qhInProcess.Head(); 272 ULONG pDataBuf; 273 ULONG ulBuffLeft; 210 274 ULONG ulBytesWritten; 211 //DAZ ULONG ulStartPos; 212 213 /* make sure we have a buffer to copy from */ 214 if (!pTemp) 215 { 216 return (ULONG)-1; 217 } 275 276 /* make sure we have a buffer to copy from */ 277 if (!pTemp) return (ULONG)-1; 218 278 219 279 /* make sure there is space in the output buffer */ 220 if (!ulSpace) 221 { 222 return (ULONG)-1; 223 } 280 if (!ulSpace) return (ULONG)-1; 224 281 225 282 /* PS+++ if input buffer is ZERO do nothing and ask for give new buffer, See REMARK in mmpm2.inf */ 226 if (!pTemp->ulBuffsz) 227 { 228 qhDone.PushOnTail(qhInProcess.PopHead()); 229 return (ULONG)-1; 230 } 231 232 /* DAZ */ 233 #if 0 234 // get the starting position. Call WaveGetHwPtr. if we get a bad rc then we bail out. 235 if(pahw->GetHwPtr(StreamId, &_configinfo, &ulStartPos) == FALSE) 236 { 237 dgprintf(("WAVESTREAM::AddBuffer Err in GetHwPtr")); 238 DebugInt3(); 239 return (ULONG)-1; 240 } 241 #endif 242 243 // get the buffer pointer and amount of data remaining 244 pDataBuf = (ULONG)pTemp->pBuffptr + pTemp->ulBuffpos; /* points to the beginning of data in src buffer */ 245 ulBuffLeft = pTemp->ulBuffsz - pTemp->ulBuffpos; /* amount of src data left to transfer */ 246 //dgprintf(("WS::AddBuffer buf=%lx remain=%lx, space=%lx bp=%lx dp=%lx size=%lx", pTemp->pBuffptr, ulBuffLeft, ulSpace, pTemp->ulBuffpos, pTemp->ulDonepos, pTemp->ulBuffsz)); 247 ulBuffLeft = min(ulBuffLeft, ulSpace); /* the smaller of src data left or dst space available */ 248 249 if (pahw->Transfer(StreamId, &_configinfo, pDataBuf, ulBuffLeft, &ulBytesWritten) == FALSE) 250 { 283 if (!pTemp->ulBuffsz) { 284 qhDone.PushOnTail(qhInProcess.PopHead()); 285 return 0; 286 } 287 if (pTemp->ulBuffsz < (_configinfo.ulBytesPerIRQ*2)) { 288 rprintf(("WS::AB: BufferMode=1")); 289 usBufferMode = 1; 290 } 291 292 // get the buffer pointer and amount of data remaining 293 pDataBuf = (ULONG)pTemp->pBuffptr + pTemp->ulBuffpos; /* points to the beginning of data in src buffer */ 294 ulBuffLeft = pTemp->ulBuffsz - pTemp->ulBuffpos; /* amount of src data left to transfer */ 295 //dprintf(("WS::AddBuffer buf=%lx remain=%lx, space=%lx bp=%lx dp=%lx size=%lx", pTemp->pBuffptr, ulBuffLeft, ulSpace, pTemp->ulBuffpos, pTemp->ulDonepos, pTemp->ulBuffsz)); 296 ulBuffLeft = min(ulBuffLeft, ulSpace); /* the smaller of src data left or dst space available */ 297 298 if (!ulBuffLeft) { 299 qhDone.PushOnTail(qhInProcess.PopHead()); 300 return 0; 301 } 302 303 if (pahw->Transfer(StreamId, &_configinfo, pDataBuf, ulBuffLeft, &ulBytesWritten) == FALSE) { 251 304 // This could mean that the hardware has underrun TODO: implement underrun logic 252 dgprintf(("WS::AddBuffer: pahw->Transfer failed"));253 254 255 if (ulBytesWritten == 0) 256 305 rprintf(("WS::AB: pahw->Transfer failed")); 306 return (ULONG)-1; 307 } 308 //dprintf(("WS::AB: %lx of %lx bytes written", ulBytesWritten, ulBuffLeft)); 309 if (ulBytesWritten == 0) { 257 310 // This could mean that the hardware has underrun TODO: implement underrun logic 258 dgprintf(("WS::AddBuffer: 0 of %lx bytes written by transfer", ulBuffLeft));259 return (ULONG)-1; /* DAZ check into returning zero, returning 0 may cause lockup */260 261 //d gprintf(("WS::AddBuffer added %lx from %lx BuffPos=%lx sz=%lx bw=%lx dp=%lx", ulBytesWritten, pTemp->pBuffptr, pTemp->ulBuffpos, pTemp->ulBuffsz, _ulBytesWritten, pTemp->ulDonepos));311 //rprintf(("WS::AddBuffer: 0 of %lx bytes written by transfer", ulBuffLeft)); 312 return (ULONG)-1; 313 } 314 //dprintf(("WS::AddBuffer added %lx from %lx BuffPos=%lx sz=%lx bw=%lx dp=%lx", ulBytesWritten, pTemp->pBuffptr, pTemp->ulBuffpos, pTemp->ulBuffsz, _ulBytesWritten, pTemp->ulDonepos)); 262 315 263 316 _ulBytesWritten += ulBytesWritten; /* update the running counter */ 264 265 266 267 268 269 270 //d gprintf(("WS::AddBuffer done with buffer %lx dp=%lx", pTemp->pBuffptr, pTemp->ulDonepos));271 272 273 317 pTemp->ulBuffpos += ulBytesWritten; /* update the buffer pos counter */ 318 pTemp->ulDonepos = _ulBytesWritten; /* update the done Position for returning the buffer */ 319 320 // check to see if the whole buffer has been copied and needs to be put on the done queue 321 if (pTemp->ulBuffpos >= (pTemp->ulBuffsz /* & 0xFFFFFFFC*/)) /* DAZ */ 322 { 323 //dprintf(("WS::AddBuffer done with buffer %lx dp=%lx", pTemp->pBuffptr, pTemp->ulDonepos)); 324 qhDone.PushOnTail(qhInProcess.PopHead()); 325 } 326 return ulBytesWritten; 274 327 } 275 328 //****************************************************************************** … … 279 332 BOOL WAVESTREAM::_vReadAudioBuf(void) 280 333 { 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 334 PSTREAMBUFFER pTemp = (PSTREAMBUFFER)qhInProcess.Head(); 335 ULONG pDataBuf; 336 ULONG ulBuffLeft, ulBytesRead; 337 338 if(!pTemp) return FALSE; 339 340 // get the buffer pointer and amount of data remaining 341 pDataBuf = (ULONG)pTemp->pBuffptr + pTemp->ulBuffpos; 342 ulBuffLeft = pTemp->ulBuffsz - pTemp->ulBuffpos; 343 344 // read wave data 345 if(pahw->Transfer(StreamId, &_configinfo, pDataBuf, ulBuffLeft, &ulBytesRead) == FALSE) 346 { 347 return FALSE; /* No more data */ 348 } 349 if(ulBytesRead == 0) { 350 return FALSE; /* No more data */ 351 } 299 352 if (ulBytesRead > ulBuffLeft) { 300 301 } 302 303 304 305 353 return FALSE; /* Internal error */ 354 } 355 356 // update the buffer pos counter 357 pTemp->ulBuffpos += ulBytesRead; 358 _ulBytesProcessed += ulBytesRead; 306 359 307 360 //dprintf(("_vReadAudioBuf %lx Requested=%lx Read=%lx Remain=%lx Processed=%lx", pDataBuf, ulBuffLeft, ulBytesRead, pTemp->ulBuffsz-pTemp->ulBuffpos, _ulBytesProcessed)); 308 361 309 310 311 312 313 314 362 if(pTemp->ulBuffpos == pTemp->ulBuffsz) { 363 qhDone.PushOnTail(qhInProcess.PopHead()); 364 ReturnBuffer(); 365 } 366 367 return TRUE; 315 368 } 316 369 //****************************************************************************** … … 327 380 ULONG ulDAZ; 328 381 329 //d dprintf(("WAVESTREAM::Process Start"));330 331 332 333 334 382 //dprintf(("WAVESTREAM::Process Start")); 383 384 // get the stream position. if we get a bad rc or the position is 0 385 // then we bail out. Hopefully this will be better next time. 386 // GetPostiion returns the adjusted hw pointer from the ALSA status ioctl 387 // This is really a running total of bytes consumed by the hardware. 335 388 // DAZ - Note that this is a 32 bit counter and will wrap at sometime. ALSA 336 389 // attempts to wrap this counter intelligently. I haven't determined what 337 390 // effect, if any, the wrapping of this counter will have playing a stream. 338 if(pahw->GetPosition(StreamId, &_configinfo, &ulBytes) == FALSE) 339 { 340 ddprintf(("Error No bytes processed")); 341 DebugInt3(); 342 return; 343 } 344 _ulBytesProcessed = ulBytes; 345 346 switch (ulStreamType & STREAM_WRITE) 347 { 348 case STREAM_WRITE: 349 if (qhInProcess.IsElements()) 350 { 351 AddBuffers(FALSE); 352 } 353 // Return any buffers that have been completely written to uniaud32 391 if(pahw->GetPosition(StreamId, &_configinfo, &ulBytes) == FALSE) 392 { 393 //dprintf(("Error No bytes processed")); 394 DebugInt3(); 395 return; 396 } 397 _ulBytesProcessed = ulBytes; 398 399 switch (ulStreamType & STREAM_WRITE) 400 { 401 case STREAM_WRITE: 402 if(!qhInProcess.IsElements() && !qhDone.IsElements()) { 403 _vUnderrunStop("WS:Process"); 404 break; 405 } 406 if (qhInProcess.IsElements()) AddBuffers(1); 407 // Return any buffers that have been completely written to uniaud32 408 //dprintf(("WS::Process usBufferMode=%x", usBufferMode)); 354 409 while (qhDone.IsElements()) { 355 410 pTemp = (PSTREAMBUFFER)qhDone.Head(); /* get a pointer to the first completed buffer */ 356 411 // Hang on to the last buffer until the hardware is done writing the data 357 412 // We do this because MMPM uses the return of the last buffer to determine when we are 358 413 // done playing the stream 359 if ((qhDone.Head() == qhDone.Tail()) && !qhInProcess.IsElements() && (_ulBytesProcessed < pTemp->ulDonepos)) break; /* only one buffer left */ 414 if ((qhDone.Head() == qhDone.Tail()) && !qhInProcess.IsElements()) { /* only one buffer left */ 415 if (_ulBytesProcessed < pTemp->ulDonepos) break; 416 } else { /* not the last buffer */ 417 /* if the buffer is bigger than BytesPerIRQ and it's not finished yet, hang on to it */ 418 if (!usBufferMode && (_ulBytesProcessed < pTemp->ulDonepos)) break; 419 //if ((_ulBytesProcessed + _configinfo.ulBytesPerIRQ) < pTemp->ulDonepos) break; 420 } 360 421 ReturnBuffer(); 361 422 } 362 363 423 break; 424 case STREAM_READ: 364 425 ulDAZ = 0; 365 426 while(_vReadAudioBuf()) { 366 427 if (ulDAZ++ > 20) { /* temporary hack to prevent hangs when uniaud32 stops (overruns) */ 367 ddprintf(("WAVESTREAM::Process Read DAZ Break"));428 rprintf(("WS::Process Read DAZ Break")); 368 429 break; 369 430 } 370 431 } 371 372 373 374 375 376 377 //ddprintf(("WAVESTREAM::Process End"));432 break; 433 default: 434 break; 435 } /* endswitch */ 436 437 ProcessEvents(); 438 //dprintf(("WAVESTREAM::Process End")); 378 439 } 379 440 //****************************************************************************** … … 383 444 #pragma on (unreferenced) 384 445 { 385 386 387 446 PSTREAMBUFFER pStreamBuf = new STREAMBUFFER(uLength, pbuf); 447 448 return Write(pStreamBuf); 388 449 } 389 450 //****************************************************************************** … … 391 452 ULONG WAVESTREAM::Write(PSTREAMBUFFER pStreamBuf) 392 453 { 393 qhInProcess.PushOnTail((PQUEUEELEMENT)pStreamBuf); 394 // dprintf2(("WAVESTREAM::Write: Push on tail %lx %ld", ((PSTREAMBUFFER)qhInProcess.Tail())->pBuffptr, ((PSTREAMBUFFER)qhInProcess.Tail())->ulBuffsz)); 395 return 0; 454 455 #if 1 456 ULONG ulStatus; 457 458 ulStatus = 0; 459 if (OSS16_WaveGetStatus(StreamId, &ulStatus) != OSSERR_SUCCESS) ulStatus = SNDRV_PCM_STATE_XRUN; 460 //dprintf(("WS::Write: status=%lx", ulStatus)); 461 if (ulStatus == SNDRV_PCM_STATE_XRUN) { 462 rprintf(("WS::Write: Xrun detect")); 463 _vUnderrunStop("WS:Write"); 464 fUnderrun = TRUE; 465 } 466 #endif 467 qhInProcess.PushOnTail((PQUEUEELEMENT)pStreamBuf); 468 if (fUnderrun) { 469 _vUnderrunStart(); 470 AddBuffers(2); 471 } 472 return 0; 396 473 } 397 474 //****************************************************************************** … … 399 476 ULONG WAVESTREAM::Read(PSTREAMBUF pbuf, unsigned uLength) 400 477 { 401 402 403 478 qhInProcess.PushOnTail((PQUEUEELEMENT)new STREAMBUFFER(uLength, pbuf)); 479 //dprintf2(("WAVESTREAM::Read: Push on tail %lx %lx", pbuf, uLength)); 480 return 0; 404 481 } 405 482 //****************************************************************************** … … 419 496 ULONG WAVESTREAM::GetCurrentTime() 420 497 { 421 ULONG Seconds, MilliSeconds, Overflow, Processed; 422 423 //PS++ optimize code 424 Processed = _ulBytesProcessed; 425 if (ulStreamState == STREAM_STREAMING) // if the stream is active 426 { 427 if (ulStreamType & STREAM_WRITE) 428 { 429 if (pahw->GetPosition(StreamId, &_configinfo, &Processed) == FALSE) 430 { 431 //DebugInt3(); 432 Processed = _ulBytesProcessed; //last known position 433 } 434 } 435 } 436 437 // if we haven't processed anything then just return _ulTimeBase 438 if(Processed == 0) 439 return(_ulTimeBase); 440 441 Seconds = Processed / _configinfo.ulPCMConsumeRate; 442 Overflow = Processed - (Seconds * _configinfo.ulPCMConsumeRate); 443 MilliSeconds = (Overflow * 1000) / _configinfo.ulPCMConsumeRate; 444 MilliSeconds += (Seconds * 1000); 445 return (MilliSeconds + _ulTimeBase); 446 } 447 //****************************************************************************** 448 //****************************************************************************** 449 ULONG WAVESTREAM::GetCurrentPos(void) 450 { 451 ULONG Processed; 498 ULONG Seconds, MilliSeconds, Overflow, Processed; 452 499 453 500 //PS++ optimize code 454 501 Processed = _ulBytesProcessed; 455 if (ulStreamState == STREAM_STREAMING) // if the stream is active 502 if (ulStreamState == STREAM_STREAMING) // if the stream is active 503 { 504 if (ulStreamType & STREAM_WRITE) 505 { 506 if (pahw->GetPosition(StreamId, &_configinfo, &Processed) == FALSE) 507 { 508 //DebugInt3(); 509 Processed = _ulBytesProcessed; //last known position 510 } 511 } 512 } 513 514 // if we haven't processed anything then just return _ulTimeBase 515 if(Processed == 0) 516 return(_ulTimeBase); 517 518 Seconds = Processed / _configinfo.ulPCMConsumeRate; 519 Overflow = Processed - (Seconds * _configinfo.ulPCMConsumeRate); 520 MilliSeconds = (Overflow * 1000) / _configinfo.ulPCMConsumeRate; 521 MilliSeconds += (Seconds * 1000); 522 return (MilliSeconds + _ulTimeBase); 523 } 524 //****************************************************************************** 525 //****************************************************************************** 526 ULONG WAVESTREAM::GetCurrentPos(void) 527 { 528 ULONG Processed; 529 530 //PS++ optimize code 531 Processed = _ulBytesProcessed; 532 if (ulStreamState == STREAM_STREAMING) // if the stream is active 456 533 { 457 534 if (ulStreamType & STREAM_WRITE) … … 478 555 if(!pTemp) 479 556 { 480 557 pTemp = (PSTREAMBUFFER)qhInProcess.Head(); 481 558 } 482 559 if(pTemp) 483 560 { 484 561 writepos = pTemp->ulBuffpos; 485 562 } 486 563 sti(); … … 495 572 void WAVESTREAM::SetCurrentTime(ULONG time) 496 573 { 497 //d dprintf(("SetCurrentTime: %lx", time));498 574 //dprintf(("SetCurrentTime: %lx", time)); 575 _ulTimeBase = time; 499 576 } 500 577 //****************************************************************************** … … 502 579 ULONG WAVESTREAM::StartStream() 503 580 { 504 505 506 507 508 ddprintf(("StartStream: already playing!!"));509 510 511 512 513 514 515 516 ddprintf(("StartStream: ConfigDev failed!!"));517 581 PSTREAMBUFFER pTemp = (PSTREAMBUFFER)qhInProcess.Head(); 582 583 if(ulStreamState == STREAM_STREAMING) 584 { 585 //dprintf(("StartStream: already playing!!")); 586 return NO_ERROR; 587 } 588 589 // configure the wave device 590 // (NOTE: Must call this function; sample rate position is reset there) 591 if(pahw->ConfigDev(StreamId, &_configinfo, (pTemp) ? pTemp->ulBuffsz : 0) == FALSE) 592 { 593 rprintf(("StartStream: ConfigDev failed!!")); 594 return ERROR_INSUFF_BUFFER; 518 595 //goto fail; 519 520 521 522 523 ddprintf(("StartStream: Prepare failed!!"));524 525 526 527 596 } 597 // prepare wave device for playback/recording 598 if(pahw->Prepare(StreamId) == FALSE) 599 { 600 rprintf(("StartStream: Prepare failed!!")); 601 goto fail; 602 } 603 604 _ulBytesProcessed = 0; 528 605 _ulBytesWritten = 0; 529 530 ulStreamState = STREAM_STREAMING; 531 //Adding the first buffer also starts playback 532 if (ulStreamType == STREAM_WAVE_PLAY) 533 { 534 pahw->SetVolume(StreamId, getMixerStreamId(), volume); //PS 535 AddBuffers(TRUE); 536 //Must set volume after adding buffers (voices inside sblive driver might not 537 //be allocated otherwise (first start) ) 538 // dprintf(("SetVolume %lx",volume)); 539 // PS, removing to high 540 // pahw->SetVolume(StreamId, getMixerStreamId(), volume); 541 } 542 else 543 { 544 //dprintf(("Starting Rec Stream")); 545 ulSavedInputGain = pahw->QueryVolume(StreamId, getMixerStreamId()); 546 pahw->SetInputSrc(StreamId, getMixerStreamId(), inputsrc); 547 pahw->SetVolume(StreamId, getMixerStreamId(), inputgain); 606 fUnderrun = FALSE; 607 usBufferMode = 0; 608 609 ulStreamState = STREAM_STREAMING; 610 //Adding the first buffer also starts playback 611 if (ulStreamType == STREAM_WAVE_PLAY) 612 { 613 //DAZ moved from AddBuffers, for I7, might not be needed 614 //DevHelp_ProcBlock (0x5541, 20, 0); 615 pahw->SetVolume(StreamId, getMixerStreamId(), volume); //PS 616 AddBuffers(3); 617 } 618 else 619 { 620 //dprintf(("Starting Rec Stream")); 621 ulSavedInputGain = pahw->QueryVolume(StreamId, getMixerStreamId()); 622 pahw->SetInputSrc(StreamId, getMixerStreamId(), inputsrc); 623 pahw->SetVolume(StreamId, getMixerStreamId(), inputgain); 548 624 549 625 if(pahw->Start(StreamId) != TRUE) 550 626 { 551 dprintf(("pahw->Start failed!!"));552 553 554 555 627 rprintf(("pahw->Start failed!!")); 628 goto fail; 629 } 630 } 631 return NO_ERROR; 556 632 557 633 fail: 558 559 634 DebugInt3(); 635 return ERROR_START_STREAM; 560 636 } 561 637 //****************************************************************************** … … 563 639 ULONG WAVESTREAM::StopStream(PCONTROL_PARM pControl) 564 640 { 565 if(ulStreamState == STREAM_STOPPED) { 566 dprintf(("WAVESTREAM::StopStream %lx (already stopped)", StreamId)); 567 pControl->ulTime = GetCurrentTime(); 568 return NO_ERROR; 569 } 570 //silence wave stream before stopping it (removes clicks) 571 if(ulStreamType == STREAM_WAVE_PLAY) { 572 pahw->SetVolume(StreamId, getMixerStreamId(), 0); 573 } 574 else { 575 pahw->SetVolume(StreamId, getMixerStreamId(), ulSavedInputGain); 576 } 577 pahw->Stop(StreamId); 578 579 ulStreamState = STREAM_STOPPED; 580 //ddprintf(("WAVESTREAM::StopStream %lx", StreamId)); 581 582 ReturnBuffers(); 583 pControl->ulTime = GetCurrentTime(); 584 585 // We need to set _ulBytesProcessed to 0 here. if we do not 586 // and MMPM restarts the stream by sending a DDCMD_SETUP followed By 587 // DDCMD_ENABLE_EVENT the event time will get screwed up. rjj 588 _ulBytesProcessed = 0; 641 if(ulStreamState == STREAM_STOPPED) { 642 //dprintf(("WS::StopStream %lx (already stopped)", StreamId)); 643 fUnderrun = FALSE; 644 pControl->ulTime = GetCurrentTime(); 645 return NO_ERROR; 646 } 647 //silence wave stream before stopping it (removes clicks) 648 if(ulStreamType == STREAM_WAVE_PLAY) { 649 pahw->SetVolume(StreamId, getMixerStreamId(), 0); 650 } 651 else { 652 pahw->SetVolume(StreamId, getMixerStreamId(), ulSavedInputGain); 653 } 654 pahw->Stop(StreamId); 655 656 ulStreamState = STREAM_STOPPED; 657 fUnderrun = FALSE; 658 //dprintf(("WAVESTREAM::StopStream %lx", StreamId)); 659 660 ReturnBuffers(); 661 pControl->ulTime = GetCurrentTime(); 662 663 // We need to set _ulBytesProcessed to 0 here. if we do not 664 // and MMPM restarts the stream by sending a DDCMD_SETUP followed By 665 // DDCMD_ENABLE_EVENT the event time will get screwed up. rjj 666 _ulBytesProcessed = 0; 589 667 _ulBytesWritten = 0; 590 668 return NO_ERROR; 591 669 } 592 670 //****************************************************************************** … … 594 672 ULONG WAVESTREAM::PauseStream(PCONTROL_PARM pControl) 595 673 { 596 ULONG ulEndPos, ulEndPos2; 597 598 if(ulStreamState == STREAM_PAUSED) { 599 dprintf(("WAVESTREAM::PauseStream %lx (already paused)", StreamId)); 600 pControl->ulTime = GetCurrentTime(); 601 return NO_ERROR; 602 } 603 604 pahw->GetPosition(StreamId, &_configinfo, &ulEndPos); 605 //silence wave stream before stopping it (removes clicks) 606 pahw->SetVolume(StreamId, getMixerStreamId(), 0); 607 pahw->Stop(StreamId); 608 674 ULONG ulEndPos; 675 676 if(ulStreamState == STREAM_PAUSED) { 677 dprintf(("WS::PauseStream %lx (already paused)", StreamId)); 678 fUnderrun = FALSE; 679 pControl->ulTime = GetCurrentTime(); 680 return NO_ERROR; 681 } 682 683 pahw->GetPosition(StreamId, &_configinfo, &ulEndPos); 684 //silence wave stream before stopping it (removes clicks) 685 pahw->SetVolume(StreamId, getMixerStreamId(), 0); 686 pahw->Stop(StreamId); 687 688 #if 0 609 689 /* DAZ test code begin */ 610 690 if (pahw->GetPosition(StreamId, &_configinfo, &ulEndPos2) == FALSE) ulEndPos2 = 0; 611 691 if (ulEndPos2 != ulEndPos) { 612 ddprintf(("WAVESTREAM::PauseStream %lx!=%lx", ulEndPos, ulEndPos2));692 dprintf(("WS::PauseStream %lx!=%lx", ulEndPos, ulEndPos2)); 613 693 if (ulEndPos2) ulEndPos = ulEndPos2; 614 694 } 615 695 /* DAZ test code end */ 616 617 ulStreamState = STREAM_PAUSED; 618 619 ddprintf(("WAVESTREAM::PauseStream %lx", StreamId)); 620 621 _ulBytesProcessed = ulEndPos; 622 623 _vRealignPausedBuffers(ulEndPos); 624 625 pControl->ulTime = GetCurrentTime(); 626 627 _ulBytesProcessed = 0; 696 #endif 697 698 ulStreamState = STREAM_PAUSED; 699 700 dprintf(("WS::PauseStream %lx", StreamId)); 701 702 _ulBytesProcessed = ulEndPos; 703 704 _vRealignPausedBuffers(ulEndPos); 705 706 pControl->ulTime = GetCurrentTime(); 707 708 _ulBytesProcessed = 0; 628 709 _ulBytesWritten = 0; 629 630 return NO_ERROR; 710 fUnderrun = FALSE; 711 712 return NO_ERROR; 631 713 } 632 714 //****************************************************************************** … … 634 716 ULONG WAVESTREAM::ResumeStream(void) 635 717 { 636 #ifdef DEBUG 637 //dprintf(("WAVESTREAM::ResumeStream %lx", StreamId)); 638 #endif 639 return StartStream(); 718 //dprintf(("WAVESTREAM::ResumeStream %lx", StreamId)); 719 return StartStream(); 640 720 } 641 721 //****************************************************************************** … … 643 723 BOOL WAVESTREAM::SetProperty(int type, ULONG value, ULONG reserved) 644 724 { 645 646 647 648 dprintf(("WAVESTREAM::SetProperty() Vol: %0lx",value));649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 725 switch(type) { 726 case PROPERTY_VOLUME: 727 volume = value; 728 dprintf(("WS::SetProperty() Vol: %0lx",value)); 729 if(ulStreamState == STREAM_STREAMING && ulStreamType == STREAM_WAVE_PLAY) { 730 MixerSetWaveVolume(getMixerStreamId(), StreamId, volume); 731 } 732 break; 733 734 case PROPERTY_INPUTSRC: 735 inputsrc = value; 736 break; 737 738 case PROPERTY_INPUTGAIN: 739 inputgain = value; 740 break; 741 742 default: 743 return STREAM::SetProperty(type, value, reserved); 744 } 745 return TRUE; 666 746 } 667 747 //****************************************************************************** … … 669 749 ULONG WAVESTREAM::GetProperty(int type) 670 750 { 671 672 673 674 675 676 677 678 679 680 681 682 683 751 switch(type) { 752 case PROPERTY_FREQUENCY: 753 return _configinfo.ulSampleRate; 754 755 case PROPERTY_INPUTSRC: 756 return inputsrc; 757 758 case PROPERTY_INPUTGAIN: 759 return inputgain; 760 761 default: 762 return STREAM::GetProperty(type); 763 } 684 764 } 685 765 //****************************************************************************** … … 688 768 STREAM(streamtype, filesysnum, mixerStreamId) 689 769 { 690 // get the pointer to the hardware object 691 pahw = (WAVEAUDIO*)GetHardwareDevice(streamtype); 692 693 _fmemset(&_configinfo, 0, sizeof(_configinfo)); 694 _configinfo.ulSampleRate = pinit->lSRate; 695 _configinfo.ulBitsPerSample = pinit->lBitsPerSRate; 696 _configinfo.ulNumChannels = pinit->sChannels; 697 _configinfo.ulDataType = pinit->sMode; 698 _ulBytesWritten = 0; 699 _ulBytesProcessed = 0; 700 _ulTimeBase = 0; 701 ulSavedInputGain = 0; 702 703 _configinfo.pConversionBuffer = 0; 704 pahw->SetupConversion(&_configinfo, pinit->ulOperation, pinit->sMode, pinit->sChannels, pinit->lBitsPerSRate); 705 706 if(_configinfo.usConversion != CONVERT_NONE) 707 {//allocate conversion buffer 708 PVOID pSelOff; 709 LIN linAddr; 710 711 if(DevHelp_VMAlloc((VMDHA_FIXED | VMDHA_CONTIG), CONVERSION_BUFFER_SIZE, (ULONG)-1L, &linAddr, &pSelOff) != 0) 712 { 713 dgprintf(("Error in DevHelp_VMAlloc Conversion Buffer")); 714 DebugInt3(); //should never happen!! 715 _configinfo.usConversion = CONVERT_NONE; 716 } 717 else _configinfo.pConversionBuffer = linAddr; 718 } 719 if(_configinfo.fSampleRateConversion == TRUE) 720 {//allocate buffer for sample rate conversion 721 PVOID pSelOff; 722 LIN linAddr; 723 724 if (DevHelp_VMAlloc((VMDHA_FIXED | VMDHA_CONTIG), CONVERSION_BUFFER_SIZE, (ULONG)-1L, &linAddr, &pSelOff) != 0) 725 { 726 dgprintf(("Error in DevHelp_VMAlloc SR Conversion Buffer")); 727 DebugInt3(); //should never happen!! 728 } 729 else _configinfo.pSRateConvBuffer = linAddr; 730 } 731 732 pinit->ulFlags |= pahw->QueryDataFlags(pinit->ulOperation, pinit->sMode, pinit->lBitsPerSRate); 733 734 StreamId = 0; 735 736 if(pahw->Open(current_device, ulStreamType, ulSysFileNum, &StreamId) != TRUE) 737 { 738 dprintf(("pahw->Open failed!!")); 739 DebugInt3(); 740 } 770 // get the pointer to the hardware object 771 pahw = (WAVEAUDIO*)GetHardwareDevice(streamtype); 772 773 _fmemset(&_configinfo, 0, sizeof(_configinfo)); 774 _configinfo.ulSampleRate = pinit->lSRate; 775 _configinfo.ulBitsPerSample = pinit->lBitsPerSRate; 776 _configinfo.ulNumChannels = pinit->sChannels; 777 _configinfo.ulDataType = pinit->sMode; 778 _ulBytesWritten = 0; 779 _ulBytesProcessed = 0; 780 _ulTimeBase = 0; 781 ulSavedInputGain = 0; 782 fUnderrun = FALSE; 783 usBufferMode = 0; 784 785 _configinfo.pConversionBuffer = 0; 786 pahw->SetupConversion(&_configinfo, pinit->ulOperation, pinit->sMode, pinit->sChannels, pinit->lBitsPerSRate); 787 788 if(_configinfo.usConversion != CONVERT_NONE) 789 {//allocate conversion buffer 790 PVOID pSelOff; 791 LIN linAddr; 792 793 if(DevHelp_VMAlloc((VMDHA_FIXED | VMDHA_CONTIG), CONVERSION_BUFFER_SIZE, (ULONG)-1L, &linAddr, &pSelOff) != 0) 794 { 795 rprintf(("Error in DevHelp_VMAlloc Conversion Buffer")); 796 DebugInt3(); //should never happen!! 797 _configinfo.usConversion = CONVERT_NONE; 798 } 799 else _configinfo.pConversionBuffer = linAddr; 800 } 801 if(_configinfo.fSampleRateConversion == TRUE) 802 {//allocate buffer for sample rate conversion 803 PVOID pSelOff; 804 LIN linAddr; 805 806 if (DevHelp_VMAlloc((VMDHA_FIXED | VMDHA_CONTIG), CONVERSION_BUFFER_SIZE, (ULONG)-1L, &linAddr, &pSelOff) != 0) 807 { 808 rprintf(("Error in DevHelp_VMAlloc SR Conversion Buffer")); 809 DebugInt3(); //should never happen!! 810 } 811 else _configinfo.pSRateConvBuffer = linAddr; 812 } 813 814 pinit->ulFlags |= pahw->QueryDataFlags(pinit->ulOperation, pinit->sMode, pinit->lBitsPerSRate); 815 816 StreamId = 0; 817 818 if(pahw->Open(current_device, ulStreamType, ulSysFileNum, &StreamId) != TRUE) 819 { 820 rprintf(("pahw->Open failed!!")); 821 DebugInt3(); 822 } 741 823 742 824 //dprintf(("WAVESTREAM stream %lx ctor %lx: rate %d bps %d numchan %d type %x", hstream, StreamId, (USHORT)_configinfo.ulSampleRate, (USHORT)_configinfo.ulBitsPerSample, (USHORT)_configinfo.ulNumChannels, (USHORT)_configinfo.ulNumChannels, (USHORT)_configinfo.ulDataType)); … … 747 829 { 748 830 //dprintf(("WAVESTREAM stream %x dtor %lx", hstream, StreamId)); 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 } 767 //****************************************************************************** 768 //****************************************************************************** 769 831 if(_configinfo.pConversionBuffer) { 832 if(DevHelp_VMFree(_configinfo.pConversionBuffer) != 0) { 833 DebugInt3(); 834 } 835 } 836 if(_configinfo.pSRateConvBuffer) { 837 if(DevHelp_VMFree(_configinfo.pSRateConvBuffer) != 0) { 838 DebugInt3(); 839 } 840 } 841 if(pahw) { 842 if (ulStreamState == STREAM_STREAMING) 843 pahw->Stop(StreamId); 844 845 pahw->Close(StreamId); 846 StreamId = 0; 847 } 848 } 849 //****************************************************************************** 850 //****************************************************************************** 851 -
OCO/trunk/drv16/wavestrm.hpp
r483 r526 58 58 protected: 59 59 60 virtual void AddBuffers( BOOL fFirst); // Initialize the audio buffer object60 virtual void AddBuffers(SHORT sFirst); // Initialize the audio buffer object 61 61 62 62 WaveConfigInfo _configinfo; // configuration info shared with the hardware … … 69 69 ULONG AddBuffer(ULONG space); // write one buffer to the audio buffer 70 70 BOOL _vReadAudioBuf(void); // read data from the audio buffer 71 void _vUnderrunStop(PCHAR pchStr); 72 ULONG _vUnderrunStart(void); 71 73 72 74 ULONG ulSavedInputGain; 75 BOOL fUnderrun; 76 USHORT usBufferMode; 73 77 74 78 WAVEAUDIO *pahw; // pointer to the hardware object for this stream -
OCO/trunk/drv16/wtsynth.cpp
r252 r526 42 42 { 43 43 if(OSS16_MidiOpen(current_device, WAVETABLE_SEND, pStreamId) != OSSERR_SUCCESS) { 44 dprintf(("WTSYNTH::Open: OSS16_MidiOpen failed!!"));44 rprintf(("WTSYNTH::Open: OSS16_MidiOpen failed!!")); 45 45 DebugInt3(); 46 46 return FALSE; … … 53 53 { 54 54 if(OSS16_MidiClose(StreamId) != OSSERR_SUCCESS) { 55 dprintf(("WTSYNTH::Close: OSS16_MidiClose failed!!"));55 rprintf(("WTSYNTH::Close: OSS16_MidiClose failed!!")); 56 56 DebugInt3(); 57 57 return FALSE; … … 65 65 //****************************************************************************** 66 66 int WTSYNTH::writeByte(OSSSTREAMID StreamId, BYTE b) 67 { 68 int dummy = b; 69 return 0; 67 { 68 int dummy = b; 69 return 0; 70 70 } 71 71 //****************************************************************************** … … 76 76 //****************************************************************************** 77 77 int WTSYNTH::readByte(OSSSTREAMID StreamId) 78 { 78 { 79 79 DebugInt3(); 80 return -1; 80 return -1; 81 81 } 82 82 //****************************************************************************** … … 102 102 { 103 103 if(MixerSetVolume(mixerStreamId, OSS32_MIX_VOLUME_MIDI, ulVolume) != TRUE) { 104 dprintf(("WTSYNTH::SetVolume: MixerSetVolume failed!!"));104 rprintf(("WTSYNTH::SetVolume: MixerSetVolume failed!!")); 105 105 //not necessarily fatal; maybe there is no volume control for midi 106 106 } -
OCO/trunk/include/dbgos2.h
r507 r526 24 24 /* dprintf is used to output info into the log for the debug version */ 25 25 #ifdef DEBUG 26 #define DBGCALLCONV FAR 27 26 28 #define dprintf(a) PrintfOut a 27 29 #define dprintf1(a) if(dbglevel >= 1) PrintfOut a … … 29 31 #define dprintf3(a) if(dbglevel >= 3) PrintfOut a 30 32 #define dprintf4(a) if(dbglevel >= 4) PrintfOut a 33 34 #define DebugInt3() //_asm int 3 DAZ temporarily taken out of debug build to prevent traps 35 31 36 #else 37 // notdef DEBUG 38 #define DBGCALLCONV NEAR 39 32 40 #define dprintf(a) // 33 41 #define dprintf1(a) // … … 35 43 #define dprintf3(a) // 36 44 #define dprintf4(a) // 37 #endif38 45 39 #ifdef DEBUG40 #define DebugInt3() //_asm int 3 DAZ temporarily taken out of debug build to prevent traps41 #else42 46 #define DebugInt3() //_asm int 3 43 #endif44 47 45 #ifdef DEBUG46 #define DBGCALLCONV FAR47 #else48 #define DBGCALLCONV NEAR49 48 #endif 50 49 -
OCO/trunk/install/control.scr
r486 r526 25 25 ssgroup=0 26 26 ssname="mmbase" 27 ssversion="1.9. 1-SVNr486"27 ssversion="1.9.3-SVNr526" 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. 1-SVNr486"45 ssversion="1.9.3-SVNr526" 46 46 sssize=680 47 47 ssdll="genin.dll" -
OCO/trunk/uniaud.inc
r486 r526 6 6 # Full UNIAUD build version 7 7 # BUILDVERSION must be 3 parts, and only numbers like 5.44.108 8 # It is best that 2 'nd number is always 2 digits, eg at least 109 BUILDVERSION = 1.9. 18 # It is best that 2nd number is always 2 digits, eg at least 10 9 BUILDVERSION = 1.9.3 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 = SVNr 48615 FIXPACK = SVNr526 16 16 17 17 # ALSA BUILD VERSION
Note:
See TracChangeset
for help on using the changeset viewer.