Changeset 5348
- Timestamp:
- Mar 21, 2001, 1:33:22 PM (24 years ago)
- Location:
- trunk/src/winmm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/src/winmm/dwaveout.cpp ¶
r5334 r5348 1 /* $Id: dwaveout.cpp,v 1.3 2 2001-03-19 19:28:38sandervl Exp $ */1 /* $Id: dwaveout.cpp,v 1.33 2001-03-21 12:33:22 sandervl Exp $ */ 2 2 3 3 /* … … 118 118 119 119 curPlayBuf = curFillBuf = curFillPos = curPlayPos = 0; 120 readPos = writePos= 0;120 bytesPlayed = bytesCopied = bytesReturned = 0; 121 121 122 122 fMixerSetup = FALSE; … … 130 130 volume = defvolume; 131 131 State = STATE_STOPPED; 132 queuedbuffers = 0; 132 133 133 134 MixBuffer = (MCI_MIX_BUFFER *)malloc(PREFILLBUF_DART*sizeof(MCI_MIX_BUFFER)); … … 301 302 int i, buflength; 302 303 304 queuedbuffers++; 303 305 if(fMixerSetup == FALSE) 304 306 { … … 383 385 384 386 curPlayBuf = curFillBuf = curFillPos = curPlayPos = 0; 385 readPos = writePos= 0;387 bytesPlayed = bytesCopied = bytesReturned = 0; 386 388 387 389 for(i=0;i<PREFILLBUF_DART;i++) { … … 433 435 434 436 writeBuffer(); //must be called before (re)starting playback 435 436 437 wmutex->leave(); 438 437 439 if(State == STATE_STOPPED) {//continue playback 438 440 restart(); 439 441 } 442 else 443 if(fUnderrun) { 444 dprintf(("Resume playback after underrun")); 445 fUnderrun = FALSE; 446 State = STATE_PLAYING; 447 448 memset(&GenericParms, 0, sizeof(GenericParms)); 449 450 // Resume the playback. 451 mciSendCommand(DeviceId, MCI_RESUME, MCI_WAIT, (PVOID)&GenericParms, 0); 452 453 //write buffers to DART; starts playback 454 // MCI_MIXSETUP_PARMS->pMixWrite does alter FS: selector! 455 USHORT selTIB = GetFS(); // save current FS selector 456 457 MixSetupParms->pmixWrite(MixSetupParms->ulMixHandle, &MixBuffer[curPlayBuf], 1); 458 459 SetFS(selTIB); // switch back to the saved FS selector 460 } 440 461 } 441 462 return(MMSYSERR_NOERROR); … … 446 467 { 447 468 MCI_GENERIC_PARMS Params; 469 470 dprintf(("WINMM: DartWaveOut::pause")); 448 471 449 472 wmutex->enter(VMUTEX_WAIT_FOREVER); … … 459 482 memset(&Params, 0, sizeof(Params)); 460 483 461 // Stopthe playback.484 // Pause the playback. 462 485 mciSendCommand(DeviceId, MCI_PAUSE, MCI_WAIT, (PVOID)&Params, 0); 463 486 … … 483 506 484 507 curPlayBuf = curFillBuf = curFillPos = curPlayPos = 0; 485 readPos = writePos= 0;508 bytesPlayed = bytesCopied = bytesReturned = 0; 486 509 487 510 return(MMSYSERR_NOERROR); … … 510 533 wavehdr->dwFlags |= WHDR_DONE; 511 534 wavehdr->dwFlags &= ~WHDR_INQUEUE; 535 wavehdr->reserved = 0; 512 536 tmpwavehdr = wavehdr; 513 537 wavehdr = wavehdr->lpNext; … … 530 554 531 555 curPlayBuf = curFillBuf = curFillPos = curPlayPos = 0; 532 readPos = writePos = 0; 556 bytesPlayed = bytesCopied = bytesReturned = 0; 557 queuedbuffers = 0; 533 558 534 559 wmutex->leave(); … … 567 592 SetFS(selTIB); // switch back to the saved FS selector 568 593 } 594 569 595 return(MMSYSERR_NOERROR); 570 596 } … … 674 700 WAVEHDR *whdr, *prevhdr = NULL; 675 701 676 dprintf2(("WINMM: handler %d \n", curPlayBuf));702 dprintf2(("WINMM: handler %d; buffers left %d", curPlayBuf, queuedbuffers)); 677 703 if(ulFlags == MIX_STREAM_ERROR) { 678 704 if(ulStatus == ERROR_DEVICE_UNDERRUN) { … … 693 719 wmutex->enter(VMUTEX_WAIT_FOREVER); 694 720 695 readPos+= MixBuffer[curPlayBuf].ulBufferLength;721 bytesPlayed += MixBuffer[curPlayBuf].ulBufferLength; 696 722 697 723 if(curPlayBuf == PREFILLBUF_DART-1) … … 699 725 else curPlayBuf++; 700 726 727 fUnderrun = FALSE; 728 701 729 whdr = wavehdr; 702 if(whdr == NULL) {703 //last buffer played -> no new ones -> silence buffer & continue704 dprintf(("WINMM: WaveOut handler LAST BUFFER PLAYED! state %s", (State == STATE_PLAYING) ? "playing" : "stopped"));705 if(State == STATE_PLAYING) {706 fUnderrun = TRUE;707 //// memset(MixBuffer[curPlayBuf].pBuffer, 0, MixBuffer[curPlayBuf].ulBufferLength);708 goto sendbuffer;709 }710 wmutex->leave();711 return;712 }713 fUnderrun = FALSE;714 730 while(whdr) { 715 731 if(whdr->reserved == WHDR_DONE) 716 732 { 717 if( readPos < writePos+ whdr->dwBufferLength) {718 dprintf2(("Buffer marked done, but not yet played completely ( %d,%d)", readPos, writePos));733 if(bytesPlayed < bytesReturned + whdr->dwBufferLength) { 734 dprintf2(("Buffer marked done, but not yet played completely (play %d/%d, cop %d, ret %d)", bytesPlayed, getPosition(), bytesCopied, bytesReturned)); 719 735 break; //not yet done 720 736 } 721 737 722 dprintf2(("WINMM: handler buf %X done (read %d, write %d)", whdr, readPos, writePos)); 723 whdr->dwFlags &= ~WHDR_INQUEUE; 724 whdr->dwFlags |= WHDR_DONE; 738 dprintf2(("WINMM: handler buf %X done (play %d/%d, cop %d, ret %d)", whdr, bytesPlayed, getPosition(), bytesCopied, bytesReturned)); 739 queuedbuffers--; 740 741 whdr->dwFlags &= ~WHDR_INQUEUE; 742 whdr->dwFlags |= WHDR_DONE; 743 whdr->reserved = 0; 725 744 726 745 if(prevhdr == NULL) … … 730 749 whdr->lpNext = NULL; 731 750 732 writePos+= whdr->dwBufferLength;751 bytesReturned += whdr->dwBufferLength; 733 752 wmutex->leave(); 734 753 … … 750 769 } 751 770 771 if(wavehdr == NULL) { 772 //last buffer played -> no new ones -> silence buffer & continue 773 dprintf(("WINMM: WaveOut handler LAST BUFFER PLAYED! state %s (play %d (%d), cop %d, ret %d)", (State == STATE_PLAYING) ? "playing" : "stopped", bytesPlayed, getPosition(), bytesCopied, bytesReturned)); 774 if(State == STATE_PLAYING) { 775 fUnderrun = TRUE; 776 pause(); 777 //// memset(MixBuffer[curPlayBuf].pBuffer, 0, MixBuffer[curPlayBuf].ulBufferLength); 778 //// goto sendbuffer; 779 } 780 wmutex->leave(); 781 return; 782 } 783 752 784 writeBuffer(); 753 785 … … 760 792 MixSetupParms->pmixWrite(MixSetupParms->ulMixHandle, &MixBuffer[curPlayBuf], 1); 761 793 SetFS(selTIB); // switch back to the saved FS selector 794 795 dprintf2(("WINMM: handler DONE")); 762 796 } 763 797 /******************************************************************************/ … … 792 826 memcpy((char *)MixBuffer[curFillBuf].pBuffer + curPlayPos, 793 827 curhdr->lpData + curFillPos, buflength); 794 curPlayPos += buflength;795 curFillPos += buflength;796 828 curPlayPos += buflength; 829 curFillPos += buflength; 830 bytesCopied += buflength; 797 831 798 832 if(curFillPos == curhdr->dwBufferLength) { 799 dprintf2(("Buffer %d done (%x)", curFillBuf, curhdr)); 833 dprintf2(("Buffer %d done ptr %x size %d %x %x %x %x %x %x", curFillBuf, curhdr->lpData, curhdr->dwBufferLength, curhdr->dwBytesRecorded, curhdr->dwUser, curhdr->dwFlags, curhdr->dwLoops, curhdr->lpNext, curhdr->reserved)); 834 800 835 curFillPos = 0; 801 836 curhdr->reserved = WHDR_DONE; -
TabularUnified trunk/src/winmm/dwaveout.h ¶
r5334 r5348 1 /* $Id: dwaveout.h,v 1.1 1 2001-03-19 19:28:38sandervl Exp $ */1 /* $Id: dwaveout.h,v 1.12 2001-03-21 12:33:22 sandervl Exp $ */ 2 2 3 3 /* … … 85 85 int curPlayBuf, curFillBuf; 86 86 ULONG curFillPos, curPlayPos; //fillpos == pos in os2 mix buffer, bufpos == pos in win buffer 87 ULONG readPos, writePos; 87 ULONG bytesPlayed, bytesCopied, bytesReturned; 88 int queuedbuffers; 88 89 89 90 // callback interface -
TabularUnified trunk/src/winmm/time.cpp ¶
r2812 r5348 1 /* $Id: time.cpp,v 1. 9 2000-02-17 14:09:32 sandervl Exp $ */1 /* $Id: time.cpp,v 1.10 2001-03-21 12:33:22 sandervl Exp $ */ 2 2 3 3 /* … … 223 223 UINT, arg2) 224 224 { 225 dprintf2(("timeGetSystemTime %x %d", arg1, arg2)); 225 226 return O32_timeGetSystemTime(arg1, arg2); 226 227 } … … 241 242 DWORD WIN32API timeGetTime() 242 243 { 243 return O32_timeGetTime(); 244 } 245 244 DWORD time; 245 #if 0 246 LARGE_INTEGER lint; 247 static LARGE_INTEGER freq; 248 static BOOL fInit = FALSE; 249 250 if(fInit == FALSE) { 251 QueryPerformanceFrequency(&freq); 252 freq.LowPart /= 1000; 253 fInit = TRUE; 254 } 255 QueryPerformanceCounter(&lint); 256 time = lint.LowPart/freq.LowPart; 257 dprintf2(("timeGetTime %x (%x:%x)", time, lint.LowPart, lint.HighPart)); 258 #else 259 //SvL: TODO: Inaccurate 260 time = O32_timeGetTime(); 261 dprintf2(("timeGetTime %x", time)); 262 #endif 263 return time; 264 } 265 -
TabularUnified trunk/src/winmm/waveout.cpp ¶
r5334 r5348 1 /* $Id: waveout.cpp,v 1.1 8 2001-03-19 19:28:39sandervl Exp $ */1 /* $Id: waveout.cpp,v 1.19 2001-03-21 12:33:22 sandervl Exp $ */ 2 2 //#undef DEBUG 3 3 /* … … 108 108 pwh->dwFlags &= ~WHDR_DONE; 109 109 110 dprintf(("waveOutWrite %x %d %x", pwh->lpData, pwh->dwBufferLength, pwh->dwFlags));110 dprintf(("waveOutWrite ptr %x size %d %x %x %x %x %x %x", pwh->lpData, pwh->dwBufferLength, pwh->dwBytesRecorded, pwh->dwUser, pwh->dwFlags, pwh->dwLoops, pwh->lpNext, pwh->reserved)); 111 111 return(dwave->write(pwh, cbwh)); 112 112 }
Note:
See TracChangeset
for help on using the changeset viewer.