VirtualBox

Changeset 61399 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Jun 2, 2016 8:54:51 AM (9 years ago)
Author:
vboxsync
Message:

Audio/DevIchAc97.cpp: Saved state fixes.

File:
1 edited

Legend:

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

    r61386 r61399  
    302302typedef struct AC97INPUTSTREAM
    303303{
    304     /** PCM line input stream. */
    305     R3PTRTYPE(PPDMAUDIOSTREAM)    pStream;
    306     /** Mixer handle for line input stream. */
    307     R3PTRTYPE(PAUDMIXSTREAM)      pMixStrm;
     304    /** Mixer handle for input stream. */
     305    R3PTRTYPE(PAUDMIXSTREAM) pMixStrm;
    308306} AC97INPUTSTREAM, *PAC97INPUTSTREAM;
    309307
    310308typedef struct AC97OUTPUTSTREAM
    311309{
    312     /** PCM output stream. */
    313     R3PTRTYPE(PPDMAUDIOSTREAM)     pStream;
    314310    /** Mixer handle for output stream. */
    315     R3PTRTYPE(PAUDMIXSTREAM)       pMixStrm;
     311    R3PTRTYPE(PAUDMIXSTREAM) pMixStrm;
    316312} AC97OUTPUTSTREAM, *PAC97OUTPUTSTREAM;
    317313
     
    531527}
    532528
     529static bool ichac97StreamIsActive(PAC97STATE pThis, PAC97STREAM pStream)
     530{
     531    AssertPtrReturn(pThis,   VERR_INVALID_POINTER);
     532    AssertPtrReturn(pStream, VERR_INVALID_POINTER);
     533
     534    bool fActive = AudioMixerSinkHasData(ichac97IndexToSink(pThis, pStream->u8Strm));
     535
     536    LogFlowFunc(("SD=%RU8, fActive=%RTbool\n", pStream->u8Strm, fActive));
     537    return fActive;
     538}
     539
    533540static int ichac97StreamSetActive(PAC97STATE pThis, PAC97STREAM pStream, bool fActive)
    534541{
     
    12461253        uint32_t cbToWrite = RT_MIN(cbElapsed, (uint32_t)sizeof(pThis->silence));
    12471254        uint32_t cbWrittenToStream;
    1248         int rc2;
    1249 
    1250         PAC97DRIVER pDrv;
    1251         RTListForEach(&pThis->lstDrv, pDrv, AC97DRIVER, Node)
    1252         {
    1253             if (pDrv->pConnector->pfnStreamGetStatus(pDrv->pConnector, pDrv->Out.pStream) == PDMAUDIOSTRMSTS_FLAG_ENABLED)
    1254             {
    1255                 rc2 = pDrv->pConnector->pfnStreamWrite(pDrv->pConnector, pDrv->Out.pStream,
    1256                                                        pThis->silence, cbToWrite, &cbWrittenToStream);
    1257                 if (RT_SUCCESS(rc2))
    1258                 {
    1259                     if (cbWrittenToStream < cbToWrite) /* Lagging behind? */
    1260                         LogFlowFunc(("\tLUN#%RU8: Warning: Only written %RU32 / %RU32 bytes, expect lags\n",
    1261                                      pDrv->uLUN, cbWrittenToStream, cbToWrite));
    1262                 }
    1263             }
    1264             else /* Stream disabled, not fatal. */
    1265             {
    1266                 cbWrittenToStream = 0;
    1267                 rc2 = VERR_NOT_AVAILABLE;
    1268                 /* Keep going. */
    1269             }
     1255
     1256        int rc2 = AudioMixerSinkWrite(pThis->pSinkOutput, AUDMIXOP_COPY,
     1257                                      pThis->silence, cbToWrite, &cbWrittenToStream);
     1258        if (RT_SUCCESS(rc2))
     1259        {
     1260            if (cbWrittenToStream < cbToWrite) /* Lagging behind? */
     1261                LogFlowFunc(("Warning: Only written %RU32 / %RU32 bytes, expect lags\n", cbWrittenToStream, cbToWrite));
    12701262        }
    12711263
     
    20892081    PAC97STATE pThis = PDMINS_2_DATA(pDevIns, PAC97STATE);
    20902082
     2083    LogFlowFuncEnter();
     2084
    20912085    SSMR3PutU32(pSSM, pThis->glob_cnt);
    20922086    SSMR3PutU32(pSSM, pThis->glob_sta);
     
    21062100    uint8_t active[LAST_INDEX];
    21072101
    2108     PAC97DRIVER pDrv;
    2109     RTListForEach(&pThis->lstDrv, pDrv, AC97DRIVER, Node)
    2110     {
    2111         PPDMIAUDIOCONNECTOR pCon = pDrv->pConnector;
    2112         AssertPtr(pCon);
    2113         active[PI_INDEX] = (pCon->pfnStreamGetStatus(pCon, pDrv->LineIn.pStream) & PDMAUDIOSTRMSTS_FLAG_ENABLED) ? 1 : 0;
    2114         active[PO_INDEX] = (pCon->pfnStreamGetStatus(pCon, pDrv->Out.pStream)   & PDMAUDIOSTRMSTS_FLAG_ENABLED) ? 1 : 0;
    2115         active[MC_INDEX] = (pCon->pfnStreamGetStatus(pCon, pDrv->MicIn.pStream)  & PDMAUDIOSTRMSTS_FLAG_ENABLED) ? 1 : 0;
    2116     }
     2102    active[PI_INDEX] = ichac97StreamIsActive(pThis, &pThis->StreamLineIn) ? 1 : 0;
     2103    active[PO_INDEX] = ichac97StreamIsActive(pThis, &pThis->StreamOut)    ? 1 : 0;
     2104    active[MC_INDEX] = ichac97StreamIsActive(pThis, &pThis->StreamMicIn)  ? 1 : 0;
    21172105
    21182106    SSMR3PutMem(pSSM, active, sizeof(active));
    21192107
     2108    LogFlowFuncLeaveRC(VINF_SUCCESS);
    21202109    return VINF_SUCCESS;
    21212110}
     
    21462135    PAC97STATE pThis = PDMINS_2_DATA(pDevIns, PAC97STATE);
    21472136
     2137    LogRel2(("ichac97LoadExec: uVersion=%RU32, uPass=0x%x\n", uVersion, uPass));
     2138
    21482139    AssertMsgReturn (uVersion == AC97_SSM_VERSION, ("%RU32\n", uVersion), VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION);
    21492140    Assert(uPass == SSM_PASS_FINAL); NOREF(uPass);
     
    21802171
    21812172    int rc = ichac97StreamsInit(pThis);
    2182     AssertRC(rc);
    2183 
    2184     /** @todo r=andy Stream IDs are hardcoded to certain streams. */
    2185     rc = ichac97StreamSetActive(pThis, &pThis->StreamLineIn, RT_BOOL(uaStrmsActive[PI_INDEX]));
    2186     AssertRC(rc);
    2187     rc = ichac97StreamSetActive(pThis, &pThis->StreamMicIn, RT_BOOL(uaStrmsActive[MC_INDEX]));
    2188     AssertRC(rc);
    2189     rc = ichac97StreamSetActive(pThis, &pThis->StreamOut,    RT_BOOL(uaStrmsActive[PO_INDEX]));
    2190     AssertRC(rc);
    2191 
    2192     pThis->bup_flag = 0;
     2173    if (RT_SUCCESS(rc))
     2174    {
     2175        /** @todo r=andy Stream IDs are hardcoded to certain streams. */
     2176        rc = ichac97StreamSetActive(pThis, &pThis->StreamLineIn,    RT_BOOL(uaStrmsActive[PI_INDEX]));
     2177        if (RT_SUCCESS(rc))
     2178            rc = ichac97StreamSetActive(pThis, &pThis->StreamMicIn, RT_BOOL(uaStrmsActive[MC_INDEX]));
     2179        if (RT_SUCCESS(rc))
     2180            rc = ichac97StreamSetActive(pThis, &pThis->StreamOut,   RT_BOOL(uaStrmsActive[PO_INDEX]));
     2181    }
     2182
     2183    pThis->bup_flag  = 0;
    21932184    pThis->last_samp = 0;
    21942185
    2195     return VINF_SUCCESS;
     2186    LogFlowFuncLeaveRC(rc);
     2187    return rc;
    21962188}
    21972189
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