Changeset 62909 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Aug 3, 2016 12:11:48 PM (8 years ago)
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/AudioMixBuffer.cpp
r62372 r62909 1362 1362 * @param pcRead Number of audio samples read. Optional. 1363 1363 */ 1364 int AudioMixBufReadCirc(PPDMAUDIOMIXBUF pMixBuf, 1365 void *pvBuf, uint32_t cbBuf, uint32_t *pcRead) 1366 { 1367 return AudioMixBufReadCircEx(pMixBuf, pMixBuf->AudioFmt, 1368 pvBuf, cbBuf, pcRead); 1364 int AudioMixBufReadCirc(PPDMAUDIOMIXBUF pMixBuf, void *pvBuf, uint32_t cbBuf, uint32_t *pcRead) 1365 { 1366 return AudioMixBufReadCircEx(pMixBuf, pMixBuf->AudioFmt, pvBuf, cbBuf, pcRead); 1369 1367 } 1370 1368 … … 1381 1379 * @param pcRead Number of audio samples read. Optional. 1382 1380 */ 1383 int AudioMixBufReadCircEx(PPDMAUDIOMIXBUF pMixBuf, PDMAUDIOMIXBUFFMT enmFmt, 1384 void *pvBuf, uint32_t cbBuf, uint32_t *pcRead) 1381 int AudioMixBufReadCircEx(PPDMAUDIOMIXBUF pMixBuf, PDMAUDIOMIXBUFFMT enmFmt, void *pvBuf, uint32_t cbBuf, uint32_t *pcRead) 1385 1382 { 1386 1383 AssertPtrReturn(pMixBuf, VERR_INVALID_POINTER); -
trunk/src/VBox/Devices/Audio/AudioMixBuffer.h
r61609 r62909 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox audio: Mixing buffer to convert audio samples to/from different 4 * rates / formats. 3 * VBox audio - Mixing buffer to convert audio samples to/from different rates / formats. 5 4 */ 6 5 … … 82 81 #endif 83 82 84 #endif /* AUDIO_MIXBUF_H */83 #endif 85 84 -
trunk/src/VBox/Devices/Audio/DrvHostDSound.cpp
r62463 r62909 14 14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the 15 15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 16 * --------------------------------------------------------------------17 16 * 18 17 */ 18 19 20 /********************************************************************************************************************************* 21 * Header Files * 22 *********************************************************************************************************************************/ 19 23 #define LOG_GROUP LOG_GROUP_DRV_HOST_AUDIO 20 24 #include <VBox/log.h> 25 #include <iprt/win/windows.h> 21 26 #include <dsound.h> 22 27 … … 28 33 #include "VBoxDD.h" 29 34 35 36 /********************************************************************************************************************************* 37 * Defined Constants And Macros * 38 *********************************************************************************************************************************/ 30 39 /* 31 40 * IDirectSound* interface uses HRESULT status codes and the driver callbacks use … … 45 54 */ 46 55 /* General code behavior. */ 47 #define DSLOG(a) do { LogRel2(a); } while(0)56 #define DSLOG(a) do { LogRel2(a); } while(0) 48 57 /* Something which produce a lot of logging during playback/recording. */ 49 #define DSLOGF(a) do { LogRel3(a); } while(0)58 #define DSLOGF(a) do { LogRel3(a); } while(0) 50 59 /* Important messages like errors. Limited in the default release log to avoid log flood. */ 51 #define DSLOGREL(a) \ 52 do { \ 53 static int8_t scLogged = 0; \ 54 if (scLogged < 8) { \ 55 ++scLogged; \ 56 LogRel(a); \ 57 } \ 58 else { \ 59 DSLOG(a); \ 60 } \ 60 #define DSLOGREL(a) \ 61 do { \ 62 static int8_t s_cLogged = 0; \ 63 if (s_cLogged < 8) { \ 64 ++s_cLogged; \ 65 LogRel(a); \ 66 } else DSLOG(a); \ 61 67 } while (0) 62 68 69 70 /** Maximum number of attempts to restore the sound buffer before giving up. */ 71 #define DRV_DSOUND_RESTORE_ATTEMPTS_MAX 3 72 73 /** Makes DRVHOSTDSOUND out of PDMIHOSTAUDIO. */ 74 #define PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface) \ 75 ( (PDRVHOSTDSOUND)((uintptr_t)pInterface - RT_OFFSETOF(DRVHOSTDSOUND, IHostAudio)) ) 76 77 78 /********************************************************************************************************************************* 79 * Structures and Typedefs * 80 *********************************************************************************************************************************/ 63 81 /* Dynamically load dsound.dll. */ 64 typedef HRESULT WINAPI FNDIRECTSOUNDENUMERATEW(LPDSENUMCALLBACKW pDSEnumCallback, LPVOID pContext);82 typedef HRESULT WINAPI FNDIRECTSOUNDENUMERATEW(LPDSENUMCALLBACKW pDSEnumCallback, PVOID pContext); 65 83 typedef FNDIRECTSOUNDENUMERATEW *PFNDIRECTSOUNDENUMERATEW; 66 typedef HRESULT WINAPI FNDIRECTSOUNDCAPTUREENUMERATEW(LPDSENUMCALLBACKW pDSEnumCallback, LPVOID pContext);84 typedef HRESULT WINAPI FNDIRECTSOUNDCAPTUREENUMERATEW(LPDSENUMCALLBACKW pDSEnumCallback, PVOID pContext); 67 85 typedef FNDIRECTSOUNDCAPTUREENUMERATEW *PFNDIRECTSOUNDCAPTUREENUMERATEW; 68 86 … … 95 113 LPDIRECTSOUND8 pDS; /** @todo Move this out of this structure! Not required per-stream (e.g. for multi-channel). */ 96 114 LPDIRECTSOUNDBUFFER8 pDSB; 97 DWORD cbPlayWritePos;98 DWORD c sPlaybackBufferSize;115 DWORD offPlayWritePos; 116 DWORD cMaxSamplesInBuffer; 99 117 bool fEnabled; 100 118 bool fRestartPlayback; … … 183 201 184 202 /********************************************************************************************************************************* 185 * Defines*203 * Internal Functions * 186 204 *********************************************************************************************************************************/ 187 188 /** Maximum number of attempts to restore the sound buffer before giving up. */ 189 #define DRV_DSOUND_RESTORE_ATTEMPTS_MAX 3 190 191 /** Makes DRVHOSTDSOUND out of PDMIHOSTAUDIO. */ 192 #define PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface) \ 193 ( (PDRVHOSTDSOUND)((uintptr_t)pInterface - RT_OFFSETOF(DRVHOSTDSOUND, IHostAudio)) ) 194 195 196 /********************************************************************************************************************************* 197 * Prototypes * 198 *********************************************************************************************************************************/ 199 200 static HRESULT directSoundPlayRestore(PDRVHOSTDSOUND pThis, LPDIRECTSOUNDBUFFER8 pDSB); 201 202 static void dsoundDeviceRemove(PDSOUNDDEV pDev); 203 static int dsoundDevicesEnumerate(PDRVHOSTDSOUND pThis, PPDMAUDIOBACKENDCFG pCfg); 205 static HRESULT directSoundPlayRestore(PDRVHOSTDSOUND pThis, LPDIRECTSOUNDBUFFER8 pDSB); 206 static void dsoundDeviceRemove(PDSOUNDDEV pDev); 207 static int dsoundDevicesEnumerate(PDRVHOSTDSOUND pThis, PPDMAUDIOBACKENDCFG pCfg); 204 208 #ifdef VBOX_WITH_AUDIO_CALLBACKS 205 static int dsoundNotifyThread(PDRVHOSTDSOUND pThis, bool fShutdown);209 static int dsoundNotifyThread(PDRVHOSTDSOUND pThis, bool fShutdown); 206 210 #endif 211 212 207 213 208 214 static DWORD dsoundRingDistance(DWORD offEnd, DWORD offBegin, DWORD cSize) … … 259 265 AssertPtrReturn(pThis, VERR_INVALID_POINTER); 260 266 AssertPtrReturn(pDSoundStream, VERR_INVALID_POINTER); 261 /* pdwBuffer is optional. */262 /* pdwFree is optional. */263 /* pdwPlayPos is optional. */267 AssertPtrNull(pdwBuffer); 268 AssertPtrNull(pdwFree); 269 AssertPtrNull(pdwPlayPos); 264 270 265 271 LPDIRECTSOUNDBUFFER8 pDSB = pDSoundStream->pDSB; … … 267 273 return VERR_INVALID_POINTER; 268 274 269 DWORD cbBuffer = AUDIOMIXBUF_S2B(&pDSoundStream->Stream.MixBuf, pDSoundStream->csPlaybackBufferSize);270 271 275 /* Get the current play position which is used for calculating the free space in the buffer. */ 272 276 DWORD cbPlayPos; 273 274 HRESULT hr; 277 HRESULT hr = E_FAIL; 275 278 for (unsigned i = 0; i < DRV_DSOUND_RESTORE_ATTEMPTS_MAX; i++) 276 279 { 277 280 hr = IDirectSoundBuffer8_GetCurrentPosition(pDSB, &cbPlayPos, NULL); 278 if ( SUCCEEDED(hr) 279 || hr != DSERR_BUFFERLOST) /** @todo: MSDN doesn't state this error for GetCurrentPosition(). */ 280 { 281 break; 282 } 283 else 284 { 285 LogFlowFunc(("Getting playing position failed due to lost buffer, restoring ...\n")); 286 directSoundPlayRestore(pThis, pDSB); 287 } 288 } 289 290 int rc = VINF_SUCCESS; 291 292 if (FAILED(hr)) 293 { 294 if (hr != DSERR_BUFFERLOST) /* Avoid log flooding if the error is still there. */ 295 DSLOGREL(("DSound: Getting current playback position failed with %Rhrc\n", hr)); 296 LogFlowFunc(("Failed with %Rhrc\n", hr)); 297 298 rc = VERR_NOT_AVAILABLE; 299 } 300 else 301 { 302 if (pdwBuffer) 303 *pdwBuffer = cbBuffer; 304 305 if (pdwFree) 306 *pdwFree = cbBuffer - dsoundRingDistance(pDSoundStream->cbPlayWritePos, cbPlayPos, cbBuffer); 307 308 if (pdwPlayPos) 309 *pdwPlayPos = cbPlayPos; 310 } 311 312 if (RT_FAILURE(rc)) 313 LogFlowFuncLeaveRC(rc); 281 if (SUCCEEDED(hr)) 282 { 283 DWORD const cbBuffer = AUDIOMIXBUF_S2B(&pDSoundStream->Stream.MixBuf, pDSoundStream->cMaxSamplesInBuffer); 284 if (pdwBuffer) 285 *pdwBuffer = cbBuffer; 286 if (pdwFree) 287 *pdwFree = cbBuffer - dsoundRingDistance(pDSoundStream->offPlayWritePos, cbPlayPos, cbBuffer); 288 if (pdwPlayPos) 289 *pdwPlayPos = cbPlayPos; 290 return VINF_SUCCESS; 291 } 292 if (hr != DSERR_BUFFERLOST) /** @todo MSDN doesn't state this error for GetCurrentPosition(). */ 293 break; 294 LogFlowFunc(("Getting playing position failed due to lost buffer, restoring ...\n")); 295 directSoundPlayRestore(pThis, pDSB); 296 } 297 298 if (hr != DSERR_BUFFERLOST) /* Avoid log flooding if the error is still there. */ 299 DSLOGREL(("DSound: Getting current playback position failed with %Rhrc\n", hr)); 300 LogFlowFunc(("Failed with %Rhrc\n", hr)); 301 302 int rc = VERR_NOT_AVAILABLE; 303 LogFlowFuncLeaveRC(rc); 314 304 return rc; 315 305 } … … 359 349 static HRESULT directSoundPlayRestore(PDRVHOSTDSOUND pThis, LPDIRECTSOUNDBUFFER8 pDSB) 360 350 { 351 RT_NOREF(pThis); 361 352 HRESULT hr = IDirectSoundBuffer8_Restore(pDSB); 362 353 if (FAILED(hr)) … … 366 357 367 358 static HRESULT directSoundPlayUnlock(PDRVHOSTDSOUND pThis, LPDIRECTSOUNDBUFFER8 pDSB, 368 LPVOID pv1, LPVOID pv2,359 PVOID pv1, PVOID pv2, 369 360 DWORD cb1, DWORD cb2) 370 361 { 362 RT_NOREF(pThis); 371 363 HRESULT hr = IDirectSoundBuffer8_Unlock(pDSB, pv1, cb1, pv2, cb2); 372 364 if (FAILED(hr)) … … 376 368 377 369 static HRESULT directSoundCaptureUnlock(LPDIRECTSOUNDCAPTUREBUFFER8 pDSCB, 378 LPVOID pv1, LPVOID pv2,370 PVOID pv1, PVOID pv2, 379 371 DWORD cb1, DWORD cb2) 380 372 { … … 388 380 LPDIRECTSOUNDBUFFER8 pDSB, PDMPCMPROPS *pProps, 389 381 DWORD dwOffset, DWORD dwBytes, 390 LPVOID *ppv1, LPVOID *ppv2,382 PVOID *ppv1, PVOID *ppv2, 391 383 DWORD *pcb1, DWORD *pcb2, 392 384 DWORD dwFlags) 393 385 { 394 LPVOID pv1 = NULL; 395 LPVOID pv2 = NULL; 396 DWORD cb1 = 0; 397 DWORD cb2 = 0; 398 399 HRESULT hr; 386 HRESULT hr = E_FAIL; 387 AssertCompile(DRV_DSOUND_RESTORE_ATTEMPTS_MAX > 0); 400 388 for (unsigned i = 0; i < DRV_DSOUND_RESTORE_ATTEMPTS_MAX; i++) 401 389 { 402 hr = IDirectSoundBuffer8_Lock(pDSB, dwOffset, dwBytes, &pv1, &cb1, &pv2, &cb2, dwFlags); 403 if ( SUCCEEDED(hr) 404 || hr != DSERR_BUFFERLOST) 405 break; 406 else 407 { 408 LogFlowFunc(("Locking failed due to lost buffer, restoring ...\n")); 409 directSoundPlayRestore(pThis, pDSB); 410 } 411 } 412 413 if (FAILED(hr)) 414 { 415 DSLOGREL(("DSound: Locking playback buffer failed with %Rhrc\n", hr)); 416 return hr; 417 } 418 419 if ( (pv1 && (cb1 & pProps->uAlign)) 420 || (pv2 && (cb2 & pProps->uAlign))) 421 { 422 DSLOGREL(("DSound: Locking playback buffer returned misaligned buffer: cb1=%RI32, cb2=%RI32 (alignment: %RU32)\n", 423 cb1, cb2, pProps->uAlign)); 424 directSoundPlayUnlock(pThis, pDSB, pv1, pv2, cb1, cb2); 425 return E_FAIL; 426 } 427 428 *ppv1 = pv1; 429 *ppv2 = pv2; 430 *pcb1 = cb1; 431 *pcb2 = cb2; 432 433 return S_OK; 390 *ppv1 = *ppv2 = NULL; 391 *pcb1 = *pcb2 = 0; 392 hr = IDirectSoundBuffer8_Lock(pDSB, dwOffset, dwBytes, ppv1, pcb1, ppv2, pcb2, dwFlags); 393 if (SUCCEEDED(hr)) 394 { 395 if ( (!*ppv1 || !(*pcb1 & pProps->uAlign)) 396 && (!*ppv2 || !(*pcb2 & pProps->uAlign)) ) 397 return S_OK; 398 DSLOGREL(("DSound: Locking playback buffer returned misaligned buffer: cb1=%#RX32, cb2=%#RX32 (alignment: %#RX32)\n", 399 *pcb1, *pcb2, pProps->uAlign)); 400 directSoundPlayUnlock(pThis, pDSB, *ppv1, *ppv2, *pcb1, *pcb2); 401 return E_FAIL; 402 } 403 404 if (hr != DSERR_BUFFERLOST) 405 break; 406 407 LogFlowFunc(("Locking failed due to lost buffer, restoring ...\n")); 408 directSoundPlayRestore(pThis, pDSB); 409 } 410 411 DSLOGREL(("DSound: Locking playback buffer failed with %Rhrc\n", hr)); 412 return hr; 434 413 } 435 414 436 415 static HRESULT directSoundCaptureLock(LPDIRECTSOUNDCAPTUREBUFFER8 pDSCB, PPDMPCMPROPS pProps, 437 416 DWORD dwOffset, DWORD dwBytes, 438 LPVOID *ppv1, LPVOID *ppv2,417 PVOID *ppv1, PVOID *ppv2, 439 418 DWORD *pcb1, DWORD *pcb2, 440 419 DWORD dwFlags) 441 420 { 442 LPVOID pv1 = NULL;443 LPVOID pv2 = NULL;421 PVOID pv1 = NULL; 422 PVOID pv2 = NULL; 444 423 DWORD cb1 = 0; 445 424 DWORD cb2 = 0; … … 628 607 629 608 /* "Upgrade" to IDirectSoundBuffer8 interface. */ 630 hr = IDirectSoundBuffer_QueryInterface(pDSB, IID_IDirectSoundBuffer8, ( LPVOID *)&pDSoundStream->pDSB);609 hr = IDirectSoundBuffer_QueryInterface(pDSB, IID_IDirectSoundBuffer8, (PVOID *)&pDSoundStream->pDSB); 631 610 IDirectSoundBuffer_Release(pDSB); 632 611 if (FAILED(hr)) … … 689 668 * playback buffer position. 690 669 */ 691 pDSoundStream->c sPlaybackBufferSize= bc.dwBufferBytes >> pDSoundStream->Stream.Props.cShift;692 DSLOG(("DSound: c sPlaybackBufferSize=%RU32\n", pDSoundStream->csPlaybackBufferSize));670 pDSoundStream->cMaxSamplesInBuffer = bc.dwBufferBytes >> pDSoundStream->Stream.Props.cShift; 671 DSLOG(("DSound: cMaxSamplesInBuffer=%RU32\n", pDSoundStream->cMaxSamplesInBuffer)); 693 672 694 673 #ifdef VBOX_WITH_AUDIO_CALLBACKS … … 707 686 708 687 LPDIRECTSOUNDNOTIFY8 pNotify; 709 hr = IDirectSoundNotify_QueryInterface(pDSoundStream->pDSB, IID_IDirectSoundNotify8, ( LPVOID *)&pNotify);688 hr = IDirectSoundNotify_QueryInterface(pDSoundStream->pDSB, IID_IDirectSoundNotify8, (PVOID *)&pNotify); 710 689 if (SUCCEEDED(hr)) 711 690 { … … 754 733 PPDMAUDIOSTREAM pStream = &pDSoundStream->Stream; 755 734 756 LPVOID pv1, pv2;735 PVOID pv1, pv2; 757 736 DWORD cb1, cb2; 758 737 HRESULT hr = directSoundPlayLock(pThis, pDSoundStream->pDSB, &pDSoundStream->Stream.Props, 759 0 /* dwOffset */, AUDIOMIXBUF_S2B(&pStream->MixBuf, pDSoundStream->c sPlaybackBufferSize),738 0 /* dwOffset */, AUDIOMIXBUF_S2B(&pStream->MixBuf, pDSoundStream->cMaxSamplesInBuffer), 760 739 &pv1, &pv2, &cb1, &cb2, DSBLOCK_ENTIREBUFFER); 761 740 if (SUCCEEDED(hr)) … … 778 757 AssertPtrReturn(pThis, E_POINTER); 779 758 AssertPtrReturn(pDSB, E_POINTER); 780 /* pdwStatus is optional. */759 AssertPtrNull(pdwStatus); 781 760 782 761 DWORD dwStatus = 0; 783 784 HRESULT hr; 762 HRESULT hr = E_FAIL; 785 763 for (unsigned i = 0; i < DRV_DSOUND_RESTORE_ATTEMPTS_MAX; i++) 786 764 { … … 1282 1260 1283 1261 static BOOL CALLBACK dsoundDevicesEnumCbPlayback(LPGUID lpGUID, LPCWSTR lpwstrDescription, 1284 LPCWSTR lpwstrModule, LPVOID lpContext)1262 LPCWSTR lpwstrModule, PVOID lpContext) 1285 1263 { 1286 1264 PDSOUNDENUMCBCTX pCtx = (PDSOUNDENUMCBCTX)lpContext; … … 1308 1286 1309 1287 static BOOL CALLBACK dsoundDevicesEnumCbCapture(LPGUID lpGUID, LPCWSTR lpwstrDescription, 1310 LPCWSTR lpwstrModule, LPVOID lpContext)1288 LPCWSTR lpwstrModule, PVOID lpContext) 1311 1289 { 1312 1290 PDSOUNDENUMCBCTX pCtx = (PDSOUNDENUMCBCTX)lpContext; … … 1458 1436 pDSoundStream->pDS = NULL; 1459 1437 pDSoundStream->pDSB = NULL; 1460 pDSoundStream-> cbPlayWritePos = 0;1438 pDSoundStream->offPlayWritePos = 0; 1461 1439 pDSoundStream->fRestartPlayback = true; 1462 pDSoundStream->c sPlaybackBufferSize= 0;1440 pDSoundStream->cMaxSamplesInBuffer = 0; 1463 1441 1464 1442 if (pcSamples) … … 1560 1538 1561 1539 /* 1562 * Check for full buffer, do not allow the cbPlayWritePos to catch cbPlayPos during playback,1540 * Check for full buffer, do not allow the offPlayWritePos to catch cbPlayPos during playback, 1563 1541 * i.e. always leave a free space for 1 audio sample. 1564 1542 */ … … 1573 1551 /* Do not write more than available space in the DirectSound playback buffer. */ 1574 1552 cbLive = RT_MIN(cbFree, cbLive); 1575 1576 1553 cbLive &= ~pStream->Props.uAlign; 1577 1554 if (cbLive == 0 || cbLive > cbBuffer) 1578 1555 { 1579 DSLOG(("DSound: cbLive=%RU32, cbBuffer=%ld, cbPlayWritePos=%ld, cbPlayPos=%ld\n",1580 cbLive, cbBuffer, pDSoundStream-> cbPlayWritePos, cbPlayPos));1556 DSLOG(("DSound: cbLive=%RU32, cbBuffer=%ld, offPlayWritePos=%ld, cbPlayPos=%ld\n", 1557 cbLive, cbBuffer, pDSoundStream->offPlayWritePos, cbPlayPos)); 1581 1558 break; 1582 1559 } … … 1585 1562 AssertPtr(pDSB); 1586 1563 1587 LPVOID pv1, pv2;1564 PVOID pv1, pv2; 1588 1565 DWORD cb1, cb2; 1589 HRESULT hr = directSoundPlayLock(pThis, pDSB, &pStream->Props, pDSoundStream-> cbPlayWritePos, cbLive,1566 HRESULT hr = directSoundPlayLock(pThis, pDSB, &pStream->Props, pDSoundStream->offPlayWritePos, cbLive, 1590 1567 &pv1, &pv2, &cb1, &cb2, 0 /* dwFlags */); 1591 1568 if (FAILED(hr)) … … 1595 1572 } 1596 1573 1597 DWORD len1 = AUDIOMIXBUF_B2S(&pStream->MixBuf, cb1); 1598 DWORD len2 = AUDIOMIXBUF_B2S(&pStream->MixBuf, cb2); 1599 1574 /** @todo r=bird: Can pv1/cb1 really be NULL? Docs says they're always set 1575 * and pv2/cb2 only used when there is a buffer wrap araound. */ 1576 1577 DWORD cSamplesIn1 = AUDIOMIXBUF_B2S(&pStream->MixBuf, cb1); 1600 1578 uint32_t cRead = 0; 1601 1579 … … 1608 1586 1609 1587 if ( RT_SUCCESS(rc) 1610 && cReadTotal == len11588 && cReadTotal == cSamplesIn1 1611 1589 && pv2 && cb2) 1612 1590 { … … 1618 1596 directSoundPlayUnlock(pThis, pDSB, pv1, pv2, cb1, cb2); 1619 1597 1620 pDSoundStream-> cbPlayWritePos =1621 (pDSoundStream->cbPlayWritePos + AUDIOMIXBUF_S2B(&pStream->MixBuf, cReadTotal))% cbBuffer;1598 pDSoundStream->offPlayWritePos = (pDSoundStream->offPlayWritePos + AUDIOMIXBUF_S2B(&pStream->MixBuf, cReadTotal)) 1599 % cbBuffer; 1622 1600 1623 1601 DSLOGF(("DSound: %RU32 (%RU32 samples) out of %RU32%s, buffer write pos %ld, rc=%Rrc\n", 1624 1602 AUDIOMIXBUF_S2B(&pStream->MixBuf, cReadTotal), cReadTotal, cbLive, 1625 1603 cbLive != AUDIOMIXBUF_S2B(&pStream->MixBuf, cReadTotal) ? " !!!": "", 1626 pDSoundStream-> cbPlayWritePos, rc));1604 pDSoundStream->offPlayWritePos, rc)); 1627 1605 1628 1606 if (cReadTotal) … … 1672 1650 1673 1651 if (RT_FAILURE(rc)) 1674 {1675 1652 dsoundUpdateStatusInternal(pThis); 1676 } 1677 else 1678 { 1679 if (pcSamplesPlayed) 1680 *pcSamplesPlayed = cReadTotal; 1681 } 1653 else if (pcSamplesPlayed) 1654 *pcSamplesPlayed = cReadTotal; 1682 1655 1683 1656 LogFlowFuncLeaveRC(rc); … … 1692 1665 directSoundPlayClose(pThis, pDSoundStream); 1693 1666 1694 pDSoundStream-> cbPlayWritePos= 0;1667 pDSoundStream->offPlayWritePos = 0; 1695 1668 pDSoundStream->fRestartPlayback = true; 1696 pDSoundStream->c sPlaybackBufferSize= 0;1669 pDSoundStream->cMaxSamplesInBuffer = 0; 1697 1670 1698 1671 RT_ZERO(pDSoundStream->streamCfg); … … 1862 1835 1863 1836 /* Lock relevant range in the DirectSound capture buffer. */ 1864 LPVOID pv1, pv2;1837 PVOID pv1, pv2; 1865 1838 DWORD cb1, cb2; 1866 1839 hr = directSoundCaptureLock(pDSCB, &pStream->Props, … … 1926 1899 static int dsoundDestroyStreamIn(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream) 1927 1900 { 1928 PDRVHOSTDSOUND pThis = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface);1901 RT_NOREF(pInterface); 1929 1902 PDSOUNDSTREAMIN pDSoundStream = (PDSOUNDSTREAMIN)pStream; 1930 1903 … … 2078 2051 CloseHandle(pThis->aEvents[DSOUNDEVENT_NOTIFY]); 2079 2052 pThis->aEvents[DSOUNDEVENT_NOTIFY] = NULL; 2080 } 2053 } 2054 #else 2055 RT_NOREF_PV(pThis); 2081 2056 #endif 2082 2057 … … 2191 2166 static DECLCALLBACK(PDMAUDIOBACKENDSTS) drvHostDSoundGetStatus(PPDMIHOSTAUDIO pInterface, PDMAUDIODIR enmDir) 2192 2167 { 2168 RT_NOREF(enmDir); 2193 2169 AssertPtrReturn(pInterface, PDMAUDIOBACKENDSTS_UNKNOWN); 2194 2170 … … 2279 2255 } 2280 2256 2257 2281 2258 static DECLCALLBACK(int) drvHostDSoundStreamIterate(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream) 2282 2259 { … … 2290 2267 } 2291 2268 2269 2270 /** 2271 * @callback_method_impl{FNPDMDRVDESTRUCT, pfnDestruct} 2272 */ 2292 2273 static DECLCALLBACK(void) drvHostDSoundDestruct(PPDMDRVINS pDrvIns) 2293 2274 { … … 2302 2283 } 2303 2284 2285 2304 2286 /** 2305 * Construct a DirectSound Audio driver instance. 2306 * 2307 * @copydoc FNPDMDRVCONSTRUCT 2287 * @callback_method_impl{FNPDMDRVCONSTRUCT, 2288 * Construct a DirectSound Audio driver instance.} 2308 2289 */ 2309 2290 static DECLCALLBACK(int) drvHostDSoundConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags) 2310 2291 { 2292 RT_NOREF(fFlags); 2311 2293 PDRVHOSTDSOUND pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTDSOUND); 2312 2294
Note:
See TracChangeset
for help on using the changeset viewer.