VirtualBox

Ignore:
Timestamp:
Nov 27, 2019 9:31:53 PM (5 years ago)
Author:
vboxsync
Message:

vmm/pdmaudioifs.h: Style, docs and other nits. First, it's always _FLAGS_ never _FLAG_. Second, enums generally should start with _INVALID = 0 to ensure we don't mistake zero-initialized memory for valid data. Struct member names shall be indented on a tab (+4) boundrary. PDM is part of the VMM, so it follows the VMM coding guidelines strictly. Skip the 'Structure for keeping a ... around' fluff, the first sentence of a structure (or anything else for that matter) documentation shall be brief and to the point. It is automatically turned into a @brief. Furthermore, additional text should be a separate paragraph as it provides details the reader doesn't necessarily need to read. bugref:9218

File:
1 edited

Legend:

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

    r81182 r82252  
    31273127int hdaCodecLoadState(PHDACODEC pThis, PSSMHANDLE pSSM, uint32_t uVersion)
    31283128{
    3129     int rc = VINF_SUCCESS;
    3130 
    31313129    PCSSMFIELD pFields = NULL;
    31323130    uint32_t   fFlags  = 0;
     
    31543152            int rc2 = SSMR3GetU32(pSSM, &cNodes);
    31553153            AssertRCReturn(rc2, rc2);
    3156             if (cNodes != 0x1c)
    3157                 return VERR_SSM_DATA_UNIT_FORMAT_CHANGED;
     3154            AssertReturn(cNodes == 0x1c, VERR_SSM_DATA_UNIT_FORMAT_CHANGED);
    31583155            AssertReturn(pThis->cTotalNodes == 0x1c, VERR_INTERNAL_ERROR);
    31593156
     
    31643161
    31653162        default:
    3166             rc = VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
    3167             break;
    3168     }
    3169 
    3170     if (RT_SUCCESS(rc))
    3171     {
    3172         for (unsigned idxNode = 0; idxNode < pThis->cTotalNodes; ++idxNode)
    3173         {
    3174             uint8_t idOld = pThis->paNodes[idxNode].SavedState.Core.uID;
    3175             int rc2 = SSMR3GetStructEx(pSSM, &pThis->paNodes[idxNode].SavedState,
    3176                                        sizeof(pThis->paNodes[idxNode].SavedState),
    3177                                        fFlags, pFields, NULL);
    3178             if (RT_SUCCESS(rc))
    3179                 rc = rc2;
    3180 
    3181             if (RT_FAILURE(rc))
    3182                 break;
    3183 
    3184             AssertLogRelMsgReturn(idOld == pThis->paNodes[idxNode].SavedState.Core.uID,
    3185                                   ("loaded %#x, expected %#x\n", pThis->paNodes[idxNode].SavedState.Core.uID, idOld),
    3186                                   VERR_SSM_DATA_UNIT_FORMAT_CHANGED);
    3187         }
    3188 
    3189         if (RT_SUCCESS(rc))
    3190         {
    3191             /*
    3192              * Update stuff after changing the state.
    3193              */
    3194             PCODECNODE pNode;
    3195             if (hdaCodecIsDacNode(pThis, pThis->u8DacLineOut))
    3196             {
    3197                 pNode = &pThis->paNodes[pThis->u8DacLineOut];
    3198                 hdaCodecToAudVolume(pThis, pNode, &pNode->dac.B_params, PDMAUDIOMIXERCTL_FRONT);
    3199             }
    3200             else if (hdaCodecIsSpdifOutNode(pThis, pThis->u8DacLineOut))
    3201             {
    3202                 pNode = &pThis->paNodes[pThis->u8DacLineOut];
    3203                 hdaCodecToAudVolume(pThis, pNode, &pNode->spdifout.B_params, PDMAUDIOMIXERCTL_FRONT);
    3204             }
    3205 
    3206             pNode = &pThis->paNodes[pThis->u8AdcVolsLineIn];
    3207             hdaCodecToAudVolume(pThis, pNode, &pNode->adcvol.B_params, PDMAUDIOMIXERCTL_LINE_IN);
    3208         }
    3209     }
    3210 
    3211     LogFlowFuncLeaveRC(rc);
    3212     return rc;
     3163            AssertFailedReturn(VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION);
     3164    }
     3165
     3166    for (unsigned idxNode = 0; idxNode < pThis->cTotalNodes; ++idxNode)
     3167    {
     3168        uint8_t idOld = pThis->paNodes[idxNode].SavedState.Core.uID;
     3169        int rc = SSMR3GetStructEx(pSSM, &pThis->paNodes[idxNode].SavedState,
     3170                                  sizeof(pThis->paNodes[idxNode].SavedState),
     3171                                  fFlags, pFields, NULL);
     3172        AssertRCReturn(rc, rc);
     3173        AssertLogRelMsgReturn(idOld == pThis->paNodes[idxNode].SavedState.Core.uID,
     3174                              ("loaded %#x, expected %#x\n", pThis->paNodes[idxNode].SavedState.Core.uID, idOld),
     3175                              VERR_SSM_DATA_UNIT_FORMAT_CHANGED);
     3176    }
     3177
     3178    /*
     3179     * Update stuff after changing the state.
     3180     */
     3181    PCODECNODE pNode;
     3182    if (hdaCodecIsDacNode(pThis, pThis->u8DacLineOut))
     3183    {
     3184        pNode = &pThis->paNodes[pThis->u8DacLineOut];
     3185        hdaCodecToAudVolume(pThis, pNode, &pNode->dac.B_params, PDMAUDIOMIXERCTL_FRONT);
     3186    }
     3187    else if (hdaCodecIsSpdifOutNode(pThis, pThis->u8DacLineOut))
     3188    {
     3189        pNode = &pThis->paNodes[pThis->u8DacLineOut];
     3190        hdaCodecToAudVolume(pThis, pNode, &pNode->spdifout.B_params, PDMAUDIOMIXERCTL_FRONT);
     3191    }
     3192
     3193    pNode = &pThis->paNodes[pThis->u8AdcVolsLineIn];
     3194    hdaCodecToAudVolume(pThis, pNode, &pNode->adcvol.B_params, PDMAUDIOMIXERCTL_LINE_IN);
     3195
     3196    LogFlowFuncLeaveRC(VINF_SUCCESS);
     3197    return VINF_SUCCESS;
    32133198}
    32143199
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