VirtualBox

Changeset 67692 in vbox


Ignore:
Timestamp:
Jun 29, 2017 12:36:40 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
116522
Message:

Audio/HDA: Stream configuration initialization fixes.

Location:
trunk/src/VBox/Devices/Audio
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Audio/DevHDA.cpp

    r67671 r67692  
    10011001 */
    10021002#ifdef IN_RING3
    1003 static int hdaSDFMTToStrmCfg(uint32_t u32SDFMT, PPDMAUDIOSTREAMCFG pStrmCfg);
     1003static int hdaSDFMTToPCMProps(uint32_t u32SDFMT, PPDMAUDIOPCMPROPS pProps);
    10041004#endif
    10051005/** @} */
     
    10621062 */
    10631063#ifdef IN_RING3
    1064 static int           hdaStreamMapInit(PHDASTREAMMAPPING pMapping, PPDMAUDIOSTREAMCFG pCfg);
     1064static int           hdaStreamMapInit(PHDASTREAMMAPPING pMapping, PPDMAUDIOPCMPROPS pProps);
    10651065static void          hdaStreamMapDestroy(PHDASTREAMMAPPING pMapping);
    10661066static void          hdaStreamMapReset(PHDASTREAMMAPPING pMapping);
     
    19571957    hdaStreamUpdateLPIB(pThis, pStream, HDA_STREAM_REG(pThis, LPIB, pStream->u8SD));
    19581958
    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);
    19601962    if (RT_FAILURE(rc))
    19611963    {
     
    19631965        return rc;
    19641966    }
    1965 
    1966     PPDMAUDIOSTREAMCFG pCfg = &pStream->State.strmCfg;
    19671967
    19681968    /* Set the stream's direction. */
     
    19771977# else
    19781978            pCfg->DestSource.Source = PDMAUDIORECSOURCE_LINE;
     1979            pCfg->enmLayout         = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED;
    19791980            RTStrCopy(pCfg->szName, sizeof(pCfg->szName), "Line In");
    19801981# endif
     
    19992000     * number of channels in a single audio stream.
    20002001     */
    2001     rc = hdaStreamMapInit(&pStream->State.Mapping, pCfg);
     2002    rc = hdaStreamMapInit(&pStream->State.Mapping, &pCfg->Props);
    20022003    AssertRCReturn(rc, rc);
    20032004
     
    29552956
    29562957#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 */
     2965static int hdaSDFMTToPCMProps(uint32_t u32SDFMT, PPDMAUDIOPCMPROPS pProps)
     2966{
     2967    AssertPtrReturn(pProps, VERR_INVALID_POINTER);
    29602968
    29612969# define EXTRACT_VALUE(v, mask, shift) ((v & ((mask) << (shift))) >> (shift))
     
    30183026    if (RT_SUCCESS(rc))
    30193027    {
    3020         RT_ZERO(pStrmCfg->Props);
    3021 
    3022         pStrmCfg->Props.uHz       = u32Hz * u32HzMult / u32HzDiv;
    3023         pStrmCfg->Props.cChannels = (u32SDFMT & 0xf) + 1;
    3024         pStrmCfg->Props.cBits     = cBits;
    3025         pStrmCfg->Props.fSigned   = true;
    3026         pStrmCfg->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);
    30273035    }
    30283036
     
    30623070
    30633071    /** @todo Make the following configurable through mixer API and/or CFGM? */
    3064     switch (pCfg->cChannels)
     3072    switch (pCfg->Props.cChannels)
    30653073    {
    30663074        case 3:  /* 2.1: Front (Stereo) + LFE. */
     
    31083116    if (rc == VERR_NOT_SUPPORTED)
    31093117    {
    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). */
    31133121        rc = VINF_SUCCESS;
    31143122    }
     
    31223130        {
    31233131            RTStrPrintf(pCfg->szName, RT_ELEMENTS(pCfg->szName), "Front");
     3132
    31243133            pCfg->DestSource.Dest = PDMAUDIOPLAYBACKDEST_FRONT;
     3134            pCfg->enmLayout       = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED;
     3135
    31253136            pCfg->Props.cChannels = 2;
     3137            pCfg->Props.cShift    = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(pCfg->Props.cBits, pCfg->Props.cChannels);
    31263138
    31273139            rc = hdaCodecRemoveStream(pThis->pCodec,  PDMAUDIOMIXERCTL_FRONT);
     
    31353147        {
    31363148            RTStrPrintf(pCfg->szName, RT_ELEMENTS(pCfg->szName), "Center/LFE");
     3149
    31373150            pCfg->DestSource.Dest = PDMAUDIOPLAYBACKDEST_CENTER_LFE;
     3151            pCfg->enmLayout       = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED;
     3152
    31383153            pCfg->Props.cChannels = (fUseCenter && fUseLFE) ? 2 : 1;
     3154            pCfg->Props.cShift    = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(pCfg->Props.cBits, pCfg->Props.cChannels);
    31393155
    31403156            rc = hdaCodecRemoveStream(pThis->pCodec,  PDMAUDIOMIXERCTL_CENTER_LFE);
     
    31473163        {
    31483164            RTStrPrintf(pCfg->szName, RT_ELEMENTS(pCfg->szName), "Rear");
     3165
    31493166            pCfg->DestSource.Dest = PDMAUDIOPLAYBACKDEST_REAR;
     3167            pCfg->enmLayout       = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED;
     3168
    31503169            pCfg->Props.cChannels = 2;
     3170            pCfg->Props.cShift    = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(pCfg->Props.cBits, pCfg->Props.cChannels);
    31513171
    31523172            rc = hdaCodecRemoveStream(pThis->pCodec,  PDMAUDIOMIXERCTL_REAR);
     
    37213741#ifdef IN_RING3
    37223742/**
    3723  * Initializes a stream mapping structure according to the given stream configuration.
     3743 * Initializes a stream mapping structure according to the given PCM properties.
    37243744 *
    37253745 * @return  IPRT status code.
    37263746 * @param   pMapping            Pointer to mapping to initialize.
    3727  * @param   pCfg                Pointer to stream configuration to use.
    3728  */
    3729 static int hdaStreamMapInit(PHDASTREAMMAPPING pMapping, PPDMAUDIOSTREAMCFG pCfg)
     3747 * @param   pProps              Pointer to PCM properties to use for initialization.
     3748 */
     3749static int hdaStreamMapInit(PHDASTREAMMAPPING pMapping, PPDMAUDIOPCMPROPS pProps)
    37303750{
    37313751    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;
    37353756
    37363757    hdaStreamMapReset(pMapping);
    37373758
    3738     pMapping->paChannels = (PPDMAUDIOSTREAMCHANNEL)RTMemAlloc(sizeof(PDMAUDIOSTREAMCHANNEL) * pCfg->Props.cChannels);
     3759    pMapping->paChannels = (PPDMAUDIOSTREAMCHANNEL)RTMemAlloc(sizeof(PDMAUDIOSTREAMCHANNEL) * pProps->cChannels);
    37393760    if (!pMapping->paChannels)
    37403761        return VERR_NO_MEMORY;
    37413762
    3742     if (!DrvAudioHlpStreamCfgIsValid(pCfg))
    3743         return VERR_INVALID_PARAMETER;
    3744 
    37453763    int rc = VINF_SUCCESS;
    37463764
    3747     Assert(RT_IS_POWER_OF_TWO(pCfg->Props.cBits));
     3765    Assert(RT_IS_POWER_OF_TWO(pProps->cBits));
    37483766
    37493767    /** @todo We assume all channels in a stream have the same format. */
    37503768    PPDMAUDIOSTREAMCHANNEL pChan = pMapping->paChannels;
    3751     for (uint8_t i = 0; i < pCfg->Props.cChannels; i++)
     3769    for (uint8_t i = 0; i < pProps->cChannels; i++)
    37523770    {
    37533771        pChan->uChannel = i;
    3754         pChan->cbStep   = (pCfg->Props.cBits / 2);
    3755         pChan->cbFrame  = pChan->cbStep * pCfg->Props.cChannels;
     3772        pChan->cbStep   = (pProps->cBits / 2);
     3773        pChan->cbFrame  = pChan->cbStep * pProps->cChannels;
    37563774        pChan->cbFirst  = i * pChan->cbStep;
    37573775        pChan->cbOff    = pChan->cbFirst;
     
    37763794    if (RT_SUCCESS(rc))
    37773795    {
    3778         pMapping->cChannels = pCfg->Props.cChannels;
     3796        pMapping->cChannels = pProps->cChannels;
    37793797#ifdef VBOX_WITH_HDA_AUDIO_INTERLEAVING_STREAMS_SUPPORT
    37803798        pMapping->enmLayout = PDMAUDIOSTREAMLAYOUT_INTERLEAVED;
     
    39393957
    39403958    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. */
    39413964        return VERR_INVALID_PARAMETER;
     3965    }
    39423966
    39433967    int rc = AudioMixerSinkSetFormat(pSink->pMixSink, &pCfg->Props);
     
    65506574                    hdaBDLEDumpAll(pThis, pStrm->u64BDLBase, pStrm->u16LVI + 1);
    65516575#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. */
    65596576                }
    65606577
  • trunk/src/VBox/Devices/Audio/HDACodec.cpp

    r67336 r67692  
    32913291        RT_ZERO(strmCfg);
    32923292
    3293         strmCfg.Props.uHz       = 44100;
    3294         strmCfg.Props.cChannels = 2;
    3295         strmCfg.Props.cBits     = 16;
    3296         strmCfg.Props.fSigned   = true;
    3297 
    32983293        /* Note: Adding the default input/output streams is *not* critical for the overall
    32993294         *       codec construction result. */
     
    33023297         * Output streams.
    33033298         */
    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);
    33053307
    33063308        /* Front. */
     
    33313333         * Input streams.
    33323334         */
    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);
    33343345
    33353346#ifdef VBOX_WITH_AUDIO_HDA_MIC_IN
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette