Changeset 65630 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Feb 6, 2017 5:01:11 PM (8 years ago)
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/AudioMixBuffer.cpp
r65056 r65630 140 140 141 141 /** 142 * Acquires (reads) a mutable pointer to the mixing buffer's audio samples without 143 * any conversion done. 144 ** @todo Rename to AudioMixBufPeek(Mutable/Raw)? 145 ** @todo Protect the buffer's data? 142 * Peeks for audio samples without any conversion done. 143 * This will get the raw sample data out of a mixing buffer. 146 144 * 147 145 * @return IPRT status code. VINF_TRY_AGAIN for getting next pointer at beginning (circular). 148 146 * @param pMixBuf Mixing buffer to acquire audio samples from. 149 147 * @param cSamplesToRead Number of audio samples to read. 150 * @param ppvSamples Returns a mutable pointer to the buffer's audio sample data. 151 * @param pcSamplesRead Number of audio samples read (acquired). 148 * @param paSampleBuf Buffer where to store the returned audio samples. 149 * @param cSampleBuf Size (in samples) of the buffer to store audio samples into. 150 * @param pcSamplesRead Returns number of read audio samples. Optional. 152 151 * 153 152 * @remark This function is not thread safe! 154 153 */ 155 int AudioMixBufAcquire(PPDMAUDIOMIXBUF pMixBuf, uint32_t cSamplesToRead, 156 PPDMAUDIOSAMPLE *ppvSamples, uint32_t *pcSamplesRead) 157 { 158 AssertPtrReturn(pMixBuf, VERR_INVALID_POINTER); 159 AssertPtrReturn(ppvSamples, VERR_INVALID_POINTER); 160 AssertPtrReturn(pcSamplesRead, VERR_INVALID_POINTER); 154 int AudioMixBufPeek(PPDMAUDIOMIXBUF pMixBuf, uint32_t cSamplesToRead, 155 PPDMAUDIOSAMPLE paSampleBuf, uint32_t cSampleBuf, uint32_t *pcSamplesRead) 156 { 157 AssertPtrReturn(pMixBuf, VERR_INVALID_POINTER); 158 AssertPtrReturn(paSampleBuf, VERR_INVALID_POINTER); 159 AssertReturn(cSampleBuf, VERR_INVALID_PARAMETER); 160 /* pcRead is optional. */ 161 161 162 162 int rc; … … 164 164 if (!cSamplesToRead) 165 165 { 166 *pcSamplesRead = 0; 166 if (pcSamplesRead) 167 *pcSamplesRead = 0; 167 168 return VINF_SUCCESS; 168 169 } 169 170 170 uint32_t c SamplesRead;171 uint32_t csRead; 171 172 if (pMixBuf->offRead + cSamplesToRead > pMixBuf->cSamples) 172 173 { 173 c SamplesRead = pMixBuf->cSamples - pMixBuf->offRead;174 csRead = pMixBuf->cSamples - pMixBuf->offRead; 174 175 rc = VINF_TRY_AGAIN; 175 176 } 176 177 else 177 178 { 178 c SamplesRead = cSamplesToRead;179 csRead = cSamplesToRead; 179 180 rc = VINF_SUCCESS; 180 181 } 181 182 182 *ppvSamples = &pMixBuf->pSamples[pMixBuf->offRead]; 183 AssertPtr(ppvSamples); 184 185 pMixBuf->offRead = (pMixBuf->offRead + cSamplesRead) % pMixBuf->cSamples; 183 memcpy(paSampleBuf, &pMixBuf->pSamples[pMixBuf->offRead], sizeof(PDMAUDIOSAMPLE) * csRead); 184 185 pMixBuf->offRead = (pMixBuf->offRead + csRead) % pMixBuf->cSamples; 186 186 Assert(pMixBuf->offRead <= pMixBuf->cSamples); 187 pMixBuf->cUsed -= RT_MIN(cSamplesRead, pMixBuf->cUsed); 188 189 *pcSamplesRead = cSamplesRead; 187 pMixBuf->cUsed -= RT_MIN(csRead, pMixBuf->cUsed); 188 189 if (pcSamplesRead) 190 *pcSamplesRead = csRead; 190 191 191 192 return rc; -
trunk/src/VBox/Devices/Audio/AudioMixBuffer.h
r63362 r65630 49 49 50 50 51 int AudioMixBufAcquire(PPDMAUDIOMIXBUF pMixBuf, uint32_t cSamplesToRead, PPDMAUDIOSAMPLE *ppvSamples, uint32_t *pcSamplesRead);52 51 inline uint32_t AudioMixBufBytesToSamples(PPDMAUDIOMIXBUF pMixBuf); 53 52 void AudioMixBufClear(PPDMAUDIOMIXBUF pMixBuf); … … 61 60 uint32_t AudioMixBufLive(PPDMAUDIOMIXBUF pMixBuf); 62 61 int AudioMixBufMixToParent(PPDMAUDIOMIXBUF pMixBuf, uint32_t cSamples, uint32_t *pcProcessed); 62 int AudioMixBufPeek(PPDMAUDIOMIXBUF pMixBuf, uint32_t cSamplesToRead, PPDMAUDIOSAMPLE paSampleBuf, uint32_t cSampleBuf, uint32_t *pcSamplesRead); 63 63 uint32_t AudioMixBufUsed(PPDMAUDIOMIXBUF pMixBuf); 64 64 int AudioMixBufReadAt(PPDMAUDIOMIXBUF pMixBuf, uint32_t offSamples, void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead);
Note:
See TracChangeset
for help on using the changeset viewer.