VirtualBox

Changeset 61089 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 20, 2016 10:05:27 AM (9 years ago)
Author:
vboxsync
Message:

Audio/AudioMixBuffer: Added some more debug code for buffer statistics.

Location:
trunk/src/VBox/Devices/Audio
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Audio/AudioMixBuffer.cpp

    r61007 r61089  
    158158#ifdef DEBUG
    159159static uint64_t s_cSamplesMixedTotal = 0;
    160 static inline void audioMixBufPrint(PPDMAUDIOMIXBUF pMixBuf);
     160static inline void audioMixBufDbgPrint(PPDMAUDIOMIXBUF pMixBuf);
    161161#endif
    162162
     
    872872    if (pMixBuf->pParent) /* Already linked? */
    873873    {
    874         AUDMIXBUF_LOG(("%s: Already linked to \"%s\"\n",
     874        AUDMIXBUF_LOG(("%s: Already linked to parent '%s'\n",
    875875                       pMixBuf->pszName, pMixBuf->pParent->pszName));
    876876        return VERR_ACCESS_DENIED;
     
    10681068#ifdef DEBUG
    10691069    s_cSamplesMixedTotal += cWrittenTotal;
    1070     audioMixBufPrint(pDst);
     1070    AudioMixBufDbgPrint(pDst);
    10711071#endif
    10721072
     
    11401140
    11411141#ifdef DEBUG
     1142static void audioMixBufDbgBufPrintIndentV(uint16_t uIndent, const char *pszFormat, va_list va)
     1143{
     1144    char *pszValueFormat;
     1145    if (RTStrAPrintfV(&pszValueFormat, pszFormat, va))
     1146    {
     1147        AUDMIXBUF_LOG(("%*s%s", uIndent, "", pszValueFormat));
     1148        RTStrFree(pszValueFormat);
     1149    }
     1150}
     1151
     1152static void audioMixBufDbgPrintIndent(uint16_t uIdtLvl, const char *pszFormat, ...)
     1153{
     1154    va_list va;
     1155    va_start(va, pszFormat);
     1156    audioMixBufDbgBufPrintIndentV(uIdtLvl * 4, pszFormat, va);
     1157    va_end(va);
     1158}
     1159
     1160/**
     1161 * Prints a single mixing buffer.
     1162 * Internal helper function for debugging. Do not use directly.
     1163 *
     1164 * @return  IPRT status code.
     1165 * @param   pMixBuf                 Mixing buffer to print.
     1166 * @param   fIsParent               Whether this is a parent buffer or not.
     1167 * @param   uIdtLvl                 Indention level to use.
     1168 */
     1169static void audioMixBufDbgPrintSingle(PPDMAUDIOMIXBUF pMixBuf, bool fIsParent, uint16_t uIdtLvl)
     1170{
     1171    audioMixBufDbgPrintIndent(uIdtLvl,
     1172                           "[%s] %s (%RU32): offReadWrite=%RU32, cProcessed=%RU32, cMixed=%RU32 (BpS=%RU32)\n",
     1173                           fIsParent ? "PARENT" : "CHILD",
     1174                           pMixBuf->pszName, pMixBuf->cSamples,
     1175                           pMixBuf->offReadWrite, pMixBuf->cProcessed, pMixBuf->cMixed,
     1176                           AUDIOMIXBUF_S2B(pMixBuf, 1));
     1177}
     1178
     1179/**
     1180 * Internal helper function for audioMixBufPrintChain().
     1181 * Do not use directly.
     1182 *
     1183 * @return  IPRT status code.
     1184 * @param   pMixBuf                 Mixing buffer to print.
     1185 * @param   uIdtLvl                 Indention level to use.
     1186 * @param   pcChildren              Pointer to children counter.
     1187 */
     1188static void audioMixBufDbgPrintChainHelper(PPDMAUDIOMIXBUF pMixBuf, uint16_t uIdtLvl, size_t *pcChildren)
     1189{
     1190    PPDMAUDIOMIXBUF pIter;
     1191    RTListForEach(&pMixBuf->lstBuffers, pIter, PDMAUDIOMIXBUF, Node)
     1192    {
     1193        audioMixBufDbgPrintSingle(pIter, false /* ifIsParent */, uIdtLvl + 1);
     1194        audioMixBufDbgPrintChainHelper(pIter, uIdtLvl + 1, pcChildren);
     1195    }
     1196}
     1197
     1198/**
     1199 * Prints statistics and status of the full chain of a mixing buffer to the logger,
     1200 * starting from the top root mixing buffer.
     1201 * For debug versions only.
     1202 *
     1203 * @return  IPRT status code.
     1204 * @param   pMixBuf                 Mixing buffer to print.
     1205 */
     1206void AudioMixBufDbgPrintChain(PPDMAUDIOMIXBUF pMixBuf)
     1207{
     1208    PPDMAUDIOMIXBUF pParent = pMixBuf->pParent;
     1209    while (pParent)
     1210    {
     1211        if (!pParent->pParent)
     1212            break;
     1213
     1214        pParent = pParent->pParent;
     1215    }
     1216
     1217    if (!pParent)
     1218        pParent = pMixBuf;
     1219
     1220    AUDMIXBUF_LOG(("********************************************\n"));
     1221
     1222    audioMixBufDbgPrintSingle(pParent, true /* fIsParent */, 0 /* uIdtLvl */);
     1223
     1224    /* Recursively iterate children. */
     1225    size_t cChildren = 0;
     1226    audioMixBufDbgPrintChainHelper(pParent, 0 /* uIdtLvl */, &cChildren);
     1227
     1228    AUDMIXBUF_LOG(("Children: %zu - Total samples mixed: %RU64\n", cChildren, s_cSamplesMixedTotal));
     1229    AUDMIXBUF_LOG(("********************************************\n"));
     1230}
     1231
    11421232/**
    11431233 * Prints statistics and status of a mixing buffer to the logger.
     
    11471237 * @param   pMixBuf                 Mixing buffer to print.
    11481238 */
    1149 static inline void audioMixBufPrint(PPDMAUDIOMIXBUF pMixBuf)
     1239void AudioMixBufDbgPrint(PPDMAUDIOMIXBUF pMixBuf)
    11501240{
    11511241    PPDMAUDIOMIXBUF pParent = pMixBuf;
     
    11541244
    11551245    AUDMIXBUF_LOG(("********************************************\n"));
    1156     AUDMIXBUF_LOG(("[PARENT] %s (%RU32): offReadWrite=%RU32, cProcessed=%RU32, cMixed=%RU32 (BpS=%RU32)\n",
    1157                    pParent->pszName, pParent->cSamples,
    1158                    pParent->offReadWrite, pParent->cProcessed, pParent->cMixed,
    1159                    AUDIOMIXBUF_S2B(pParent, 1)));
    1160 
    1161     size_t cChildren = 0;
     1246
     1247    audioMixBufDbgPrintSingle(pMixBuf, true /* fIsParent */, 0 /* iIdtLevel */);
    11621248
    11631249    PPDMAUDIOMIXBUF pIter;
    11641250    RTListForEach(&pParent->lstBuffers, pIter, PDMAUDIOMIXBUF, Node)
    1165     {
    1166         AUDMIXBUF_LOG(("\t[CHILD] %s (%RU32): offReadWrite=%RU32, cProcessed=%RU32, cMixed=%RU32 (BpS=%RU32)\n",
    1167                        pIter->pszName, pIter->cSamples,
    1168                        pIter->offReadWrite, pIter->cProcessed, pIter->cMixed,
    1169                        AUDIOMIXBUF_S2B(pIter, 1)));
    1170         cChildren++;
    1171     }
    1172     AUDMIXBUF_LOG(("Children: %zu - Total samples mixed: %RU64\n", cChildren, s_cSamplesMixedTotal));
    1173     AUDMIXBUF_LOG(("********************************************\n"));
     1251        audioMixBufDbgPrintSingle(pMixBuf, false /* fIsParent */, 1 /* iIdtLevel */);
    11741252}
    11751253#endif
     
    12551333
    12561334#ifdef DEBUG
    1257         audioMixBufPrint(pMixBuf);
     1335        AudioMixBufDbgPrint(pMixBuf);
    12581336#endif
    12591337    }
     
    13171395    {
    13181396#ifdef DEBUG
    1319         audioMixBufPrint(pMixBuf);
     1397        AudioMixBufDbgPrint(pMixBuf);
    13201398#endif
    13211399        if (pcRead)
     
    14001478
    14011479#ifdef DEBUG
    1402     audioMixBufPrint(pMixBuf);
     1480    AudioMixBufDbgPrint(pMixBuf);
    14031481#endif
    14041482
     
    15971675        cWritten = pConv(pMixBuf->pSamples + offSamples, pvBuf, cbBuf, &convOpts);
    15981676#ifdef DEBUG
    1599         audioMixBufPrint(pMixBuf);
     1677        AudioMixBufDbgPrint(pMixBuf);
    16001678#endif
    16011679        rc = cWritten ? VINF_SUCCESS : VERR_GENERAL_FAILURE; /** @todo Fudge! */
     
    17541832
    17551833#ifdef DEBUG
    1756     audioMixBufPrint(pMixBuf);
     1834    AudioMixBufDbgPrint(pMixBuf);
    17571835#endif
    17581836
  • trunk/src/VBox/Devices/Audio/AudioMixBuffer.h

    r57451 r61089  
    66
    77/*
    8  * Copyright (C) 2014-2015 Oracle Corporation
     8 * Copyright (C) 2014-2016 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    7979int AudioMixBufWriteCircEx(PPDMAUDIOMIXBUF pMixBuf, PDMAUDIOMIXBUFFMT enmFmt, const void *pvBuf, uint32_t cbBuf, uint32_t *pcWritten);
    8080
     81#ifdef DEBUG
     82void AudioMixBufDbgPrint(PPDMAUDIOMIXBUF pMixBuf);
     83void AudioMixBufDbgPrintChain(PPDMAUDIOMIXBUF pMixBuf);
     84#endif
     85
    8186#endif /* AUDIO_MIXBUF_H */
    8287
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette