- Timestamp:
- May 4, 2015 2:46:57 PM (10 years ago)
- svn:sync-xref-src-repo-rev:
- 100024
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvHostNullAudio.cpp
r54967 r55649 61 61 /** Note: Always must come first! */ 62 62 PDMAUDIOHSTSTRMOUT hw; 63 uint64_t u64TicksLast; 63 64 } NULLAUDIOSTREAMOUT; 64 65 … … 134 135 if (RT_SUCCESS(rc)) 135 136 { 137 NULLAUDIOSTREAMOUT *pNullStrmOut = (NULLAUDIOSTREAMOUT *)pHstStrmOut; 138 pNullStrmOut->u64TicksLast = 0; 136 139 if (pcSamples) 137 140 *pcSamples = _1K; … … 151 154 uint32_t *pcSamplesPlayed) 152 155 { 153 /* Always pretend consuming all samples available at this time. */ 154 const uint32_t cSamplesPlayed = audioMixBufSize(&pHstStrmOut->MixBuf); 156 PDRVHOSTNULLAUDIO pDrv = RT_FROM_MEMBER(pInterface, DRVHOSTNULLAUDIO, IHostAudio); 157 NULLAUDIOSTREAMOUT *pNullStrmOut = (NULLAUDIOSTREAMOUT *)pHstStrmOut; 158 159 /* Consume as many samples as would be played at the current frequency since last call. */ 160 uint32_t csLive = drvAudioHstOutSamplesLive(pHstStrmOut, NULL /* pcStreamsLive */); 161 uint64_t u64TicksNow = PDMDrvHlpTMGetVirtualTime(pDrv->pDrvIns); 162 uint64_t u64TicksElapsed = u64TicksNow - pNullStrmOut->u64TicksLast; 163 uint64_t u64TicksFreq = PDMDrvHlpTMGetVirtualFreq(pDrv->pDrvIns); 164 165 /* Remember when samples were consumed. */ 166 pNullStrmOut->u64TicksLast = u64TicksNow; 167 168 /* Minimize the rounding error by adding 0.5: samples = int((u64TicksElapsed * samplesFreq) / u64TicksFreq + 0.5). 169 * If rounding is not taken into account then the playback rate will be consistently lower that expected. 170 */ 171 uint64_t cSamplesPlayed = (2 * u64TicksElapsed * pHstStrmOut->Props.uHz + u64TicksFreq) / u64TicksFreq / 2; 172 173 /* Don't play more than available. */ 174 if (cSamplesPlayed > csLive) 175 cSamplesPlayed = csLive; 176 155 177 audioMixBufFinish(&pHstStrmOut->MixBuf, cSamplesPlayed); 156 178
Note:
See TracChangeset
for help on using the changeset viewer.