VirtualBox

Changeset 89337 in vbox for trunk/src/VBox/Devices/Audio


Ignore:
Timestamp:
May 28, 2021 8:49:59 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
144686
Message:

AudioMixer: Removed old conversion functions. bugref:9890

Location:
trunk/src/VBox/Devices/Audio
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Audio/AudioMixBuffer.cpp

    r89336 r89337  
    358358    } \
    359359    \
    360     DECLCALLBACK(uint32_t) audioMixBufConvFrom##a_Name##Stereo(PPDMAUDIOFRAME paDst, const void *pvSrc, uint32_t cbSrc, \
    361                                                                PCAUDMIXBUFCONVOPTS pOpts) \
    362     { \
    363         a_Type const *pSrc = (a_Type const *)pvSrc; \
    364         uint32_t cFrames = RT_MIN(pOpts->cFrames, cbSrc / sizeof(a_Type)); \
    365         AUDMIXBUF_MACRO_LOG(("cFrames=%RU32, BpS=%zu, lVol=%RU32, rVol=%RU32\n", \
    366                              pOpts->cFrames, sizeof(a_Type), pOpts->From.Volume.uLeft, pOpts->From.Volume.uRight)); \
    367         for (uint32_t i = 0; i < cFrames; i++) \
    368         { \
    369             paDst->i64LSample = ASMMult2xS32RetS64((int32_t)audioMixBufClipFrom##a_Name(*pSrc++), pOpts->From.Volume.uLeft ) >> AUDIOMIXBUF_VOL_SHIFT; \
    370             paDst->i64RSample = ASMMult2xS32RetS64((int32_t)audioMixBufClipFrom##a_Name(*pSrc++), pOpts->From.Volume.uRight) >> AUDIOMIXBUF_VOL_SHIFT; \
    371             paDst++; \
    372         } \
    373         \
    374         return cFrames; \
    375     } \
    376     \
    377     DECLCALLBACK(uint32_t) audioMixBufConvFrom##a_Name##Mono(PPDMAUDIOFRAME paDst, const void *pvSrc, uint32_t cbSrc, \
    378                                                              PCAUDMIXBUFCONVOPTS pOpts) \
    379     { \
    380         a_Type const *pSrc = (a_Type const *)pvSrc; \
    381         const uint32_t cFrames = RT_MIN(pOpts->cFrames, cbSrc / sizeof(a_Type)); \
    382         AUDMIXBUF_MACRO_LOG(("cFrames=%RU32, BpS=%zu, lVol=%RU32, rVol=%RU32\n", \
    383                              cFrames, sizeof(a_Type), pOpts->From.Volume.uLeft, pOpts->From.Volume.uRight)); \
    384         for (uint32_t i = 0; i < cFrames; i++) \
    385         { \
    386             paDst->i64LSample = ASMMult2xS32RetS64((int32_t)audioMixBufClipFrom##a_Name(*pSrc), pOpts->From.Volume.uLeft)  >> AUDIOMIXBUF_VOL_SHIFT; \
    387             paDst->i64RSample = ASMMult2xS32RetS64((int32_t)audioMixBufClipFrom##a_Name(*pSrc), pOpts->From.Volume.uRight) >> AUDIOMIXBUF_VOL_SHIFT; \
    388             pSrc++; \
    389             paDst++; \
    390         } \
    391         \
    392         return cFrames; \
    393     } \
    394     \
    395     DECLCALLBACK(void) audioMixBufConvTo##a_Name##Stereo(void *pvDst, PCPDMAUDIOFRAME paSrc, PCAUDMIXBUFCONVOPTS pOpts) \
    396     { \
    397         PCPDMAUDIOFRAME pSrc = paSrc; \
    398         a_Type *pDst = (a_Type *)pvDst; \
    399         uint32_t cFrames = pOpts->cFrames; \
    400         while (cFrames--) \
    401         { \
    402             AUDMIXBUF_MACRO_LOG(("%p: l=%RI64, r=%RI64\n", pSrc, pSrc->i64LSample, pSrc->i64RSample)); \
    403             pDst[0] = audioMixBufClipTo##a_Name(pSrc->i64LSample); \
    404             pDst[1] = audioMixBufClipTo##a_Name(pSrc->i64RSample); \
    405             AUDMIXBUF_MACRO_LOG(("\t-> l=%RI16, r=%RI16\n", pDst[0], pDst[1])); \
    406             pDst += 2; \
    407             pSrc++; \
    408         } \
    409     } \
    410     \
    411     DECLCALLBACK(void) audioMixBufConvTo##a_Name##Mono(void *pvDst, PCPDMAUDIOFRAME paSrc, PCAUDMIXBUFCONVOPTS pOpts) \
    412     { \
    413         PCPDMAUDIOFRAME pSrc = paSrc; \
    414         a_Type *pDst = (a_Type *)pvDst; \
    415         uint32_t cFrames = pOpts->cFrames; \
    416         while (cFrames--) \
    417         { \
    418             *pDst++ = audioMixBufClipTo##a_Name((pSrc->i64LSample + pSrc->i64RSample) / 2); \
    419             pSrc++; \
    420         } \
    421     } \
    422360    /* Encoders for peek: */ \
    423361    \
     
    643581#endif
    644582
    645 DECLCALLBACK(void) audioMixBufConvToRawS64Stereo(void *pvDst, PCPDMAUDIOFRAME paSrc, PCAUDMIXBUFCONVOPTS pOpts)
    646 {
    647     AssertCompile(sizeof(paSrc[0]) == sizeof(int64_t) * 2);
    648     memcpy(pvDst, paSrc, sizeof(int64_t) * 2 * pOpts->cFrames);
    649 }
    650583
    651584/* Encoders for peek: */
     
    806739
    807740/**
    808  * Looks up the matching conversion function for converting audio frames from a
    809  * source format.
    810  *
    811  * @returns Pointer to matching conversion function, NULL if not supported.
    812  * @param   pProps  The audio format to find a "from" converter for.
    813  */
    814 static PFNAUDIOMIXBUFCONVFROM audioMixBufConvFromLookup(PCPDMAUDIOPCMPROPS pProps)
    815 {
    816     if (PDMAudioPropsIsSigned(pProps))
    817     {
    818         switch (PDMAudioPropsChannels(pProps))
    819         {
    820             case 2:
    821                 switch (PDMAudioPropsSampleSize(pProps))
    822                 {
    823                     case 1:  return audioMixBufConvFromS8Stereo;
    824                     case 2:  return audioMixBufConvFromS16Stereo;
    825                     case 4:  return audioMixBufConvFromS32Stereo;
    826                     //case 8:  return pProps->fRaw ? audioMixBufConvToRawS64Stereo : NULL;
    827                     default: return NULL;
    828                 }
    829 
    830             case 1:
    831                 switch (PDMAudioPropsSampleSize(pProps))
    832                 {
    833                     case 1:  return audioMixBufConvFromS8Mono;
    834                     case 2:  return audioMixBufConvFromS16Mono;
    835                     case 4:  return audioMixBufConvFromS32Mono;
    836                     default: return NULL;
    837                 }
    838             default:
    839                 return NULL;
    840         }
    841     }
    842     else /* Unsigned */
    843     {
    844         switch (PDMAudioPropsChannels(pProps))
    845         {
    846             case 2:
    847                 switch (PDMAudioPropsSampleSize(pProps))
    848                 {
    849                     case 1:  return audioMixBufConvFromU8Stereo;
    850                     case 2:  return audioMixBufConvFromU16Stereo;
    851                     case 4:  return audioMixBufConvFromU32Stereo;
    852                     default: return NULL;
    853                 }
    854 
    855             case 1:
    856                 switch (PDMAudioPropsSampleSize(pProps))
    857                 {
    858                     case 1:  return audioMixBufConvFromU8Mono;
    859                     case 2:  return audioMixBufConvFromU16Mono;
    860                     case 4:  return audioMixBufConvFromU32Mono;
    861                     default: return NULL;
    862                 }
    863             default:
    864                 return NULL;
    865         }
    866     }
    867     /* not reached */
    868 }
    869 
    870 /**
    871  * Looks up the matching conversion function for converting audio frames to a
    872  * destination format.
    873  *
    874  * @returns Pointer to matching conversion function, NULL if not supported.
    875  * @param   pProps  The audio format to find a "to" converter for.
    876  */
    877 static PFNAUDIOMIXBUFCONVTO audioMixBufConvToLookup(PCPDMAUDIOPCMPROPS pProps)
    878 {
    879     if (PDMAudioPropsIsSigned(pProps))
    880     {
    881         switch (PDMAudioPropsChannels(pProps))
    882         {
    883             case 2:
    884                 switch (PDMAudioPropsSampleSize(pProps))
    885                 {
    886                     case 1:  return audioMixBufConvToS8Stereo;
    887                     case 2:  return audioMixBufConvToS16Stereo;
    888                     case 4:  return audioMixBufConvToS32Stereo;
    889                     case 8:  return pProps->fRaw ? audioMixBufConvToRawS64Stereo : NULL;
    890                     default: return NULL;
    891                 }
    892 
    893             case 1:
    894                 switch (PDMAudioPropsSampleSize(pProps))
    895                 {
    896                     case 1:  return audioMixBufConvToS8Mono;
    897                     case 2:  return audioMixBufConvToS16Mono;
    898                     case 4:  return audioMixBufConvToS32Mono;
    899                     default: return NULL;
    900                 }
    901             default:
    902                 return NULL;
    903         }
    904     }
    905     else /* Unsigned */
    906     {
    907         switch (PDMAudioPropsChannels(pProps))
    908         {
    909             case 2:
    910                 switch (PDMAudioPropsSampleSize(pProps))
    911                 {
    912                     case 1:  return audioMixBufConvToU8Stereo;
    913                     case 2:  return audioMixBufConvToU16Stereo;
    914                     case 4:  return audioMixBufConvToU32Stereo;
    915                     default: return NULL;
    916                 }
    917 
    918             case 1:
    919                 switch (PDMAudioPropsSampleSize(pProps))
    920                 {
    921                     case 1:  return audioMixBufConvToU8Mono;
    922                     case 2:  return audioMixBufConvToU16Mono;
    923                     case 4:  return audioMixBufConvToU32Mono;
    924                     default: return NULL;
    925                 }
    926             default:
    927                 return NULL;
    928         }
    929     }
    930     /* not reached */
    931 }
    932 
    933 /**
    934741 * Converts a PDM audio volume to an internal mixing buffer volume.
    935742 *
     
    991798
    992799    pMixBuf->Props       = *pProps;
    993     pMixBuf->pfnConvFrom = audioMixBufConvFromLookup(pProps);
    994     pMixBuf->pfnConvTo   = audioMixBufConvToLookup(pProps);
    995800
    996801    pMixBuf->pszName = RTStrDup(pszName);
  • trunk/src/VBox/Devices/Audio/AudioMixBuffer.h

    r89335 r89337  
    8686typedef AUDMIXBUFVOL *PAUDMIXBUFVOL;
    8787
    88 /*
    89  * Frame conversion parameters for the audioMixBufConvFromXXX / audioMixBufConvToXXX functions.
    90  */
    91 typedef struct AUDMIXBUFCONVOPTS
    92 {
    93     /** Number of audio frames to convert. */
    94     uint32_t        cFrames;
    95     union
    96     {
    97         struct
    98         {
    99             /** Volume to use for conversion. */
    100             AUDMIXBUFVOL Volume;
    101         } From;
    102     } RT_UNION_NM(u);
    103 } AUDMIXBUFCONVOPTS;
    104 /** Pointer to conversion parameters for the audio mixer.   */
    105 typedef AUDMIXBUFCONVOPTS *PAUDMIXBUFCONVOPTS;
    106 /** Pointer to const conversion parameters for the audio mixer.   */
    107 typedef AUDMIXBUFCONVOPTS const *PCAUDMIXBUFCONVOPTS;
    108 
    109 /**
    110  * Convertion-from function used by the audio buffer mixer.
    111  *
    112  * @returns Number of audio frames returned.
    113  * @param   paDst           Where to return the converted frames.
    114  * @param   pvSrc           The source frame bytes.
    115  * @param   cbSrc           Number of bytes to convert.
    116  * @param   pOpts           Conversion options.
    117  * @todo r=bird: The @a paDst size is presumable given in @a pOpts->cFrames?
    118  */
    119 typedef DECLCALLBACKTYPE(uint32_t, FNAUDIOMIXBUFCONVFROM,(PPDMAUDIOFRAME paDst, const void *pvSrc, uint32_t cbSrc,
    120                                                           PCAUDMIXBUFCONVOPTS pOpts));
    121 /** Pointer to a convertion-from function used by the audio buffer mixer. */
    122 typedef FNAUDIOMIXBUFCONVFROM *PFNAUDIOMIXBUFCONVFROM;
    123 
    124 /**
    125  * Convertion-to function used by the audio buffer mixer.
    126  *
    127  * @param   pvDst           Output buffer.
    128  * @param   paSrc           The input frames.
    129  * @param   pOpts           Conversion options.
    130  * @todo r=bird: The @a paSrc size is presumable given in @a pOpts->cFrames and
    131  *       this implicitly gives the pvDst size too, right?
    132  */
    133 typedef DECLCALLBACKTYPE(void, FNAUDIOMIXBUFCONVTO,(void *pvDst, PCPDMAUDIOFRAME paSrc, PCAUDMIXBUFCONVOPTS pOpts));
    134 /** Pointer to a convertion-to function used by the audio buffer mixer. */
    135 typedef FNAUDIOMIXBUFCONVTO *PFNAUDIOMIXBUFCONVTO;
    13688
    13789/** Pointer to audio mixing buffer.  */
     
    222174     *       extra copying? */
    223175    PDMAUDIOPCMPROPS            Props;
    224     /** Standard conversion-to function for set uAudioFmt. */
    225     PFNAUDIOMIXBUFCONVTO        pfnConvTo;
    226     /** Standard conversion-from function for set uAudioFmt. */
    227     PFNAUDIOMIXBUFCONVFROM      pfnConvFrom;
    228176
    229177    /** Ratio of the associated parent stream's frequency by this stream's
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette