VirtualBox

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


Ignore:
Timestamp:
Dec 1, 2019 1:20:59 AM (5 years ago)
Author:
vboxsync
Message:

DevHDA: Fixed bug in hdaCodecLoadState showcasing why switch aren't the best way of handling saved state versions. If the switch has current-version case, it's either already broken or just waiting for it to happen. (Current version shouldn't be used anywhere but in the registration statement.) This one broke when the state version was last bumped. bugref:9218

Location:
trunk/src/VBox/Devices/Audio
Files:
2 edited

Legend:

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

    r82307 r82308  
    37433743
    37443744        default:
    3745             LogRel(("HDA: Warning: Unsupported / too new saved state version (%RU32)\n", uVersion));
    3746             return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
     3745            AssertLogRelMsgFailedReturn(("HDA: Internal Error! Didn't expect saved state version %RU32 ending up in hdaR3LoadExecLegacy!\n",
     3746                                         uVersion), VERR_INTERNAL_ERROR_5);
    37473747    }
    37483748
  • trunk/src/VBox/Devices/Audio/HDACodec.cpp

    r82307 r82308  
    31293129    PCSSMFIELD pFields = NULL;
    31303130    uint32_t   fFlags  = 0;
    3131     switch (uVersion)
    3132     {
    3133         case HDA_SAVED_STATE_VERSION_1:
    3134             AssertReturn(pThis->cTotalNodes == 0x1c, VERR_INTERNAL_ERROR);
    3135             pFields = g_aCodecNodeFieldsV1;
    3136             fFlags  = SSMSTRUCT_FLAGS_MEM_BAND_AID_RELAXED;
    3137             break;
    3138 
    3139         case HDA_SAVED_STATE_VERSION_2:
    3140         case HDA_SAVED_STATE_VERSION_3:
    3141             AssertReturn(pThis->cTotalNodes == 0x1c, VERR_INTERNAL_ERROR);
    3142             pFields = g_aCodecNodeFields;
    3143             fFlags  = SSMSTRUCT_FLAGS_MEM_BAND_AID_RELAXED;
    3144             break;
    3145 
     3131    if (uVersion >= HDA_SAVED_STATE_VERSION_4)
     3132    {
    31463133        /* Since version 4 a flexible node count is supported. */
    3147         case HDA_SAVED_STATE_VERSION_4:
    3148         case HDA_SAVED_STATE_VERSION_5:
    3149         case HDA_SAVED_STATE_VERSION:
    3150         {
    3151             uint32_t cNodes;
    3152             int rc2 = SSMR3GetU32(pSSM, &cNodes);
    3153             AssertRCReturn(rc2, rc2);
    3154             AssertReturn(cNodes == 0x1c, VERR_SSM_DATA_UNIT_FORMAT_CHANGED);
    3155             AssertReturn(pThis->cTotalNodes == 0x1c, VERR_INTERNAL_ERROR);
    3156 
    3157             pFields = g_aCodecNodeFields;
    3158             fFlags  = 0;
    3159             break;
    3160         }
    3161 
    3162         default:
    3163             AssertFailedReturn(VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION);
    3164     }
     3134        uint32_t cNodes;
     3135        int rc2 = SSMR3GetU32(pSSM, &cNodes);
     3136        AssertRCReturn(rc2, rc2);
     3137        AssertReturn(cNodes == 0x1c, VERR_SSM_DATA_UNIT_FORMAT_CHANGED);
     3138        AssertReturn(pThis->cTotalNodes == 0x1c, VERR_INTERNAL_ERROR);
     3139
     3140        pFields = g_aCodecNodeFields;
     3141        fFlags  = 0;
     3142    }
     3143    else if (uVersion >= HDA_SAVED_STATE_VERSION_2)
     3144    {
     3145        AssertReturn(pThis->cTotalNodes == 0x1c, VERR_INTERNAL_ERROR);
     3146        pFields = g_aCodecNodeFields;
     3147        fFlags  = SSMSTRUCT_FLAGS_MEM_BAND_AID_RELAXED;
     3148    }
     3149    else if (uVersion >= HDA_SAVED_STATE_VERSION_1)
     3150    {
     3151        AssertReturn(pThis->cTotalNodes == 0x1c, VERR_INTERNAL_ERROR);
     3152        pFields = g_aCodecNodeFieldsV1;
     3153        fFlags  = SSMSTRUCT_FLAGS_MEM_BAND_AID_RELAXED;
     3154    }
     3155    else
     3156        AssertFailedReturn(VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION);
    31653157
    31663158    for (unsigned idxNode = 0; idxNode < pThis->cTotalNodes; ++idxNode)
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