Changeset 57145 in vbox for trunk/src/VBox/Devices/Audio/DrvHostDSound.cpp
- Timestamp:
- Jul 31, 2015 4:01:58 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvHostDSound.cpp
r56648 r57145 68 68 typedef struct DSOUNDSTREAMOUT 69 69 { 70 PDMAUDIOHSTSTRMOUT hw; /* Always must come first! */71 LPDIRECTSOUND pDS;72 LPDIRECTSOUNDBUFFER pDSB;73 DWORD cbPlayWritePos;74 DWORD csPlaybackBufferSize;75 bool fReinitPlayPos;76 PDMAUDIOSTREAMCFG streamCfg;70 PDMAUDIOHSTSTRMOUT hw; /* Always must come first! */ 71 LPDIRECTSOUND8 pDS; 72 LPDIRECTSOUNDBUFFER8 pDSB; 73 DWORD cbPlayWritePos; 74 DWORD csPlaybackBufferSize; 75 bool fReinitPlayPos; 76 PDMAUDIOSTREAMCFG streamCfg; 77 77 } DSOUNDSTREAMOUT, *PDSOUNDSTREAMOUT; 78 78 79 79 typedef struct DSOUNDSTREAMIN 80 80 { 81 PDMAUDIOHSTSTRMIN hw; /* Always must come first! */82 LPDIRECTSOUNDCAPTURE pDSC;83 LPDIRECTSOUNDCAPTUREBUFFER pDSCB;84 DWORD csCaptureReadPos;85 DWORD csCaptureBufferSize;86 HRESULT hrLastCaptureIn;87 PDMAUDIORECSOURCE enmRecSource;88 PDMAUDIOSTREAMCFG streamCfg;81 PDMAUDIOHSTSTRMIN hw; /* Always must come first! */ 82 LPDIRECTSOUNDCAPTURE8 pDSC; 83 LPDIRECTSOUNDCAPTUREBUFFER8 pDSCB; 84 DWORD csCaptureReadPos; 85 DWORD csCaptureBufferSize; 86 HRESULT hrLastCaptureIn; 87 PDMAUDIORECSOURCE enmRecSource; 88 PDMAUDIOSTREAMCFG streamCfg; 89 89 } DSOUNDSTREAMIN, *PDSOUNDSTREAMIN; 90 90 … … 171 171 } 172 172 173 static int dsoundPlayRestore(LPDIRECTSOUNDBUFFER pDSB)174 { 175 HRESULT hr = IDirectSoundBuffer _Restore(pDSB);173 static int dsoundPlayRestore(LPDIRECTSOUNDBUFFER8 pDSB) 174 { 175 HRESULT hr = IDirectSoundBuffer8_Restore(pDSB); 176 176 if (SUCCEEDED(hr)) 177 177 return VINF_SUCCESS; … … 181 181 } 182 182 183 static int dsoundUnlockOutput(LPDIRECTSOUNDBUFFER pDSB,183 static int dsoundUnlockOutput(LPDIRECTSOUNDBUFFER8 pDSB, 184 184 LPVOID pv1, LPVOID pv2, 185 185 DWORD cb1, DWORD cb2) 186 186 { 187 HRESULT hr = IDirectSoundBuffer _Unlock(pDSB, pv1, cb1, pv2, cb2);187 HRESULT hr = IDirectSoundBuffer8_Unlock(pDSB, pv1, cb1, pv2, cb2); 188 188 if (SUCCEEDED(hr)) 189 189 return VINF_SUCCESS; … … 193 193 } 194 194 195 static int dsoundUnlockInput(LPDIRECTSOUNDCAPTUREBUFFER pDSCB,195 static int dsoundUnlockInput(LPDIRECTSOUNDCAPTUREBUFFER8 pDSCB, 196 196 LPVOID pv1, LPVOID pv2, 197 197 DWORD cb1, DWORD cb2) 198 198 { 199 HRESULT hr = IDirectSoundCaptureBuffer _Unlock(pDSCB, pv1, cb1, pv2, cb2);199 HRESULT hr = IDirectSoundCaptureBuffer8_Unlock(pDSCB, pv1, cb1, pv2, cb2); 200 200 if (SUCCEEDED(hr)) 201 201 return VINF_SUCCESS; … … 205 205 } 206 206 207 static int dsoundLockOutput(LPDIRECTSOUNDBUFFER pDSB, PDMPCMPROPS *pProps,207 static int dsoundLockOutput(LPDIRECTSOUNDBUFFER8 pDSB, PDMPCMPROPS *pProps, 208 208 DWORD dwOffset, DWORD dwBytes, 209 209 LPVOID *ppv1, LPVOID *ppv2, … … 218 218 DWORD cb2 = 0; 219 219 220 HRESULT hr = IDirectSoundBuffer _Lock(pDSB, dwOffset, dwBytes, &pv1, &cb1, &pv2, &cb2, dwFlags);220 HRESULT hr = IDirectSoundBuffer8_Lock(pDSB, dwOffset, dwBytes, &pv1, &cb1, &pv2, &cb2, dwFlags); 221 221 if (hr == DSERR_BUFFERLOST) 222 222 { … … 224 224 if (RT_SUCCESS(rc)) 225 225 { 226 hr = IDirectSoundBuffer _Lock(pDSB, dwOffset, dwBytes, &pv1, &cb1, &pv2, &cb2, dwFlags);226 hr = IDirectSoundBuffer8_Lock(pDSB, dwOffset, dwBytes, &pv1, &cb1, &pv2, &cb2, dwFlags); 227 227 } 228 228 } … … 250 250 } 251 251 252 static int dsoundLockInput(LPDIRECTSOUNDCAPTUREBUFFER pDSCB, PPDMPCMPROPS pProps,252 static int dsoundLockInput(LPDIRECTSOUNDCAPTUREBUFFER8 pDSCB, PPDMPCMPROPS pProps, 253 253 DWORD dwOffset, DWORD dwBytes, 254 254 LPVOID *ppv1, LPVOID *ppv2, … … 261 261 DWORD cb2 = 0; 262 262 263 HRESULT hr = IDirectSoundCaptureBuffer _Lock(pDSCB, dwOffset, dwBytes,264 &pv1, &cb1, &pv2, &cb2, dwFlags);263 HRESULT hr = IDirectSoundCaptureBuffer8_Lock(pDSCB, dwOffset, dwBytes, 264 &pv1, &cb1, &pv2, &cb2, dwFlags); 265 265 if (FAILED(hr)) 266 266 { … … 294 294 if (pDSoundStrmOut->pDS) 295 295 { 296 IDirectSound _Release(pDSoundStrmOut->pDS);296 IDirectSound8_Release(pDSoundStrmOut->pDS); 297 297 pDSoundStrmOut->pDS = NULL; 298 298 } … … 307 307 } 308 308 309 HRESULT hr = CoCreateInstance(CLSID_DirectSound , NULL, CLSCTX_ALL,310 IID_IDirectSound , (void **)&pDSoundStrmOut->pDS);309 HRESULT hr = CoCreateInstance(CLSID_DirectSound8, NULL, CLSCTX_ALL, 310 IID_IDirectSound8, (void **)&pDSoundStrmOut->pDS); 311 311 if (FAILED(hr)) 312 312 { … … 315 315 else 316 316 { 317 hr = IDirectSound _Initialize(pDSoundStrmOut->pDS, pThis->cfg.pGuidPlay);317 hr = IDirectSound8_Initialize(pDSoundStrmOut->pDS, pThis->cfg.pGuidPlay); 318 318 if (SUCCEEDED(hr)) 319 319 { 320 320 HWND hwnd = GetDesktopWindow(); 321 hr = IDirectSound _SetCooperativeLevel(pDSoundStrmOut->pDS, hwnd, DSSCL_PRIORITY);321 hr = IDirectSound8_SetCooperativeLevel(pDSoundStrmOut->pDS, hwnd, DSSCL_PRIORITY); 322 322 if (FAILED (hr)) 323 323 { … … 348 348 if (pDSoundStrmOut->pDSB) 349 349 { 350 HRESULT hr = IDirectSoundBuffer _Stop(pDSoundStrmOut->pDSB);350 HRESULT hr = IDirectSoundBuffer8_Stop(pDSoundStrmOut->pDSB); 351 351 if (FAILED(hr)) 352 352 { … … 354 354 } 355 355 356 IDirectSoundBuffer _Release(pDSoundStrmOut->pDSB);356 IDirectSoundBuffer8_Release(pDSoundStrmOut->pDSB); 357 357 pDSoundStrmOut->pDSB = NULL; 358 358 } … … 392 392 { 393 393 DSBUFFERDESC bd; 394 LPDIRECTSOUNDBUFFER pDSB; 394 395 RT_ZERO(bd); 395 396 bd.dwSize = sizeof(bd); … … 397 398 bd.dwFlags = DSBCAPS_GLOBALFOCUS | DSBCAPS_GETCURRENTPOSITION2; 398 399 bd.dwBufferBytes = pThis->cfg.cbBufferOut; 399 hr = IDirectSound _CreateSoundBuffer(pDSoundStrmOut->pDS,400 &bd, &pDS oundStrmOut->pDSB, NULL);400 hr = IDirectSound8_CreateSoundBuffer(pDSoundStrmOut->pDS, 401 &bd, &pDSB, NULL); 401 402 if (FAILED(hr)) 402 403 { … … 405 406 } 406 407 408 hr = IDirectSoundBuffer_QueryInterface(pDSB, IID_IDirectSoundBuffer8, (void **)&pDSoundStrmOut->pDSB); 409 pDSB->Release(); 410 if (FAILED(hr)) 411 { 412 DSLOGREL(("DSound: playback QueryInterface %Rhrc\n", hr)); 413 break; 414 } 415 407 416 /* Query the actual parameters. */ 408 417 409 hr = IDirectSoundBuffer _GetFormat(pDSoundStrmOut->pDSB, &wfx, sizeof(wfx), NULL);418 hr = IDirectSoundBuffer8_GetFormat(pDSoundStrmOut->pDSB, &wfx, sizeof(wfx), NULL); 410 419 if (FAILED(hr)) 411 420 { … … 417 426 RT_ZERO(bc); 418 427 bc.dwSize = sizeof(bc); 419 hr = IDirectSoundBuffer _GetCaps(pDSoundStrmOut->pDSB, &bc);428 hr = IDirectSoundBuffer8_GetCaps(pDSoundStrmOut->pDSB, &bc); 420 429 if (FAILED(hr)) 421 430 { … … 490 499 } 491 500 492 static int dsoundPlayGetStatus(LPDIRECTSOUNDBUFFER pDSB, DWORD *pStatus)501 static int dsoundPlayGetStatus(LPDIRECTSOUNDBUFFER8 pDSB, DWORD *pStatus) 493 502 { 494 503 int rc = VINF_SUCCESS; 495 504 496 505 DWORD dwStatus = 0; 497 HRESULT hr = IDirectSoundBuffer _GetStatus(pDSB, &dwStatus);506 HRESULT hr = IDirectSoundBuffer8_GetStatus(pDSB, &dwStatus); 498 507 if (SUCCEEDED(hr)) 499 508 { … … 503 512 if (RT_SUCCESS(rc)) 504 513 { 505 hr = IDirectSoundBuffer _GetStatus(pDSB, &dwStatus);514 hr = IDirectSoundBuffer8_GetStatus(pDSB, &dwStatus); 506 515 } 507 516 } … … 535 544 DSLOG(("DSound: playback stop\n")); 536 545 537 HRESULT hr = IDirectSoundBuffer _Stop(pDSoundStrmOut->pDSB);546 HRESULT hr = IDirectSoundBuffer8_Stop(pDSoundStrmOut->pDSB); 538 547 if (FAILED(hr)) 539 548 { … … 569 578 DSLOG(("DSound: playback start\n")); 570 579 571 HRESULT hr = IDirectSoundBuffer _Play(pDSoundStrmOut->pDSB, 0, 0, DSBPLAY_LOOPING);580 HRESULT hr = IDirectSoundBuffer8_Play(pDSoundStrmOut->pDSB, 0, 0, DSBPLAY_LOOPING); 572 581 if (FAILED(hr)) 573 582 { … … 631 640 if (pDSoundStrmIn->pDSC) 632 641 { 633 IDirectSoundCapture _Release(pDSoundStrmIn->pDSC);642 IDirectSoundCapture8_Release(pDSoundStrmIn->pDSC); 634 643 pDSoundStrmIn->pDSC = NULL; 635 644 } … … 644 653 } 645 654 646 HRESULT hr = CoCreateInstance(CLSID_DirectSoundCapture , NULL, CLSCTX_ALL,647 IID_IDirectSoundCapture , (void **)&pDSoundStrmIn->pDSC);655 HRESULT hr = CoCreateInstance(CLSID_DirectSoundCapture8, NULL, CLSCTX_ALL, 656 IID_IDirectSoundCapture8, (void **)&pDSoundStrmIn->pDSC); 648 657 if (FAILED(hr)) 649 658 { … … 653 662 { 654 663 LPCGUID pGUID = dsoundCaptureSelectDevice(pThis, pDSoundStrmIn); 655 hr = IDirectSoundCapture _Initialize(pDSoundStrmIn->pDSC, pGUID);664 hr = IDirectSoundCapture8_Initialize(pDSoundStrmIn->pDSC, pGUID); 656 665 if (FAILED(hr)) 657 666 { … … 677 686 if (pDSoundStrmIn->pDSCB) 678 687 { 679 HRESULT hr = IDirectSoundCaptureBuffer _Stop(pDSoundStrmIn->pDSCB);688 HRESULT hr = IDirectSoundCaptureBuffer8_Stop(pDSoundStrmIn->pDSCB); 680 689 if (FAILED (hr)) 681 690 { … … 683 692 } 684 693 685 IDirectSoundCaptureBuffer _Release(pDSoundStrmIn->pDSCB);694 IDirectSoundCaptureBuffer8_Release(pDSoundStrmIn->pDSCB); 686 695 pDSoundStrmIn->pDSCB = NULL; 687 696 } … … 721 730 { 722 731 DSCBUFFERDESC bd; 732 LPDIRECTSOUNDCAPTUREBUFFER pDSCB = NULL; 723 733 RT_ZERO(bd); 724 734 bd.dwSize = sizeof(bd); 725 735 bd.lpwfxFormat = &wfx; 726 736 bd.dwBufferBytes = pThis->cfg.cbBufferIn; 727 hr = IDirectSoundCapture _CreateCaptureBuffer(pDSoundStrmIn->pDSC,728 &bd, &pDSoundStrmIn->pDSCB, NULL);737 hr = IDirectSoundCapture8_CreateCaptureBuffer(pDSoundStrmIn->pDSC, 738 &bd, &pDSCB, NULL); 729 739 730 740 if (FAILED(hr)) … … 735 745 } 736 746 747 hr = IDirectSoundCaptureBuffer_QueryInterface(pDSCB, IID_IDirectSoundCaptureBuffer8, (void **)&pDSCB); 748 IDirectSoundCaputreBuffer_Release(pDSCB); 749 if (FAILED(hr)) 750 { 751 DSLOGREL(("DSound: querying capture buffer %Rhrc\n", hr)); 752 break; 753 } 754 737 755 /* Query the actual parameters. */ 738 756 739 757 DWORD cbReadPos = 0; 740 hr = IDirectSoundCaptureBuffer _GetCurrentPosition(pDSoundStrmIn->pDSCB, NULL, &cbReadPos);758 hr = IDirectSoundCaptureBuffer8_GetCurrentPosition(pDSoundStrmIn->pDSCB, NULL, &cbReadPos); 741 759 if (FAILED(hr)) 742 760 { … … 746 764 747 765 RT_ZERO(wfx); 748 hr = IDirectSoundCaptureBuffer _GetFormat(pDSoundStrmIn->pDSCB, &wfx, sizeof(wfx), NULL);766 hr = IDirectSoundCaptureBuffer8_GetFormat(pDSoundStrmIn->pDSCB, &wfx, sizeof(wfx), NULL); 749 767 if (FAILED(hr)) 750 768 { … … 756 774 RT_ZERO(bc); 757 775 bc.dwSize = sizeof(bc); 758 hr = IDirectSoundCaptureBuffer _GetCaps(pDSoundStrmIn->pDSCB, &bc);776 hr = IDirectSoundCaptureBuffer8_GetCaps(pDSoundStrmIn->pDSCB, &bc); 759 777 if (FAILED (hr)) 760 778 { … … 814 832 DSLOG(("DSound: capture stop\n")); 815 833 816 HRESULT hr = IDirectSoundCaptureBuffer _Stop(pDSoundStrmIn->pDSCB);834 HRESULT hr = IDirectSoundCaptureBuffer8_Stop(pDSoundStrmIn->pDSCB); 817 835 if (FAILED(hr)) 818 836 { … … 829 847 { 830 848 DWORD dwStatus; 831 hr = IDirectSoundCaptureBuffer _GetStatus(pDSoundStrmIn->pDSCB, &dwStatus);849 hr = IDirectSoundCaptureBuffer8_GetStatus(pDSoundStrmIn->pDSCB, &dwStatus); 832 850 if (FAILED(hr)) 833 851 { … … 844 862 DSLOG(("DSound: capture start\n")); 845 863 846 hr = IDirectSoundCaptureBuffer _Start(pDSoundStrmIn->pDSCB, DSCBSTART_LOOPING);864 hr = IDirectSoundCaptureBuffer8_Start(pDSoundStrmIn->pDSCB, DSCBSTART_LOOPING); 847 865 if (FAILED (hr)) 848 866 { … … 1059 1077 PDRVHOSTDSOUND pThis = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface); 1060 1078 PDSOUNDSTREAMOUT pDSoundStrmOut = (PDSOUNDSTREAMOUT)pHstStrmOut; 1061 LPDIRECTSOUNDBUFFER pDSB = pDSoundStrmOut->pDSB;1079 LPDIRECTSOUNDBUFFER8 pDSB = pDSoundStrmOut->pDSB; 1062 1080 1063 1081 int rc = VINF_SUCCESS; … … 1074 1092 1075 1093 DWORD cbPlayPos, cbWritePos; 1076 HRESULT hr = IDirectSoundBuffer _GetCurrentPosition(pDSB, &cbPlayPos, &cbWritePos);1094 HRESULT hr = IDirectSoundBuffer8_GetCurrentPosition(pDSB, &cbPlayPos, &cbWritePos); 1077 1095 if (hr == DSERR_BUFFERLOST) 1078 1096 { … … 1085 1103 } 1086 1104 1087 hr = IDirectSoundBuffer _GetCurrentPosition(pDSB, &cbPlayPos, &cbWritePos);1105 hr = IDirectSoundBuffer8_GetCurrentPosition(pDSB, &cbPlayPos, &cbWritePos); 1088 1106 if (hr == DSERR_BUFFERLOST) 1089 1107 {
Note:
See TracChangeset
for help on using the changeset viewer.