Changeset 88479 in vbox for trunk/src/VBox/Devices/Audio
- Timestamp:
- Apr 13, 2021 12:18:50 AM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 143738
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvHostAudioPulseAudio.cpp
r88478 r88479 61 61 /** (Release) log found devices. */ 62 62 #define PULSEAUDIOENUMCBFLAGS_LOG RT_BIT(0) 63 /** Only do default devices. */ 64 #define PULSEAUDIOENUMCBFLAGS_DEFAULT_ONLY RT_BIT(1) 63 65 /** @} */ 64 66 … … 407 409 if (eol == 0 && pInfo != NULL) 408 410 { 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); 417 416 } 418 417 else if (eol == 1 && !pInfo && pCbCtx->rcEnum == VERR_AUDIO_ENUMERATION_FAILED) … … 445 444 if (eol == 0 && pInfo != NULL) 446 445 { 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); 455 451 } 456 452 else if (eol == 1 && !pInfo && pCbCtx->rcEnum == VERR_AUDIO_ENUMERATION_FAILED) … … 511 507 * @note Called with the PA main loop locked. 512 508 */ 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 f Log = (fEnum & PULSEAUDIOENUMCBFLAGS_LOG);509 static 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); 518 514 int rc; 519 515 … … 549 545 LogRel2(("PulseAudio: No default output sink found\n")); 550 546 551 if (CbCtx.pszDefaultSink || pDeviceEnum)547 if (CbCtx.pszDefaultSink || !fOnlyDefault) 552 548 { 553 549 CbCtx.rcEnum = VERR_AUDIO_ENUMERATION_FAILED; 554 if ( pDeviceEnum)550 if (!fOnlyDefault) 555 551 rc = drvHostAudioPaWaitFor(pThis, 556 552 pa_context_get_sink_info_list(pThis->pContext, drvHostAudioPaEnumSinkCallback, &CbCtx)); … … 572 568 else if (fLog) 573 569 LogRel2(("PulseAudio: No default input source found\n")); 574 if (CbCtx.pszDefaultSource || pDeviceEnum)570 if (CbCtx.pszDefaultSource || !fOnlyDefault) 575 571 { 576 572 CbCtx.rcEnum = VERR_AUDIO_ENUMERATION_FAILED; 577 573 int rc2; 578 if ( pDeviceEnum)574 if (!fOnlyDefault) 579 575 rc2 = drvHostAudioPaWaitFor(pThis, pa_context_get_source_info_list(pThis->pContext, 580 576 drvHostAudioPaEnumSourceCallback, &CbCtx)); … … 591 587 } 592 588 593 /** @todo r=bird: WTF are we making all this effort here w/o actually594 * updating neither the backend configuration structure nor pThis?595 * Sigh^3!596 *597 * update: I've reused this code for actual device enumeration now, so598 * it's not 99.5% useless anymore, but I'm still puzzled at why it's599 * required for pfnGetConfig... */600 RT_NOREF(pCfg);601 602 589 /* clean up */ 603 590 RTStrFree(CbCtx.pszDefaultSink); … … 617 604 AssertPtrReturn(pBackendCfg, VERR_INVALID_POINTER); 618 605 619 /* Basic init: */ 606 /* 607 * The configuration. 608 */ 620 609 RTStrCopy(pBackendCfg->szName, sizeof(pBackendCfg->szName), "PulseAudio"); 621 610 pBackendCfg->cbStreamOut = sizeof(PULSEAUDIOSTREAM); … … 624 613 pBackendCfg->cMaxStreamsIn = UINT32_MAX; 625 614 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); 627 621 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); 629 623 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; 631 631 } 632 632 … … 643 643 /* Refine it or something (currently only some LogRel2 stuff): */ 644 644 pa_threaded_mainloop_lock(pThis->pMainLoop); 645 int rc = drvHostAudioPaEnumerate(pThis, NULL /*pCfg*/,PULSEAUDIOENUMCBFLAGS_NONE, pDeviceEnum);645 int rc = drvHostAudioPaEnumerate(pThis, PULSEAUDIOENUMCBFLAGS_NONE, pDeviceEnum); 646 646 pa_threaded_mainloop_unlock(pThis->pMainLoop); 647 647 return rc; 648 648 } 649 650 649 651 650
Note:
See TracChangeset
for help on using the changeset viewer.