Changeset 67692 in vbox
- Timestamp:
- Jun 29, 2017 12:36:40 PM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 116522
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevHDA.cpp
r67671 r67692 1001 1001 */ 1002 1002 #ifdef IN_RING3 1003 static int hdaSDFMTTo StrmCfg(uint32_t u32SDFMT, PPDMAUDIOSTREAMCFG pStrmCfg);1003 static int hdaSDFMTToPCMProps(uint32_t u32SDFMT, PPDMAUDIOPCMPROPS pProps); 1004 1004 #endif 1005 1005 /** @} */ … … 1062 1062 */ 1063 1063 #ifdef IN_RING3 1064 static int hdaStreamMapInit(PHDASTREAMMAPPING pMapping, PPDMAUDIO STREAMCFG pCfg);1064 static int hdaStreamMapInit(PHDASTREAMMAPPING pMapping, PPDMAUDIOPCMPROPS pProps); 1065 1065 static void hdaStreamMapDestroy(PHDASTREAMMAPPING pMapping); 1066 1066 static void hdaStreamMapReset(PHDASTREAMMAPPING pMapping); … … 1957 1957 hdaStreamUpdateLPIB(pThis, pStream, HDA_STREAM_REG(pThis, LPIB, pStream->u8SD)); 1958 1958 1959 int rc = hdaSDFMTToStrmCfg(HDA_STREAM_REG(pThis, FMT, uSD), &pStream->State.strmCfg); 1959 PPDMAUDIOSTREAMCFG pCfg = &pStream->State.strmCfg; 1960 1961 int rc = hdaSDFMTToPCMProps(HDA_STREAM_REG(pThis, FMT, uSD), &pCfg->Props); 1960 1962 if (RT_FAILURE(rc)) 1961 1963 { … … 1963 1965 return rc; 1964 1966 } 1965 1966 PPDMAUDIOSTREAMCFG pCfg = &pStream->State.strmCfg;1967 1967 1968 1968 /* Set the stream's direction. */ … … 1977 1977 # else 1978 1978 pCfg->DestSource.Source = PDMAUDIORECSOURCE_LINE; 1979 pCfg->enmLayout = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED; 1979 1980 RTStrCopy(pCfg->szName, sizeof(pCfg->szName), "Line In"); 1980 1981 # endif … … 1999 2000 * number of channels in a single audio stream. 2000 2001 */ 2001 rc = hdaStreamMapInit(&pStream->State.Mapping, pCfg);2002 rc = hdaStreamMapInit(&pStream->State.Mapping, &pCfg->Props); 2002 2003 AssertRCReturn(rc, rc); 2003 2004 … … 2955 2956 2956 2957 #ifdef IN_RING3 2957 static int hdaSDFMTToStrmCfg(uint32_t u32SDFMT, PPDMAUDIOSTREAMCFG pStrmCfg) 2958 { 2959 AssertPtrReturn(pStrmCfg, VERR_INVALID_POINTER); 2958 /** 2959 * Converts an HDA stream's SDFMT register into a given PCM properties structure. 2960 * 2961 * @return IPRT status code. 2962 * @param u32SDFMT The HDA stream's SDFMT value to convert. 2963 * @param pProps PCM properties structure to hold converted result on success. 2964 */ 2965 static int hdaSDFMTToPCMProps(uint32_t u32SDFMT, PPDMAUDIOPCMPROPS pProps) 2966 { 2967 AssertPtrReturn(pProps, VERR_INVALID_POINTER); 2960 2968 2961 2969 # define EXTRACT_VALUE(v, mask, shift) ((v & ((mask) << (shift))) >> (shift)) … … 3018 3026 if (RT_SUCCESS(rc)) 3019 3027 { 3020 RT_ ZERO(pStrmCfg->Props);3021 3022 p StrmCfg->Props.uHz = u32Hz * u32HzMult / u32HzDiv;3023 p StrmCfg->Props.cChannels = (u32SDFMT & 0xf) + 1;3024 p StrmCfg->Props.cBits = cBits;3025 p StrmCfg->Props.fSigned = true;3026 p StrmCfg->Props.cShift = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(pStrmCfg->Props.cBits, pStrmCfg->Props.cChannels);3028 RT_BZERO(pProps, sizeof(PDMAUDIOPCMPROPS)); 3029 3030 pProps->cBits = cBits; 3031 pProps->fSigned = true; 3032 pProps->cChannels = (u32SDFMT & 0xf) + 1; 3033 pProps->uHz = u32Hz * u32HzMult / u32HzDiv; 3034 pProps->cShift = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(pProps->cBits, pProps->cChannels); 3027 3035 } 3028 3036 … … 3062 3070 3063 3071 /** @todo Make the following configurable through mixer API and/or CFGM? */ 3064 switch (pCfg-> cChannels)3072 switch (pCfg->Props.cChannels) 3065 3073 { 3066 3074 case 3: /* 2.1: Front (Stereo) + LFE. */ … … 3108 3116 if (rc == VERR_NOT_SUPPORTED) 3109 3117 { 3110 LogRel (("HDA: Unsupported channel count (%RU8), falling back to stereo channels\n", pCfg->Props.cChannels));3111 pCfg->Props.cChannels = 2; 3112 3118 LogRel2(("HDA: Unsupported channel count (%RU8), falling back to stereo channels\n", pCfg->Props.cChannels)); 3119 3120 /* Fall back to 2 channels (see below in fUseFront block). */ 3113 3121 rc = VINF_SUCCESS; 3114 3122 } … … 3122 3130 { 3123 3131 RTStrPrintf(pCfg->szName, RT_ELEMENTS(pCfg->szName), "Front"); 3132 3124 3133 pCfg->DestSource.Dest = PDMAUDIOPLAYBACKDEST_FRONT; 3134 pCfg->enmLayout = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED; 3135 3125 3136 pCfg->Props.cChannels = 2; 3137 pCfg->Props.cShift = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(pCfg->Props.cBits, pCfg->Props.cChannels); 3126 3138 3127 3139 rc = hdaCodecRemoveStream(pThis->pCodec, PDMAUDIOMIXERCTL_FRONT); … … 3135 3147 { 3136 3148 RTStrPrintf(pCfg->szName, RT_ELEMENTS(pCfg->szName), "Center/LFE"); 3149 3137 3150 pCfg->DestSource.Dest = PDMAUDIOPLAYBACKDEST_CENTER_LFE; 3151 pCfg->enmLayout = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED; 3152 3138 3153 pCfg->Props.cChannels = (fUseCenter && fUseLFE) ? 2 : 1; 3154 pCfg->Props.cShift = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(pCfg->Props.cBits, pCfg->Props.cChannels); 3139 3155 3140 3156 rc = hdaCodecRemoveStream(pThis->pCodec, PDMAUDIOMIXERCTL_CENTER_LFE); … … 3147 3163 { 3148 3164 RTStrPrintf(pCfg->szName, RT_ELEMENTS(pCfg->szName), "Rear"); 3165 3149 3166 pCfg->DestSource.Dest = PDMAUDIOPLAYBACKDEST_REAR; 3167 pCfg->enmLayout = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED; 3168 3150 3169 pCfg->Props.cChannels = 2; 3170 pCfg->Props.cShift = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(pCfg->Props.cBits, pCfg->Props.cChannels); 3151 3171 3152 3172 rc = hdaCodecRemoveStream(pThis->pCodec, PDMAUDIOMIXERCTL_REAR); … … 3721 3741 #ifdef IN_RING3 3722 3742 /** 3723 * Initializes a stream mapping structure according to the given stream configuration.3743 * Initializes a stream mapping structure according to the given PCM properties. 3724 3744 * 3725 3745 * @return IPRT status code. 3726 3746 * @param pMapping Pointer to mapping to initialize. 3727 * @param p Cfg Pointer to stream configuration to use.3728 */ 3729 static int hdaStreamMapInit(PHDASTREAMMAPPING pMapping, PPDMAUDIO STREAMCFG pCfg)3747 * @param pProps Pointer to PCM properties to use for initialization. 3748 */ 3749 static int hdaStreamMapInit(PHDASTREAMMAPPING pMapping, PPDMAUDIOPCMPROPS pProps) 3730 3750 { 3731 3751 AssertPtrReturn(pMapping, VERR_INVALID_POINTER); 3732 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); 3733 3734 AssertReturn(pCfg->Props.cChannels, VERR_INVALID_PARAMETER); 3752 AssertPtrReturn(pProps, VERR_INVALID_POINTER); 3753 3754 if (!DrvAudioHlpPCMPropsAreValid(pProps)) 3755 return VERR_INVALID_PARAMETER; 3735 3756 3736 3757 hdaStreamMapReset(pMapping); 3737 3758 3738 pMapping->paChannels = (PPDMAUDIOSTREAMCHANNEL)RTMemAlloc(sizeof(PDMAUDIOSTREAMCHANNEL) * p Cfg->Props.cChannels);3759 pMapping->paChannels = (PPDMAUDIOSTREAMCHANNEL)RTMemAlloc(sizeof(PDMAUDIOSTREAMCHANNEL) * pProps->cChannels); 3739 3760 if (!pMapping->paChannels) 3740 3761 return VERR_NO_MEMORY; 3741 3762 3742 if (!DrvAudioHlpStreamCfgIsValid(pCfg))3743 return VERR_INVALID_PARAMETER;3744 3745 3763 int rc = VINF_SUCCESS; 3746 3764 3747 Assert(RT_IS_POWER_OF_TWO(p Cfg->Props.cBits));3765 Assert(RT_IS_POWER_OF_TWO(pProps->cBits)); 3748 3766 3749 3767 /** @todo We assume all channels in a stream have the same format. */ 3750 3768 PPDMAUDIOSTREAMCHANNEL pChan = pMapping->paChannels; 3751 for (uint8_t i = 0; i < p Cfg->Props.cChannels; i++)3769 for (uint8_t i = 0; i < pProps->cChannels; i++) 3752 3770 { 3753 3771 pChan->uChannel = i; 3754 pChan->cbStep = (p Cfg->Props.cBits / 2);3755 pChan->cbFrame = pChan->cbStep * p Cfg->Props.cChannels;3772 pChan->cbStep = (pProps->cBits / 2); 3773 pChan->cbFrame = pChan->cbStep * pProps->cChannels; 3756 3774 pChan->cbFirst = i * pChan->cbStep; 3757 3775 pChan->cbOff = pChan->cbFirst; … … 3776 3794 if (RT_SUCCESS(rc)) 3777 3795 { 3778 pMapping->cChannels = p Cfg->Props.cChannels;3796 pMapping->cChannels = pProps->cChannels; 3779 3797 #ifdef VBOX_WITH_HDA_AUDIO_INTERLEAVING_STREAMS_SUPPORT 3780 3798 pMapping->enmLayout = PDMAUDIOSTREAMLAYOUT_INTERLEAVED; … … 3939 3957 3940 3958 if (!DrvAudioHlpStreamCfgIsValid(pCfg)) 3959 { 3960 LogRel(("HDA: Invalid stream configuration used for sink #%RU8: %RU8 bit, %RU8 channel(s) @ %RU32Hz\n", 3961 pSink->uSD, pCfg->Props.cBits, pCfg->Props.cChannels, pCfg->Props.uHz)); 3962 3963 AssertFailed(); /* Should not happen. */ 3941 3964 return VERR_INVALID_PARAMETER; 3965 } 3942 3966 3943 3967 int rc = AudioMixerSinkSetFormat(pSink->pMixSink, &pCfg->Props); … … 6550 6574 hdaBDLEDumpAll(pThis, pStrm->u64BDLBase, pStrm->u16LVI + 1); 6551 6575 #endif 6552 }6553 6554 rc = hdaSDFMTToStrmCfg(HDA_STREAM_REG(pThis, FMT, uStreamID), &pStrm->State.strmCfg);6555 if (RT_FAILURE(rc))6556 {6557 LogRel(("HDA: Stream #%RU8: Loading format failed, rc=%Rrc\n", uStreamID, rc));6558 /* Continue. */6559 6576 } 6560 6577 -
trunk/src/VBox/Devices/Audio/HDACodec.cpp
r67336 r67692 3291 3291 RT_ZERO(strmCfg); 3292 3292 3293 strmCfg.Props.uHz = 44100;3294 strmCfg.Props.cChannels = 2;3295 strmCfg.Props.cBits = 16;3296 strmCfg.Props.fSigned = true;3297 3298 3293 /* Note: Adding the default input/output streams is *not* critical for the overall 3299 3294 * codec construction result. */ … … 3302 3297 * Output streams. 3303 3298 */ 3304 strmCfg.enmDir = PDMAUDIODIR_OUT; 3299 strmCfg.enmDir = PDMAUDIODIR_OUT; 3300 strmCfg.enmLayout = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED; 3301 3302 strmCfg.Props.cBits = 16; 3303 strmCfg.Props.fSigned = true; 3304 strmCfg.Props.cChannels = 2; 3305 strmCfg.Props.uHz = 44100; 3306 strmCfg.Props.cShift = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(strmCfg.Props.cBits, strmCfg.Props.cChannels); 3305 3307 3306 3308 /* Front. */ … … 3331 3333 * Input streams. 3332 3334 */ 3333 strmCfg.enmDir = PDMAUDIODIR_IN; 3335 RT_ZERO(strmCfg); 3336 3337 strmCfg.enmDir = PDMAUDIODIR_IN; 3338 strmCfg.enmLayout = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED; 3339 3340 strmCfg.Props.cBits = 16; 3341 strmCfg.Props.fSigned = true; 3342 strmCfg.Props.cChannels = 2; 3343 strmCfg.Props.uHz = 44100; 3344 strmCfg.Props.cShift = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(strmCfg.Props.cBits, strmCfg.Props.cChannels); 3334 3345 3335 3346 #ifdef VBOX_WITH_AUDIO_HDA_MIC_IN
Note:
See TracChangeset
for help on using the changeset viewer.