Changeset 59182 in vbox for trunk/src/VBox/Devices/Audio/DevIchHda.cpp
- Timestamp:
- Dec 18, 2015 1:24:53 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevIchHda.cpp
r59174 r59182 737 737 bool fRCEnabled; 738 738 #ifndef VBOX_WITH_AUDIO_CALLBACKS 739 /** The emulation timer for handling the attached 740 * LUN drivers. */ 739 /** The timer for pumping data thru the attached LUN drivers. */ 741 740 PTMTIMERR3 pTimer; 742 /** Timer ticks for handling the LUN drivers. */ 743 uint64_t uTimerTicks; 744 /** Timestamp (delta) since last timer call. */ 741 /** The timer interval for pumping data thru the LUN drivers in timer ticks. */ 742 uint64_t cTimerTicks; 743 /** Timestamp of the last timer callback (hdaTimer). 744 * Used to calculate the time actually elapsed between two timer callbacks. */ 745 745 uint64_t uTimerTS; 746 746 #endif … … 756 756 union 757 757 { 758 /** List of associated LUN drivers . */758 /** List of associated LUN drivers (HDADRIVER). */ 759 759 RTLISTANCHOR lstDrv; 760 760 /** Padding for alignment. */ … … 3028 3028 static DECLCALLBACK(void) hdaTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 3029 3029 { 3030 PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); 3031 AssertPtrReturnVoid(pThis); 3030 PHDASTATE pThis = (PHDASTATE)pvUser; 3031 Assert(pThis == PDMINS_2_DATA(pDevIns, PHDASTATE)); 3032 AssertPtr(pThis); 3032 3033 3033 3034 STAM_PROFILE_START(&pThis->StatTimer, a); 3034 3035 int rc = VINF_SUCCESS;3036 3035 3037 3036 uint32_t cbInMax = 0; … … 3040 3039 PHDADRIVER pDrv; 3041 3040 3042 uint32_t cbIn, cbOut; 3043 3044 uint64_t uTicksNow = PDMDevHlpTMTimeVirtGet(pDevIns); 3045 uint64_t uTicksElapsed = uTicksNow - pThis->uTimerTS; 3046 uint64_t uTicksPerSec = PDMDevHlpTMTimeVirtGetFreq(pDevIns); 3041 uint64_t uTicksNow = TMTimerGet(pTimer); 3042 uint64_t cTicksElapsed = uTicksNow - pThis->uTimerTS; 3043 uint64_t cTicksPerSec = TMTimerGetFreq(pTimer); 3047 3044 3048 3045 pThis->uTimerTS = uTicksNow; … … 3050 3047 RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node) 3051 3048 { 3052 cbIn = cbOut = 0; 3053 rc = pDrv->pConnector->pfnQueryStatus(pDrv->pConnector, 3054 &cbIn, &cbOut, NULL /* cSamplesLive */); 3049 uint32_t cbIn = 0; 3050 uint32_t cbOut = 0; 3051 3052 int rc = pDrv->pConnector->pfnQueryStatus(pDrv->pConnector, &cbIn, &cbOut, NULL /* pcSamplesLive */); 3055 3053 if (RT_SUCCESS(rc)) 3056 rc = pDrv->pConnector->pfnPlayOut(pDrv->pConnector, NULL /* cSamplesPlayed */);3054 rc = pDrv->pConnector->pfnPlayOut(pDrv->pConnector, NULL /* pcSamplesPlayed */); 3057 3055 3058 3056 #ifdef DEBUG_TIMER … … 3070 3068 || !fIsActiveOut) 3071 3069 { 3072 uint32_t cSamplesMin = (int)((2 * uTicksElapsed * pDrv->Out.pStrmOut->Props.uHz + uTicksPerSec) / uTicksPerSec / 2);3070 uint32_t cSamplesMin = (int)((2 * cTicksElapsed * pDrv->Out.pStrmOut->Props.uHz + cTicksPerSec) / cTicksPerSec / 2); 3073 3071 uint32_t cbSamplesMin = AUDIOMIXBUF_S2B(&pDrv->Out.pStrmOut->MixBuf, cSamplesMin); 3074 3072 … … 3095 3093 3096 3094 /* Kick the timer again. */ 3097 TMTimerSet(pThis->pTimer, TMTimerGet(pThis->pTimer) + pThis->uTimerTicks); 3095 uint64_t cTicks = pThis->cTimerTicks; 3096 /** @todo adjust cTicks down by now much cbOutMin represents. */ 3097 TMTimerSet(pThis->pTimer, uTicksNow + cTicks); 3098 3098 3099 3099 STAM_PROFILE_STOP(&pThis->StatTimer, a); … … 4174 4174 if (pThis->pTimer) 4175 4175 { 4176 rc2 = TMTimerSet(pThis->pTimer, TMTimerGet(pThis->pTimer) + pThis-> uTimerTicks);4176 rc2 = TMTimerSet(pThis->pTimer, TMTimerGet(pThis->pTimer) + pThis->cTimerTicks); 4177 4177 AssertRC(rc2); 4178 4178 } … … 4632 4632 { 4633 4633 /** @todo Investigate why sounds is getting corrupted if the "ticks" value is too 4634 * low, e.g. "PDMDevHlpTMTimeVirtGetFreq / 200". */ 4635 pThis->uTimerTicks = PDMDevHlpTMTimeVirtGetFreq(pDevIns) / 500; /** @todo Make this configurable! */ 4636 pThis->uTimerTS = PDMDevHlpTMTimeVirtGet(pDevIns); 4637 if (pThis->uTimerTicks < 100) 4638 pThis->uTimerTicks = 100; 4639 LogFunc(("Timer ticks=%RU64\n", pThis->uTimerTicks)); 4634 * low, e.g. "PDMDevHlpTMTimeVirtGetFreq / 200". 4635 * Update: Because the guest doesn't prepare enough data at a time. */ 4636 pThis->cTimerTicks = TMTimerGetFreq(pThis->pTimer) / 500; /** @todo Make this configurable! */ 4637 pThis->uTimerTS = TMTimerGet(pThis->pTimer); 4638 LogFunc(("Timer ticks=%RU64\n", pThis->cTimerTicks)); 4640 4639 4641 4640 /* Fire off timer. */ 4642 TMTimerSet(pThis->pTimer, TMTimerGet(pThis->pTimer) + pThis-> uTimerTicks);4641 TMTimerSet(pThis->pTimer, TMTimerGet(pThis->pTimer) + pThis->cTimerTicks); 4643 4642 } 4644 4643 }
Note:
See TracChangeset
for help on using the changeset viewer.