VirtualBox

Changeset 56644 in vbox


Ignore:
Timestamp:
Jun 25, 2015 8:35:23 PM (9 years ago)
Author:
vboxsync
Message:

Audio/ALSA: Fix possible endless loop if the mixer buffer is already full and the ALSA capture device keeps producing samples (null capture device). Check how much we can write to the mixer buffer upfront to avoid loosing any samples

File:
1 edited

Legend:

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

    r56622 r56644  
    825825    }
    826826
     827    /*
     828     * Check how much we can read from the capture device without overflowing
     829     * the mixer buffer.
     830     */
    827831    Assert(cAvail);
    828     size_t cbToRead = AUDIOMIXBUF_S2B(&pHstStrmIn->MixBuf, cAvail);
     832    size_t cbToRead = RT_MIN(AUDIOMIXBUF_S2B(&pHstStrmIn->MixBuf, cAvail),
     833                             AudioMixBufFreeBytes(&pHstStrmIn->MixBuf));
    829834
    830835    LogFlowFunc(("cbToRead=%zu, cAvail=%RI32\n", cbToRead, cAvail));
     
    886891                break;
    887892
     893            /*
     894             * We should not run into a full mixer buffer or we loose samples and
     895             * run into an endless loop if ALSA keeps producing samples ("null"
     896             * capture device for example).
     897             */
     898            AssertLogRelMsgBreakStmt(cWritten > 0, ("Mixer buffer shouldn't be full at this point!\n"),
     899                                     rc = VERR_INTERNAL_ERROR);
    888900            uint32_t cbWritten = AUDIOMIXBUF_S2B(&pHstStrmIn->MixBuf, cWritten);
    889901
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