VirtualBox

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


Ignore:
Timestamp:
Feb 6, 2018 11:00:32 AM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
120707
Message:

Audio/DrvAudio.cpp: More error checking for drvAudioStreamPlayNonInterleaved().

File:
1 edited

Legend:

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

    r70878 r70881  
    13021302        if (cfToPlay)
    13031303        {
    1304             uint8_t auBuf[_4K]; /** @todo Get rid of this here. */
     1304            uint8_t auBuf[256]; /** @todo Get rid of this here. */
    13051305
    13061306            uint32_t cbLeft  = AUDIOMIXBUF_F2B(&pHstStream->MixBuf, cfToPlay);
     
    13111311                uint32_t cfRead = 0;
    13121312                rc = AudioMixBufAcquireReadBlock(&pHstStream->MixBuf, auBuf, RT_MIN(cbChunk, cbLeft), &cfRead);
    1313                 if (   !cfRead
    1314                     || RT_FAILURE(rc))
    1315                 {
     1313                if (RT_FAILURE(rc))
    13161314                    break;
    1317                 }
    13181315
    13191316                uint32_t cbRead = AUDIOMIXBUF_F2B(&pHstStream->MixBuf, cfRead);
    13201317                Assert(cbRead <= cbChunk);
    13211318
     1319                uint32_t cfPlayed = 0;
    13221320                uint32_t cbPlayed = 0;
    13231321                rc = pThis->pHostDrvAudio->pfnStreamPlay(pThis->pHostDrvAudio, pHstStream->pvBackend,
    13241322                                                         auBuf, cbRead, &cbPlayed);
    1325                 if (   RT_FAILURE(rc)
    1326                     || !cbPlayed)
     1323                if (   RT_SUCCESS(rc)
     1324                    && cbPlayed)
    13271325                {
     1326                    if (pThis->Dbg.fEnabled)
     1327                        DrvAudioHlpFileWrite(pHstStream->Out.Dbg.pFilePlayNonInterleaved, auBuf, cbPlayed, 0 /* fFlags */);
     1328
     1329                    if (cbRead != cbPlayed)
     1330                        LogRel2(("Audio: Host stream '%s' played wrong amount (%RU32 bytes read but played %RU32 (%RI32), writable was %RU32)\n",
     1331                                 pHstStream->szName, cbRead, cbPlayed, cbRead - cbPlayed, cbWritable));
     1332
     1333                    cfPlayed       = AUDIOMIXBUF_B2F(&pHstStream->MixBuf, cbPlayed);
     1334                    cfPlayedTotal += cfPlayed;
     1335
     1336                    Assert(cbLeft >= cbPlayed);
     1337                    cbLeft        -= cbPlayed;
     1338                }
     1339
     1340                AudioMixBufReleaseReadBlock(&pHstStream->MixBuf, cfPlayed);
     1341
     1342                if (RT_FAILURE(rc))
    13281343                    break;
    1329                 }
    1330 
    1331                 if (pThis->Dbg.fEnabled)
    1332                     DrvAudioHlpFileWrite(pHstStream->Out.Dbg.pFilePlayNonInterleaved, auBuf, cbPlayed, 0 /* fFlags */);
    1333 
    1334                 AssertMsg(cbPlayed <= cbRead, ("Played more than available (%RU32 available but got %RU32)\n", cbRead, cbPlayed));
    1335 #if 0 /** @todo Also handle mono channels. Needs fixing */
    1336                 AssertMsg(cbPlayed % 2 == 0,
    1337                           ("Backend for stream '%s' returned uneven played bytes count (cfRead=%RU32, cbPlayed=%RU32)\n",
    1338                            pHstStream->szName, cfRead, cbPlayed));*/
    1339 #endif
    1340                 const uint32_t cfPlayed = AUDIOMIXBUF_B2F(&pHstStream->MixBuf, cbPlayed);
    1341 
    1342                 cfPlayedTotal += cfPlayed;
    1343                 Assert(cbLeft >= cbPlayed);
    1344                 cbLeft        -= cbPlayed;
    1345 
    1346                 AudioMixBufReleaseReadBlock(&pHstStream->MixBuf, cfPlayed);
    13471344            }
    13481345        }
Note: See TracChangeset for help on using the changeset viewer.

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