Changeset 533 for OCO/trunk/drv16/wavestrm.cpp
- Timestamp:
- Aug 2, 2010, 11:30:35 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
OCO/trunk/drv16/wavestrm.cpp
r529 r533 55 55 USHORT WAVESTREAM::_vRealignBuffer(ULONG ulEndPos, PSTREAMBUFFER pBuffer) 56 56 { 57 if ( ulEndPos >= pBuffer->ulDonepos) { /* all of the data has been consumed */57 if (ARG1_IS_AFTER_OR_EQUAL_TO_ARG2(ulEndPos, pBuffer->ulDonepos)) { /* all of the data has been consumed */ 58 58 pBuffer->ulBuffpos = pBuffer->ulBuffsz; 59 59 pBuffer->ulDonepos = 0; … … 61 61 } 62 62 63 if ( ulEndPos >= (pBuffer->ulDonepos - pBuffer->ulBuffpos)) { /* some of the data has been consumed */63 if (ARG1_IS_AFTER_OR_EQUAL_TO_ARG2(ulEndPos, (pBuffer->ulDonepos - pBuffer->ulBuffpos))) { /* some of the data has been consumed */ 64 64 pBuffer->ulBuffpos = pBuffer->ulDonepos - ulEndPos; 65 65 pBuffer->ulBuffpos &= 0xFFFFFFFC; //keep it on a dword boundary … … 155 155 fUnderrun = TRUE; 156 156 _ulBytesProcessed = 0; 157 _ulLastPosition = 0; 157 158 _ulBytesWritten = 0; 158 159 } … … 175 176 176 177 _ulBytesProcessed = 0; 178 _ulLastPosition = 0; 177 179 _ulBytesWritten = 0; 178 180 ulStreamState = STREAM_STREAMING; … … 298 300 299 301 if (pahw->Transfer(StreamId, &_configinfo, pDataBuf, ulBuffLeft, &ulBytesWritten) == FALSE) { 300 // This could mean that the hardware has underrun TODO: implement underrun logic302 // This could mean that the hardware has underrun 301 303 rprintf(("WS::AB: pahw->Transfer failed")); 302 304 return (ULONG)-1; … … 304 306 //dprintf(("WS::AB: %lx of %lx bytes written", ulBytesWritten, ulBuffLeft)); 305 307 if (ulBytesWritten == 0) { 306 // This could mean that the hardware has underrun TODO: implement underrun logic308 // This could mean that the hardware has underrun 307 309 //rprintf(("WS::AddBuffer: 0 of %lx bytes written by transfer", ulBuffLeft)); 308 310 return (ULONG)-1; … … 322 324 return ulBytesWritten; 323 325 } 326 324 327 //****************************************************************************** 325 328 // Read data from the audio Buffer. … … 363 366 return TRUE; 364 367 } 368 365 369 //****************************************************************************** 366 370 // called by the irq function in the hardware object when we get an interrupt … … 377 381 { 378 382 PSTREAMBUFFER pTemp; 379 ULONG ulBytes ;383 ULONG ulBytes, ulDelta; 380 384 381 385 // get the stream position. if we get a bad rc or the position is 0 … … 391 395 return; 392 396 } 393 _ulBytesProcessed = ulBytes; 397 398 ulDelta = ulBytes - _ulLastPosition; 399 if (ulBytes < _ulLastPosition) { /* the byte counter in uniaud32 has wrapped */ 400 ulDelta = ulBytes; 401 if (_configinfo.ulBytesPerIRQ > ulDelta) ulDelta = _configinfo.ulBytesPerIRQ; 402 rprintf(("u32 wrap: BytesProcessed=%lx LastPosition=%lx Bytes=%lx Delta=%lx InProcess=%lx Done=%lx", 403 _ulBytesProcessed, _ulLastPosition, ulBytes, ulDelta, qhInProcess.IsElements(), qhDone.IsElements())); 404 } 405 406 _ulBytesProcessed += ulDelta; 407 _ulLastPosition = ulBytes; 394 408 395 409 if(!qhInProcess.IsElements() && !qhDone.IsElements()) { … … 407 421 // done playing the stream 408 422 if ((qhDone.Head() == qhDone.Tail()) && !qhInProcess.IsElements()) { /* only one buffer left */ 409 if ( _ulBytesProcessed < pTemp->ulDonepos) break;423 if (ARG1_IS_BEFORE_ARG2(_ulBytesProcessed, pTemp->ulDonepos)) break; 410 424 } else { /* not the last buffer */ 411 /* if the buffer is bigger than BytesPerIRQ and it's not finished yet, hang on to it */ 412 if (!usBufferMode && (_ulBytesProcessed < pTemp->ulDonepos)) break; 413 //if ((_ulBytesProcessed + _configinfo.ulBytesPerIRQ) < pTemp->ulDonepos) break; 425 /* if uniaud32 is not done playing the data hang on to the buffer */ 426 if (!usBufferMode && ARG1_IS_BEFORE_ARG2(_ulBytesProcessed, pTemp->ulDonepos)) break; 414 427 } 415 428 ReturnBuffer(); … … 485 498 ULONG Seconds, MilliSeconds, Overflow, Processed; 486 499 487 //PS++ optimize code488 500 Processed = _ulBytesProcessed; 489 if (ulStreamState == STREAM_STREAMING) // if the stream is active 490 { 491 if (ulStreamType & STREAM_WRITE) 492 { 493 if (pahw->GetPosition(StreamId, &_configinfo, &Processed) == FALSE) 494 { 495 //DebugInt3(); 496 Processed = _ulBytesProcessed; //last known position 497 } 501 if (ulStreamState == STREAM_STREAMING) { // if the stream is active 502 if (ulStreamType & STREAM_WRITE) { 503 if (pahw->GetPosition(StreamId, &_configinfo, &Processed) == FALSE) { 504 Processed = _ulBytesProcessed; 505 } 498 506 } 499 507 } 500 508 501 509 // if we haven't processed anything then just return _ulTimeBase 502 if(Processed == 0) 503 return(_ulTimeBase); 510 if(Processed == 0) return(_ulTimeBase); 504 511 505 512 Seconds = Processed / _configinfo.ulPCMConsumeRate; … … 515 522 ULONG Processed; 516 523 517 //PS++ optimize code518 524 Processed = _ulBytesProcessed; 519 if (ulStreamState == STREAM_STREAMING) // if the stream is active 520 { 521 if (ulStreamType & STREAM_WRITE) 522 { 523 if (pahw->GetPosition(StreamId, &_configinfo, &Processed) == FALSE) 524 { 525 if (ulStreamState == STREAM_STREAMING) { // if the stream is active 526 if (ulStreamType & STREAM_WRITE) { 527 if (pahw->GetPosition(StreamId, &_configinfo, &Processed) == FALSE) { 525 528 DebugInt3(); 526 529 Processed = _ulBytesProcessed; //last known position … … 590 593 591 594 _ulBytesProcessed = 0; 595 _ulLastPosition = 0; 592 596 _ulBytesWritten = 0; 593 597 fUnderrun = FALSE; … … 632 636 return NO_ERROR; 633 637 } 638 634 639 //silence wave stream before stopping it (removes clicks) 635 640 if(ulStreamType == STREAM_WAVE_PLAY) { … … 652 657 // DDCMD_ENABLE_EVENT the event time will get screwed up. rjj 653 658 _ulBytesProcessed = 0; 659 _ulLastPosition = 0; 654 660 _ulBytesWritten = 0; 655 661 return NO_ERROR; … … 659 665 ULONG WAVESTREAM::PauseStream(PCONTROL_PARM pControl) 660 666 { 661 ULONG ulEndPos;667 //DAZ ULONG ulEndPos; 662 668 663 669 if(ulStreamState == STREAM_PAUSED) { … … 668 674 } 669 675 670 pahw->GetPosition(StreamId, &_configinfo, &ulEndPos);676 //DAZ pahw->GetPosition(StreamId, &_configinfo, &ulEndPos); 671 677 //silence wave stream before stopping it (removes clicks) 672 678 pahw->SetVolume(StreamId, getMixerStreamId(), 0); … … 677 683 dprintf(("WS::PauseStream %lx", StreamId)); 678 684 679 _ulBytesProcessed = ulEndPos;680 681 _vRealignPausedBuffers( ulEndPos);685 //DAZ _ulBytesProcessed = ulEndPos; 686 687 _vRealignPausedBuffers(_ulBytesProcessed); 682 688 683 689 pControl->ulTime = GetCurrentTime(); 684 690 685 691 _ulBytesProcessed = 0; 692 _ulLastPosition = 0; 686 693 _ulBytesWritten = 0; 687 694 fUnderrun = FALSE; … … 755 762 _ulBytesWritten = 0; 756 763 _ulBytesProcessed = 0; 764 _ulLastPosition = 0; 757 765 _ulTimeBase = 0; 758 766 ulSavedInputGain = 0;
Note:
See TracChangeset
for help on using the changeset viewer.