Changeset 59275 in vbox
- Timestamp:
- Jan 7, 2016 11:57:56 AM (9 years ago)
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/AudioMixer.cpp
r58600 r59275 7 7 8 8 /* 9 * Copyright (C) 2014-201 5Oracle Corporation9 * Copyright (C) 2014-2016 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 250 250 } 251 251 252 int AudioMixerGetDeviceFormat(PAUDIOMIXER pMixer, PPDMAUDIOSTREAMCFG pCfg) 253 { 254 AssertPtrReturn(pMixer, VERR_INVALID_POINTER); 255 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); 256 257 /** @todo Perform a deep copy, if needed. */ 258 *pCfg = pMixer->devFmt; 259 260 return VINF_SUCCESS; 261 } 262 252 263 uint32_t AudioMixerGetStreamCount(PAUDIOMIXER pMixer) 253 264 { -
trunk/src/VBox/Devices/Audio/AudioMixer.h
r56689 r59275 7 7 8 8 /* 9 * Copyright (C) 2014-201 5Oracle Corporation9 * Copyright (C) 2014-2016 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 98 98 int AudioMixerCreate(const char *pszName, uint32_t uFlags, PAUDIOMIXER *ppMixer); 99 99 void AudioMixerDestroy(PAUDIOMIXER pMixer); 100 int AudioMixerGetDeviceFormat(PAUDIOMIXER pMixer, PPDMAUDIOSTREAMCFG pCfg); 100 101 uint32_t AudioMixerGetStreamCount(PAUDIOMIXER pMixer); 101 102 void AudioMixerInvalidate(PAUDIOMIXER pMixer); -
trunk/src/VBox/Devices/Audio/DevIchAc97.cpp
r59191 r59275 5 5 6 6 /* 7 * Copyright (C) 2006-201 5Oracle Corporation7 * Copyright (C) 2006-2016 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 36 36 #include "AudioMixBuffer.h" 37 37 #include "AudioMixer.h" 38 #include "DrvAudio.h" 38 39 39 40 … … 1173 1174 STAM_PROFILE_START(&pThis->StatTimer, a); 1174 1175 1175 int rc = VINF_SUCCESS;1176 1177 1176 uint32_t cbInMax = 0; 1178 1177 uint32_t cbOutMin = UINT32_MAX; … … 1185 1184 1186 1185 pThis->uTimerTS = cTicksNow; 1186 1187 /* 1188 * Calculate the mixer's (fixed) sampling rate. 1189 */ 1190 AssertPtr(pThis->pMixer); 1191 1192 PDMAUDIOSTREAMCFG mixerStrmCfg; 1193 int rc = AudioMixerGetDeviceFormat(pThis->pMixer, &mixerStrmCfg); 1194 AssertRC(rc); 1195 1196 PDMPCMPROPS mixerStrmProps; 1197 rc = DrvAudioStreamCfgToProps(&mixerStrmCfg, &mixerStrmProps); 1198 AssertRC(rc); 1199 1200 uint32_t cMixerSamplesMin = (int)((2 * cTicksElapsed * mixerStrmCfg.uHz + cTicksPerSec) / cTicksPerSec / 2); 1201 uint32_t cbMixerSamplesMin = cMixerSamplesMin << mixerStrmProps.cShift; 1187 1202 1188 1203 RTListForEach(&pThis->lstDrv, pDrv, AC97DRIVER, Node) … … 1199 1214 LogFlowFunc(("LUN#%RU8: rc=%Rrc, cbIn=%RU32, cbOut=%RU32\n", pDrv->uLUN, rc, cbIn, cbOut)); 1200 1215 #endif 1201 const bool fIsActiveOut = pDrv->pConnector->pfnIsActiveOut(pDrv->pConnector, pDrv->Out.pStrmOut);1202 1203 1216 /* If we there was an error handling (available) output or there simply is no output available, 1204 1217 * then calculate the minimum data rate which must be processed by the device emulation in order … … 1207 1220 * This is not the optimal solution, but as we have to deal with this on a timer-based approach 1208 1221 * (until we have the audio callbacks) we need to have device' DMA engines running. */ 1222 if (!pDrv->pConnector->pfnIsValidOut(pDrv->pConnector, pDrv->Out.pStrmOut)) 1223 { 1224 /* Use the mixer's (fixed) sampling rate. */ 1225 cbOut = RT_MAX(cbOut, cbMixerSamplesMin); 1226 continue; 1227 } 1228 1229 const bool fIsActiveOut = pDrv->pConnector->pfnIsActiveOut(pDrv->pConnector, pDrv->Out.pStrmOut); 1209 1230 if ( RT_FAILURE(rc) 1210 1231 || !fIsActiveOut) … … 2420 2441 2421 2442 uint8_t cFailed = 0; 2422 if (!pCon->pfnIs InputOK(pCon, pDrv->LineIn.pStrmIn))2443 if (!pCon->pfnIsValidIn (pCon, pDrv->LineIn.pStrmIn)) 2423 2444 cFailed++; 2424 if (!pCon->pfnIs InputOK(pCon, pDrv->MicIn.pStrmIn))2445 if (!pCon->pfnIsValidIn (pCon, pDrv->MicIn.pStrmIn)) 2425 2446 cFailed++; 2426 if (!pCon->pfnIs OutputOK(pCon, pDrv->Out.pStrmOut))2447 if (!pCon->pfnIsValidOut(pCon, pDrv->Out.pStrmOut)) 2427 2448 cFailed++; 2428 2449 … … 2443 2464 else if (cFailed) 2444 2465 { 2445 if (!pDrv->pConnector->pfnIs InputOK(pDrv->pConnector, pDrv->LineIn.pStrmIn))2466 if (!pDrv->pConnector->pfnIsValidIn (pDrv->pConnector, pDrv->LineIn.pStrmIn)) 2446 2467 LogRel(("AC97: WARNING: Unable to open PCM line input for LUN #%RU32!\n", pDrv->uLUN)); 2447 if (!pDrv->pConnector->pfnIs InputOK(pDrv->pConnector, pDrv->MicIn.pStrmIn))2468 if (!pDrv->pConnector->pfnIsValidIn (pDrv->pConnector, pDrv->MicIn.pStrmIn)) 2448 2469 LogRel(("AC97: WARNING: Unable to open PCM microphone input for LUN #%RU32!\n", pDrv->uLUN)); 2449 if (!pDrv->pConnector->pfnIs OutputOK(pDrv->pConnector, pDrv->Out.pStrmOut))2470 if (!pDrv->pConnector->pfnIsValidOut(pDrv->pConnector, pDrv->Out.pStrmOut)) 2450 2471 LogRel(("AC97: WARNING: Unable to open PCM output for LUN #%RU32!\n", pDrv->uLUN)); 2451 2472 2452 2473 char szMissingStreams[255]; 2453 2474 size_t len = 0; 2454 if (!pCon->pfnIs InputOK(pCon, pDrv->LineIn.pStrmIn))2475 if (!pCon->pfnIsValidIn (pCon, pDrv->LineIn.pStrmIn)) 2455 2476 len = RTStrPrintf(szMissingStreams, 2456 2477 sizeof(szMissingStreams), "PCM Input"); 2457 if (!pCon->pfnIsOutputOK(pCon, pDrv->Out.pStrmOut)) 2478 if (!pCon->pfnIsValidIn (pCon, pDrv->MicIn.pStrmIn)) 2479 len += RTStrPrintf(szMissingStreams + len, 2480 sizeof(szMissingStreams) - len, len ? ", PCM Microphone" : "PCM Microphone"); 2481 if (!pCon->pfnIsValidOut(pCon, pDrv->Out.pStrmOut)) 2458 2482 len += RTStrPrintf(szMissingStreams + len, 2459 2483 sizeof(szMissingStreams) - len, len ? ", PCM Output" : "PCM Output"); 2460 if (!pCon->pfnIsInputOK (pCon, pDrv->MicIn.pStrmIn))2461 len += RTStrPrintf(szMissingStreams + len,2462 sizeof(szMissingStreams) - len, len ? ", PCM Microphone" : "PCM Microphone");2463 2484 2464 2485 PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "HostAudioNotResponding", -
trunk/src/VBox/Devices/Audio/DevIchHda.cpp
r59272 r59275 9 9 10 10 /* 11 * Copyright (C) 2006-201 5Oracle Corporation11 * Copyright (C) 2006-2016 Oracle Corporation 12 12 * 13 13 * This file is part of VirtualBox Open Source Edition (OSE), as … … 46 46 #include "AudioMixer.h" 47 47 #include "DevIchHdaCodec.h" 48 #include "DrvAudio.h" 48 49 49 50 … … 2133 2134 2134 2135 #ifdef IN_RING3 2135 static int hdaS dFmtToAudSettings(uint32_t u32SdFmt, PPDMAUDIOSTREAMCFG pCfg)2136 static int hdaSDFMTToStrmCfg(uint32_t u32SdFmt, PPDMAUDIOSTREAMCFG pCfg) 2136 2137 { 2137 2138 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); … … 2225 2226 return VINF_SUCCESS; 2226 2227 2227 PDMAUDIOSTREAMCFG as;2228 int rc = hdaS dFmtToAudSettings(u32Value, &as);2228 PDMAUDIOSTREAMCFG strmCfg; 2229 int rc = hdaSDFMTToStrmCfg(u32Value, &strmCfg); 2229 2230 if (RT_FAILURE(rc)) 2230 2231 return rc; … … 2235 2236 case HDA_REG_SD0FMT: 2236 2237 RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node) 2237 rc = hdaCodecOpenStream(pThis->pCodec, PI_INDEX, & as);2238 rc = hdaCodecOpenStream(pThis->pCodec, PI_INDEX, &strmCfg); 2238 2239 break; 2239 2240 # ifdef VBOX_WITH_HDA_MIC_IN 2240 2241 case HDA_REG_SD2FMT: 2241 2242 RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node) 2242 rc = hdaCodecOpenStream(pThis->pCodec, MC_INDEX, & as);2243 rc = hdaCodecOpenStream(pThis->pCodec, MC_INDEX, &strmCfg); 2243 2244 break; 2244 2245 # endif … … 3021 3022 pThis->uTimerTS = cTicksNow; 3022 3023 3024 /* 3025 * Calculate the codec's (fixed) sampling rate. 3026 */ 3027 AssertPtr(pThis->pCodec); 3028 PDMPCMPROPS codecStrmProps; 3029 3030 int rc = DrvAudioStreamCfgToProps(&pThis->pCodec->strmCfg, &codecStrmProps); 3031 AssertRC(rc); 3032 3033 uint32_t cCodecSamplesMin = (int)((2 * cTicksElapsed * pThis->pCodec->strmCfg.uHz + cTicksPerSec) / cTicksPerSec / 2); 3034 uint32_t cbCodecSamplesMin = cCodecSamplesMin << codecStrmProps.cShift; 3035 3036 /* 3037 * Process all driver nodes. 3038 */ 3023 3039 RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node) 3024 3040 { … … 3026 3042 uint32_t cbOut = 0; 3027 3043 3028 intrc = pDrv->pConnector->pfnQueryStatus(pDrv->pConnector, &cbIn, &cbOut, NULL /* pcSamplesLive */);3044 rc = pDrv->pConnector->pfnQueryStatus(pDrv->pConnector, &cbIn, &cbOut, NULL /* pcSamplesLive */); 3029 3045 if (RT_SUCCESS(rc)) 3030 3046 rc = pDrv->pConnector->pfnPlayOut(pDrv->pConnector, NULL /* pcSamplesPlayed */); … … 3033 3049 LogFlowFunc(("LUN#%RU8: rc=%Rrc, cbIn=%RU32, cbOut=%RU32\n", pDrv->uLUN, rc, cbIn, cbOut)); 3034 3050 #endif 3035 const bool fIsActiveOut = pDrv->pConnector->pfnIsActiveOut(pDrv->pConnector, pDrv->Out.pStrmOut);3036 3037 3051 /* If we there was an error handling (available) output or there simply is no output available, 3038 3052 * then calculate the minimum data rate which must be processed by the device emulation in order … … 3041 3055 * This is not the optimal solution, but as we have to deal with this on a timer-based approach 3042 3056 * (until we have the audio callbacks) we need to have device' DMA engines running. */ 3057 if (!pDrv->pConnector->pfnIsValidOut(pDrv->pConnector, pDrv->Out.pStrmOut)) 3058 { 3059 /* Use the codec's (fixed) sampling rate. */ 3060 cbOut = RT_MAX(cbOut, cbCodecSamplesMin); 3061 continue; 3062 } 3063 3064 const bool fIsActiveOut = pDrv->pConnector->pfnIsActiveOut(pDrv->pConnector, pDrv->Out.pStrmOut); 3043 3065 if ( RT_FAILURE(rc) 3044 3066 || !fIsActiveOut) … … 3816 3838 3817 3839 /* Load BDLE states. */ 3818 HDABDLESTATE StateDummy;3819 PHDABDLESTATE pState;3820 3840 for (uint32_t a = 0; a < pStrm->State.cBDLE; a++) 3821 3841 { -
trunk/src/VBox/Devices/Audio/DevIchHdaCodec.cpp
r59257 r59275 9 9 10 10 /* 11 * Copyright (C) 2006-201 5Oracle Corporation11 * Copyright (C) 2006-2016 Oracle Corporation 12 12 * 13 13 * This file is part of VirtualBox Open Source Edition (OSE), as … … 2607 2607 2608 2608 int rc; 2609 2610 2609 switch (enmSoundSource) 2611 2610 { 2612 2611 case PI_INDEX: 2613 rc = pThis->pfnOpenIn(pThis->pHDAState, "hda.in", PDMAUDIORECSOURCE_LINE_IN, pCfg);2612 rc = pThis->pfnOpenIn(pThis->pHDAState, "hda.in", PDMAUDIORECSOURCE_LINE_IN, pCfg); 2614 2613 break; 2615 2614 #ifdef VBOX_WITH_HDA_MIC_IN 2615 case MC_INDEX: 2616 rc = pThis->pfnOpenIn(pThis->pHDAState, "hda.mc", PDMAUDIORECSOURCE_MIC, pCfg); 2617 break; 2618 #endif 2616 2619 case PO_INDEX: 2617 2620 rc = pThis->pfnOpenOut(pThis->pHDAState, "hda.out", pCfg); 2618 2621 break; 2619 2622 2620 #ifdef VBOX_WITH_HDA_MIC_IN2621 case MC_INDEX:2622 rc = pThis->pfnOpenIn(pThis->pHDAState, "hda.mc", PDMAUDIORECSOURCE_MIC, pCfg);2623 break;2624 #endif2625 2623 default: 2626 2624 AssertMsgFailed(("Index %ld not implemented\n", enmSoundSource)); … … 2731 2729 pThis->paVerbs = &g_aCodecVerbs[0]; 2732 2730 pThis->cVerbs = RT_ELEMENTS(g_aCodecVerbs); 2731 2733 2732 pThis->pfnLookup = codecLookup; 2734 2733 #ifdef DEBUG … … 2747 2746 pThis->paNodes[1].afg.u32F20_param = CODEC_MAKE_F20(pThis->u16VendorId, pThis->u8BSKU, pThis->u8AssemblyId); 2748 2747 2749 /* 44.1 kHz. */ 2750 PDMAUDIOSTREAMCFG as; 2751 as.uHz = 44100; 2752 as.cChannels = 2; 2753 as.enmFormat = AUD_FMT_S16; 2754 as.enmEndianness = PDMAUDIOHOSTENDIANNESS; 2755 2756 pThis->paNodes[1].node.au32F00_param[0xA] = CODEC_F00_0A_16_BIT; 2757 2758 hdaCodecOpenStream(pThis, PI_INDEX, &as); 2759 hdaCodecOpenStream(pThis, PO_INDEX, &as); 2748 /* This codec uses a fixed setting (44.1 kHz, 16-bit signed, 2 channels). */ 2749 pThis->strmCfg.uHz = 44100; 2750 pThis->strmCfg.cChannels = 2; 2751 pThis->strmCfg.enmFormat = AUD_FMT_S16; 2752 pThis->strmCfg.enmEndianness = PDMAUDIOHOSTENDIANNESS; 2753 2754 hdaCodecOpenStream(pThis, PI_INDEX, &pThis->strmCfg); 2760 2755 #ifdef VBOX_WITH_HDA_MIC_IN 2761 hdaCodecOpenStream(pThis, MC_INDEX, & as);2756 hdaCodecOpenStream(pThis, MC_INDEX, &pThis->strmCfg); 2762 2757 #endif 2763 2764 pThis->paNodes[1].node.au32F00_param[0xA] |= CODEC_F00_0A_44_1KHZ; 2765 2766 uint8_t i; 2767 Assert(pThis->paNodes); 2768 Assert(pThis->pfnCodecNodeReset); 2769 2770 for (i = 0; i < pThis->cTotalNodes; ++i) 2758 hdaCodecOpenStream(pThis, PO_INDEX, &pThis->strmCfg); 2759 2760 /* Initialize the AFG node with the fixed setting. */ 2761 pThis->paNodes[1].node.au32F00_param[0xA] = CODEC_F00_0A_44_1KHZ | CODEC_F00_0A_16_BIT; 2762 2763 AssertPtr(pThis->paNodes); 2764 AssertPtr(pThis->pfnCodecNodeReset); 2765 2766 for (uint8_t i = 0; i < pThis->cTotalNodes; i++) 2771 2767 pThis->pfnCodecNodeReset(pThis, i, &pThis->paNodes[i]); 2772 2768 2773 hdaCodecToAudVolume(pThis, &pThis->paNodes[pThis->u8DacLineOut].dac.B_params, PDMAUDIOMIXERCTL_PCM);2769 hdaCodecToAudVolume(pThis, &pThis->paNodes[pThis->u8DacLineOut].dac.B_params, PDMAUDIOMIXERCTL_PCM); 2774 2770 hdaCodecToAudVolume(pThis, &pThis->paNodes[pThis->u8AdcVolsLineIn].adcvol.B_params, PDMAUDIOMIXERCTL_LINE_IN); 2775 2771 -
trunk/src/VBox/Devices/Audio/DevIchHdaCodec.h
r59212 r59275 5 5 6 6 /* 7 * Copyright (C) 2006-201 5Oracle Corporation7 * Copyright (C) 2006-2016 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 77 77 uint8_t u8AssemblyId; 78 78 /** List of assigned HDA drivers to this codec. 79 * A driver only can be assigned to one codec 80 * at a time. */ 79 * A driver only can be assigned to one codec at a time. */ 81 80 RTLISTANCHOR lstDrv; 81 /** The codec's current audio stream configuration. */ 82 PDMAUDIOSTREAMCFG strmCfg; 82 83 83 84 #ifndef VBOX_WITH_HDA_CODEC_EMU -
trunk/src/VBox/Devices/Audio/DevSB16.cpp
r59191 r59275 7 7 8 8 /* 9 * Copyright (C) 2015 Oracle Corporation9 * Copyright (C) 2015-2016 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 57 57 #include "AudioMixBuffer.h" 58 58 #include "AudioMixer.h" 59 #include "DrvAudio.h" 59 60 60 61 /** Current saved state version. */ … … 1647 1648 AssertPtr(pThis); 1648 1649 1649 int rc = VINF_SUCCESS;1650 1651 1650 uint32_t cbInMax = 0; 1652 1651 uint32_t cbOutMin = UINT32_MAX; … … 1659 1658 1660 1659 pThis->uTimerTSIO = cTicksNow; 1660 1661 /* 1662 * Calculate the mixer's (fixed) sampling rate. 1663 */ 1664 AssertPtr(pThis->pMixer); 1665 1666 PDMAUDIOSTREAMCFG mixerStrmCfg; 1667 int rc = AudioMixerGetDeviceFormat(pThis->pMixer, &mixerStrmCfg); 1668 AssertRC(rc); 1669 1670 PDMPCMPROPS mixerStrmProps; 1671 rc = DrvAudioStreamCfgToProps(&mixerStrmCfg, &mixerStrmProps); 1672 AssertRC(rc); 1673 1674 uint32_t cMixerSamplesMin = (int)((2 * cTicksElapsed * mixerStrmCfg.uHz + cTicksPerSec) / cTicksPerSec / 2); 1675 uint32_t cbMixerSamplesMin = cMixerSamplesMin << mixerStrmProps.cShift; 1661 1676 1662 1677 RTListForEach(&pThis->lstDrv, pDrv, SB16DRIVER, Node) … … 1670 1685 rc = pDrv->pConnector->pfnPlayOut(pDrv->pConnector, NULL /* cSamplesPlayed */); 1671 1686 1672 Log2Func(("LUN#%RU8: rc=%Rrc, cbIn=%RU32, cbOut=%RU32\n", pDrv->uLUN, rc, cbIn, cbOut)); 1673 1674 const bool fIsActiveOut = pDrv->pConnector->pfnIsActiveOut(pDrv->pConnector, pDrv->Out.pStrmOut); 1675 1687 #ifdef DEBUG_TIMER 1688 LogFlowFunc(("LUN#%RU8: rc=%Rrc, cbIn=%RU32, cbOut=%RU32\n", pDrv->uLUN, rc, cbIn, cbOut)); 1689 #endif 1676 1690 /* If we there was an error handling (available) output or there simply is no output available, 1677 1691 * then calculate the minimum data rate which must be processed by the device emulation in order … … 1680 1694 * This is not the optimal solution, but as we have to deal with this on a timer-based approach 1681 1695 * (until we have the audio callbacks) we need to have device' DMA engines running. */ 1696 if (!pDrv->pConnector->pfnIsValidOut(pDrv->pConnector, pDrv->Out.pStrmOut)) 1697 { 1698 /* Use the mixer's (fixed) sampling rate. */ 1699 cbOut = RT_MAX(cbOut, cbMixerSamplesMin); 1700 continue; 1701 } 1702 1703 const bool fIsActiveOut = pDrv->pConnector->pfnIsActiveOut(pDrv->pConnector, pDrv->Out.pStrmOut); 1682 1704 if ( RT_FAILURE(rc) 1683 1705 || !fIsActiveOut) -
trunk/src/VBox/Devices/Audio/DrvAudio.cpp
r59102 r59275 1882 1882 } 1883 1883 1884 static DECLCALLBACK(bool) drvAudioIs InputOK(PPDMIAUDIOCONNECTOR pInterface,1884 static DECLCALLBACK(bool) drvAudioIsValidIn(PPDMIAUDIOCONNECTOR pInterface, 1885 1885 PPDMAUDIOGSTSTRMIN pGstStrmIn) 1886 1886 { … … 1888 1888 } 1889 1889 1890 static DECLCALLBACK(bool) drvAudioIs OutputOK(PPDMIAUDIOCONNECTOR pInterface,1890 static DECLCALLBACK(bool) drvAudioIsValidOut(PPDMIAUDIOCONNECTOR pInterface, 1891 1891 PPDMAUDIOGSTSTRMOUT pGstStrmOut) 1892 1892 { … … 2167 2167 pThis->IAudioConnector.pfnIsActiveIn = drvAudioIsActiveIn; 2168 2168 pThis->IAudioConnector.pfnIsActiveOut = drvAudioIsActiveOut; 2169 pThis->IAudioConnector.pfnIs InputOK = drvAudioIsInputOK;2170 pThis->IAudioConnector.pfnIs OutputOK = drvAudioIsOutputOK;2169 pThis->IAudioConnector.pfnIsValidIn = drvAudioIsValidIn; 2170 pThis->IAudioConnector.pfnIsValidOut = drvAudioIsValidOut; 2171 2171 pThis->IAudioConnector.pfnInitNull = drvAudioInitNull; 2172 2172 pThis->IAudioConnector.pfnEnableOut = drvAudioEnableOut;
Note:
See TracChangeset
for help on using the changeset viewer.