Changeset 88236 in vbox for trunk/src/VBox/Devices/Audio
- Timestamp:
- Mar 22, 2021 11:31:26 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvAudio.cpp
r88235 r88236 301 301 302 302 #ifdef LOG_ENABLED 303 304 /** Buffer size for dbgAudioStreamStatusToStr. */ 305 # define DRVAUDIO_STATUS_STR_MAX sizeof("INITIALIZED ENABLED PAUSED PENDING_DISABLED PENDING_REINIT 0x12345678") 306 303 307 /** 304 308 * Converts an audio stream status to a string. 305 309 * 306 * @returns Stringified stream status flags. Must be free'd with RTStrFree(). 307 * "NONE" if no flags set. 308 * @param fStatus Stream status flags to convert. 309 */ 310 static char *dbgAudioStreamStatusToStr(PDMAUDIOSTREAMSTS fStatus) 311 { 312 #define APPEND_FLAG_TO_STR(_aFlag) \ 313 if (fStatus & PDMAUDIOSTREAMSTS_FLAGS_##_aFlag) \ 314 { \ 315 if (pszFlags) \ 316 { \ 317 rc2 = RTStrAAppend(&pszFlags, " "); \ 318 if (RT_FAILURE(rc2)) \ 319 break; \ 320 } \ 321 \ 322 rc2 = RTStrAAppend(&pszFlags, #_aFlag); \ 323 if (RT_FAILURE(rc2)) \ 324 break; \ 325 } \ 326 327 char *pszFlags = NULL; 328 int rc2 = VINF_SUCCESS; 329 330 do 331 { 332 APPEND_FLAG_TO_STR(INITIALIZED ); 333 APPEND_FLAG_TO_STR(ENABLED ); 334 APPEND_FLAG_TO_STR(PAUSED ); 335 APPEND_FLAG_TO_STR(PENDING_DISABLE); 336 APPEND_FLAG_TO_STR(PENDING_REINIT ); 337 } while (0); 338 339 if (!pszFlags) 340 rc2 = RTStrAAppend(&pszFlags, "NONE"); 341 342 if ( RT_FAILURE(rc2) 343 && pszFlags) 344 { 345 RTStrFree(pszFlags); 346 pszFlags = NULL; 347 } 348 349 #undef APPEND_FLAG_TO_STR 350 351 return pszFlags; 352 } 353 #endif /* defined(VBOX_STRICT) || defined(LOG_ENABLED) */ 310 * @returns pszDst 311 * @param pszDst Buffer to convert into, at least minimum size is 312 * DRVAUDIO_STATUS_STR_MAX. 313 * @param fStatus Stream status flags to convert. 314 */ 315 static const char *dbgAudioStreamStatusToStr(char pszDst[DRVAUDIO_STATUS_STR_MAX], PDMAUDIOSTREAMSTS fStatus) 316 { 317 static const struct 318 { 319 const char *pszMnemonic; 320 uint32_t cchMnemnonic; 321 PDMAUDIOSTREAMSTS fFlag; 322 } s_aFlags[] = 323 { 324 { RT_STR_TUPLE("INITIALIZED "), PDMAUDIOSTREAMSTS_FLAGS_INITIALIZED }, 325 { RT_STR_TUPLE("ENABLED "), PDMAUDIOSTREAMSTS_FLAGS_ENABLED }, 326 { RT_STR_TUPLE("PAUSED "), PDMAUDIOSTREAMSTS_FLAGS_PAUSED }, 327 { RT_STR_TUPLE("PENDING_DISABLE "), PDMAUDIOSTREAMSTS_FLAGS_PENDING_DISABLE }, 328 { RT_STR_TUPLE("PENDING_REINIT "), PDMAUDIOSTREAMSTS_FLAGS_PENDING_REINIT }, 329 }; 330 if (!fStatus) 331 strcpy(pszDst, "NONE"); 332 else 333 { 334 char *psz = pszDst; 335 for (size_t i = 0; i < RT_ELEMENTS(s_aFlags); i++) 336 if (fStatus & s_aFlags[i].fFlag) 337 { 338 memcpy(psz, s_aFlags[i].pszMnemonic, s_aFlags[i].cchMnemnonic); 339 psz += s_aFlags[i].cchMnemnonic; 340 fStatus &= ~s_aFlags[i].fFlag; 341 if (!fStatus) 342 break; 343 } 344 if (fStatus == 0) 345 psz[-1] = '\0'; 346 else 347 psz += RTStrPrintf(psz, DRVAUDIO_STATUS_STR_MAX - (psz - pszDst), "%#x", fStatus); 348 Assert((uintptr_t)(psz - pszDst) <= DRVAUDIO_STATUS_STR_MAX); 349 } 350 return pszDst; 351 } 352 353 #endif /* defined(LOG_ENABLED) */ 354 354 355 355 # if 0 /* unused */ … … 489 489 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 490 490 491 LogFunc(("[%s] enmStreamCmd=%s\n", pStream->szName, PDMAudioStrmCmdGetName(enmStreamCmd)));492 493 491 #ifdef LOG_ENABLED 494 char *pszStreamSts = dbgAudioStreamStatusToStr(pStream->fStatus);495 LogFlowFunc(("fStatus=%s\n", pszStreamSts)); 496 RTStrFree(pszStreamSts);497 #endif /* LOG_ENABLED */ 492 char szStreamSts[DRVAUDIO_STATUS_STR_MAX]; 493 #endif 494 LogFunc(("[%s] enmStreamCmd=%s fStatus=%s\n", pStream->szName, PDMAudioStrmCmdGetName(enmStreamCmd), 495 dbgAudioStreamStatusToStr(szStreamSts, pStream->fStatus))); 498 496 499 497 int rc = VINF_SUCCESS; … … 600 598 601 599 #ifdef LOG_ENABLED 602 char *pszStreamSts = dbgAudioStreamStatusToStr(pStream->fStatus);603 LogFlowFunc(("[%s] enmStreamCmd=%s, fStatus=%s\n", pStream->szName, PDMAudioStrmCmdGetName(enmStreamCmd), pszStreamSts)); 604 RTStrFree(pszStreamSts);605 #endif /* LOG_ENABLED */ 600 char szStreamSts[DRVAUDIO_STATUS_STR_MAX]; 601 #endif 602 LogFlowFunc(("[%s] enmStreamCmd=%s, fStatus=%s\n", pStream->szName, PDMAudioStrmCmdGetName(enmStreamCmd), 603 dbgAudioStreamStatusToStr(szStreamSts, pStream->fStatus))); 606 604 607 605 if (!pThis->pHostDrvAudio) /* If not lower driver is configured, bail out. */ … … 1109 1107 #endif 1110 1108 1111 #ifdef LOG_ENABLED1112 char *pszStreamSts = dbgAudioStreamStatusToStr(pStream->fStatus);1113 AssertPtr(pszStreamSts);1114 #endif1115 1116 1109 /* Whether to discard the incoming data or not. */ 1117 1110 bool fToBitBucket = false; … … 1220 1213 1221 1214 } while (0); 1222 1223 #ifdef LOG_ENABLED1224 RTStrFree(pszStreamSts);1225 #endif1226 1215 1227 1216 int rc2 = RTCritSectLeave(&pThis->CritSect); … … 1366 1355 1367 1356 #ifdef LOG_ENABLED 1368 char *pszStreamSts = dbgAudioStreamStatusToStr(pStream->fStatus); 1369 Log3Func(("[%s] fStatus=%s\n", pStream->szName, pszStreamSts)); 1370 RTStrFree(pszStreamSts); 1371 #endif /* LOG_ENABLED */ 1372 1357 char szStreamSts[DRVAUDIO_STATUS_STR_MAX]; 1358 #endif 1359 Log3Func(("[%s] fStatus=%s\n", pStream->szName, dbgAudioStreamStatusToStr(szStreamSts, pStream->fStatus))); 1373 1360 } 1374 1361 } … … 1397 1384 1398 1385 #ifdef LOG_ENABLED 1399 char *pszStreamSts = dbgAudioStreamStatusToStr(pStream->fStatus); 1400 Log3Func(("[%s] fStatus=%s\n", pStream->szName, pszStreamSts)); 1401 RTStrFree(pszStreamSts); 1402 #endif /* LOG_ENABLED */ 1386 char szStreamSts[DRVAUDIO_STATUS_STR_MAX]; 1387 #endif 1388 Log3Func(("[%s] fStatus=%s\n", pStream->szName, dbgAudioStreamStatusToStr(szStreamSts, pStream->fStatus))); 1403 1389 1404 1390 /* Not enabled or paused? Skip iteration. */ … … 1675 1661 PDMAUDIOSTREAMSTS fStrmStatus = pStream->fStatus; 1676 1662 #ifdef LOG_ENABLED 1677 char *pszStreamSts = dbgAudioStreamStatusToStr(fStrmStatus); 1678 Log3Func(("[%s] Start fStatus=%s\n", pStream->szName, pszStreamSts)); 1679 RTStrFree(pszStreamSts); 1680 #endif /* LOG_ENABLED */ 1663 char szStreamSts[DRVAUDIO_STATUS_STR_MAX]; 1664 #endif 1665 Log3Func(("[%s] Start fStatus=%s\n", pStream->szName, dbgAudioStreamStatusToStr(szStreamSts, fStrmStatus))); 1681 1666 1682 1667 do /* No, this isn't a loop either. sigh. */ … … 1829 1814 } while (0); 1830 1815 1831 #ifdef LOG_ENABLED 1832 uint32_t cFramesLive = AudioMixBufLive(&pStream->Host.MixBuf); 1833 pszStreamSts = dbgAudioStreamStatusToStr(fStrmStatus); 1834 Log3Func(("[%s] End fStatus=%s, cFramesLive=%RU32, cfPlayedTotal=%RU32, rc=%Rrc\n", 1835 pStream->szName, pszStreamSts, cFramesLive, cfPlayedTotal, rc)); 1836 RTStrFree(pszStreamSts); 1837 #endif /* LOG_ENABLED */ 1816 Log3Func(("[%s] End fStatus=%s, cFramesLive=%RU32, cfPlayedTotal=%RU32, rc=%Rrc\n", pStream->szName, 1817 dbgAudioStreamStatusToStr(szStreamSts, fStrmStatus), AudioMixBufLive(&pStream->Host.MixBuf), cfPlayedTotal, rc)); 1838 1818 1839 1819 int rc2 = RTCritSectLeave(&pThis->CritSect); … … 2050 2030 2051 2031 #ifdef LOG_ENABLED 2052 char *pszStreamSts = dbgAudioStreamStatusToStr(pStream->fStatus); 2053 Log3Func(("[%s] fStatus=%s\n", pStream->szName, pszStreamSts)); 2054 RTStrFree(pszStreamSts); 2055 #endif /* LOG_ENABLED */ 2032 char szStreamSts[DRVAUDIO_STATUS_STR_MAX]; 2033 #endif 2034 Log3Func(("[%s] fStatus=%s\n", pStream->szName, dbgAudioStreamStatusToStr(szStreamSts, pStream->fStatus))); 2056 2035 2057 2036 do … … 3071 3050 3072 3051 #ifdef LOG_ENABLED 3073 char *pszStreamSts = dbgAudioStreamStatusToStr(fStrmStatus); 3074 Log3Func(("[%s] %s\n", pStream->szName, pszStreamSts)); 3075 RTStrFree(pszStreamSts); 3052 char szStreamSts[DRVAUDIO_STATUS_STR_MAX]; 3076 3053 #endif 3054 Log3Func(("[%s] %s\n", pStream->szName, dbgAudioStreamStatusToStr(szStreamSts, fStrmStatus))); 3077 3055 3078 3056 rc2 = RTCritSectLeave(&pThis->CritSect); … … 3397 3375 3398 3376 #ifdef LOG_ENABLED 3399 char *pszStreamSts = dbgAudioStreamStatusToStr(pStream->fStatus); 3400 LogFunc(("[%s] fStatus=%s\n", pStream->szName, pszStreamSts)); 3377 char szStreamSts[DRVAUDIO_STATUS_STR_MAX]; 3401 3378 #endif 3379 LogFunc(("[%s] fStatus=%s\n", pStream->szName, dbgAudioStreamStatusToStr(szStreamSts, pStream->fStatus))); 3402 3380 3403 3381 if (pStream->fStatus & PDMAUDIOSTREAMSTS_FLAGS_INITIALIZED) … … 3413 3391 } 3414 3392 3415 #ifdef LOG_ENABLED3416 RTStrFree(pszStreamSts);3417 #endif3418 3419 3393 LogFlowFunc(("[%s] Returning %Rrc\n", pStream->szName, rc)); 3420 3394 return rc; … … 3452 3426 if (pStream->fStatus != PDMAUDIOSTREAMSTS_FLAGS_NONE) 3453 3427 { 3454 char *pszStreamSts = dbgAudioStreamStatusToStr(pStream->fStatus);3455 LogFunc(("[%s] Warning: Still has %s set when uninitializing\n", pStream->szName, pszStreamSts));3456 RTStrFree(pszStreamSts);3428 char szStreamSts[DRVAUDIO_STATUS_STR_MAX]; 3429 LogFunc(("[%s] Warning: Still has %s set when uninitializing\n", 3430 pStream->szName, dbgAudioStreamStatusToStr(szStreamSts, pStream->fStatus))); 3457 3431 } 3458 3432 #endif
Note:
See TracChangeset
for help on using the changeset viewer.