Changeset 89768 in vbox for trunk/src/VBox/Devices/Audio
- Timestamp:
- Jun 17, 2021 11:03:19 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 145220
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/AudioMixBuffer.cpp
r89529 r89768 2082 2082 AssertPtrReturnVoid(pVol); 2083 2083 2084 LogFlowFunc(("%s: lVol=%RU8, rVol=%RU8, fMuted=%RTbool\n", pMixBuf->pszName, pVol->uLeft, pVol->uRight, pVol->fMuted)); 2084 LogFlowFunc(("%s: fMuted=%RTbool auChannels=%.*Rhxs\n", 2085 pMixBuf->pszName, pVol->fMuted, sizeof(pVol->auChannels), pVol->auChannels)); 2085 2086 2086 2087 /* … … 2091 2092 pMixBuf->Volume.fMuted = false; 2092 2093 2093 AssertCompileSize(pVol->uLeft, sizeof(uint8_t)); 2094 pMixBuf->Volume.auChannels[0] = s_aVolumeConv[pVol->uLeft ] * (AUDIOMIXBUF_VOL_0DB >> 16); 2095 pMixBuf->Volume.auChannels[1] = s_aVolumeConv[pVol->uRight] * (AUDIOMIXBUF_VOL_0DB >> 16); 2094 AssertCompileSize(pVol->auChannels[0], sizeof(uint8_t)); 2096 2095 for (uintptr_t i = 2; i < pMixBuf->cChannels; i++) 2097 pMixBuf->Volume.auChannels[i] = pMixBuf->Volume.auChannels[1];2096 pMixBuf->Volume.auChannels[i] = s_aVolumeConv[pVol->auChannels[i]] * (AUDIOMIXBUF_VOL_0DB >> 16); 2098 2097 2099 2098 pMixBuf->Volume.fAllMax = true; -
trunk/src/VBox/Devices/Audio/AudioMixer.cpp
r89559 r89768 193 193 194 194 /* Set master volume to the max. */ 195 pMixer->VolMaster.fMuted = false; 196 pMixer->VolMaster.uLeft = PDMAUDIO_VOLUME_MAX; 197 pMixer->VolMaster.uRight = PDMAUDIO_VOLUME_MAX; 195 PDMAudioVolumeInitMax(&pMixer->VolMaster); 198 196 199 197 LogFlowFunc(("Created mixer '%s'\n", pMixer->pszName)); … … 262 260 AssertRCReturnVoid(rc2); 263 261 264 pHlp->pfnPrintf(pHlp, "[Master] %s: lVol=%u, rVol=%u, fMuted=%RTbool\n", pMixer->pszName,265 pMixer-> VolMaster.uLeft, pMixer->VolMaster.uRight, pMixer->VolMaster.fMuted);262 pHlp->pfnPrintf(pHlp, "[Master] %s: fMuted=%RTbool auChannels=%.*Rhxs\n", 263 pMixer->pszName, pMixer->VolMaster.fMuted, sizeof(pMixer->VolMaster.auChannels), pMixer->VolMaster.auChannels); 266 264 267 265 PAUDMIXSINK pSink; … … 269 267 RTListForEach(&pMixer->lstSinks, pSink, AUDMIXSINK, Node) 270 268 { 271 pHlp->pfnPrintf(pHlp, "[Sink %u] %s: lVol=%u, rVol=%u, fMuted=%RTbool\n", iSink, pSink->pszName,272 pSink->Volume.uLeft, pSink->Volume.uRight, pSink->Volume.fMuted);269 pHlp->pfnPrintf(pHlp, "[Sink %u] %s: fMuted=%RTbool auChannels=%.*Rhxs\n", 270 iSink, pSink->pszName, pSink->Volume.fMuted, sizeof(pSink->Volume.auChannels), pSink->Volume.auChannels); 273 271 ++iSink; 274 272 } … … 298 296 * Make a copy. 299 297 */ 298 LogFlowFunc(("[%s] fMuted=%RTbool auChannels=%.*Rhxs => fMuted=%RTbool auChannels=%.*Rhxs\n", pMixer->pszName, 299 pMixer->VolMaster.fMuted, sizeof(pMixer->VolMaster.auChannels), pMixer->VolMaster.auChannels, 300 pVol->fMuted, sizeof(pVol->auChannels), pVol->auChannels )); 300 301 memcpy(&pMixer->VolMaster, pVol, sizeof(PDMAUDIOVOLUME)); 301 LogFlowFunc(("[%s] lVol=%RU32, rVol=%RU32 => fMuted=%RTbool, lVol=%RU32, rVol=%RU32\n",302 pMixer->pszName, pVol->uLeft, pVol->uRight,303 pMixer->VolMaster.fMuted, pMixer->VolMaster.uLeft, pMixer->VolMaster.uRight));304 302 305 303 /* … … 395 393 396 394 /* Set initial volume to max. */ 397 pSink->Volume.fMuted = false; 398 pSink->Volume.uLeft = PDMAUDIO_VOLUME_MAX; 399 pSink->Volume.uRight = PDMAUDIO_VOLUME_MAX; 395 PDMAudioVolumeInitMax(&pSink->Volume); 400 396 401 397 /* Ditto for the combined volume. */ 402 pSink->VolumeCombined.fMuted = false; 403 pSink->VolumeCombined.uLeft = PDMAUDIO_VOLUME_MAX; 404 pSink->VolumeCombined.uRight = PDMAUDIO_VOLUME_MAX; 398 PDMAudioVolumeInitMax(&pSink->VolumeCombined); 405 399 406 400 /* AIO */ … … 1062 1056 Assert(pSink->uMagic == AUDMIXSINK_MAGIC); 1063 1057 AssertPtr(pVolMaster); 1064 LogFlowFunc(("[%s] Master fMuted=%RTbool, lVol=%RU32, rVol=%RU32\n", 1065 pSink->pszName, pVolMaster->fMuted, pVolMaster->uLeft, pVolMaster->uRight)); 1066 1067 pSink->VolumeCombined.fMuted = pVolMaster->fMuted || pSink->Volume.fMuted; 1068 /** @todo Very crude implementation for now -- needs more work! */ 1069 pSink->VolumeCombined.uLeft = (uint32_t)RT_MAX(pSink->Volume.uLeft, 1) * RT_MAX(pVolMaster->uLeft, 1) / PDMAUDIO_VOLUME_MAX; 1070 pSink->VolumeCombined.uRight = (uint32_t)RT_MAX(pSink->Volume.uRight, 1) * RT_MAX(pVolMaster->uRight, 1) / PDMAUDIO_VOLUME_MAX; 1071 1072 LogFlowFunc(("[%s] fMuted=%RTbool, lVol=%RU32, rVol=%RU32 -> fMuted=%RTbool, lVol=%RU32, rVol=%RU32\n", 1073 pSink->pszName, pSink->Volume.fMuted, pSink->Volume.uLeft, pSink->Volume.uRight, 1074 pSink->VolumeCombined.fMuted, pSink->VolumeCombined.uLeft, pSink->VolumeCombined.uRight)); 1058 LogFlowFunc(("[%s] Master fMuted=%RTbool auChannels=%.*Rhxs\n", 1059 pSink->pszName, pVolMaster->fMuted, sizeof(pVolMaster->auChannels), pVolMaster->auChannels)); 1060 1061 PDMAudioVolumeCombine(&pSink->VolumeCombined, &pSink->Volume, pVolMaster); 1062 1063 LogFlowFunc(("[%s] fMuted=%RTbool auChannels=%.*Rhxs -> fMuted=%RTbool auChannels=%.*Rhxs\n", pSink->pszName, 1064 pSink->Volume.fMuted, sizeof(pSink->Volume.auChannels), pSink->Volume.auChannels, 1065 pSink->VolumeCombined.fMuted, sizeof(pSink->VolumeCombined.auChannels), pSink->VolumeCombined.auChannels )); 1075 1066 1076 1067 AudioMixBufSetVolume(&pSink->MixBuf, &pSink->VolumeCombined); … … 1097 1088 memcpy(&pSink->Volume, pVol, sizeof(PDMAUDIOVOLUME)); 1098 1089 1099 LogRel2(("Audio Mixer: Setting volume of sink '%s' to %RU8/%RU8 (%s)\n",1100 pSink->pszName, pVol->uLeft, pVol->uRight, pVol->fMuted ? "Muted" : "Unmuted"));1090 LogRel2(("Audio Mixer: Setting volume of sink '%s' to fMuted=%RTbool auChannels=%.*Rhxs\n", 1091 pSink->pszName, pVol->fMuted, sizeof(pVol->auChannels), pVol->auChannels)); 1101 1092 1102 1093 Assert(pSink->pParent); -
trunk/src/VBox/Devices/Audio/DevHda.cpp
r89757 r89768 2585 2585 && pSink->pMixSink) 2586 2586 { 2587 LogRel2(("HDA: Setting volume for mixer sink '%s' to %RU8/%RU8 (%s)\n",2588 pSink->pMixSink->pszName, pVol-> uLeft, pVol->uRight, pVol->fMuted ? "Muted" : "Unmuted"));2587 LogRel2(("HDA: Setting volume for mixer sink '%s' to fMuted=%RTbool auChannels=%.*Rhxs\n", 2588 pSink->pMixSink->pszName, pVol->fMuted, sizeof(pVol->auChannels), pVol->auChannels)); 2589 2589 2590 2590 /* Set the volume. … … 4921 4921 4922 4922 /* There is no master volume control. Set the master to max. */ 4923 PDMAUDIOVOLUME vol = { false, 255, 255 };4924 rc = AudioMixerSetMasterVolume(pThisCC->pMixer, & vol);4923 PDMAUDIOVOLUME Vol = PDMAUDIOVOLUME_INITIALIZER_MAX; 4924 rc = AudioMixerSetMasterVolume(pThisCC->pMixer, &Vol); 4925 4925 AssertRCReturn(rc, rc); 4926 4926 -
trunk/src/VBox/Devices/Audio/DevHdaCodec.cpp
r89213 r89768 896 896 iMute &= 0x1; 897 897 898 uint8_t lVol= AMPLIFIER_REGISTER(*pAmp, iDir, AMPLIFIER_LEFT, 0) & 0x7f;899 uint8_t rVol= AMPLIFIER_REGISTER(*pAmp, iDir, AMPLIFIER_RIGHT, 0) & 0x7f;898 uint8_t bLeft = AMPLIFIER_REGISTER(*pAmp, iDir, AMPLIFIER_LEFT, 0) & 0x7f; 899 uint8_t bRight = AMPLIFIER_REGISTER(*pAmp, iDir, AMPLIFIER_RIGHT, 0) & 0x7f; 900 900 901 901 /* … … 905 905 * to 1 (rather than zero) internally. 906 906 */ 907 lVol = (lVol + 1) * (2 * 255) / 256; 908 rVol = (rVol + 1) * (2 * 255) / 256; 909 910 PDMAUDIOVOLUME Vol = { RT_BOOL(iMute), lVol, rVol }; 911 912 LogFunc(("[NID0x%02x] %RU8/%RU8 (%s)\n", 913 pNode->node.uID, lVol, rVol, RT_BOOL(iMute) ? "Muted" : "Unmuted")); 914 915 LogRel2(("HDA: Setting volume for mixer control '%s' to %RU8/%RU8 (%s)\n", 916 PDMAudioMixerCtlGetName(enmMixerCtl), lVol, rVol, RT_BOOL(iMute) ? "Muted" : "Unmuted")); 907 bLeft = (bLeft + 1) * (2 * 255) / 256; 908 bRight = (bRight + 1) * (2 * 255) / 256; 909 910 PDMAUDIOVOLUME Vol; 911 PDMAudioVolumeInitFromStereo(&Vol, RT_BOOL(iMute), bLeft, bRight); 912 913 LogFunc(("[NID0x%02x] %RU8/%RU8%s\n", pNode->node.uID, bLeft, bRight, Vol.fMuted ? "- Muted!" : "")); 914 LogRel2(("HDA: Setting volume for mixer control '%s' to %RU8/%RU8%s\n", 915 PDMAudioMixerCtlGetName(enmMixerCtl), bLeft, bRight, Vol.fMuted ? "- Muted!" : "")); 917 916 918 917 return pThisCC->pfnCbMixerSetVolume(pThisCC->pDevIns, enmMixerCtl, &Vol); -
trunk/src/VBox/Devices/Audio/DevIchAc97.cpp
r89759 r89768 1276 1276 { 1277 1277 STAM_REL_COUNTER_INC(&pStreamCC->State.StatDmaFlowProblems); 1278 Log (("ichac97R3StreamUpdateDma:Warning! Stream #%u has insufficient space free: %u bytes, need %u. Will try move data out of the buffer...\n",1278 LogFunc(("Warning! Stream #%u has insufficient space free: %u bytes, need %u. Will try move data out of the buffer...\n", 1279 1279 pStreamCC->u8SD, cbStreamFree, cbPeriod)); 1280 1280 int rc = AudioMixerSinkTryLock(pSink); … … 1287 1287 else 1288 1288 RTThreadYield(); 1289 Log (("ichac97R3StreamUpdateDma:Gained %u bytes.\n", ichac97R3StreamGetFree(pStreamCC) - cbStreamFree));1289 LogFunc(("Gained %u bytes.\n", ichac97R3StreamGetFree(pStreamCC) - cbStreamFree)); 1290 1290 1291 1291 cbStreamFree = ichac97R3StreamGetFree(pStreamCC); … … 1356 1356 if (cbStreamUsed < cbPreBuffer) 1357 1357 { 1358 Log3 (("hdaR3StreamUpdateDma:Pre-buffering (got %#x out of %#x bytes)...\n", cbStreamUsed, cbPreBuffer));1358 Log3Func(("Pre-buffering (got %#x out of %#x bytes)...\n", cbStreamUsed, cbPreBuffer)); 1359 1359 fWriteSilence = true; 1360 1360 cbStreamUsed = cbPeriod; … … 1362 1362 else 1363 1363 { 1364 Log3 (("hdaR3StreamUpdateDma:Completed pre-buffering (got %#x, needed %#x bytes).\n", cbStreamUsed, cbPreBuffer));1364 Log3Func(("Completed pre-buffering (got %#x, needed %#x bytes).\n", cbStreamUsed, cbPreBuffer)); 1365 1365 pStreamCC->State.fInputPreBuffered = true; 1366 1366 fWriteSilence = ichac97R3StreamGetFree(pStreamCC) >= cbPreBuffer + cbPreBuffer / 2; … … 1376 1376 { 1377 1377 STAM_REL_COUNTER_INC(&pStreamCC->State.StatDmaFlowProblems); 1378 Log (("ichac97R3StreamUpdateDma:Warning! Stream #%u has insufficient data available: %u bytes, need %u. Will try move pull more data into the buffer...\n",1378 LogFunc(("Warning! Stream #%u has insufficient data available: %u bytes, need %u. Will try move pull more data into the buffer...\n", 1379 1379 pStreamCC->u8SD, cbStreamUsed, cbPeriod)); 1380 1380 int rc = AudioMixerSinkTryLock(pSink); … … 1387 1387 else 1388 1388 RTThreadYield(); 1389 Log (("ichac97R3StreamUpdateDma:Gained %u bytes.\n", ichac97R3StreamGetUsed(pStreamCC) - cbStreamUsed));1389 LogFunc(("Gained %u bytes.\n", ichac97R3StreamGetUsed(pStreamCC) - cbStreamUsed)); 1390 1390 cbStreamUsed = ichac97R3StreamGetUsed(pStreamCC); 1391 1391 if (cbStreamUsed < cbPeriod) … … 3034 3034 if (pThisCC->pMixer) /* Device can be in reset state, so no mixer available. */ 3035 3035 { 3036 PDMAUDIOVOLUME Vol = { fCtlMuted, lVol, rVol }; 3037 PAUDMIXSINK pSink = NULL; 3038 3036 PDMAUDIOVOLUME Vol; 3037 PDMAudioVolumeInitFromStereo(&Vol, fCtlMuted, lVol, rVol); 3038 3039 PAUDMIXSINK pSink = NULL; 3039 3040 switch (enmMixerCtl) 3040 3041 { … … 3118 3119 if (pThisCC->pMixer) /* Device can be in reset state, so no mixer available. */ 3119 3120 { 3120 PDMAUDIOVOLUME Vol = { fCtlMuted, lVol, rVol }; 3121 PDMAUDIOVOLUME Vol; 3122 PDMAudioVolumeInitFromStereo(&Vol, fCtlMuted, lVol, rVol); 3123 3121 3124 PAUDMIXSINK pSink = NULL; 3122 3123 3125 switch (enmMixerCtl) 3124 3126 { … … 3137 3139 } 3138 3140 3139 if (pSink) { 3141 if (pSink) 3142 { 3140 3143 rc = AudioMixerSinkSetVolume(pSink, &Vol); 3141 3144 /* There is only one AC'97 recording gain control. If line in … … 3144 3147 * NB: The codecs we support do not have the dedicated microphone control. 3145 3148 */ 3146 if ( (pSink == pThisCC->pSinkLineIn)&& pThisCC->pSinkMicIn)3149 if (pSink == pThisCC->pSinkLineIn && pThisCC->pSinkMicIn) 3147 3150 rc = AudioMixerSinkSetVolume(pSink, &Vol); 3148 3151 } -
trunk/src/VBox/Devices/Audio/DevSB16.cpp
r89379 r89768 1183 1183 * @param pVol Where to store the master volume information. 1184 1184 */ 1185 static voidsb16GetMasterVolume(PSB16STATE pThis, PPDMAUDIOVOLUME pVol)1185 DECLINLINE(void) sb16GetMasterVolume(PSB16STATE pThis, PPDMAUDIOVOLUME pVol) 1186 1186 { 1187 1187 /* There's no mute switch, only volume controls. */ 1188 uint8_t lvol = sb16MixRegToVol(pThis, 0x30); 1189 uint8_t rvol = sb16MixRegToVol(pThis, 0x31); 1190 1191 pVol->fMuted = false; 1192 pVol->uLeft = lvol; 1193 pVol->uRight = rvol; 1188 PDMAudioVolumeInitFromStereo(pVol, false /*fMuted*/, sb16MixRegToVol(pThis, 0x30), sb16MixRegToVol(pThis, 0x31)); 1194 1189 } 1195 1190 … … 1200 1195 * @param pVol Where to store the output stream volume information. 1201 1196 */ 1202 static voidsb16GetPcmOutVolume(PSB16STATE pThis, PPDMAUDIOVOLUME pVol)1197 DECLINLINE(void) sb16GetPcmOutVolume(PSB16STATE pThis, PPDMAUDIOVOLUME pVol) 1203 1198 { 1204 1199 /* There's no mute switch, only volume controls. */ 1205 uint8_t lvol = sb16MixRegToVol(pThis, 0x32); 1206 uint8_t rvol = sb16MixRegToVol(pThis, 0x33); 1207 1208 pVol->fMuted = false; 1209 pVol->uLeft = lvol; 1210 pVol->uRight = rvol; 1200 PDMAudioVolumeInitFromStereo(pVol, false /*fMuted*/, sb16MixRegToVol(pThis, 0x32), sb16MixRegToVol(pThis, 0x33)); 1211 1201 } 1212 1202 … … 1221 1211 /* Combine the master + output stream volume. */ 1222 1212 PDMAUDIOVOLUME VolCombined; 1223 RT_ZERO(VolCombined); 1224 1225 VolCombined.fMuted = VolMaster.fMuted || VolOut.fMuted; 1226 if (!VolCombined.fMuted) 1227 { 1228 VolCombined.uLeft = ( (VolOut.uLeft ? VolOut.uLeft : 1) 1229 * (VolMaster.uLeft ? VolMaster.uLeft : 1)) / PDMAUDIO_VOLUME_MAX; 1230 1231 VolCombined.uRight = ( (VolOut.uRight ? VolOut.uRight : 1) 1232 * (VolMaster.uRight ? VolMaster.uRight : 1)) / PDMAUDIO_VOLUME_MAX; 1233 } 1213 PDMAudioVolumeCombine(&VolCombined, &VolMaster, &VolOut); 1234 1214 1235 1215 int rc2 = AudioMixerSinkSetVolume(pThis->pSinkOut, &VolCombined); -
trunk/src/VBox/Devices/Audio/testcase/tstAudioMixBuffer.cpp
r89377 r89768 794 794 * 1) Full volume/0dB attenuation (255). 795 795 */ 796 PDMAUDIOVOLUME Vol; 797 Vol.fMuted = false; 798 Vol.uLeft = 255; 799 Vol.uRight = 255; 796 PDMAUDIOVOLUME Vol = PDMAUDIOVOLUME_INITIALIZER_MAX; 800 797 AudioMixBufSetVolume(&MixBuf, &Vol); 801 798 … … 826 823 * 2) Half volume/-6dB attenuation (16 steps down). 827 824 */ 828 Vol.uLeft = 255 - 16; 829 Vol.uRight = 255 - 16; 825 PDMAudioVolumeInitFromStereo(&Vol, false, 255 - 16, 255 - 16); 830 826 AudioMixBufSetVolume(&MixBuf, &Vol); 831 827
Note:
See TracChangeset
for help on using the changeset viewer.