VirtualBox

Changeset 57736 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Sep 14, 2015 1:11:50 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
102658
Message:

DrvHostDSound: dynamically load dsound.dll

Location:
trunk/src/VBox/Devices
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Audio/DrvHostDSound.cpp

    r57717 r57736  
    2828#include "VBoxDD.h"
    2929
     30/* Dynamically load dsound.dll. */
     31typedef HRESULT WINAPI FNDIRECTSOUNDENUMERATEW(LPDSENUMCALLBACKW pDSEnumCallback, LPVOID pContext);
     32typedef FNDIRECTSOUNDENUMERATEW *PFNDIRECTSOUNDENUMERATEW;
     33typedef HRESULT WINAPI FNDIRECTSOUNDCAPTUREENUMERATEW(LPDSENUMCALLBACKW pDSEnumCallback, LPVOID pContext);
     34typedef FNDIRECTSOUNDCAPTUREENUMERATEW *PFNDIRECTSOUNDCAPTUREENUMERATEW;
     35
    3036typedef struct DSOUNDHOSTCFG
    3137{
     
    323329    if (FAILED(hr))
    324330    {
    325         LogRel(("DSound: Error creating DirectSound instance: %Rhrc\n", hr));
     331        LogRelMax(s_cMaxRelLogEntries, ("DSound: Error creating DirectSound instance: %Rhrc\n", hr));
    326332    }
    327333    else
     
    14871493    pCfg->cMaxHstStrmsIn  = 0;
    14881494
    1489     DSOUNDENUMCBCTX ctx = { pThis, pCfg };
    1490 
    1491     HRESULT hr = DirectSoundEnumerateW(&dsoundEnumCallback, &ctx);
    1492     if (FAILED(hr))
    1493         LogRel(("DSound: Error enumerating host playback devices: %Rhrc\n", hr));
    1494 
    1495     LogRel(("DSound: Found %RU32 host playback devices\n", pCfg->cMaxHstStrmsOut));
     1495    RTLDRMOD hDSound = NULL;
     1496    int rc = RTLdrLoadSystem("dsound.dll", true /*fNoUnload*/, &hDSound);
     1497    if (RT_SUCCESS(rc))
     1498    {
     1499        PFNDIRECTSOUNDENUMERATEW pfnDirectSoundEnumerateW = NULL;
     1500        PFNDIRECTSOUNDCAPTUREENUMERATEW pfnDirectSoundCaptureEnumerateW = NULL;
     1501
     1502        rc = RTLdrGetSymbol(hDSound, "DirectSoundEnumerateW", (void**)&pfnDirectSoundEnumerateW);
     1503        if (RT_SUCCESS(rc))
     1504        {
     1505            rc = RTLdrGetSymbol(hDSound, "DirectSoundCaptureEnumerateW", (void**)&pfnDirectSoundCaptureEnumerateW);
     1506        }
     1507
     1508        if (RT_SUCCESS(rc))
     1509        {
     1510            DSOUNDENUMCBCTX ctx = { pThis, pCfg };
     1511
     1512            HRESULT hr = pfnDirectSoundEnumerateW(&dsoundEnumCallback, &ctx);
     1513            if (FAILED(hr))
     1514                LogRel(("DSound: Error enumerating host playback devices: %Rhrc\n", hr));
     1515
     1516            LogRel(("DSound: Found %RU32 host playback devices\n", pCfg->cMaxHstStrmsOut));
     1517
     1518            hr = pfnDirectSoundCaptureEnumerateW(&dsoundCaptureEnumCallback, &ctx);
     1519            if (FAILED(hr))
     1520                LogRel(("DSound: Error enumerating host capturing devices: %Rhrc\n", hr));
     1521
     1522            LogRel(("DSound: Found %RU32 host capturing devices\n", pCfg->cMaxHstStrmsIn));
     1523        }
     1524
     1525        RTLdrClose(hDSound);
     1526    }
     1527    else
     1528    {
     1529        /* No dsound.dll on this system.  */
     1530        LogRel(("DSound: could not load dsound.dll %Rrc\n", rc));
     1531    }
     1532
     1533    /* Always return success and at least default values to make the caller happy. */
    14961534    if (pCfg->cMaxHstStrmsOut == 0)
     1535    {
     1536        LogRel(("DSound: Adjusting the number of host playback devices to 1\n"));
    14971537        pCfg->cMaxHstStrmsOut = 1; /* Support at least one stream. */
    1498 
    1499     hr = DirectSoundCaptureEnumerateW(&dsoundCaptureEnumCallback, &ctx);
    1500     if (FAILED(hr))
    1501         LogRel(("DSound: Error enumerating host capturing devices: %Rhrc\n", hr));
    1502 
    1503     LogRel(("DSound: Found %RU32 host capturing devices\n", pCfg->cMaxHstStrmsIn));
     1538    }
     1539
    15041540    if (pCfg->cMaxHstStrmsIn < 2)
    15051541    {
  • trunk/src/VBox/Devices/Makefile.kmk

    r57522 r57736  
    559559  VBoxDD_SOURCES += \
    560560   Audio/DrvHostDSound.cpp
    561   VBoxDD_LIBS    += \
    562    $(PATH_SDK_$(VBOX_WINDDK)_LIB)/dsound.lib
    563561 endif
    564562
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette