Changeset 58372 in vbox for trunk/src/VBox
- Timestamp:
- Oct 22, 2015 10:48:08 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvHostNullAudio.cpp
r57827 r58372 55 55 { 56 56 /** Note: Always must come first! */ 57 PDMAUDIOHSTSTRMOUT hw;58 uint64_t u64TicksLast;59 uint64_t csPlayBuffer;60 uint8_t *pu8PlayBuffer;61 } NULLAUDIOSTREAMOUT ;57 PDMAUDIOHSTSTRMOUT streamOut; 58 uint64_t u64TicksLast; 59 uint64_t csPlayBuffer; 60 uint8_t *pu8PlayBuffer; 61 } NULLAUDIOSTREAMOUT, *PNULLAUDIOSTREAMOUT; 62 62 63 63 typedef struct NULLAUDIOSTREAMIN 64 64 { 65 65 /** Note: Always must come first! */ 66 PDMAUDIOHSTSTRMIN hw;67 } NULLAUDIOSTREAMIN ;66 PDMAUDIOHSTSTRMIN streamIn; 67 } NULLAUDIOSTREAMIN, *PNULLAUDIOSTREAMIN; 68 68 69 69 /** … … 132 132 if (RT_SUCCESS(rc)) 133 133 { 134 NULLAUDIOSTREAMOUT *pNullStrmOut = (NULLAUDIOSTREAMOUT *)pHstStrmOut;135 pNullStrmOut->u64TicksLast = 0;136 pNullStrmOut->csPlayBuffer = _1K;134 PNULLAUDIOSTREAMOUT pNullStrmOut = (PNULLAUDIOSTREAMOUT)pHstStrmOut; 135 pNullStrmOut->u64TicksLast = 0; 136 pNullStrmOut->csPlayBuffer = _1K; 137 137 pNullStrmOut->pu8PlayBuffer = (uint8_t *)RTMemAlloc(_1K << pHstStrmOut->Props.cShift); 138 138 if (pNullStrmOut->pu8PlayBuffer) … … 161 161 { 162 162 PDRVHOSTNULLAUDIO pDrv = RT_FROM_MEMBER(pInterface, DRVHOSTNULLAUDIO, IHostAudio); 163 NULLAUDIOSTREAMOUT *pNullStrmOut = (NULLAUDIOSTREAMOUT *)pHstStrmOut;163 PNULLAUDIOSTREAMOUT pNullStrmOut = (PNULLAUDIOSTREAMOUT)pHstStrmOut; 164 164 165 165 /* Consume as many samples as would be played at the current frequency since last call. */ 166 uint32_t csLive = drvAudioHstOutSamplesLive(pHstStrmOut);167 uint64_t u64TicksNow = PDMDrvHlpTMGetVirtualTime(pDrv->pDrvIns);166 uint32_t csLive = drvAudioHstOutSamplesLive(pHstStrmOut); 167 uint64_t u64TicksNow = PDMDrvHlpTMGetVirtualTime(pDrv->pDrvIns); 168 168 uint64_t u64TicksElapsed = u64TicksNow - pNullStrmOut->u64TicksLast; 169 uint64_t u64TicksFreq = PDMDrvHlpTMGetVirtualFreq(pDrv->pDrvIns);169 uint64_t u64TicksFreq = PDMDrvHlpTMGetVirtualFreq(pDrv->pDrvIns); 170 170 171 171 /* Remember when samples were consumed. */ 172 172 pNullStrmOut->u64TicksLast = u64TicksNow; 173 173 174 /* Minimize the rounding error by adding 0.5: samples = int((u64TicksElapsed * samplesFreq) / u64TicksFreq + 0.5). 174 /* 175 * Minimize the rounding error by adding 0.5: samples = int((u64TicksElapsed * samplesFreq) / u64TicksFreq + 0.5). 175 176 * If rounding is not taken into account then the playback rate will be consistently lower that expected. 176 177 */ … … 230 231 static DECLCALLBACK(int) drvHostNullAudioFiniOut(PPDMIHOSTAUDIO pInterface, PPDMAUDIOHSTSTRMOUT pHstStrmOut) 231 232 { 232 NULLAUDIOSTREAMOUT *pNullStrmOut = (NULLAUDIOSTREAMOUT *)pHstStrmOut; 233 RTMemFree(pNullStrmOut->pu8PlayBuffer); 233 PNULLAUDIOSTREAMOUT pNullStrmOut = (PNULLAUDIOSTREAMOUT)pHstStrmOut; 234 if ( pNullStrmOut 235 && pNullStrmOut->pu8PlayBuffer) 236 { 237 RTMemFree(pNullStrmOut->pu8PlayBuffer); 238 } 234 239 return VINF_SUCCESS; 235 240 }
Note:
See TracChangeset
for help on using the changeset viewer.