VirtualBox

Changeset 89992 in vbox for trunk/src/VBox/Devices/Audio


Ignore:
Timestamp:
Jul 2, 2021 8:56:55 AM (4 years ago)
Author:
vboxsync
Message:

Audio/ValKit: More testing code fixes and additions. bugref:10008

File:
1 edited

Legend:

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

    r89962 r89992  
    719719                                                         const void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten)
    720720{
    721     RT_NOREF(pStream);
    722 
    723721    if (cbBuf == 0)
    724722    {
     
    730728    PDRVHOSTVALKITAUDIO pThis = RT_FROM_MEMBER(pInterface, DRVHOSTVALKITAUDIO, IHostAudio);
    731729
    732     PVALKITTESTDATA pTst = NULL;
     730    bool const fIsSilence = PDMAudioPropsIsBufferSilence(&pStream->pStream->Cfg.Props, pvBuf, cbBuf);
    733731
    734732    int rc = RTCritSectEnter(&pThis->CritSect);
     
    736734    {
    737735        if (pThis->pTestCur == NULL)
     736        {
    738737            pThis->pTestCur = RTListGetFirst(&pThis->lstTestsPlay, VALKITTESTDATA, Node);
    739 
    740         pTst = pThis->pTestCur;
     738            if (pThis->pTestCur)
     739                LogRel(("ValKit: Next guest playback test in queue is test #%RU32\n", pThis->pTestCur->idxTest));
     740        }
    741741
    742742        int rc2 = RTCritSectLeave(&pThis->CritSect);
     
    744744    }
    745745
    746     if (pTst == NULL) /* Empty list? */
    747     {
    748         LogRel(("ValKit: Warning: Guest is playing back data when no playback test is active\n"));
     746    if (pThis->pTestCur == NULL) /* Empty list? */
     747    {
     748#ifdef DEBUG_andy
     749        if (!fIsSilence)
     750#endif
     751            LogRel(("ValKit: Warning: Guest is playing back audio (%s, %RU32 bytes, %RU64ms) when no playback test is active\n",
     752                    fIsSilence ? "silence" : "audible", cbBuf, PDMAudioPropsBytesToMilli(&pStream->pStream->Cfg.Props, cbBuf)));
    749753
    750754        *pcbWritten = cbBuf;
     
    752756    }
    753757
    754 #if 1
    755     if (PDMAudioPropsIsBufferSilence(&pStream->pStream->Cfg.Props, pvBuf, cbBuf))
    756     {
    757         LogRel(("ValKit: Skipping %RU32 bytes of silence\n", cbBuf));
    758 
    759         *pcbWritten = cbBuf;
    760         return VINF_SUCCESS;
    761     }
     758#ifndef DEBUG_andy
     759    if (fIsSilence)
     760        LogRel2(("ValKit: Guest is playing back %RU32 bytes (%RU64ms) silence\n",
     761                 cbBuf, PDMAudioPropsBytesToMilli(&pStream->pStream->Cfg.Props, cbBuf)));
    762762#endif
    763763
    764     if (pTst->t.TestTone.u.Play.cbRead == 0)
     764    PVALKITTESTDATA pTst = pThis->pTestCur;
     765
     766    const bool fHandleSilence = false; /** @todo Skip blocks of entire silence for now. */
     767
     768    if (pTst->pEntry == NULL)
    765769    {
    766770        AUDIOTESTPARMS Parms;
     
    770774        Parms.TestTone = pTst->t.TestTone.Parms;
    771775
    772         Assert(pTst->pEntry == NULL);
    773776        rc = AudioTestSetTestBegin(&pThis->Set, "Recording audio data from guest",
    774777                                    &Parms, &pTst->pEntry);
     
    788791    if (RT_SUCCESS(rc))
    789792    {
    790         rc = AudioTestSetObjWrite(pTst->pObj, pvBuf, cbBuf);
    791         if (RT_SUCCESS(rc))
    792         {
     793        if (   !fIsSilence
     794            || (fIsSilence && fHandleSilence))
     795        {
     796            rc = AudioTestSetObjWrite(pTst->pObj, pvBuf, cbBuf);
    793797            pTst->t.TestTone.u.Play.cbRead += cbBuf;
    794798
    795         #if 0
    796799            const bool fComplete = pTst->t.TestTone.u.Play.cbRead >= pTst->t.TestTone.u.Play.cbToRead;
    797800            if (fComplete)
     
    804807                            pTst->idxTest, pTst->t.TestTone.u.Play.cbRead - pTst->t.TestTone.u.Play.cbToRead));
    805808
     809                AudioTestSetTestDone(pTst->pEntry);
     810
    806811                rc = RTCritSectEnter(&pThis->CritSect);
    807812                if (RT_SUCCESS(rc))
    808813                {
    809                     AudioTestSetTestDone(pTst->pEntry);
     814                    drvHostValKiUnregisterPlayTest(pThis, pTst);
    810815
    811816                    pThis->pTestCur = NULL;
    812817                    pTst            = NULL;
    813 
    814                     if (pThis->fTestSetEnded)
    815                         rc = RTSemEventSignal(pThis->EventSemEnded);
    816818
    817819                    int rc2 = RTCritSectLeave(&pThis->CritSect);
     
    820822                }
    821823            }
    822         #endif
    823 
    824             cbWritten = cbBuf;
    825         }
     824        }
     825
     826        /* Always report everything as being played. */
     827        cbWritten = cbBuf;
    826828    }
    827829
     
    848850    RT_NOREF(pStream);
    849851
     852    if (cbBuf == 0)
     853    {
     854        /* Fend off draining calls. */
     855        *pcbRead = 0;
     856        return VINF_SUCCESS;
     857    }
     858
    850859    PDRVHOSTVALKITAUDIO pThis = RT_FROM_MEMBER(pInterface, DRVHOSTVALKITAUDIO, IHostAudio);
    851860
     
    854863    {
    855864        if (pThis->pTestCur == NULL)
     865        {
    856866            pThis->pTestCur = RTListGetFirst(&pThis->lstTestsRec, VALKITTESTDATA, Node);
     867            if (pThis->pTestCur)
     868                LogRel(("ValKit: Next guest recording test in queue is test #%RU32\n", pThis->pTestCur->idxTest));
     869        }
    857870
    858871        int rc2 = RTCritSectLeave(&pThis->CritSect);
     
    862875    if (pThis->pTestCur == NULL) /* Empty list? */
    863876    {
    864         LogRelMax(64, ("ValKit: Warning: Guest is recording audio data when no recording test is active\n"));
     877        LogRelMax(64, ("ValKit: Warning: Guest is trying to record audio data when no recording test is active\n"));
    865878
    866879        *pcbRead = 0;
     
    870883    PVALKITTESTDATA pTst = pThis->pTestCur;
    871884
    872     if (pTst->t.TestTone.u.Rec.cbWritten == 0)
     885    if (pTst->pEntry == NULL)
    873886    {
    874887        AUDIOTESTPARMS Parms;
     
    878891        Parms.TestTone = pTst->t.TestTone.Parms;
    879892
    880         Assert(pTst->pEntry == NULL);
    881893        rc = AudioTestSetTestBegin(&pThis->Set, "Injecting audio input data to guest",
    882894                                    &Parms, &pTst->pEntry);
     
    909921                Assert(pTst->t.TestTone.u.Rec.cbWritten <= pTst->t.TestTone.u.Rec.cbToWrite);
    910922
    911                 const bool fComplete = pTst->t.TestTone.u.Rec.cbToWrite == pTst->t.TestTone.u.Rec.cbWritten;
    912 
     923                const bool fComplete = pTst->t.TestTone.u.Rec.cbToWrite >= pTst->t.TestTone.u.Rec.cbWritten;
    913924                if (fComplete)
    914925                {
    915926                    LogRel(("ValKit: Injecting audio input data done (took %RU32ms)\n",
    916927                            RTTimeMilliTS() - pTst->msStartedTS));
     928
     929                    AudioTestSetTestDone(pTst->pEntry);
    917930
    918931                    rc = RTCritSectEnter(&pThis->CritSect);
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