VirtualBox

Changeset 82417 in vbox for trunk/src/VBox/Devices/Audio


Ignore:
Timestamp:
Dec 5, 2019 1:31:38 PM (5 years ago)
Author:
vboxsync
Message:

DevHDA: More cleanups. bugref:9218

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

Legend:

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

    r82406 r82417  
    507507    SSMFIELD_ENTRY(HDASTREAMPERIOD, u64StartWalClk),
    508508    SSMFIELD_ENTRY(HDASTREAMPERIOD, u64ElapsedWalClk),
    509     SSMFIELD_ENTRY(HDASTREAMPERIOD, framesTransferred),
     509    SSMFIELD_ENTRY(HDASTREAMPERIOD, cFramesTransferred),
    510510    SSMFIELD_ENTRY(HDASTREAMPERIOD, cIntPending),
    511511    SSMFIELD_ENTRY_TERM()
     
    27862786        {
    27872787#  ifdef DEBUG
    2788             PHDASTREAMDBGINFO pStreamDbg = &pStream->Dbg;
     2788            PHDASTREAMDEBUG pStreamDbg = &pStream->Dbg;
    27892789
    27902790            const uint64_t tsNowNs     = RTTimeNanoTS();
  • trunk/src/VBox/Devices/Audio/DevHDA.h

    r82406 r82417  
    101101
    102102/**
    103  * ICH Intel HD Audio Controller state.
     103 * Shared ICH Intel HD audio controller state.
    104104 */
    105105typedef struct HDASTATE
     
    226226     *  This is set to HDASTATE_ALIGNMENT_CHECK_MAGIC. */
    227227    uint64_t                uAlignmentCheckMagic;
    228 } HDASTATE, *PHDASTATE;
     228} HDASTATE;
     229/** Pointer to a shared HDA device state.  */
     230typedef HDASTATE *PHDASTATE;
    229231
    230232/** Value for HDASTATE:uAlignmentCheckMagic. */
  • trunk/src/VBox/Devices/Audio/DevHDACommon.h

    r82406 r82417  
    535535
    536536
    537 /** The HDA controller. */
     537/** Pointer to a shared HDA state. */
    538538typedef struct HDASTATE *PHDASTATE;
    539 /** The HDA stream. */
     539/** Pointer to a HDA stream state. */
    540540typedef struct HDASTREAM *PHDASTREAM;
    541 
     541/** Pointer to a mixer sink. */
    542542typedef struct HDAMIXERSINK *PHDAMIXERSINK;
    543543
  • trunk/src/VBox/Devices/Audio/HDACodec.cpp

    r82399 r82417  
    27122712 * HDA codec verb map.
    27132713 * @todo Any reason not to use binary search here?
     2714 *      bird: because you'd need to sort the entries first...
    27142715 */
    27152716static const CODECVERB g_aCodecVerbs[] =
  • trunk/src/VBox/Devices/Audio/HDAStream.cpp

    r82345 r82417  
    924924
    925925    PHDASTREAMPERIOD pPeriod = &pStream->State.Period;
    926     if (!hdaR3StreamPeriodLock(pPeriod))
    927         return VERR_ACCESS_DENIED;
     926    hdaR3StreamPeriodLock(pPeriod))
    928927
    929928    bool fProceed = true;
  • trunk/src/VBox/Devices/Audio/HDAStream.h

    r82406 r82417  
    11/* $Id$ */
    22/** @file
    3  * HDAStream.h - Stream functions for HD Audio.
     3 * HDAStream.h - Streams for HD Audio.
    44 */
    55
     
    2323
    2424#include "DevHDACommon.h"
    25 
    2625#include "HDAStreamMap.h"
    2726#include "HDAStreamPeriod.h"
    2827
    2928
    30 typedef struct HDAMIXERSINK *PHDAMIXERSINK;
    31 
    3229#ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO
    3330/**
    34  * Structure keeping the HDA stream's state for asynchronous I/O.
     31 * HDA stream's state for asynchronous I/O.
    3532 */
    3633typedef struct HDASTREAMSTATEAIO
    3734{
    3835    /** Thread handle for the actual I/O thread. */
    39     RTTHREAD              Thread;
     36    RTTHREAD                Thread;
    4037    /** Event for letting the thread know there is some data to process. */
    41     RTSEMEVENT            Event;
     38    RTSEMEVENT              Event;
    4239    /** Critical section for synchronizing access. */
    43     RTCRITSECT            CritSect;
     40    RTCRITSECT              CritSect;
    4441    /** Started indicator. */
    45     volatile bool         fStarted;
     42    volatile bool           fStarted;
    4643    /** Shutdown indicator. */
    47     volatile bool         fShutdown;
     44    volatile bool           fShutdown;
    4845    /** Whether the thread should do any data processing or not. */
    49     volatile bool         fEnabled;
    50     uint32_t              Padding1;
    51 } HDASTREAMSTATEAIO, *PHDASTREAMSTATEAIO;
     46    volatile bool           fEnabled;
     47    bool                    afPadding[1+4];
     48} HDASTREAMSTATEAIO;
     49/** Pointer to a HDA stream's asynchronous I/O state. */
     50typedef HDASTREAMSTATEAIO *PHDASTREAMSTATEAIO;
    5251#endif
    5352
     
    5554 * Structure containing HDA stream debug stuff, configurable at runtime.
    5655 */
    57 typedef struct HDASTREAMDBGINFORT
     56typedef struct HDASTREAMDEBUGRT
    5857{
    5958    /** Whether debugging is enabled or not. */
     
    7069    /** File for dumping mapped (that is, extracted) DMA reads / writes. */
    7170    R3PTRTYPE(PPDMAUDIOFILE) pFileDMAMapped;
    72 } HDASTREAMDBGINFORT, *PHDASTREAMDBGINFORT;
     71} HDASTREAMDEBUGRT;
    7372
    7473/**
    7574 * Structure containing HDA stream debug information.
    7675 */
    77 typedef struct HDASTREAMDBGINFO
     76typedef struct HDASTREAMDEBUG
    7877{
    7978#ifdef DEBUG
     
    106105#endif
    107106    /** Runtime debug info. */
    108     HDASTREAMDBGINFORT      Runtime;
    109 } HDASTREAMDBGINFO ,*PHDASTREAMDBGINFO;
     107    HDASTREAMDEBUGRT        Runtime;
     108} HDASTREAMDEBUG;
     109typedef HDASTREAMDEBUG *PHDASTREAMDEBUG;
    110110
    111111/**
     
    185185} HDASTREAMSTATE;
    186186AssertCompileSizeAlignment(HDASTREAMSTATE, 8);
     187/** Pointer to the internal state of an HDA stream. */
    187188typedef HDASTREAMSTATE *PHDASTREAMSTATE;
    188189
     
    204205{
    205206    /** Stream descriptor number (SDn). */
    206     uint8_t                  u8SD;
     207    uint8_t                     u8SD;
    207208    /** Current channel index.
    208209     *  For a stereo stream, this is u8Channel + 1. */
    209     uint8_t                  u8Channel;
    210     uint8_t                  Padding0[6];
     210    uint8_t                     u8Channel;
     211    uint8_t                     abPadding0[6];
    211212    /** DMA base address (SDnBDPU - SDnBDPL).
    212213     *  Will be updated in hdaR3StreamInit(). */
    213     uint64_t                 u64BDLBase;
     214    uint64_t                    u64BDLBase;
    214215    /** Cyclic Buffer Length (SDnCBL).
    215216     *  Represents the size of the ring buffer.
    216217     *  Will be updated in hdaR3StreamInit(). */
    217     uint32_t                 u32CBL;
     218    uint32_t                    u32CBL;
    218219    /** Format (SDnFMT).
    219220     *  Will be updated in hdaR3StreamInit(). */
    220     uint16_t                 u16FMT;
     221    uint16_t                    u16FMT;
    221222    /** FIFO Size (FIFOS).
    222223     *  Maximum number of bytes that may have been DMA'd into
     
    224225     *
    225226     *  Will be updated in hdaR3StreamInit(). */
    226     uint16_t                 u16FIFOS;
     227    uint16_t                    u16FIFOS;
    227228    /** FIFO Watermark. */
    228     uint16_t                 u16FIFOW;
     229    uint16_t                    u16FIFOW;
    229230    /** Last Valid Index (SDnLVI).
    230231     *  Will be updated in hdaR3StreamInit(). */
    231     uint16_t                 u16LVI;
    232     uint16_t                 Padding1[2];
     232    uint16_t                    u16LVI;
     233    uint16_t                    au16Padding1[2];
    233234    /** Pointer to the HDA state this stream is attached to. */
    234     R3PTRTYPE(PHDASTATE)     pHDAState;
     235    R3PTRTYPE(PHDASTATE)        pHDAState;
    235236    /** Pointer to HDA sink this stream is attached to. */
    236     R3PTRTYPE(PHDAMIXERSINK) pMixSink;
     237    R3PTRTYPE(PHDAMIXERSINK)    pMixSink;
    237238    /** The timer for pumping data thru the attached LUN drivers. */
    238     TMTIMERHANDLE            hTimer;
     239    TMTIMERHANDLE               hTimer;
    239240    /** The stream'S critical section to serialize access. */
    240     RTCRITSECT               CritSect;
     241    RTCRITSECT                  CritSect;
    241242    /** Internal state of this stream. */
    242     HDASTREAMSTATE           State;
     243    HDASTREAMSTATE              State;
    243244    /** Debug information. */
    244     HDASTREAMDBGINFO         Dbg;
     245    HDASTREAMDEBUG              Dbg;
    245246} HDASTREAM;
    246247/** Pointer to an HDA stream (SDI / SDO).  */
     
    282283bool              hdaR3StreamRegisterDMAHandlers(PHDASTREAM pStream);
    283284void              hdaR3StreamUnregisterDMAHandlers(PHDASTREAM pStream);
    284 # endif /* HDA_USE_DMA_ACCESS_HANDLER */
     285# endif
    285286/** @} */
    286 
    287 /** @name Timer functions.
    288  * @{
    289  */
    290 DECLCALLBACK(void) hdaR3StreamTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser);
    291 /** @} */
    292 
    293287
    294288/** @name Async I/O stream functions.
  • trunk/src/VBox/Devices/Audio/HDAStreamPeriod.cpp

    r82406 r82417  
    106106        cTotalPeriods = 2; /* At least two periods *must* be present (LVI >= 1). */
    107107
    108     uint32_t framesToTransfer = (u32CBL / 4 /** @todo Define frame size? */) / cTotalPeriods;
     108    uint32_t cFramesToTransfer = (u32CBL / 4 /** @todo Define frame size? */) / cTotalPeriods;
    109109
    110110    pPeriod->u8SD              = u8SD;
    111111    pPeriod->u64StartWalClk    = 0;
    112112    pPeriod->u32Hz             = pStreamCfg->Props.uHz;
    113     pPeriod->u64DurationWalClk = hdaR3StreamPeriodFramesToWalClk(pPeriod, framesToTransfer);
     113    pPeriod->u64DurationWalClk = hdaR3StreamPeriodFramesToWalClk(pPeriod, cFramesToTransfer);
    114114    pPeriod->u64ElapsedWalClk  = 0;
    115115    pPeriod->i64DelayWalClk    = 0;
    116     pPeriod->framesToTransfer  = framesToTransfer;
    117     pPeriod->framesTransferred = 0;
     116    pPeriod->cFramesToTransfer  = cFramesToTransfer;
     117    pPeriod->cFramesTransferred = 0;
    118118    pPeriod->cIntPending       = 0;
    119119
    120120    Log3Func(("[SD%RU8] %RU64 long, Hz=%RU32, CBL=%RU32, LVI=%RU16 -> %u periods, %RU32 frames each\n",
    121121              pPeriod->u8SD, pPeriod->u64DurationWalClk, pPeriod->u32Hz, u32CBL, u16LVI,
    122               cTotalPeriods, pPeriod->framesToTransfer));
     122              cTotalPeriods, pPeriod->cFramesToTransfer));
    123123
    124124    return VINF_SUCCESS;
     
    141141    pPeriod->u64StartWalClk    = 0;
    142142    pPeriod->u64ElapsedWalClk  = 0;
    143     pPeriod->framesTransferred = 0;
     143    pPeriod->cFramesTransferred = 0;
    144144    pPeriod->cIntPending       = 0;
    145145# ifdef LOG_ENABLED
     
    162162    pPeriod->u64StartWalClk    = u64WalClk;
    163163    pPeriod->u64ElapsedWalClk  = 0;
    164     pPeriod->framesTransferred = 0;
     164    pPeriod->cFramesTransferred = 0;
    165165    pPeriod->cIntPending       = 0;
    166166# ifdef LOG_ENABLED
     
    224224 * Locks a stream period for serializing access.
    225225 *
    226  * @return  true if locking was successful, false if not.
     226 * @returns IPRT status code (safe to ignore, asserted).
    227227 * @param   pPeriod             Stream period to lock.
    228228 */
    229 bool hdaR3StreamPeriodLock(PHDASTREAMPERIOD pPeriod)
    230 {
    231     return RT_SUCCESS(RTCritSectEnter(&pPeriod->CritSect));
     229int hdaR3StreamPeriodLock(PHDASTREAMPERIOD pPeriod)
     230{
     231    int rc = RTCritSectEnter(&pPeriod->CritSect);
     232    AssertRC(rc);
     233    return rc;
    232234}
    233235
     
    295297uint32_t hdaR3StreamPeriodGetRemainingFrames(PHDASTREAMPERIOD pPeriod)
    296298{
    297     Assert(pPeriod->framesToTransfer >= pPeriod->framesTransferred);
    298     return pPeriod->framesToTransfer - pPeriod->framesTransferred;
     299    Assert(pPeriod->cFramesToTransfer >= pPeriod->cFramesTransferred);
     300    return pPeriod->cFramesToTransfer - pPeriod->cFramesTransferred;
    299301}
    300302
     
    385387void hdaR3StreamPeriodInc(PHDASTREAMPERIOD pPeriod, uint32_t framesInc)
    386388{
    387     pPeriod->framesTransferred += framesInc;
    388     Assert(pPeriod->framesTransferred <= pPeriod->framesToTransfer);
    389 
    390     pPeriod->u64ElapsedWalClk   = hdaR3StreamPeriodFramesToWalClk(pPeriod, pPeriod->framesTransferred);
     389    pPeriod->cFramesTransferred += framesInc;
     390    Assert(pPeriod->cFramesTransferred <= pPeriod->cFramesToTransfer);
     391
     392    pPeriod->u64ElapsedWalClk   = hdaR3StreamPeriodFramesToWalClk(pPeriod, pPeriod->cFramesTransferred);
    391393    Assert(pPeriod->u64ElapsedWalClk <= pPeriod->u64DurationWalClk);
    392394
    393395    Log3Func(("[SD%RU8] cbTransferred=%RU32, u64ElapsedWalClk=%RU64\n",
    394               pPeriod->u8SD, pPeriod->framesTransferred, pPeriod->u64ElapsedWalClk));
     396              pPeriod->u8SD, pPeriod->cFramesTransferred, pPeriod->u64ElapsedWalClk));
    395397}
    396398
     
    409411                                hdaR3StreamPeriodHasElapsed(pPeriod)
    410412                             /* All frames transferred? */
    411                              && pPeriod->framesTransferred >= pPeriod->framesToTransfer;
     413                             && pPeriod->cFramesTransferred >= pPeriod->cFramesToTransfer;
    412414# ifdef VBOX_STRICT
    413415    if (fIsComplete)
    414416    {
    415         Assert(pPeriod->framesTransferred == pPeriod->framesToTransfer);
     417        Assert(pPeriod->cFramesTransferred == pPeriod->cFramesToTransfer);
    416418        Assert(pPeriod->u64ElapsedWalClk  == pPeriod->u64DurationWalClk);
    417419    }
  • trunk/src/VBox/Devices/Audio/HDAStreamPeriod.h

    r82406 r82417  
    2828#include <VBox/log.h> /* LOG_ENABLED */
    2929
    30 struct HDASTREAM;
    31 typedef struct HDASTREAM *PHDASTREAM;
    3230
    3331#ifdef LOG_ENABLED
     
    3533 * Debug stuff for a HDA stream's period.
    3634 */
    37 typedef struct HDASTREAMPERIODDDEBUG
     35typedef struct HDASTREAMPERIODDEBUG
    3836{
    3937    /** Host start time (in ns) of the period. */
    4038    uint64_t                tsStartNs;
    41 } HDASTREAMPERIODDDEBUG;
     39} HDASTREAMPERIODDEBUG;
    4240#endif
    4341
     
    5654typedef struct HDASTREAMPERIOD
    5755{
    58     /** Critical section for serializing access. */
     56    /** Critical section for serializing access.
     57     * @todo r=bird: This is not needed.  The stream lock is held the two places
     58     *       this critsect is entered. */
    5959    RTCRITSECT              CritSect;
    6060    /** Associated HDA stream descriptor (SD) number. */
     
    7676    int64_t                 i64DelayWalClk;
    7777    /** Number of audio frames to transfer for this period. */
    78     uint32_t                framesToTransfer;
     78    uint32_t                cFramesToTransfer;
    7979    /** Number of audio frames already transfered. */
    80     uint32_t                framesTransferred;
     80    uint32_t                cFramesTransferred;
    8181#ifdef LOG_ENABLED
    8282    /** Debugging state. */
    83     HDASTREAMPERIODDDEBUG   Dbg;
     83    HDASTREAMPERIODDEBUG    Dbg;
    8484#endif
    8585} HDASTREAMPERIOD;
     
    9797void     hdaR3StreamPeriodPause(PHDASTREAMPERIOD pPeriod);
    9898void     hdaR3StreamPeriodResume(PHDASTREAMPERIOD pPeriod);
    99 bool     hdaR3StreamPeriodLock(PHDASTREAMPERIOD pPeriod);
     99int      hdaR3StreamPeriodLock(PHDASTREAMPERIOD pPeriod);
    100100void     hdaR3StreamPeriodUnlock(PHDASTREAMPERIOD pPeriod);
    101101uint64_t hdaR3StreamPeriodFramesToWalClk(PHDASTREAMPERIOD pPeriod, uint32_t uFrames);
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