VirtualBox

Changeset 94993 in vbox for trunk/include/VBox


Ignore:
Timestamp:
May 12, 2022 1:57:54 PM (3 years ago)
Author:
vboxsync
Message:

Audio: Resolved @todos regarding PDMAudioPropsAreValid() / AudioHlpPcmPropsAreValid():

  • Renamed AudioHlpPcmPropsAreValid() -> AudioHlpPcmPropsAreValidAndSupported().
  • Don't assert when not supported or invalid (i.e. not set) but just return false. The caller now is responsible for asserting now, if needed.
  • Also added unsigned samples support to AudioHlpPcmPropsAreValidAndSupported().
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/pdmaudioinline.h

    r93115 r94993  
    11501150 * @param   pProps  The PCM properties to check.
    11511151 *
    1152  * @remarks This just performs a generic check of value ranges.  Further, it
    1153  *          will assert if the input is invalid.
     1152 * @remarks This just performs a generic check of value ranges.
    11541153 *
    11551154 * @sa      PDMAudioStrmCfgIsValid
     
    11591158    AssertPtrReturn(pProps, false);
    11601159
    1161     AssertReturn(pProps->cChannelsX != 0, false);
    1162     AssertReturn(pProps->cChannelsX <= PDMAUDIO_MAX_CHANNELS, false);
    1163     AssertMsgReturn(   pProps->cbSampleX == 1 || pProps->cbSampleX == 2 || pProps->cbSampleX == 4  || (pProps->cbSampleX == 8 && pProps->fRaw),
    1164                     ("%u\n", pProps->cbSampleX), false);
    1165     AssertMsgReturn(pProps->cbFrame == pProps->cbSampleX * pProps->cChannelsX,
    1166                     ("cbFrame=%u cbSample=%u cChannels=%u\n", pProps->cbFrame, pProps->cbSampleX, pProps->cChannelsX),
    1167                     false);
    1168     AssertMsgReturn(pProps->uHz >= 1000 && pProps->uHz < 1000000, ("%u\n", pProps->uHz), false);
    1169     AssertMsgReturn(pProps->cShiftX == PDMAUDIOPCMPROPS_MAKE_SHIFT(pProps),
    1170                     ("cShift=%u cbSample=%u cChannels=%u\n", pProps->cShiftX, pProps->cbSampleX, pProps->cChannelsX),
    1171                     false);
    1172     AssertReturn(!pProps->fRaw || (pProps->fSigned && pProps->cbSampleX == sizeof(int64_t)), false);
    1173     return true;
     1160        /* Channels. */
     1161    if (   pProps->cChannelsX != 0
     1162        && pProps->cChannelsX <= PDMAUDIO_MAX_CHANNELS
     1163        /* Sample size. */
     1164        && (   pProps->cbSampleX == 1
     1165            || pProps->cbSampleX == 2
     1166            || pProps->cbSampleX == 4
     1167            || (pProps->cbSampleX == 8 && pProps->fRaw))
     1168        /* Hertz rate. */
     1169        && pProps->uHz >= 1000
     1170        && pProps->uHz < 1000000
     1171        /* Raw format: Here we only support int64_t as sample size currently, if enabled. */
     1172        && (   !pProps->fRaw
     1173            || (pProps->fSigned && pProps->cbSampleX == sizeof(int64_t)))
     1174       )
     1175    {
     1176        /* A few more sanity checks to see if the structure has been properly initialized (via PDMAudioPropsInit[Ex]). */
     1177        AssertMsgReturn(pProps->cShiftX == PDMAUDIOPCMPROPS_MAKE_SHIFT(pProps),
     1178                        ("cShift=%u cbSample=%u cChannels=%u\n", pProps->cShiftX, pProps->cbSampleX, pProps->cChannelsX),
     1179                        false);
     1180        AssertMsgReturn(pProps->cbFrame == pProps->cbSampleX * pProps->cChannelsX,
     1181                        ("cbFrame=%u cbSample=%u cChannels=%u\n", pProps->cbFrame, pProps->cbSampleX, pProps->cChannelsX),
     1182                        false);
     1183
     1184        return true;
     1185    }
     1186
     1187    return false;
    11741188}
    11751189
Note: See TracChangeset for help on using the changeset viewer.

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