VirtualBox

Changeset 73205 in vbox


Ignore:
Timestamp:
Jul 18, 2018 2:44:55 PM (7 years ago)
Author:
vboxsync
Message:

Audio/SB16: Removed a lot of Doppelmoppel code and added sb16CheckAndReOpenOut() instead.

File:
1 edited

Legend:

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

    r71766 r73205  
    55
    66/*
    7  * Copyright (C) 2015-2017 Oracle Corporation
     7 * Copyright (C) 2015-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    220220*   Internal Functions                                                                                                           *
    221221*********************************************************************************************************************************/
     222static int sb16CheckAndReOpenOut(PSB16STATE pThis);
    222223static int sb16OpenOut(PSB16STATE pThis, PPDMAUDIOSTREAMCFG pCfg);
    223224static void sb16CloseOut(PSB16STATE pThis);
     
    348349static void continue_dma8(PSB16STATE pThis)
    349350{
    350     if (pThis->freq > 0)
    351     {
    352         /* At the moment we only have one stream, the output stream. */
    353         PPDMAUDIOSTREAMCFG pCfg = &pThis->Out.Cfg;
    354 
    355         pCfg->enmDir          = PDMAUDIODIR_OUT;
    356         pCfg->DestSource.Dest = PDMAUDIOPLAYBACKDEST_FRONT;
    357         pCfg->enmLayout       = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED;
    358 
    359         pCfg->Props.uHz       = pThis->freq;
    360         pCfg->Props.cChannels = 1 << pThis->fmt_stereo;
    361         pCfg->Props.cBits     = pThis->fmt_bits;
    362         pCfg->Props.fSigned   = RT_BOOL(pThis->fmt_signed);
    363         pCfg->Props.cShift    = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(pCfg->Props.cBits, pCfg->Props.cChannels);
    364 
    365         strcpy(pCfg->szName, "Output");
    366 
    367         sb16CloseOut(pThis);
    368 
    369         int rc = sb16OpenOut(pThis, pCfg);
    370         AssertRC(rc);
    371     }
    372 
     351    sb16CheckAndReOpenOut(pThis);
    373352    sb16Control(pThis, 1);
    374353}
     
    494473    }
    495474
    496     if (pThis->freq)
    497     {
    498         /* At the moment we only have one stream, the output stream. */
    499         PPDMAUDIOSTREAMCFG pCfg = &pThis->Out.Cfg;
    500 
    501         pCfg->enmDir          = PDMAUDIODIR_OUT;
    502         pCfg->DestSource.Dest = PDMAUDIOPLAYBACKDEST_FRONT;
    503         pCfg->enmLayout       = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED;
    504 
    505         pCfg->Props.uHz       = pThis->freq;
    506         pCfg->Props.cChannels = 1 << pThis->fmt_stereo;
    507         pCfg->Props.cBits     = pThis->fmt_bits;
    508         pCfg->Props.fSigned   = RT_BOOL(pThis->fmt_signed);
    509         pCfg->Props.cShift    = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(pCfg->Props.cBits, pCfg->Props.cChannels);
    510 
    511         strcpy(pCfg->szName, "Output");
    512 
    513         sb16CloseOut(pThis);
    514 
    515         int rc = sb16OpenOut(pThis, pCfg);
    516         AssertRC(rc);
    517     }
    518 
     475    sb16CheckAndReOpenOut(pThis);
    519476    sb16Control(pThis, 1);
    520477    sb16SpeakerControl(pThis, 1);
     
    10641021{
    10651022    LogFlowFuncEnter();
    1066 
    1067     sb16CloseOut(pThis);
    10681023
    10691024    pThis->freq       = 11025;
     
    20121967    AssertRCReturn(rc, rc);
    20131968
    2014 #if 0
    2015     PSB16DRIVER pDrv;
    2016     RTListForEach(&pThis->lstDrv, pDrv, SB16DRIVER, Node)
    2017     {
    2018         if (pDrv->Out.pStream)
    2019         {
    2020             pDrv->pConnector->pfnCloseOut(pThis->pDrv, pDrv->Out.pStream);
    2021             pDrv->Out.pStream = NULL;
    2022         }
    2023     }
    2024 #endif
    2025 
    20261969    if (pThis->dma_running)
    20271970    {
    2028         if (pThis->freq)
    2029         {
    2030             /* At the moment we only have one stream, the output stream. */
    2031             PPDMAUDIOSTREAMCFG pCfg = &pThis->Out.Cfg;
    2032 
    2033             pCfg->enmDir          = PDMAUDIODIR_OUT;
    2034             pCfg->DestSource.Dest = PDMAUDIOPLAYBACKDEST_FRONT;
    2035             pCfg->enmLayout       = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED;
    2036 
    2037             pCfg->Props.uHz       = pThis->freq;
    2038             pCfg->Props.cChannels = 1 << pThis->fmt_stereo;
    2039             pCfg->Props.cBits     = pThis->fmt_bits;
    2040             pCfg->Props.fSigned   = RT_BOOL(pThis->fmt_signed);
    2041             pCfg->Props.cShift    = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(pCfg->Props.cBits, pCfg->Props.cChannels);
    2042 
    2043             strcpy(pCfg->szName, "Output");
    2044 
    2045             sb16CloseOut(pThis);
    2046 
    2047             rc = sb16OpenOut(pThis, pCfg);
    2048             AssertRC(rc);
    2049         }
    2050 
     1971        sb16CheckAndReOpenOut(pThis);
    20511972        sb16Control(pThis, 1);
    20521973        sb16SpeakerControl(pThis, pThis->speaker);
     
    21652086}
    21662087
     2088/**
     2089 * Checks if the output stream needs to be (re-)created and does so if needed.
     2090 *
     2091 * @return VBox status code.
     2092 * @param  pThis                SB16 state.
     2093 */
     2094static int sb16CheckAndReOpenOut(PSB16STATE pThis)
     2095{
     2096    AssertPtrReturn(pThis, VERR_INVALID_POINTER);
     2097
     2098    int rc = VINF_SUCCESS;
     2099
     2100    if (pThis->freq > 0)
     2101    {
     2102        /* At the moment we only have one stream, the output stream. */
     2103        PDMAUDIOSTREAMCFG Cfg;
     2104        RT_ZERO(Cfg);
     2105
     2106        Cfg.Props.uHz       = pThis->freq;
     2107        Cfg.Props.cChannels = 1 << pThis->fmt_stereo;
     2108        Cfg.Props.cBits     = pThis->fmt_bits;
     2109        Cfg.Props.fSigned   = RT_BOOL(pThis->fmt_signed);
     2110        Cfg.Props.cShift    = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(Cfg.Props.cBits, Cfg.Props.cChannels);
     2111
     2112        if (!DrvAudioHlpPCMPropsAreEqual(&Cfg.Props, &pThis->Out.Cfg.Props))
     2113        {
     2114            Cfg.enmDir          = PDMAUDIODIR_OUT;
     2115            Cfg.DestSource.Dest = PDMAUDIOPLAYBACKDEST_FRONT;
     2116            Cfg.enmLayout       = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED;
     2117
     2118            strcpy(Cfg.szName, "Output");
     2119
     2120            sb16CloseOut(pThis);
     2121
     2122            rc = sb16OpenOut(pThis, &Cfg);
     2123            AssertRC(rc);
     2124        }
     2125    }
     2126    else
     2127        sb16CloseOut(pThis);
     2128
     2129    LogFlowFuncLeaveRC(rc);
     2130    return rc;
     2131}
     2132
    21672133static int sb16OpenOut(PSB16STATE pThis, PPDMAUDIOSTREAMCFG pCfg)
    21682134{
     
    21752141        return VERR_INVALID_PARAMETER;
    21762142
    2177     int rc = VINF_SUCCESS;
     2143    int rc = DrvAudioHlpStreamCfgCopy(&pThis->Out.Cfg, pCfg);
     2144    if (RT_FAILURE(rc))
     2145        return rc;
    21782146
    21792147    PSB16DRIVER pDrv;
    21802148    RTListForEach(&pThis->lstDrv, pDrv, SB16DRIVER, Node)
    21812149    {
    2182         int rc2 = sb16CreateDrvStream(pThis, pCfg, pDrv);
     2150        int rc2 = sb16CreateDrvStream(pThis, &pThis->Out.Cfg, pDrv);
    21832151        if (RT_FAILURE(rc2))
    21842152            LogFunc(("Attaching stream failed with %Rrc\n", rc2));
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