VirtualBox

Changeset 89443 in vbox for trunk


Ignore:
Timestamp:
Jun 1, 2021 8:42:04 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
144797
Message:

DrvHostAudioOss: Only mono and stereo for now. Fend off draining calls to pfnStreamPlay (w/ cbBuf=0) to avoid assertion. bugref:9890

File:
1 edited

Legend:

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

    r89258 r89443  
    376376        /*
    377377         * Configure it.
     378         *
     379         * Note! We limit the output channels to mono or stereo for now just
     380         *       to keep things simple and avoid wasting time here.  If the
     381         *       channel count isn't a power of two, our code below trips up
     382         *       on the fragment size.  We'd also need to try report/get
     383         *       channel mappings and whatnot.
    378384         */
    379385        OSSAUDIOSTREAMCFG ReqOssCfg;
     
    381387
    382388        memcpy(&ReqOssCfg.Props, &pCfgReq->Props, sizeof(PDMAUDIOPCMPROPS));
     389        if (PDMAudioPropsChannels(&ReqOssCfg.Props) > 2)
     390        {
     391            LogRel2(("OSS: Limiting output to two channels, requested %u.\n", PDMAudioPropsChannels(&ReqOssCfg.Props) ));
     392            PDMAudioPropsSetChannels(&ReqOssCfg.Props, 2);
     393        }
     394
    383395        ReqOssCfg.cbFragmentLog2 = 12;
    384396        ReqOssCfg.cbFragment     = RT_BIT_32(ReqOssCfg.cbFragmentLog2);
    385         uint32_t const cbBuffer  = PDMAudioPropsFramesToBytes(&pCfgReq->Props, pCfgReq->Backend.cFramesBufferSize);
     397        uint32_t const cbBuffer  = PDMAudioPropsFramesToBytes(&ReqOssCfg.Props, pCfgReq->Backend.cFramesBufferSize);
    386398        ReqOssCfg.cFragments     = cbBuffer >> ReqOssCfg.cbFragmentLog2;
    387399        AssertLogRelStmt(cbBuffer < ((uint32_t)0x7ffe << ReqOssCfg.cbFragmentLog2), ReqOssCfg.cFragments = 0x7ffe);
     
    744756
    745757    /*
     758     * Return immediately if this is a draining service call.
     759     *
     760     * Otherwise the ioctl below will race the drain thread and sometimes fail,
     761     * triggering annoying assertion and release logging.
     762     */
     763    if (cbBuf || !pStreamOSS->fDraining)
     764    { /* likely */ }
     765    else
     766    {
     767        *pcbWritten = 0;
     768        return VINF_SUCCESS;
     769    }
     770
     771    /*
    746772     * Figure out now much to write.
    747773     */
    748774    audio_buf_info BufInfo;
    749775    int rc2 = ioctl(pStreamOSS->hFile, SNDCTL_DSP_GETOSPACE, &BufInfo);
    750     AssertLogRelMsgReturn(rc2 >= 0, ("OSS: Failed to retrieve current playback buffer: %s (%d)\n", strerror(errno), errno),
     776    AssertLogRelMsgReturn(rc2 >= 0, ("OSS: Failed to retrieve current playback buffer: %s (%d, hFile=%d, rc2=%d)\n",
     777                                     strerror(errno), errno, pStreamOSS->hFile, rc2),
    751778                          RTErrConvertFromErrno(errno));
    752779
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