- Timestamp:
- May 5, 2021 11:38:58 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 144222
- Location:
- trunk
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vmm/pdmaudioifs.h
r88884 r88887 1308 1308 #define PDMAUDIOBACKENDSTREAM_MAGIC PDM_VERSION_MAKE(0xa0d4, 1, 0) 1309 1309 1310 /** 1311 * Host audio (backend) stream state returned by PDMIHOSTAUDIO::pfnStreamGetState. 1312 */ 1313 typedef enum PDMHOSTAUDIOSTREAMSTATE 1314 { 1315 /** Invalid zero value, as per usual. */ 1316 PDMHOSTAUDIOSTREAMSTATE_INVALID = 0, 1317 /** The stream is being initialized. 1318 * This should also be used when switching to a new device and the stream 1319 * stops to work with the old device while the new one being configured. */ 1320 PDMHOSTAUDIOSTREAMSTATE_INITIALIZING, 1321 /** The stream does not work (async init failed, audio subsystem gone 1322 * fishing, or similar). */ 1323 PDMHOSTAUDIOSTREAMSTATE_NOT_WORKING, 1324 /** Backend is working okay. */ 1325 PDMHOSTAUDIOSTREAMSTATE_OKAY, 1326 /** Backend is working but doesn't want any commands or data reads/writes. */ 1327 PDMHOSTAUDIOSTREAMSTATE_INACTIVE, 1328 /** End of valid values. */ 1329 PDMHOSTAUDIOSTREAMSTATE_END, 1330 /** Blow the type up to 32 bits. */ 1331 PDMHOSTAUDIOSTREAMSTATE_32BIT_HACK = 0x7fffffff 1332 } PDMHOSTAUDIOSTREAMSTATE; 1333 1310 1334 1311 1335 /** Pointer to a host audio interface. */ … … 1500 1524 1501 1525 /** 1502 * Returns the current status of the given backend stream. 1503 * 1504 * @returns PDMAUDIOSTREAM_STS_XXX 1526 * Returns the current state of the given backend stream. 1527 * 1528 * @returns PDMHOSTAUDIOSTREAMSTATE value. 1529 * @retval PDMHOSTAUDIOSTREAMSTATE_INVALID if invalid stream. 1505 1530 * @param pInterface Pointer to the interface structure containing the called function pointer. 1506 1531 * @param pStream Pointer to audio stream. 1507 1532 */ 1508 DECLR3CALLBACKMEMBER( uint32_t, pfnStreamGetStatus, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream));1533 DECLR3CALLBACKMEMBER(PDMHOSTAUDIOSTREAMSTATE, pfnStreamGetState, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)); 1509 1534 1510 1535 /** … … 1533 1558 DECLR3CALLBACKMEMBER(int, pfnStreamCapture, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream, 1534 1559 void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead)); 1535 1536 1560 } PDMIHOSTAUDIO; 1537 1561 1538 1562 /** PDMIHOSTAUDIO interface ID. */ 1539 #define PDMIHOSTAUDIO_IID " b320d6ab-6cbc-46a8-8011-57e7f7eb0e25"1563 #define PDMIHOSTAUDIO_IID "53949a0a-ca2d-4d25-869f-2a8357991293" 1540 1564 1541 1565 -
trunk/include/VBox/vmm/pdmaudioinline.h
r88884 r88887 1107 1107 1108 1108 /** 1109 * Converts a audio stream state enum value to a string. 1110 * 1111 * @returns Pointer to read-only audio stream state string on success, 1112 * "illegal" if invalid command value. 1113 * @param enmStreamState The state to convert. 1114 */ 1115 DECLINLINE(const char *) PDMAudioStreamStateGetName(PDMAUDIOSTREAMSTATE enmStreamState) 1116 { 1117 switch (enmStreamState) 1118 { 1119 case PDMAUDIOSTREAMSTATE_INVALID: return "invalid"; 1120 case PDMAUDIOSTREAMSTATE_NOT_WORKING: return "not-working"; 1121 case PDMAUDIOSTREAMSTATE_NEED_REINIT: return "need-reinit"; 1122 case PDMAUDIOSTREAMSTATE_INACTIVE: return "inactive"; 1123 case PDMAUDIOSTREAMSTATE_ENABLED: return "enabled"; 1124 case PDMAUDIOSTREAMSTATE_ENABLED_READABLE: return "enabled-readable"; 1125 case PDMAUDIOSTREAMSTATE_ENABLED_WRITABLE: return "enabled-writable"; 1126 /* no default: */ 1127 case PDMAUDIOSTREAMSTATE_END: 1128 case PDMAUDIOSTREAMSTATE_32BIT_HACK: 1129 break; 1130 } 1131 AssertMsgFailedReturn(("Invalid audio stream state: %d\n", enmStreamState), "illegal"); 1132 } 1133 1134 /** 1135 * Converts a host audio (backend) stream state enum value to a string. 1136 * 1137 * @returns Pointer to read-only host audio stream state string on success, 1138 * "illegal" if invalid command value. 1139 * @param enmHostAudioStreamState The state to convert. 1140 */ 1141 DECLINLINE(const char *) PDMHostAudioStreamStateGetName(PDMHOSTAUDIOSTREAMSTATE enmHostAudioStreamState) 1142 { 1143 switch (enmHostAudioStreamState) 1144 { 1145 case PDMHOSTAUDIOSTREAMSTATE_INVALID: return "invalid"; 1146 case PDMHOSTAUDIOSTREAMSTATE_INITIALIZING: return "initializing"; 1147 case PDMHOSTAUDIOSTREAMSTATE_NOT_WORKING: return "not-working"; 1148 case PDMHOSTAUDIOSTREAMSTATE_OKAY: return "okay"; 1149 case PDMHOSTAUDIOSTREAMSTATE_INACTIVE: return "inactive"; 1150 /* no default: */ 1151 case PDMHOSTAUDIOSTREAMSTATE_END: 1152 case PDMHOSTAUDIOSTREAMSTATE_32BIT_HACK: 1153 break; 1154 } 1155 AssertMsgFailedReturn(("Invalid host audio stream state: %d\n", enmHostAudioStreamState), "illegal"); 1156 } 1157 1158 /** 1109 1159 * Checks if the stream status is one that can be read from. 1110 1160 * … … 1121 1171 | PDMAUDIOSTREAM_STS_PAUSED 1122 1172 | PDMAUDIOSTREAM_STS_NEED_REINIT)) 1123 == ( PDMAUDIOSTREAM_STS_INITIALIZED1124 | PDMAUDIOSTREAM_STS_ENABLED);1125 }1126 1127 /**1128 * Checks if the stream status is one that can be read from.1129 *1130 * @returns @c true if ready to be read from, @c false if not.1131 * @param fStatus Stream status to evaluate, PDMAUDIOSTREAM_STS_XXX.1132 * @note Only for backend statuses.1133 */1134 DECLINLINE(bool) PDMAudioStrmStatusBackendCanRead(uint32_t fStatus)1135 {1136 PDMAUDIOSTREAM_STS_ASSERT_VALID_BACKEND(fStatus);1137 AssertReturn(!(fStatus & ~PDMAUDIOSTREAM_STS_VALID_MASK_BACKEND), false);1138 return (fStatus & ( PDMAUDIOSTREAM_STS_INITIALIZED1139 | PDMAUDIOSTREAM_STS_ENABLED1140 | PDMAUDIOSTREAM_STS_PAUSED1141 | PDMAUDIOSTREAM_STS_NEED_REINIT ))1142 1173 == ( PDMAUDIOSTREAM_STS_INITIALIZED 1143 1174 | PDMAUDIOSTREAM_STS_ENABLED); … … 1165 1196 1166 1197 /** 1167 * Checks if the stream status is one that can be written to, backend edition.1168 *1169 * @returns @c true if ready to be written to, @c false if not.1170 * @param fStatus Stream status to evaluate, PDMAUDIOSTREAM_STS_XXX.1171 * @note Only for backend statuses.1172 */1173 DECLINLINE(bool) PDMAudioStrmStatusBackendCanWrite(uint32_t fStatus)1174 {1175 PDMAUDIOSTREAM_STS_ASSERT_VALID_BACKEND(fStatus);1176 AssertReturn(!(fStatus & ~PDMAUDIOSTREAM_STS_VALID_MASK_BACKEND), false);1177 return (fStatus & ( PDMAUDIOSTREAM_STS_INITIALIZED1178 | PDMAUDIOSTREAM_STS_ENABLED1179 | PDMAUDIOSTREAM_STS_PAUSED1180 | PDMAUDIOSTREAM_STS_PENDING_DISABLE))1181 == ( PDMAUDIOSTREAM_STS_INITIALIZED1182 | PDMAUDIOSTREAM_STS_ENABLED);1183 }1184 1185 /**1186 1198 * Checks if the stream status is a ready-to-operate one. 1187 1199 * -
trunk/src/VBox/Devices/Audio/AudioMixer.cpp
r88884 r88887 744 744 } 745 745 746 /** @todo r=bird: There almost serious issue here. One stupid/buggy audio 747 * driver chain will mess up the whole thing. Either we or DrvAudio 748 * need to take note of this and somehow gloss over it... DevHDA with a 749 * linux guest completely freezes up the audio in the guest if we fail 750 * here. (Buggy VRDE code.) */ 746 751 PAUDMIXSTREAM pStream; 747 752 if ( pSink->enmDir == AUDMIXSINKDIR_INPUT … … 2112 2117 int rc = pConn->pfnStreamReInit(pConn, pStream); 2113 2118 enmState = pConn->pfnStreamGetState(pConn, pStream); 2114 LogFunc(("[%s] re-init returns %Rrc and % d.\n", pMixStream->pszName, rc, enmState));2119 LogFunc(("[%s] re-init returns %Rrc and %s.\n", pMixStream->pszName, rc, PDMAudioStreamStateGetName(enmState))); 2115 2120 2116 2121 PAUDMIXSINK const pSink = pMixStream->pSink; -
trunk/src/VBox/Devices/Audio/DrvAudio.cpp
r88884 r88887 131 131 uint32_t cTriesReInit; 132 132 133 /** The backend stat usat the last play or capture call.134 * This is used to detect state changes . */135 uint32_t fLastBackendStatus;133 /** The backend state at the last play or capture call. 134 * This is used to detect state changes (for what that is worth). */ 135 PDMHOSTAUDIOSTREAMSTATE enmLastBackendState; 136 136 137 137 /** The pfnStreamInitAsync request handle. */ … … 436 436 * Wrapper around PDMIHOSTAUDIO::pfnStreamGetStatus and checks the result. 437 437 * 438 * @returns PDMAUDIOSTREAM_STS_XXX438 * @returns A PDMHOSTAUDIOSTREAMSTATE value. 439 439 * @param pThis Pointer to the DrvAudio instance data. 440 440 * @param pStreamEx The stream to get the backend status for. 441 441 */ 442 DECLINLINE(uint32_t) drvAudioStreamGetBackendStatus(PDRVAUDIO pThis, PDRVAUDIOSTREAM pStreamEx) 443 { 444 uint32_t fBackendStatus = pThis->pHostDrvAudio 445 ? pThis->pHostDrvAudio->pfnStreamGetStatus(pThis->pHostDrvAudio, pStreamEx->pBackend) 446 : 0; 447 PDMAUDIOSTREAM_STS_ASSERT_VALID_BACKEND(fBackendStatus); 448 return fBackendStatus; 442 DECLINLINE(PDMHOSTAUDIOSTREAMSTATE) drvAudioStreamGetBackendState(PDRVAUDIO pThis, PDRVAUDIOSTREAM pStreamEx) 443 { 444 if (pThis->pHostDrvAudio) 445 { 446 PDMHOSTAUDIOSTREAMSTATE enmState = pThis->pHostDrvAudio->pfnStreamGetState(pThis->pHostDrvAudio, pStreamEx->pBackend); 447 Assert(enmState > PDMHOSTAUDIOSTREAMSTATE_INVALID && enmState < PDMHOSTAUDIOSTREAMSTATE_END); 448 return enmState; 449 } 450 return PDMHOSTAUDIOSTREAMSTATE_NOT_WORKING; 449 451 } 450 452 … … 598 600 if (!(fStatus & PDMAUDIOSTREAM_STS_PENDING_DISABLE)) 599 601 { 602 /** @todo r=bird: We need to redo pre-buffering OR switch to 603 * DRVAUDIOPLAYSTATE_PREBUF_SWITCHING playback mode when disabling 604 * output streams. The former is preferred if associated with 605 * reporting the stream as INACTIVE. */ 600 606 rc2 = drvAudioStreamControlInternalBackend(pThis, pStreamEx, PDMAUDIOSTREAMCMD_ENABLE); 601 607 pszOperation = "enable"; … … 1078 1084 1079 1085 /* 1080 * Tweak the last backend status to asserting in 1081 * drvAudioStreamPlayProcessBackendStateChange(). 1086 * Update the last backend state. 1082 1087 */ 1083 pStreamEx->fLastBackendStatus |= drvAudioStreamGetBackendStatus(pThis, pStreamEx) 1084 & PDMAUDIOSTREAM_STS_INITIALIZED; 1088 pStreamEx->enmLastBackendState = drvAudioStreamGetBackendState(pThis, pStreamEx); 1085 1089 } 1086 1090 /* … … 1163 1167 if (RT_SUCCESS(rc)) 1164 1168 { 1169 pStreamEx->enmLastBackendState = drvAudioStreamGetBackendState(pThis, pStreamEx); 1170 1165 1171 AssertLogRelReturn(pStreamEx->pBackend->uMagic == PDMAUDIOBACKENDSTREAM_MAGIC, VERR_INTERNAL_ERROR_3); 1166 1172 AssertLogRelReturn(pStreamEx->pBackend->pStream == &pStreamEx->Core, VERR_INTERNAL_ERROR_3); … … 1170 1176 several possible early return paths before it). */ 1171 1177 pStreamEx->fStatus |= PDMAUDIOSTREAM_STS_INITIALIZED; 1172 1173 pStreamEx->fLastBackendStatus = drvAudioStreamGetBackendStatus(pThis, pStreamEx);1174 PDMAUDIOSTREAM_STS_ASSERT_VALID(pStreamEx->fStatus);1175 1178 } 1176 1179 else … … 1189 1192 AssertStmt(rc != VINF_AUDIO_STREAM_ASYNC_INIT_NEEDED || pThis->pHostDrvAudio->pfnStreamInitAsync != NULL, 1190 1193 pStreamEx->fNeedAsyncInit = false); 1191 Assert(rc != VINF_AUDIO_STREAM_ASYNC_INIT_NEEDED || !(pStreamEx->fLastBackendStatus & PDMAUDIOSTREAM_STS_INITIALIZED)); 1194 AssertMsg( rc != VINF_AUDIO_STREAM_ASYNC_INIT_NEEDED 1195 || pStreamEx->enmLastBackendState == PDMHOSTAUDIOSTREAMSTATE_INITIALIZING, 1196 ("rc=%Rrc %s\n", rc, PDMHostAudioStreamStateGetName(pStreamEx->enmLastBackendState))); 1192 1197 1193 1198 /* Validate acquired configuration. */ … … 1872 1877 if (pStreamEx->cRefs > 0 && pStreamEx->cRefs < UINT32_MAX / 4) 1873 1878 { 1874 char szStatus[DRVAUDIO_STATUS_STR_MAX] , szBackendStatus[DRVAUDIO_STATUS_STR_MAX];1879 char szStatus[DRVAUDIO_STATUS_STR_MAX]; 1875 1880 LogRel2(("Audio: Destroying stream '%s': cRefs=%u; status: %s; backend: %s; hReqInitAsync=%p\n", 1876 1881 pStreamEx->Core.szName, pStreamEx->cRefs, drvAudioStreamStatusToStr(szStatus, pStreamEx->fStatus), 1877 drvAudioStreamStatusToStr(szBackendStatus, drvAudioStreamGetBackendStatus(pThis, pStreamEx)),1882 PDMHostAudioStreamStateGetName(drvAudioStreamGetBackendState(pThis, pStreamEx)), 1878 1883 pStreamEx->hReqInitAsync)); 1879 1884 … … 2198 2203 * finish initializing the stream, we'll update it about the stream state. 2199 2204 */ 2200 int rc = VINF_SUCCESS; 2201 uint32_t const fBackendStatus = drvAudioStreamGetBackendStatus(pThis, pStreamEx); /* (checks pThis->pHostDrvAudio too) */ 2202 bool const fDirEnabled = pStreamEx->Core.enmDir == PDMAUDIODIR_IN ? pThis->In.fEnabled : pThis->Out.fEnabled; 2203 2204 char szStreamSts[DRVAUDIO_STATUS_STR_MAX], szBackendStreamSts[DRVAUDIO_STATUS_STR_MAX]; 2205 int rc = VINF_SUCCESS; 2206 bool const fDirEnabled = pStreamEx->Core.enmDir == PDMAUDIODIR_IN 2207 ? pThis->In.fEnabled : pThis->Out.fEnabled; 2208 PDMHOSTAUDIOSTREAMSTATE const enmBackendState = drvAudioStreamGetBackendState(pThis, pStreamEx); 2209 /* ^^^ (checks pThis->pHostDrvAudio != NULL too) */ 2210 2211 char szStreamSts[DRVAUDIO_STATUS_STR_MAX]; 2205 2212 LogRel2(("Audio: %s stream '%s' backend (%s is %s; status: %s; backend-status: %s)\n", 2206 2213 PDMAudioStrmCmdGetName(enmStreamCmd), pStreamEx->Core.szName, PDMAudioDirGetName(pStreamEx->Core.enmDir), 2207 2214 fDirEnabled ? "enabled" : "disabled", drvAudioStreamStatusToStr(szStreamSts, pStreamEx->fStatus), 2208 drvAudioStreamStatusToStr(szBackendStreamSts, fBackendStatus) ));2215 PDMHostAudioStreamStateGetName(enmBackendState) )); 2209 2216 2210 2217 if (fDirEnabled) 2211 2218 { 2212 if ( (pStreamEx->fStatus & PDMAUDIOSTREAM_STS_BACKEND_READY )2213 && (fBackendStatus & PDMAUDIOSTREAM_STS_INITIALIZED))2219 if ( (pStreamEx->fStatus & PDMAUDIOSTREAM_STS_BACKEND_READY /* don't really need this check, do we? */) 2220 && enmBackendState == PDMHOSTAUDIOSTREAMSTATE_OKAY) 2214 2221 { 2215 2222 /** @todo Backend will change to explicit methods here, so please don't simplify … … 2256 2263 } 2257 2264 } 2258 } 2265 else 2266 LogFlowFunc(("enmBackendStat(=%s) != OKAY || !(fStatus(=%#x) & BACKEND_READY)\n", 2267 PDMHostAudioStreamStateGetName(enmBackendState), pStreamEx->fStatus)); 2268 } 2269 else 2270 LogFlowFunc(("fDirEnabled=false\n")); 2259 2271 return rc; 2260 2272 } … … 2370 2382 { 2371 2383 /* Reset the play state before we try to start. */ 2372 pStreamEx->fLastBackendStatus = drvAudioStreamGetBackendStatus(pThis, pStreamEx); 2384 PDMHOSTAUDIOSTREAMSTATE const enmBackendState = drvAudioStreamGetBackendState(pThis, pStreamEx); 2385 pStreamEx->enmLastBackendState = enmBackendState; 2373 2386 if (pStreamEx->Core.enmDir == PDMAUDIODIR_OUT) 2374 2387 { 2375 2388 pStreamEx->Out.cbPreBuffered = 0; 2376 2389 pStreamEx->Out.offPreBuf = 0; 2377 pStreamEx->Out.enmPlayState = pStreamEx->Out.cbPreBufThreshold > 0 2378 ? DRVAUDIOPLAYSTATE_PREBUF 2379 : (pStreamEx->fStatus & PDMAUDIOSTREAM_STS_BACKEND_READY) 2380 && (pStreamEx->fLastBackendStatus & PDMAUDIOSTREAM_STS_INITIALIZED) 2381 ? DRVAUDIOPLAYSTATE_PLAY 2382 : DRVAUDIOPLAYSTATE_NOPLAY; 2383 LogFunc(("ENABLE: fLastBackendStatus=%#x enmPlayState=%s\n", 2384 pStreamEx->fLastBackendStatus, drvAudioPlayStateName(pStreamEx->Out.enmPlayState))); 2390 pStreamEx->Out.enmPlayState = DRVAUDIOPLAYSTATE_NOPLAY; 2391 switch (enmBackendState) 2392 { 2393 case PDMHOSTAUDIOSTREAMSTATE_INITIALIZING: 2394 if (pStreamEx->Out.cbPreBufThreshold > 0) 2395 pStreamEx->Out.enmPlayState = DRVAUDIOPLAYSTATE_PREBUF; 2396 break; 2397 case PDMHOSTAUDIOSTREAMSTATE_OKAY: 2398 pStreamEx->Out.enmPlayState = pStreamEx->Out.cbPreBufThreshold > 0 2399 ? DRVAUDIOPLAYSTATE_PREBUF : DRVAUDIOPLAYSTATE_PLAY; 2400 break; 2401 case PDMHOSTAUDIOSTREAMSTATE_NOT_WORKING: 2402 case PDMHOSTAUDIOSTREAMSTATE_INACTIVE: 2403 break; 2404 /* no default */ 2405 case PDMHOSTAUDIOSTREAMSTATE_INVALID: 2406 case PDMHOSTAUDIOSTREAMSTATE_END: 2407 case PDMHOSTAUDIOSTREAMSTATE_32BIT_HACK: 2408 break; 2409 } 2410 LogFunc(("ENABLE: enmBackendState=%s enmPlayState=%s\n", PDMHostAudioStreamStateGetName(enmBackendState), 2411 drvAudioPlayStateName(pStreamEx->Out.enmPlayState))); 2385 2412 } 2386 2413 else 2387 LogFunc(("ENABLE: fLastBackendStatus=%#x\n", pStreamEx->fLastBackendStatus));2414 LogFunc(("ENABLE: enmBackendState=%s\n", PDMHostAudioStreamStateGetName(enmBackendState))); 2388 2415 2389 2416 rc = drvAudioStreamControlInternalBackend(pThis, pStreamEx, PDMAUDIOSTREAMCMD_ENABLE); … … 2803 2830 /* Must check the backend state here first and only try commit the 2804 2831 pre-buffered samples if the backend is in working order. */ 2805 uint32_t const fBackendStatus = drvAudioStreamGetBackendStatus(pThis, pStreamEx); /* (checks pThis->pHostDrvAudio too) */ 2832 PDMHOSTAUDIOSTREAMSTATE const enmBackendState = drvAudioStreamGetBackendState(pThis, pStreamEx); 2833 /* ^^^ (checks pThis->pHostDrvAudio != NULL too) */ 2806 2834 if ( (pStreamEx->fStatus & PDMAUDIOSTREAM_STS_BACKEND_READY) 2807 && (fBackendStatus & PDMAUDIOSTREAM_STS_INITIALIZED))2835 && enmBackendState == PDMHOSTAUDIOSTREAMSTATE_OKAY) 2808 2836 { 2809 2837 uint32_t cbIgnored = 0; … … 2812 2840 } 2813 2841 else 2814 Log3Func(("[%s] Skipping committing pre-buffered samples , backend not initialized (%#x)!\n",2815 pStreamEx->Core.szName, fBackendStatus));2842 Log3Func(("[%s] Skipping committing pre-buffered samples (status: %#x backend: %s)!\n", 2843 pStreamEx->Core.szName, pStreamEx->fStatus, PDMHostAudioStreamStateGetName(enmBackendState))); 2816 2844 } 2817 2845 break; … … 2929 2957 ) 2930 2958 { 2931 uint32_t const fBackendStatus = drvAudioStreamGetBackendStatus(pThis, pStreamEx); 2932 2959 PDMHOSTAUDIOSTREAMSTATE const enmBackendState = drvAudioStreamGetBackendState(pThis, pStreamEx); 2933 2960 if (pStreamEx->fNoMixBufs) 2934 2961 cbReadable = pThis->pHostDrvAudio 2935 2962 && (pStreamEx->fStatus & PDMAUDIOSTREAM_STS_BACKEND_READY) 2936 && (fBackendStatus & PDMAUDIOSTREAM_STS_INITIALIZED)2963 && enmBackendState == PDMHOSTAUDIOSTREAMSTATE_OKAY 2937 2964 && !fDisabled 2938 2965 ? pThis->pHostDrvAudio->pfnStreamGetReadable(pThis->pHostDrvAudio, pStreamEx->pBackend) … … 2953 2980 * Reading the actual data from a stream then will return silence then. 2954 2981 */ 2955 if ( !PDMAudioStrmStatusBackendCanRead(fBackendStatus)2982 if ( enmBackendState != PDMHOSTAUDIOSTREAMSTATE_OKAY /** @todo probably not correct. OTOH, I'm not sure if we do what the above comment claims either. */ 2956 2983 || fDisabled) 2957 2984 { … … 2963 2990 LogRel(("Audio: Input for driver '%s' has been disabled, returning silence\n", pThis->szName)); 2964 2991 else 2965 LogRel(("Audio: Warning: Input for stream '%s' of driver '%s' not ready (current input status is % #x), returning silence\n",2966 pStreamEx->Core.szName, pThis->szName, fBackendStatus));2992 LogRel(("Audio: Warning: Input for stream '%s' of driver '%s' not ready (current input status is %s), returning silence\n", 2993 pStreamEx->Core.szName, pThis->szName, PDMHostAudioStreamStateGetName(enmBackendState) )); 2967 2994 2968 2995 pStreamEx->Core.fWarningsShown |= PDMAUDIOSTREAM_WARN_FLAGS_DISABLED; … … 3016 3043 case DRVAUDIOPLAYSTATE_PLAY_PREBUF: 3017 3044 Assert(pStreamEx->fStatus & PDMAUDIOSTREAM_STS_BACKEND_READY); 3018 Assert(drvAudioStreamGetBackendStat us(pThis, pStreamEx) & PDMAUDIOSTREAM_STS_INITIALIZED);3045 Assert(drvAudioStreamGetBackendState(pThis, pStreamEx) == PDMHOSTAUDIOSTREAMSTATE_OKAY /* potential unplug race */); 3019 3046 cbWritable = pThis->pHostDrvAudio->pfnStreamGetWritable(pThis->pHostDrvAudio, pStreamEx->pBackend); 3020 3047 break; … … 3054 3081 to move the data. */ 3055 3082 Assert(pStreamEx->fStatus & PDMAUDIOSTREAM_STS_BACKEND_READY); 3056 Assert(drvAudioStreamGetBackendStat us(pThis, pStreamEx) & PDMAUDIOSTREAM_STS_INITIALIZED);3083 Assert(drvAudioStreamGetBackendState(pThis, pStreamEx) == PDMHOSTAUDIOSTREAMSTATE_OKAY /* potential unplug race */); 3057 3084 uint32_t const cbMin = PDMAudioPropsFramesToBytes(&pStreamEx->Core.Props, 8); 3058 3085 cbWritable = pThis->pHostDrvAudio->pfnStreamGetWritable(pThis->pHostDrvAudio, pStreamEx->pBackend); … … 3101 3128 AssertRCReturn(rc, PDMAUDIOSTREAMSTATE_INVALID); 3102 3129 3103 uint32_t const fStrmStatus = pStreamEx->fStatus; 3104 PDMAUDIODIR const enmDir = pStreamEx->Guest.Cfg.enmDir; 3130 PDMHOSTAUDIOSTREAMSTATE const enmBackendState = drvAudioStreamGetBackendState(pThis, pStreamEx); 3131 uint32_t const fStrmStatus = pStreamEx->fStatus; 3132 PDMAUDIODIR const enmDir = pStreamEx->Guest.Cfg.enmDir; 3133 Assert(enmDir == PDMAUDIODIR_IN || enmDir == PDMAUDIODIR_OUT); 3105 3134 3106 3135 RTCritSectLeave(&pThis->CritSect); … … 3114 3143 if (fStrmStatus & PDMAUDIOSTREAM_STS_INITIALIZED) 3115 3144 { 3116 if (fStrmStatus & PDMAUDIOSTREAM_STS_ENABLED) 3145 if ( (fStrmStatus & PDMAUDIOSTREAM_STS_ENABLED) 3146 && (enmDir == PDMAUDIODIR_IN ? pThis->In.fEnabled : pThis->Out.fEnabled) 3147 && ( enmBackendState == PDMHOSTAUDIOSTREAMSTATE_OKAY 3148 || enmBackendState == PDMHOSTAUDIOSTREAMSTATE_INITIALIZING )) 3117 3149 enmState = enmDir == PDMAUDIODIR_IN ? PDMAUDIOSTREAMSTATE_ENABLED_READABLE : PDMAUDIOSTREAMSTATE_ENABLED_WRITABLE; 3118 3150 else … … 3128 3160 char szStreamSts[DRVAUDIO_STATUS_STR_MAX]; 3129 3161 #endif 3130 Log3Func(("[%s] returns %d (%s)\n", pStreamEx->Core.szName, enmState, drvAudioStreamStatusToStr(szStreamSts, fStrmStatus))); 3162 Log3Func(("[%s] returns %s (status: %s)\n", pStreamEx->Core.szName, PDMAudioStreamStateGetName(enmState), 3163 drvAudioStreamStatusToStr(szStreamSts, fStrmStatus))); 3131 3164 return enmState; 3132 3165 } … … 3156 3189 3157 3190 /** 3158 * Processes backend status change. 3159 * 3160 * @todo bird: I'm more and more of the opinion that the backend should 3161 * explicitly notify us about these changes, rather that we polling them 3162 * via PDMIHOSTAUDIO::pfnStreamGetStatus... 3163 */ 3164 static void drvAudioStreamPlayProcessBackendStateChange(PDRVAUDIOSTREAM pStreamEx, uint32_t fNewState, uint32_t fOldState) 3165 { 3191 * Processes backend state change. 3192 */ 3193 static void drvAudioStreamPlayProcessBackendStateChange(PDRVAUDIOSTREAM pStreamEx, PDMHOSTAUDIOSTREAMSTATE enmNewState, 3194 PDMHOSTAUDIOSTREAMSTATE enmOldState) 3195 { 3196 #ifdef LOG_ENABLED 3166 3197 DRVAUDIOPLAYSTATE const enmPlayState = pStreamEx->Out.enmPlayState; 3167 3168 /* 3169 * Did PDMAUDIOSTREAM_STS_INITIALIZED change? 3170 */ 3171 if ((fOldState ^ fNewState) & PDMAUDIOSTREAM_STS_INITIALIZED) 3172 { 3173 if (fOldState & PDMAUDIOSTREAM_STS_INITIALIZED) 3174 { 3175 /* Pulse audio clear INITIALIZED. */ 3176 switch (enmPlayState) 3198 #endif 3199 Assert(enmNewState != enmOldState); 3200 Assert(enmOldState > PDMHOSTAUDIOSTREAMSTATE_INVALID && enmOldState < PDMHOSTAUDIOSTREAMSTATE_END); 3201 AssertReturnVoid(enmNewState > PDMHOSTAUDIOSTREAMSTATE_INVALID && enmNewState < PDMHOSTAUDIOSTREAMSTATE_END); 3202 3203 /* 3204 * Figure out what happend and how that reflects on the playback state and stuff. 3205 */ 3206 switch (enmNewState) 3207 { 3208 case PDMHOSTAUDIOSTREAMSTATE_INITIALIZING: 3209 /* Guess we're switching device. Nothing to do because the backend will tell us, right? */ 3210 break; 3211 3212 case PDMHOSTAUDIOSTREAMSTATE_NOT_WORKING: 3213 /* The stream has stopped working. Switch to noplay mode. */ 3214 pStreamEx->Out.enmPlayState = DRVAUDIOPLAYSTATE_NOPLAY; 3215 break; 3216 3217 case PDMHOSTAUDIOSTREAMSTATE_OKAY: 3218 switch (enmOldState) 3177 3219 { 3178 case DRVAUDIOPLAYSTATE_PLAY: 3179 case DRVAUDIOPLAYSTATE_PREBUF_COMMITTING: 3180 pStreamEx->Out.enmPlayState = DRVAUDIOPLAYSTATE_NOPLAY; 3181 /** @todo We could enter PREBUF here and hope for the device to re-appear in 3182 * initialized state... */ 3220 case PDMHOSTAUDIOSTREAMSTATE_INITIALIZING: 3221 /* Should be taken care of elsewhere, so do nothing. */ 3183 3222 break; 3184 case DRVAUDIOPLAYSTATE_PLAY_PREBUF: 3185 pStreamEx->Out.enmPlayState = DRVAUDIOPLAYSTATE_PREBUF_SWITCHING; 3223 3224 case PDMHOSTAUDIOSTREAMSTATE_NOT_WORKING: 3225 case PDMHOSTAUDIOSTREAMSTATE_INACTIVE: 3226 /* Go back to pre-buffering/playing depending on whether it is enabled 3227 or not, resetting the stream state. */ 3228 drvAudioStreamResetInternal(pStreamEx); 3186 3229 break; 3187 case DRVAUDIOPLAYSTATE_PREBUF: 3188 break; 3189 case DRVAUDIOPLAYSTATE_PREBUF_OVERDUE: 3190 case DRVAUDIOPLAYSTATE_PREBUF_SWITCHING: 3191 AssertFailedBreak(); 3192 /* no default */ 3193 case DRVAUDIOPLAYSTATE_NOPLAY: 3194 case DRVAUDIOPLAYSTATE_END: 3195 case DRVAUDIOPLAYSTATE_INVALID: 3230 3231 /* no default: */ 3232 case PDMHOSTAUDIOSTREAMSTATE_OKAY: /* impossible */ 3233 case PDMHOSTAUDIOSTREAMSTATE_INVALID: 3234 case PDMHOSTAUDIOSTREAMSTATE_END: 3235 case PDMHOSTAUDIOSTREAMSTATE_32BIT_HACK: 3196 3236 break; 3197 3237 } 3198 LogFunc(("PDMAUDIOSTREAM_STS_INITIALIZED was cleared: %s -> %s\n", 3199 drvAudioPlayStateName(enmPlayState), drvAudioPlayStateName(pStreamEx->Out.enmPlayState) )); 3200 } 3201 else 3202 { 3203 if (pStreamEx->fStatus & PDMAUDIOSTREAM_STS_BACKEND_READY) 3204 { 3205 /** @todo We need to resync the stream status somewhere... */ 3206 switch (enmPlayState) 3207 { 3208 case DRVAUDIOPLAYSTATE_PREBUF: 3209 case DRVAUDIOPLAYSTATE_PREBUF_SWITCHING: 3210 break; 3211 case DRVAUDIOPLAYSTATE_PREBUF_OVERDUE: 3212 pStreamEx->Out.enmPlayState = DRVAUDIOPLAYSTATE_PREBUF_COMMITTING; 3213 break; 3214 case DRVAUDIOPLAYSTATE_NOPLAY: 3215 pStreamEx->Out.enmPlayState = DRVAUDIOPLAYSTATE_PREBUF; 3216 break; 3217 case DRVAUDIOPLAYSTATE_PLAY: 3218 case DRVAUDIOPLAYSTATE_PLAY_PREBUF: 3219 case DRVAUDIOPLAYSTATE_PREBUF_COMMITTING: 3220 AssertFailedBreak(); 3221 /* no default */ 3222 case DRVAUDIOPLAYSTATE_END: 3223 case DRVAUDIOPLAYSTATE_INVALID: 3224 break; 3225 } 3226 LogFunc(("PDMAUDIOSTREAM_STS_INITIALIZED was set: %s -> %s\n", 3227 drvAudioPlayStateName(enmPlayState), drvAudioPlayStateName(pStreamEx->Out.enmPlayState) )); 3228 } 3229 else 3230 LogFunc(("PDMAUDIOSTREAM_STS_INITIALIZED was set (enmPlayState=%s), but PDMAUDIOSTREAM_STS_BACKEND_READY is not.\n", 3231 drvAudioPlayStateName(enmPlayState) )); 3232 } 3233 } 3238 break; 3239 3240 case PDMHOSTAUDIOSTREAMSTATE_INACTIVE: 3241 /* Stream is now inactive. Switch to noplay mode. */ 3242 pStreamEx->Out.enmPlayState = DRVAUDIOPLAYSTATE_NOPLAY; 3243 break; 3244 3245 /* no default: */ 3246 case PDMHOSTAUDIOSTREAMSTATE_INVALID: 3247 case PDMHOSTAUDIOSTREAMSTATE_END: 3248 case PDMHOSTAUDIOSTREAMSTATE_32BIT_HACK: 3249 break; 3250 } 3251 3252 LogFunc(("Stream '%s': %s/%s -> %s/%s\n", pStreamEx->Guest.Cfg.szName, 3253 PDMHostAudioStreamStateGetName(enmOldState), drvAudioPlayStateName(enmPlayState), 3254 PDMHostAudioStreamStateGetName(enmNewState), drvAudioPlayStateName(pStreamEx->Out.enmPlayState) )); 3234 3255 } 3235 3256 … … 3279 3300 && pThis->pHostDrvAudio != NULL) 3280 3301 { 3281 #ifdef LOG_ENABLED3282 char szState[DRVAUDIO_STATUS_STR_MAX];3283 #endif3284 3302 /* 3285 * Get the backend state and check if we've changed to "initialized" or 3286 * to switch prep mode. 3287 * 3288 * We don't really need to watch ENABLE or PAUSE here as these should be 3289 * in sync between our state and the backend (there is a tiny tiny chance 3290 * that we are resumed before the backend driver, but AIO threads really 3291 * shouldn't be getting here that fast I hope). 3303 * Get the backend state and check if it changed. 3292 3304 */ 3293 /** @todo 3294 * The PENDING_DISABLE (== draining) is not reported by most backend and it's an 3295 * open question whether we should still allow writes even when the backend 3296 * is draining anyway. We currently don't. Maybe we just re-define it as 3297 * a non-backend status flag. 3298 */ 3299 uint32_t const fBackendStatus = drvAudioStreamGetBackendStatus(pThis, pStreamEx); 3300 Assert( (fBackendStatus & (PDMAUDIOSTREAM_STS_ENABLED | PDMAUDIOSTREAM_STS_PAUSED)) 3301 == (pStreamEx->fStatus & (PDMAUDIOSTREAM_STS_ENABLED | PDMAUDIOSTREAM_STS_PAUSED)) 3302 || !(pStreamEx->fStatus & PDMAUDIOSTREAM_STS_BACKEND_READY) 3303 || !(fBackendStatus & PDMAUDIOSTREAM_STS_INITIALIZED)); 3304 3305 if (!((pStreamEx->fLastBackendStatus ^ fBackendStatus) & PDMAUDIOSTREAM_STS_INITIALIZED)) 3305 PDMHOSTAUDIOSTREAMSTATE const enmBackendState = drvAudioStreamGetBackendState(pThis, pStreamEx); 3306 if (enmBackendState == pStreamEx->enmLastBackendState) 3306 3307 { /* no relevant change - likely */ } 3307 3308 else 3308 3309 { 3309 drvAudioStreamPlayProcessBackendStateChange(pStreamEx, fBackendStatus, pStreamEx->fLastBackendStatus);3310 pStreamEx-> fLastBackendStatus = fBackendStatus;3310 drvAudioStreamPlayProcessBackendStateChange(pStreamEx, enmBackendState, pStreamEx->enmLastBackendState); 3311 pStreamEx->enmLastBackendState = enmBackendState; 3311 3312 } 3312 3313 … … 3318 3319 case DRVAUDIOPLAYSTATE_PLAY: 3319 3320 Assert(pStreamEx->fStatus & PDMAUDIOSTREAM_STS_BACKEND_READY); 3320 Assert( fBackendStatus & PDMAUDIOSTREAM_STS_INITIALIZED);3321 Assert(enmBackendState == PDMHOSTAUDIOSTREAMSTATE_OKAY); 3321 3322 rc = drvAudioStreamPlayLocked(pThis, pStreamEx, (uint8_t const *)pvBuf, cbBuf, pcbWritten); 3322 3323 break; … … 3324 3325 case DRVAUDIOPLAYSTATE_PLAY_PREBUF: 3325 3326 Assert(pStreamEx->fStatus & PDMAUDIOSTREAM_STS_BACKEND_READY); 3326 Assert( fBackendStatus & PDMAUDIOSTREAM_STS_INITIALIZED);3327 Assert(enmBackendState == PDMHOSTAUDIOSTREAMSTATE_OKAY); 3327 3328 rc = drvAudioStreamPlayLocked(pThis, pStreamEx, (uint8_t const *)pvBuf, cbBuf, pcbWritten); 3328 3329 drvAudioStreamPreBuffer(pStreamEx, (uint8_t const *)pvBuf, *pcbWritten, pStreamEx->Out.cbPreBufThreshold); … … 3332 3333 if (cbBuf + pStreamEx->Out.cbPreBuffered < pStreamEx->Out.cbPreBufThreshold) 3333 3334 rc = drvAudioStreamPlayToPreBuffer(pStreamEx, pvBuf, cbBuf, pStreamEx->Out.cbPreBufThreshold, pcbWritten); 3334 else if ( (fBackendStatus & PDMAUDIOSTREAM_STS_INITIALIZED)3335 else if ( enmBackendState == PDMHOSTAUDIOSTREAMSTATE_OKAY 3335 3336 && (pStreamEx->fStatus & PDMAUDIOSTREAM_STS_BACKEND_READY)) 3336 3337 { … … 3352 3353 case DRVAUDIOPLAYSTATE_PREBUF_OVERDUE: 3353 3354 Assert( !(pStreamEx->fStatus & PDMAUDIOSTREAM_STS_BACKEND_READY) 3354 || !(fBackendStatus & PDMAUDIOSTREAM_STS_INITIALIZED));3355 || enmBackendState != PDMHOSTAUDIOSTREAMSTATE_OKAY); 3355 3356 RT_FALL_THRU(); 3356 3357 case DRVAUDIOPLAYSTATE_PREBUF_SWITCHING: … … 3360 3361 case DRVAUDIOPLAYSTATE_PREBUF_COMMITTING: 3361 3362 Assert(pStreamEx->fStatus & PDMAUDIOSTREAM_STS_BACKEND_READY); 3362 Assert( fBackendStatus & PDMAUDIOSTREAM_STS_INITIALIZED);3363 Assert(enmBackendState == PDMHOSTAUDIOSTREAMSTATE_OKAY); 3363 3364 rc = drvAudioStreamPreBufComitting(pThis, pStreamEx, (uint8_t const *)pvBuf, cbBuf, pcbWritten); 3364 3365 break; … … 3368 3369 pStreamEx->offInternal += cbBuf; 3369 3370 Log3Func(("[%s] Discarding the data, backend state: %s\n", pStreamEx->Core.szName, 3370 drvAudioStreamStatusToStr(szState, fBackendStatus) ));3371 PDMHostAudioStreamStateGetName(enmBackendState) )); 3371 3372 break; 3372 3373 … … 3725 3726 } 3726 3727 3727 uint32_t const fBackendStatus = drvAudioStreamGetBackendStatus(pThis, pStreamEx);3728 if ( fBackendStatus & PDMAUDIOSTREAM_STS_INITIALIZED)3728 PDMHOSTAUDIOSTREAMSTATE const enmBackendState = drvAudioStreamGetBackendState(pThis, pStreamEx); 3729 if (enmBackendState == PDMHOSTAUDIOSTREAMSTATE_OKAY) 3729 3730 { 3730 3731 /* … … 3889 3890 if (pThis->pHostDrvAudio->pfnStreamNotifyDeviceChanged) 3890 3891 { 3891 LogFlowFunc(("Calling pfnStreamNotifyDeviceChanged on %s, old backend stat us: %#x...\n", pStreamEx->Core.szName,3892 drvAudioStreamGetBackendStatus(pThis, pStreamEx) ));3892 LogFlowFunc(("Calling pfnStreamNotifyDeviceChanged on %s, old backend state: %s...\n", pStreamEx->Core.szName, 3893 PDMHostAudioStreamStateGetName(drvAudioStreamGetBackendState(pThis, pStreamEx)) )); 3893 3894 pThis->pHostDrvAudio->pfnStreamNotifyDeviceChanged(pThis->pHostDrvAudio, pStreamEx->pBackend, pvUser); 3894 LogFlowFunc(("New stream backend status: %#x.\n", drvAudioStreamGetBackendStatus(pThis, pStreamEx) )); 3895 LogFlowFunc(("New stream backend state: %s\n", 3896 PDMHostAudioStreamStateGetName(drvAudioStreamGetBackendState(pThis, pStreamEx)) )); 3895 3897 } 3896 3898 else … … 4216 4218 AssertPtrReturn(pIHostDrvAudio->pfnStreamGetWritable, VERR_INVALID_POINTER); 4217 4219 AssertPtrNullReturn(pIHostDrvAudio->pfnStreamGetPending, VERR_INVALID_POINTER); 4218 AssertPtrReturn(pIHostDrvAudio->pfnStreamGetStat us, VERR_INVALID_POINTER);4220 AssertPtrReturn(pIHostDrvAudio->pfnStreamGetState, VERR_INVALID_POINTER); 4219 4221 AssertPtrReturn(pIHostDrvAudio->pfnStreamPlay, VERR_INVALID_POINTER); 4220 4222 AssertPtrReturn(pIHostDrvAudio->pfnStreamCapture, VERR_INVALID_POINTER); -
trunk/src/VBox/Devices/Audio/DrvHostAudioAlsa.cpp
r88819 r88887 1118 1118 1119 1119 /** 1120 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus} 1121 */ 1122 static DECLCALLBACK(uint32_t) drvHostAlsaAudioHA_StreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 1123 { 1124 RT_NOREF(pInterface, pStream); 1125 1126 return PDMAUDIOSTREAM_STS_INITIALIZED | PDMAUDIOSTREAM_STS_ENABLED; 1120 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState} 1121 */ 1122 static DECLCALLBACK(PDMHOSTAUDIOSTREAMSTATE) drvHostAlsaAudioHA_StreamGetState(PPDMIHOSTAUDIO pInterface, 1123 PPDMAUDIOBACKENDSTREAM pStream) 1124 { 1125 RT_NOREF(pInterface); 1126 AssertPtrReturn(pStream, PDMHOSTAUDIOSTREAMSTATE_INVALID); 1127 1128 return PDMHOSTAUDIOSTREAMSTATE_OKAY; 1127 1129 } 1128 1130 … … 1418 1420 pThis->IHostAudio.pfnStreamGetWritable = drvHostAlsaAudioHA_StreamGetWritable; 1419 1421 pThis->IHostAudio.pfnStreamGetPending = drvHostAlsaAudioHA_StreamGetPending; 1420 pThis->IHostAudio.pfnStreamGetStat us = drvHostAlsaAudioHA_StreamGetStatus;1422 pThis->IHostAudio.pfnStreamGetState = drvHostAlsaAudioHA_StreamGetState; 1421 1423 pThis->IHostAudio.pfnStreamPlay = drvHostAlsaAudioHA_StreamPlay; 1422 1424 pThis->IHostAudio.pfnStreamCapture = drvHostAlsaAudioHA_StreamCapture; -
trunk/src/VBox/Devices/Audio/DrvHostAudioCoreAudio.cpp
r88820 r88887 2424 2424 2425 2425 /** 2426 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus} 2427 */ 2428 static DECLCALLBACK(uint32_t) drvHostCoreAudioHA_StreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 2426 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState} 2427 */ 2428 static DECLCALLBACK(PDMHOSTAUDIOSTREAMSTATE) drvHostCoreAudioHA_StreamGetState(PPDMIHOSTAUDIO pInterface, 2429 PPDMAUDIOBACKENDSTREAM pStream) 2429 2430 { 2430 2431 RT_NOREF(pInterface); 2431 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 2432 2433 PCOREAUDIOSTREAM pCAStream = (PCOREAUDIOSTREAM)pStream; 2434 2435 uint32_t fStrmStatus = PDMAUDIOSTREAM_STS_NONE; 2436 2437 if (pCAStream->pCfg) /* Configured? */ 2438 { 2439 if (ASMAtomicReadU32(&pCAStream->enmStatus) == COREAUDIOSTATUS_INIT) 2440 fStrmStatus |= PDMAUDIOSTREAM_STS_INITIALIZED | PDMAUDIOSTREAM_STS_ENABLED; 2441 } 2442 2443 return fStrmStatus; 2432 PCOREAUDIOSTREAM pStreamCa = (PCOREAUDIOSTREAM)pStream; 2433 AssertPtrReturn(pStreamCa, PDMHOSTAUDIOSTREAMSTATE_INVALID); 2434 2435 if (pStreamCa->pCfg) /* Configured? */ 2436 { 2437 if (ASMAtomicReadU32(&pStreamCa->enmStatus) == COREAUDIOSTATUS_INIT) 2438 return PDMHOSTAUDIOSTREAMSTATE_OKAY; 2439 } 2440 2441 return PDMHOSTAUDIOSTREAMSTATE_NOT_WORKING; /** @todo ?? */ 2444 2442 } 2445 2443 … … 2557 2555 pThis->IHostAudio.pfnStreamGetWritable = drvHostCoreAudioHA_StreamGetWritable; 2558 2556 pThis->IHostAudio.pfnStreamGetPending = NULL; 2559 pThis->IHostAudio.pfnStreamGetStat us = drvHostCoreAudioHA_StreamGetStatus;2557 pThis->IHostAudio.pfnStreamGetState = drvHostCoreAudioHA_StreamGetState; 2560 2558 pThis->IHostAudio.pfnStreamPlay = drvHostCoreAudioHA_StreamPlay; 2561 2559 pThis->IHostAudio.pfnStreamCapture = drvHostCoreAudioHA_StreamCapture; -
trunk/src/VBox/Devices/Audio/DrvHostAudioDSound.cpp
r88853 r88887 2402 2402 2403 2403 /** 2404 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus} 2405 */ 2406 static DECLCALLBACK(uint32_t) drvHostDSoundHA_StreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 2404 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState} 2405 */ 2406 static DECLCALLBACK(PDMHOSTAUDIOSTREAMSTATE) drvHostDSoundHA_StreamGetState(PPDMIHOSTAUDIO pInterface, 2407 PPDMAUDIOBACKENDSTREAM pStream) 2407 2408 { 2408 2409 RT_NOREF(pInterface); 2409 2410 PDSOUNDSTREAM pStreamDS = (PDSOUNDSTREAM)pStream; 2410 AssertPtrReturn(pStreamDS, PDMAUDIOSTREAM_STS_NONE); 2411 2412 uint32_t fStrmStatus = PDMAUDIOSTREAM_STS_INITIALIZED; 2413 if (pStreamDS->fEnabled) 2414 fStrmStatus |= PDMAUDIOSTREAM_STS_ENABLED; 2415 2416 LogFlowFunc(("returns %#x for '%s' {%s}\n", fStrmStatus, pStreamDS->Cfg.szName, drvHostDSoundStreamStatusString(pStreamDS))); 2417 return fStrmStatus; 2411 AssertPtrReturn(pStreamDS, PDMHOSTAUDIOSTREAMSTATE_INVALID); 2412 2413 LogFlowFunc(("returns OKAY for '%s' {%s}\n", pStreamDS->Cfg.szName, drvHostDSoundStreamStatusString(pStreamDS))); 2414 return PDMHOSTAUDIOSTREAMSTATE_OKAY; 2418 2415 } 2419 2416 … … 2771 2768 pThis->IHostAudio.pfnStreamGetWritable = drvHostDSoundHA_StreamGetWritable; 2772 2769 pThis->IHostAudio.pfnStreamGetPending = NULL; 2773 pThis->IHostAudio.pfnStreamGetStat us = drvHostDSoundHA_StreamGetStatus;2770 pThis->IHostAudio.pfnStreamGetState = drvHostDSoundHA_StreamGetState; 2774 2771 pThis->IHostAudio.pfnStreamPlay = drvHostDSoundHA_StreamPlay; 2775 2772 pThis->IHostAudio.pfnStreamCapture = drvHostDSoundHA_StreamCapture; -
trunk/src/VBox/Devices/Audio/DrvHostAudioDebug.cpp
r88868 r88887 261 261 262 262 /** 263 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus} 264 */ 265 static DECLCALLBACK(uint32_t) drvHostDebugAudioHA_StreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 266 { 267 RT_NOREF(pInterface, pStream); 268 return PDMAUDIOSTREAM_STS_INITIALIZED | PDMAUDIOSTREAM_STS_ENABLED; 263 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState} 264 */ 265 static DECLCALLBACK(PDMHOSTAUDIOSTREAMSTATE) drvHostDebugAudioHA_StreamGetState(PPDMIHOSTAUDIO pInterface, 266 PPDMAUDIOBACKENDSTREAM pStream) 267 { 268 RT_NOREF(pInterface); 269 AssertPtrReturn(pStream, PDMHOSTAUDIOSTREAMSTATE_INVALID); 270 return PDMHOSTAUDIOSTREAMSTATE_OKAY; 269 271 } 270 272 … … 448 450 pThis->IHostAudio.pfnStreamGetWritable = drvHostDebugAudioHA_StreamGetWritable; 449 451 pThis->IHostAudio.pfnStreamGetPending = drvHostDebugAudioHA_StreamGetPending; 450 pThis->IHostAudio.pfnStreamGetStat us = drvHostDebugAudioHA_StreamGetStatus;452 pThis->IHostAudio.pfnStreamGetState = drvHostDebugAudioHA_StreamGetState; 451 453 pThis->IHostAudio.pfnStreamPlay = drvHostDebugAudioHA_StreamPlay; 452 454 pThis->IHostAudio.pfnStreamCapture = drvHostDebugAudioHA_StreamCapture; -
trunk/src/VBox/Devices/Audio/DrvHostAudioNull.cpp
r88819 r88887 181 181 182 182 /** 183 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus} 184 */ 185 static DECLCALLBACK(uint32_t) drvHostNullAudioHA_StreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 186 { 187 RT_NOREF(pInterface, pStream); 188 return PDMAUDIOSTREAM_STS_INITIALIZED | PDMAUDIOSTREAM_STS_ENABLED; 183 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState} 184 */ 185 static DECLCALLBACK(PDMHOSTAUDIOSTREAMSTATE) drvHostNullAudioHA_StreamGetState(PPDMIHOSTAUDIO pInterface, 186 PPDMAUDIOBACKENDSTREAM pStream) 187 { 188 RT_NOREF(pInterface); 189 AssertPtrReturn(pStream, PDMHOSTAUDIOSTREAMSTATE_INVALID); 190 #if 0 191 /* Bit bucket appraoch where we ignore the output and silence the input buffers. */ 192 return PDMHOSTAUDIOSTREAMSTATE_OKAY; 193 #else 194 /* Approach where the mixer in the devices skips us and saves a few CPU cycles. */ 195 return PDMHOSTAUDIOSTREAMSTATE_INACTIVE; 196 #endif 189 197 } 190 198 … … 242 250 /* .pfnStreamGetWritable =*/ drvHostNullAudioHA_StreamGetWritable, 243 251 /* .pfnStreamGetPending =*/ drvHostNullAudioHA_StreamGetPending, 244 /* .pfnStreamGetStat us =*/ drvHostNullAudioHA_StreamGetStatus,252 /* .pfnStreamGetState =*/ drvHostNullAudioHA_StreamGetState, 245 253 /* .pfnStreamPlay =*/ drvHostNullAudioHA_StreamPlay, 246 254 /* .pfnStreamCapture =*/ drvHostNullAudioHA_StreamCapture, -
trunk/src/VBox/Devices/Audio/DrvHostAudioOss.cpp
r88819 r88887 699 699 700 700 /** 701 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus} 702 */ 703 static DECLCALLBACK(uint32_t) drvHostOssAudioHA_StreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 704 { 705 RT_NOREF(pInterface, pStream); 706 return PDMAUDIOSTREAM_STS_INITIALIZED | PDMAUDIOSTREAM_STS_ENABLED; 701 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState} 702 */ 703 static DECLCALLBACK(PDMHOSTAUDIOSTREAMSTATE) drvHostOssAudioHA_StreamGetState(PPDMIHOSTAUDIO pInterface, 704 PPDMAUDIOBACKENDSTREAM pStream) 705 { 706 RT_NOREF(pInterface); 707 AssertPtrReturn(pStream, PDMHOSTAUDIOSTREAMSTATE_INVALID); 708 return PDMHOSTAUDIOSTREAMSTATE_OKAY; 707 709 } 708 710 … … 871 873 pThis->IHostAudio.pfnStreamGetWritable = drvHostOssAudioHA_StreamGetWritable; 872 874 pThis->IHostAudio.pfnStreamGetPending = NULL; 873 pThis->IHostAudio.pfnStreamGetStat us = drvHostOssAudioHA_StreamGetStatus;875 pThis->IHostAudio.pfnStreamGetState = drvHostOssAudioHA_StreamGetState; 874 876 pThis->IHostAudio.pfnStreamPlay = drvHostOssAudioHA_StreamPlay; 875 877 pThis->IHostAudio.pfnStreamCapture = drvHostOssAudioHA_StreamCapture; -
trunk/src/VBox/Devices/Audio/DrvHostAudioPulseAudio.cpp
r88848 r88887 1547 1547 1548 1548 /** 1549 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus} 1550 */ 1551 static DECLCALLBACK(uint32_t) drvHostAudioPaHA_StreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 1549 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState} 1550 */ 1551 static DECLCALLBACK(PDMHOSTAUDIOSTREAMSTATE) drvHostAudioPaHA_StreamGetState(PPDMIHOSTAUDIO pInterface, 1552 PPDMAUDIOBACKENDSTREAM pStream) 1552 1553 { 1553 1554 PDRVHOSTPULSEAUDIO pThis = RT_FROM_MEMBER(pInterface, DRVHOSTPULSEAUDIO, IHostAudio); 1554 RT_NOREF(pStream);1555 AssertPtrReturn(pStream, PDMHOSTAUDIOSTREAMSTATE_INVALID); 1555 1556 1556 1557 /* Check PulseAudio's general status. */ … … 1561 1562 { 1562 1563 /** @todo should we check the actual stream state? */ 1563 return PDM AUDIOSTREAM_STS_INITIALIZED | PDMAUDIOSTREAM_STS_ENABLED;1564 return PDMHOSTAUDIOSTREAMSTATE_OKAY; 1564 1565 } 1565 1566 LogFunc(("non-good context state: %d\n", enmState)); … … 1567 1568 else 1568 1569 LogFunc(("No context!\n")); 1569 return PDM AUDIOSTREAM_STS_NONE;1570 return PDMHOSTAUDIOSTREAMSTATE_NOT_WORKING; 1570 1571 } 1571 1572 … … 1912 1913 pThis->IHostAudio.pfnStreamGetWritable = drvHostAudioPaHA_StreamGetWritable; 1913 1914 pThis->IHostAudio.pfnStreamGetPending = NULL; 1914 pThis->IHostAudio.pfnStreamGetStat us = drvHostAudioPaHA_StreamGetStatus;1915 pThis->IHostAudio.pfnStreamGetState = drvHostAudioPaHA_StreamGetState; 1915 1916 pThis->IHostAudio.pfnStreamPlay = drvHostAudioPaHA_StreamPlay; 1916 1917 pThis->IHostAudio.pfnStreamCapture = drvHostAudioPaHA_StreamCapture; -
trunk/src/VBox/Devices/Audio/DrvHostAudioValidationKit.cpp
r88819 r88887 332 332 333 333 /** 334 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus} 335 */ 336 static DECLCALLBACK(uint32_t) drvHostValKitAudioHA_StreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 337 { 338 RT_NOREF(pInterface, pStream); 339 return PDMAUDIOSTREAM_STS_INITIALIZED | PDMAUDIOSTREAM_STS_ENABLED; 334 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState} 335 */ 336 static DECLCALLBACK(PDMHOSTAUDIOSTREAMSTATE) drvHostValKitAudioHA_StreamGetState(PPDMIHOSTAUDIO pInterface, 337 PPDMAUDIOBACKENDSTREAM pStream) 338 { 339 RT_NOREF(pInterface); 340 AssertPtrReturn(pStream, PDMHOSTAUDIOSTREAMSTATE_INVALID); 341 return PDMHOSTAUDIOSTREAMSTATE_OKAY; 340 342 } 341 343 … … 445 447 pThis->IHostAudio.pfnStreamGetWritable = drvHostValKitAudioHA_StreamGetWritable; 446 448 pThis->IHostAudio.pfnStreamGetPending = NULL; 447 pThis->IHostAudio.pfnStreamGetStat us = drvHostValKitAudioHA_StreamGetStatus;449 pThis->IHostAudio.pfnStreamGetState = drvHostValKitAudioHA_StreamGetState; 448 450 pThis->IHostAudio.pfnStreamPlay = drvHostValKitAudioHA_StreamPlay; 449 451 pThis->IHostAudio.pfnStreamCapture = drvHostValKitAudioHA_StreamCapture; -
trunk/src/VBox/Devices/Audio/DrvHostAudioWasApi.cpp
r88878 r88887 2519 2519 2520 2520 /** 2521 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus} 2522 */ 2523 static DECLCALLBACK(uint32_t) drvHostAudioWasHA_StreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 2521 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState} 2522 */ 2523 static DECLCALLBACK(PDMHOSTAUDIOSTREAMSTATE) drvHostAudioWasHA_StreamGetState(PPDMIHOSTAUDIO pInterface, 2524 PPDMAUDIOBACKENDSTREAM pStream) 2524 2525 { 2525 2526 RT_NOREF(pInterface); 2526 2527 PDRVHOSTAUDIOWASSTREAM pStreamWas = (PDRVHOSTAUDIOWASSTREAM)pStream; 2527 AssertPtrReturn(pStreamWas, PDM AUDIOSTREAM_STS_NONE);2528 2529 uint32_t fStrmStatus = 0;2528 AssertPtrReturn(pStreamWas, PDMHOSTAUDIOSTREAMSTATE_INVALID); 2529 2530 PDMHOSTAUDIOSTREAMSTATE enmState; 2530 2531 AssertPtr(pStreamWas->pDevCfg); 2531 2532 if (pStreamWas->pDevCfg /*paranoia*/) 2532 2533 { 2533 2534 if (RT_SUCCESS(pStreamWas->pDevCfg->rcSetup)) 2534 fStrmStatus |= PDMAUDIOSTREAM_STS_INITIALIZED; 2535 else if (pStreamWas->pDevCfg->rcSetup != VERR_AUDIO_STREAM_INIT_IN_PROGRESS) 2536 { 2537 /** @todo trigger device reset? Probably won't help, so what to do? */ 2538 } 2539 } 2540 if (pStreamWas->fEnabled) 2541 { 2542 fStrmStatus |= PDMAUDIOSTREAM_STS_ENABLED; 2543 if (pStreamWas->fDraining) 2544 fStrmStatus |= PDMAUDIOSTREAM_STS_PENDING_DISABLE; 2545 if (pStreamWas->fRestartOnResume) 2546 fStrmStatus |= PDMAUDIOSTREAM_STS_PAUSED; 2547 } 2548 if (pStreamWas->fSwitchingDevice) 2549 fStrmStatus |= PDMAUDIOSTREAM_STS_PREPARING_SWITCH; 2550 2551 LogFlowFunc(("returns %#x for '%s' {%s}\n", fStrmStatus, pStreamWas->Cfg.szName, drvHostWasStreamStatusString(pStreamWas))); 2552 return fStrmStatus; 2535 enmState = PDMHOSTAUDIOSTREAMSTATE_OKAY; 2536 else if ( pStreamWas->pDevCfg->rcSetup == VERR_AUDIO_STREAM_INIT_IN_PROGRESS 2537 || pStreamWas->fSwitchingDevice ) 2538 enmState = PDMHOSTAUDIOSTREAMSTATE_INITIALIZING; 2539 else 2540 enmState = PDMHOSTAUDIOSTREAMSTATE_NOT_WORKING; 2541 } 2542 else if (pStreamWas->fSwitchingDevice) 2543 enmState = PDMHOSTAUDIOSTREAMSTATE_INITIALIZING; 2544 else 2545 enmState = PDMHOSTAUDIOSTREAMSTATE_NOT_WORKING; 2546 2547 LogFlowFunc(("returns %d for '%s' {%s}\n", enmState, pStreamWas->Cfg.szName, drvHostWasStreamStatusString(pStreamWas))); 2548 return enmState; 2553 2549 } 2554 2550 … … 3020 3016 pThis->IHostAudio.pfnStreamGetWritable = drvHostAudioWasHA_StreamGetWritable; 3021 3017 pThis->IHostAudio.pfnStreamGetPending = drvHostAudioWasHA_StreamGetPending; 3022 pThis->IHostAudio.pfnStreamGetStat us = drvHostAudioWasHA_StreamGetStatus;3018 pThis->IHostAudio.pfnStreamGetState = drvHostAudioWasHA_StreamGetState; 3023 3019 pThis->IHostAudio.pfnStreamPlay = drvHostAudioWasHA_StreamPlay; 3024 3020 pThis->IHostAudio.pfnStreamCapture = drvHostAudioWasHA_StreamCapture; -
trunk/src/VBox/Main/src-client/DrvAudioRec.cpp
r88819 r88887 609 609 610 610 /** 611 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus} 612 */ 613 static DECLCALLBACK(uint32_t) drvAudioVideoRecHA_StreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 614 { 615 RT_NOREF(pInterface, pStream); 616 return PDMAUDIOSTREAM_STS_INITIALIZED | PDMAUDIOSTREAM_STS_ENABLED; 611 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState} 612 */ 613 static DECLCALLBACK(PDMHOSTAUDIOSTREAMSTATE) drvAudioVideoRecHA_StreamGetState(PPDMIHOSTAUDIO pInterface, 614 PPDMAUDIOBACKENDSTREAM pStream) 615 { 616 RT_NOREF(pInterface); 617 AssertPtrReturn(pStream, PDMHOSTAUDIOSTREAMSTATE_INVALID); 618 return PDMHOSTAUDIOSTREAMSTATE_OKAY; 617 619 } 618 620 … … 1112 1114 pThis->IHostAudio.pfnStreamGetWritable = drvAudioVideoRecHA_StreamGetWritable; 1113 1115 pThis->IHostAudio.pfnStreamGetPending = NULL; 1114 pThis->IHostAudio.pfnStreamGetStat us = drvAudioVideoRecHA_StreamGetStatus;1116 pThis->IHostAudio.pfnStreamGetState = drvAudioVideoRecHA_StreamGetState; 1115 1117 pThis->IHostAudio.pfnStreamPlay = drvAudioVideoRecHA_StreamPlay; 1116 1118 pThis->IHostAudio.pfnStreamCapture = drvAudioVideoRecHA_StreamCapture; -
trunk/src/VBox/Main/src-client/DrvAudioVRDE.cpp
r88885 r88887 415 415 } 416 416 } 417 pDrv->pConsoleVRDPServer = NULL; 417 pDrv->pConsoleVRDPServer = NULL; /** @todo r=bird: WTF? */ 418 418 419 419 return VINF_SUCCESS; … … 595 595 596 596 /** 597 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus} 598 */ 599 static DECLCALLBACK(uint32_t) drvAudioVrdeHA_StreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 597 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState} 598 */ 599 static DECLCALLBACK(PDMHOSTAUDIOSTREAMSTATE) drvAudioVrdeHA_StreamGetState(PPDMIHOSTAUDIO pInterface, 600 PPDMAUDIOBACKENDSTREAM pStream) 600 601 { 601 602 PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio); 602 RT_NOREF(pStream); 603 604 return pDrv->cClients > 0 605 ? PDMAUDIOSTREAM_STS_INITIALIZED | PDMAUDIOSTREAM_STS_ENABLED 606 #if 0 /* later mabye */ /** @todo r=bird: Weird backend status mess. */ 607 : PDMAUDIOSTREAM_STS_NONE /* play possum if the clients all disappears. Re-init should be underways. */; 608 #else 609 : PDMAUDIOSTREAM_STS_INITIALIZED /* If any clients are connected, flag the stream as enabled. */; 610 #endif 603 AssertPtrReturn(pStream, PDMHOSTAUDIOSTREAMSTATE_INVALID); 604 605 return pDrv->cClients > 0 ? PDMHOSTAUDIOSTREAMSTATE_OKAY : PDMHOSTAUDIOSTREAMSTATE_INACTIVE; 611 606 } 612 607 … … 806 801 pThis->IHostAudio.pfnStreamGetWritable = drvAudioVrdeHA_StreamGetWritable; 807 802 pThis->IHostAudio.pfnStreamGetPending = NULL; 808 pThis->IHostAudio.pfnStreamGetStat us = drvAudioVrdeHA_StreamGetStatus;803 pThis->IHostAudio.pfnStreamGetState = drvAudioVrdeHA_StreamGetState; 809 804 pThis->IHostAudio.pfnStreamPlay = drvAudioVrdeHA_StreamPlay; 810 805 pThis->IHostAudio.pfnStreamCapture = drvAudioVrdeHA_StreamCapture;
Note:
See TracChangeset
for help on using the changeset viewer.