VirtualBox

Changeset 89517 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jun 4, 2021 10:31:57 PM (4 years ago)
Author:
vboxsync
Message:

DrvHostAudioOss: Use BufInfo.bytes for drvHstAudOssHA_StreamGetWritable and drvHstAudOssHA_StreamPlay too, it seems to work fine here on Linux. bugref:9890

File:
1 edited

Legend:

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

    r89516 r89517  
    696696    AssertMsgReturn(rc2 >= 0, ("SNDCTL_DSP_GETOSPACE failed: %s (%d)\n", strerror(errno), errno), 0);
    697697
    698 #if 0 /** @todo we could return BufInfo.bytes here iff StreamPlay didn't use the fragmented approach */
    699     /** @todo r=bird: WTF do we make a fuss over BufInfo.bytes for when we don't
    700      *        even use it?!? */
    701     AssertLogRelMsgReturn(BufInfo.bytes >= 0, ("OSS: Warning: Invalid available size: %d\n", BufInfo.bytes), VERR_INTERNAL_ERROR_3);
    702     if ((unsigned)BufInfo.bytes > cbBuf)
    703     {
    704         LogRel2(("OSS: Warning: Too big output size (%d > %RU32), limiting to %RU32\n", BufInfo.bytes, cbBuf, cbBuf));
    705         BufInfo.bytes = cbBuf;
    706         /* Keep going. */
    707     }
    708 #endif
    709 
    710     uint32_t cbRet = (uint32_t)(BufInfo.fragments * BufInfo.fragsize);
    711     Log4Func(("returns %#x (%u)\n", cbRet, cbRet));
     698    /* Try use the size. */
     699    uint32_t        cbRet;
     700    uint32_t const  cbBuf = pStreamOSS->OssCfg.cbFragment * pStreamOSS->OssCfg.cFragments;
     701    if (BufInfo.bytes >= 0 && (unsigned)BufInfo.bytes <= cbBuf)
     702        cbRet = BufInfo.bytes;
     703    else
     704    {
     705        AssertMsgFailed(("Invalid available size: %d\n", BufInfo.bytes));
     706        AssertMsgReturn(BufInfo.fragments >= 0, ("fragments: %d\n", BufInfo.fragments), 0);
     707        AssertMsgReturn(BufInfo.fragsize >= 0, ("fragsize: %d\n", BufInfo.fragsize), 0);
     708        cbRet = (uint32_t)(BufInfo.fragments * BufInfo.fragsize);
     709        AssertMsgStmt(cbRet <= cbBuf, ("fragsize*fragments: %d, cbBuf=%#x\n", cbRet, cbBuf), 0);
     710    }
     711
     712    Log4Func(("returns %#x (%u) [cbBuf=%#x]\n", cbRet, cbRet, cbBuf));
    712713    return cbRet;
    713714}
     
    739740
    740741    /*
    741      * Figure out now much to write.
     742     * Figure out now much to write (same as drvHstAudOssHA_StreamGetWritable).
    742743     */
    743744    audio_buf_info BufInfo;
     
    747748                          RTErrConvertFromErrno(errno));
    748749
    749 #if 0   /** @todo r=bird: WTF do we make a fuss over BufInfo.bytes for when we don't even use it?!? */
    750     AssertLogRelMsgReturn(BufInfo.bytes >= 0, ("OSS: Warning: Invalid available size: %d\n", BufInfo.bytes), VERR_INTERNAL_ERROR_3);
    751     if ((unsigned)BufInfo.bytes > cbBuf)
    752     {
    753         LogRel2(("OSS: Warning: Too big output size (%d > %RU32), limiting to %RU32\n", BufInfo.bytes, cbBuf, cbBuf));
    754         BufInfo.bytes = cbBuf;
    755         /* Keep going. */
    756     }
    757 #endif
    758     uint32_t cbToWrite = (uint32_t)(BufInfo.fragments * BufInfo.fragsize);
     750    uint32_t        cbToWrite;
     751    uint32_t const  cbStreamBuf = pStreamOSS->OssCfg.cbFragment * pStreamOSS->OssCfg.cFragments;
     752    if (BufInfo.bytes >= 0 && (unsigned)BufInfo.bytes <= cbStreamBuf)
     753        cbToWrite = BufInfo.bytes;
     754    else
     755    {
     756        AssertMsgFailed(("Invalid available size: %d\n", BufInfo.bytes));
     757        AssertMsgReturn(BufInfo.fragments >= 0, ("fragments: %d\n", BufInfo.fragments), 0);
     758        AssertMsgReturn(BufInfo.fragsize >= 0, ("fragsize: %d\n", BufInfo.fragsize), 0);
     759        cbToWrite = (uint32_t)(BufInfo.fragments * BufInfo.fragsize);
     760        AssertMsgStmt(cbToWrite <= cbStreamBuf, ("fragsize*fragments: %d, cbStreamBuf=%#x\n", cbToWrite, cbStreamBuf), 0);
     761    }
     762
    759763    cbToWrite = RT_MIN(cbToWrite, cbBuf);
    760764    Log3Func(("@%#RX64 cbBuf=%#x BufInfo: fragments=%#x fragstotal=%#x fragsize=%#x bytes=%#x %s cbToWrite=%#x\n",
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