VirtualBox

Changeset 88479 in vbox for trunk/src/VBox/Devices/Audio


Ignore:
Timestamp:
Apr 13, 2021 12:18:50 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
143738
Message:

DrvHostAudioPulseAudio: Don't do useless default device 'enumeration' during pfnGetConfig, pfnGetDevices geets all and logs more. Left a only-default enumeration mode in case we need it. bugref:9890

File:
1 edited

Legend:

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

    r88478 r88479  
    6161/** (Release) log found devices. */
    6262#define PULSEAUDIOENUMCBFLAGS_LOG           RT_BIT(0)
     63/** Only do default devices. */
     64#define PULSEAUDIOENUMCBFLAGS_DEFAULT_ONLY  RT_BIT(1)
    6365/** @} */
    6466
     
    407409    if (eol == 0 && pInfo != NULL)
    408410    {
    409         if (pCbCtx->pDeviceEnum)
    410             drvHostAudioPaEnumAddDevice(pCbCtx, PDMAUDIODIR_IN, pInfo->name, pInfo->description,
    411                                         pInfo->sample_spec.channels, 0 /*cChannelsOutput*/, pCbCtx->pszDefaultSource);
    412         else
    413         {
    414             LogRel2(("PulseAudio: Using input source '%s'\n", pInfo->name));
    415             /** @todo Store sources + channel mapping in callback context as soon as we have surround support. */
    416         }
     411        LogRel2(("Pulse Audio: Source #%u: %u Hz %uch format=%u name='%s' desc='%s' driver='%s' flags=%#x\n",
     412                 pInfo->index, pInfo->sample_spec.rate, pInfo->sample_spec.channels, pInfo->sample_spec.format,
     413                 pInfo->name, pInfo->description, pInfo->driver, pInfo->flags));
     414        drvHostAudioPaEnumAddDevice(pCbCtx, PDMAUDIODIR_IN, pInfo->name, pInfo->description,
     415                                    pInfo->sample_spec.channels, 0 /*cChannelsOutput*/, pCbCtx->pszDefaultSource);
    417416    }
    418417    else if (eol == 1 && !pInfo && pCbCtx->rcEnum == VERR_AUDIO_ENUMERATION_FAILED)
     
    445444    if (eol == 0 && pInfo != NULL)
    446445    {
    447         if (pCbCtx->pDeviceEnum)
    448             drvHostAudioPaEnumAddDevice(pCbCtx, PDMAUDIODIR_OUT, pInfo->name, pInfo->description,
    449                                         0 /*cChannelsInput*/, pInfo->sample_spec.channels, pCbCtx->pszDefaultSink);
    450         else
    451         {
    452             LogRel2(("PulseAudio: Using output sink '%s'\n", pInfo->name));
    453             /** @todo Store sinks + channel mapping in callback context as soon as we have surround support. */
    454         }
     446        LogRel2(("Pulse Audio: Sink #%u: %u Hz %uch format=%u name='%s' desc='%s' driver='%s' flags=%#x\n",
     447                 pInfo->index, pInfo->sample_spec.rate, pInfo->sample_spec.channels, pInfo->sample_spec.format,
     448                 pInfo->name, pInfo->description, pInfo->driver, pInfo->flags));
     449        drvHostAudioPaEnumAddDevice(pCbCtx, PDMAUDIODIR_OUT, pInfo->name, pInfo->description,
     450                                    0 /*cChannelsInput*/, pInfo->sample_spec.channels, pCbCtx->pszDefaultSink);
    455451    }
    456452    else if (eol == 1 && !pInfo && pCbCtx->rcEnum == VERR_AUDIO_ENUMERATION_FAILED)
     
    511507 * @note Called with the PA main loop locked.
    512508 */
    513 static int drvHostAudioPaEnumerate(PDRVHOSTPULSEAUDIO pThis, PPDMAUDIOBACKENDCFG pCfg,
    514                                    uint32_t fEnum, PPDMAUDIOHOSTENUM pDeviceEnum)
    515 {
    516     PULSEAUDIOENUMCBCTX CbCtx = { pThis->pMainLoop, fEnum, VERR_AUDIO_ENUMERATION_FAILED, NULL, NULL, pDeviceEnum };
    517     bool const          fLog  = (fEnum & PULSEAUDIOENUMCBFLAGS_LOG);
     509static int drvHostAudioPaEnumerate(PDRVHOSTPULSEAUDIO pThis, uint32_t fEnum, PPDMAUDIOHOSTENUM pDeviceEnum)
     510{
     511    PULSEAUDIOENUMCBCTX CbCtx        = { pThis->pMainLoop, fEnum, VERR_AUDIO_ENUMERATION_FAILED, NULL, NULL, pDeviceEnum };
     512    bool const          fLog         = (fEnum & PULSEAUDIOENUMCBFLAGS_LOG);
     513    bool const          fOnlyDefault = (fEnum & PULSEAUDIOENUMCBFLAGS_DEFAULT_ONLY);
    518514    int                 rc;
    519515
     
    549545        LogRel2(("PulseAudio: No default output sink found\n"));
    550546
    551     if (CbCtx.pszDefaultSink || pDeviceEnum)
     547    if (CbCtx.pszDefaultSink || !fOnlyDefault)
    552548    {
    553549        CbCtx.rcEnum = VERR_AUDIO_ENUMERATION_FAILED;
    554         if (pDeviceEnum)
     550        if (!fOnlyDefault)
    555551            rc = drvHostAudioPaWaitFor(pThis,
    556552                                       pa_context_get_sink_info_list(pThis->pContext, drvHostAudioPaEnumSinkCallback, &CbCtx));
     
    572568    else if (fLog)
    573569        LogRel2(("PulseAudio: No default input source found\n"));
    574     if (CbCtx.pszDefaultSource || pDeviceEnum)
     570    if (CbCtx.pszDefaultSource || !fOnlyDefault)
    575571    {
    576572        CbCtx.rcEnum = VERR_AUDIO_ENUMERATION_FAILED;
    577573        int rc2;
    578         if (pDeviceEnum)
     574        if (!fOnlyDefault)
    579575            rc2 = drvHostAudioPaWaitFor(pThis, pa_context_get_source_info_list(pThis->pContext,
    580576                                                                               drvHostAudioPaEnumSourceCallback, &CbCtx));
     
    591587    }
    592588
    593     /** @todo r=bird: WTF are we making all this effort here w/o actually
    594      *        updating neither the backend configuration structure nor pThis?
    595      *        Sigh^3!
    596      *
    597      * update: I've reused this code for actual device enumeration now, so
    598      *         it's not 99.5% useless anymore, but I'm still puzzled at why it's
    599      *         required for pfnGetConfig... */
    600     RT_NOREF(pCfg);
    601 
    602589    /* clean up */
    603590    RTStrFree(CbCtx.pszDefaultSink);
     
    617604    AssertPtrReturn(pBackendCfg, VERR_INVALID_POINTER);
    618605
    619     /* Basic init: */
     606    /*
     607     * The configuration.
     608     */
    620609    RTStrCopy(pBackendCfg->szName, sizeof(pBackendCfg->szName), "PulseAudio");
    621610    pBackendCfg->cbStreamOut    = sizeof(PULSEAUDIOSTREAM);
     
    624613    pBackendCfg->cMaxStreamsIn  = UINT32_MAX;
    625614
    626     /* Refine it or something (currently only some LogRel2 stuff): */
     615#if 0
     616    /*
     617     * In case we want to gather info about default devices, we can do this:
     618     */
     619    PDMAUDIOHOSTENUM DeviceEnum;
     620    PDMAudioHostEnumInit(&DeviceEnum);
    627621    pa_threaded_mainloop_lock(pThis->pMainLoop);
    628     int rc = drvHostAudioPaEnumerate(pThis, pBackendCfg, PULSEAUDIOENUMCBFLAGS_LOG, NULL /*pDeviceEnum*/);
     622    int rc = drvHostAudioPaEnumerate(pThis, PULSEAUDIOENUMCBFLAGS_DEFAULT_ONLY | PULSEAUDIOENUMCBFLAGS_LOG, &DeviceEnum);
    629623    pa_threaded_mainloop_unlock(pThis->pMainLoop);
    630     return rc;
     624    AssertRCReturn(rc, rc);
     625    /** @todo do stuff with DeviceEnum. */
     626    PDMAudioHostEnumDelete(&DeviceEnum);
     627#else
     628    RT_NOREF(pThis);
     629#endif
     630    return VINF_SUCCESS;
    631631}
    632632
     
    643643    /* Refine it or something (currently only some LogRel2 stuff): */
    644644    pa_threaded_mainloop_lock(pThis->pMainLoop);
    645     int rc = drvHostAudioPaEnumerate(pThis, NULL /*pCfg*/, PULSEAUDIOENUMCBFLAGS_NONE, pDeviceEnum);
     645    int rc = drvHostAudioPaEnumerate(pThis, PULSEAUDIOENUMCBFLAGS_NONE, pDeviceEnum);
    646646    pa_threaded_mainloop_unlock(pThis->pMainLoop);
    647647    return rc;
    648648}
    649 
    650649
    651650
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