Changeset 89564 in vbox
- Timestamp:
- Jun 8, 2021 9:24:27 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvAudio.cpp
r89556 r89564 1091 1091 1092 1092 /* 1093 * Buffer size 1094 */ 1095 const char *pszWhat = "device-specific"; 1096 if (pDrvCfg->uBufferSizeMs) 1097 { 1098 pCfg->Backend.cFramesBufferSize = PDMAudioPropsMilliToFrames(&pCfg->Props, pDrvCfg->uBufferSizeMs); 1099 pszWhat = "custom"; 1100 } 1101 1102 if (!pCfg->Backend.cFramesBufferSize) /* Set default buffer size if nothing explicitly is set. */ 1103 { 1104 pCfg->Backend.cFramesBufferSize = PDMAudioPropsMilliToFrames(&pCfg->Props, 300 /*ms*/); 1105 pszWhat = "default"; 1106 } 1107 1108 LogRel2(("Audio: Using %s buffer size %RU64 ms / %RU32 frames for stream '%s'\n", 1109 pszWhat, PDMAudioPropsFramesToMilli(&pCfg->Props, pCfg->Backend.cFramesBufferSize), 1110 pCfg->Backend.cFramesBufferSize, pszName)); 1111 1112 /* 1093 1113 * Period size 1094 1114 */ 1095 const char *pszWhat = "device-specific";1115 pszWhat = "device-specific"; 1096 1116 if (pDrvCfg->uPeriodSizeMs) 1097 1117 { … … 1102 1122 if (!pCfg->Backend.cFramesPeriod) /* Set default period size if nothing explicitly is set. */ 1103 1123 { 1104 pCfg->Backend.cFramesPeriod = PDMAudioPropsMilliToFrames(&pCfg->Props, 150 /*ms*/);1124 pCfg->Backend.cFramesPeriod = pCfg->Backend.cFramesBufferSize / 4; 1105 1125 pszWhat = "default"; 1126 } 1127 1128 if (pCfg->Backend.cFramesPeriod >= pCfg->Backend.cFramesBufferSize / 2) 1129 { 1130 LogRel(("Audio: Warning! Stream '%s': The stream period size (%RU64ms, %s) cannot be more than half the buffer size (%RU64ms)!\n", 1131 pszName, PDMAudioPropsFramesToMilli(&pCfg->Props, pCfg->Backend.cFramesPeriod), pszWhat, 1132 PDMAudioPropsFramesToMilli(&pCfg->Props, pCfg->Backend.cFramesBufferSize))); 1133 pCfg->Backend.cFramesPeriod = pCfg->Backend.cFramesBufferSize / 2; 1106 1134 } 1107 1135 … … 1109 1137 pszWhat, PDMAudioPropsFramesToMilli(&pCfg->Props, pCfg->Backend.cFramesPeriod), 1110 1138 pCfg->Backend.cFramesPeriod, pszName)); 1111 1112 /*1113 * Buffer size1114 */1115 pszWhat = "device-specific";1116 if (pDrvCfg->uBufferSizeMs)1117 {1118 pCfg->Backend.cFramesBufferSize = PDMAudioPropsMilliToFrames(&pCfg->Props, pDrvCfg->uBufferSizeMs);1119 pszWhat = "custom";1120 }1121 1122 if (!pCfg->Backend.cFramesBufferSize) /* Set default buffer size if nothing explicitly is set. */1123 {1124 pCfg->Backend.cFramesBufferSize = PDMAudioPropsMilliToFrames(&pCfg->Props, 300 /*ms*/);1125 pszWhat = "default";1126 }1127 1128 LogRel2(("Audio: Using %s buffer size %RU64 ms / %RU32 frames for stream '%s'\n",1129 pszWhat, PDMAudioPropsFramesToMilli(&pCfg->Props, pCfg->Backend.cFramesBufferSize),1130 pCfg->Backend.cFramesBufferSize, pszName));1131 1139 1132 1140 /* … … 1154 1162 } 1155 1163 1164 if (pCfg->Backend.cFramesPreBuffering >= pCfg->Backend.cFramesBufferSize) 1165 { 1166 LogRel(("Audio: Warning! Stream '%s': Pre-buffering (%RU64ms, %s) cannot equal or exceed the buffer size (%RU64ms)!\n", 1167 pszName, PDMAudioPropsFramesToMilli(&pCfg->Props, pCfg->Backend.cFramesBufferSize), pszWhat, 1168 PDMAudioPropsFramesToMilli(&pCfg->Props, pCfg->Backend.cFramesPreBuffering) )); 1169 pCfg->Backend.cFramesPreBuffering = pCfg->Backend.cFramesBufferSize - 1; 1170 } 1171 1156 1172 LogRel2(("Audio: Using %s pre-buffering size %RU64 ms / %RU32 frames for stream '%s'\n", 1157 1173 pszWhat, PDMAudioPropsFramesToMilli(&pCfg->Props, pCfg->Backend.cFramesPreBuffering), 1158 1174 pCfg->Backend.cFramesPreBuffering, pszName)); 1159 1160 /*1161 * Validate input.1162 */1163 if (pCfg->Backend.cFramesBufferSize < pCfg->Backend.cFramesPeriod)1164 {1165 LogRel(("Audio: Error for stream '%s': Buffering size (%RU64ms) must not be smaller than the period size (%RU64ms)\n",1166 pszName, PDMAudioPropsFramesToMilli(&pCfg->Props, pCfg->Backend.cFramesBufferSize),1167 PDMAudioPropsFramesToMilli(&pCfg->Props, pCfg->Backend.cFramesPeriod)));1168 return VERR_INVALID_PARAMETER;1169 }1170 1171 if ( pCfg->Backend.cFramesPreBuffering != UINT32_MAX /* Custom pre-buffering set? */1172 && pCfg->Backend.cFramesPreBuffering)1173 {1174 if (pCfg->Backend.cFramesBufferSize < pCfg->Backend.cFramesPreBuffering)1175 {1176 LogRel(("Audio: Error for stream '%s': Buffering size (%RU64ms) must not be smaller than the pre-buffering size (%RU64ms)\n",1177 pszName, PDMAudioPropsFramesToMilli(&pCfg->Props, pCfg->Backend.cFramesPreBuffering),1178 PDMAudioPropsFramesToMilli(&pCfg->Props, pCfg->Backend.cFramesBufferSize)));1179 return VERR_INVALID_PARAMETER;1180 }1181 }1182 1175 1183 1176 return VINF_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.