Changeset 54482 in vbox for trunk/src/VBox
- Timestamp:
- Feb 25, 2015 11:40:56 AM (10 years ago)
- svn:sync-xref-src-repo-rev:
- 98590
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/AudioMixBuffer.cpp
r54460 r54482 19 19 #include <iprt/asm-math.h> 20 20 #include <iprt/assert.h> 21 #ifdef DEBUG_ andy21 #ifdef DEBUG_DUMP_PCM_DATA 22 22 # include <iprt/file.h> 23 23 #endif 24 24 #include <iprt/mem.h> 25 25 #include <iprt/string.h> /* For RT_BZERO. */ 26 27 #ifdef LOG_GROUP 28 # undef LOG_GROUP 29 #endif 30 #define LOG_GROUP LOG_GROUP_DEV_AUDIO 31 #include <VBox/log.h> 32 26 33 #ifdef TESTCASE 34 # define LOG_ENABLED 27 35 # include <iprt/stream.h> 28 36 #endif … … 31 39 #include "AudioMixBuffer.h" 32 40 33 #ifdef LOG_GROUP34 # undef LOG_GROUP35 #endif36 41 #if 0 37 42 # define AUDMIXBUF_LOG(x) LogFlowFunc(x) 38 # define LOG_GROUP LOG_GROUP_DEV_AUDIO39 # include <VBox/log.h>40 43 #else 41 # define AUDMIXBUF_LOG(x) do {} while (0) 44 # if defined(TESTCASE) 45 # define AUDMIXBUF_LOG(x) LogFunc(x) 46 # else 47 # define AUDMIXBUF_LOG(x) do {} while (0) 48 # endif 42 49 #endif 43 50 … … 126 133 pIter->pszName, pIter->cMixed, pIter->cMixed - cSamplesToClear)); 127 134 128 Assert(pIter->cMixed >= cSamplesToClear); 129 pIter->cMixed -= cSamplesToClear; 135 pIter->cMixed -= RT_MIN(pIter->cMixed, cSamplesToClear); 130 136 pIter->offReadWrite = 0; 131 137 } … … 376 382 while (paDst < paDstEnd) \ 377 383 { \ 378 if (paSrc >= paSrcEnd) \379 break; \380 \381 384 while (pRate->srcOffset <= (pRate->dstOffset >> 32)) \ 382 385 { \ 383 AUDMIXBUF_MACRO_LOG(("foo1\n")); \384 386 samLast = *paSrc++; \ 385 387 pRate->srcOffset++; \ … … 387 389 if (paSrc >= paSrcEnd) \ 388 390 break; \ 389 AUDMIXBUF_MACRO_LOG(("foo1.1\n")); \390 391 } \ 391 AUDMIXBUF_MACRO_LOG(("foo2\n")); \392 392 \ 393 393 samCur = *paSrc; \ … … 410 410 \ 411 411 AUDMIXBUF_MACRO_LOG(("\t\tpRate->dstOffset=%RU64\n", pRate->dstOffset)); \ 412 \ 413 if (paSrc >= paSrcEnd) \ 414 break; \ 415 \ 412 416 } \ 413 417 \ … … 903 907 { 904 908 AssertPtrReturn(pMixBuf, 0); 909 910 AUDMIXBUF_LOG(("%s: cProcessed=%RU32\n", pMixBuf->pszName, pMixBuf->cProcessed)); 905 911 return pMixBuf->cProcessed; 906 912 } … … 970 976 return VINF_SUCCESS; 971 977 972 uint32_t cToRead = RT_MIN(AUDIOMIXBUF_B2S(pMixBuf, cbBuf), 973 pMixBuf->cProcessed); 978 uint32_t cToRead = RT_MIN(AUDIOMIXBUF_B2S(pMixBuf, cbBuf), pMixBuf->cProcessed); 974 979 975 980 AUDMIXBUF_LOG(("%s: pvBuf=%p, cbBuf=%zu (%RU32 samples), cToRead=%RU32\n", 976 pMixBuf->pszName, pvBuf, 977 cbBuf, AUDIOMIXBUF_B2S(pMixBuf, cbBuf), cToRead)); 981 pMixBuf->pszName, pvBuf, cbBuf, AUDIOMIXBUF_B2S(pMixBuf, cbBuf), cToRead)); 978 982 979 983 if (!cToRead) … … 1167 1171 uint32_t cWritten; 1168 1172 1169 #if 01173 #ifdef DEBUG_DUMP_PCM_DATA 1170 1174 RTFILE fh; 1171 1175 rc = RTFileOpen(&fh, "c:\\temp\\test_writeat.pcm", … … 1285 1289 } 1286 1290 1287 #if 01291 #ifdef DEBUG_DUMP_PCM_DATA 1288 1292 RTFILE fh; 1289 1293 RTFileOpen(&fh, "c:\\temp\\test_writeex.pcm", -
trunk/src/VBox/Devices/Audio/testcase/tstAudioMixBuffer.cpp
r54460 r54482 23 23 #include <iprt/initterm.h> 24 24 #include <iprt/mem.h> 25 #include <iprt/rand.h> 25 26 #include <iprt/stream.h> 26 27 #include <iprt/string.h> … … 152 153 RTTESTI_CHECK_RC_OK(audioMixBufInit(&parent, "Parent", &props, cBufSize)); 153 154 154 PDMAUDIOSTREAMCFG cfg_c1 = /* Downmixing*/155 PDMAUDIOSTREAMCFG cfg_c1 = /* Upmixing to parent */ 155 156 { 156 157 22100, /* Hz */ … … 167 168 RTTESTI_CHECK_RC_OK(audioMixBufLinkTo(&child1, &parent)); 168 169 169 PDMAUDIOSTREAMCFG cfg_c2 = /* Upmixing*/170 PDMAUDIOSTREAMCFG cfg_c2 = /* Downmixing to parent */ 170 171 { 171 172 48000, /* Hz */ … … 187 188 size_t cbBuf = _1K; 188 189 char pvBuf[_1K]; 189 int16_t samples16[32] = { 0xAA, 0xBB }; 190 uint32_t read , written, proc, mixed; 191 190 int16_t samples[32] = { 0xAA, 0xBB }; 191 uint32_t free, read , written, proc, mixed, temp; 192 193 uint32_t cChild1Free = cBufSize; 194 uint32_t cChild1Mixed = 0; 192 195 uint32_t cSamplesParent1 = 16; 193 196 uint32_t cSamplesChild1 = 16; 194 uint32_t cSamplesParent2 = 32; 197 198 uint32_t cChild2Free = cBufSize; 199 uint32_t cChild2Mixed = 0; 200 uint32_t cSamplesParent2 = 16; 195 201 uint32_t cSamplesChild2 = 16; 196 202 197 for (int i = 0; i < 32; i++) 198 { 199 RTTESTI_CHECK_RC_OK(audioMixBufWriteAt(&child1, 0, &samples16, sizeof(samples16), &written)); 200 RTTESTI_CHECK(written == cSamplesChild1); 201 RTTESTI_CHECK_RC_OK(audioMixBufMixToParent(&child1, written, &mixed)); 202 RTTESTI_CHECK(mixed == cSamplesChild1); 203 204 RTTESTI_CHECK_RC_OK(audioMixBufReadCirc(&parent, pvBuf, cbBuf, &read)); 205 RTTESTI_CHECK(read == 31); 206 207 RTTESTI_CHECK_RC_OK(audioMixBufWriteAt(&child2, 0, &samples16, sizeof(samples16), &written)); 208 RTTESTI_CHECK(written == cSamplesChild2); 209 RTTESTI_CHECK_RC_OK(audioMixBufMixToParent(&child2, written, &mixed)); 210 RTTESTI_CHECK(mixed == cSamplesChild2); 211 212 RTTESTI_CHECK_RC_OK(audioMixBufReadCirc(&parent, pvBuf, cbBuf, &read)); 213 RTTESTI_CHECK(read == 15); 203 uint32_t t = RTRandU32() % 64; 204 205 for (uint32_t i = 0; i < t; i++) 206 { 207 RTTestPrintf(hTest, RTTESTLVL_DEBUG, "i=%RU32\n", i); 208 RTTESTI_CHECK_RC_OK_BREAK(audioMixBufWriteAt(&child1, 0, &samples, sizeof(samples), &written)); 209 RTTESTI_CHECK_MSG_BREAK(written == cSamplesChild1, ("Child1: Expected %RU32 written samples, got %RU32\n", cSamplesChild1, written)); 210 RTTESTI_CHECK_RC_OK_BREAK(audioMixBufMixToParent(&child1, written, &mixed)); 211 temp = audioMixBufProcessed(&parent) - audioMixBufMixed(&child2); 212 RTTESTI_CHECK_MSG_BREAK(audioMixBufMixed(&child1) == temp, ("Child1: Expected %RU32 mixed samples, got %RU32\n", audioMixBufMixed(&child1), temp)); 213 214 RTTESTI_CHECK_RC_OK_BREAK(audioMixBufWriteAt(&child2, 0, &samples, sizeof(samples), &written)); 215 RTTESTI_CHECK_MSG_BREAK(written == cSamplesChild2, ("Child2: Expected %RU32 written samples, got %RU32\n", cSamplesChild2, written)); 216 RTTESTI_CHECK_RC_OK_BREAK(audioMixBufMixToParent(&child2, written, &mixed)); 217 temp = audioMixBufProcessed(&parent) - audioMixBufMixed(&child1); 218 RTTESTI_CHECK_MSG_BREAK(audioMixBufMixed(&child2) == temp, ("Child2: Expected %RU32 mixed samples, got %RU32\n", audioMixBufMixed(&child2), temp)); 219 } 220 221 RTTESTI_CHECK(audioMixBufProcessed(&parent) == audioMixBufMixed(&child1) + audioMixBufMixed(&child2)); 222 223 for (;;) 224 { 225 RTTESTI_CHECK_RC_OK_BREAK(audioMixBufReadCirc(&parent, pvBuf, cbBuf, &read)); 226 if (!read) 227 break; 228 audioMixBufFinish(&parent, read); 214 229 } 215 230 216 231 RTTESTI_CHECK(audioMixBufProcessed(&parent) == 0); 232 RTTESTI_CHECK(audioMixBufMixed(&child1) == 0); 233 RTTESTI_CHECK(audioMixBufMixed(&child2) == 0); 217 234 218 235 return RTTestSubErrorCount(hTest) ? VERR_GENERAL_FAILURE : VINF_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.