Changeset 82417 in vbox for trunk/src/VBox/Devices/Audio
- Timestamp:
- Dec 5, 2019 1:31:38 PM (5 years ago)
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevHDA.cpp
r82406 r82417 507 507 SSMFIELD_ENTRY(HDASTREAMPERIOD, u64StartWalClk), 508 508 SSMFIELD_ENTRY(HDASTREAMPERIOD, u64ElapsedWalClk), 509 SSMFIELD_ENTRY(HDASTREAMPERIOD, framesTransferred),509 SSMFIELD_ENTRY(HDASTREAMPERIOD, cFramesTransferred), 510 510 SSMFIELD_ENTRY(HDASTREAMPERIOD, cIntPending), 511 511 SSMFIELD_ENTRY_TERM() … … 2786 2786 { 2787 2787 # ifdef DEBUG 2788 PHDASTREAMD BGINFOpStreamDbg = &pStream->Dbg;2788 PHDASTREAMDEBUG pStreamDbg = &pStream->Dbg; 2789 2789 2790 2790 const uint64_t tsNowNs = RTTimeNanoTS(); -
trunk/src/VBox/Devices/Audio/DevHDA.h
r82406 r82417 101 101 102 102 /** 103 * ICH Intel HD Audio Controller state.103 * Shared ICH Intel HD audio controller state. 104 104 */ 105 105 typedef struct HDASTATE … … 226 226 * This is set to HDASTATE_ALIGNMENT_CHECK_MAGIC. */ 227 227 uint64_t uAlignmentCheckMagic; 228 } HDASTATE, *PHDASTATE; 228 } HDASTATE; 229 /** Pointer to a shared HDA device state. */ 230 typedef HDASTATE *PHDASTATE; 229 231 230 232 /** Value for HDASTATE:uAlignmentCheckMagic. */ -
trunk/src/VBox/Devices/Audio/DevHDACommon.h
r82406 r82417 535 535 536 536 537 /** The HDA controller. */537 /** Pointer to a shared HDA state. */ 538 538 typedef struct HDASTATE *PHDASTATE; 539 /** The HDA stream. */539 /** Pointer to a HDA stream state. */ 540 540 typedef struct HDASTREAM *PHDASTREAM; 541 541 /** Pointer to a mixer sink. */ 542 542 typedef struct HDAMIXERSINK *PHDAMIXERSINK; 543 543 -
trunk/src/VBox/Devices/Audio/HDACodec.cpp
r82399 r82417 2712 2712 * HDA codec verb map. 2713 2713 * @todo Any reason not to use binary search here? 2714 * bird: because you'd need to sort the entries first... 2714 2715 */ 2715 2716 static const CODECVERB g_aCodecVerbs[] = -
trunk/src/VBox/Devices/Audio/HDAStream.cpp
r82345 r82417 924 924 925 925 PHDASTREAMPERIOD pPeriod = &pStream->State.Period; 926 if (!hdaR3StreamPeriodLock(pPeriod)) 927 return VERR_ACCESS_DENIED; 926 hdaR3StreamPeriodLock(pPeriod)) 928 927 929 928 bool fProceed = true; -
trunk/src/VBox/Devices/Audio/HDAStream.h
r82406 r82417 1 1 /* $Id$ */ 2 2 /** @file 3 * HDAStream.h - Stream functions for HD Audio.3 * HDAStream.h - Streams for HD Audio. 4 4 */ 5 5 … … 23 23 24 24 #include "DevHDACommon.h" 25 26 25 #include "HDAStreamMap.h" 27 26 #include "HDAStreamPeriod.h" 28 27 29 28 30 typedef struct HDAMIXERSINK *PHDAMIXERSINK;31 32 29 #ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO 33 30 /** 34 * Structure keeping theHDA stream's state for asynchronous I/O.31 * HDA stream's state for asynchronous I/O. 35 32 */ 36 33 typedef struct HDASTREAMSTATEAIO 37 34 { 38 35 /** Thread handle for the actual I/O thread. */ 39 RTTHREAD Thread;36 RTTHREAD Thread; 40 37 /** Event for letting the thread know there is some data to process. */ 41 RTSEMEVENT Event;38 RTSEMEVENT Event; 42 39 /** Critical section for synchronizing access. */ 43 RTCRITSECT CritSect;40 RTCRITSECT CritSect; 44 41 /** Started indicator. */ 45 volatile bool fStarted;42 volatile bool fStarted; 46 43 /** Shutdown indicator. */ 47 volatile bool fShutdown;44 volatile bool fShutdown; 48 45 /** 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. */ 50 typedef HDASTREAMSTATEAIO *PHDASTREAMSTATEAIO; 52 51 #endif 53 52 … … 55 54 * Structure containing HDA stream debug stuff, configurable at runtime. 56 55 */ 57 typedef struct HDASTREAMD BGINFORT56 typedef struct HDASTREAMDEBUGRT 58 57 { 59 58 /** Whether debugging is enabled or not. */ … … 70 69 /** File for dumping mapped (that is, extracted) DMA reads / writes. */ 71 70 R3PTRTYPE(PPDMAUDIOFILE) pFileDMAMapped; 72 } HDASTREAMD BGINFORT, *PHDASTREAMDBGINFORT;71 } HDASTREAMDEBUGRT; 73 72 74 73 /** 75 74 * Structure containing HDA stream debug information. 76 75 */ 77 typedef struct HDASTREAMD BGINFO76 typedef struct HDASTREAMDEBUG 78 77 { 79 78 #ifdef DEBUG … … 106 105 #endif 107 106 /** Runtime debug info. */ 108 HDASTREAMDBGINFORT Runtime; 109 } HDASTREAMDBGINFO ,*PHDASTREAMDBGINFO; 107 HDASTREAMDEBUGRT Runtime; 108 } HDASTREAMDEBUG; 109 typedef HDASTREAMDEBUG *PHDASTREAMDEBUG; 110 110 111 111 /** … … 185 185 } HDASTREAMSTATE; 186 186 AssertCompileSizeAlignment(HDASTREAMSTATE, 8); 187 /** Pointer to the internal state of an HDA stream. */ 187 188 typedef HDASTREAMSTATE *PHDASTREAMSTATE; 188 189 … … 204 205 { 205 206 /** Stream descriptor number (SDn). */ 206 uint8_t u8SD;207 uint8_t u8SD; 207 208 /** Current channel index. 208 209 * 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]; 211 212 /** DMA base address (SDnBDPU - SDnBDPL). 212 213 * Will be updated in hdaR3StreamInit(). */ 213 uint64_t u64BDLBase;214 uint64_t u64BDLBase; 214 215 /** Cyclic Buffer Length (SDnCBL). 215 216 * Represents the size of the ring buffer. 216 217 * Will be updated in hdaR3StreamInit(). */ 217 uint32_t u32CBL;218 uint32_t u32CBL; 218 219 /** Format (SDnFMT). 219 220 * Will be updated in hdaR3StreamInit(). */ 220 uint16_t u16FMT;221 uint16_t u16FMT; 221 222 /** FIFO Size (FIFOS). 222 223 * Maximum number of bytes that may have been DMA'd into … … 224 225 * 225 226 * Will be updated in hdaR3StreamInit(). */ 226 uint16_t u16FIFOS;227 uint16_t u16FIFOS; 227 228 /** FIFO Watermark. */ 228 uint16_t u16FIFOW;229 uint16_t u16FIFOW; 229 230 /** Last Valid Index (SDnLVI). 230 231 * Will be updated in hdaR3StreamInit(). */ 231 uint16_t u16LVI;232 uint16_t Padding1[2];232 uint16_t u16LVI; 233 uint16_t au16Padding1[2]; 233 234 /** Pointer to the HDA state this stream is attached to. */ 234 R3PTRTYPE(PHDASTATE) pHDAState;235 R3PTRTYPE(PHDASTATE) pHDAState; 235 236 /** Pointer to HDA sink this stream is attached to. */ 236 R3PTRTYPE(PHDAMIXERSINK) pMixSink;237 R3PTRTYPE(PHDAMIXERSINK) pMixSink; 237 238 /** The timer for pumping data thru the attached LUN drivers. */ 238 TMTIMERHANDLE hTimer;239 TMTIMERHANDLE hTimer; 239 240 /** The stream'S critical section to serialize access. */ 240 RTCRITSECT CritSect;241 RTCRITSECT CritSect; 241 242 /** Internal state of this stream. */ 242 HDASTREAMSTATE State;243 HDASTREAMSTATE State; 243 244 /** Debug information. */ 244 HDASTREAMD BGINFODbg;245 HDASTREAMDEBUG Dbg; 245 246 } HDASTREAM; 246 247 /** Pointer to an HDA stream (SDI / SDO). */ … … 282 283 bool hdaR3StreamRegisterDMAHandlers(PHDASTREAM pStream); 283 284 void hdaR3StreamUnregisterDMAHandlers(PHDASTREAM pStream); 284 # endif /* HDA_USE_DMA_ACCESS_HANDLER */285 # endif 285 286 /** @} */ 286 287 /** @name Timer functions.288 * @{289 */290 DECLCALLBACK(void) hdaR3StreamTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser);291 /** @} */292 293 287 294 288 /** @name Async I/O stream functions. -
trunk/src/VBox/Devices/Audio/HDAStreamPeriod.cpp
r82406 r82417 106 106 cTotalPeriods = 2; /* At least two periods *must* be present (LVI >= 1). */ 107 107 108 uint32_t framesToTransfer = (u32CBL / 4 /** @todo Define frame size? */) / cTotalPeriods;108 uint32_t cFramesToTransfer = (u32CBL / 4 /** @todo Define frame size? */) / cTotalPeriods; 109 109 110 110 pPeriod->u8SD = u8SD; 111 111 pPeriod->u64StartWalClk = 0; 112 112 pPeriod->u32Hz = pStreamCfg->Props.uHz; 113 pPeriod->u64DurationWalClk = hdaR3StreamPeriodFramesToWalClk(pPeriod, framesToTransfer);113 pPeriod->u64DurationWalClk = hdaR3StreamPeriodFramesToWalClk(pPeriod, cFramesToTransfer); 114 114 pPeriod->u64ElapsedWalClk = 0; 115 115 pPeriod->i64DelayWalClk = 0; 116 pPeriod-> framesToTransfer = framesToTransfer;117 pPeriod-> framesTransferred = 0;116 pPeriod->cFramesToTransfer = cFramesToTransfer; 117 pPeriod->cFramesTransferred = 0; 118 118 pPeriod->cIntPending = 0; 119 119 120 120 Log3Func(("[SD%RU8] %RU64 long, Hz=%RU32, CBL=%RU32, LVI=%RU16 -> %u periods, %RU32 frames each\n", 121 121 pPeriod->u8SD, pPeriod->u64DurationWalClk, pPeriod->u32Hz, u32CBL, u16LVI, 122 cTotalPeriods, pPeriod-> framesToTransfer));122 cTotalPeriods, pPeriod->cFramesToTransfer)); 123 123 124 124 return VINF_SUCCESS; … … 141 141 pPeriod->u64StartWalClk = 0; 142 142 pPeriod->u64ElapsedWalClk = 0; 143 pPeriod-> framesTransferred = 0;143 pPeriod->cFramesTransferred = 0; 144 144 pPeriod->cIntPending = 0; 145 145 # ifdef LOG_ENABLED … … 162 162 pPeriod->u64StartWalClk = u64WalClk; 163 163 pPeriod->u64ElapsedWalClk = 0; 164 pPeriod-> framesTransferred = 0;164 pPeriod->cFramesTransferred = 0; 165 165 pPeriod->cIntPending = 0; 166 166 # ifdef LOG_ENABLED … … 224 224 * Locks a stream period for serializing access. 225 225 * 226 * @return true if locking was successful, false if not.226 * @returns IPRT status code (safe to ignore, asserted). 227 227 * @param pPeriod Stream period to lock. 228 228 */ 229 bool hdaR3StreamPeriodLock(PHDASTREAMPERIOD pPeriod) 230 { 231 return RT_SUCCESS(RTCritSectEnter(&pPeriod->CritSect)); 229 int hdaR3StreamPeriodLock(PHDASTREAMPERIOD pPeriod) 230 { 231 int rc = RTCritSectEnter(&pPeriod->CritSect); 232 AssertRC(rc); 233 return rc; 232 234 } 233 235 … … 295 297 uint32_t hdaR3StreamPeriodGetRemainingFrames(PHDASTREAMPERIOD pPeriod) 296 298 { 297 Assert(pPeriod-> framesToTransfer >= pPeriod->framesTransferred);298 return pPeriod-> framesToTransfer - pPeriod->framesTransferred;299 Assert(pPeriod->cFramesToTransfer >= pPeriod->cFramesTransferred); 300 return pPeriod->cFramesToTransfer - pPeriod->cFramesTransferred; 299 301 } 300 302 … … 385 387 void hdaR3StreamPeriodInc(PHDASTREAMPERIOD pPeriod, uint32_t framesInc) 386 388 { 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); 391 393 Assert(pPeriod->u64ElapsedWalClk <= pPeriod->u64DurationWalClk); 392 394 393 395 Log3Func(("[SD%RU8] cbTransferred=%RU32, u64ElapsedWalClk=%RU64\n", 394 pPeriod->u8SD, pPeriod-> framesTransferred, pPeriod->u64ElapsedWalClk));396 pPeriod->u8SD, pPeriod->cFramesTransferred, pPeriod->u64ElapsedWalClk)); 395 397 } 396 398 … … 409 411 hdaR3StreamPeriodHasElapsed(pPeriod) 410 412 /* All frames transferred? */ 411 && pPeriod-> framesTransferred >= pPeriod->framesToTransfer;413 && pPeriod->cFramesTransferred >= pPeriod->cFramesToTransfer; 412 414 # ifdef VBOX_STRICT 413 415 if (fIsComplete) 414 416 { 415 Assert(pPeriod-> framesTransferred == pPeriod->framesToTransfer);417 Assert(pPeriod->cFramesTransferred == pPeriod->cFramesToTransfer); 416 418 Assert(pPeriod->u64ElapsedWalClk == pPeriod->u64DurationWalClk); 417 419 } -
trunk/src/VBox/Devices/Audio/HDAStreamPeriod.h
r82406 r82417 28 28 #include <VBox/log.h> /* LOG_ENABLED */ 29 29 30 struct HDASTREAM;31 typedef struct HDASTREAM *PHDASTREAM;32 30 33 31 #ifdef LOG_ENABLED … … 35 33 * Debug stuff for a HDA stream's period. 36 34 */ 37 typedef struct HDASTREAMPERIODD DEBUG35 typedef struct HDASTREAMPERIODDEBUG 38 36 { 39 37 /** Host start time (in ns) of the period. */ 40 38 uint64_t tsStartNs; 41 } HDASTREAMPERIODD DEBUG;39 } HDASTREAMPERIODDEBUG; 42 40 #endif 43 41 … … 56 54 typedef struct HDASTREAMPERIOD 57 55 { 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. */ 59 59 RTCRITSECT CritSect; 60 60 /** Associated HDA stream descriptor (SD) number. */ … … 76 76 int64_t i64DelayWalClk; 77 77 /** Number of audio frames to transfer for this period. */ 78 uint32_t framesToTransfer;78 uint32_t cFramesToTransfer; 79 79 /** Number of audio frames already transfered. */ 80 uint32_t framesTransferred;80 uint32_t cFramesTransferred; 81 81 #ifdef LOG_ENABLED 82 82 /** Debugging state. */ 83 HDASTREAMPERIODD DEBUGDbg;83 HDASTREAMPERIODDEBUG Dbg; 84 84 #endif 85 85 } HDASTREAMPERIOD; … … 97 97 void hdaR3StreamPeriodPause(PHDASTREAMPERIOD pPeriod); 98 98 void hdaR3StreamPeriodResume(PHDASTREAMPERIOD pPeriod); 99 boolhdaR3StreamPeriodLock(PHDASTREAMPERIOD pPeriod);99 int hdaR3StreamPeriodLock(PHDASTREAMPERIOD pPeriod); 100 100 void hdaR3StreamPeriodUnlock(PHDASTREAMPERIOD pPeriod); 101 101 uint64_t hdaR3StreamPeriodFramesToWalClk(PHDASTREAMPERIOD pPeriod, uint32_t uFrames);
Note:
See TracChangeset
for help on using the changeset viewer.