Changeset 73378 in vbox for trunk/src/VBox
- Timestamp:
- Jul 27, 2018 8:48:37 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvAudioCommon.cpp
r73345 r73378 120 120 121 121 /** 122 * Clears a sample buffer by the given amount of audio samples.123 * 124 * @return IPRT status code.122 * Clears a sample buffer by the given amount of audio frames with silence (according to the format 123 * given by the PCM properties). 124 * 125 125 * @param pPCMProps PCM properties to use for the buffer to clear. 126 126 * @param pvBuf Buffer to clear. 127 127 * @param cbBuf Size (in bytes) of the buffer. 128 * @param c Samples Number of audio samples to clear in the buffer.129 */ 130 void DrvAudioHlpClearBuf(const PPDMAUDIOPCMPROPS pPCMProps, void *pvBuf, size_t cbBuf, uint32_t c Samples)128 * @param cFrames Number of audio frames to clear in the buffer. 129 */ 130 void DrvAudioHlpClearBuf(const PPDMAUDIOPCMPROPS pPCMProps, void *pvBuf, size_t cbBuf, uint32_t cFrames) 131 131 { 132 132 AssertPtrReturnVoid(pPCMProps); 133 133 AssertPtrReturnVoid(pvBuf); 134 134 135 if (!cbBuf || !c Samples)135 if (!cbBuf || !cFrames) 136 136 return; 137 137 138 138 Assert(pPCMProps->cBits); 139 size_t cbToClear = cSamples * (pPCMProps->cBits / 8 /* Bytes */);139 size_t cbToClear = DrvAudioHlpFramesToBytes(pPCMProps, cFrames); 140 140 Assert(cbBuf >= cbToClear); 141 141 … … 143 143 cbToClear = cbBuf; 144 144 145 Log2Func(("pPCMProps=%p, pvBuf=%p, cSamples=%RU32, fSigned=%RTbool, cBits=%RU8\n", 146 pPCMProps, pvBuf, cSamples, pPCMProps->fSigned, pPCMProps->cBits)); 145 Log2Func(("pPCMProps=%p, pvBuf=%p, cFrames=%RU32, fSigned=%RTbool, cBits=%RU8\n", 146 pPCMProps, pvBuf, cFrames, pPCMProps->fSigned, pPCMProps->cBits)); 147 148 Assert(pPCMProps->fSwapEndian == false); /** @todo Swapping Endianness is not supported yet. */ 147 149 148 150 if (pPCMProps->fSigned) … … 163 165 { 164 166 uint16_t *p = (uint16_t *)pvBuf; 165 int16_t s = INT16_MAX; 166 167 if (pPCMProps->fSwapEndian) 168 s = RT_BSWAP_U16(s); 169 170 for (uint32_t i = 0; i < cSamples; i++) 167 uint16_t s = 0x8000; 168 169 for (uint32_t i = 0; i < DrvAudioHlpBytesToFrames(pPCMProps, (uint32_t)cbToClear); i++) 171 170 p[i] = s; 172 171 173 172 break; 174 173 } 174 175 /** @todo Add 24 bit? */ 175 176 176 177 case 32: 177 178 { 178 179 uint32_t *p = (uint32_t *)pvBuf; 179 int32_t s = INT32_MAX; 180 181 if (pPCMProps->fSwapEndian) 182 s = RT_BSWAP_U32(s); 183 184 for (uint32_t i = 0; i < cSamples; i++) 180 uint32_t s = 0x80000000; 181 182 for (uint32_t i = 0; i < DrvAudioHlpBytesToFrames(pPCMProps, (uint32_t)cbToClear); i++) 185 183 p[i] = s; 186 184
Note:
See TracChangeset
for help on using the changeset viewer.