VirtualBox

Ignore:
Timestamp:
May 12, 2016 1:18:40 PM (9 years ago)
Author:
vboxsync
Message:

Audio: Renaming.

File:
1 edited

Legend:

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

    r60941 r60942  
    906906static int       hdaRegWriteSDBDPL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    907907static int       hdaRegWriteSDBDPU(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
    908 DECLINLINE(int)  hdaRegWriteSDLock(PHDASTATE pThis, PHDASTREAM pStrmSt, uint32_t iReg, uint32_t u32Value);
    909 DECLINLINE(void) hdaRegWriteSDUnlock(PHDASTREAM pStrmSt);
     908DECLINLINE(int)  hdaRegWriteSDLock(PHDASTATE pThis, PHDASTREAM pStream, uint32_t iReg, uint32_t u32Value);
     909DECLINLINE(void) hdaRegWriteSDUnlock(PHDASTREAM pStream);
    910910
    911911/*
     
    922922
    923923#ifdef IN_RING3
    924 static void hdaStreamDestroy(PHDASTREAM pStrmSt);
     924static void hdaStreamDestroy(PHDASTREAM pStream);
    925925static int hdaStreamSetActive(PHDASTATE pThis, PHDASTREAM pStream, bool fActive);
    926 static int hdaStreamStart(PHDASTREAM pStrmSt);
    927 static int hdaStreamStop(PHDASTREAM pStrmSt);
    928 static int hdaStreamWaitForStateChange(PHDASTREAM pStrmSt, RTMSINTERVAL msTimeout);
    929 static int hdaTransfer(PHDASTATE pThis, PHDASTREAM pStrmSt, uint32_t cbToProcess, uint32_t *pcbProcessed);
     926static int hdaStreamStart(PHDASTREAM pStream);
     927static int hdaStreamStop(PHDASTREAM pStream);
     928static int hdaStreamWaitForStateChange(PHDASTREAM pStream, RTMSINTERVAL msTimeout);
     929static int hdaTransfer(PHDASTATE pThis, PHDASTREAM pStream, uint32_t cbToProcess, uint32_t *pcbProcessed);
    930930#endif
    931931
     
    938938#ifdef IN_RING3
    939939static int           hdaBDLEFetch(PHDASTATE pThis, PHDABDLE pBDLE, uint64_t u64BaseDMA, uint16_t u16Entry);
    940 DECLINLINE(uint32_t) hdaStreamUpdateLPIB(PHDASTATE pThis, PHDASTREAM pStrmSt, uint32_t u32LPIB);
     940DECLINLINE(uint32_t) hdaStreamUpdateLPIB(PHDASTATE pThis, PHDASTREAM pStream, uint32_t u32LPIB);
    941941# ifdef LOG_ENABLED
    942942static void          hdaBDLEDumpAll(PHDASTATE pThis, uint64_t u64BaseDMA, uint16_t cBDLE);
     
    11351135
    11361136#ifdef IN_RING3
    1137 DECLINLINE(uint32_t) hdaStreamUpdateLPIB(PHDASTATE pThis, PHDASTREAM pStrmSt, uint32_t u32LPIB)
     1137DECLINLINE(uint32_t) hdaStreamUpdateLPIB(PHDASTATE pThis, PHDASTREAM pStream, uint32_t u32LPIB)
    11381138{
    11391139    AssertPtrReturn(pThis,   0);
    1140     AssertPtrReturn(pStrmSt, 0);
    1141 
    1142     Assert(u32LPIB <= pStrmSt->u32CBL);
     1140    AssertPtrReturn(pStream, 0);
     1141
     1142    Assert(u32LPIB <= pStream->u32CBL);
    11431143
    11441144    LogFlowFunc(("[SD%RU8]: LPIB=%RU32 (DMA Position Buffer Enabled: %RTbool)\n",
    1145                  pStrmSt->u8SD, u32LPIB, pThis->fDMAPosition));
     1145                 pStream->u8SD, u32LPIB, pThis->fDMAPosition));
    11461146
    11471147    /* Update LPIB in any case. */
    1148     HDA_STREAM_REG(pThis, LPIB, pStrmSt->u8SD) = u32LPIB;
     1148    HDA_STREAM_REG(pThis, LPIB, pStream->u8SD) = u32LPIB;
    11491149
    11501150    /* Do we need to tell the current DMA position? */
     
    11521152    {
    11531153        int rc2 = PDMDevHlpPCIPhysWrite(pThis->CTX_SUFF(pDevIns),
    1154                                         (pThis->u64DPBase & DPBASE_ADDR_MASK) + (pStrmSt->u8SD * 2 * sizeof(uint32_t)),
     1154                                        (pThis->u64DPBase & DPBASE_ADDR_MASK) + (pStream->u8SD * 2 * sizeof(uint32_t)),
    11551155                                        (void *)&u32LPIB, sizeof(uint32_t));
    11561156        AssertRC(rc2);
     
    13231323 * @return Number of bytes accumulated/free in the FIFO.
    13241324 */
    1325 DECLINLINE(uint8_t) hdaStreamGetFIFOW(PHDASTATE pThis, PHDASTREAM pStrmSt)
     1325DECLINLINE(uint8_t) hdaStreamGetFIFOW(PHDASTATE pThis, PHDASTREAM pStream)
    13261326{
    13271327    AssertPtrReturn(pThis, 0);
    1328     AssertPtrReturn(pStrmSt, 0);
     1328    AssertPtrReturn(pStream, 0);
    13291329
    13301330#ifdef VBOX_HDA_WITH_FIFO
    1331     return hdaSDFIFOWToBytes(HDA_STREAM_REG(pThis, FIFOW, pStrmSt->u8SD));
     1331    return hdaSDFIFOWToBytes(HDA_STREAM_REG(pThis, FIFOW, pStream->u8SD));
    13321332#else
    13331333    return 0;
     
    16011601}
    16021602
    1603 static int hdaStreamCreate(PHDASTREAM pStrmSt, uint8_t uSD)
    1604 {
    1605     AssertPtrReturn(pStrmSt, VERR_INVALID_POINTER);
     1603static int hdaStreamCreate(PHDASTREAM pStream, uint8_t uSD)
     1604{
     1605    AssertPtrReturn(pStream, VERR_INVALID_POINTER);
    16061606    AssertReturn(uSD <= HDA_MAX_STREAMS, VERR_INVALID_PARAMETER);
    16071607
    1608     int rc = RTSemEventCreate(&pStrmSt->State.hStateChangedEvent);
     1608    int rc = RTSemEventCreate(&pStream->State.hStateChangedEvent);
    16091609    if (RT_SUCCESS(rc))
    1610         rc = RTSemMutexCreate(&pStrmSt->State.hMtx);
     1610        rc = RTSemMutexCreate(&pStream->State.hMtx);
    16111611
    16121612    if (RT_SUCCESS(rc))
    16131613    {
    1614         pStrmSt->u8SD           = uSD;
    1615         pStrmSt->pMixSink       = NULL;
    1616 
    1617         pStrmSt->State.fActive  = false;
    1618         pStrmSt->State.fInReset = false;
    1619         pStrmSt->State.fDoStop  = false;
     1614        pStream->u8SD           = uSD;
     1615        pStream->pMixSink       = NULL;
     1616
     1617        pStream->State.fActive  = false;
     1618        pStream->State.fInReset = false;
     1619        pStream->State.fDoStop  = false;
    16201620    }
    16211621
     
    16241624}
    16251625
    1626 static void hdaStreamDestroy(PHDASTREAM pStrmSt)
    1627 {
    1628     AssertPtrReturnVoid(pStrmSt);
    1629 
    1630     LogFlowFunc(("[SD%RU8]: Destroying ...\n", pStrmSt->u8SD));
    1631 
    1632     int rc2 = hdaStreamStop(pStrmSt);
     1626static void hdaStreamDestroy(PHDASTREAM pStream)
     1627{
     1628    AssertPtrReturnVoid(pStream);
     1629
     1630    LogFlowFunc(("[SD%RU8]: Destroying ...\n", pStream->u8SD));
     1631
     1632    int rc2 = hdaStreamStop(pStream);
    16331633    AssertRC(rc2);
    16341634
    1635     hdaStreamMapDestroy(&pStrmSt->State.Mapping);
    1636 
    1637     if (pStrmSt->State.hMtx != NIL_RTSEMMUTEX)
    1638     {
    1639         rc2 = RTSemMutexDestroy(pStrmSt->State.hMtx);
     1635    hdaStreamMapDestroy(&pStream->State.Mapping);
     1636
     1637    if (pStream->State.hMtx != NIL_RTSEMMUTEX)
     1638    {
     1639        rc2 = RTSemMutexDestroy(pStream->State.hMtx);
    16401640        AssertRC(rc2);
    1641         pStrmSt->State.hMtx = NIL_RTSEMMUTEX;
    1642     }
    1643 
    1644     if (pStrmSt->State.hStateChangedEvent != NIL_RTSEMEVENT)
    1645     {
    1646         rc2 = RTSemEventDestroy(pStrmSt->State.hStateChangedEvent);
     1641        pStream->State.hMtx = NIL_RTSEMMUTEX;
     1642    }
     1643
     1644    if (pStream->State.hStateChangedEvent != NIL_RTSEMEVENT)
     1645    {
     1646        rc2 = RTSemEventDestroy(pStream->State.hStateChangedEvent);
    16471647        AssertRC(rc2);
    1648         pStrmSt->State.hStateChangedEvent = NIL_RTSEMEVENT;
     1648        pStream->State.hStateChangedEvent = NIL_RTSEMEVENT;
    16491649    }
    16501650
     
    16861686}
    16871687
    1688 static void hdaStreamReset(PHDASTATE pThis, PHDASTREAM pStrmSt)
     1688static void hdaStreamReset(PHDASTATE pThis, PHDASTREAM pStream)
    16891689{
    16901690    AssertPtrReturnVoid(pThis);
    1691     AssertPtrReturnVoid(pStrmSt);
    1692 
    1693     const uint8_t uSD = pStrmSt->u8SD;
     1691    AssertPtrReturnVoid(pStream);
     1692
     1693    const uint8_t uSD = pStream->u8SD;
    16941694
    16951695#ifdef VBOX_STRICT
     
    17031703     * Set reset state.
    17041704     */
    1705     Assert(ASMAtomicReadBool(&pStrmSt->State.fInReset) == false); /* No nested calls. */
    1706     ASMAtomicXchgBool(&pStrmSt->State.fInReset, true);
     1705    Assert(ASMAtomicReadBool(&pStream->State.fInReset) == false); /* No nested calls. */
     1706    ASMAtomicXchgBool(&pStream->State.fInReset, true);
    17071707
    17081708    /*
    17091709     * First, reset the internal stream state.
    17101710     */
    1711     RT_ZERO(pStrmSt->State.BDLE);
    1712     pStrmSt->State.uCurBDLE = 0;
     1711    RT_ZERO(pStream->State.BDLE);
     1712    pStream->State.uCurBDLE = 0;
    17131713
    17141714    /*
     
    17321732    HDA_STREAM_REG(pThis, BDPL,  uSD) = 0;
    17331733
    1734     int rc2 = hdaStreamInit(pThis, pStrmSt, uSD);
     1734    int rc2 = hdaStreamInit(pThis, pStream, uSD);
    17351735    AssertRC(rc2);
    17361736
     
    17391739
    17401740    /* Exit reset state. */
    1741     ASMAtomicXchgBool(&pStrmSt->State.fInReset, false);
     1741    ASMAtomicXchgBool(&pStream->State.fInReset, false);
    17421742}
    17431743
     
    17781778}
    17791779
    1780 static void hdaStreamAssignToSink(PHDASTREAM pStrmSt, PHDAMIXERSINK pMixSink)
    1781 {
    1782     AssertPtrReturnVoid(pStrmSt);
    1783 
    1784     int rc2 = RTSemMutexRequest(pStrmSt->State.hMtx, RT_INDEFINITE_WAIT);
     1780static void hdaStreamAssignToSink(PHDASTREAM pStream, PHDAMIXERSINK pMixSink)
     1781{
     1782    AssertPtrReturnVoid(pStream);
     1783
     1784    int rc2 = RTSemMutexRequest(pStream->State.hMtx, RT_INDEFINITE_WAIT);
    17851785    if (RT_SUCCESS(rc2))
    17861786    {
    1787         pStrmSt->pMixSink = pMixSink;
    1788 
    1789         rc2 = RTSemMutexRelease(pStrmSt->State.hMtx);
     1787        pStream->pMixSink = pMixSink;
     1788
     1789        rc2 = RTSemMutexRelease(pStream->State.hMtx);
    17901790        AssertRC(rc2);
    17911791    }
    17921792}
    17931793
    1794 static int hdaStreamStart(PHDASTREAM pStrmSt)
    1795 {
    1796     AssertPtrReturn(pStrmSt, VERR_INVALID_POINTER);
    1797 
    1798     ASMAtomicXchgBool(&pStrmSt->State.fDoStop, false);
    1799     ASMAtomicXchgBool(&pStrmSt->State.fActive, true);
     1794static int hdaStreamStart(PHDASTREAM pStream)
     1795{
     1796    AssertPtrReturn(pStream, VERR_INVALID_POINTER);
     1797
     1798    ASMAtomicXchgBool(&pStream->State.fDoStop, false);
     1799    ASMAtomicXchgBool(&pStream->State.fActive, true);
    18001800
    18011801    LogFlowFuncLeave();
     
    18031803}
    18041804
    1805 static int hdaStreamStop(PHDASTREAM pStrmSt)
    1806 {
    1807     AssertPtrReturn(pStrmSt, VERR_INVALID_POINTER);
     1805static int hdaStreamStop(PHDASTREAM pStream)
     1806{
     1807    AssertPtrReturn(pStream, VERR_INVALID_POINTER);
    18081808
    18091809    /* Already in stopped state? */
    1810     bool fActive = ASMAtomicReadBool(&pStrmSt->State.fActive);
     1810    bool fActive = ASMAtomicReadBool(&pStream->State.fActive);
    18111811    if (!fActive)
    18121812        return VINF_SUCCESS;
     
    18161816     * Wait for the stream to stop.
    18171817     */
    1818     ASMAtomicXchgBool(&pStrmSt->State.fDoStop, true);
    1819 
    1820     int rc = hdaStreamWaitForStateChange(pStrmSt, 60 * 1000 /* ms timeout */);
    1821     fActive = ASMAtomicReadBool(&pStrmSt->State.fActive);
     1818    ASMAtomicXchgBool(&pStream->State.fDoStop, true);
     1819
     1820    int rc = hdaStreamWaitForStateChange(pStream, 60 * 1000 /* ms timeout */);
     1821    fActive = ASMAtomicReadBool(&pStream->State.fActive);
    18221822    if (   /* Waiting failed? */
    18231823           RT_FAILURE(rc)
     
    18271827        AssertRC(rc);
    18281828        LogRel(("HDA: Warning: Unable to stop stream %RU8 (state: %s), rc=%Rrc\n",
    1829                 pStrmSt->u8Strm, fActive ? "active" : "stopped", rc));
     1829                pStream->u8Strm, fActive ? "active" : "stopped", rc));
    18301830    }
    18311831#else
     
    19451945}
    19461946
    1947 static int hdaStreamWaitForStateChange(PHDASTREAM pStrmSt, RTMSINTERVAL msTimeout)
    1948 {
    1949     AssertPtrReturn(pStrmSt, VERR_INVALID_POINTER);
    1950 
    1951     LogFlowFunc(("[SD%RU8]: msTimeout=%RU32\n", pStrmSt->u8SD, msTimeout));
    1952     return RTSemEventWait(pStrmSt->State.hStateChangedEvent, msTimeout);
     1947static int hdaStreamWaitForStateChange(PHDASTREAM pStream, RTMSINTERVAL msTimeout)
     1948{
     1949    AssertPtrReturn(pStream, VERR_INVALID_POINTER);
     1950
     1951    LogFlowFunc(("[SD%RU8]: msTimeout=%RU32\n", pStream->u8SD, msTimeout));
     1952    return RTSemEventWait(pStream->State.hStateChangedEvent, msTimeout);
    19531953}
    19541954#endif /* IN_RING3 */
     
    22052205        return VINF_SUCCESS;
    22062206
    2207     PHDASTREAM pStrmSt = hdaStreamFromSD(pThis, HDA_SD_NUM_FROM_REG(pThis, CBL, iReg));
    2208     if (!pStrmSt)
     2207    PHDASTREAM pStream = hdaStreamFromSD(pThis, HDA_SD_NUM_FROM_REG(pThis, CBL, iReg));
     2208    if (!pStream)
    22092209    {
    22102210        LogFunc(("[SD%RU8]: Warning: Changing SDCBL on non-attached stream (0x%x)\n", HDA_SD_NUM_FROM_REG(pThis, CTL, iReg), u32Value));
     
    22122212    }
    22132213
    2214     int rc2 = hdaRegWriteSDLock(pThis, pStrmSt, iReg, u32Value);
     2214    int rc2 = hdaRegWriteSDLock(pThis, pStream, iReg, u32Value);
    22152215    AssertRC(rc2);
    22162216
    2217     pStrmSt->u32CBL = u32Value;
     2217    pStream->u32CBL = u32Value;
    22182218
    22192219    /* Reset BDLE state. */
    2220     RT_ZERO(pStrmSt->State.BDLE);
    2221     pStrmSt->State.uCurBDLE = 0;
     2220    RT_ZERO(pStream->State.BDLE);
     2221    pStream->State.uCurBDLE = 0;
    22222222
    22232223    rc2 = hdaRegWriteU32(pThis, iReg, u32Value);
    22242224    AssertRC(rc2);
    22252225
    2226     LogFlowFunc(("[SD%RU8]: CBL=%RU32\n", pStrmSt->u8SD, u32Value));
    2227     hdaRegWriteSDUnlock(pStrmSt);
     2226    LogFlowFunc(("[SD%RU8]: CBL=%RU32\n", pStream->u8SD, u32Value));
     2227    hdaRegWriteSDUnlock(pStream);
    22282228
    22292229    return VINF_SUCCESS; /* Always return success to the MMIO handler. */
     
    22732273    pTag->pStrm = hdaStreamFromSD(pThis, uSD);
    22742274
    2275     PHDASTREAM pStrmSt = pTag->pStrm;
    2276     AssertPtr(pStrmSt);
     2275    PHDASTREAM pStream = pTag->pStrm;
     2276    AssertPtr(pStream);
    22772277
    22782278    /* Note: Do not use hdaRegWriteSDLock() here, as SDnCTL might change the RUN bit. */
    2279     int rc2 = RTSemMutexRequest(pStrmSt->State.hMtx, RT_INDEFINITE_WAIT);
     2279    int rc2 = RTSemMutexRequest(pStream->State.hMtx, RT_INDEFINITE_WAIT);
    22802280    AssertRC(rc2);
    22812281#endif /* IN_RING3 */
     
    23002300        Assert(!fInRun && !fRun);
    23012301
    2302         LogFunc(("[SD%RU8]: Guest initiated enter to stream reset\n", pStrmSt->u8SD));
    2303         hdaStreamReset(pThis, pStrmSt);
     2302        LogFunc(("[SD%RU8]: Guest initiated enter to stream reset\n", pStream->u8SD));
     2303        hdaStreamReset(pThis, pStream);
    23042304#endif
    23052305    }
     
    23132313        {
    23142314            Assert(!fReset && !fInReset);
    2315             LogFunc(("[SD%RU8]: fRun=%RTbool\n", pStrmSt->u8SD, fRun));
    2316 
    2317             hdaStreamSetActive(pThis, pStrmSt, fRun);
     2315            LogFunc(("[SD%RU8]: fRun=%RTbool\n", pStream->u8SD, fRun));
     2316
     2317            hdaStreamSetActive(pThis, pStream, fRun);
    23182318
    23192319            if (fRun)
    23202320            {
    23212321                /* (Re-)Fetch the current BDLE entry. */
    2322                 rc2 = hdaBDLEFetch(pThis, &pStrmSt->State.BDLE, pStrmSt->u64BDLBase, pStrmSt->State.uCurBDLE);
     2322                rc2 = hdaBDLEFetch(pThis, &pStream->State.BDLE, pStream->u64BDLBase, pStream->State.uCurBDLE);
    23232323                AssertRC(rc2);
    23242324            }
     
    23262326
    23272327        if (!fInRun && !fRun)
    2328             hdaStreamInit(pThis, pStrmSt, pStrmSt->u8SD);
     2328            hdaStreamInit(pThis, pStream, pStream->u8SD);
    23292329#endif /* IN_RING3 */
    23302330    }
     
    23372337    AssertRC(rc2);
    23382338
    2339     hdaRegWriteSDUnlock(pStrmSt);
     2339    hdaRegWriteSDUnlock(pStream);
    23402340    return VINF_SUCCESS; /* Always return success to the MMIO handler. */
    23412341#else
     
    23652365        return VINF_SUCCESS;
    23662366
    2367     PHDASTREAM pStrmSt = hdaStreamFromSD(pThis, HDA_SD_NUM_FROM_REG(pThis, LVI, iReg));
    2368     if (!pStrmSt)
     2367    PHDASTREAM pStream = hdaStreamFromSD(pThis, HDA_SD_NUM_FROM_REG(pThis, LVI, iReg));
     2368    if (!pStream)
    23692369    {
    23702370        LogFunc(("[SD%RU8]: Warning: Changing SDLVI on non-attached stream (0x%x)\n", HDA_SD_NUM_FROM_REG(pThis, CTL, iReg), u32Value));
     
    23722372    }
    23732373
    2374     int rc2 = hdaRegWriteSDLock(pThis, pStrmSt, iReg, u32Value);
     2374    int rc2 = hdaRegWriteSDLock(pThis, pStream, iReg, u32Value);
    23752375    AssertRC(rc2);
    23762376
    23772377    /** @todo Validate LVI. */
    2378     pStrmSt->u16LVI = u32Value;
     2378    pStream->u16LVI = u32Value;
    23792379
    23802380    /* Reset BDLE state. */
    2381     RT_ZERO(pStrmSt->State.BDLE);
    2382     pStrmSt->State.uCurBDLE = 0;
     2381    RT_ZERO(pStream->State.BDLE);
     2382    pStream->State.uCurBDLE = 0;
    23832383
    23842384    rc2 = hdaRegWriteU16(pThis, iReg, u32Value);
    23852385    AssertRC(rc2);
    23862386
    2387     LogFlowFunc(("[SD%RU8]: LVI=%RU32\n", pStrmSt->u8SD, u32Value));
    2388     hdaRegWriteSDUnlock(pStrmSt);
     2387    LogFlowFunc(("[SD%RU8]: LVI=%RU32\n", pStream->u8SD, u32Value));
     2388    hdaRegWriteSDUnlock(pStream);
    23892389
    23902390    return VINF_SUCCESS; /* Always return success to the MMIO handler. */
     
    27212721        return VINF_SUCCESS; /* Always return success to the MMIO handler. */
    27222722
    2723     PHDASTREAM pStrmSt = hdaStreamFromSD(pThis, HDA_SD_NUM_FROM_REG(pThis, FMT, iReg));
    2724     if (!pStrmSt)
     2723    PHDASTREAM pStream = hdaStreamFromSD(pThis, HDA_SD_NUM_FROM_REG(pThis, FMT, iReg));
     2724    if (!pStream)
    27252725    {
    27262726        LogFunc(("[SD%RU8]: Warning: Changing SDFMT on non-attached stream (0x%x)\n",
     
    27292729    }
    27302730
    2731     rc = hdaRegWriteSDLock(pThis, pStrmSt, iReg, u32Value);
     2731    rc = hdaRegWriteSDLock(pThis, pStream, iReg, u32Value);
    27322732    AssertRC(rc);
    27332733
    27342734    LogFunc(("[SD%RU8]: Hz=%RU32, Channels=%RU8, enmFmt=%RU32\n",
    2735              pStrmSt->u8SD, strmCfg.uHz, strmCfg.cChannels, strmCfg.enmFormat));
     2735             pStream->u8SD, strmCfg.uHz, strmCfg.cChannels, strmCfg.enmFormat));
    27362736
    27372737    /* Set audio direction. */
    2738     strmCfg.enmDir = hdaGetDirFromSD(pStrmSt->u8SD);
     2738    strmCfg.enmDir = hdaGetDirFromSD(pStream->u8SD);
    27392739
    27402740    /*
     
    27462746     * number of channels in a single audio stream.
    27472747     */
    2748     rc = hdaStreamMapInit(&pStrmSt->State.Mapping, &strmCfg);
     2748    rc = hdaStreamMapInit(&pStream->State.Mapping, &strmCfg);
    27492749    AssertRC(rc);
    27502750
     
    27882788        }
    27892789        else
    2790             LogFunc(("[SD%RU8]: (Re-)Opening stream failed with rc=%Rrc\n", pStrmSt->u8SD, rc));
    2791 
    2792         hdaRegWriteSDUnlock(pStrmSt);
     2790            LogFunc(("[SD%RU8]: (Re-)Opening stream failed with rc=%Rrc\n", pStream->u8SD, rc));
     2791
     2792        hdaRegWriteSDUnlock(pStream);
    27932793    }
    27942794
     
    28062806        return VINF_SUCCESS;
    28072807
    2808     PHDASTREAM pStrmSt = hdaStreamFromSD(pThis, u8Strm);
    2809     if (!pStrmSt)
     2808    PHDASTREAM pStream = hdaStreamFromSD(pThis, u8Strm);
     2809    if (!pStream)
    28102810    {
    28112811        LogFunc(("[SD%RU8]: Warning: Changing SDBPL/SDBPU on non-attached stream (0x%x)\n", HDA_SD_NUM_FROM_REG(pThis, CTL, iReg), u32Value));
     
    28132813    }
    28142814
    2815     int rc2 = hdaRegWriteSDLock(pThis, pStrmSt, iReg, u32Value);
     2815    int rc2 = hdaRegWriteSDLock(pThis, pStream, iReg, u32Value);
    28162816    AssertRC(rc2);
    28172817
     
    28202820
    28212821    /* Update BDL base. */
    2822     pStrmSt->u64BDLBase = RT_MAKE_U64(HDA_STREAM_REG(pThis, BDPL, u8Strm),
     2822    pStream->u64BDLBase = RT_MAKE_U64(HDA_STREAM_REG(pThis, BDPL, u8Strm),
    28232823                                      HDA_STREAM_REG(pThis, BDPU, u8Strm));
    28242824    /* Reset BDLE state. */
    2825     RT_ZERO(pStrmSt->State.BDLE);
    2826     pStrmSt->State.uCurBDLE = 0;
    2827 
    2828     LogFlowFunc(("[SD%RU8]: BDLBase=0x%x\n", pStrmSt->u8SD, pStrmSt->u64BDLBase));
    2829     hdaRegWriteSDUnlock(pStrmSt);
     2825    RT_ZERO(pStream->State.BDLE);
     2826    pStream->State.uCurBDLE = 0;
     2827
     2828    LogFlowFunc(("[SD%RU8]: BDLBase=0x%x\n", pStream->u8SD, pStream->u64BDLBase));
     2829    hdaRegWriteSDUnlock(pStream);
    28302830
    28312831    return VINF_SUCCESS; /* Always return success to the MMIO handler. */
     
    28542854 * @param   u32Value            Value to write.
    28552855 */
    2856 DECLINLINE(int) hdaRegWriteSDLock(PHDASTATE pThis, PHDASTREAM pStrmSt, uint32_t iReg, uint32_t u32Value)
     2856DECLINLINE(int) hdaRegWriteSDLock(PHDASTATE pThis, PHDASTREAM pStream, uint32_t iReg, uint32_t u32Value)
    28572857{
    28582858    AssertPtrReturn(pThis,   VERR_INVALID_POINTER);
    2859     AssertPtrReturn(pStrmSt, VERR_INVALID_POINTER);
     2859    AssertPtrReturn(pStream, VERR_INVALID_POINTER);
    28602860
    28612861#ifdef VBOX_STRICT
    28622862    /* Check if the SD's RUN bit is set. */
    2863     uint32_t u32SDCTL = HDA_STREAM_REG(pThis, CTL, pStrmSt->u8SD);
     2863    uint32_t u32SDCTL = HDA_STREAM_REG(pThis, CTL, pStream->u8SD);
    28642864    bool fIsRunning   = RT_BOOL(u32SDCTL & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN));
    28652865    if (fIsRunning)
    28662866    {
    28672867        LogFlowFunc(("[SD%RU8]: Warning: Cannot write to register 0x%x (0x%x) when RUN bit is set (%R[sdctl])\n",
    2868                      pStrmSt->u8SD, iReg, u32Value, u32SDCTL));
     2868                     pStream->u8SD, iReg, u32Value, u32SDCTL));
    28692869        return VERR_ACCESS_DENIED;
    28702870    }
    28712871#endif
    28722872
    2873     return RTSemMutexRequest(pStrmSt->State.hMtx, RT_INDEFINITE_WAIT);
    2874 }
    2875 
    2876 DECLINLINE(void) hdaRegWriteSDUnlock(PHDASTREAM pStrmSt)
    2877 {
    2878     AssertPtrReturnVoid(pStrmSt);
    2879 
    2880     int rc2 = RTSemMutexRelease(pStrmSt->State.hMtx);
     2873    return RTSemMutexRequest(pStream->State.hMtx, RT_INDEFINITE_WAIT);
     2874}
     2875
     2876DECLINLINE(void) hdaRegWriteSDUnlock(PHDASTREAM pStream)
     2877{
     2878    AssertPtrReturnVoid(pStream);
     2879
     2880    int rc2 = RTSemMutexRelease(pStream->State.hMtx);
    28812881    AssertRC(rc2);
    28822882}
     
    30983098 * @return Number of bytes for the DMA engine to process.
    30993099 */
    3100 DECLINLINE(uint32_t) hdaStreamGetTransferSize(PHDASTATE pThis, PHDASTREAM pStrmSt, uint32_t cbMax)
     3100DECLINLINE(uint32_t) hdaStreamGetTransferSize(PHDASTATE pThis, PHDASTREAM pStream, uint32_t cbMax)
    31013101{
    31023102    AssertPtrReturn(pThis,   0);
    3103     AssertPtrReturn(pStrmSt, 0);
     3103    AssertPtrReturn(pStream, 0);
    31043104
    31053105    if (!cbMax)
    31063106        return 0;
    31073107
    3108     PHDABDLE pBDLE = &pStrmSt->State.BDLE;
    3109 
    3110     uint32_t u32LPIB = HDA_STREAM_REG(pThis, LPIB, pStrmSt->u8SD);
    3111     Assert(u32LPIB <= pStrmSt->u32CBL);
    3112 
    3113     uint32_t cbFree = pStrmSt->u32CBL - u32LPIB; /** @todo Convert samples to bytes? */
     3108    PHDABDLE pBDLE = &pStream->State.BDLE;
     3109
     3110    uint32_t u32LPIB = HDA_STREAM_REG(pThis, LPIB, pStream->u8SD);
     3111    Assert(u32LPIB <= pStream->u32CBL);
     3112
     3113    uint32_t cbFree = pStream->u32CBL - u32LPIB; /** @todo Convert samples to bytes? */
    31143114    if (cbFree)
    31153115    {
     
    31183118
    31193119        /* Make sure we only copy as much as the stream's FIFO can hold (SDFIFOS, 18.2.39). */
    3120         cbFree = RT_MIN(cbFree, pStrmSt->u16FIFOS);
     3120        cbFree = RT_MIN(cbFree, pStream->u16FIFOS);
    31213121
    31223122        /* Make sure we only transfer as many bytes as requested. */
     
    31363136    }
    31373137
    3138     LogFlowFunc(("[SD%RU8]: CBL=%RU32, LPIB=%RU32, cbFree=%RU32, %R[bdle]\n", pStrmSt->u8SD,
    3139                  pStrmSt->u32CBL, HDA_STREAM_REG(pThis, LPIB, pStrmSt->u8SD), cbFree, pBDLE));
     3138    LogFlowFunc(("[SD%RU8]: CBL=%RU32, LPIB=%RU32, cbFree=%RU32, %R[bdle]\n", pStream->u8SD,
     3139                 pStream->u32CBL, HDA_STREAM_REG(pThis, LPIB, pStream->u8SD), cbFree, pBDLE));
    31403140    return cbFree;
    31413141}
     
    32803280#endif /* IN_RING3 */
    32813281
    3282 DECLINLINE(bool) hdaStreamNeedsNextBDLE(PHDASTATE pThis, PHDASTREAM pStrmSt)
     3282DECLINLINE(bool) hdaStreamNeedsNextBDLE(PHDASTATE pThis, PHDASTREAM pStream)
    32833283{
    32843284    AssertPtrReturn(pThis,   false);
    3285     AssertPtrReturn(pStrmSt, false);
    3286 
    3287     PHDABDLE pBDLE   = &pStrmSt->State.BDLE;
    3288     uint32_t u32LPIB = HDA_STREAM_REG(pThis, LPIB, pStrmSt->u8SD);
     3285    AssertPtrReturn(pStream, false);
     3286
     3287    PHDABDLE pBDLE   = &pStream->State.BDLE;
     3288    uint32_t u32LPIB = HDA_STREAM_REG(pThis, LPIB, pStream->u8SD);
    32893289
    32903290    /* Did we reach the CBL (Cyclic Buffer List) limit? */
    3291     bool fCBLLimitReached = u32LPIB >= pStrmSt->u32CBL;
     3291    bool fCBLLimitReached = u32LPIB >= pStream->u32CBL;
    32923292
    32933293    /* Do we need to use the next BDLE entry? Either because we reached
     
    32963296                             || (pBDLE->State.u32BufOff >= pBDLE->u32BufSize));
    32973297
    3298     Assert(u32LPIB                <= pStrmSt->u32CBL);
     3298    Assert(u32LPIB                <= pStream->u32CBL);
    32993299    Assert(pBDLE->State.u32BufOff <= pBDLE->u32BufSize);
    33003300
    33013301    LogFlowFunc(("[SD%RU8]: LPIB=%RU32, CBL=%RU32, fCBLLimitReached=%RTbool, fNeedsNextBDLE=%RTbool, %R[bdle]\n",
    3302                  pStrmSt->u8SD, u32LPIB, pStrmSt->u32CBL, fCBLLimitReached, fNeedsNextBDLE, pBDLE));
     3302                 pStream->u8SD, u32LPIB, pStream->u32CBL, fCBLLimitReached, fNeedsNextBDLE, pBDLE));
    33033303
    33043304    return fNeedsNextBDLE;
    33053305}
    33063306
    3307 DECLINLINE(void) hdaStreamTransferUpdate(PHDASTATE pThis, PHDASTREAM pStrmSt, uint32_t cbInc)
     3307DECLINLINE(void) hdaStreamTransferUpdate(PHDASTATE pThis, PHDASTREAM pStream, uint32_t cbInc)
    33083308{
    33093309    AssertPtrReturnVoid(pThis);
    3310     AssertPtrReturnVoid(pStrmSt);
    3311 
    3312     LogFlowFunc(("[SD%RU8]: cbInc=%RU32\n", pStrmSt->u8SD, cbInc));
    3313 
    3314     Assert(cbInc <= pStrmSt->u16FIFOS);
     3310    AssertPtrReturnVoid(pStream);
     3311
     3312    LogFlowFunc(("[SD%RU8]: cbInc=%RU32\n", pStream->u8SD, cbInc));
     3313
     3314    Assert(cbInc <= pStream->u16FIFOS);
    33153315
    33163316    if (!cbInc) /* Nothing to do? Bail out early. */
    33173317        return;
    33183318
    3319     PHDABDLE pBDLE = &pStrmSt->State.BDLE;
     3319    PHDABDLE pBDLE = &pStream->State.BDLE;
    33203320
    33213321    /*
     
    33263326    if (pBDLE->State.cbBelowFIFOW == 0) /* Did we hit (or exceed) the watermark? */
    33273327    {
    3328         uint32_t u32LPIB = HDA_STREAM_REG(pThis, LPIB, pStrmSt->u8SD);
    3329 
    3330         AssertMsg(((u32LPIB + cbInc) <= pStrmSt->u32CBL),
     3328        uint32_t u32LPIB = HDA_STREAM_REG(pThis, LPIB, pStream->u8SD);
     3329
     3330        AssertMsg(((u32LPIB + cbInc) <= pStream->u32CBL),
    33313331                  ("[SD%RU8] Increment (%RU32) exceeds CBL (%RU32): LPIB (%RU32)\n",
    3332                    pStrmSt->u8SD, cbInc, pStrmSt->u32CBL, u32LPIB));
    3333 
    3334         u32LPIB = RT_MIN(u32LPIB + cbInc, pStrmSt->u32CBL);
     3332                   pStream->u8SD, cbInc, pStream->u32CBL, u32LPIB));
     3333
     3334        u32LPIB = RT_MIN(u32LPIB + cbInc, pStream->u32CBL);
    33353335
    33363336        LogFlowFunc(("[SD%RU8]: LPIB: %RU32 -> %RU32, CBL=%RU32\n",
    3337                      pStrmSt->u8SD,
    3338                      HDA_STREAM_REG(pThis, LPIB, pStrmSt->u8SD), HDA_STREAM_REG(pThis, LPIB, pStrmSt->u8SD) + cbInc,
    3339                      pStrmSt->u32CBL));
    3340 
    3341         hdaStreamUpdateLPIB(pThis, pStrmSt, u32LPIB);
     3337                     pStream->u8SD,
     3338                     HDA_STREAM_REG(pThis, LPIB, pStream->u8SD), HDA_STREAM_REG(pThis, LPIB, pStream->u8SD) + cbInc,
     3339                     pStream->u32CBL));
     3340
     3341        hdaStreamUpdateLPIB(pThis, pStream, u32LPIB);
    33423342    }
    33433343}
     
    33923392 *       but "reports bytes" when all conditions are met (FIFOW).
    33933393 */
    3394 static int hdaReadAudio(PHDASTATE pThis, PHDASTREAM pStrmSt, uint32_t cbMax, uint32_t *pcbRead)
     3394static int hdaReadAudio(PHDASTATE pThis, PHDASTREAM pStream, uint32_t cbMax, uint32_t *pcbRead)
    33953395{
    33963396    AssertPtrReturn(pThis,   VERR_INVALID_POINTER);
    3397     AssertPtrReturn(pStrmSt, VERR_INVALID_POINTER);
     3397    AssertPtrReturn(pStream, VERR_INVALID_POINTER);
    33983398    /* pcbRead is optional. */
    33993399
     
    34033403    do
    34043404    {
    3405         PHDABDLE pBDLE = &pStrmSt->State.BDLE;
    3406 
    3407         uint32_t cbBuf = hdaStreamGetTransferSize(pThis, pStrmSt, cbMax);
     3405        PHDABDLE pBDLE = &pStream->State.BDLE;
     3406
     3407        uint32_t cbBuf = hdaStreamGetTransferSize(pThis, pStream, cbMax);
    34083408        Log3Func(("cbBuf=%RU32, %R[bdle]\n", cbBuf, pBDLE));
    34093409
     
    34143414        }
    34153415
    3416         AssertPtr(pStrmSt->pMixSink);
    3417         AssertPtr(pStrmSt->pMixSink->pMixSink);
    3418         rc = AudioMixerSinkRead(pStrmSt->pMixSink->pMixSink, AUDMIXOP_BLEND, pBDLE->State.au8FIFO, cbBuf, &cbRead);
     3416        AssertPtr(pStream->pMixSink);
     3417        AssertPtr(pStream->pMixSink->pMixSink);
     3418        rc = AudioMixerSinkRead(pStream->pMixSink->pMixSink, AUDMIXOP_BLEND, pBDLE->State.au8FIFO, cbBuf, &cbRead);
    34193419        if (RT_FAILURE(rc))
    34203420            break;
     
    34293429        Assert(cbRead <= cbBuf);
    34303430        Assert(cbRead <= pBDLE->u32BufSize - pBDLE->State.u32BufOff);
    3431         Assert(cbRead <= pStrmSt->u16FIFOS);
     3431        Assert(cbRead <= pStream->u16FIFOS);
    34323432
    34333433        /*
     
    34393439        AssertRC(rc);
    34403440
    3441         if (pBDLE->State.cbBelowFIFOW + cbRead > hdaStreamGetFIFOW(pThis, pStrmSt))
     3441        if (pBDLE->State.cbBelowFIFOW + cbRead > hdaStreamGetFIFOW(pThis, pStream))
    34423442        {
    34433443            pBDLE->State.u32BufOff    += cbRead;
     
    34493449            pBDLE->State.u32BufOff    += cbRead;
    34503450            pBDLE->State.cbBelowFIFOW += cbRead;
    3451             Assert(pBDLE->State.cbBelowFIFOW <= hdaStreamGetFIFOW(pThis, pStrmSt));
     3451            Assert(pBDLE->State.cbBelowFIFOW <= hdaStreamGetFIFOW(pThis, pStream));
    34523452            //hdaBackendTransferUnreported(pThis, pBDLE, pStreamDesc, cbRead, pcbAvail);
    34533453
     
    34673467}
    34683468
    3469 static int hdaWriteAudio(PHDASTATE pThis, PHDASTREAM pStrmSt, uint32_t cbMax, uint32_t *pcbWritten)
     3469static int hdaWriteAudio(PHDASTATE pThis, PHDASTREAM pStream, uint32_t cbMax, uint32_t *pcbWritten)
    34703470{
    34713471    AssertPtrReturn(pThis,      VERR_INVALID_POINTER);
    3472     AssertPtrReturn(pStrmSt,    VERR_INVALID_POINTER);
     3472    AssertPtrReturn(pStream,    VERR_INVALID_POINTER);
    34733473    AssertPtrReturn(pcbWritten, VERR_INVALID_POINTER);
    34743474    /* pcbWritten is optional. */
    34753475
    3476     PHDABDLE pBDLE = &pStrmSt->State.BDLE;
     3476    PHDABDLE pBDLE = &pStream->State.BDLE;
    34773477
    34783478    uint32_t cbWritten = 0;
    3479     uint32_t cbToWrite = hdaStreamGetTransferSize(pThis, pStrmSt, cbMax);
     3479    uint32_t cbToWrite = hdaStreamGetTransferSize(pThis, pStream, cbMax);
    34803480
    34813481    Log3Func(("cbToWrite=%RU32, %R[bdle]\n", cbToWrite, pBDLE));
     
    35173517         * Write to audio backend. We should ensure that we have enough bytes to copy to the backend.
    35183518         */
    3519         if (cbBuf >= hdaStreamGetFIFOW(pThis, pStrmSt))
     3519        if (cbBuf >= hdaStreamGetFIFOW(pThis, pStream))
    35203520        {
    3521             PHDASTREAMMAPPING pMapping            = &pStrmSt->State.Mapping;
     3521            PHDASTREAMMAPPING pMapping            = &pStream->State.Mapping;
    35223522
    35233523            /** @todo Which channel is which? */
     
    35943594            pBDLE->State.u32BufOff += cbWritten;
    35953595            pBDLE->State.cbBelowFIFOW += cbWritten;
    3596             Assert(pBDLE->State.cbBelowFIFOW <= hdaStreamGetFIFOW(pThis, pStrmSt));
     3596            Assert(pBDLE->State.cbBelowFIFOW <= hdaStreamGetFIFOW(pThis, pStream));
    35973597
    35983598            /* Not enough bytes to be processed and reported, we'll try our luck next time around. */
     
    36023602    }
    36033603
    3604     Assert(cbWritten <= pStrmSt->u16FIFOS);
     3604    Assert(cbWritten <= pStream->u16FIFOS);
    36053605
    36063606    if (RT_SUCCESS(rc))
     
    41134113#if 0
    41144114    Log3Func(("[SD%RU8] fProceed=%RTbool, fRun=%RTbool, cbToProcess=%RU32\n",
    4115               pStrmSt->u8SD, fProceed, HDA_STREAM_REG(pThis, CTL, pStrmSt->u8SD) & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN),
     4115              pStream->u8SD, fProceed, HDA_STREAM_REG(pThis, CTL, pStream->u8SD) & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN),
    41164116              cbToProcess));
    41174117#endif
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