VirtualBox

Changeset 73526 in vbox for trunk/src


Ignore:
Timestamp:
Aug 6, 2018 1:58:05 PM (6 years ago)
Author:
vboxsync
Message:

Audio/PulseAudio: Dropped the (static) backend configuration and also make use of the handed-in buffering parameters here.

File:
1 edited

Legend:

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

    r73462 r73526  
    133133} PULSEAUDIOSTREAM, *PPULSEAUDIOSTREAM;
    134134
    135 /* The desired buffer length in milliseconds. Will be the target total stream
    136  * latency on newer version of pulse. Apparent latency can be less (or more.)
    137  */
    138 typedef struct PULSEAUDIOCFG
    139 {
    140     RTMSINTERVAL buffer_msecs_out;
    141     RTMSINTERVAL buffer_msecs_in;
    142 } PULSEAUDIOCFG, *PPULSEAUDIOCFG;
    143 
    144 static PULSEAUDIOCFG s_pulseCfg =
    145 {
    146     100, /* buffer_msecs_out */
    147     100  /* buffer_msecs_in */
    148 };
    149 
    150135/**
    151136 * Callback context for server enumeration callbacks.
     
    750735    pStreamPA->SampleSpec.channels = pCfgReq->Props.cChannels;
    751736
    752     pStreamPA->curLatencyUs        = 100 * 1000; /** 10ms latency by default. @todo Make this configurable. */
     737    pStreamPA->curLatencyUs        = DrvAudioHlpFramesToMilli(pCfgReq->Backend.cfBufferSize, &pCfgReq->Props) * RT_US_1MS;
    753738
    754739    const uint32_t cbLatency = pa_usec_to_bytes(pStreamPA->curLatencyUs, &pStreamPA->SampleSpec);
    755740
    756     LogRel2(("PulseAudio: Initial output latency is %RU64ms (%RU32 bytes)\n", pStreamPA->curLatencyUs / 1000 /* ms */, cbLatency));
     741    LogRel2(("PulseAudio: Initial output latency is %RU64ms (%RU32 bytes)\n", pStreamPA->curLatencyUs / RT_US_1MS, cbLatency));
    757742
    758743    pStreamPA->BufAttr.tlength     = cbLatency;
    759     pStreamPA->BufAttr.maxlength   = (pStreamPA->BufAttr.tlength * 3) / 2;
     744    pStreamPA->BufAttr.maxlength   = -1; /* Let the PulseAudio server choose the biggest size it can handle. */
    760745    pStreamPA->BufAttr.prebuf      = cbLatency;
    761     pStreamPA->BufAttr.minreq      = (uint32_t)-1;                 /* PulseAudio should set something sensible for minreq on it's own. */
    762 
    763     LogFunc(("BufAttr tlength=%RU32, maxLength=%RU32, minReq=%RU32\n",
     746    pStreamPA->BufAttr.minreq      = DrvAudioHlpFramesToBytes(pCfgReq->Backend.cfPeriod, &pCfgReq->Props);
     747
     748    LogFunc(("Requested: BufAttr tlength=%RU32, maxLength=%RU32, minReq=%RU32\n",
    764749             pStreamPA->BufAttr.tlength, pStreamPA->BufAttr.maxlength, pStreamPA->BufAttr.minreq));
    765750
     
    767752
    768753    char szName[256];
    769     RTStrPrintf2(szName, sizeof(szName),  "VirtualBox %s [%s]",
     754    RTStrPrintf2(szName, sizeof(szName), "VirtualBox %s [%s]",
    770755                 DrvAudioHlpPlaybackDstToStr(pCfgReq->DestSource.Dest), pThis->szStreamName);
    771756
     
    788773    uint32_t cbBuf = RT_MIN(pStreamPA->BufAttr.tlength * 2,
    789774                            pStreamPA->BufAttr.maxlength); /** @todo Make this configurable! */
     775
     776    LogFunc(("Acquired: BufAttr tlength=%RU32, maxLength=%RU32, minReq=%RU32\n",
     777             pStreamPA->BufAttr.tlength, pStreamPA->BufAttr.maxlength, pStreamPA->BufAttr.minreq));
     778
    790779    if (cbBuf)
    791780    {
     
    810799    pStreamPA->SampleSpec.channels = pCfgReq->Props.cChannels;
    811800
    812     /** @todo Check these values! */
    813     pStreamPA->BufAttr.fragsize    = (pa_bytes_per_second(&pStreamPA->SampleSpec) * s_pulseCfg.buffer_msecs_in) / 1000;
    814     pStreamPA->BufAttr.maxlength   = (pStreamPA->BufAttr.fragsize * 3) / 2;
     801    pStreamPA->BufAttr.fragsize    = DrvAudioHlpFramesToBytes(pCfgReq->Backend.cfPeriod, &pCfgReq->Props);
     802    pStreamPA->BufAttr.maxlength   = -1; /* Let the PulseAudio server choose the biggest size it can handle. */
    815803
    816804    Assert(pCfgReq->enmDir == PDMAUDIODIR_IN);
    817805
    818806    char szName[256];
    819     RTStrPrintf2(szName, sizeof(szName),  "VirtualBox %s [%s]",
     807    RTStrPrintf2(szName, sizeof(szName), "VirtualBox %s [%s]",
    820808                 DrvAudioHlpRecSrcToStr(pCfgReq->DestSource.Source), pThis->szStreamName);
    821809
Note: See TracChangeset for help on using the changeset viewer.

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