VirtualBox

Ignore:
Timestamp:
Dec 5, 2018 9:34:58 AM (6 years ago)
Author:
vboxsync
Message:

Forward ported r127158 (Audio/HDA: Implemented support for Windows 10 Build 1809 default surround speaker setup) + build fixes (r127159, r127160, r127162, r127165, r127167).

File:
1 edited

Legend:

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

    r73529 r75962  
    55
    66/*
    7  * Copyright (C) 2017 Oracle Corporation
     7 * Copyright (C) 2017-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3535#ifdef IN_RING3
    3636
     37static int hdaR3StreamMapSetup(PHDASTREAMMAP pMap, PPDMAUDIOPCMPROPS pProps);
     38
    3739/**
    3840 * Initializes a stream mapping structure according to the given PCM properties.
    3941 *
    4042 * @return  IPRT status code.
    41  * @param   pMapping            Pointer to mapping to initialize.
     43 * @param   pMap                Pointer to mapping to initialize.
    4244 * @param   pProps              Pointer to PCM properties to use for initialization.
    4345 */
    44 int hdaR3StreamMapInit(PHDASTREAMMAPPING pMapping, PPDMAUDIOPCMPROPS pProps)
     46int hdaR3StreamMapInit(PHDASTREAMMAP pMap, PPDMAUDIOPCMPROPS pProps)
    4547{
    46     AssertPtrReturn(pMapping, VERR_INVALID_POINTER);
     48    AssertPtrReturn(pMap, VERR_INVALID_POINTER);
    4749    AssertPtrReturn(pProps,   VERR_INVALID_POINTER);
    4850
     
    5052        return VERR_INVALID_PARAMETER;
    5153
    52     hdaR3StreamMapReset(pMapping);
     54    hdaR3StreamMapReset(pMap);
    5355
    54     pMapping->paChannels = (PPDMAUDIOSTREAMCHANNEL)RTMemAlloc(sizeof(PDMAUDIOSTREAMCHANNEL) * pProps->cChannels);
    55     if (!pMapping->paChannels)
    56         return VERR_NO_MEMORY;
     56    int rc = hdaR3StreamMapSetup(pMap, pProps);
     57    if (RT_FAILURE(rc))
     58        return rc;
    5759
    58     int rc = VINF_SUCCESS;
    59 
    60     Assert(RT_IS_POWER_OF_TWO(pProps->cBytes * 8));
    61 
    62     /** @todo We assume all channels in a stream have the same format. */
    63     PPDMAUDIOSTREAMCHANNEL pChan = pMapping->paChannels;
    64     for (uint8_t i = 0; i < pProps->cChannels; i++)
    65     {
    66         pChan->uChannel = i;
    67         pChan->cbStep   = pProps->cBytes;
    68         pChan->cbFrame  = pChan->cbStep * pProps->cChannels;
    69         pChan->cbFirst  = i * pChan->cbStep;
    70         pChan->cbOff    = pChan->cbFirst;
    71 
    72         int rc2 = hdaR3StreamChannelDataInit(&pChan->Data, PDMAUDIOSTREAMCHANNELDATA_FLAG_NONE);
    73         if (RT_SUCCESS(rc))
    74             rc = rc2;
    75 
    76         if (RT_FAILURE(rc))
    77             break;
    78 
    79         pChan++;
    80     }
    81 
     60#ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND
    8261    if (   RT_SUCCESS(rc)
    8362        /* Create circular buffer if not created yet. */
    84         && !pMapping->pCircBuf)
     63        && !pMap->pCircBuf)
    8564    {
    86         rc = RTCircBufCreate(&pMapping->pCircBuf, _4K); /** @todo Make size configurable? */
     65        rc = RTCircBufCreate(&pMap->pCircBuf, _4K); /** @todo Make size configurable? */
    8766    }
     67#endif
    8868
    8969    if (RT_SUCCESS(rc))
    9070    {
    91         pMapping->cChannels = pProps->cChannels;
    92 #ifdef VBOX_WITH_HDA_AUDIO_INTERLEAVING_STREAMS_SUPPORT
    93         pMapping->enmLayout = PDMAUDIOSTREAMLAYOUT_INTERLEAVED;
    94 #else
    95         pMapping->enmLayout = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED;
    96 #endif
     71        pMap->cbFrameSize = pProps->cChannels * pProps->cBytes;
     72
     73        LogFunc(("cChannels=%RU8, cBytes=%RU8 -> cbFrameSize=%RU32\n",
     74                 pProps->cChannels, pProps->cBytes, pMap->cbFrameSize));
     75
     76        Assert(pMap->cbFrameSize); /* Frame size must not be 0. */
     77
     78        pMap->enmLayout = PDMAUDIOSTREAMLAYOUT_INTERLEAVED;
    9779    }
    9880
     
    10486 * Destroys a given stream mapping.
    10587 *
    106  * @param   pMapping            Pointer to mapping to destroy.
     88 * @param   pMap            Pointer to mapping to destroy.
    10789 */
    108 void hdaR3StreamMapDestroy(PHDASTREAMMAPPING pMapping)
     90void hdaR3StreamMapDestroy(PHDASTREAMMAP pMap)
    10991{
    110     hdaR3StreamMapReset(pMapping);
     92    hdaR3StreamMapReset(pMap);
    11193
    112     if (pMapping->pCircBuf)
     94#ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND
     95    if (pMap->pCircBuf)
    11396    {
    114         RTCircBufDestroy(pMapping->pCircBuf);
    115         pMapping->pCircBuf = NULL;
     97        RTCircBufDestroy(pMap->pCircBuf);
     98        pMap->pCircBuf = NULL;
    11699    }
     100#endif
    117101}
    118102
     
    121105 * Resets a given stream mapping.
    122106 *
    123  * @param   pMapping            Pointer to mapping to reset.
     107 * @param   pMap            Pointer to mapping to reset.
    124108 */
    125 void hdaR3StreamMapReset(PHDASTREAMMAPPING pMapping)
     109void hdaR3StreamMapReset(PHDASTREAMMAP pMap)
    126110{
    127     AssertPtrReturnVoid(pMapping);
     111    AssertPtrReturnVoid(pMap);
    128112
    129     pMapping->enmLayout = PDMAUDIOSTREAMLAYOUT_UNKNOWN;
     113    pMap->enmLayout = PDMAUDIOSTREAMLAYOUT_UNKNOWN;
    130114
    131     if (pMapping->cChannels)
     115    if (pMap->paMappings)
    132116    {
    133         for (uint8_t i = 0; i < pMapping->cChannels; i++)
    134             hdaR3StreamChannelDataDestroy(&pMapping->paChannels[i].Data);
     117        for (uint8_t i = 0; i < pMap->cMappings; i++)
     118            hdaR3StreamChannelDataDestroy(&pMap->paMappings[i].Data);
    135119
    136         AssertPtr(pMapping->paChannels);
    137         RTMemFree(pMapping->paChannels);
    138         pMapping->paChannels = NULL;
     120        RTMemFree(pMap->paMappings);
     121        pMap->paMappings = NULL;
    139122
    140         pMapping->cChannels = 0;
     123        pMap->cMappings = 0;
    141124    }
    142125}
    143126
     127
     128/**
     129 * Sets up a stream mapping according to the given properties / configuration.
     130 *
     131 * @return VBox status code, or VERR_NOT_SUPPORTED if the channel setup is not supported (yet).
     132 * @param  pMap                 Pointer to mapping to set up.
     133 * @param  pProps               PCM audio properties to use for lookup.
     134 */
     135static int hdaR3StreamMapSetup(PHDASTREAMMAP pMap, PPDMAUDIOPCMPROPS pProps)
     136{
     137    int rc;
     138
     139    /** @todo We ASSUME that all channels in a stream ...
     140     *        - have the same format
     141     *        - are in a consecutive order with no gaps in between
     142     *        - have a simple (raw) data layout
     143     *        - work in a non-striped fashion, e.g. interleaved (only on one SDn, not spread over multiple SDns) */
     144    if  (   pProps->cChannels == 1  /* Mono */
     145         || pProps->cChannels == 2  /* Stereo */
     146         || pProps->cChannels == 4  /* Quadrophonic */
     147         || pProps->cChannels == 6) /* Surround (5.1) */
     148    {
     149        /* For now we don't have anything other as mono / stereo channels being covered by the backends.
     150         * So just set up one channel covering those and skipping the rest (like configured rear or center/LFE outputs). */
     151        pMap->cMappings  = 1;
     152        pMap->paMappings = (PPDMAUDIOSTREAMMAP)RTMemAlloc(sizeof(PDMAUDIOSTREAMMAP) * pMap->cMappings);
     153        if (!pMap->paMappings)
     154            return VERR_NO_MEMORY;
     155
     156        PPDMAUDIOSTREAMMAP pMapLR = &pMap->paMappings[0];
     157
     158        pMapLR->aID[0]  = PDMAUDIOSTREAMCHANNELID_FRONT_LEFT;
     159        pMapLR->aID[1]  = PDMAUDIOSTREAMCHANNELID_FRONT_RIGHT;
     160        pMapLR->cbFrame = pProps->cBytes * pProps->cChannels;
     161        pMapLR->cbSize  = pProps->cBytes * 2 /* Front left + Front right channels */;
     162        pMapLR->cbFirst = 0;
     163        pMapLR->cbOff   = pMapLR->cbFirst;
     164
     165        rc = hdaR3StreamChannelDataInit(&pMapLR->Data, PDMAUDIOSTREAMCHANNELDATA_FLAG_NONE);
     166        AssertRC(rc);
     167    }
     168    else
     169        rc = VERR_NOT_SUPPORTED; /** @todo r=andy Support more setups. */
     170
     171    return rc;
     172}
    144173#endif /* IN_RING3 */
    145174
Note: See TracChangeset for help on using the changeset viewer.

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