- Timestamp:
- May 20, 2016 10:52:22 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vmm/pdmaudioifs.h
r61050 r61091 340 340 341 341 /** 342 * Structure for holding sample conversion parameters for 343 * the audioMixBufConvFromXXX / audioMixBufConvToXXX macros. 344 */ 345 typedef struct AUDMIXBUF_CONVOPTS 346 { 347 /** Number of audio samples to convert. */ 348 uint32_t cSamples; 349 /** Volume to apply during conversion. Pass 0 350 * to convert the original values. May not apply to 351 * all conversion functions. */ 352 PDMAUDIOVOLUME Volume; 353 } AUDMIXBUF_CONVOPTS, *PAUDMIXBUF_CONVOPTS; 354 355 /** 342 356 * Note: All internal handling is done in samples, 343 357 * not in bytes! … … 345 359 typedef uint32_t PDMAUDIOMIXBUFFMT; 346 360 typedef PDMAUDIOMIXBUFFMT *PPDMAUDIOMIXBUFFMT; 361 362 typedef uint32_t (AUDMIXBUF_FN_CONVFROM) (PPDMAUDIOSAMPLE paDst, const void *pvSrc, uint32_t cbSrc, const PAUDMIXBUF_CONVOPTS pOpts); 363 typedef AUDMIXBUF_FN_CONVFROM *PAUDMIXBUF_FN_CONVFROM; 364 365 typedef void (AUDMIXBUF_FN_CONVTO) (void *pvDst, const PPDMAUDIOSAMPLE paSrc, const PAUDMIXBUF_CONVOPTS pOpts); 366 typedef AUDMIXBUF_FN_CONVTO *PAUDMIXBUF_FN_CONVTO; 347 367 348 368 typedef struct PDMAUDIOMIXBUF *PPDMAUDIOMIXBUF; … … 378 398 /** This buffer's audio format. */ 379 399 PDMAUDIOMIXBUFFMT AudioFmt; 400 /** Standard conversion-to function for set AudioFmt. */ 401 PAUDMIXBUF_FN_CONVTO pConvTo; 402 /** Standard conversion-from function for set AudioFmt. */ 403 PAUDMIXBUF_FN_CONVFROM pConvFrom; 380 404 /** 381 405 * Ratio of the associated parent stream's frequency by this stream's -
trunk/src/VBox/Devices/Audio/AudioMixBuffer.cpp
r61089 r61091 131 131 AssertCompile(AUDIOMIXBUF_VOL_0DB == 0x40000000); /* For now -- when only attenuation is used. */ 132 132 133 /**134 * Structure for holding sample conversion parameters for135 * the audioMixBufConvFromXXX / audioMixBufConvToXXX macros.136 */137 typedef struct AUDMIXBUF_CONVOPTS138 {139 /** Number of audio samples to convert. */140 uint32_t cSamples;141 /** Volume to apply during conversion. Pass 0142 * to convert the original values. May not apply to143 * all conversion functions. */144 PDMAUDIOVOLUME Volume;145 } AUDMIXBUF_CONVOPTS, *PAUDMIXBUF_CONVOPTS;146 147 133 /* 148 134 * When running the audio testcases we want to verfiy … … 160 146 static inline void audioMixBufDbgPrint(PPDMAUDIOMIXBUF pMixBuf); 161 147 #endif 162 163 typedef uint32_t (AUDMIXBUF_FN_CONVFROM) (PPDMAUDIOSAMPLE paDst, const void *pvSrc, uint32_t cbSrc, const PAUDMIXBUF_CONVOPTS pOpts);164 typedef AUDMIXBUF_FN_CONVFROM *PAUDMIXBUF_FN_CONVFROM;165 166 typedef void (AUDMIXBUF_FN_CONVTO) (void *pvDst, const PPDMAUDIOSAMPLE paSrc, const PAUDMIXBUF_CONVOPTS pOpts);167 typedef AUDMIXBUF_FN_CONVTO *PAUDMIXBUF_FN_CONVTO;168 148 169 149 /* Can return VINF_TRY_AGAIN for getting next pointer at beginning (circular) */ … … 649 629 * @return PAUDMIXBUF_FN_CONVFROM Function pointer to conversion macro if found, NULL if not supported. 650 630 * @param enmFmt Audio format to lookup conversion macro for. 651 * @param fMuted Flag determining whether the source is muted. 652 */ 653 static inline PAUDMIXBUF_FN_CONVFROM audioMixBufConvFromLookup(PDMAUDIOMIXBUFFMT enmFmt, bool fMuted) 654 { 655 if (fMuted) 656 return audioMixBufConvFromSilence; 657 631 */ 632 static inline PAUDMIXBUF_FN_CONVFROM audioMixBufConvFromLookup(PDMAUDIOMIXBUFFMT enmFmt) 633 { 658 634 if (AUDMIXBUF_FMT_SIGNED(enmFmt)) 659 635 { … … 807 783 pProps->cBits, 808 784 pProps->fSigned); 785 786 pMixBuf->pConvFrom = audioMixBufConvFromLookup(pMixBuf->AudioFmt); 787 pMixBuf->pConvTo = audioMixBufConvToLookup(pMixBuf->AudioFmt); 788 809 789 pMixBuf->cShift = pProps->cShift; 810 790 pMixBuf->pszName = RTStrDup(pszName); … … 1321 1301 if (cToProcess) 1322 1302 { 1323 PAUDMIXBUF_FN_CONVTO pConv = audioMixBufConvToLookup(enmFmt); 1303 PAUDMIXBUF_FN_CONVTO pConv; 1304 if (pMixBuf->AudioFmt != enmFmt) 1305 pConv = audioMixBufConvToLookup(enmFmt); 1306 else 1307 pConv = pMixBuf->pConvTo; 1308 1324 1309 if (pConv) 1325 1310 { 1326 1311 AUDMIXBUF_CONVOPTS convOpts = { cToProcess, pMixBuf->Volume }; 1312 1313 AssertPtr(pConv); 1327 1314 pConv(pvBuf, pMixBuf->pSamples + offSamples, &convOpts); 1328 1315 1316 #ifdef DEBUG 1317 AudioMixBufDbgPrint(pMixBuf); 1318 #endif 1329 1319 rc = VINF_SUCCESS; 1330 1320 } 1331 1321 else 1332 rc = VERR_INVALID_PARAMETER; 1333 1334 #ifdef DEBUG 1335 AudioMixBufDbgPrint(pMixBuf); 1336 #endif 1322 rc = VERR_NOT_SUPPORTED; 1337 1323 } 1338 1324 else … … 1651 1637 return VERR_BUFFER_OVERFLOW; 1652 1638 1653 PAUDMIXBUF_FN_CONVFROM pConv = audioMixBufConvFromLookup(enmFmt, pMixBuf->Volume.fMuted); 1639 PAUDMIXBUF_FN_CONVFROM pConv; 1640 if (pMixBuf->AudioFmt != enmFmt) 1641 pConv = audioMixBufConvFromLookup(enmFmt); 1642 else 1643 { 1644 pConv = pMixBuf->Volume.fMuted 1645 ? &audioMixBufConvFromSilence : pMixBuf->pConvFrom; 1646 } 1647 1654 1648 if (!pConv) 1655 1649 return VERR_NOT_SUPPORTED; … … 1754 1748 } 1755 1749 1756 PAUDMIXBUF_FN_CONVFROM pConv = audioMixBufConvFromLookup(enmFmt, pMixBuf->Volume.fMuted); 1750 PAUDMIXBUF_FN_CONVFROM pConv; 1751 if (pMixBuf->AudioFmt != enmFmt) 1752 pConv = audioMixBufConvFromLookup(enmFmt); 1753 else 1754 { 1755 pConv = pMixBuf->Volume.fMuted 1756 ? &audioMixBufConvFromSilence : pMixBuf->pConvFrom; 1757 } 1758 1757 1759 if (!pConv) 1758 1760 return VERR_NOT_SUPPORTED;
Note:
See TracChangeset
for help on using the changeset viewer.