Changeset 89482 in vbox for trunk/src/VBox/Devices/Audio
- Timestamp:
- Jun 3, 2021 12:56:20 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 144838
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvHostAudioPulseAudio.cpp
r89423 r89482 50 50 * Defines * 51 51 *********************************************************************************************************************************/ 52 /** Max number of errors reported by drvH ostAudioPaError per instance.52 /** Max number of errors reported by drvHstAudPaError per instance. 53 53 * @todo Make this configurable thru driver config. */ 54 54 #define VBOX_PULSEAUDIO_MAX_LOG_REL_ERRORS 99 55 55 56 56 57 /** @name PULSEAUDIOENUMCBFLAGS_XXX57 /** @name DRVHSTAUDPAENUMCB_F_XXX 58 58 * @{ */ 59 59 /** No flags specified. */ 60 #define PULSEAUDIOENUMCBFLAGS_NONE060 #define DRVHSTAUDPAENUMCB_F_NONE 0 61 61 /** (Release) log found devices. */ 62 #define PULSEAUDIOENUMCBFLAGS_LOGRT_BIT(0)62 #define DRVHSTAUDPAENUMCB_F_LOG RT_BIT(0) 63 63 /** Only do default devices. */ 64 #define PULSEAUDIOENUMCBFLAGS_DEFAULT_ONLYRT_BIT(1)64 #define DRVHSTAUDPAENUMCB_F_DEFAULT_ONLY RT_BIT(1) 65 65 /** @} */ 66 66 … … 70 70 *********************************************************************************************************************************/ 71 71 /** Pointer to the instance data for a pulse audio host audio driver. */ 72 typedef struct DRVH OSTPULSEAUDIO *PDRVHOSTPULSEAUDIO;72 typedef struct DRVHSTAUDPA *PDRVHSTAUDPA; 73 73 74 74 … … 76 76 * Callback context for the server init context state changed callback. 77 77 */ 78 typedef struct PULSEAUDIOSTATECHGCTX78 typedef struct DRVHSTAUDPASTATECHGCTX 79 79 { 80 80 /** The event semaphore. */ … … 82 82 /** The returned context state. */ 83 83 pa_context_state_t volatile enmCtxState; 84 } PULSEAUDIOSTATECHGCTX;84 } DRVHSTAUDPASTATECHGCTX; 85 85 /** Pointer to a server init context state changed callback context. */ 86 typedef PULSEAUDIOSTATECHGCTX *PPULSEAUDIOSTATECHGCTX;86 typedef DRVHSTAUDPASTATECHGCTX *PDRVHSTAUDPASTATECHGCTX; 87 87 88 88 … … 90 90 * Enumeration callback context used by the pfnGetConfig code. 91 91 */ 92 typedef struct PULSEAUDIOENUMCBCTX92 typedef struct DRVHSTAUDPAENUMCBCTX 93 93 { 94 94 /** Pointer to PulseAudio's threaded main loop. */ 95 95 pa_threaded_mainloop *pMainLoop; 96 /** Enumeration flags, PULSEAUDIOENUMCBFLAGS_XXX. */96 /** Enumeration flags, DRVHSTAUDPAENUMCB_F_XXX. */ 97 97 uint32_t fFlags; 98 98 /** VBox status code for the operation. … … 106 106 /** The device enumeration to fill, NULL if pfnGetConfig context. */ 107 107 PPDMAUDIOHOSTENUM pDeviceEnum; 108 } PULSEAUDIOENUMCBCTX;108 } DRVHSTAUDPAENUMCBCTX; 109 109 /** Pointer to an enumeration callback context. */ 110 typedef PULSEAUDIOENUMCBCTX *PPULSEAUDIOENUMCBCTX;110 typedef DRVHSTAUDPAENUMCBCTX *PDRVHSTAUDPAENUMCBCTX; 111 111 112 112 … … 114 114 * Pulse audio device enumeration entry. 115 115 */ 116 typedef struct PULSEAUDIODEVENTRY116 typedef struct DRVHSTAUDPADEVENTRY 117 117 { 118 118 /** The part we share with others. */ … … 123 123 RT_FLEXIBLE_ARRAY_EXTENSION 124 124 char szPulseName[RT_FLEXIBLE_ARRAY]; 125 } PULSEAUDIODEVENTRY;125 } DRVHSTAUDPADEVENTRY; 126 126 /** Pointer to a pulse audio device enumeration entry. */ 127 typedef PULSEAUDIODEVENTRY *PPULSEAUDIODEVENTRY;127 typedef DRVHSTAUDPADEVENTRY *PDRVHSTAUDPADEVENTRY; 128 128 129 129 … … 131 131 * Pulse audio stream data. 132 132 */ 133 typedef struct PULSEAUDIOSTREAM133 typedef struct DRVHSTAUDPASTREAM 134 134 { 135 135 /** Common part. */ … … 138 138 PDMAUDIOSTREAMCFG Cfg; 139 139 /** Pointer to driver instance. */ 140 PDRVH OSTPULSEAUDIOpDrv;140 PDRVHSTAUDPA pDrv; 141 141 /** Pointer to opaque PulseAudio stream. */ 142 142 pa_stream *pStream; … … 177 177 /** Pulse playback and buffer metrics. */ 178 178 pa_buffer_attr BufAttr; 179 } PULSEAUDIOSTREAM;179 } DRVHSTAUDPASTREAM; 180 180 /** Pointer to pulse audio stream data. */ 181 typedef PULSEAUDIOSTREAM *PPULSEAUDIOSTREAM;181 typedef DRVHSTAUDPASTREAM *PDRVHSTAUDPASTREAM; 182 182 183 183 … … 186 186 * @implements PDMIAUDIOCONNECTOR 187 187 */ 188 typedef struct DRVH OSTPULSEAUDIO188 typedef struct DRVHSTAUDPA 189 189 { 190 190 /** Pointer to the driver instance structure. */ … … 209 209 char szStreamName[64]; 210 210 /** Don't want to put this on the stack... */ 211 PULSEAUDIOSTATECHGCTX InitStateChgCtx;211 DRVHSTAUDPASTATECHGCTX InitStateChgCtx; 212 212 /** Pointer to host audio interface. */ 213 213 PDMIHOSTAUDIO IHostAudio; 214 } DRVH OSTPULSEAUDIO;214 } DRVHSTAUDPA; 215 215 216 216 … … 244 244 * @param rcPa The error code to convert. 245 245 */ 246 static int drvH ostAudioPaErrorToVBox(int rcPa)246 static int drvHstAudPaErrorToVBox(int rcPa) 247 247 { 248 248 /** @todo Implement some PulseAudio -> VBox mapping here. */ … … 260 260 * @param ... Format string arguments. 261 261 */ 262 static int drvH ostAudioPaError(PDRVHOSTPULSEAUDIOpThis, const char *pszFormat, ...)262 static int drvHstAudPaError(PDRVHSTAUDPA pThis, const char *pszFormat, ...) 263 263 { 264 264 AssertPtrReturn(pThis, VERR_INVALID_POINTER); … … 266 266 267 267 int const rcPa = pa_context_errno(pThis->pContext); 268 int const rcVBox = drvH ostAudioPaErrorToVBox(rcPa);268 int const rcVBox = drvHstAudPaErrorToVBox(rcPa); 269 269 270 270 if ( pThis->cLogErrors < VBOX_PULSEAUDIO_MAX_LOG_REL_ERRORS … … 288 288 * mainloop might not have been entered yet. 289 289 */ 290 static void drvH ostAudioPaSignalWaiter(PDRVHOSTPULSEAUDIOpThis)290 static void drvHstAudPaSignalWaiter(PDRVHSTAUDPA pThis) 291 291 { 292 292 if (pThis) … … 301 301 * Wrapper around pa_threaded_mainloop_wait(). 302 302 */ 303 static void drvH ostAudioPaMainloopWait(PDRVHOSTPULSEAUDIOpThis)303 static void drvHstAudPaMainloopWait(PDRVHSTAUDPA pThis) 304 304 { 305 305 /** @todo r=bird: explain this logic. */ … … 313 313 * Pulse audio callback for context status changes, init variant. 314 314 */ 315 static void drvH ostAudioPaCtxCallbackStateChanged(pa_context *pCtx, void *pvUser)315 static void drvHstAudPaCtxCallbackStateChanged(pa_context *pCtx, void *pvUser) 316 316 { 317 317 AssertPtrReturnVoid(pCtx); 318 318 319 PDRVH OSTPULSEAUDIO pThis = (PDRVHOSTPULSEAUDIO)pvUser;319 PDRVHSTAUDPA pThis = (PDRVHSTAUDPA)pvUser; 320 320 AssertPtrReturnVoid(pThis); 321 321 … … 325 325 case PA_CONTEXT_TERMINATED: 326 326 case PA_CONTEXT_FAILED: 327 drvH ostAudioPaSignalWaiter(pThis);327 drvHstAudPaSignalWaiter(pThis); 328 328 break; 329 329 … … 339 339 * This will consume the pOperation reference. 340 340 */ 341 static int drvH ostAudioPaWaitForEx(PDRVHOSTPULSEAUDIOpThis, pa_operation *pOperation, RTMSINTERVAL cMsTimeout)341 static int drvHstAudPaWaitForEx(PDRVHSTAUDPA pThis, pa_operation *pOperation, RTMSINTERVAL cMsTimeout) 342 342 { 343 343 AssertPtrReturn(pOperation, VERR_INVALID_POINTER); … … 348 348 { 349 349 if (!pThis->fAbortLoop) /** @todo r=bird: I do _not_ get the logic behind this fAbortLoop mechanism, it looks more 350 * than a little mixed up and too much generalized see drvH ostAudioPaSignalWaiter. */350 * than a little mixed up and too much generalized see drvHstAudPaSignalWaiter. */ 351 351 { 352 352 AssertPtr(pThis->pMainLoop); … … 384 384 385 385 386 static int drvH ostAudioPaWaitFor(PDRVHOSTPULSEAUDIOpThis, pa_operation *pOP)387 { 388 return drvH ostAudioPaWaitForEx(pThis, pOP, 10 * RT_MS_1SEC);386 static int drvHstAudPaWaitFor(PDRVHSTAUDPA pThis, pa_operation *pOP) 387 { 388 return drvHstAudPaWaitForEx(pThis, pOP, 10 * RT_MS_1SEC); 389 389 } 390 390 … … 396 396 397 397 /** 398 * Worker for drvH ostAudioPaEnumSourceCallback() and399 * drvH ostAudioPaEnumSinkCallback() that adds an entry to the enumeration398 * Worker for drvHstAudPaEnumSourceCallback() and 399 * drvHstAudPaEnumSinkCallback() that adds an entry to the enumeration 400 400 * result. 401 401 */ 402 static void drvH ostAudioPaEnumAddDevice(PPULSEAUDIOENUMCBCTX pCbCtx, PDMAUDIODIR enmDir, const char *pszName,402 static void drvHstAudPaEnumAddDevice(PDRVHSTAUDPAENUMCBCTX pCbCtx, PDMAUDIODIR enmDir, const char *pszName, 403 403 const char *pszDesc, uint8_t cChannelsInput, uint8_t cChannelsOutput, 404 404 const char *pszDefaultName) 405 405 { 406 size_t const cchName = strlen(pszName);407 P PULSEAUDIODEVENTRY pDev = (PPULSEAUDIODEVENTRY)PDMAudioHostDevAlloc(RT_UOFFSETOF(PULSEAUDIODEVENTRY, szPulseName)408 + RT_ALIGN_Z(cchName + 1, 16));406 size_t const cchName = strlen(pszName); 407 PDRVHSTAUDPADEVENTRY pDev = (PDRVHSTAUDPADEVENTRY)PDMAudioHostDevAlloc(RT_UOFFSETOF(DRVHSTAUDPADEVENTRY, szPulseName) 408 + RT_ALIGN_Z(cchName + 1, 16)); 409 409 if (pDev != NULL) 410 410 { … … 434 434 * Enumeration callback - source info. 435 435 * 436 * @param pCtx The context (DRVH OSTPULSEAUDIO::pContext).436 * @param pCtx The context (DRVHSTAUDPA::pContext). 437 437 * @param pInfo The info. NULL when @a eol is not zero. 438 438 * @param eol Error-or-last indicator or something like that: … … 440 440 * - 1: End of list, no info. 441 441 * - -1: Error callback, no info. 442 * @param pvUserData Pointer to our PULSEAUDIOENUMCBCTX structure.443 */ 444 static void drvH ostAudioPaEnumSourceCallback(pa_context *pCtx, const pa_source_info *pInfo, int eol, void *pvUserData)442 * @param pvUserData Pointer to our DRVHSTAUDPAENUMCBCTX structure. 443 */ 444 static void drvHstAudPaEnumSourceCallback(pa_context *pCtx, const pa_source_info *pInfo, int eol, void *pvUserData) 445 445 { 446 446 LogFlowFunc(("pCtx=%p pInfo=%p eol=%d pvUserData=%p\n", pCtx, pInfo, eol, pvUserData)); 447 P PULSEAUDIOENUMCBCTX pCbCtx = (PPULSEAUDIOENUMCBCTX)pvUserData;447 PDRVHSTAUDPAENUMCBCTX pCbCtx = (PDRVHSTAUDPAENUMCBCTX)pvUserData; 448 448 AssertPtrReturnVoid(pCbCtx); 449 449 Assert((pInfo == NULL) == (eol != 0)); … … 455 455 pInfo->index, pInfo->sample_spec.rate, pInfo->sample_spec.channels, pInfo->sample_spec.format, 456 456 pInfo->name, pInfo->description, pInfo->driver, pInfo->flags)); 457 drvH ostAudioPaEnumAddDevice(pCbCtx, PDMAUDIODIR_IN, pInfo->name, pInfo->description,457 drvHstAudPaEnumAddDevice(pCbCtx, PDMAUDIODIR_IN, pInfo->name, pInfo->description, 458 458 pInfo->sample_spec.channels, 0 /*cChannelsOutput*/, pCbCtx->pszDefaultSource); 459 459 } … … 470 470 * Enumeration callback - sink info. 471 471 * 472 * @param pCtx The context (DRVH OSTPULSEAUDIO::pContext).472 * @param pCtx The context (DRVHSTAUDPA::pContext). 473 473 * @param pInfo The info. NULL when @a eol is not zero. 474 474 * @param eol Error-or-last indicator or something like that: … … 476 476 * - 1: End of list, no info. 477 477 * - -1: Error callback, no info. 478 * @param pvUserData Pointer to our PULSEAUDIOENUMCBCTX structure.479 */ 480 static void drvH ostAudioPaEnumSinkCallback(pa_context *pCtx, const pa_sink_info *pInfo, int eol, void *pvUserData)478 * @param pvUserData Pointer to our DRVHSTAUDPAENUMCBCTX structure. 479 */ 480 static void drvHstAudPaEnumSinkCallback(pa_context *pCtx, const pa_sink_info *pInfo, int eol, void *pvUserData) 481 481 { 482 482 LogFlowFunc(("pCtx=%p pInfo=%p eol=%d pvUserData=%p\n", pCtx, pInfo, eol, pvUserData)); 483 P PULSEAUDIOENUMCBCTX pCbCtx = (PPULSEAUDIOENUMCBCTX)pvUserData;483 PDRVHSTAUDPAENUMCBCTX pCbCtx = (PDRVHSTAUDPAENUMCBCTX)pvUserData; 484 484 AssertPtrReturnVoid(pCbCtx); 485 485 Assert((pInfo == NULL) == (eol != 0)); … … 491 491 pInfo->index, pInfo->sample_spec.rate, pInfo->sample_spec.channels, pInfo->sample_spec.format, 492 492 pInfo->name, pInfo->description, pInfo->driver, pInfo->flags)); 493 drvH ostAudioPaEnumAddDevice(pCbCtx, PDMAUDIODIR_OUT, pInfo->name, pInfo->description,493 drvHstAudPaEnumAddDevice(pCbCtx, PDMAUDIODIR_OUT, pInfo->name, pInfo->description, 494 494 0 /*cChannelsInput*/, pInfo->sample_spec.channels, pCbCtx->pszDefaultSink); 495 495 } … … 508 508 * Copy down the default names. 509 509 */ 510 static void drvH ostAudioPaEnumServerCallback(pa_context *pCtx, const pa_server_info *pInfo, void *pvUserData)510 static void drvHstAudPaEnumServerCallback(pa_context *pCtx, const pa_server_info *pInfo, void *pvUserData) 511 511 { 512 512 LogFlowFunc(("pCtx=%p pInfo=%p pvUserData=%p\n", pCtx, pInfo, pvUserData)); 513 P PULSEAUDIOENUMCBCTX pCbCtx = (PPULSEAUDIOENUMCBCTX)pvUserData;513 PDRVHSTAUDPAENUMCBCTX pCbCtx = (PDRVHSTAUDPAENUMCBCTX)pvUserData; 514 514 AssertPtrReturnVoid(pCbCtx); 515 515 RT_NOREF(pCtx); … … 551 551 * @note Called with the PA main loop locked. 552 552 */ 553 static int drvH ostAudioPaEnumerate(PDRVHOSTPULSEAUDIOpThis, uint32_t fEnum, PPDMAUDIOHOSTENUM pDeviceEnum)554 { 555 PULSEAUDIOENUMCBCTX CbCtx = { pThis->pMainLoop, fEnum, VERR_AUDIO_ENUMERATION_FAILED, NULL, NULL, pDeviceEnum };556 bool const fLog = (fEnum & PULSEAUDIOENUMCBFLAGS_LOG);557 bool const fOnlyDefault = (fEnum & PULSEAUDIOENUMCBFLAGS_DEFAULT_ONLY);558 int rc;553 static int drvHstAudPaEnumerate(PDRVHSTAUDPA pThis, uint32_t fEnum, PPDMAUDIOHOSTENUM pDeviceEnum) 554 { 555 DRVHSTAUDPAENUMCBCTX CbCtx = { pThis->pMainLoop, fEnum, VERR_AUDIO_ENUMERATION_FAILED, NULL, NULL, pDeviceEnum }; 556 bool const fLog = (fEnum & DRVHSTAUDPAENUMCB_F_LOG); 557 bool const fOnlyDefault = (fEnum & DRVHSTAUDPAENUMCB_F_DEFAULT_ONLY); 558 int rc; 559 559 560 560 /* … … 564 564 LogRel(("PulseAudio: Retrieving server information ...\n")); 565 565 CbCtx.rcEnum = VERR_AUDIO_ENUMERATION_FAILED; 566 pa_operation *paOpServerInfo = pa_context_get_server_info(pThis->pContext, drvH ostAudioPaEnumServerCallback, &CbCtx);566 pa_operation *paOpServerInfo = pa_context_get_server_info(pThis->pContext, drvHstAudPaEnumServerCallback, &CbCtx); 567 567 if (paOpServerInfo) 568 rc = drvH ostAudioPaWaitFor(pThis, paOpServerInfo);568 rc = drvHstAudPaWaitFor(pThis, paOpServerInfo); 569 569 else 570 570 { … … 593 593 CbCtx.rcEnum = VERR_AUDIO_ENUMERATION_FAILED; 594 594 if (!fOnlyDefault) 595 rc = drvH ostAudioPaWaitFor(pThis,596 pa_context_get_sink_info_list(pThis->pContext, drvH ostAudioPaEnumSinkCallback, &CbCtx));595 rc = drvHstAudPaWaitFor(pThis, 596 pa_context_get_sink_info_list(pThis->pContext, drvHstAudPaEnumSinkCallback, &CbCtx)); 597 597 else 598 rc = drvH ostAudioPaWaitFor(pThis, pa_context_get_sink_info_by_name(pThis->pContext, CbCtx.pszDefaultSink,599 drvH ostAudioPaEnumSinkCallback, &CbCtx));598 rc = drvHstAudPaWaitFor(pThis, pa_context_get_sink_info_by_name(pThis->pContext, CbCtx.pszDefaultSink, 599 drvHstAudPaEnumSinkCallback, &CbCtx)); 600 600 if (RT_SUCCESS(rc)) 601 601 rc = CbCtx.rcEnum; … … 617 617 int rc2; 618 618 if (!fOnlyDefault) 619 rc2 = drvH ostAudioPaWaitFor(pThis, pa_context_get_source_info_list(pThis->pContext,620 drvH ostAudioPaEnumSourceCallback, &CbCtx));619 rc2 = drvHstAudPaWaitFor(pThis, pa_context_get_source_info_list(pThis->pContext, 620 drvHstAudPaEnumSourceCallback, &CbCtx)); 621 621 else 622 rc2 = drvH ostAudioPaWaitFor(pThis, pa_context_get_source_info_by_name(pThis->pContext, CbCtx.pszDefaultSource,623 drvH ostAudioPaEnumSourceCallback, &CbCtx));622 rc2 = drvHstAudPaWaitFor(pThis, pa_context_get_source_info_by_name(pThis->pContext, CbCtx.pszDefaultSource, 623 drvHstAudPaEnumSourceCallback, &CbCtx)); 624 624 if (RT_SUCCESS(rc2)) 625 625 rc2 = CbCtx.rcEnum; … … 643 643 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetConfig} 644 644 */ 645 static DECLCALLBACK(int) drvH ostAudioPaHA_GetConfig(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDCFG pBackendCfg)646 { 647 PDRVH OSTPULSEAUDIO pThis = RT_FROM_MEMBER(pInterface, DRVHOSTPULSEAUDIO, IHostAudio);645 static DECLCALLBACK(int) drvHstAudPaHA_GetConfig(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDCFG pBackendCfg) 646 { 647 PDRVHSTAUDPA pThis = RT_FROM_MEMBER(pInterface, DRVHSTAUDPA, IHostAudio); 648 648 AssertPtrReturn(pBackendCfg, VERR_INVALID_POINTER); 649 649 … … 652 652 */ 653 653 RTStrCopy(pBackendCfg->szName, sizeof(pBackendCfg->szName), "PulseAudio"); 654 pBackendCfg->cbStream = sizeof( PULSEAUDIOSTREAM);654 pBackendCfg->cbStream = sizeof(DRVHSTAUDPASTREAM); 655 655 pBackendCfg->fFlags = 0; 656 656 pBackendCfg->cMaxStreamsOut = UINT32_MAX; … … 664 664 PDMAudioHostEnumInit(&DeviceEnum); 665 665 pa_threaded_mainloop_lock(pThis->pMainLoop); 666 int rc = drvH ostAudioPaEnumerate(pThis, PULSEAUDIOENUMCBFLAGS_DEFAULT_ONLY | PULSEAUDIOENUMCBFLAGS_LOG, &DeviceEnum);666 int rc = drvHstAudPaEnumerate(pThis, DRVHSTAUDPAENUMCB_F_DEFAULT_ONLY | DRVHSTAUDPAENUMCB_F_LOG, &DeviceEnum); 667 667 pa_threaded_mainloop_unlock(pThis->pMainLoop); 668 668 AssertRCReturn(rc, rc); … … 679 679 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetDevices} 680 680 */ 681 static DECLCALLBACK(int) drvH ostAudioPaHA_GetDevices(PPDMIHOSTAUDIO pInterface, PPDMAUDIOHOSTENUM pDeviceEnum)682 { 683 PDRVH OSTPULSEAUDIO pThis = RT_FROM_MEMBER(pInterface, DRVHOSTPULSEAUDIO, IHostAudio);681 static DECLCALLBACK(int) drvHstAudPaHA_GetDevices(PPDMIHOSTAUDIO pInterface, PPDMAUDIOHOSTENUM pDeviceEnum) 682 { 683 PDRVHSTAUDPA pThis = RT_FROM_MEMBER(pInterface, DRVHSTAUDPA, IHostAudio); 684 684 AssertPtrReturn(pDeviceEnum, VERR_INVALID_POINTER); 685 685 PDMAudioHostEnumInit(pDeviceEnum); … … 687 687 /* Refine it or something (currently only some LogRel2 stuff): */ 688 688 pa_threaded_mainloop_lock(pThis->pMainLoop); 689 int rc = drvH ostAudioPaEnumerate(pThis, PULSEAUDIOENUMCBFLAGS_NONE, pDeviceEnum);689 int rc = drvHstAudPaEnumerate(pThis, DRVHSTAUDPAENUMCB_F_NONE, pDeviceEnum); 690 690 pa_threaded_mainloop_unlock(pThis->pMainLoop); 691 691 return rc; … … 696 696 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetStatus} 697 697 */ 698 static DECLCALLBACK(PDMAUDIOBACKENDSTS) drvH ostAudioPaHA_GetStatus(PPDMIHOSTAUDIO pInterface, PDMAUDIODIR enmDir)698 static DECLCALLBACK(PDMAUDIOBACKENDSTS) drvHstAudPaHA_GetStatus(PPDMIHOSTAUDIO pInterface, PDMAUDIODIR enmDir) 699 699 { 700 700 RT_NOREF(pInterface, enmDir); … … 706 706 * Stream status changed. 707 707 */ 708 static void drvH ostAudioPaStreamStateChangedCallback(pa_stream *pStream, void *pvUser)708 static void drvHstAudPaStreamStateChangedCallback(pa_stream *pStream, void *pvUser) 709 709 { 710 710 AssertPtrReturnVoid(pStream); 711 711 712 PDRVH OSTPULSEAUDIO pThis = (PDRVHOSTPULSEAUDIO)pvUser;712 PDRVHSTAUDPA pThis = (PDRVHSTAUDPA)pvUser; 713 713 AssertPtrReturnVoid(pThis); 714 714 … … 718 718 case PA_STREAM_FAILED: 719 719 case PA_STREAM_TERMINATED: 720 drvH ostAudioPaSignalWaiter(pThis);720 drvHstAudPaSignalWaiter(pThis); 721 721 break; 722 722 … … 731 731 * Debug PA callback: Need data to output. 732 732 */ 733 static void drvH ostAudioPaStreamReqWriteDebugCallback(pa_stream *pStream, size_t cbLen, void *pvContext)733 static void drvHstAudPaStreamReqWriteDebugCallback(pa_stream *pStream, size_t cbLen, void *pvContext) 734 734 { 735 735 RT_NOREF(cbLen, pvContext); … … 745 745 * Debug PA callback: Underflow. This may happen when draing/corking. 746 746 */ 747 static void drvH ostAudioPaStreamUnderflowDebugCallback(pa_stream *pStream, void *pvContext)748 { 749 P PULSEAUDIOSTREAM pStrm = (PPULSEAUDIOSTREAM)pvContext;747 static void drvHstAudPaStreamUnderflowDebugCallback(pa_stream *pStream, void *pvContext) 748 { 749 PDRVHSTAUDPASTREAM pStrm = (PDRVHSTAUDPASTREAM)pvContext; 750 750 AssertPtrReturnVoid(pStrm); 751 751 … … 794 794 * Debug PA callback: Overflow. This may happen when draing/corking. 795 795 */ 796 static void drvH ostAudioPaStreamOverflowDebugCallback(pa_stream *pStream, void *pvContext)796 static void drvHstAudPaStreamOverflowDebugCallback(pa_stream *pStream, void *pvContext) 797 797 { 798 798 RT_NOREF(pStream, pvContext); … … 811 811 * @param pProps The PDM audio source properties. 812 812 */ 813 static pa_sample_format_t drvH ostAudioPaPropsToPulse(PCPDMAUDIOPCMPROPS pProps)813 static pa_sample_format_t drvHstAudPaPropsToPulse(PCPDMAUDIOPCMPROPS pProps) 814 814 { 815 815 switch (PDMAudioPropsSampleSize(pProps)) … … 849 849 * @param uHz The frequency. 850 850 */ 851 static int drvH ostAudioPaToAudioProps(PPDMAUDIOPCMPROPS pProps, pa_sample_format_t enmPulseFmt, uint8_t cChannels, uint32_t uHz)851 static int drvHstAudPaToAudioProps(PPDMAUDIOPCMPROPS pProps, pa_sample_format_t enmPulseFmt, uint8_t cChannels, uint32_t uHz) 852 852 { 853 853 AssertReturn(cChannels > 0, VERR_INVALID_PARAMETER); … … 901 901 * @note Caller owns the mainloop lock. 902 902 */ 903 static int drvH ostAudioPaStreamCreateLocked(PDRVHOSTPULSEAUDIO pThis, PPULSEAUDIOSTREAM pStreamPA,904 903 static int drvHstAudPaStreamCreateLocked(PDRVHSTAUDPA pThis, PDRVHSTAUDPASTREAM pStreamPA, 904 const char *pszName, PPDMAUDIOSTREAMCFG pCfgAcq) 905 905 { 906 906 /* … … 919 919 */ 920 920 #ifdef DEBUG 921 pa_stream_set_write_callback( pStream, drvH ostAudioPaStreamReqWriteDebugCallback, pStreamPA);922 pa_stream_set_underflow_callback( pStream, drvH ostAudioPaStreamUnderflowDebugCallback, pStreamPA);921 pa_stream_set_write_callback( pStream, drvHstAudPaStreamReqWriteDebugCallback, pStreamPA); 922 pa_stream_set_underflow_callback( pStream, drvHstAudPaStreamUnderflowDebugCallback, pStreamPA); 923 923 if (pCfgAcq->enmDir == PDMAUDIODIR_OUT) 924 pa_stream_set_overflow_callback(pStream, drvH ostAudioPaStreamOverflowDebugCallback, pStreamPA);924 pa_stream_set_overflow_callback(pStream, drvHstAudPaStreamOverflowDebugCallback, pStreamPA); 925 925 #endif 926 pa_stream_set_state_callback( pStream, drvH ostAudioPaStreamStateChangedCallback, pThis);926 pa_stream_set_state_callback( pStream, drvHstAudPaStreamStateChangedCallback, pThis); 927 927 928 928 /* … … 960 960 && PA_STREAM_IS_GOOD(enmStreamState) 961 961 && RTTimeNanoTS() - nsStart < RT_NS_10SEC /* not really timed */ ) 962 drvH ostAudioPaMainloopWait(pThis);962 drvHstAudPaMainloopWait(pThis); 963 963 if (enmStreamState == PA_STREAM_READY) 964 964 { … … 984 984 * modified since the caller converted it from pCfgReq. 985 985 */ 986 rc = drvH ostAudioPaToAudioProps(&pCfgAcq->Props, pStreamPA->SampleSpec.format,986 rc = drvHstAudPaToAudioProps(&pCfgAcq->Props, pStreamPA->SampleSpec.format, 987 987 pStreamPA->SampleSpec.channels, pStreamPA->SampleSpec.rate); 988 988 if (RT_SUCCESS(rc)) … … 1093 1093 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCreate} 1094 1094 */ 1095 static DECLCALLBACK(int) drvH ostAudioPaHA_StreamCreate(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,1096 1097 { 1098 PDRVH OSTPULSEAUDIO pThis = RT_FROM_MEMBER(pInterface, DRVHOSTPULSEAUDIO, IHostAudio);1099 P PULSEAUDIOSTREAM pStreamPA = (PPULSEAUDIOSTREAM)pStream;1095 static DECLCALLBACK(int) drvHstAudPaHA_StreamCreate(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream, 1096 PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 1097 { 1098 PDRVHSTAUDPA pThis = RT_FROM_MEMBER(pInterface, DRVHSTAUDPA, IHostAudio); 1099 PDRVHSTAUDPASTREAM pStreamPA = (PDRVHSTAUDPASTREAM)pStream; 1100 1100 AssertPtrReturn(pStreamPA, VERR_INVALID_POINTER); 1101 1101 AssertPtrReturn(pCfgReq, VERR_INVALID_POINTER); … … 1116 1116 pStreamPA->SampleSpec.rate = PDMAudioPropsHz(&pCfgReq->Props); 1117 1117 pStreamPA->SampleSpec.channels = PDMAudioPropsChannels(&pCfgReq->Props); 1118 pStreamPA->SampleSpec.format = drvH ostAudioPaPropsToPulse(&pCfgReq->Props);1118 pStreamPA->SampleSpec.format = drvHstAudPaPropsToPulse(&pCfgReq->Props); 1119 1119 1120 1120 /* … … 1186 1186 */ 1187 1187 pa_threaded_mainloop_lock(pThis->pMainLoop); 1188 rc = drvH ostAudioPaStreamCreateLocked(pThis, pStreamPA, szName, pCfgAcq);1188 rc = drvHstAudPaStreamCreateLocked(pThis, pStreamPA, szName, pCfgAcq); 1189 1189 pa_threaded_mainloop_unlock(pThis->pMainLoop); 1190 1190 if (RT_SUCCESS(rc)) … … 1237 1237 * @note Caller has locked the mainloop. 1238 1238 */ 1239 static void drvH ostAudioPaStreamCancelAndReleaseOperations(PPULSEAUDIOSTREAM pStreamPA)1239 static void drvHstAudPaStreamCancelAndReleaseOperations(PDRVHSTAUDPASTREAM pStreamPA) 1240 1240 { 1241 1241 if (pStreamPA->pDrainOp) … … 1268 1268 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamDestroy} 1269 1269 */ 1270 static DECLCALLBACK(int) drvHostAudioPaHA_StreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream, 1271 bool fImmediate) 1272 { 1273 PDRVHOSTPULSEAUDIO pThis = RT_FROM_MEMBER(pInterface, DRVHOSTPULSEAUDIO, IHostAudio); 1274 PPULSEAUDIOSTREAM pStreamPA = (PPULSEAUDIOSTREAM)pStream; 1270 static DECLCALLBACK(int) drvHstAudPaHA_StreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream, bool fImmediate) 1271 { 1272 PDRVHSTAUDPA pThis = RT_FROM_MEMBER(pInterface, DRVHSTAUDPA, IHostAudio); 1273 PDRVHSTAUDPASTREAM pStreamPA = (PDRVHSTAUDPASTREAM)pStream; 1275 1274 AssertPtrReturn(pStreamPA, VERR_INVALID_POINTER); 1276 1275 RT_NOREF(fImmediate); … … 1280 1279 pa_threaded_mainloop_lock(pThis->pMainLoop); 1281 1280 1282 drvH ostAudioPaStreamCancelAndReleaseOperations(pStreamPA);1281 drvHstAudPaStreamCancelAndReleaseOperations(pStreamPA); 1283 1282 pa_stream_disconnect(pStreamPA->pStream); 1284 1283 … … 1297 1296 * @note This is fully async, so nobody is waiting for this. 1298 1297 */ 1299 static void drvH ostAudioPaStreamCorkUncorkCommon(PPULSEAUDIOSTREAM pStreamPA, int fSuccess, const char *pszOperation)1298 static void drvHstAudPaStreamCorkUncorkCommon(PDRVHSTAUDPASTREAM pStreamPA, int fSuccess, const char *pszOperation) 1300 1299 { 1301 1300 AssertPtrReturnVoid(pStreamPA); … … 1303 1302 1304 1303 if (!fSuccess) 1305 drvH ostAudioPaError(pStreamPA->pDrv, "%s stream '%s' failed", pszOperation, pStreamPA->Cfg.szName);1304 drvHstAudPaError(pStreamPA->pDrv, "%s stream '%s' failed", pszOperation, pStreamPA->Cfg.szName); 1306 1305 1307 1306 if (pStreamPA->pCorkOp) … … 1316 1315 * Completion callback used with pa_stream_cork(,false,). 1317 1316 */ 1318 static void drvH ostAudioPaStreamUncorkCompletionCallback(pa_stream *pStream, int fSuccess, void *pvUser)1317 static void drvHstAudPaStreamUncorkCompletionCallback(pa_stream *pStream, int fSuccess, void *pvUser) 1319 1318 { 1320 1319 RT_NOREF(pStream); 1321 drvH ostAudioPaStreamCorkUncorkCommon((PPULSEAUDIOSTREAM)pvUser, fSuccess, "Uncorking");1320 drvHstAudPaStreamCorkUncorkCommon((PDRVHSTAUDPASTREAM)pvUser, fSuccess, "Uncorking"); 1322 1321 } 1323 1322 … … 1326 1325 * Completion callback used with pa_stream_cork(,true,). 1327 1326 */ 1328 static void drvH ostAudioPaStreamCorkCompletionCallback(pa_stream *pStream, int fSuccess, void *pvUser)1327 static void drvHstAudPaStreamCorkCompletionCallback(pa_stream *pStream, int fSuccess, void *pvUser) 1329 1328 { 1330 1329 RT_NOREF(pStream); 1331 drvH ostAudioPaStreamCorkUncorkCommon((PPULSEAUDIOSTREAM)pvUser, fSuccess, "Corking");1330 drvHstAudPaStreamCorkUncorkCommon((PDRVHSTAUDPASTREAM)pvUser, fSuccess, "Corking"); 1332 1331 } 1333 1332 … … 1336 1335 * @ interface_method_impl{PDMIHOSTAUDIO,pfnStreamEnable} 1337 1336 */ 1338 static DECLCALLBACK(int) drvH ostAudioPaHA_StreamEnable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)1339 { 1340 PDRVH OSTPULSEAUDIO pThis = RT_FROM_MEMBER(pInterface, DRVHOSTPULSEAUDIO, IHostAudio);1341 P PULSEAUDIOSTREAM pStreamPA = (PPULSEAUDIOSTREAM)pStream;1337 static DECLCALLBACK(int) drvHstAudPaHA_StreamEnable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 1338 { 1339 PDRVHSTAUDPA pThis = RT_FROM_MEMBER(pInterface, DRVHSTAUDPA, IHostAudio); 1340 PDRVHSTAUDPASTREAM pStreamPA = (PDRVHSTAUDPASTREAM)pStream; 1342 1341 LogFlowFunc(("\n")); 1343 1342 … … 1347 1346 pa_threaded_mainloop_lock(pThis->pMainLoop); 1348 1347 1349 drvH ostAudioPaStreamCancelAndReleaseOperations(pStreamPA);1348 drvHstAudPaStreamCancelAndReleaseOperations(pStreamPA); 1350 1349 pStreamPA->pCorkOp = pa_stream_cork(pStreamPA->pStream, 0 /*uncork it*/, 1351 drvH ostAudioPaStreamUncorkCompletionCallback, pStreamPA);1350 drvHstAudPaStreamUncorkCompletionCallback, pStreamPA); 1352 1351 LogFlowFunc(("Uncorking '%s': %p (async)\n", pStreamPA->Cfg.szName, pStreamPA->pCorkOp)); 1353 1352 int const rc = pStreamPA->pCorkOp ? VINF_SUCCESS 1354 : drvH ostAudioPaError(pThis, "pa_stream_cork('%s', 0 /*uncork it*/,,) failed", pStreamPA->Cfg.szName);1353 : drvHstAudPaError(pThis, "pa_stream_cork('%s', 0 /*uncork it*/,,) failed", pStreamPA->Cfg.szName); 1355 1354 1356 1355 … … 1365 1364 * @ interface_method_impl{PDMIHOSTAUDIO,pfnStreamDisable} 1366 1365 */ 1367 static DECLCALLBACK(int) drvH ostAudioPaHA_StreamDisable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)1368 { 1369 PDRVH OSTPULSEAUDIO pThis = RT_FROM_MEMBER(pInterface, DRVHOSTPULSEAUDIO, IHostAudio);1370 P PULSEAUDIOSTREAM pStreamPA = (PPULSEAUDIOSTREAM)pStream;1366 static DECLCALLBACK(int) drvHstAudPaHA_StreamDisable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 1367 { 1368 PDRVHSTAUDPA pThis = RT_FROM_MEMBER(pInterface, DRVHSTAUDPA, IHostAudio); 1369 PDRVHSTAUDPASTREAM pStreamPA = (PDRVHSTAUDPASTREAM)pStream; 1371 1370 LogFlowFunc(("\n")); 1372 1371 … … 1409 1408 * Cork (pause playback/capture) the stream. 1410 1409 */ 1411 drvH ostAudioPaStreamCancelAndReleaseOperations(pStreamPA);1410 drvHstAudPaStreamCancelAndReleaseOperations(pStreamPA); 1412 1411 pStreamPA->pCorkOp = pa_stream_cork(pStreamPA->pStream, 1 /* cork it */, 1413 drvH ostAudioPaStreamCorkCompletionCallback, pStreamPA);1412 drvHstAudPaStreamCorkCompletionCallback, pStreamPA); 1414 1413 LogFlowFunc(("Corking '%s': %p (async)\n", pStreamPA->Cfg.szName, pStreamPA->pCorkOp)); 1415 1414 int const rc = pStreamPA->pCorkOp ? VINF_SUCCESS 1416 : drvH ostAudioPaError(pThis, "pa_stream_cork('%s', 1 /*cork*/,,) failed", pStreamPA->Cfg.szName);1415 : drvHstAudPaError(pThis, "pa_stream_cork('%s', 1 /*cork*/,,) failed", pStreamPA->Cfg.szName); 1417 1416 1418 1417 pa_threaded_mainloop_unlock(pThis->pMainLoop); … … 1425 1424 * @ interface_method_impl{PDMIHOSTAUDIO,pfnStreamPause} 1426 1425 */ 1427 static DECLCALLBACK(int) drvH ostAudioPaHA_StreamPause(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)1426 static DECLCALLBACK(int) drvHstAudPaHA_StreamPause(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 1428 1427 { 1429 1428 /* Same as disable. */ 1430 return drvH ostAudioPaHA_StreamDisable(pInterface, pStream);1429 return drvHstAudPaHA_StreamDisable(pInterface, pStream); 1431 1430 } 1432 1431 … … 1435 1434 * @ interface_method_impl{PDMIHOSTAUDIO,pfnStreamResume} 1436 1435 */ 1437 static DECLCALLBACK(int) drvH ostAudioPaHA_StreamResume(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)1436 static DECLCALLBACK(int) drvHstAudPaHA_StreamResume(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 1438 1437 { 1439 1438 /* Same as enable. */ 1440 return drvH ostAudioPaHA_StreamEnable(pInterface, pStream);1439 return drvHstAudPaHA_StreamEnable(pInterface, pStream); 1441 1440 } 1442 1441 … … 1446 1445 * @note This is fully async, so nobody is waiting for this. 1447 1446 */ 1448 static void drvH ostAudioPaStreamDrainCompletionCallback(pa_stream *pStream, int fSuccess, void *pvUser)1449 { 1450 P PULSEAUDIOSTREAM pStreamPA = (PPULSEAUDIOSTREAM)pvUser;1447 static void drvHstAudPaStreamDrainCompletionCallback(pa_stream *pStream, int fSuccess, void *pvUser) 1448 { 1449 PDRVHSTAUDPASTREAM pStreamPA = (PDRVHSTAUDPASTREAM)pvUser; 1451 1450 AssertPtrReturnVoid(pStreamPA); 1452 1451 Assert(pStreamPA->pStream == pStream); … … 1454 1453 1455 1454 if (!fSuccess) 1456 drvH ostAudioPaError(pStreamPA->pDrv, "Draining stream '%s' failed", pStreamPA->Cfg.szName);1455 drvHstAudPaError(pStreamPA->pDrv, "Draining stream '%s' failed", pStreamPA->Cfg.szName); 1457 1456 1458 1457 /* Now cork the stream (doing it unconditionally atm). */ … … 1465 1464 } 1466 1465 1467 pStreamPA->pCorkOp = pa_stream_cork(pStream, 1 /* cork it*/, drvH ostAudioPaStreamCorkCompletionCallback, pStreamPA);1466 pStreamPA->pCorkOp = pa_stream_cork(pStream, 1 /* cork it*/, drvHstAudPaStreamCorkCompletionCallback, pStreamPA); 1468 1467 if (pStreamPA->pCorkOp) 1469 1468 LogFlowFunc(("Started cork operation %p of %s (following drain)\n", pStreamPA->pCorkOp, pStreamPA->Cfg.szName)); 1470 1469 else 1471 drvH ostAudioPaError(pStreamPA->pDrv, "pa_stream_cork failed on '%s' (following drain)", pStreamPA->Cfg.szName);1470 drvHstAudPaError(pStreamPA->pDrv, "pa_stream_cork failed on '%s' (following drain)", pStreamPA->Cfg.szName); 1472 1471 } 1473 1472 … … 1476 1475 * Callback used with pa_stream_tigger(), starts draining. 1477 1476 */ 1478 static void drvH ostAudioPaStreamTriggerCompletionCallback(pa_stream *pStream, int fSuccess, void *pvUser)1479 { 1480 P PULSEAUDIOSTREAM pStreamPA = (PPULSEAUDIOSTREAM)pvUser;1477 static void drvHstAudPaStreamTriggerCompletionCallback(pa_stream *pStream, int fSuccess, void *pvUser) 1478 { 1479 PDRVHSTAUDPASTREAM pStreamPA = (PDRVHSTAUDPASTREAM)pvUser; 1481 1480 AssertPtrReturnVoid(pStreamPA); 1482 1481 RT_NOREF(pStream); … … 1484 1483 1485 1484 if (!fSuccess) 1486 drvH ostAudioPaError(pStreamPA->pDrv, "Forcing playback before drainig '%s' failed", pStreamPA->Cfg.szName);1485 drvHstAudPaError(pStreamPA->pDrv, "Forcing playback before drainig '%s' failed", pStreamPA->Cfg.szName); 1487 1486 1488 1487 if (pStreamPA->pTriggerOp) … … 1497 1496 * @ interface_method_impl{PDMIHOSTAUDIO,pfnStreamDrain} 1498 1497 */ 1499 static DECLCALLBACK(int) drvH ostAudioPaHA_StreamDrain(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)1500 { 1501 PDRVH OSTPULSEAUDIO pThis = RT_FROM_MEMBER(pInterface, DRVHOSTPULSEAUDIO, IHostAudio);1502 P PULSEAUDIOSTREAM pStreamPA = (PPULSEAUDIOSTREAM)pStream;1498 static DECLCALLBACK(int) drvHstAudPaHA_StreamDrain(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 1499 { 1500 PDRVHSTAUDPA pThis = RT_FROM_MEMBER(pInterface, DRVHSTAUDPA, IHostAudio); 1501 PDRVHSTAUDPASTREAM pStreamPA = (PDRVHSTAUDPASTREAM)pStream; 1503 1502 AssertReturn(pStreamPA->Cfg.enmDir == PDMAUDIODIR_OUT, VERR_INVALID_PARAMETER); 1504 1503 LogFlowFunc(("\n")); … … 1539 1538 pa_operation_unref(pStreamPA->pTriggerOp); 1540 1539 } 1541 pStreamPA->pTriggerOp = pa_stream_trigger(pStreamPA->pStream, drvH ostAudioPaStreamTriggerCompletionCallback, pStreamPA);1540 pStreamPA->pTriggerOp = pa_stream_trigger(pStreamPA->pStream, drvHstAudPaStreamTriggerCompletionCallback, pStreamPA); 1542 1541 if (pStreamPA->pTriggerOp) 1543 1542 LogFlowFunc(("Started tigger operation %p on %s\n", pStreamPA->pTriggerOp, pStreamPA->Cfg.szName)); 1544 1543 else 1545 rc = drvH ostAudioPaError(pStreamPA->pDrv, "pa_stream_trigger failed on '%s'", pStreamPA->Cfg.szName);1544 rc = drvHstAudPaError(pStreamPA->pDrv, "pa_stream_trigger failed on '%s'", pStreamPA->Cfg.szName); 1546 1545 } 1547 1546 … … 1549 1548 * Initiate the draining (async), will cork the stream when it completes. 1550 1549 */ 1551 pStreamPA->pDrainOp = pa_stream_drain(pStreamPA->pStream, drvH ostAudioPaStreamDrainCompletionCallback, pStreamPA);1550 pStreamPA->pDrainOp = pa_stream_drain(pStreamPA->pStream, drvHstAudPaStreamDrainCompletionCallback, pStreamPA); 1552 1551 if (pStreamPA->pDrainOp) 1553 1552 LogFlowFunc(("Started drain operation %p of %s\n", pStreamPA->pDrainOp, pStreamPA->Cfg.szName)); 1554 1553 else 1555 rc = drvH ostAudioPaError(pStreamPA->pDrv, "pa_stream_drain failed on '%s'", pStreamPA->Cfg.szName);1554 rc = drvHstAudPaError(pStreamPA->pDrv, "pa_stream_drain failed on '%s'", pStreamPA->Cfg.szName); 1556 1555 1557 1556 pa_threaded_mainloop_unlock(pThis->pMainLoop); … … 1564 1563 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamControl} 1565 1564 */ 1566 static DECLCALLBACK(int) drvH ostAudioPaHA_StreamControl(PPDMIHOSTAUDIO pInterface,1567 1565 static DECLCALLBACK(int) drvHstAudPaHA_StreamControl(PPDMIHOSTAUDIO pInterface, 1566 PPDMAUDIOBACKENDSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd) 1568 1567 { 1569 1568 /** @todo r=bird: I'd like to get rid of this pfnStreamControl method, … … 1574 1573 { 1575 1574 case PDMAUDIOSTREAMCMD_ENABLE: 1576 return drvH ostAudioPaHA_StreamEnable(pInterface, pStream);1575 return drvHstAudPaHA_StreamEnable(pInterface, pStream); 1577 1576 case PDMAUDIOSTREAMCMD_DISABLE: 1578 return drvH ostAudioPaHA_StreamDisable(pInterface, pStream);1577 return drvHstAudPaHA_StreamDisable(pInterface, pStream); 1579 1578 case PDMAUDIOSTREAMCMD_PAUSE: 1580 return drvH ostAudioPaHA_StreamPause(pInterface, pStream);1579 return drvHstAudPaHA_StreamPause(pInterface, pStream); 1581 1580 case PDMAUDIOSTREAMCMD_RESUME: 1582 return drvH ostAudioPaHA_StreamResume(pInterface, pStream);1581 return drvHstAudPaHA_StreamResume(pInterface, pStream); 1583 1582 case PDMAUDIOSTREAMCMD_DRAIN: 1584 return drvH ostAudioPaHA_StreamDrain(pInterface, pStream);1583 return drvHstAudPaHA_StreamDrain(pInterface, pStream); 1585 1584 1586 1585 case PDMAUDIOSTREAMCMD_END: … … 1597 1596 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable} 1598 1597 */ 1599 static DECLCALLBACK(uint32_t) drvH ostAudioPaHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)1600 { 1601 PDRVH OSTPULSEAUDIO pThis = RT_FROM_MEMBER(pInterface, DRVHOSTPULSEAUDIO, IHostAudio);1602 P PULSEAUDIOSTREAM pStreamPA = (PPULSEAUDIOSTREAM)pStream;1598 static DECLCALLBACK(uint32_t) drvHstAudPaHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 1599 { 1600 PDRVHSTAUDPA pThis = RT_FROM_MEMBER(pInterface, DRVHSTAUDPA, IHostAudio); 1601 PDRVHSTAUDPASTREAM pStreamPA = (PDRVHSTAUDPASTREAM)pStream; 1603 1602 uint32_t cbReadable = 0; 1604 1603 if (pStreamPA->Cfg.enmDir == PDMAUDIODIR_IN) … … 1613 1612 cbReadable = (uint32_t)cbReadablePa; 1614 1613 else 1615 drvH ostAudioPaError(pThis, "pa_stream_readable_size failed on '%s'", pStreamPA->Cfg.szName);1614 drvHstAudPaError(pThis, "pa_stream_readable_size failed on '%s'", pStreamPA->Cfg.szName); 1616 1615 } 1617 1616 else … … 1628 1627 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable} 1629 1628 */ 1630 static DECLCALLBACK(uint32_t) drvH ostAudioPaHA_StreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)1631 { 1632 PDRVH OSTPULSEAUDIO pThis = RT_FROM_MEMBER(pInterface, DRVHOSTPULSEAUDIO, IHostAudio);1633 P PULSEAUDIOSTREAM pStreamPA = (PPULSEAUDIOSTREAM)pStream;1629 static DECLCALLBACK(uint32_t) drvHstAudPaHA_StreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 1630 { 1631 PDRVHSTAUDPA pThis = RT_FROM_MEMBER(pInterface, DRVHSTAUDPA, IHostAudio); 1632 PDRVHSTAUDPASTREAM pStreamPA = (PDRVHSTAUDPASTREAM)pStream; 1634 1633 uint32_t cbWritable = 0; 1635 1634 if (pStreamPA->Cfg.enmDir == PDMAUDIODIR_OUT) … … 1644 1643 cbWritable = cbWritablePa <= UINT32_MAX ? (uint32_t)cbWritablePa : UINT32_MAX; 1645 1644 else 1646 drvH ostAudioPaError(pThis, "pa_stream_writable_size failed on '%s'", pStreamPA->Cfg.szName);1645 drvHstAudPaError(pThis, "pa_stream_writable_size failed on '%s'", pStreamPA->Cfg.szName); 1647 1646 } 1648 1647 else … … 1660 1659 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState} 1661 1660 */ 1662 static DECLCALLBACK(PDMHOSTAUDIOSTREAMSTATE) drvH ostAudioPaHA_StreamGetState(PPDMIHOSTAUDIO pInterface,1663 1664 { 1665 PDRVH OSTPULSEAUDIO pThis = RT_FROM_MEMBER(pInterface, DRVHOSTPULSEAUDIO, IHostAudio);1661 static DECLCALLBACK(PDMHOSTAUDIOSTREAMSTATE) drvHstAudPaHA_StreamGetState(PPDMIHOSTAUDIO pInterface, 1662 PPDMAUDIOBACKENDSTREAM pStream) 1663 { 1664 PDRVHSTAUDPA pThis = RT_FROM_MEMBER(pInterface, DRVHSTAUDPA, IHostAudio); 1666 1665 AssertPtrReturn(pStream, PDMHOSTAUDIOSTREAMSTATE_INVALID); 1667 P PULSEAUDIOSTREAM pStreamPA = (PPULSEAUDIOSTREAM)pStream;1666 PDRVHSTAUDPASTREAM pStreamPA = (PDRVHSTAUDPASTREAM)pStream; 1668 1667 AssertPtrReturn(pStreamPA, PDMHOSTAUDIOSTREAMSTATE_INVALID); 1669 1668 … … 1706 1705 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamPlay} 1707 1706 */ 1708 static DECLCALLBACK(int) drvH ostAudioPaHA_StreamPlay(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,1709 1710 { 1711 PDRVH OSTPULSEAUDIO pThis = RT_FROM_MEMBER(pInterface, DRVHOSTPULSEAUDIO, IHostAudio);1712 P PULSEAUDIOSTREAM pStreamPA = (PPULSEAUDIOSTREAM)pStream;1707 static DECLCALLBACK(int) drvHstAudPaHA_StreamPlay(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream, 1708 const void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten) 1709 { 1710 PDRVHSTAUDPA pThis = RT_FROM_MEMBER(pInterface, DRVHSTAUDPA, IHostAudio); 1711 PDRVHSTAUDPASTREAM pStreamPA = (PDRVHSTAUDPASTREAM)pStream; 1713 1712 AssertPtrReturn(pStreamPA, VERR_INVALID_POINTER); 1714 1713 AssertPtrReturn(pcbWritten, VERR_INVALID_POINTER); … … 1755 1754 else 1756 1755 { 1757 rc = drvH ostAudioPaError(pStreamPA->pDrv, "Failed to write to output stream");1756 rc = drvHstAudPaError(pStreamPA->pDrv, "Failed to write to output stream"); 1758 1757 break; 1759 1758 } … … 1762 1761 { 1763 1762 if (cbWriteable == (size_t)-1) 1764 rc = drvH ostAudioPaError(pStreamPA->pDrv, "pa_stream_writable_size failed on '%s'", pStreamPA->Cfg.szName);1763 rc = drvHstAudPaError(pStreamPA->pDrv, "pa_stream_writable_size failed on '%s'", pStreamPA->Cfg.szName); 1765 1764 break; 1766 1765 } … … 1785 1784 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCapture} 1786 1785 */ 1787 static DECLCALLBACK(int) drvH ostAudioPaHA_StreamCapture(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,1788 1789 { 1790 PDRVH OSTPULSEAUDIO pThis = RT_FROM_MEMBER(pInterface, DRVHOSTPULSEAUDIO, IHostAudio);1791 P PULSEAUDIOSTREAM pStreamPA = (PPULSEAUDIOSTREAM)pStream;1786 static DECLCALLBACK(int) drvHstAudPaHA_StreamCapture(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream, 1787 void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead) 1788 { 1789 PDRVHSTAUDPA pThis = RT_FROM_MEMBER(pInterface, DRVHSTAUDPA, IHostAudio); 1790 PDRVHSTAUDPASTREAM pStreamPA = (PDRVHSTAUDPASTREAM)pStream; 1792 1791 AssertPtrReturn(pStreamPA, VERR_INVALID_POINTER); 1793 1792 AssertPtrReturn(pvBuf, VERR_INVALID_POINTER); … … 1906 1905 else 1907 1906 { 1908 rc = drvH ostAudioPaError(pStreamPA->pDrv, "pa_stream_peek failed on '%s' (%d)", pStreamPA->Cfg.szName, rcPa);1907 rc = drvHstAudPaError(pStreamPA->pDrv, "pa_stream_peek failed on '%s' (%d)", pStreamPA->Cfg.szName, rcPa); 1909 1908 pStreamPA->pbPeekBuf = NULL; 1910 1909 pStreamPA->cbPeekBuf = 0; … … 1915 1914 { 1916 1915 if (cbAvail != (size_t)-1) 1917 rc = drvH ostAudioPaError(pStreamPA->pDrv, "pa_stream_readable_size failed on '%s'", pStreamPA->Cfg.szName);1916 rc = drvHstAudPaError(pStreamPA->pDrv, "pa_stream_readable_size failed on '%s'", pStreamPA->Cfg.szName); 1918 1917 break; 1919 1918 } … … 1942 1941 * @interface_method_impl{PDMIBASE,pfnQueryInterface} 1943 1942 */ 1944 static DECLCALLBACK(void *) drvH ostAudioPaQueryInterface(PPDMIBASE pInterface, const char *pszIID)1943 static DECLCALLBACK(void *) drvHstAudPaQueryInterface(PPDMIBASE pInterface, const char *pszIID) 1945 1944 { 1946 1945 AssertPtrReturn(pInterface, NULL); 1947 1946 AssertPtrReturn(pszIID, NULL); 1948 1947 1949 PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface);1950 PDRVH OSTPULSEAUDIO pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTPULSEAUDIO);1948 PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface); 1949 PDRVHSTAUDPA pThis = PDMINS_2_DATA(pDrvIns, PDRVHSTAUDPA); 1951 1950 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase); 1952 1951 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIHOSTAUDIO, &pThis->IHostAudio); … … 1965 1964 * @copydoc FNPDMDRVDESTRUCT 1966 1965 */ 1967 static DECLCALLBACK(void) drvH ostAudioPaDestruct(PPDMDRVINS pDrvIns)1966 static DECLCALLBACK(void) drvHstAudPaDestruct(PPDMDRVINS pDrvIns) 1968 1967 { 1969 1968 PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns); 1970 PDRVH OSTPULSEAUDIO pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTPULSEAUDIO);1969 PDRVHSTAUDPA pThis = PDMINS_2_DATA(pDrvIns, PDRVHSTAUDPA); 1971 1970 LogFlowFuncEnter(); 1972 1971 … … 1995 1994 * 1996 1995 * Signalls our event semaphore so we can do a timed wait from 1997 * drvH ostAudioPaConstruct().1998 */ 1999 static void drvH ostAudioPaCtxCallbackStateChangedInit(pa_context *pCtx, void *pvUser)1996 * drvHstAudPaConstruct(). 1997 */ 1998 static void drvHstAudPaCtxCallbackStateChangedInit(pa_context *pCtx, void *pvUser) 2000 1999 { 2001 2000 AssertPtrReturnVoid(pCtx); 2002 P PULSEAUDIOSTATECHGCTX pStateChgCtx = (PPULSEAUDIOSTATECHGCTX)pvUser;2001 PDRVHSTAUDPASTATECHGCTX pStateChgCtx = (PDRVHSTAUDPASTATECHGCTX)pvUser; 2003 2002 pa_context_state_t enmCtxState = pa_context_get_state(pCtx); 2004 2003 switch (enmCtxState) … … 2023 2022 * @copydoc FNPDMDRVCONSTRUCT 2024 2023 */ 2025 static DECLCALLBACK(int) drvH ostAudioPaConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags)2024 static DECLCALLBACK(int) drvHstAudPaConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags) 2026 2025 { 2027 2026 RT_NOREF(pCfg, fFlags); 2028 2027 PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns); 2029 PDRVH OSTPULSEAUDIO pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTPULSEAUDIO);2028 PDRVHSTAUDPA pThis = PDMINS_2_DATA(pDrvIns, PDRVHSTAUDPA); 2030 2029 LogRel(("Audio: Initializing PulseAudio driver\n")); 2031 2030 … … 2035 2034 pThis->pDrvIns = pDrvIns; 2036 2035 /* IBase */ 2037 pDrvIns->IBase.pfnQueryInterface = drvH ostAudioPaQueryInterface;2036 pDrvIns->IBase.pfnQueryInterface = drvHstAudPaQueryInterface; 2038 2037 /* IHostAudio */ 2039 pThis->IHostAudio.pfnGetConfig = drvH ostAudioPaHA_GetConfig;2040 pThis->IHostAudio.pfnGetDevices = drvH ostAudioPaHA_GetDevices;2038 pThis->IHostAudio.pfnGetConfig = drvHstAudPaHA_GetConfig; 2039 pThis->IHostAudio.pfnGetDevices = drvHstAudPaHA_GetDevices; 2041 2040 pThis->IHostAudio.pfnSetDevice = NULL; 2042 pThis->IHostAudio.pfnGetStatus = drvH ostAudioPaHA_GetStatus;2041 pThis->IHostAudio.pfnGetStatus = drvHstAudPaHA_GetStatus; 2043 2042 pThis->IHostAudio.pfnDoOnWorkerThread = NULL; 2044 2043 pThis->IHostAudio.pfnStreamConfigHint = NULL; 2045 pThis->IHostAudio.pfnStreamCreate = drvH ostAudioPaHA_StreamCreate;2044 pThis->IHostAudio.pfnStreamCreate = drvHstAudPaHA_StreamCreate; 2046 2045 pThis->IHostAudio.pfnStreamInitAsync = NULL; 2047 pThis->IHostAudio.pfnStreamDestroy = drvH ostAudioPaHA_StreamDestroy;2046 pThis->IHostAudio.pfnStreamDestroy = drvHstAudPaHA_StreamDestroy; 2048 2047 pThis->IHostAudio.pfnStreamNotifyDeviceChanged = NULL; 2049 pThis->IHostAudio.pfnStreamControl = drvH ostAudioPaHA_StreamControl;2050 pThis->IHostAudio.pfnStreamGetReadable = drvH ostAudioPaHA_StreamGetReadable;2051 pThis->IHostAudio.pfnStreamGetWritable = drvH ostAudioPaHA_StreamGetWritable;2048 pThis->IHostAudio.pfnStreamControl = drvHstAudPaHA_StreamControl; 2049 pThis->IHostAudio.pfnStreamGetReadable = drvHstAudPaHA_StreamGetReadable; 2050 pThis->IHostAudio.pfnStreamGetWritable = drvHstAudPaHA_StreamGetWritable; 2052 2051 pThis->IHostAudio.pfnStreamGetPending = NULL; 2053 pThis->IHostAudio.pfnStreamGetState = drvH ostAudioPaHA_StreamGetState;2054 pThis->IHostAudio.pfnStreamPlay = drvH ostAudioPaHA_StreamPlay;2055 pThis->IHostAudio.pfnStreamCapture = drvH ostAudioPaHA_StreamCapture;2052 pThis->IHostAudio.pfnStreamGetState = drvHstAudPaHA_StreamGetState; 2053 pThis->IHostAudio.pfnStreamPlay = drvHstAudPaHA_StreamPlay; 2054 pThis->IHostAudio.pfnStreamCapture = drvHstAudPaHA_StreamCapture; 2056 2055 2057 2056 /* … … 2109 2108 2110 2109 pa_threaded_mainloop_lock(pThis->pMainLoop); 2111 pa_context_set_state_callback(pThis->pContext, drvH ostAudioPaCtxCallbackStateChangedInit, &pThis->InitStateChgCtx);2110 pa_context_set_state_callback(pThis->pContext, drvHstAudPaCtxCallbackStateChangedInit, &pThis->InitStateChgCtx); 2112 2111 if (!pa_context_connect(pThis->pContext, NULL /* pszServer */, PA_CONTEXT_NOFLAGS, NULL)) 2113 2112 { … … 2121 2120 /* Install the main state changed callback to know if something happens to our acquired context. */ 2122 2121 pa_threaded_mainloop_lock(pThis->pMainLoop); 2123 pa_context_set_state_callback(pThis->pContext, drvH ostAudioPaCtxCallbackStateChanged, pThis /* pvUserData */);2122 pa_context_set_state_callback(pThis->pContext, drvHstAudPaCtxCallbackStateChanged, pThis /* pvUserData */); 2124 2123 pa_threaded_mainloop_unlock(pThis->pMainLoop); 2125 2124 } … … 2172 2171 ~0U, 2173 2172 /* cbInstance */ 2174 sizeof(DRVH OSTPULSEAUDIO),2173 sizeof(DRVHSTAUDPA), 2175 2174 /* pfnConstruct */ 2176 drvH ostAudioPaConstruct,2175 drvHstAudPaConstruct, 2177 2176 /* pfnDestruct */ 2178 drvH ostAudioPaDestruct,2177 drvHstAudPaDestruct, 2179 2178 /* pfnRelocate */ 2180 2179 NULL,
Note:
See TracChangeset
for help on using the changeset viewer.