Changeset 65655 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Feb 7, 2017 12:51:46 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvHostNullAudio.cpp
r65624 r65655 64 64 /** The stream's acquired configuration. */ 65 65 PPDMAUDIOSTREAMCFG pCfg; 66 union 67 { 68 struct 69 { 70 /** Timestamp of last played samples. */ 71 uint64_t u64TicksLast; 72 } Out; 73 }; 74 } NULLAUDIOSTREAM; 75 typedef NULLAUDIOSTREAM *PNULLAUDIOSTREAM; 66 } NULLAUDIOSTREAM, *PNULLAUDIOSTREAM; 76 67 77 68 /** … … 151 142 AssertReturn(cbBuf, VERR_INVALID_PARAMETER); 152 143 153 PDRVHOSTNULLAUDIO pDrv = RT_FROM_MEMBER(pInterface, DRVHOSTNULLAUDIO, IHostAudio); 154 PNULLAUDIOSTREAM pStreamNull = (PNULLAUDIOSTREAM)pStream; 155 156 /* Consume as many samples as would be played at the current frequency since last call. */ 157 uint32_t csLive = PDMAUDIOPCMPROPS_B2S(&pStreamNull->pCfg->Props, cbBuf); 158 159 uint64_t u64TicksNow = PDMDrvHlpTMGetVirtualTime(pDrv->pDrvIns); 160 uint64_t u64TicksElapsed = u64TicksNow - pStreamNull->Out.u64TicksLast; 161 uint64_t u64TicksFreq = PDMDrvHlpTMGetVirtualFreq(pDrv->pDrvIns); 162 163 /* Remember when samples were consumed. */ 164 pStreamNull->Out.u64TicksLast = u64TicksNow; 165 166 /* 167 * Minimize the rounding error by adding 0.5: samples = int((u64TicksElapsed * samplesFreq) / u64TicksFreq + 0.5). 168 * If rounding is not taken into account then the playback rate will be consistently lower that expected. 169 */ 170 uint64_t csPlayed = (2 * u64TicksElapsed * pStreamNull->pCfg->Props.uHz + u64TicksFreq) / u64TicksFreq / 2; 171 172 /* Don't play more than available. */ 173 if (csPlayed > csLive) 174 csPlayed = csLive; 144 RT_NOREF(pInterface, pStream, pvBuf); 175 145 176 146 /* Note: No copying of samples needed here, as this a NULL backend. */ 177 147 178 148 if (pcbWritten) 179 *pcbWritten = PDMAUDIOPCMPROPS_S2B(&pStreamNull->pCfg->Props, csPlayed);149 *pcbWritten = cbBuf; /* Return all bytes as written. */ 180 150 181 151 return VINF_SUCCESS; … … 214 184 static int nullCreateStreamOut(PNULLAUDIOSTREAM pStreamNull, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 215 185 { 216 RT_NOREF(pCfgReq); 217 218 pStreamNull->Out.u64TicksLast = 0; 186 RT_NOREF(pStreamNull, pCfgReq); 219 187 220 188 if (pCfgAcq)
Note:
See TracChangeset
for help on using the changeset viewer.