VirtualBox

Changeset 37190 in vbox


Ignore:
Timestamp:
May 24, 2011 3:23:48 AM (14 years ago)
Author:
vboxsync
Message:

Audio/HDA: loading V1 saved state. (xTracker/5704).

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

Legend:

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

    r37185 r37190  
    3232#define CODECNODE_F0_PARAM_LENGTH 0x14
    3333#define CODECNODE_F02_PARAM_LENGTH 16
     34
    3435typedef struct CODECCOMMONNODE
    3536{
     
    18351836}
    18361837
    1837 int codecLoadState(CODECState *pCodecState, PSSMHANDLE pSSMHandle)
    1838 {
    1839     int rc = SSMR3GetMem (pSSMHandle, pCodecState->pNodes, sizeof(CODECNODE) * pCodecState->cTotalNodes);
     1838static DECLCALLBACK(int)codecLoadV1(PCODECState pCodecState, PSSMHANDLE pSSMHandle, size_t cbOffset)
     1839{
     1840    size_t cbRawNodesV1 = (sizeof(CODECNODE) + cbOffset) * pCodecState->cTotalNodes;
     1841    uint8_t *pu8RawNodesV1 = (uint8_t *)RTMemAlloc(cbRawNodesV1);
     1842    uint8_t *pu8NodeV1 = NULL;
     1843    int idxNode = 0;
     1844    if (!pu8RawNodesV1)
     1845        return VERR_NO_MEMORY;
     1846    int rc = SSMR3GetMem (pSSMHandle, pu8RawNodesV1, cbRawNodesV1);
     1847
     1848    if (RT_FAILURE(rc))
     1849    {
     1850        RTMemFree(pu8RawNodesV1);
     1851        AssertRCReturn(rc, rc);
     1852    }
     1853    pu8NodeV1 = &pu8RawNodesV1[0];
     1854    for (idxNode = 0; idxNode < pCodecState->cTotalNodes; ++idxNode)
     1855    {
     1856        pCodecState->pNodes[idxNode].node.id = pu8NodeV1[0];
     1857        memcpy(pCodecState->pNodes[idxNode].node.au32F00_param,
     1858               pu8NodeV1 + RT_OFFSETOF(CODECCOMMONNODE, au32F00_param),
     1859               sizeof(CODECNODE) - RT_OFFSETOF(CODECCOMMONNODE,au32F00_param));
     1860        pu8NodeV1 += sizeof(CODECNODE) + cbOffset;
     1861    }
     1862
     1863    RTMemFree(pu8RawNodesV1);
     1864    return rc;
     1865}
     1866
     1867int codecLoadState(CODECState *pCodecState, PSSMHANDLE pSSMHandle, uint32_t uVersion)
     1868{
     1869    int rc;
     1870    if (uVersion == 1)
     1871    {
     1872#if RT_ARCH_X86
     1873        if (SSMR3HandleHostBits(pSSMHandle) == 32)
     1874            rc = codecLoadV1(pCodecState, pSSMHandle, sizeof(long));
     1875        else
     1876            rc = codecLoadV1(pCodecState, pSSMHandle, sizeof(uint64_t));
     1877#else
     1878        if (SSMR3HandleHostBits(pSSMHandle) == 64)
     1879            rc = codecLoadV1(pCodecState, pSSMHandle, sizeof(long));
     1880        else
     1881            rc = codecLoadV1(pCodecState, pSSMHandle, sizeof(uint32_t));
     1882#endif
     1883    }
     1884    else
     1885        rc = SSMR3GetMem (pSSMHandle, pCodecState->pNodes, sizeof(CODECNODE) * pCodecState->cTotalNodes);
    18401886    if (codecIsDacNode(pCodecState, pCodecState->u8DacLineOut))
    18411887        codecToAudVolume(&pCodecState->pNodes[pCodecState->u8DacLineOut].dac.B_params, AUD_MIXER_VOLUME);
  • trunk/src/VBox/Devices/Audio/DevCodec.h

    r36691 r37190  
    527527int codecDestruct(CODECState *pCodecState);
    528528int codecSaveState(CODECState *pCodecState, PSSMHANDLE pSSMHandle);
    529 int codecLoadState(CODECState *pCodecState, PSSMHANDLE pSSMHandle);
     529int codecLoadState(CODECState *pCodecState, PSSMHANDLE pSSMHandle, uint32_t uVersion);
    530530int codecOpenVoice(CODECState *pCodecState, ENMSOUNDSOURCE enmSoundSource, audsettings_t *pAudioSettings);
     531
     532#define HDA_SSM_VERSION 2
    531533
    532534# ifdef VBOX_WITH_HDA_CODEC_EMU
  • trunk/src/VBox/Devices/Audio/DevIchIntelHDA.cpp

    r37185 r37190  
    5353#endif
    5454
    55 #define HDA_SSM_VERSION 2
    5655PDMBOTHCBDECL(int) hdaMMIORead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb);
    5756PDMBOTHCBDECL(int) hdaMMIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb);
     
    19961995    PCIINTELHDLinkState *pThis = PDMINS_2_DATA(pDevIns, PCIINTELHDLinkState *);
    19971996    /* Load Codec nodes states */
    1998     if (uVersion < HDA_SSM_VERSION)
     1997    if (uVersion > HDA_SSM_VERSION)
    19991998        return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
    20001999    Assert (uPass == SSM_PASS_FINAL); NOREF(uPass);
    20012000
    2002     codecLoadState(&pThis->hda.Codec, pSSMHandle);
     2001    codecLoadState(&pThis->hda.Codec, pSSMHandle, uVersion);
    20032002    /* Load MMIO registers */
    20042003    SSMR3GetMem (pSSMHandle, pThis->hda.au32Regs, sizeof (pThis->hda.au32Regs));
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