Changeset 69876 in vbox
- Timestamp:
- Nov 30, 2017 9:49:32 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevSB16.cpp
r69288 r69876 1214 1214 } 1215 1215 1216 static void sb16SetMasterVolume(PSB16STATE pThis) 1216 /** 1217 * Returns the device's current master volume. 1218 * 1219 * @param pThis SB16 state. 1220 * @param pVol Where to store the master volume information. 1221 */ 1222 static void sb16GetMasterVolume(PSB16STATE pThis, PPDMAUDIOVOLUME pVol) 1217 1223 { 1218 1224 /* There's no mute switch, only volume controls. */ … … 1220 1226 uint8_t rvol = sb16MixRegToVol(pThis, 0x31); 1221 1227 1222 PDMAUDIOVOLUME Vol = { false /* fMute */, lvol, rvol }; 1223 1224 PSB16DRIVER pDrv; 1225 RTListForEach(&pThis->lstDrv, pDrv, SB16DRIVER, Node) 1226 { 1227 int rc2 = pDrv->pConnector->pfnStreamSetVolume(pDrv->pConnector, pDrv->Out.pStream, &Vol); 1228 AssertRC(rc2); 1229 } 1230 } 1231 1232 static void sb16SetPcmOutVolume(PSB16STATE pThis) 1228 pVol->fMuted = false; 1229 pVol->uLeft = lvol; 1230 pVol->uRight = rvol; 1231 } 1232 1233 /** 1234 * Returns the device's current output stream volume. 1235 * 1236 * @param pThis SB16 state. 1237 * @param pVol Where to store the output stream volume information. 1238 */ 1239 static void sb16GetPcmOutVolume(PSB16STATE pThis, PPDMAUDIOVOLUME pVol) 1233 1240 { 1234 1241 /* There's no mute switch, only volume controls. */ … … 1236 1243 uint8_t rvol = sb16MixRegToVol(pThis, 0x33); 1237 1244 1238 PDMAUDIOVOLUME Vol = { false /* fMute */, lvol, rvol }; 1245 pVol->fMuted = false; 1246 pVol->uLeft = lvol; 1247 pVol->uRight = rvol; 1248 } 1249 1250 static void sb16UpdateVolume(PSB16STATE pThis) 1251 { 1252 PDMAUDIOVOLUME VolMaster; 1253 sb16GetMasterVolume(pThis, &VolMaster); 1254 1255 PDMAUDIOVOLUME VolOut; 1256 sb16GetPcmOutVolume(pThis, &VolOut); 1257 1258 /* Combine the master + output stream volume. */ 1259 PDMAUDIOVOLUME VolCombined; 1260 RT_ZERO(VolCombined); 1261 1262 VolCombined.fMuted = VolMaster.fMuted || VolOut.fMuted; 1263 if (!VolCombined.fMuted) 1264 { 1265 VolCombined.uLeft = ( (VolOut.uLeft ? VolOut.uLeft : 1) 1266 * (VolMaster.uLeft ? VolMaster.uLeft : 1)) / PDMAUDIO_VOLUME_MAX; 1267 1268 VolCombined.uRight = ( (VolOut.uRight ? VolOut.uRight : 1) 1269 * (VolMaster.uRight ? VolMaster.uRight : 1)) / PDMAUDIO_VOLUME_MAX; 1270 } 1239 1271 1240 1272 PSB16DRIVER pDrv; 1241 1273 RTListForEach(&pThis->lstDrv, pDrv, SB16DRIVER, Node) 1242 1274 { 1243 int rc2 = pDrv->pConnector->pfnStreamSetVolume(pDrv->pConnector, pDrv->Out.pStream, &Vol );1275 int rc2 = pDrv->pConnector->pfnStreamSetVolume(pDrv->pConnector, pDrv->Out.pStream, &VolCombined); 1244 1276 AssertRC(rc2); 1245 1277 } … … 1511 1543 1512 1544 /* Update the master (mixer) and PCM out volumes. */ 1513 sb16SetMasterVolume(pThis); 1514 sb16SetPcmOutVolume(pThis); 1545 sb16UpdateVolume(pThis); 1515 1546 } 1516 1547 … … 1686 1717 1687 1718 /* Update the master (mixer) volume. */ 1688 if (fUpdateMaster) 1689 sb16SetMasterVolume(pThis); 1690 1691 /* Update the stream (PCM) volume. */ 1692 if (fUpdateStream) 1693 sb16SetPcmOutVolume(pThis); 1719 if ( fUpdateMaster 1720 || fUpdateStream) 1721 { 1722 sb16UpdateVolume(pThis); 1723 } 1694 1724 1695 1725 return VINF_SUCCESS; … … 2184 2214 2185 2215 /* Update the master (mixer) and PCM out volumes. */ 2186 sb16SetMasterVolume(pThis); 2187 sb16SetPcmOutVolume(pThis); 2216 sb16UpdateVolume(pThis); 2188 2217 2189 2218 return VINF_SUCCESS; … … 2342 2371 rc = rc2; 2343 2372 } 2373 2374 sb16UpdateVolume(pThis); 2344 2375 2345 2376 LogFlowFuncLeaveRC(rc);
Note:
See TracChangeset
for help on using the changeset viewer.