Changeset 94993 in vbox
- Timestamp:
- May 12, 2022 1:57:54 PM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 151418
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vmm/pdmaudioinline.h
r93115 r94993 1150 1150 * @param pProps The PCM properties to check. 1151 1151 * 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. 1154 1153 * 1155 1154 * @sa PDMAudioStrmCfgIsValid … … 1159 1158 AssertPtrReturn(pProps, false); 1160 1159 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; 1174 1188 } 1175 1189 -
trunk/src/VBox/Devices/Audio/AudioHlp.cpp
r93115 r94993 128 128 if ( pCfg->enmDir == PDMAUDIODIR_IN 129 129 || pCfg->enmDir == PDMAUDIODIR_OUT) 130 return AudioHlpPcmPropsAreValid (&pCfg->Props);130 return AudioHlpPcmPropsAreValidAndSupported(&pCfg->Props); 131 131 } 132 132 } … … 152 152 153 153 /** 154 * Checks whether given PCM properties are valid or not. 155 * 156 * @note This is more of a supported than valid check. There is code for 157 * unsigned samples elsewhere (like DrvAudioHlpClearBuf()), but this 158 * function will flag such properties as not valid. 159 * 160 * @todo r=bird: See note and explain properly. Perhaps rename to 161 * AudioHlpPcmPropsAreValidAndSupported? 162 * 163 * @returns @c true if the properties are valid, @c false if not. 154 * Checks whether given PCM properties are valid *and* supported by the audio stack or not. 155 * 156 * @returns @c true if the properties are valid and supported, @c false if not. 164 157 * @param pProps The PCM properties to check. 165 */ 166 bool AudioHlpPcmPropsAreValid(PCPDMAUDIOPCMPROPS pProps) 158 * 159 * @note Use PDMAudioPropsAreValid() to just check the validation bits. 160 */ 161 bool AudioHlpPcmPropsAreValidAndSupported(PCPDMAUDIOPCMPROPS pProps) 167 162 { 168 163 AssertPtrReturn(pProps, false); 169 AssertReturn(PDMAudioPropsAreValid(pProps), false); 170 164 165 if (!PDMAudioPropsAreValid(pProps)) 166 return false; 167 168 /* Properties seem valid, now check if we actually support those. */ 171 169 switch (PDMAudioPropsSampleSize(pProps)) 172 170 { 173 171 case 1: /* 8 bit */ 174 if (PDMAudioPropsIsSigned(pProps)) 175 return false; 176 break; 172 /* Signed / unsigned. */ 173 break; 177 174 case 2: /* 16 bit */ 178 if (!PDMAudioPropsIsSigned(pProps)) 179 return false; 175 /* Signed / unsigned. */ 180 176 break; 181 177 /** @todo Do we need support for 24 bit samples? */ 182 178 case 4: /* 32 bit */ 183 if (!PDMAudioPropsIsSigned(pProps)) 184 return false; 179 /* Signed / unsigned. */ 185 180 break; 186 181 case 8: /* 64-bit raw */ -
trunk/src/VBox/Devices/Audio/AudioHlp.h
r93115 r94993 38 38 /** @name Audio PCM properties helper methods. 39 39 * @{ */ 40 bool AudioHlpPcmPropsAreValid (PCPDMAUDIOPCMPROPS pProps);40 bool AudioHlpPcmPropsAreValidAndSupported(PCPDMAUDIOPCMPROPS pProps); 41 41 /** @} */ 42 42 -
trunk/src/VBox/Devices/Audio/AudioMixer.cpp
r93115 r94993 958 958 AssertReturn(pSink->uMagic == AUDMIXSINK_MAGIC, VERR_INVALID_MAGIC); 959 959 AssertPtrReturn(pProps, VERR_INVALID_POINTER); 960 AssertReturn(AudioHlpPcmPropsAreValid (pProps), VERR_INVALID_PARAMETER);960 AssertReturn(AudioHlpPcmPropsAreValidAndSupported(pProps), VERR_INVALID_PARAMETER); 961 961 962 962 /* … … 2287 2287 * mixing. The mixing is done here and we bridge guest & host configs.) 2288 2288 */ 2289 AssertMsg(AudioHlpPcmPropsAreValid (&pSink->PCMProps),2290 ("%s: Does not (yet) have a format set when it must\n", pSink->pszName));2289 AssertMsg(AudioHlpPcmPropsAreValidAndSupported(&pSink->PCMProps), 2290 ("%s: Does not (yet) have a (valid and supported) format set when it must\n", pSink->pszName)); 2291 2291 2292 2292 PDMAUDIOSTREAMCFG CfgHost; -
trunk/src/VBox/Devices/Audio/DevHdaStream.cpp
r93115 r94993 1056 1056 && pStreamR3->Dbg.Runtime.fEnabled) 1057 1057 { 1058 Assert(AudioHlpPcmPropsAreValid (&pStreamShared->State.Cfg.Props));1058 Assert(AudioHlpPcmPropsAreValidAndSupported(&pStreamShared->State.Cfg.Props)); 1059 1059 1060 1060 if (fEnable) -
trunk/src/VBox/Devices/Audio/DevSB16.cpp
r94829 r94993 2523 2523 { 2524 2524 /* Sanity: If stream is going be enabled, PCM props must be valid. Otherwise the saved state is borked somehow. */ 2525 AssertMsgReturn(AudioHlpPcmPropsAreValid (&pStream->Cfg.Props),2525 AssertMsgReturn(AudioHlpPcmPropsAreValidAndSupported(&pStream->Cfg.Props), 2526 2526 ("PCM properties for stream #%RU8 are invalid\n", pStream->uIdx), VERR_SSM_DATA_UNIT_FORMAT_CHANGED); 2527 2527 sb16StreamControl(pDevIns, pThis, pStream, true /* fRun */); -
trunk/src/VBox/Devices/Audio/DrvAudio.cpp
r93115 r94993 1081 1081 1082 1082 /* Validate PCM properties. */ 1083 if (!AudioHlpPcmPropsAreValid (&pCfg->Props))1083 if (!AudioHlpPcmPropsAreValidAndSupported(&pCfg->Props)) 1084 1084 { 1085 1085 LogRel(("Audio: Invalid custom PCM properties set for stream '%s', cannot create stream\n", pszName)); -
trunk/src/VBox/Devices/Audio/testcase/tstAudioMixBuffer.cpp
r93944 r94993 78 78 RTTESTI_CHECK(PDMAudioPropsGetBitrate(&Cfg441StereoU32) == 44100*8*8); 79 79 80 RTTESTI_CHECK(AudioHlpPcmPropsAreValid (&Cfg441StereoS16));81 RTTESTI_CHECK(AudioHlpPcmPropsAreValid (&Cfg441StereoU16) == false); /* go figure */82 RTTESTI_CHECK(AudioHlpPcmPropsAreValid (&Cfg441StereoU32) == false); /* go figure */80 RTTESTI_CHECK(AudioHlpPcmPropsAreValidAndSupported(&Cfg441StereoS16)); 81 RTTESTI_CHECK(AudioHlpPcmPropsAreValidAndSupported(&Cfg441StereoU16) == false); /* go figure */ 82 RTTESTI_CHECK(AudioHlpPcmPropsAreValidAndSupported(&Cfg441StereoU32) == false); /* go figure */ 83 83 84 84 … … 210 210 ); 211 211 212 RTTESTI_CHECK(AudioHlpPcmPropsAreValid (&config));212 RTTESTI_CHECK(AudioHlpPcmPropsAreValidAndSupported(&config)); 213 213 214 214 uint32_t cBufSize = _1K; … … 658 658 uint32_t const cFrames = RTRandU32Ex(16, RT_ELEMENTS(aSrcFrames)); 659 659 PDMAUDIOPCMPROPS const CfgSrc = PDMAUDIOPCMPROPS_INITIALIZER(2 /*cbSample*/, true /*fSigned*/, 2 /*ch*/, uFromHz, false /*fSwap*/); 660 RTTESTI_CHECK(AudioHlpPcmPropsAreValid (&CfgSrc));660 RTTESTI_CHECK(AudioHlpPcmPropsAreValidAndSupported(&CfgSrc)); 661 661 AUDIOMIXBUF MixBuf; 662 662 RTTESTI_CHECK_RC_OK_RETV(AudioMixBufInit(&MixBuf, "NewPeekMixBuf", &CfgSrc, cFrames)); … … 668 668 /* Peek state (destination) is uToHz 2ch S16 */ 669 669 PDMAUDIOPCMPROPS const CfgDst = PDMAUDIOPCMPROPS_INITIALIZER(2 /*cbSample*/, true /*fSigned*/, 2 /*ch*/, uToHz, false /*fSwap*/); 670 RTTESTI_CHECK(AudioHlpPcmPropsAreValid (&CfgDst));670 RTTESTI_CHECK(AudioHlpPcmPropsAreValidAndSupported(&CfgDst)); 671 671 AUDIOMIXBUFPEEKSTATE PeekState; 672 672 RTTESTI_CHECK_RC_OK_RETV(AudioMixBufInitPeekState(&MixBuf, &PeekState, &CfgDst));
Note:
See TracChangeset
for help on using the changeset viewer.