Changeset 89489 in vbox
- Timestamp:
- Jun 3, 2021 11:00:02 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vmm/pdmaudioifs.h
r89487 r89489 641 641 typedef struct PDMAUDIOSTREAMCFG 642 642 { 643 /** The stream's PCM properties. */ 644 PDMAUDIOPCMPROPS Props; 643 645 /** Direction of the stream. */ 644 646 PDMAUDIODIR enmDir; 645 647 /** Destination / source path. */ 646 648 PDMAUDIOPATH enmPath; 647 /** The stream's PCM properties. */648 PDMAUDIOPCMPROPS Props;649 649 /** Device emulation-specific data needed for the audio connector. */ 650 650 struct … … 874 874 * - Before DRVAUDIO::CritSectHotPlug. */ 875 875 RTCRITSECT CritSect; 876 /** Stream configuration. */ 877 PDMAUDIOSTREAMCFG Cfg; 876 878 /** Magic value (PDMAUDIOSTREAM_MAGIC). */ 877 879 uint32_t uMagic; 878 /** Audio direction of this stream. */879 PDMAUDIODIR enmDir;880 880 /** Size (in bytes) of the backend-specific stream data. */ 881 881 uint32_t cbBackend; … … 883 883 * See PDMAUDIOSTREAM_WARN_FLAGS_XXX. */ 884 884 uint32_t fWarningsShown; 885 /** The stream properties. */886 PDMAUDIOPCMPROPS Props;887 888 /** Name of this stream. */889 char szName[64];890 885 } PDMAUDIOSTREAM; 891 886 /** Pointer to an audio stream. */ … … 960 955 * configuring host audio. 961 956 * 962 * @param pInterface 963 * @param pCfg 964 * 957 * @param pInterface Pointer to this interface. 958 * @param pCfg The typical configuration. Can be modified by the 959 * drivers in unspecified ways. 965 960 */ 966 961 DECLR3CALLBACKMEMBER(void, pfnStreamConfigHint, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAMCFG pCfg)); … … 970 965 * 971 966 * @returns VBox status code. 972 * @param pInterface Pointer to the interface structure containing the called function pointer. 973 * @param fFlags PDMAUDIOSTREAM_CREATE_F_XXX. 974 * @param pCfgHost Stream configuration for host side. 975 * @param pCfgGuest Stream configuration for guest side. 976 * @param ppStream Pointer where to return the created audio stream on success. 977 * @todo r=bird: It is not documented how pCfgHost and pCfgGuest can be 978 * modified the DrvAudio... 979 */ 980 DECLR3CALLBACKMEMBER(int, pfnStreamCreate, (PPDMIAUDIOCONNECTOR pInterface, uint32_t fFlags, PPDMAUDIOSTREAMCFG pCfgHost, 981 PPDMAUDIOSTREAMCFG pCfgGuest, PPDMAUDIOSTREAM *ppStream)); 967 * @param pInterface Pointer to this interface. 968 * @param fFlags PDMAUDIOSTREAM_CREATE_F_XXX. 969 * @param pCfgReq The requested stream configuration. The actual stream 970 * configuration can be found in pStream->Cfg on success. 971 * @param ppStream Pointer where to return the created audio stream on 972 * success. 973 */ 974 DECLR3CALLBACKMEMBER(int, pfnStreamCreate, (PPDMIAUDIOCONNECTOR pInterface, uint32_t fFlags, PCPDMAUDIOSTREAMCFG pCfgReq, 975 PPDMAUDIOSTREAM *ppStream)); 982 976 983 977 … … 1097 1091 1098 1092 /** PDMIAUDIOCONNECTOR interface ID. */ 1099 #define PDMIAUDIOCONNECTOR_IID " ae82616d-0da7-489a-aa4c-3e74d112ca9c"1093 #define PDMIAUDIOCONNECTOR_IID "2900fe2a-6aeb-4953-ac12-f8965612f446" 1100 1094 1101 1095 … … 1315 1309 PDMAUDIOSTREAMCMD enmStreamCmd)); 1316 1310 1317 /**1318 * Returns the amount which is readable from the audio (input) stream.1319 *1320 * @returns For non-raw layout streams: Number of readable bytes.1321 * for raw layout streams : Number of readable audio frames.1322 * @param pInterface Pointer to the interface structure containing the called function pointer.1323 * @param pStream Pointer to audio stream.1324 */1325 DECLR3CALLBACKMEMBER(uint32_t, pfnStreamGetReadable, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream));1326 1327 /**1328 * Returns the amount which is writable to the audio (output) stream.1329 *1330 * @returns Number of writable bytes.1331 * @param pInterface Pointer to the interface structure containing the called function pointer.1332 * @param pStream Pointer to audio stream.1333 */1334 DECLR3CALLBACKMEMBER(uint32_t, pfnStreamGetWritable, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream));1335 1336 /**1337 * Returns the number of buffered bytes that hasn't been played yet (optional).1338 *1339 * Is not valid on an input stream, implementions shall assert and return zero.1340 *1341 * @returns Number of pending bytes.1342 * @param pInterface Pointer to this interface.1343 * @param pStream Pointer to audio stream.1344 *1345 * @todo This is no longer not used by DrvAudio and can probably be removed.1346 */1347 DECLR3CALLBACKMEMBER(uint32_t, pfnStreamGetPending, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream));1348 1311 1349 1312 /** … … 1356 1319 */ 1357 1320 DECLR3CALLBACKMEMBER(PDMHOSTAUDIOSTREAMSTATE, pfnStreamGetState, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)); 1321 1322 /** 1323 * Returns the number of buffered bytes that hasn't been played yet (optional). 1324 * 1325 * Is not valid on an input stream, implementions shall assert and return zero. 1326 * 1327 * @returns Number of pending bytes. 1328 * @param pInterface Pointer to this interface. 1329 * @param pStream Pointer to audio stream. 1330 * 1331 * @todo This is no longer not used by DrvAudio and can probably be removed. 1332 */ 1333 DECLR3CALLBACKMEMBER(uint32_t, pfnStreamGetPending, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)); 1334 1335 /** 1336 * Returns the amount which is writable to the audio (output) stream. 1337 * 1338 * @returns Number of writable bytes. 1339 * @param pInterface Pointer to the interface structure containing the called function pointer. 1340 * @param pStream Pointer to audio stream. 1341 */ 1342 DECLR3CALLBACKMEMBER(uint32_t, pfnStreamGetWritable, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)); 1358 1343 1359 1344 /** … … 1378 1363 1379 1364 /** 1365 * Returns the amount which is readable from the audio (input) stream. 1366 * 1367 * @returns For non-raw layout streams: Number of readable bytes. 1368 * for raw layout streams : Number of readable audio frames. 1369 * @param pInterface Pointer to the interface structure containing the called function pointer. 1370 * @param pStream Pointer to audio stream. 1371 */ 1372 DECLR3CALLBACKMEMBER(uint32_t, pfnStreamGetReadable, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)); 1373 1374 /** 1380 1375 * Captures (reads from) an audio (input) stream. 1381 1376 * … … 1392 1387 1393 1388 /** PDMIHOSTAUDIO interface ID. */ 1394 #define PDMIHOSTAUDIO_IID " 0625ae75-491b-428b-836e-4f8a9869788f"1389 #define PDMIHOSTAUDIO_IID "147dedd7-cac1-469b-b545-335dbe90abf6" 1395 1390 1396 1391 … … 1477 1472 1478 1473 /** PDMIHOSTAUDIOPORT interface ID. */ 1479 #define PDMIHOSTAUDIOPORT_IID " d42144e9-867e-4d1c-86d4-acb92b47f013"1474 #define PDMIHOSTAUDIOPORT_IID "92ea5169-8271-402d-99a7-9de26a52acaf" 1480 1475 1481 1476 /** @} */ -
trunk/src/VBox/Devices/Audio/AudioMixer.cpp
r89379 r89489 532 532 { 533 533 uint32_t cFrames = pMixStream->cFramesBackendBuffer; 534 if (PDMAudioPropsHz(&pMixStream->pStream-> Props) == PDMAudioPropsHz(&pSink->MixBuf.Props))534 if (PDMAudioPropsHz(&pMixStream->pStream->Cfg.Props) == PDMAudioPropsHz(&pSink->MixBuf.Props)) 535 535 { /* likely */ } 536 536 else 537 cFrames = cFrames * PDMAudioPropsHz(&pSink->MixBuf.Props) / PDMAudioPropsHz(&pMixStream->pStream-> Props);537 cFrames = cFrames * PDMAudioPropsHz(&pSink->MixBuf.Props) / PDMAudioPropsHz(&pMixStream->pStream->Cfg.Props); 538 538 if (cFrames > cFramesStreamMax) 539 539 { … … 1006 1006 RTListForEach(&pSink->lstStreams, pMixStream, AUDMIXSTREAM, Node) 1007 1007 { 1008 int rc2 = AudioMixBufInitWriteState(&pSink->MixBuf, &pMixStream->WriteState, &pMixStream->pStream-> Props);1008 int rc2 = AudioMixBufInitWriteState(&pSink->MixBuf, &pMixStream->WriteState, &pMixStream->pStream->Cfg.Props); 1009 1009 /** @todo remember this. */ 1010 1010 AssertLogRelRC(rc2); … … 1015 1015 RTListForEach(&pSink->lstStreams, pMixStream, AUDMIXSTREAM, Node) 1016 1016 { 1017 int rc2 = AudioMixBufInitPeekState(&pSink->MixBuf, &pMixStream->PeekState, &pMixStream->pStream-> Props);1017 int rc2 = AudioMixBufInitPeekState(&pSink->MixBuf, &pMixStream->PeekState, &pMixStream->pStream->Cfg.Props); 1018 1018 /** @todo remember this. */ 1019 1019 AssertLogRelRC(rc2); … … 1137 1137 1138 1138 uint32_t const cbReadable = pIConnector->pfnStreamGetReadable(pIConnector, pStream); 1139 uint32_t cFrames = PDMAudioPropsBytesToFrames(&pStream-> Props, cbReadable);1139 uint32_t cFrames = PDMAudioPropsBytesToFrames(&pStream->Cfg.Props, cbReadable); 1140 1140 pMixStream->cFramesLastAvail = cFrames; 1141 if (PDMAudioPropsHz(&pStream-> Props) == PDMAudioPropsHz(&pSink->MixBuf.Props))1141 if (PDMAudioPropsHz(&pStream->Cfg.Props) == PDMAudioPropsHz(&pSink->MixBuf.Props)) 1142 1142 { /* likely */ } 1143 1143 else 1144 1144 { 1145 cFrames = cFrames * PDMAudioPropsHz(&pSink->MixBuf.Props) / PDMAudioPropsHz(&pStream-> Props);1145 cFrames = cFrames * PDMAudioPropsHz(&pSink->MixBuf.Props) / PDMAudioPropsHz(&pStream->Cfg.Props); 1146 1146 cFrames = cFrames > 2 ? cFrames - 2 : 0; /* rounding safety fudge */ 1147 1147 } … … 1274 1274 1275 1275 /* Calculate how many bytes we should read from this stream. */ 1276 bool const fResampleSrc = PDMAudioPropsHz(&pStream-> Props) != PDMAudioPropsHz(&pSink->MixBuf.Props);1276 bool const fResampleSrc = PDMAudioPropsHz(&pStream->Cfg.Props) != PDMAudioPropsHz(&pSink->MixBuf.Props); 1277 1277 uint32_t const cbSrcToXfer = !fResampleSrc 1278 ? PDMAudioPropsFramesToBytes(&pStream-> Props, cFramesToXfer)1279 : PDMAudioPropsFramesToBytes(&pStream-> Props, /** @todo check rounding errors here... */1278 ? PDMAudioPropsFramesToBytes(&pStream->Cfg.Props, cFramesToXfer) 1279 : PDMAudioPropsFramesToBytes(&pStream->Cfg.Props, /** @todo check rounding errors here... */ 1280 1280 cFramesToXfer * PDMAudioPropsHz(&pSink->MixBuf.Props) 1281 / PDMAudioPropsHz(&pStream-> Props));1281 / PDMAudioPropsHz(&pStream->Cfg.Props)); 1282 1282 1283 1283 /* Do the reading. */ … … 1332 1332 /* We don't need to blend silence buffers. For simplicity, always blend 1333 1333 when we're resampling (for rounding). */ 1334 else if (fResampleSrc || !PDMAudioPropsIsBufferSilence(&pStream-> Props, pvBuf, cbSrcRead))1334 else if (fResampleSrc || !PDMAudioPropsIsBufferSilence(&pStream->Cfg.Props, pvBuf, cbSrcRead)) 1335 1335 { 1336 1336 AudioMixBufBlend(&pSink->MixBuf, &pMixStream->WriteState, pvBuf, cbSrcRead, … … 1339 1339 else 1340 1340 { 1341 cFramesDstTransferred = PDMAudioPropsBytesToFrames(&pStream-> Props, cbSrcRead);1341 cFramesDstTransferred = PDMAudioPropsBytesToFrames(&pStream->Cfg.Props, cbSrcRead); 1342 1342 AudioMixBufBlendGap(&pSink->MixBuf, &pMixStream->WriteState, cFramesDstTransferred); 1343 1343 } … … 1420 1420 { 1421 1421 uint32_t const cbWritable = pMixStream->pConn->pfnStreamGetWritable(pMixStream->pConn, pMixStream->pStream); 1422 uint32_t cFrames = PDMAudioPropsBytesToFrames(&pMixStream->pStream-> Props, cbWritable);1422 uint32_t cFrames = PDMAudioPropsBytesToFrames(&pMixStream->pStream->Cfg.Props, cbWritable); 1423 1423 pMixStream->cFramesLastAvail = cFrames; 1424 if (PDMAudioPropsHz(&pMixStream->pStream-> Props) == PDMAudioPropsHz(&pSink->MixBuf.Props))1424 if (PDMAudioPropsHz(&pMixStream->pStream->Cfg.Props) == PDMAudioPropsHz(&pSink->MixBuf.Props)) 1425 1425 { /* likely */ } 1426 1426 else 1427 1427 { 1428 cFrames = cFrames * PDMAudioPropsHz(&pSink->MixBuf.Props) / PDMAudioPropsHz(&pMixStream->pStream-> Props);1428 cFrames = cFrames * PDMAudioPropsHz(&pSink->MixBuf.Props) / PDMAudioPropsHz(&pMixStream->pStream->Cfg.Props); 1429 1429 cFrames = cFrames > 2 ? cFrames - 2 : 0; /* rounding safety fudge */ 1430 1430 } … … 2262 2262 * this is the sink format & direction with the src/dir, layout, name 2263 2263 * and device specific config copied from the guest side config (pCfg). 2264 * We disregard any Backend settings here. 2265 * 2266 * (Note! pfnStreamCreate used to get both CfgHost and pCfg (aka pCfgGuest) 2267 * passed in, but that became unnecessary with DrvAudio stoppping 2268 * mixing. The mixing is done here and we bridge guest & host configs.) 2264 2269 */ 2265 2270 AssertMsg(AudioHlpPcmPropsAreValid(&pSink->PCMProps), … … 2282 2287 */ 2283 2288 PPDMAUDIOSTREAM pStream; 2284 rc = pConn->pfnStreamCreate(pConn, 0 /*fFlags*/, &CfgHost, pCfg,&pStream);2289 rc = pConn->pfnStreamCreate(pConn, 0 /*fFlags*/, &CfgHost, &pStream); 2285 2290 if (RT_SUCCESS(rc)) 2286 2291 { … … 2289 2294 /* Set up the mixing buffer conversion state. */ 2290 2295 if (pSink->enmDir == PDMAUDIODIR_IN) 2291 rc = AudioMixBufInitWriteState(&pSink->MixBuf, &pMixStream->WriteState, &pStream-> Props);2296 rc = AudioMixBufInitWriteState(&pSink->MixBuf, &pMixStream->WriteState, &pStream->Cfg.Props); 2292 2297 else 2293 rc = AudioMixBufInitPeekState(&pSink->MixBuf, &pMixStream->PeekState, &pStream-> Props);2298 rc = AudioMixBufInitPeekState(&pSink->MixBuf, &pMixStream->PeekState, &pStream->Cfg.Props); 2294 2299 if (RT_SUCCESS(rc)) 2295 2300 { … … 2396 2401 pStream->pszName, pSink->pszName), VERR_NOT_FOUND); 2397 2402 Assert(RTCritSectIsOwner(&pSink->CritSect)); 2398 LogFlowFunc(("[%s] (Stream = %s), cStreams=%RU8\n", pSink->pszName, pStream->pStream-> szName, pSink->cStreams));2403 LogFlowFunc(("[%s] (Stream = %s), cStreams=%RU8\n", pSink->pszName, pStream->pStream->Cfg.szName, pSink->cStreams)); 2399 2404 2400 2405 /* … … 2527 2532 if (pSink->enmDir == PDMAUDIODIR_OUT) 2528 2533 { 2529 rc = AudioMixBufInitPeekState(&pSink->MixBuf, &pMixStream->PeekState, &pStream-> Props);2534 rc = AudioMixBufInitPeekState(&pSink->MixBuf, &pMixStream->PeekState, &pStream->Cfg.Props); 2530 2535 /** @todo we need to remember this, don't we? */ 2531 2536 AssertLogRelRCReturn(rc, VINF_SUCCESS); … … 2533 2538 else 2534 2539 { 2535 rc = AudioMixBufInitWriteState(&pSink->MixBuf, &pMixStream->WriteState, &pStream-> Props);2540 rc = AudioMixBufInitWriteState(&pSink->MixBuf, &pMixStream->WriteState, &pStream->Cfg.Props); 2536 2541 /** @todo we need to remember this, don't we? */ 2537 2542 AssertLogRelRCReturn(rc, VINF_SUCCESS); -
trunk/src/VBox/Devices/Audio/DrvAudio.cpp
r89445 r89489 201 201 PRTREQ hReqInitAsync; 202 202 203 /** @todo The guest and host fields only contains the stream config now that204 * the mixing buffer is gone, so we can probably combine them into a205 * single Cfg member. */206 /** The guest side of the stream. */207 DRVAUDIOSTREAMCTX Guest;208 /** The host side of the stream. */209 DRVAUDIOSTREAMCTX Host;210 211 212 203 /** The nanosecond timestamp when the stream was started. */ 213 204 uint64_t nsStarted; … … 600 591 { 601 592 PDMHOSTAUDIOSTREAMSTATE enmState = pThis->pHostDrvAudio->pfnStreamGetState(pThis->pHostDrvAudio, pStreamEx->pBackend); 602 Log9Func(("%s: %s\n", pStreamEx->Core. szName, PDMHostAudioStreamStateGetName(enmState) ));593 Log9Func(("%s: %s\n", pStreamEx->Core.Cfg.szName, PDMHostAudioStreamStateGetName(enmState) )); 603 594 Assert( enmState > PDMHOSTAUDIOSTREAMSTATE_INVALID 604 595 && enmState < PDMHOSTAUDIOSTREAMSTATE_END 605 && (enmState != PDMHOSTAUDIOSTREAMSTATE_DRAINING || pStreamEx-> Guest.Cfg.enmDir == PDMAUDIODIR_OUT));596 && (enmState != PDMHOSTAUDIOSTREAMSTATE_DRAINING || pStreamEx->Core.Cfg.enmDir == PDMAUDIODIR_OUT)); 606 597 return enmState; 607 598 } 608 Log9Func(("%s: not-working\n", pStreamEx->Core. szName));599 Log9Func(("%s: not-working\n", pStreamEx->Core.Cfg.szName)); 609 600 return PDMHOSTAUDIOSTREAMSTATE_NOT_WORKING; 610 601 } … … 616 607 DECLINLINE(void) drvAudioStreamProcessBackendStateChangeWasDraining(PDRVAUDIOSTREAM pStreamEx) 617 608 { 618 Log(("drvAudioStreamProcessBackendStateChange: Stream '%s': Done draining - disabling stream.\n", pStreamEx->Core. szName));609 Log(("drvAudioStreamProcessBackendStateChange: Stream '%s': Done draining - disabling stream.\n", pStreamEx->Core.Cfg.szName)); 619 610 pStreamEx->fStatus &= ~(PDMAUDIOSTREAM_STS_ENABLED | PDMAUDIOSTREAM_STS_PENDING_DISABLE); 620 611 drvAudioStreamResetInternal(pStreamEx); … … 631 622 PDMHOSTAUDIOSTREAMSTATE enmOldState) 632 623 { 633 PDMAUDIODIR const enmDir = pStreamEx-> Guest.Cfg.enmDir;624 PDMAUDIODIR const enmDir = pStreamEx->Core.Cfg.enmDir; 634 625 #ifdef LOG_ENABLED 635 626 DRVAUDIOPLAYSTATE const enmPlayState = enmDir == PDMAUDIODIR_OUT … … 704 695 705 696 if (enmDir == PDMAUDIODIR_OUT) 706 LogFunc(("Output stream '%s': %s/%s -> %s/%s\n", pStreamEx->Core. szName,697 LogFunc(("Output stream '%s': %s/%s -> %s/%s\n", pStreamEx->Core.Cfg.szName, 707 698 PDMHostAudioStreamStateGetName(enmOldState), drvAudioPlayStateName(enmPlayState), 708 699 PDMHostAudioStreamStateGetName(enmNewState), drvAudioPlayStateName(pStreamEx->Out.enmPlayState) )); 709 700 else 710 LogFunc(("Input stream '%s': %s/%s -> %s/%s\n", pStreamEx->Core. szName,701 LogFunc(("Input stream '%s': %s/%s -> %s/%s\n", pStreamEx->Core.Cfg.szName, 711 702 PDMHostAudioStreamStateGetName(enmOldState), drvAudioCaptureStateName(enmCaptureState), 712 703 PDMHostAudioStreamStateGetName(enmNewState), drvAudioCaptureStateName(pStreamEx->In.enmCaptureState) )); … … 864 855 RTListForEach(&pThis->LstStreams, pStreamEx, DRVAUDIOSTREAM, ListEntry) 865 856 { 866 if (pStreamEx->Core. enmDir == enmDir)857 if (pStreamEx->Core.Cfg.enmDir == enmDir) 867 858 { 868 859 /* … … 911 902 { 912 903 LogRel(("Audio: Failed to %s %s stream '%s': %Rrc\n", 913 pszOperation, enmDir == PDMAUDIODIR_IN ? "input" : "output", pStreamEx->Core. szName, rc2));904 pszOperation, enmDir == PDMAUDIODIR_IN ? "input" : "output", pStreamEx->Core.Cfg.szName, rc2)); 914 905 if (RT_SUCCESS(rc)) 915 906 rc = rc2; /** @todo r=bird: This isn't entirely helpful to the caller since we'll update the status … … 1016 1007 if (pStreamEx) 1017 1008 { 1018 LogFunc(("[%s]\n", pStreamEx->Core. szName));1009 LogFunc(("[%s]\n", pStreamEx->Core.Cfg.szName)); 1019 1010 Assert(pStreamEx->Core.uMagic == PDMAUDIOSTREAM_MAGIC); 1020 1011 Assert(pStreamEx->uMagic == DRVAUDIOSTREAM_MAGIC); … … 1040 1031 * @returns VBox status code. 1041 1032 * @param pThis Pointer to the DrvAudio instance data. 1042 * @param pCfg Req The requestconfiguration that should be adjusted.1033 * @param pCfg The configuration that should be adjusted. 1043 1034 * @param pszName Stream name to use when logging warnings and errors. 1044 1035 */ 1045 static int drvAudioStreamAdjustConfig(PCDRVAUDIO pThis, PPDMAUDIOSTREAMCFG pCfg Req, const char *pszName)1036 static int drvAudioStreamAdjustConfig(PCDRVAUDIO pThis, PPDMAUDIOSTREAMCFG pCfg, const char *pszName) 1046 1037 { 1047 1038 /* Get the right configuration for the stream to be created. */ 1048 PCDRVAUDIOCFG pDrvCfg = pCfg Req->enmDir == PDMAUDIODIR_IN ? &pThis->CfgIn: &pThis->CfgOut;1039 PCDRVAUDIOCFG pDrvCfg = pCfg->enmDir == PDMAUDIODIR_IN ? &pThis->CfgIn: &pThis->CfgOut; 1049 1040 1050 1041 /* Fill in the tweakable parameters into the requested host configuration. … … 1056 1047 if (PDMAudioPropsSampleSize(&pDrvCfg->Props) != 0) /* Anything set via custom extra-data? */ 1057 1048 { 1058 PDMAudioPropsSetSampleSize(&pCfg Req->Props, PDMAudioPropsSampleSize(&pDrvCfg->Props));1049 PDMAudioPropsSetSampleSize(&pCfg->Props, PDMAudioPropsSampleSize(&pDrvCfg->Props)); 1059 1050 LogRel2(("Audio: Using custom sample size of %RU8 bytes for stream '%s'\n", 1060 PDMAudioPropsSampleSize(&pCfg Req->Props), pszName));1051 PDMAudioPropsSampleSize(&pCfg->Props), pszName)); 1061 1052 } 1062 1053 1063 1054 if (pDrvCfg->Props.uHz) /* Anything set via custom extra-data? */ 1064 1055 { 1065 pCfg Req->Props.uHz = pDrvCfg->Props.uHz;1066 LogRel2(("Audio: Using custom Hz rate %RU32 for stream '%s'\n", pCfg Req->Props.uHz, pszName));1056 pCfg->Props.uHz = pDrvCfg->Props.uHz; 1057 LogRel2(("Audio: Using custom Hz rate %RU32 for stream '%s'\n", pCfg->Props.uHz, pszName)); 1067 1058 } 1068 1059 1069 1060 if (pDrvCfg->uSigned != UINT8_MAX) /* Anything set via custom extra-data? */ 1070 1061 { 1071 pCfg Req->Props.fSigned = RT_BOOL(pDrvCfg->uSigned);1062 pCfg->Props.fSigned = RT_BOOL(pDrvCfg->uSigned); 1072 1063 LogRel2(("Audio: Using custom %s sample format for stream '%s'\n", 1073 pCfg Req->Props.fSigned ? "signed" : "unsigned", pszName));1064 pCfg->Props.fSigned ? "signed" : "unsigned", pszName)); 1074 1065 } 1075 1066 1076 1067 if (pDrvCfg->uSwapEndian != UINT8_MAX) /* Anything set via custom extra-data? */ 1077 1068 { 1078 pCfg Req->Props.fSwapEndian = RT_BOOL(pDrvCfg->uSwapEndian);1069 pCfg->Props.fSwapEndian = RT_BOOL(pDrvCfg->uSwapEndian); 1079 1070 LogRel2(("Audio: Using custom %s endianess for samples of stream '%s'\n", 1080 pCfg Req->Props.fSwapEndian ? "swapped" : "original", pszName));1071 pCfg->Props.fSwapEndian ? "swapped" : "original", pszName)); 1081 1072 } 1082 1073 1083 1074 if (PDMAudioPropsChannels(&pDrvCfg->Props) != 0) /* Anything set via custom extra-data? */ 1084 1075 { 1085 PDMAudioPropsSetChannels(&pCfg Req->Props, PDMAudioPropsChannels(&pDrvCfg->Props));1076 PDMAudioPropsSetChannels(&pCfg->Props, PDMAudioPropsChannels(&pDrvCfg->Props)); 1086 1077 LogRel2(("Audio: Using custom %RU8 channel(s) for stream '%s'\n", PDMAudioPropsChannels(&pDrvCfg->Props), pszName)); 1087 1078 } 1088 1079 1089 1080 /* Validate PCM properties. */ 1090 if (!AudioHlpPcmPropsAreValid(&pCfg Req->Props))1081 if (!AudioHlpPcmPropsAreValid(&pCfg->Props)) 1091 1082 { 1092 1083 LogRel(("Audio: Invalid custom PCM properties set for stream '%s', cannot create stream\n", pszName)); … … 1100 1091 if (pDrvCfg->uPeriodSizeMs) 1101 1092 { 1102 pCfg Req->Backend.cFramesPeriod = PDMAudioPropsMilliToFrames(&pCfgReq->Props, pDrvCfg->uPeriodSizeMs);1093 pCfg->Backend.cFramesPeriod = PDMAudioPropsMilliToFrames(&pCfg->Props, pDrvCfg->uPeriodSizeMs); 1103 1094 pszWhat = "custom"; 1104 1095 } 1105 1096 1106 if (!pCfg Req->Backend.cFramesPeriod) /* Set default period size if nothing explicitly is set. */1107 { 1108 pCfg Req->Backend.cFramesPeriod = PDMAudioPropsMilliToFrames(&pCfgReq->Props, 150 /*ms*/);1097 if (!pCfg->Backend.cFramesPeriod) /* Set default period size if nothing explicitly is set. */ 1098 { 1099 pCfg->Backend.cFramesPeriod = PDMAudioPropsMilliToFrames(&pCfg->Props, 150 /*ms*/); 1109 1100 pszWhat = "default"; 1110 1101 } 1111 1102 1112 1103 LogRel2(("Audio: Using %s period size %RU64 ms / %RU32 frames for stream '%s'\n", 1113 pszWhat, PDMAudioPropsFramesToMilli(&pCfg Req->Props, pCfgReq->Backend.cFramesPeriod),1114 pCfg Req->Backend.cFramesPeriod, pszName));1104 pszWhat, PDMAudioPropsFramesToMilli(&pCfg->Props, pCfg->Backend.cFramesPeriod), 1105 pCfg->Backend.cFramesPeriod, pszName)); 1115 1106 1116 1107 /* … … 1120 1111 if (pDrvCfg->uBufferSizeMs) 1121 1112 { 1122 pCfg Req->Backend.cFramesBufferSize = PDMAudioPropsMilliToFrames(&pCfgReq->Props, pDrvCfg->uBufferSizeMs);1113 pCfg->Backend.cFramesBufferSize = PDMAudioPropsMilliToFrames(&pCfg->Props, pDrvCfg->uBufferSizeMs); 1123 1114 pszWhat = "custom"; 1124 1115 } 1125 1116 1126 if (!pCfg Req->Backend.cFramesBufferSize) /* Set default buffer size if nothing explicitly is set. */1127 { 1128 pCfg Req->Backend.cFramesBufferSize = PDMAudioPropsMilliToFrames(&pCfgReq->Props, 300 /*ms*/);1117 if (!pCfg->Backend.cFramesBufferSize) /* Set default buffer size if nothing explicitly is set. */ 1118 { 1119 pCfg->Backend.cFramesBufferSize = PDMAudioPropsMilliToFrames(&pCfg->Props, 300 /*ms*/); 1129 1120 pszWhat = "default"; 1130 1121 } 1131 1122 1132 1123 LogRel2(("Audio: Using %s buffer size %RU64 ms / %RU32 frames for stream '%s'\n", 1133 pszWhat, PDMAudioPropsFramesToMilli(&pCfg Req->Props, pCfgReq->Backend.cFramesBufferSize),1134 pCfg Req->Backend.cFramesBufferSize, pszName));1124 pszWhat, PDMAudioPropsFramesToMilli(&pCfg->Props, pCfg->Backend.cFramesBufferSize), 1125 pCfg->Backend.cFramesBufferSize, pszName)); 1135 1126 1136 1127 /* … … 1140 1131 if (pDrvCfg->uPreBufSizeMs != UINT32_MAX) /* Anything set via global / per-VM extra-data? */ 1141 1132 { 1142 pCfg Req->Backend.cFramesPreBuffering = PDMAudioPropsMilliToFrames(&pCfgReq->Props, pDrvCfg->uPreBufSizeMs);1133 pCfg->Backend.cFramesPreBuffering = PDMAudioPropsMilliToFrames(&pCfg->Props, pDrvCfg->uPreBufSizeMs); 1143 1134 pszWhat = "custom"; 1144 1135 } 1145 1136 else /* No, then either use the default or device-specific settings (if any). */ 1146 1137 { 1147 if (pCfg Req->Backend.cFramesPreBuffering == UINT32_MAX) /* Set default pre-buffering size if nothing explicitly is set. */1138 if (pCfg->Backend.cFramesPreBuffering == UINT32_MAX) /* Set default pre-buffering size if nothing explicitly is set. */ 1148 1139 { 1149 1140 /* Pre-buffer 66% of the buffer for output streams, but only 50% for input. Capping both at 200ms. */ 1150 if (pCfg Req->enmDir == PDMAUDIODIR_OUT)1151 pCfg Req->Backend.cFramesPreBuffering = pCfgReq->Backend.cFramesBufferSize * 2 / 3;1141 if (pCfg->enmDir == PDMAUDIODIR_OUT) 1142 pCfg->Backend.cFramesPreBuffering = pCfg->Backend.cFramesBufferSize * 2 / 3; 1152 1143 else 1153 pCfg Req->Backend.cFramesPreBuffering = pCfgReq->Backend.cFramesBufferSize / 2;1154 uint32_t const cFramesMax = PDMAudioPropsMilliToFrames(&pCfg Req->Props, 200);1155 pCfg Req->Backend.cFramesPreBuffering = RT_MIN(pCfgReq->Backend.cFramesPreBuffering, cFramesMax);1144 pCfg->Backend.cFramesPreBuffering = pCfg->Backend.cFramesBufferSize / 2; 1145 uint32_t const cFramesMax = PDMAudioPropsMilliToFrames(&pCfg->Props, 200); 1146 pCfg->Backend.cFramesPreBuffering = RT_MIN(pCfg->Backend.cFramesPreBuffering, cFramesMax); 1156 1147 pszWhat = "default"; 1157 1148 } … … 1159 1150 1160 1151 LogRel2(("Audio: Using %s pre-buffering size %RU64 ms / %RU32 frames for stream '%s'\n", 1161 pszWhat, PDMAudioPropsFramesToMilli(&pCfg Req->Props, pCfgReq->Backend.cFramesPreBuffering),1162 pCfg Req->Backend.cFramesPreBuffering, pszName));1152 pszWhat, PDMAudioPropsFramesToMilli(&pCfg->Props, pCfg->Backend.cFramesPreBuffering), 1153 pCfg->Backend.cFramesPreBuffering, pszName)); 1163 1154 1164 1155 /* 1165 1156 * Validate input. 1166 1157 */ 1167 if (pCfg Req->Backend.cFramesBufferSize < pCfgReq->Backend.cFramesPeriod)1158 if (pCfg->Backend.cFramesBufferSize < pCfg->Backend.cFramesPeriod) 1168 1159 { 1169 1160 LogRel(("Audio: Error for stream '%s': Buffering size (%RU64ms) must not be smaller than the period size (%RU64ms)\n", 1170 pszName, PDMAudioPropsFramesToMilli(&pCfg Req->Props, pCfgReq->Backend.cFramesBufferSize),1171 PDMAudioPropsFramesToMilli(&pCfg Req->Props, pCfgReq->Backend.cFramesPeriod)));1161 pszName, PDMAudioPropsFramesToMilli(&pCfg->Props, pCfg->Backend.cFramesBufferSize), 1162 PDMAudioPropsFramesToMilli(&pCfg->Props, pCfg->Backend.cFramesPeriod))); 1172 1163 return VERR_INVALID_PARAMETER; 1173 1164 } 1174 1165 1175 if ( pCfg Req->Backend.cFramesPreBuffering != UINT32_MAX /* Custom pre-buffering set? */1176 && pCfg Req->Backend.cFramesPreBuffering)1177 { 1178 if (pCfg Req->Backend.cFramesBufferSize < pCfgReq->Backend.cFramesPreBuffering)1166 if ( pCfg->Backend.cFramesPreBuffering != UINT32_MAX /* Custom pre-buffering set? */ 1167 && pCfg->Backend.cFramesPreBuffering) 1168 { 1169 if (pCfg->Backend.cFramesBufferSize < pCfg->Backend.cFramesPreBuffering) 1179 1170 { 1180 1171 LogRel(("Audio: Error for stream '%s': Buffering size (%RU64ms) must not be smaller than the pre-buffering size (%RU64ms)\n", 1181 pszName, PDMAudioPropsFramesToMilli(&pCfg Req->Props, pCfgReq->Backend.cFramesPreBuffering),1182 PDMAudioPropsFramesToMilli(&pCfg Req->Props, pCfgReq->Backend.cFramesBufferSize)));1172 pszName, PDMAudioPropsFramesToMilli(&pCfg->Props, pCfg->Backend.cFramesPreBuffering), 1173 PDMAudioPropsFramesToMilli(&pCfg->Props, pCfg->Backend.cFramesBufferSize))); 1183 1174 return VERR_INVALID_PARAMETER; 1184 1175 } … … 1292 1283 rc = drvAudioStreamControlInternalBackend(pThis, pStreamEx, PDMAUDIOSTREAMCMD_PAUSE); 1293 1284 if (RT_FAILURE(rc)) 1294 LogRelMax(64, ("Audio: Failed to pause stream '%s' after %s: %Rrc\n", pStreamEx->Core. szName, pszWhen, rc));1285 LogRelMax(64, ("Audio: Failed to pause stream '%s' after %s: %Rrc\n", pStreamEx->Core.Cfg.szName, pszWhen, rc)); 1295 1286 } 1296 1287 } 1297 1288 else 1298 LogRelMax(64, ("Audio: Failed to enable stream '%s' after %s: %Rrc\n", pStreamEx->Core. szName, pszWhen, rc));1289 LogRelMax(64, ("Audio: Failed to enable stream '%s' after %s: %Rrc\n", pStreamEx->Core.Cfg.szName, pszWhen, rc)); 1299 1290 } 1300 1291 return rc; … … 1310 1301 static DECLCALLBACK(void) drvAudioStreamInitAsync(PDRVAUDIO pThis, PDRVAUDIOSTREAM pStreamEx) 1311 1302 { 1312 LogFlow(("pThis=%p pStreamEx=%p (%s)\n", pThis, pStreamEx, pStreamEx->Core. szName));1303 LogFlow(("pThis=%p pStreamEx=%p (%s)\n", pThis, pStreamEx, pStreamEx->Core.Cfg.szName)); 1313 1304 1314 1305 int rc = RTCritSectRwEnterShared(&pThis->CritSectHotPlug); … … 1353 1344 * Modify the play state if output stream. 1354 1345 */ 1355 if (pStreamEx->Core. enmDir == PDMAUDIODIR_OUT)1346 if (pStreamEx->Core.Cfg.enmDir == PDMAUDIODIR_OUT) 1356 1347 { 1357 1348 DRVAUDIOPLAYSTATE const enmPlayState = pStreamEx->Out.enmPlayState; … … 1392 1383 else if (!fDestroyed) 1393 1384 { 1394 LogRelMax(64, ("Audio: Failed to initialize stream '%s': %Rrc\n", pStreamEx->Core. szName, rc));1385 LogRelMax(64, ("Audio: Failed to initialize stream '%s': %Rrc\n", pStreamEx->Core.Cfg.szName, rc)); 1395 1386 } 1396 1387 … … 1421 1412 * @returns VBox status code. 1422 1413 * @param pThis Pointer to driver instance. 1423 * @param pStreamEx Audio stream to create the backend side for. 1424 * @param pCfgReq Requested audio stream configuration to use for 1425 * stream creation. 1426 * @param pCfgAcq Acquired audio stream configuration returned by 1427 * the backend. 1414 * @param pStreamEx Stream to create backend for. The Core.Cfg field 1415 * contains the requested configuration when we're called 1416 * and the actual configuration when successfully 1417 * returning. 1428 1418 * 1429 1419 * @note Configuration precedence for requested audio stream configuration (first has highest priority, if set): … … 1433 1423 * - default value 1434 1424 */ 1435 static int drvAudioStreamCreateInternalBackend(PDRVAUDIO pThis, PDRVAUDIOSTREAM pStreamEx, 1436 PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 1425 static int drvAudioStreamCreateInternalBackend(PDRVAUDIO pThis, PDRVAUDIOSTREAM pStreamEx) 1437 1426 { 1438 1427 AssertMsg((pStreamEx->fStatus & PDMAUDIOSTREAM_STS_BACKEND_CREATED) == 0, 1439 ("Stream '%s' already initialized in backend\n", pStreamEx->Core. szName));1440 1441 /* 1442 * Adjust the requested stream config, applying oursettings.1443 */ 1444 int rc = drvAudioStreamAdjustConfig(pThis, pCfgReq, pStreamEx->Core.szName);1428 ("Stream '%s' already initialized in backend\n", pStreamEx->Core.Cfg.szName)); 1429 1430 /* 1431 * Adjust the stream config, applying defaults and any overriding settings. 1432 */ 1433 int rc = drvAudioStreamAdjustConfig(pThis, &pStreamEx->Core.Cfg, pStreamEx->Core.Cfg.szName); 1445 1434 if (RT_FAILURE(rc)) 1446 1435 return rc; 1447 1448 /* 1449 * Make the acquired host configuration the requested host configuration initially, 1450 * in case the backend does not report back an acquired configuration. 1451 */ 1452 /** @todo r=bird: This is conveniently not documented in the interface... */ 1453 rc = PDMAudioStrmCfgCopy(pCfgAcq, pCfgReq); 1454 if (RT_FAILURE(rc)) 1455 { 1456 LogRel(("Audio: Creating stream '%s' with an invalid backend configuration not possible, skipping\n", 1457 pStreamEx->Core.szName)); 1458 return rc; 1459 } 1436 PDMAUDIOSTREAMCFG const CfgReq = pStreamEx->Core.Cfg; 1460 1437 1461 1438 /* … … 1472 1449 rc = VERR_STATE_CHANGED); 1473 1450 if (RT_SUCCESS(rc)) 1474 rc = pThis->pHostDrvAudio->pfnStreamCreate(pThis->pHostDrvAudio, pStreamEx->pBackend, pCfgReq, pCfgAcq);1451 rc = pThis->pHostDrvAudio->pfnStreamCreate(pThis->pHostDrvAudio, pStreamEx->pBackend, &CfgReq, &pStreamEx->Core.Cfg); 1475 1452 if (RT_SUCCESS(rc)) 1476 1453 { … … 1491 1468 RTCritSectRwLeaveShared(&pThis->CritSectHotPlug); 1492 1469 if (rc == VERR_NOT_SUPPORTED) 1493 LogRel2(("Audio: Creating stream '%s' in backend not supported\n", pStreamEx->Core. szName));1470 LogRel2(("Audio: Creating stream '%s' in backend not supported\n", pStreamEx->Core.Cfg.szName)); 1494 1471 else if (rc == VERR_AUDIO_STREAM_COULD_NOT_CREATE) 1495 LogRel2(("Audio: Stream '%s' could not be created in backend because of missing hardware / drivers\n", pStreamEx->Core.szName)); 1472 LogRel2(("Audio: Stream '%s' could not be created in backend because of missing hardware / drivers\n", 1473 pStreamEx->Core.Cfg.szName)); 1496 1474 else 1497 LogRel(("Audio: Creating stream '%s' in backend failed with %Rrc\n", pStreamEx->Core. szName, rc));1475 LogRel(("Audio: Creating stream '%s' in backend failed with %Rrc\n", pStreamEx->Core.Cfg.szName, rc)); 1498 1476 return rc; 1499 1477 } … … 1507 1485 ("rc=%Rrc %s\n", rc, PDMHostAudioStreamStateGetName(pStreamEx->enmLastBackendState))); 1508 1486 1509 /* Validate acquired configuration. */ 1487 PPDMAUDIOSTREAMCFG const pCfgAcq = &pStreamEx->Core.Cfg; 1488 1489 /* 1490 * Validate acquired configuration. 1491 */ 1510 1492 char szTmp[PDMAUDIOPROPSTOSTRING_MAX]; 1493 LogFunc(("Backend returned: %s\n", PDMAudioStrmCfgToString(pCfgAcq, szTmp, sizeof(szTmp)) )); 1511 1494 AssertLogRelMsgReturn(AudioHlpStreamCfgIsValid(pCfgAcq), 1512 1495 ("Audio: Creating stream '%s' returned an invalid backend configuration (%s), skipping\n", 1513 p StreamEx->Core.szName, PDMAudioPropsToString(&pCfgAcq->Props, szTmp, sizeof(szTmp))),1496 pCfgAcq->szName, PDMAudioPropsToString(&pCfgAcq->Props, szTmp, sizeof(szTmp))), 1514 1497 VERR_INVALID_PARAMETER); 1515 1498 1516 1499 /* Let the user know that the backend changed one of the values requested above. */ 1517 if (pCfgAcq->Backend.cFramesBufferSize != pCfgReq->Backend.cFramesBufferSize) 1518 LogRel2(("Audio: Buffer size overwritten by backend for stream '%s' (now %RU64ms, %RU32 frames)\n", 1519 pStreamEx->Core.szName, PDMAudioPropsFramesToMilli(&pCfgAcq->Props, pCfgAcq->Backend.cFramesBufferSize), pCfgAcq->Backend.cFramesBufferSize)); 1520 1521 if (pCfgAcq->Backend.cFramesPeriod != pCfgReq->Backend.cFramesPeriod) 1522 LogRel2(("Audio: Period size overwritten by backend for stream '%s' (now %RU64ms, %RU32 frames)\n", 1523 pStreamEx->Core.szName, PDMAudioPropsFramesToMilli(&pCfgAcq->Props, pCfgAcq->Backend.cFramesPeriod), pCfgAcq->Backend.cFramesPeriod)); 1500 if (pCfgAcq->Backend.cFramesBufferSize != CfgReq.Backend.cFramesBufferSize) 1501 LogRel2(("Audio: Backend changed buffer size from %RU64ms (%RU32 frames) to %RU64ms (%RU32 frames)\n", 1502 PDMAudioPropsFramesToMilli(&CfgReq.Props, CfgReq.Backend.cFramesBufferSize), CfgReq.Backend.cFramesBufferSize, 1503 PDMAudioPropsFramesToMilli(&pCfgAcq->Props, pCfgAcq->Backend.cFramesBufferSize), pCfgAcq->Backend.cFramesBufferSize)); 1504 1505 if (pCfgAcq->Backend.cFramesPeriod != CfgReq.Backend.cFramesPeriod) 1506 LogRel2(("Audio: Backend changed period size from %RU64ms (%RU32 frames) to %RU64ms (%RU32 frames)\n", 1507 PDMAudioPropsFramesToMilli(&CfgReq.Props, CfgReq.Backend.cFramesPeriod), CfgReq.Backend.cFramesPeriod, 1508 PDMAudioPropsFramesToMilli(&pCfgAcq->Props, pCfgAcq->Backend.cFramesPeriod), pCfgAcq->Backend.cFramesPeriod)); 1524 1509 1525 1510 /* Was pre-buffering requested, but the acquired configuration from the backend told us something else? */ 1526 if (pCfgReq->Backend.cFramesPreBuffering) 1527 { 1528 if (pCfgAcq->Backend.cFramesPreBuffering != pCfgReq->Backend.cFramesPreBuffering) 1529 LogRel2(("Audio: Pre-buffering size overwritten by backend for stream '%s' (now %RU64ms, %RU32 frames)\n", 1530 pStreamEx->Core.szName, PDMAudioPropsFramesToMilli(&pCfgAcq->Props, pCfgAcq->Backend.cFramesPreBuffering), pCfgAcq->Backend.cFramesPreBuffering)); 1511 if (CfgReq.Backend.cFramesPreBuffering) 1512 { 1513 if (pCfgAcq->Backend.cFramesPreBuffering != CfgReq.Backend.cFramesPreBuffering) 1514 LogRel2(("Audio: Backend changed pre-buffering size from %RU64ms (%RU32 frames) to %RU64ms (%RU32 frames)\n", 1515 PDMAudioPropsFramesToMilli(&CfgReq.Props, CfgReq.Backend.cFramesPreBuffering), CfgReq.Backend.cFramesPreBuffering, 1516 PDMAudioPropsFramesToMilli(&pCfgAcq->Props, pCfgAcq->Backend.cFramesPreBuffering), pCfgAcq->Backend.cFramesPreBuffering)); 1531 1517 1532 1518 if (pCfgAcq->Backend.cFramesPreBuffering > pCfgAcq->Backend.cFramesBufferSize) 1533 1519 { 1534 1520 pCfgAcq->Backend.cFramesPreBuffering = pCfgAcq->Backend.cFramesBufferSize; 1535 LogRel2(("Audio: Pre-buffering size bigger than buffer size for stream '%s', adjusting to %RU64ms (%RU32 frames)\n", 1536 pStreamEx->Core.szName,PDMAudioPropsFramesToMilli(&pCfgAcq->Props, pCfgAcq->Backend.cFramesPreBuffering), pCfgAcq->Backend.cFramesPreBuffering));1521 LogRel2(("Audio: Pre-buffering size bigger than buffer size for stream '%s', adjusting to %RU64ms (%RU32 frames)\n", pCfgAcq->szName, 1522 PDMAudioPropsFramesToMilli(&pCfgAcq->Props, pCfgAcq->Backend.cFramesPreBuffering), pCfgAcq->Backend.cFramesPreBuffering)); 1537 1523 } 1538 1524 } 1539 else if ( pCfgReq->Backend.cFramesPreBuffering == 0) /* Was the pre-buffering requested as being disabeld? Tell the users. */1540 { 1541 LogRel2(("Audio: Pre-buffering is disabled for stream '%s'\n", p StreamEx->Core.szName));1525 else if (CfgReq.Backend.cFramesPreBuffering == 0) /* Was the pre-buffering requested as being disabeld? Tell the users. */ 1526 { 1527 LogRel2(("Audio: Pre-buffering is disabled for stream '%s'\n", pCfgAcq->szName)); 1542 1528 pCfgAcq->Backend.cFramesPreBuffering = 0; 1543 1529 } … … 1551 1537 VERR_INVALID_PARAMETER); 1552 1538 1539 /* 1540 * Check if the backend did return sane values and correct if necessary. 1541 * Should never happen with our own backends, but you never know ... 1542 */ 1543 uint32_t const cFramesPreBufferingMax = pCfgAcq->Backend.cFramesBufferSize - RT_MIN(16, pCfgAcq->Backend.cFramesBufferSize); 1544 if (pCfgAcq->Backend.cFramesPreBuffering > cFramesPreBufferingMax) 1545 { 1546 LogRel2(("Audio: Warning: Pre-buffering size of %RU32 frames for stream '%s' is too close to or larger than the %RU32 frames buffer size, reducing it to %RU32 frames!\n", 1547 pCfgAcq->Backend.cFramesPreBuffering, pCfgAcq->szName, pCfgAcq->Backend.cFramesBufferSize, cFramesPreBufferingMax)); 1548 AssertFailed(); 1549 pCfgAcq->Backend.cFramesPreBuffering = cFramesPreBufferingMax; 1550 } 1551 1552 if (pCfgAcq->Backend.cFramesPeriod > pCfgAcq->Backend.cFramesBufferSize) 1553 { 1554 LogRel2(("Audio: Warning: Period size of %RU32 frames for stream '%s' is larger than the %RU32 frames buffer size, reducing it to %RU32 frames!\n", 1555 pCfgAcq->Backend.cFramesPeriod, pCfgAcq->szName, pCfgAcq->Backend.cFramesBufferSize, pCfgAcq->Backend.cFramesBufferSize / 2)); 1556 AssertFailed(); 1557 pCfgAcq->Backend.cFramesPeriod = pCfgAcq->Backend.cFramesBufferSize / 2; 1558 } 1559 1560 LogRel2(("Audio: Buffer size for stream '%s' is %RU64 ms / %RU32 frames\n", pCfgAcq->szName, 1561 PDMAudioPropsFramesToMilli(&pCfgAcq->Props, pCfgAcq->Backend.cFramesBufferSize), pCfgAcq->Backend.cFramesBufferSize)); 1562 LogRel2(("Audio: Pre-buffering size for stream '%s' is %RU64 ms / %RU32 frames\n", pCfgAcq->szName, 1563 PDMAudioPropsFramesToMilli(&pCfgAcq->Props, pCfgAcq->Backend.cFramesPreBuffering), pCfgAcq->Backend.cFramesPreBuffering)); 1564 LogRel2(("Audio: Scheduling hint for stream '%s' is %RU32ms / %RU32 frames\n", pCfgAcq->szName, 1565 pCfgAcq->Device.cMsSchedulingHint, PDMAudioPropsMilliToFrames(&pCfgAcq->Props, pCfgAcq->Device.cMsSchedulingHint))); 1566 1567 /* Make sure the configured buffer size by the backend at least can hold the configured latency. */ 1568 uint32_t const cMsPeriod = PDMAudioPropsFramesToMilli(&pCfgAcq->Props, pCfgAcq->Backend.cFramesPeriod); 1569 LogRel2(("Audio: Period size of stream '%s' is %RU64 ms / %RU32 frames\n", 1570 pCfgAcq->szName, cMsPeriod, pCfgAcq->Backend.cFramesPeriod)); 1571 /** @todo r=bird: This is probably a misleading/harmless warning as we'd just 1572 * have to transfer more each time we move data. The period is generally 1573 * pure irrelevant fiction anyway. A more relevant comparison would 1574 * be to half the buffer size, i.e. making sure we get scheduled often 1575 * enough to keep the buffer at least half full (probably more 1576 * sensible if the buffer size was more than 2x scheduling periods). */ 1577 if ( CfgReq.Device.cMsSchedulingHint /* Any scheduling hint set? */ 1578 && CfgReq.Device.cMsSchedulingHint > cMsPeriod) /* This might lead to buffer underflows. */ 1579 LogRel(("Audio: Warning: Scheduling hint of stream '%s' is bigger (%RU64ms) than used period size (%RU64ms)\n", 1580 pCfgAcq->szName, CfgReq.Device.cMsSchedulingHint, cMsPeriod)); 1581 1582 /* 1583 * Done, just log the result: 1584 */ 1585 LogFunc(("[%s] Acquired format: %s\n", pCfgAcq->szName, 1586 PDMAudioStrmCfgToString(&pStreamEx->Core.Cfg, szTmp, sizeof(szTmp)) )); 1587 LogRel2(("Audio: Acquired format: %s\n", PDMAudioStrmCfgToString(&pStreamEx->Core.Cfg, szTmp, sizeof(szTmp)) )); 1588 1553 1589 return VINF_SUCCESS; 1554 1590 } … … 1560 1596 * @returns VBox status code. 1561 1597 * @param pThis Pointer to driver instance. 1562 * @param pStreamEx Stream to initialize. 1563 * @param pCfgHost Stream configuration to use for the host side (backend). 1564 * This will be adjusted. 1565 * @param pCfgGuest Stream configuration to use for the guest side. 1566 */ 1567 static int drvAudioStreamInitInternal(PDRVAUDIO pThis, PDRVAUDIOSTREAM pStreamEx, 1568 PPDMAUDIOSTREAMCFG pCfgHost, PCPDMAUDIOSTREAMCFG pCfgGuest) 1598 * @param pStreamEx Stream to initialize. Caller already set a few fields. 1599 * The Core.Cfg field contains the requested configuration 1600 * when we're called and the actual configuration when 1601 * successfully returning. 1602 */ 1603 static int drvAudioStreamInitInternal(PDRVAUDIO pThis, PDRVAUDIOSTREAM pStreamEx) 1569 1604 { 1570 1605 /* … … 1573 1608 pStreamEx->Core.uMagic = PDMAUDIOSTREAM_MAGIC; 1574 1609 1575 #ifdef LOG_ENABLED 1576 LogFunc(("[%s] Requested host format:\n", pStreamEx->Core.szName)); 1577 PDMAudioStrmCfgLog(pCfgHost); 1578 #endif 1579 1580 LogRel2(("Audio: Creating stream '%s'\n", pStreamEx->Core.szName)); 1581 LogRel2(("Audio: Guest %s format for '%s': %RU32Hz, %u%s, %RU8 channel%s\n", 1582 pCfgGuest->enmDir == PDMAUDIODIR_IN ? "recording" : "playback", pStreamEx->Core.szName, 1583 pCfgGuest->Props.uHz, PDMAudioPropsSampleBits(&pCfgGuest->Props), pCfgGuest->Props.fSigned ? "S" : "U", 1584 PDMAudioPropsChannels(&pCfgGuest->Props), PDMAudioPropsChannels(&pCfgGuest->Props) == 1 ? "" : "s")); 1585 LogRel2(("Audio: Requested host %s format for '%s': %RU32Hz, %u%s, %RU8 channel%s\n", 1586 pCfgHost->enmDir == PDMAUDIODIR_IN ? "recording" : "playback", pStreamEx->Core.szName, 1587 pCfgHost->Props.uHz, PDMAudioPropsSampleBits(&pCfgHost->Props), pCfgHost->Props.fSigned ? "S" : "U", 1588 PDMAudioPropsChannels(&pCfgHost->Props), PDMAudioPropsChannels(&pCfgHost->Props) == 1 ? "" : "s")); 1589 1590 PDMAUDIOSTREAMCFG CfgHostAcq; 1591 int rc = drvAudioStreamCreateInternalBackend(pThis, pStreamEx, pCfgHost, &CfgHostAcq); 1610 char szTmp[PDMAUDIOSTRMCFGTOSTRING_MAX]; 1611 LogFunc(("[%s] Requested host format: %s\n", pStreamEx->Core.Cfg.szName, 1612 PDMAudioStrmCfgToString(&pStreamEx->Core.Cfg, szTmp, sizeof(szTmp)) )); 1613 LogRel2(("Audio: Creating stream: %s\n", PDMAudioStrmCfgToString(&pStreamEx->Core.Cfg, szTmp, sizeof(szTmp)))); 1614 1615 int rc = drvAudioStreamCreateInternalBackend(pThis, pStreamEx); 1592 1616 if (RT_FAILURE(rc)) 1593 1617 return rc; 1594 1618 1595 LogFunc(("[%s] Acquired host format:\n", pStreamEx->Core.szName));1596 PDMAudioStrmCfgLog(&CfgHostAcq);1597 LogRel2(("Audio: Acquired host %s format for '%s': %RU32Hz, %u%s, %RU8 channel%s\n",1598 CfgHostAcq.enmDir == PDMAUDIODIR_IN ? "recording" : "playback", pStreamEx->Core.szName,1599 CfgHostAcq.Props.uHz, PDMAudioPropsSampleBits(&CfgHostAcq.Props), CfgHostAcq.Props.fSigned ? "S" : "U",1600 PDMAudioPropsChannels(&CfgHostAcq.Props), PDMAudioPropsChannels(&CfgHostAcq.Props) == 1 ? "" : "s"));1601 Assert(PDMAudioPropsAreValid(&CfgHostAcq.Props));1602 1603 /* Set the stream properties. */1604 pStreamEx->Core.Props = CfgHostAcq.Props;1605 1606 /* Let the user know if the backend changed some of the tweakable values. */1607 if (CfgHostAcq.Backend.cFramesBufferSize != pCfgHost->Backend.cFramesBufferSize)1608 LogRel2(("Audio: Backend changed buffer size from %RU64ms (%RU32 frames) to %RU64ms (%RU32 frames)\n",1609 PDMAudioPropsFramesToMilli(&pCfgHost->Props, pCfgHost->Backend.cFramesBufferSize), pCfgHost->Backend.cFramesBufferSize,1610 PDMAudioPropsFramesToMilli(&CfgHostAcq.Props, CfgHostAcq.Backend.cFramesBufferSize), CfgHostAcq.Backend.cFramesBufferSize));1611 1612 if (CfgHostAcq.Backend.cFramesPeriod != pCfgHost->Backend.cFramesPeriod)1613 LogRel2(("Audio: Backend changed period size from %RU64ms (%RU32 frames) to %RU64ms (%RU32 frames)\n",1614 PDMAudioPropsFramesToMilli(&pCfgHost->Props, pCfgHost->Backend.cFramesPeriod), pCfgHost->Backend.cFramesPeriod,1615 PDMAudioPropsFramesToMilli(&CfgHostAcq.Props, CfgHostAcq.Backend.cFramesPeriod), CfgHostAcq.Backend.cFramesPeriod));1616 1617 if (CfgHostAcq.Backend.cFramesPreBuffering != pCfgHost->Backend.cFramesPreBuffering)1618 LogRel2(("Audio: Backend changed pre-buffering size from %RU64ms (%RU32 frames) to %RU64ms (%RU32 frames)\n",1619 PDMAudioPropsFramesToMilli(&pCfgHost->Props, pCfgHost->Backend.cFramesPreBuffering), pCfgHost->Backend.cFramesPreBuffering,1620 PDMAudioPropsFramesToMilli(&CfgHostAcq.Props, CfgHostAcq.Backend.cFramesPreBuffering), CfgHostAcq.Backend.cFramesPreBuffering));1621 1622 /*1623 * Check if the backend did return sane values and correct if necessary.1624 * Should never happen with our own backends, but you never know ...1625 */1626 uint32_t const cFramesPreBufferingMax = CfgHostAcq.Backend.cFramesBufferSize - RT_MIN(16, CfgHostAcq.Backend.cFramesBufferSize);1627 if (CfgHostAcq.Backend.cFramesPreBuffering > cFramesPreBufferingMax)1628 {1629 LogRel2(("Audio: Warning: Pre-buffering size of %RU32 frames for stream '%s' is too close to or larger than the %RU32 frames buffer size, reducing it to %RU32 frames!\n",1630 CfgHostAcq.Backend.cFramesPreBuffering, pStreamEx->Core.szName, CfgHostAcq.Backend.cFramesBufferSize, cFramesPreBufferingMax));1631 AssertFailed();1632 CfgHostAcq.Backend.cFramesPreBuffering = cFramesPreBufferingMax;1633 }1634 1635 if (CfgHostAcq.Backend.cFramesPeriod > CfgHostAcq.Backend.cFramesBufferSize)1636 {1637 LogRel2(("Audio: Warning: Period size of %RU32 frames for stream '%s' is larger than the %RU32 frames buffer size, reducing it to %RU32 frames!\n",1638 CfgHostAcq.Backend.cFramesPeriod, pStreamEx->Core.szName, CfgHostAcq.Backend.cFramesBufferSize, CfgHostAcq.Backend.cFramesBufferSize / 2));1639 AssertFailed();1640 CfgHostAcq.Backend.cFramesPeriod = CfgHostAcq.Backend.cFramesBufferSize / 2;1641 }1642 1643 LogRel2(("Audio: Buffer size of stream '%s' is %RU64 ms / %RU32 frames\n", pStreamEx->Core.szName,1644 PDMAudioPropsFramesToMilli(&CfgHostAcq.Props, CfgHostAcq.Backend.cFramesBufferSize), CfgHostAcq.Backend.cFramesBufferSize));1645 LogRel2(("Audio: Pre-buffering size of stream '%s' is %RU64 ms / %RU32 frames\n", pStreamEx->Core.szName,1646 PDMAudioPropsFramesToMilli(&CfgHostAcq.Props, CfgHostAcq.Backend.cFramesPreBuffering), CfgHostAcq.Backend.cFramesPreBuffering));1647 1648 /* Make sure the configured buffer size by the backend at least can hold the configured latency. */1649 const uint32_t msPeriod = PDMAudioPropsFramesToMilli(&CfgHostAcq.Props, CfgHostAcq.Backend.cFramesPeriod);1650 LogRel2(("Audio: Period size of stream '%s' is %RU64 ms / %RU32 frames\n",1651 pStreamEx->Core.szName, msPeriod, CfgHostAcq.Backend.cFramesPeriod));1652 1653 if ( pCfgGuest->Device.cMsSchedulingHint /* Any scheduling hint set? */1654 && pCfgGuest->Device.cMsSchedulingHint > msPeriod) /* This might lead to buffer underflows. */1655 LogRel(("Audio: Warning: Scheduling hint of stream '%s' is bigger (%RU64ms) than used period size (%RU64ms)\n",1656 pStreamEx->Core.szName, pCfgGuest->Device.cMsSchedulingHint, msPeriod));1657 1658 /*1659 * Make a copy of the acquired host stream configuration and the guest side one.1660 */1661 rc = PDMAudioStrmCfgCopy(&pStreamEx->Host.Cfg, &CfgHostAcq);1662 AssertRC(rc);1663 1664 rc = PDMAudioStrmCfgCopy(&pStreamEx->Guest.Cfg, pCfgGuest);1665 AssertRC(rc);1666 1667 1619 /* 1668 1620 * Configure host buffers. 1669 1621 */ 1670 1622 Assert(pStreamEx->cbPreBufThreshold == 0); 1671 if (CfgHostAcq.Backend.cFramesPreBuffering != 0) 1672 pStreamEx->cbPreBufThreshold = PDMAudioPropsFramesToBytes(&CfgHostAcq.Props, CfgHostAcq.Backend.cFramesPreBuffering); 1623 if (pStreamEx->Core.Cfg.Backend.cFramesPreBuffering != 0) 1624 pStreamEx->cbPreBufThreshold = PDMAudioPropsFramesToBytes(&pStreamEx->Core.Cfg.Props, 1625 pStreamEx->Core.Cfg.Backend.cFramesPreBuffering); 1673 1626 1674 1627 /* Allocate space for pre-buffering of output stream w/o mixing buffers. */ 1675 if (p CfgHost->enmDir == PDMAUDIODIR_OUT)1628 if (pStreamEx->Core.Cfg.enmDir == PDMAUDIODIR_OUT) 1676 1629 { 1677 1630 Assert(pStreamEx->Out.cbPreBufAlloc == 0); 1678 1631 Assert(pStreamEx->Out.cbPreBuffered == 0); 1679 1632 Assert(pStreamEx->Out.offPreBuf == 0); 1680 if ( CfgHostAcq.Backend.cFramesPreBuffering != 0)1633 if (pStreamEx->Core.Cfg.Backend.cFramesPreBuffering != 0) 1681 1634 { 1682 pStreamEx->Out.cbPreBufAlloc = PDMAudioPropsFramesToBytes(& CfgHostAcq.Props,1683 CfgHostAcq.Backend.cFramesBufferSize - 2);1635 pStreamEx->Out.cbPreBufAlloc = PDMAudioPropsFramesToBytes(&pStreamEx->Core.Cfg.Props, 1636 pStreamEx->Core.Cfg.Backend.cFramesBufferSize - 2); 1684 1637 pStreamEx->Out.cbPreBufAlloc = RT_MIN(RT_ALIGN_32(pStreamEx->cbPreBufThreshold + _8K, _4K), 1685 1638 pStreamEx->Out.cbPreBufAlloc); … … 1691 1644 1692 1645 /* 1693 * Init guest stream.1694 */1695 if (pCfgGuest->Device.cMsSchedulingHint)1696 LogRel2(("Audio: Stream '%s' got a scheduling hint of %RU32ms (%RU32 bytes)\n",1697 pStreamEx->Core.szName, pCfgGuest->Device.cMsSchedulingHint,1698 PDMAudioPropsMilliToBytes(&pCfgGuest->Props, pCfgGuest->Device.cMsSchedulingHint)));1699 1700 /*1701 1646 * Register statistics. 1702 1647 */ 1703 1648 PPDMDRVINS const pDrvIns = pThis->pDrvIns; 1704 1649 /** @todo expose config and more. */ 1705 PDMDrvHlpSTAMRegisterF(pDrvIns, &pStreamEx-> Host.Cfg.Backend.cFramesBufferSize, STAMTYPE_U32, STAMVISIBILITY_USED, STAMUNIT_NONE,1706 "Host side: The size of the backend buffer (in frames)", "%s/0-HostBackendBufSize", pStreamEx->Core. szName);1707 if (p CfgGuest->enmDir == PDMAUDIODIR_IN)1650 PDMDrvHlpSTAMRegisterF(pDrvIns, &pStreamEx->Core.Cfg.Backend.cFramesBufferSize, STAMTYPE_U32, STAMVISIBILITY_USED, STAMUNIT_NONE, 1651 "Host side: The size of the backend buffer (in frames)", "%s/0-HostBackendBufSize", pStreamEx->Core.Cfg.szName); 1652 if (pStreamEx->Core.Cfg.enmDir == PDMAUDIODIR_IN) 1708 1653 { 1709 1654 /** @todo later? */ … … 1712 1657 { 1713 1658 PDMDrvHlpSTAMRegisterF(pDrvIns, &pStreamEx->Out.Stats.cbBackendWritableBefore, STAMTYPE_U32, STAMVISIBILITY_USED, STAMUNIT_NONE, 1714 "Host side: Free space in backend buffer before play", "%s/0-HostBackendBufFreeBefore", pStreamEx->Core. szName);1659 "Host side: Free space in backend buffer before play", "%s/0-HostBackendBufFreeBefore", pStreamEx->Core.Cfg.szName); 1715 1660 PDMDrvHlpSTAMRegisterF(pDrvIns, &pStreamEx->Out.Stats.cbBackendWritableAfter, STAMTYPE_U32, STAMVISIBILITY_USED, STAMUNIT_NONE, 1716 "Host side: Free space in backend buffer after play", "%s/0-HostBackendBufFreeAfter", pStreamEx->Core. szName);1661 "Host side: Free space in backend buffer after play", "%s/0-HostBackendBufFreeAfter", pStreamEx->Core.Cfg.szName); 1717 1662 } 1718 1663 1719 1664 #ifdef VBOX_WITH_STATISTICS 1720 if (p CfgGuest->enmDir == PDMAUDIODIR_IN)1665 if (pStreamEx->Core.Cfg.enmDir == PDMAUDIODIR_IN) 1721 1666 { 1722 1667 PDMDrvHlpSTAMRegisterF(pDrvIns, &pStreamEx->In.Stats.TotalFramesCaptured, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_NONE, 1723 "Total frames played.", "%s/TotalFramesCaptured", pStreamEx->Core. szName);1668 "Total frames played.", "%s/TotalFramesCaptured", pStreamEx->Core.Cfg.szName); 1724 1669 PDMDrvHlpSTAMRegisterF(pDrvIns, &pStreamEx->In.Stats.TotalTimesCaptured, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_NONE, 1725 "Total number of playbacks.", "%s/TotalTimesCaptured", pStreamEx->Core. szName);1670 "Total number of playbacks.", "%s/TotalTimesCaptured", pStreamEx->Core.Cfg.szName); 1726 1671 PDMDrvHlpSTAMRegisterF(pDrvIns, &pStreamEx->In.Stats.TotalTimesRead, STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_NONE, 1727 "Total number of reads.", "%s/TotalTimesRead", pStreamEx->Core. szName);1672 "Total number of reads.", "%s/TotalTimesRead", pStreamEx->Core.Cfg.szName); 1728 1673 } 1729 1674 else 1730 1675 { 1731 Assert(p CfgGuest->enmDir == PDMAUDIODIR_OUT);1676 Assert(pStreamEx->Core.Cfg.enmDir == PDMAUDIODIR_OUT); 1732 1677 } 1733 1678 #endif /* VBOX_WITH_STATISTICS */ 1734 1679 1735 LogFlowFunc(("[%s] Returning %Rrc\n", pStreamEx->Core. szName, rc));1680 LogFlowFunc(("[%s] Returning %Rrc\n", pStreamEx->Core.Cfg.szName, rc)); 1736 1681 return rc; 1737 1682 } … … 1741 1686 * @interface_method_impl{PDMIAUDIOCONNECTOR,pfnStreamCreate} 1742 1687 */ 1743 static DECLCALLBACK(int) drvAudioStreamCreate(PPDMIAUDIOCONNECTOR pInterface, uint32_t fFlags, P PDMAUDIOSTREAMCFG pCfgHost,1744 PPDMAUDIOSTREAM CFG pCfgGuest, PPDMAUDIOSTREAM*ppStream)1688 static DECLCALLBACK(int) drvAudioStreamCreate(PPDMIAUDIOCONNECTOR pInterface, uint32_t fFlags, PCPDMAUDIOSTREAMCFG pCfgReq, 1689 PPDMAUDIOSTREAM *ppStream) 1745 1690 { 1746 1691 PDRVAUDIO pThis = RT_FROM_MEMBER(pInterface, DRVAUDIO, IAudioConnector); … … 1751 1696 */ 1752 1697 AssertReturn(!(fFlags & ~PDMAUDIOSTREAM_CREATE_F_NO_MIXBUF), VERR_INVALID_FLAGS); 1753 AssertPtrReturn(pCfg Host,VERR_INVALID_POINTER);1754 AssertPtrReturn(p CfgGuest,VERR_INVALID_POINTER);1755 AssertPtrReturn(ppStream, VERR_INVALID_POINTER);1756 LogFlowFunc((" Host=%s, Guest=%s\n", pCfgHost->szName, pCfgGuest->szName));1698 AssertPtrReturn(pCfgReq, VERR_INVALID_POINTER); 1699 AssertPtrReturn(ppStream, VERR_INVALID_POINTER); 1700 *ppStream = NULL; 1701 LogFlowFunc(("pCfgReq=%s\n", pCfgReq->szName)); 1757 1702 #ifdef LOG_ENABLED 1758 PDMAudioStrmCfgLog(pCfgHost); 1759 PDMAudioStrmCfgLog(pCfgGuest); 1703 PDMAudioStrmCfgLog(pCfgReq); 1760 1704 #endif 1761 AssertReturn(AudioHlpStreamCfgIsValid(pCfgHost), VERR_INVALID_PARAMETER); 1762 AssertReturn(AudioHlpStreamCfgIsValid(pCfgGuest), VERR_INVALID_PARAMETER); 1763 AssertReturn(pCfgHost->enmDir == pCfgGuest->enmDir, VERR_MISMATCH); 1764 AssertReturn(pCfgHost->enmDir == PDMAUDIODIR_IN || pCfgHost->enmDir == PDMAUDIODIR_OUT, VERR_NOT_SUPPORTED); 1705 AssertReturn(AudioHlpStreamCfgIsValid(pCfgReq), VERR_INVALID_PARAMETER); 1706 AssertReturn(pCfgReq->enmDir == PDMAUDIODIR_IN || pCfgReq->enmDir == PDMAUDIODIR_OUT, VERR_NOT_SUPPORTED); 1765 1707 1766 1708 /* … … 1770 1712 AssertRCReturn(rc, rc); 1771 1713 1772 uint32_t * const pcFreeStreams = pCfg Host->enmDir == PDMAUDIODIR_IN ? &pThis->In.cStreamsFree : &pThis->Out.cStreamsFree;1714 uint32_t * const pcFreeStreams = pCfgReq->enmDir == PDMAUDIODIR_IN ? &pThis->In.cStreamsFree : &pThis->Out.cStreamsFree; 1773 1715 if (*pcFreeStreams > 0) 1774 1716 *pcFreeStreams -= 1; … … 1776 1718 { 1777 1719 RTCritSectRwLeaveExcl(&pThis->CritSectGlobals); 1778 LogFlowFunc(("Maximum number of host %s streams reached\n", PDMAudioDirGetName(pCfg Host->enmDir) ));1779 return pCfg Host->enmDir == PDMAUDIODIR_IN ? VERR_AUDIO_NO_FREE_INPUT_STREAMS : VERR_AUDIO_NO_FREE_OUTPUT_STREAMS;1720 LogFlowFunc(("Maximum number of host %s streams reached\n", PDMAudioDirGetName(pCfgReq->enmDir) )); 1721 return pCfgReq->enmDir == PDMAUDIODIR_IN ? VERR_AUDIO_NO_FREE_INPUT_STREAMS : VERR_AUDIO_NO_FREE_OUTPUT_STREAMS; 1780 1722 } 1781 1723 … … 1811 1753 1812 1754 pStreamEx->pBackend = pBackend; 1813 pStreamEx->Core. enmDir = pCfgHost->enmDir;1755 pStreamEx->Core.Cfg = *pCfgReq; 1814 1756 pStreamEx->Core.cbBackend = (uint32_t)cbHstStrm; 1815 1757 pStreamEx->fDestroyImmediate = true; … … 1819 1761 /* Make a unqiue stream name including the host (backend) driver name. */ 1820 1762 AssertPtr(pThis->pHostDrvAudio); 1821 size_t cchName = RTStrPrintf(pStreamEx->Core. szName, RT_ELEMENTS(pStreamEx->Core.szName), "[%s] %s:0",1822 pThis->BackendCfg.szName, pCfg Host->szName[0] != '\0' ? pCfgHost->szName : "<NoName>");1823 if (cchName < sizeof(pStreamEx->Core. szName))1763 size_t cchName = RTStrPrintf(pStreamEx->Core.Cfg.szName, RT_ELEMENTS(pStreamEx->Core.Cfg.szName), "[%s] %s:0", 1764 pThis->BackendCfg.szName, pCfgReq->szName[0] != '\0' ? pCfgReq->szName : "<NoName>"); 1765 if (cchName < sizeof(pStreamEx->Core.Cfg.szName)) 1824 1766 { 1825 1767 RTCritSectRwEnterShared(&pThis->CritSectGlobals); … … 1830 1772 RTListForEach(&pThis->LstStreams, pIt, DRVAUDIOSTREAM, ListEntry) 1831 1773 { 1832 if (strcmp(pIt->Core. szName, pStreamEx->Core.szName) == 0)1774 if (strcmp(pIt->Core.Cfg.szName, pStreamEx->Core.Cfg.szName) == 0) 1833 1775 { 1834 RTStrPrintf(pStreamEx->Core. szName, RT_ELEMENTS(pStreamEx->Core.szName), "[%s] %s:%u",1835 pThis->BackendCfg.szName, pCfg Host->szName[0] != '\0' ? pCfgHost->szName : "<NoName>",1776 RTStrPrintf(pStreamEx->Core.Cfg.szName, RT_ELEMENTS(pStreamEx->Core.Cfg.szName), "[%s] %s:%u", 1777 pThis->BackendCfg.szName, pCfgReq->szName[0] != '\0' ? pCfgReq->szName : "<NoName>", 1836 1778 i); 1837 1779 fDone = false; … … 1848 1790 * Try to init the rest. 1849 1791 */ 1850 rc = drvAudioStreamInitInternal(pThis, pStreamEx , pCfgHost, pCfgGuest);1792 rc = drvAudioStreamInitInternal(pThis, pStreamEx); 1851 1793 if (RT_SUCCESS(rc)) 1852 1794 { … … 1866 1808 * Init debug stuff if enabled (ignore failures). 1867 1809 */ 1868 if (pCfg Host->enmDir == PDMAUDIODIR_IN)1810 if (pCfgReq->enmDir == PDMAUDIODIR_IN) 1869 1811 { 1870 1812 if (pThis->CfgIn.Dbg.fEnabled) 1871 1813 AudioHlpFileCreateAndOpen(&pStreamEx->In.Dbg.pFileCapture, pThis->CfgIn.Dbg.szPathOut, 1872 "DrvAudioCapture", pThis->pDrvIns->iInstance, &pStreamEx-> Host.Cfg.Props);1814 "DrvAudioCapture", pThis->pDrvIns->iInstance, &pStreamEx->Core.Cfg.Props); 1873 1815 } 1874 1816 else /* Out */ … … 1876 1818 if (pThis->CfgOut.Dbg.fEnabled) 1877 1819 AudioHlpFileCreateAndOpen(&pStreamEx->Out.Dbg.pFilePlay, pThis->CfgOut.Dbg.szPathOut, 1878 "DrvAudioPlay", pThis->pDrvIns->iInstance, &pStreamEx-> Host.Cfg.Props);1820 "DrvAudioPlay", pThis->pDrvIns->iInstance, &pStreamEx->Core.Cfg.Props); 1879 1821 } 1880 1822 … … 1957 1899 char szStreamSts[DRVAUDIO_STATUS_STR_MAX]; 1958 1900 #endif 1959 LogFunc(("[%s] fStatus=%s\n", pStreamEx->Core. szName, drvAudioStreamStatusToStr(szStreamSts, pStreamEx->fStatus)));1901 LogFunc(("[%s] fStatus=%s\n", pStreamEx->Core.Cfg.szName, drvAudioStreamStatusToStr(szStreamSts, pStreamEx->fStatus))); 1960 1902 1961 1903 if (pStreamEx->fStatus & PDMAUDIOSTREAM_STS_BACKEND_CREATED) … … 1974 1916 } 1975 1917 1976 LogFlowFunc(("[%s] Returning %Rrc\n", pStreamEx->Core. szName, rc));1918 LogFlowFunc(("[%s] Returning %Rrc\n", pStreamEx->Core.Cfg.szName, rc)); 1977 1919 return rc; 1978 1920 } … … 1991 1933 AssertPtrReturn(pThis, VERR_INVALID_POINTER); 1992 1934 AssertMsgReturn(pStreamEx->cRefs <= 1, 1993 ("Stream '%s' still has %RU32 references held when uninitializing\n", pStreamEx->Core. szName, pStreamEx->cRefs),1935 ("Stream '%s' still has %RU32 references held when uninitializing\n", pStreamEx->Core.Cfg.szName, pStreamEx->cRefs), 1994 1936 VERR_WRONG_ORDER); 1995 LogFlowFunc(("[%s] cRefs=%RU32\n", pStreamEx->Core. szName, pStreamEx->cRefs));1937 LogFlowFunc(("[%s] cRefs=%RU32\n", pStreamEx->Core.Cfg.szName, pStreamEx->cRefs)); 1996 1938 1997 1939 RTCritSectEnter(&pStreamEx->Core.CritSect); … … 2005 1947 2006 1948 /* Free pre-buffer space. */ 2007 if ( pStreamEx->Core. enmDir == PDMAUDIODIR_OUT1949 if ( pStreamEx->Core.Cfg.enmDir == PDMAUDIODIR_OUT 2008 1950 && pStreamEx->Out.pbPreBuf) 2009 1951 { … … 2022 1964 char szStreamSts[DRVAUDIO_STATUS_STR_MAX]; 2023 1965 LogFunc(("[%s] Warning: Still has %s set when uninitializing\n", 2024 pStreamEx->Core. szName, drvAudioStreamStatusToStr(szStreamSts, pStreamEx->fStatus)));1966 pStreamEx->Core.Cfg.szName, drvAudioStreamStatusToStr(szStreamSts, pStreamEx->fStatus))); 2025 1967 } 2026 1968 #endif … … 2029 1971 2030 1972 PPDMDRVINS const pDrvIns = pThis->pDrvIns; 2031 PDMDrvHlpSTAMDeregisterByPrefix(pDrvIns, pStreamEx->Core. szName);2032 2033 if (pStreamEx->Core. enmDir == PDMAUDIODIR_IN)1973 PDMDrvHlpSTAMDeregisterByPrefix(pDrvIns, pStreamEx->Core.Cfg.szName); 1974 1975 if (pStreamEx->Core.Cfg.enmDir == PDMAUDIODIR_IN) 2034 1976 { 2035 1977 if (pThis->CfgIn.Dbg.fEnabled) … … 2041 1983 else 2042 1984 { 2043 Assert(pStreamEx->Core. enmDir == PDMAUDIODIR_OUT);1985 Assert(pStreamEx->Core.Cfg.enmDir == PDMAUDIODIR_OUT); 2044 1986 if (pThis->CfgOut.Dbg.fEnabled) 2045 1987 { … … 2087 2029 RTCritSectRwEnterExcl(&pThis->CritSectGlobals); 2088 2030 2089 if (pStreamEx->Core. enmDir == PDMAUDIODIR_IN)2031 if (pStreamEx->Core.Cfg.enmDir == PDMAUDIODIR_IN) 2090 2032 pThis->In.cStreamsFree++; 2091 2033 else /* Out */ … … 2101 2043 else 2102 2044 { 2103 LogRel(("Audio: Uninitializing stream '%s' failed with %Rrc\n", pStreamEx->Core. szName, rc));2045 LogRel(("Audio: Uninitializing stream '%s' failed with %Rrc\n", pStreamEx->Core.Cfg.szName, rc)); 2104 2046 /** @todo r=bird: What's the plan now? */ 2105 2047 } … … 2111 2053 } 2112 2054 2113 Log12Func(("returns %u (%s)\n", cRefs, cRefs > 0 ? pStreamEx->Core. szName : "destroyed"));2055 Log12Func(("returns %u (%s)\n", cRefs, cRefs > 0 ? pStreamEx->Core.Cfg.szName : "destroyed")); 2114 2056 return cRefs; 2115 2057 } … … 2127 2069 static DECLCALLBACK(void) drvAudioStreamDestroyAsync(PDRVAUDIO pThis, PDRVAUDIOSTREAM pStreamEx, bool fImmediate) 2128 2070 { 2129 LogFlowFunc(("pThis=%p pStreamEx=%p (%s) fImmediate=%RTbool\n", pThis, pStreamEx, pStreamEx->Core. szName, fImmediate));2071 LogFlowFunc(("pThis=%p pStreamEx=%p (%s) fImmediate=%RTbool\n", pThis, pStreamEx, pStreamEx->Core.Cfg.szName, fImmediate)); 2130 2072 #ifdef LOG_ENABLED 2131 2073 uint64_t const nsStart = RTTimeNanoTS(); … … 2166 2108 PDRVAUDIOSTREAM pStreamEx = (PDRVAUDIOSTREAM)pStream; /* Note! Do not touch pStream after this! */ 2167 2109 AssertPtrReturn(pStreamEx, VERR_INVALID_POINTER); 2168 LogFlowFunc(("ENTER - %p (%s) fImmediate=%RTbool\n", pStreamEx, pStreamEx->Core. szName, fImmediate));2110 LogFlowFunc(("ENTER - %p (%s) fImmediate=%RTbool\n", pStreamEx, pStreamEx->Core.Cfg.szName, fImmediate)); 2169 2111 AssertReturn(pStreamEx->Core.uMagic == PDMAUDIOSTREAM_MAGIC, VERR_INVALID_MAGIC); 2170 2112 AssertReturn(pStreamEx->uMagic == DRVAUDIOSTREAM_MAGIC, VERR_INVALID_MAGIC); … … 2185 2127 char szStatus[DRVAUDIO_STATUS_STR_MAX]; 2186 2128 LogRel2(("Audio: Destroying stream '%s': cRefs=%u; status: %s; backend: %s; hReqInitAsync=%p\n", 2187 pStreamEx->Core. szName, pStreamEx->cRefs, drvAudioStreamStatusToStr(szStatus, pStreamEx->fStatus),2129 pStreamEx->Core.Cfg.szName, pStreamEx->cRefs, drvAudioStreamStatusToStr(szStatus, pStreamEx->fStatus), 2188 2130 PDMHostAudioStreamStateGetName(drvAudioStreamGetBackendState(pThis, pStreamEx)), 2189 2131 pStreamEx->hReqInitAsync)); … … 2263 2205 static void drvAudioStreamResetInternal(PDRVAUDIOSTREAM pStreamEx) 2264 2206 { 2265 LogFunc(("[%s]\n", pStreamEx->Core. szName));2207 LogFunc(("[%s]\n", pStreamEx->Core.Cfg.szName)); 2266 2208 Assert(RTCritSectIsOwner(&pStreamEx->Core.CritSect)); 2267 2209 … … 2269 2211 pStreamEx->nsLastPlayedCaptured = 0; 2270 2212 pStreamEx->nsLastReadWritten = 0; 2271 if (pStreamEx-> Host.Cfg.enmDir == PDMAUDIODIR_OUT)2213 if (pStreamEx->Core.Cfg.enmDir == PDMAUDIODIR_OUT) 2272 2214 { 2273 2215 pStreamEx->Out.cbPreBuffered = 0; … … 2298 2240 { 2299 2241 char szTmp[RT_MAX(PDMAUDIOSTRMCFGTOSTRING_MAX, DRVAUDIO_STATUS_STR_MAX)]; 2300 LogFlowFunc(("[%s] status: %s\n", pStreamEx->Core. szName, drvAudioStreamStatusToStr(szTmp, pStreamEx->fStatus) ));2242 LogFlowFunc(("[%s] status: %s\n", pStreamEx->Core.Cfg.szName, drvAudioStreamStatusToStr(szTmp, pStreamEx->fStatus) )); 2301 2243 Assert(RTCritSectIsOwner(&pStreamEx->Core.CritSect)); 2302 2244 RTCritSectRwEnterShared(&pThis->CritSectHotPlug); … … 2317 2259 drvAudioStreamResetInternal(pStreamEx); 2318 2260 2319 /** @todo 2320 * We need to zero the backend storage here!! 2321 * We need to zero the backend storage here!! 2322 * We need to zero the backend storage here!! 2323 * We need to zero the backend storage here!! 2324 * We need to zero the backend storage here!! 2325 * We need to zero the backend storage here!! 2326 * We need to zero the backend storage here!! 2327 * */ 2328 PDMAUDIOSTREAMCFG CfgHostAcq; 2329 rc = drvAudioStreamCreateInternalBackend(pThis, pStreamEx, &pStreamEx->Host.Cfg, &CfgHostAcq); 2261 RT_BZERO(pStreamEx->pBackend + 1, pStreamEx->Core.cbBackend - sizeof(*pStreamEx->pBackend)); 2262 2263 rc = drvAudioStreamCreateInternalBackend(pThis, pStreamEx); 2330 2264 if (RT_SUCCESS(rc)) 2331 2265 { 2332 2266 LogFunc(("[%s] Acquired host format: %s\n", 2333 pStreamEx->Core. szName, PDMAudioStrmCfgToString(&CfgHostAcq, szTmp, sizeof(szTmp)) ));2334 /** @todo Validate (re-)acquired configuration with pStreamEx->Core. Host.Cfg?2267 pStreamEx->Core.Cfg.szName, PDMAudioStrmCfgToString(&pStreamEx->Core.Cfg, szTmp, sizeof(szTmp)) )); 2268 /** @todo Validate (re-)acquired configuration with pStreamEx->Core.Core.Cfg? 2335 2269 * drvAudioStreamInitInternal() does some setup and a bunch of 2336 2270 * validations + adjustments of the stream config, so this surely is quite … … 2373 2307 else 2374 2308 { 2375 LogRel(("Audio: Re-initializing stream '%s' somehow failed, status: %s\n", pStreamEx->Core. szName,2309 LogRel(("Audio: Re-initializing stream '%s' somehow failed, status: %s\n", pStreamEx->Core.Cfg.szName, 2376 2310 drvAudioStreamStatusToStr(szTmp, pStreamEx->fStatus) )); 2377 2311 AssertFailed(); … … 2381 2315 } 2382 2316 else 2383 LogRel(("Audio: Re-initializing stream '%s' failed with %Rrc\n", pStreamEx->Core. szName, rc));2317 LogRel(("Audio: Re-initializing stream '%s' failed with %Rrc\n", pStreamEx->Core.Cfg.szName, rc)); 2384 2318 } 2385 2319 else 2386 2320 { 2387 LogRel(("Audio: Re-initializing stream '%s' failed to destroy previous backend.\n", pStreamEx->Core. szName));2321 LogRel(("Audio: Re-initializing stream '%s' failed to destroy previous backend.\n", pStreamEx->Core.Cfg.szName)); 2388 2322 AssertFailed(); 2389 2323 } 2390 2324 2391 2325 RTCritSectRwLeaveShared(&pThis->CritSectHotPlug); 2392 LogFunc(("[%s] Returning %Rrc\n", pStreamEx->Core. szName, rc));2326 LogFunc(("[%s] Returning %Rrc\n", pStreamEx->Core.Cfg.szName, rc)); 2393 2327 return rc; 2394 2328 } … … 2439 2373 { 2440 2374 LogRel(("Audio: Re-initializing stream '%s' exceeded maximum retries (%u), leaving as disabled\n", 2441 pStreamEx->Core. szName, cMaxTries));2375 pStreamEx->Core.Cfg.szName, cMaxTries)); 2442 2376 2443 2377 /* Don't try to re-initialize anymore and mark as disabled. */ … … 2457 2391 char szStreamSts[DRVAUDIO_STATUS_STR_MAX]; 2458 2392 #endif 2459 Log3Func(("[%s] fStatus=%s\n", pStreamEx->Core. szName, drvAudioStreamStatusToStr(szStreamSts, pStreamEx->fStatus)));2393 Log3Func(("[%s] fStatus=%s\n", pStreamEx->Core.Cfg.szName, drvAudioStreamStatusToStr(szStreamSts, pStreamEx->fStatus))); 2460 2394 } 2461 2395 else … … 2488 2422 Assert(cRefs < _1K); 2489 2423 2490 Log12Func(("returns %u (%s)\n", cRefs, pStreamEx->Core. szName));2424 Log12Func(("returns %u (%s)\n", cRefs, pStreamEx->Core.Cfg.szName)); 2491 2425 return cRefs; 2492 2426 } … … 2547 2481 * finish initializing the stream, we'll update it about the stream state. 2548 2482 */ 2549 bool const fDirEnabled = pStreamEx->Core. enmDir == PDMAUDIODIR_IN2483 bool const fDirEnabled = pStreamEx->Core.Cfg.enmDir == PDMAUDIODIR_IN 2550 2484 ? pThis->In.fEnabled : pThis->Out.fEnabled; 2551 2485 PDMHOSTAUDIOSTREAMSTATE const enmBackendState = drvAudioStreamGetBackendState(pThis, pStreamEx); … … 2554 2488 char szStreamSts[DRVAUDIO_STATUS_STR_MAX]; 2555 2489 LogRel2(("Audio: %s stream '%s' backend (%s is %s; status: %s; backend-status: %s)\n", 2556 PDMAudioStrmCmdGetName(enmStreamCmd), pStreamEx->Core. szName, PDMAudioDirGetName(pStreamEx->Core.enmDir),2490 PDMAudioStrmCmdGetName(enmStreamCmd), pStreamEx->Core.Cfg.szName, PDMAudioDirGetName(pStreamEx->Core.Cfg.enmDir), 2557 2491 fDirEnabled ? "enabled" : "disabled", drvAudioStreamStatusToStr(szStreamSts, pStreamEx->fStatus), 2558 2492 PDMHostAudioStreamStateGetName(enmBackendState) )); … … 2597 2531 } 2598 2532 if (RT_SUCCESS(rc)) 2599 Log2Func(("[%s] %s succeeded (%Rrc)\n", pStreamEx->Core. szName, PDMAudioStrmCmdGetName(enmStreamCmd), rc));2533 Log2Func(("[%s] %s succeeded (%Rrc)\n", pStreamEx->Core.Cfg.szName, PDMAudioStrmCmdGetName(enmStreamCmd), rc)); 2600 2534 else 2601 2535 { 2602 LogFunc(("[%s] %s failed with %Rrc\n", pStreamEx->Core. szName, PDMAudioStrmCmdGetName(enmStreamCmd), rc));2536 LogFunc(("[%s] %s failed with %Rrc\n", pStreamEx->Core.Cfg.szName, PDMAudioStrmCmdGetName(enmStreamCmd), rc)); 2603 2537 if ( rc != VERR_NOT_IMPLEMENTED 2604 2538 && rc != VERR_NOT_SUPPORTED 2605 2539 && rc != VERR_AUDIO_STREAM_NOT_READY) 2606 LogRel(("Audio: %s stream '%s' failed with %Rrc\n", PDMAudioStrmCmdGetName(enmStreamCmd), pStreamEx->Core. szName, rc));2540 LogRel(("Audio: %s stream '%s' failed with %Rrc\n", PDMAudioStrmCmdGetName(enmStreamCmd), pStreamEx->Core.Cfg.szName, rc)); 2607 2541 } 2608 2542 } … … 2628 2562 drvAudioStreamResetInternal(pStreamEx); 2629 2563 2630 LogFunc(("[%s]\n", pStreamEx->Core. szName));2564 LogFunc(("[%s]\n", pStreamEx->Core.Cfg.szName)); 2631 2565 2632 2566 pStreamEx->fStatus &= PDMAUDIOSTREAM_STS_BACKEND_CREATED | PDMAUDIOSTREAM_STS_BACKEND_READY; … … 2637 2571 * Reset statistics. 2638 2572 */ 2639 if (pStreamEx->Core. enmDir == PDMAUDIODIR_IN)2573 if (pStreamEx->Core.Cfg.enmDir == PDMAUDIODIR_IN) 2640 2574 { 2641 2575 STAM_COUNTER_RESET(&pStreamEx->In.Stats.TotalFramesCaptured); … … 2643 2577 STAM_COUNTER_RESET(&pStreamEx->In.Stats.TotalTimesRead); 2644 2578 } 2645 else if (pStreamEx->Core. enmDir == PDMAUDIODIR_OUT)2579 else if (pStreamEx->Core.Cfg.enmDir == PDMAUDIODIR_OUT) 2646 2580 { 2647 2581 } … … 2669 2603 char szStreamSts[DRVAUDIO_STATUS_STR_MAX]; 2670 2604 #endif 2671 LogFunc(("[%s] enmStreamCmd=%s fStatus=%s\n", pStreamEx->Core. szName, PDMAudioStrmCmdGetName(enmStreamCmd),2605 LogFunc(("[%s] enmStreamCmd=%s fStatus=%s\n", pStreamEx->Core.Cfg.szName, PDMAudioStrmCmdGetName(enmStreamCmd), 2672 2606 drvAudioStreamStatusToStr(szStreamSts, pStreamEx->fStatus))); 2673 2607 … … 2682 2616 if (pStreamEx->fStatus & PDMAUDIOSTREAM_STS_PENDING_DISABLE) 2683 2617 { 2684 LogFunc(("Stream '%s' is still draining - disabling...\n", pStreamEx->Core. szName));2618 LogFunc(("Stream '%s' is still draining - disabling...\n", pStreamEx->Core.Cfg.szName)); 2685 2619 rc = drvAudioStreamControlInternalBackend(pThis, pStreamEx, PDMAUDIOSTREAMCMD_DISABLE); 2686 2620 AssertRC(rc); … … 2700 2634 pStreamEx->offInternal = 0; 2701 2635 2702 if (pStreamEx->Core. enmDir == PDMAUDIODIR_OUT)2636 if (pStreamEx->Core.Cfg.enmDir == PDMAUDIODIR_OUT) 2703 2637 { 2704 2638 pStreamEx->Out.cbPreBuffered = 0; … … 2773 2707 { 2774 2708 rc = drvAudioStreamControlInternalBackend(pThis, pStreamEx, PDMAUDIOSTREAMCMD_DISABLE); 2775 LogFunc(("DISABLE '%s': Backend DISABLE -> %Rrc\n", pStreamEx->Core. szName, rc));2709 LogFunc(("DISABLE '%s': Backend DISABLE -> %Rrc\n", pStreamEx->Core.Cfg.szName, rc)); 2776 2710 if (RT_SUCCESS(rc)) /** @todo ignore this and reset it anyway? */ 2777 2711 drvAudioStreamResetOnDisable(pStreamEx); … … 2808 2742 * Only for output streams and we don't want this command more than once. 2809 2743 */ 2810 AssertReturn(pStreamEx->Core. enmDir == PDMAUDIODIR_OUT, VERR_INVALID_FUNCTION);2744 AssertReturn(pStreamEx->Core.Cfg.enmDir == PDMAUDIODIR_OUT, VERR_INVALID_FUNCTION); 2811 2745 AssertBreak(!(pStreamEx->fStatus & PDMAUDIOSTREAM_STS_PENDING_DISABLE)); 2812 2746 if (pStreamEx->fStatus & PDMAUDIOSTREAM_STS_ENABLED) … … 2818 2752 if (pStreamEx->Out.cbPreBuffered > 0) 2819 2753 { 2820 LogFunc(("DRAIN '%s': Initiating draining of pre-buffered data...\n", pStreamEx->Core. szName));2754 LogFunc(("DRAIN '%s': Initiating draining of pre-buffered data...\n", pStreamEx->Core.Cfg.szName)); 2821 2755 pStreamEx->Out.enmPlayState = DRVAUDIOPLAYSTATE_PREBUF_COMMITTING; 2822 2756 pStreamEx->fStatus |= PDMAUDIOSTREAM_STS_PENDING_DISABLE; … … 2830 2764 case DRVAUDIOPLAYSTATE_PREBUF_OVERDUE: 2831 2765 LogFunc(("DRAIN '%s': Nothing to drain (enmPlayState=%s)\n", 2832 pStreamEx->Core. szName, drvAudioPlayStateName(pStreamEx->Out.enmPlayState)));2766 pStreamEx->Core.Cfg.szName, drvAudioPlayStateName(pStreamEx->Out.enmPlayState))); 2833 2767 rc = drvAudioStreamControlInternalBackend(pThis, pStreamEx, PDMAUDIOSTREAMCMD_DISABLE); 2834 2768 AssertRC(rc); … … 2839 2773 case DRVAUDIOPLAYSTATE_PLAY_PREBUF: 2840 2774 LogFunc(("DRAIN '%s': Initiating backend draining (enmPlayState=%s -> NOPLAY) ...\n", 2841 pStreamEx->Core. szName, drvAudioPlayStateName(pStreamEx->Out.enmPlayState)));2775 pStreamEx->Core.Cfg.szName, drvAudioPlayStateName(pStreamEx->Out.enmPlayState))); 2842 2776 pStreamEx->Out.enmPlayState = DRVAUDIOPLAYSTATE_NOPLAY; 2843 2777 rc = drvAudioStreamControlInternalBackend(pThis, pStreamEx, PDMAUDIOSTREAMCMD_DRAIN); … … 2850 2784 { 2851 2785 LogFunc(("DRAIN '%s': Backend DRAIN failed with %Rrc, disabling the stream instead...\n", 2852 pStreamEx->Core. szName, rc));2786 pStreamEx->Core.Cfg.szName, rc)); 2853 2787 rc = drvAudioStreamControlInternalBackend(pThis, pStreamEx, PDMAUDIOSTREAMCMD_DISABLE); 2854 2788 AssertRC(rc); … … 2859 2793 case DRVAUDIOPLAYSTATE_PREBUF_COMMITTING: 2860 2794 LogFunc(("DRAIN '%s': Initiating draining of pre-buffered data (already committing)...\n", 2861 pStreamEx->Core. szName));2795 pStreamEx->Core.Cfg.szName)); 2862 2796 pStreamEx->fStatus |= PDMAUDIOSTREAM_STS_PENDING_DISABLE; 2863 2797 PDMAUDIOSTREAM_STS_ASSERT_VALID(pStreamEx->fStatus); … … 2879 2813 2880 2814 if (RT_FAILURE(rc)) 2881 LogFunc(("[%s] Failed with %Rrc\n", pStreamEx->Core. szName, rc));2815 LogFunc(("[%s] Failed with %Rrc\n", pStreamEx->Core.Cfg.szName, rc)); 2882 2816 2883 2817 return rc; … … 2905 2839 AssertRCReturn(rc, rc); 2906 2840 2907 LogFlowFunc(("[%s] enmStreamCmd=%s\n", pStream ->szName, PDMAudioStrmCmdGetName(enmStreamCmd)));2841 LogFlowFunc(("[%s] enmStreamCmd=%s\n", pStreamEx->Core.Cfg.szName, PDMAudioStrmCmdGetName(enmStreamCmd))); 2908 2842 2909 2843 rc = drvAudioStreamControlInternal(pThis, pStreamEx, enmStreamCmd); … … 2982 2916 const uint8_t *pbBuf, uint32_t cbBuf, uint32_t *pcbWritten) 2983 2917 { 2984 Log3Func(("%s: @%#RX64: cbBuf=%#x\n", pStreamEx->Core. szName, pStreamEx->offInternal, cbBuf));2918 Log3Func(("%s: @%#RX64: cbBuf=%#x\n", pStreamEx->Core.Cfg.szName, pStreamEx->offInternal, cbBuf)); 2985 2919 2986 2920 uint32_t cbWritable = pThis->pHostDrvAudio->pfnStreamGetWritable(pThis->pHostDrvAudio, pStreamEx->pBackend); … … 2989 2923 uint32_t cbWritten = 0; 2990 2924 int rc = VINF_SUCCESS; 2991 uint8_t const cbFrame = PDMAudioPropsFrameSize(&pStreamEx->Core. Props);2925 uint8_t const cbFrame = PDMAudioPropsFrameSize(&pStreamEx->Core.Cfg.Props); 2992 2926 while (cbBuf >= cbFrame && cbWritable >= cbFrame) 2993 2927 { 2994 uint32_t const cbToWrite = PDMAudioPropsFloorBytesToFrame(&pStreamEx->Core. Props, RT_MIN(cbBuf, cbWritable));2928 uint32_t const cbToWrite = PDMAudioPropsFloorBytesToFrame(&pStreamEx->Core.Cfg.Props, RT_MIN(cbBuf, cbWritable)); 2995 2929 uint32_t cbWrittenNow = 0; 2996 2930 rc = pThis->pHostDrvAudio->pfnStreamPlay(pThis->pHostDrvAudio, pStreamEx->pBackend, pbBuf, cbToWrite, &cbWrittenNow); … … 2999 2933 if (cbWrittenNow != cbToWrite) 3000 2934 Log3Func(("%s: @%#RX64: Wrote fewer bytes than requested: %#x, requested %#x\n", 3001 pStreamEx->Core. szName, pStreamEx->offInternal, cbWrittenNow, cbToWrite));2935 pStreamEx->Core.Cfg.szName, pStreamEx->offInternal, cbWrittenNow, cbToWrite)); 3002 2936 #ifdef DEBUG_bird 3003 2937 Assert(cbWrittenNow == cbToWrite); … … 3013 2947 *pcbWritten = cbWritten; 3014 2948 LogFunc(("%s: @%#RX64: pfnStreamPlay failed writing %#x bytes (%#x previous written, %#x writable): %Rrc\n", 3015 pStreamEx->Core. szName, pStreamEx->offInternal, cbToWrite, cbWritten, cbWritable, rc));2949 pStreamEx->Core.Cfg.szName, pStreamEx->offInternal, cbToWrite, cbWritten, cbWritable, rc)); 3016 2950 return cbWritten ? VINF_SUCCESS : rc; 3017 2951 } … … 3025 2959 pStreamEx->nsLastPlayedCaptured = RTTimeNanoTS(); 3026 2960 3027 Log3Func(("%s: @%#RX64: Wrote %#x bytes (%#x bytes left)\n", pStreamEx->Core. szName, pStreamEx->offInternal, cbWritten, cbBuf));2961 Log3Func(("%s: @%#RX64: Wrote %#x bytes (%#x bytes left)\n", pStreamEx->Core.Cfg.szName, pStreamEx->offInternal, cbWritten, cbBuf)); 3028 2962 return rc; 3029 2963 } … … 3042 2976 pStreamEx->offInternal += cbBuf; 3043 2977 Log3Func(("[%s] Pre-buffering (%s): wrote %#x bytes => %#x bytes / %u%%\n", 3044 pStreamEx->Core. szName, drvAudioPlayStateName(pStreamEx->Out.enmPlayState), cbBuf, pStreamEx->Out.cbPreBuffered,2978 pStreamEx->Core.Cfg.szName, drvAudioPlayStateName(pStreamEx->Out.enmPlayState), cbBuf, pStreamEx->Out.cbPreBuffered, 3045 2979 pStreamEx->Out.cbPreBuffered * 100 / RT_MAX(pStreamEx->cbPreBufThreshold, 1))); 3046 2980 … … 3140 3074 3141 3075 LogRel2(("Audio: @%#RX64: Stream '%s' pre-buffering commit problem: wrote %#x out of %#x + %#x - rc=%Rrc *pcbWritten=%#x %s -> PREBUF_COMMITTING\n", 3142 pStreamEx->offInternal, pStreamEx->Core. szName, pStreamEx->Out.cbPreBuffered - cbLeft,3076 pStreamEx->offInternal, pStreamEx->Core.Cfg.szName, pStreamEx->Out.cbPreBuffered - cbLeft, 3143 3077 pStreamEx->Out.cbPreBuffered, cbBuf, rc, *pcbWritten, drvAudioPlayStateName(pStreamEx->Out.enmPlayState) )); 3144 3078 AssertMsg( pStreamEx->Out.enmPlayState == DRVAUDIOPLAYSTATE_PREBUF_COMMITTING … … 3174 3108 char szStreamSts[DRVAUDIO_STATUS_STR_MAX]; 3175 3109 #endif 3176 Log3Func(("[%s] fStatus=%s\n", pStreamEx->Core. szName, drvAudioStreamStatusToStr(szStreamSts, pStreamEx->fStatus)));3110 Log3Func(("[%s] fStatus=%s\n", pStreamEx->Core.Cfg.szName, drvAudioStreamStatusToStr(szStreamSts, pStreamEx->fStatus))); 3177 3111 3178 3112 /* Not enabled or paused? Skip iteration. */ … … 3190 3124 else 3191 3125 { 3192 AssertReturn(pStreamEx->Core. enmDir == PDMAUDIODIR_OUT, VINF_SUCCESS);3126 AssertReturn(pStreamEx->Core.Cfg.enmDir == PDMAUDIODIR_OUT, VINF_SUCCESS); 3193 3127 RTCritSectRwEnterShared(&pThis->CritSectHotPlug); 3194 3128 … … 3202 3136 uint32_t cbIgnored = 0; 3203 3137 drvAudioStreamPreBufComitting(pThis, pStreamEx, NULL, 0, &cbIgnored); 3204 Log3Func(("Stream '%s': Transferred %#x bytes\n", pStreamEx->Core. szName, cbIgnored));3138 Log3Func(("Stream '%s': Transferred %#x bytes\n", pStreamEx->Core.Cfg.szName, cbIgnored)); 3205 3139 } 3206 3140 if (pStreamEx->Out.cbPreBuffered == 0) 3207 3141 { 3208 Log3Func(("Stream '%s': No more pre-buffered data -> NOPLAY + backend DRAIN\n", pStreamEx->Core. szName));3142 Log3Func(("Stream '%s': No more pre-buffered data -> NOPLAY + backend DRAIN\n", pStreamEx->Core.Cfg.szName)); 3209 3143 pStreamEx->Out.enmPlayState = DRVAUDIOPLAYSTATE_NOPLAY; 3210 3144 … … 3213 3147 { 3214 3148 LogFunc(("Stream '%s': Backend DRAIN failed with %Rrc, disabling the stream instead...\n", 3215 pStreamEx->Core. szName, rc));3149 pStreamEx->Core.Cfg.szName, rc)); 3216 3150 rc = drvAudioStreamControlInternalBackend(pThis, pStreamEx, PDMAUDIOSTREAMCMD_DISABLE); 3217 3151 AssertRC(rc); … … 3235 3169 else 3236 3170 { 3237 LogFunc(("Stream '%s': Backend finished draining.\n", pStreamEx->Core. szName));3171 LogFunc(("Stream '%s': Backend finished draining.\n", pStreamEx->Core.Cfg.szName)); 3238 3172 drvAudioStreamResetOnDisable(pStreamEx); 3239 3173 } … … 3294 3228 PDMHOSTAUDIOSTREAMSTATE const enmBackendState = drvAudioStreamGetBackendStateAndProcessChanges(pThis, pStreamEx); 3295 3229 uint32_t const fStrmStatus = pStreamEx->fStatus; 3296 PDMAUDIODIR const enmDir = pStreamEx-> Guest.Cfg.enmDir;3230 PDMAUDIODIR const enmDir = pStreamEx->Core.Cfg.enmDir; 3297 3231 Assert(enmDir == PDMAUDIODIR_IN || enmDir == PDMAUDIODIR_OUT); 3298 3232 … … 3326 3260 char szStreamSts[DRVAUDIO_STATUS_STR_MAX]; 3327 3261 #endif 3328 Log3Func(("[%s] returns %s (status: %s)\n", pStreamEx->Core. szName, PDMAudioStreamStateGetName(enmState),3262 Log3Func(("[%s] returns %s (status: %s)\n", pStreamEx->Core.Cfg.szName, PDMAudioStreamStateGetName(enmState), 3329 3263 drvAudioStreamStatusToStr(szStreamSts, fStrmStatus))); 3330 3264 return enmState; … … 3343 3277 AssertReturn(pStreamEx->Core.uMagic == PDMAUDIOSTREAM_MAGIC, 0); 3344 3278 AssertReturn(pStreamEx->uMagic == DRVAUDIOSTREAM_MAGIC, 0); 3345 AssertMsgReturn(pStreamEx->Core. enmDir == PDMAUDIODIR_OUT, ("Can't write to a non-output stream\n"), 0);3279 AssertMsgReturn(pStreamEx->Core.Cfg.enmDir == PDMAUDIODIR_OUT, ("Can't write to a non-output stream\n"), 0); 3346 3280 3347 3281 int rc = RTCritSectEnter(&pStreamEx->Core.CritSect); … … 3381 3315 cbWritable = pStreamEx->Out.cbPreBufAlloc - pStreamEx->Out.cbPreBuffered; 3382 3316 if (!cbWritable) 3383 cbWritable = PDMAudioPropsFramesToBytes(&pStreamEx->Core. Props, 2);3317 cbWritable = PDMAudioPropsFramesToBytes(&pStreamEx->Core.Cfg.Props, 2); 3384 3318 break; 3385 3319 … … 3392 3326 case DRVAUDIOPLAYSTATE_PREBUF_OVERDUE: 3393 3327 case DRVAUDIOPLAYSTATE_PREBUF_SWITCHING: 3394 cbWritable = PDMAudioPropsFramesToBytes(&pStreamEx->Core. Props,3395 RT_MAX(pStreamEx-> Host.Cfg.Backend.cFramesBufferSize,3396 pStreamEx-> Host.Cfg.Backend.cFramesPreBuffering));3328 cbWritable = PDMAudioPropsFramesToBytes(&pStreamEx->Core.Cfg.Props, 3329 RT_MAX(pStreamEx->Core.Cfg.Backend.cFramesBufferSize, 3330 pStreamEx->Core.Cfg.Backend.cFramesPreBuffering)); 3397 3331 break; 3398 3332 … … 3406 3340 Assert(pStreamEx->fStatus & PDMAUDIOSTREAM_STS_BACKEND_READY); 3407 3341 Assert(enmBackendState == PDMHOSTAUDIOSTREAMSTATE_OKAY /* potential unplug race */); 3408 uint32_t const cbMin = PDMAudioPropsFramesToBytes(&pStreamEx->Core. Props, 8);3342 uint32_t const cbMin = PDMAudioPropsFramesToBytes(&pStreamEx->Core.Cfg.Props, 8); 3409 3343 cbWritable = pThis->pHostDrvAudio->pfnStreamGetWritable(pThis->pHostDrvAudio, pStreamEx->pBackend); 3410 3344 if (cbWritable >= pStreamEx->Out.cbPreBuffered + cbMin) … … 3425 3359 3426 3360 /* Make sure to align the writable size to the host's frame size. */ 3427 cbWritable = PDMAudioPropsFloorBytesToFrame(&pStreamEx->Core. Props, cbWritable);3361 cbWritable = PDMAudioPropsFloorBytesToFrame(&pStreamEx->Core.Cfg.Props, cbWritable); 3428 3362 } 3429 3363 … … 3431 3365 RTCritSectLeave(&pStreamEx->Core.CritSect); 3432 3366 Log3Func(("[%s] cbWritable=%#RX32 (%RU64ms) enmPlayMode=%s enmBackendState=%s\n", 3433 pStreamEx->Core. szName, cbWritable, PDMAudioPropsBytesToMilli(&pStreamEx->Core.Props, cbWritable),3367 pStreamEx->Core.Cfg.szName, cbWritable, PDMAudioPropsBytesToMilli(&pStreamEx->Core.Cfg.Props, cbWritable), 3434 3368 drvAudioPlayStateName(enmPlayMode), PDMHostAudioStreamStateGetName(enmBackendState) )); 3435 3369 return cbWritable; … … 3462 3396 AssertReturn(pStreamEx->Core.uMagic == PDMAUDIOSTREAM_MAGIC, VERR_INVALID_MAGIC); 3463 3397 AssertReturn(pStreamEx->uMagic == DRVAUDIOSTREAM_MAGIC, VERR_INVALID_MAGIC); 3464 AssertMsgReturn(pStreamEx->Core. enmDir == PDMAUDIODIR_OUT,3398 AssertMsgReturn(pStreamEx->Core.Cfg.enmDir == PDMAUDIODIR_OUT, 3465 3399 ("Stream '%s' is not an output stream and therefore cannot be written to (direction is '%s')\n", 3466 pStreamEx->Core. szName, PDMAudioDirGetName(pStreamEx->Core.enmDir)), VERR_ACCESS_DENIED);3467 3468 AssertMsg(PDMAudioPropsIsSizeAligned(&pStreamEx->Core. Props, cbBuf),3469 ("Stream '%s' got a non-frame-aligned write (%#RX32 bytes)\n", pStreamEx->Core. szName, cbBuf));3400 pStreamEx->Core.Cfg.szName, PDMAudioDirGetName(pStreamEx->Core.Cfg.enmDir)), VERR_ACCESS_DENIED); 3401 3402 AssertMsg(PDMAudioPropsIsSizeAligned(&pStreamEx->Core.Cfg.Props, cbBuf), 3403 ("Stream '%s' got a non-frame-aligned write (%#RX32 bytes)\n", pStreamEx->Core.Cfg.szName, cbBuf)); 3470 3404 3471 3405 int rc = RTCritSectEnter(&pStreamEx->Core.CritSect); … … 3512 3446 { 3513 3447 Log3Func(("[%s] Pre-buffering completing: cbBuf=%#x cbPreBuffered=%#x => %#x vs cbPreBufThreshold=%#x\n", 3514 pStreamEx->Core. szName, cbBuf, pStreamEx->Out.cbPreBuffered,3448 pStreamEx->Core.Cfg.szName, cbBuf, pStreamEx->Out.cbPreBuffered, 3515 3449 cbBuf + pStreamEx->Out.cbPreBuffered, pStreamEx->cbPreBufThreshold)); 3516 3450 rc = drvAudioStreamPreBufComitting(pThis, pStreamEx, (uint8_t const *)pvBuf, cbBuf, pcbWritten); … … 3519 3453 { 3520 3454 Log3Func(("[%s] Pre-buffering completing but device not ready: cbBuf=%#x cbPreBuffered=%#x => %#x vs cbPreBufThreshold=%#x; PREBUF -> PREBUF_OVERDUE\n", 3521 pStreamEx->Core. szName, cbBuf, pStreamEx->Out.cbPreBuffered,3455 pStreamEx->Core.Cfg.szName, cbBuf, pStreamEx->Out.cbPreBuffered, 3522 3456 cbBuf + pStreamEx->Out.cbPreBuffered, pStreamEx->cbPreBufThreshold)); 3523 3457 pStreamEx->Out.enmPlayState = DRVAUDIOPLAYSTATE_PREBUF_OVERDUE; … … 3543 3477 *pcbWritten = cbBuf; 3544 3478 pStreamEx->offInternal += cbBuf; 3545 Log3Func(("[%s] Discarding the data, backend state: %s\n", pStreamEx->Core. szName,3479 Log3Func(("[%s] Discarding the data, backend state: %s\n", pStreamEx->Core.Cfg.szName, 3546 3480 PDMHostAudioStreamStateGetName(enmBackendState) )); 3547 3481 break; … … 3561 3495 *pcbWritten = cbBuf; 3562 3496 pStreamEx->offInternal += cbBuf; 3563 Log3Func(("[%s] Backend stream %s, discarding the data\n", pStreamEx->Core. szName,3497 Log3Func(("[%s] Backend stream %s, discarding the data\n", pStreamEx->Core.Cfg.szName, 3564 3498 !pThis->Out.fEnabled ? "disabled" : !pThis->pHostDrvAudio ? "not attached" : "not ready yet")); 3565 3499 } … … 3585 3519 AssertReturn(pStreamEx->Core.uMagic == PDMAUDIOSTREAM_MAGIC, 0); 3586 3520 AssertReturn(pStreamEx->uMagic == DRVAUDIOSTREAM_MAGIC, 0); 3587 AssertMsg(pStreamEx->Core. enmDir == PDMAUDIODIR_IN, ("Can't read from a non-input stream\n"));3521 AssertMsg(pStreamEx->Core.Cfg.enmDir == PDMAUDIODIR_IN, ("Can't read from a non-input stream\n")); 3588 3522 3589 3523 … … 3620 3554 { 3621 3555 uint64_t const cNsStream = RTTimeNanoTS() - pStreamEx->nsStarted; 3622 uint64_t const offCur = PDMAudioPropsNanoToBytes64(&pStreamEx->Core. Props, cNsStream);3556 uint64_t const offCur = PDMAudioPropsNanoToBytes64(&pStreamEx->Core.Cfg.Props, cNsStream); 3623 3557 if (offCur > pStreamEx->offInternal) 3624 3558 { … … 3639 3573 3640 3574 /* Make sure to align the readable size to the host's frame size. */ 3641 cbReadable = PDMAudioPropsFloorBytesToFrame(&pStreamEx->Core. Props, cbReadable);3575 cbReadable = PDMAudioPropsFloorBytesToFrame(&pStreamEx->Core.Cfg.Props, cbReadable); 3642 3576 } 3643 3577 … … 3645 3579 RTCritSectLeave(&pStreamEx->Core.CritSect); 3646 3580 Log3Func(("[%s] cbReadable=%#RX32 (%RU64ms) enmCaptureMode=%s enmBackendState=%s\n", 3647 pStreamEx->Core. szName, cbReadable, PDMAudioPropsBytesToMilli(&pStreamEx->Core.Props, cbReadable),3581 pStreamEx->Core.Cfg.szName, cbReadable, PDMAudioPropsBytesToMilli(&pStreamEx->Core.Cfg.Props, cbReadable), 3648 3582 drvAudioCaptureStateName(enmCaptureState), PDMHostAudioStreamStateGetName(enmBackendState) )); 3649 3583 return cbReadable; … … 3667 3601 /** @todo Does not take paused time into account... */ 3668 3602 uint64_t const cNsStream = RTTimeNanoTS() - pStreamEx->nsStarted; 3669 uint64_t const offCur = PDMAudioPropsNanoToBytes64(&pStreamEx->Core. Props, cNsStream);3603 uint64_t const offCur = PDMAudioPropsNanoToBytes64(&pStreamEx->Core.Cfg.Props, cNsStream); 3670 3604 if (offCur > pStreamEx->offInternal) 3671 3605 { … … 3675 3609 pStreamEx->offInternal += cbToClear; 3676 3610 cbBuf -= cbToClear; 3677 PDMAudioPropsClearBuffer(&pStreamEx->Core. Props, pbBuf, cbToClear,3678 PDMAudioPropsBytesToFrames(&pStreamEx->Core. Props, cbToClear));3611 PDMAudioPropsClearBuffer(&pStreamEx->Core.Cfg.Props, pbBuf, cbToClear, 3612 PDMAudioPropsBytesToFrames(&pStreamEx->Core.Cfg.Props, cbToClear)); 3679 3613 } 3680 3614 else 3681 3615 *pcbRead = 0; 3682 3616 Log4Func(("%s: @%#RX64: Read %#x bytes of silence (%#x bytes left)\n", 3683 pStreamEx->Core. szName, pStreamEx->offInternal, *pcbRead, cbBuf));3617 pStreamEx->Core.Cfg.szName, pStreamEx->offInternal, *pcbRead, cbBuf)); 3684 3618 return VINF_SUCCESS; 3685 3619 } … … 3692 3626 uint8_t *pbBuf, uint32_t cbBuf, uint32_t *pcbRead) 3693 3627 { 3694 Log4Func(("%s: @%#RX64: cbBuf=%#x\n", pStreamEx->Core. szName, pStreamEx->offInternal, cbBuf));3628 Log4Func(("%s: @%#RX64: cbBuf=%#x\n", pStreamEx->Core.Cfg.szName, pStreamEx->offInternal, cbBuf)); 3695 3629 3696 3630 uint32_t cbReadable = pThis->pHostDrvAudio->pfnStreamGetReadable(pThis->pHostDrvAudio, pStreamEx->pBackend); … … 3699 3633 uint32_t cbRead = 0; 3700 3634 int rc = VINF_SUCCESS; 3701 uint8_t const cbFrame = PDMAudioPropsFrameSize(&pStreamEx->Core. Props);3635 uint8_t const cbFrame = PDMAudioPropsFrameSize(&pStreamEx->Core.Cfg.Props); 3702 3636 while (cbBuf >= cbFrame && cbReadable >= cbFrame) 3703 3637 { 3704 uint32_t const cbToRead = PDMAudioPropsFloorBytesToFrame(&pStreamEx->Core. Props, RT_MIN(cbBuf, cbReadable));3638 uint32_t const cbToRead = PDMAudioPropsFloorBytesToFrame(&pStreamEx->Core.Cfg.Props, RT_MIN(cbBuf, cbReadable)); 3705 3639 uint32_t cbReadNow = 0; 3706 3640 rc = pThis->pHostDrvAudio->pfnStreamCapture(pThis->pHostDrvAudio, pStreamEx->pBackend, pbBuf, cbToRead, &cbReadNow); … … 3709 3643 if (cbReadNow != cbToRead) 3710 3644 Log4Func(("%s: @%#RX64: Read fewer bytes than requested: %#x, requested %#x\n", 3711 pStreamEx->Core. szName, pStreamEx->offInternal, cbReadNow, cbToRead));3645 pStreamEx->Core.Cfg.szName, pStreamEx->offInternal, cbReadNow, cbToRead)); 3712 3646 #ifdef DEBUG_bird 3713 3647 Assert(cbReadNow == cbToRead); … … 3723 3657 *pcbRead = cbRead; 3724 3658 LogFunc(("%s: @%#RX64: pfnStreamCapture failed read %#x bytes (%#x previous read, %#x readable): %Rrc\n", 3725 pStreamEx->Core. szName, pStreamEx->offInternal, cbToRead, cbRead, cbReadable, rc));3659 pStreamEx->Core.Cfg.szName, pStreamEx->offInternal, cbToRead, cbRead, cbReadable, rc)); 3726 3660 return cbRead ? VINF_SUCCESS : rc; 3727 3661 } … … 3735 3669 pStreamEx->nsLastPlayedCaptured = RTTimeNanoTS(); 3736 3670 3737 Log4Func(("%s: @%#RX64: Read %#x bytes (%#x bytes left)\n", pStreamEx->Core. szName, pStreamEx->offInternal, cbRead, cbBuf));3671 Log4Func(("%s: @%#RX64: Read %#x bytes (%#x bytes left)\n", pStreamEx->Core.Cfg.szName, pStreamEx->offInternal, cbRead, cbBuf)); 3738 3672 return rc; 3739 3673 } … … 3765 3699 AssertReturn(pStreamEx->Core.uMagic == PDMAUDIOSTREAM_MAGIC, VERR_INVALID_MAGIC); 3766 3700 AssertReturn(pStreamEx->uMagic == DRVAUDIOSTREAM_MAGIC, VERR_INVALID_MAGIC); 3767 AssertMsgReturn(pStreamEx->Core. enmDir == PDMAUDIODIR_IN,3701 AssertMsgReturn(pStreamEx->Core.Cfg.enmDir == PDMAUDIODIR_IN, 3768 3702 ("Stream '%s' is not an input stream and therefore cannot be read from (direction is '%s')\n", 3769 pStreamEx->Core. szName, PDMAudioDirGetName(pStreamEx->Core.enmDir)), VERR_ACCESS_DENIED);3770 3771 AssertMsg(PDMAudioPropsIsSizeAligned(&pStreamEx->Core. Props, cbBuf),3772 ("Stream '%s' got a non-frame-aligned write (%#RX32 bytes)\n", pStreamEx->Core. szName, cbBuf));3703 pStreamEx->Core.Cfg.szName, PDMAudioDirGetName(pStreamEx->Core.Cfg.enmDir)), VERR_ACCESS_DENIED); 3704 3705 AssertMsg(PDMAudioPropsIsSizeAligned(&pStreamEx->Core.Cfg.Props, cbBuf), 3706 ("Stream '%s' got a non-frame-aligned write (%#RX32 bytes)\n", pStreamEx->Core.Cfg.szName, cbBuf)); 3773 3707 3774 3708 int rc = RTCritSectEnter(&pStreamEx->Core.CritSect); … … 3809 3743 { 3810 3744 Log4Func(("[%s] Pre-buffering completed: cbReadable=%#x vs cbPreBufThreshold=%#x (cbBuf=%#x)\n", 3811 pStreamEx->Core. szName, cbReadable, pStreamEx->cbPreBufThreshold, cbBuf));3745 pStreamEx->Core.Cfg.szName, cbReadable, pStreamEx->cbPreBufThreshold, cbBuf)); 3812 3746 pStreamEx->In.enmCaptureState = DRVAUDIOCAPTURESTATE_CAPTURING; 3813 3747 rc = drvAudioStreamCaptureLocked(pThis, pStreamEx, (uint8_t *)pvBuf, cbBuf, pcbRead); … … 3817 3751 pStreamEx->In.Stats.cbBackendReadableAfter = cbReadable; 3818 3752 Log4Func(("[%s] Pre-buffering: Got %#x out of %#x\n", 3819 pStreamEx->Core. szName, cbReadable, pStreamEx->cbPreBufThreshold));3753 pStreamEx->Core.Cfg.szName, cbReadable, pStreamEx->cbPreBufThreshold)); 3820 3754 } 3821 3755 else 3822 3756 Log4Func(("[%s] Pre-buffering: Backend status %s\n", 3823 pStreamEx->Core. szName, PDMHostAudioStreamStateGetName(enmBackendState) ));3757 pStreamEx->Core.Cfg.szName, PDMHostAudioStreamStateGetName(enmBackendState) )); 3824 3758 drvAudioStreamCaptureSilence(pStreamEx, (uint8_t *)pvBuf, cbBuf, pcbRead); 3825 3759 break; … … 3828 3762 *pcbRead = 0; 3829 3763 Log4Func(("[%s] Not capturing - backend state: %s\n", 3830 pStreamEx->Core. szName, PDMHostAudioStreamStateGetName(enmBackendState) ));3764 pStreamEx->Core.Cfg.szName, PDMHostAudioStreamStateGetName(enmBackendState) )); 3831 3765 break; 3832 3766 … … 3844 3778 { 3845 3779 *pcbRead = 0; 3846 Log4Func(("[%s] Backend stream %s, returning no data\n", pStreamEx->Core. szName,3780 Log4Func(("[%s] Backend stream %s, returning no data\n", pStreamEx->Core.Cfg.szName, 3847 3781 !pThis->Out.fEnabled ? "disabled" : !pThis->pHostDrvAudio ? "not attached" : "not ready yet")); 3848 3782 } … … 3996 3930 static void drvAudioStreamMarkNeedReInit(PDRVAUDIOSTREAM pStreamEx, const char *pszCaller) 3997 3931 { 3998 LogFlow((LOG_FN_FMT ": Flagging %s for re-init.\n", pszCaller, pStreamEx->Core. szName)); RT_NOREF(pszCaller);3932 LogFlow((LOG_FN_FMT ": Flagging %s for re-init.\n", pszCaller, pStreamEx->Core.Cfg.szName)); RT_NOREF(pszCaller); 3999 3933 Assert(RTCritSectIsOwner(&pStreamEx->Core.CritSect)); 4000 3934 … … 4024 3958 RTListForEach(&pThis->LstStreams, pStreamEx, DRVAUDIOSTREAM, ListEntry) 4025 3959 { 4026 if (pStreamEx->Core. enmDir == enmDir)3960 if (pStreamEx->Core.Cfg.enmDir == enmDir) 4027 3961 { 4028 3962 RTCritSectEnter(&pStreamEx->Core.CritSect); … … 4031 3965 if (pThis->pHostDrvAudio->pfnStreamNotifyDeviceChanged) 4032 3966 { 4033 LogFlowFunc(("Calling pfnStreamNotifyDeviceChanged on %s, old backend state: %s...\n", pStreamEx->Core. szName,3967 LogFlowFunc(("Calling pfnStreamNotifyDeviceChanged on %s, old backend state: %s...\n", pStreamEx->Core.Cfg.szName, 4034 3968 PDMHostAudioStreamStateGetName(drvAudioStreamGetBackendState(pThis, pStreamEx)) )); 4035 3969 pThis->pHostDrvAudio->pfnStreamNotifyDeviceChanged(pThis->pHostDrvAudio, pStreamEx->pBackend, pvUser); … … 4066 4000 AssertReturnVoid(pStreamEx->Core.uMagic == PDMAUDIOSTREAM_MAGIC); 4067 4001 AssertReturnVoid(pStreamEx->uMagic == DRVAUDIOSTREAM_MAGIC); 4068 LogFlowFunc(("pStreamEx=%p '%s'\n", pStreamEx, pStreamEx->Core. szName));4002 LogFlowFunc(("pStreamEx=%p '%s'\n", pStreamEx, pStreamEx->Core.Cfg.szName)); 4069 4003 4070 4004 /* … … 4074 4008 AssertReturnVoidStmt(pStreamEx->uMagic == DRVAUDIOSTREAM_MAGIC, RTCritSectLeave(&pStreamEx->Core.CritSect)); /* paranoia */ 4075 4009 4076 if (pStreamEx->Core. enmDir == PDMAUDIODIR_OUT)4010 if (pStreamEx->Core.Cfg.enmDir == PDMAUDIODIR_OUT) 4077 4011 { 4078 4012 if (pStreamEx->cbPreBufThreshold > 0) … … 4149 4083 4150 4084 4151 if (pStreamEx->Core. enmDir == PDMAUDIODIR_OUT)4085 if (pStreamEx->Core.Cfg.enmDir == PDMAUDIODIR_OUT) 4152 4086 { 4153 4087 DRVAUDIOPLAYSTATE const enmPlayState = pStreamEx->Out.enmPlayState; 4154 4088 pStreamEx->Out.enmPlayState = DRVAUDIOPLAYSTATE_PREBUF; 4155 LogFunc(("%s: %s -> %s\n", pStreamEx->Core. szName, drvAudioPlayStateName(enmPlayState),4089 LogFunc(("%s: %s -> %s\n", pStreamEx->Core.Cfg.szName, drvAudioPlayStateName(enmPlayState), 4156 4090 drvAudioPlayStateName(pStreamEx->Out.enmPlayState) )); 4157 4091 RT_NOREF(enmPlayState); -
trunk/src/VBox/Devices/Audio/DrvHostAudioNull.cpp
r89487 r89489 248 248 /* .pfnStreamNotifyDeviceChanged =*/ NULL, 249 249 /* .pfnStreamControl =*/ drvHstAudNullHA_StreamControl, 250 /* .pfnStreamGetState =*/ drvHstAudNullHA_StreamGetState, 251 /* .pfnStreamGetPending =*/ drvHstAudNullHA_StreamGetPending, 252 /* .pfnStreamGetWritable =*/ drvHstAudNullHA_StreamGetWritable, 253 /* .pfnStreamPlay =*/ drvHstAudNullHA_StreamPlay, 250 254 /* .pfnStreamGetReadable =*/ drvHstAudNullHA_StreamGetReadable, 251 /* .pfnStreamGetWritable =*/ drvHstAudNullHA_StreamGetWritable,252 /* .pfnStreamGetPending =*/ drvHstAudNullHA_StreamGetPending,253 /* .pfnStreamGetState =*/ drvHstAudNullHA_StreamGetState,254 /* .pfnStreamPlay =*/ drvHstAudNullHA_StreamPlay,255 255 /* .pfnStreamCapture =*/ drvHstAudNullHA_StreamCapture, 256 256 }; -
trunk/src/VBox/Main/src-client/DrvAudioVRDE.cpp
r89487 r89489 633 633 * sensible, so I've removed it. */ 634 634 635 uint32_t cFrames = PDMAudioPropsBytesToFrames(&pStream->pStream-> Props, cbBuf);635 uint32_t cFrames = PDMAudioPropsBytesToFrames(&pStream->pStream->Cfg.Props, cbBuf); 636 636 Assert(cFrames == cbBuf / (sizeof(uint64_t) * 2)); 637 637 pDrv->pConsoleVRDPServer->SendAudioSamples(pvBuf, cFrames, uVrdpFormat); 638 638 639 639 Log3Func(("cFramesWritten=%RU32\n", cFrames)); 640 *pcbWritten = PDMAudioPropsFramesToBytes(&pStream->pStream-> Props, cFrames);640 *pcbWritten = PDMAudioPropsFramesToBytes(&pStream->pStream->Cfg.Props, cFrames); 641 641 Assert(*pcbWritten == cbBuf); 642 642 return VINF_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.