VirtualBox

Changeset 60925 in vbox for trunk/include/VBox/vmm


Ignore:
Timestamp:
May 10, 2016 1:27:44 PM (9 years ago)
Author:
vboxsync
Message:

Audio: Update on infrastructure:

  • More work on HDA stream interleaving + surround support
  • The mixer can now (optionally) act as a supplemental layer between audio connector interface and device emulation (where applicable)
  • Multiple LUN streams can be bound to a certain sink, which in turn then can be treated as separate input/output channels
  • Unified more code which was duplicated between different audio device emulations
  • Tiny bit of documentation

Work in progress.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/pdmaudioifs.h

    r60368 r60925  
    2828
    2929#include <VBox/types.h>
     30#include <iprt/circbuf.h>
    3031#include <iprt/critsect.h>
    3132#include <iprt/list.h>
     
    5253typedef enum PDMAUDIOFMT
    5354{
    54     AUD_FMT_INVALID,
    55     AUD_FMT_U8,
    56     AUD_FMT_S8,
    57     AUD_FMT_U16,
    58     AUD_FMT_S16,
    59     AUD_FMT_U32,
    60     AUD_FMT_S32,
     55    PDMAUDIOFMT_INVALID,
     56    PDMAUDIOFMT_U8,
     57    PDMAUDIOFMT_S8,
     58    PDMAUDIOFMT_U16,
     59    PDMAUDIOFMT_S16,
     60    PDMAUDIOFMT_U32,
     61    PDMAUDIOFMT_S32,
    6162    /** Hack to blow the type up to 32-bit. */
    62     AUD_FMT_32BIT_HACK = 0x7fffffff
     63    PDMAUDIOFMT_32BIT_HACK = 0x7fffffff
    6364} PDMAUDIOFMT;
    6465
     
    152153
    153154/**
     155 * Audio stream (data) layout.
     156 */
     157typedef enum PDMAUDIOSTREAMLAYOUT
     158{
     159    /** Unknown access type; do not use. */
     160    PDMAUDIOSTREAMLAYOUT_UNKNOWN = 0,
     161    /** Non-interleaved access, that is, consecutive
     162     *  access to the data. */
     163    PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED,
     164    /** Interleaved access, where the data can be
     165     *  mixed together with data of other audio streams. */
     166    PDMAUDIOSTREAMLAYOUT_INTERLEAVED
     167} PDMAUDIOSTREAMLAYOUT, *PPDMAUDIOSTREAMLAYOUT;
     168
     169/** No stream channel data flags defined. */
     170#define PDMAUDIOSTREAMCHANNELDATA_FLAG_NONE      0
     171
     172/**
     173 * Structure for keeping a stream channel data block around.
     174 */
     175typedef struct PDMAUDIOSTREAMCHANNELDATA
     176{
     177    /** Circular buffer for the channel data. */
     178    PRTCIRCBUF pCircBuf;
     179    size_t     cbAcq;
     180    /** Channel data flags. */
     181    uint32_t   fFlags;
     182} PDMAUDIOSTREAMCHANNELDATA, *PPDMAUDIOSTREAMCHANNELDATA;
     183
     184/**
     185 * Structure for a single channel of an audio stream.
     186 * An audio stream consists of one or multiple channels,
     187 * depending on the configuration.
     188 */
     189typedef struct PDMAUDIOSTREAMCHANNEL
     190{
     191    /** Channel ID. */
     192    uint8_t                   uChannel;
     193    /** Step size (in bytes) to the channel's next frame. */
     194    size_t                    cbStep;
     195    /** Frame size (in bytes) of this channel. */
     196    size_t                    cbFrame;
     197    /** Offset (in bytes) to first sample in the data block. */
     198    size_t                    cbFirst;
     199    /** Currente offset (in bytes) in the data stream. */
     200    size_t                    cbOff;
     201    /** Associated data buffer. */
     202    PDMAUDIOSTREAMCHANNELDATA Data;
     203} PDMAUDIOSTREAMCHANNEL, *PPDMAUDIOSTREAMCHANNEL;
     204
     205/**
    154206 * Structure for keeping an audio stream configuration.
    155207 */
     
    157209{
    158210    /** Friendly name of the stream. */
    159     const char               *pszName;
     211    char                     szName[64];
    160212    /** Direction of the stream. */
    161213    PDMAUDIODIR              enmDir;
     
    169221    /** Frequency in Hertz (Hz). */
    170222    uint32_t                 uHz;
    171     /** Number of channels (2 for stereo, 1 for mono). */
     223    /** Number of audio channels (2 for stereo, 1 for mono). */
    172224    uint8_t                  cChannels;
    173225    /** Audio format. */
     
    337389     */
    338390    int64_t                iFreqRatio;
    339     /* For quickly converting samples <-> bytes and
    340      * vice versa. */
     391    /** For quickly converting samples <-> bytes and vice versa. */
    341392    uint8_t                cShift;
    342393} PDMAUDIOMIXBUF;
     
    347398/** No flags being set. */
    348399#define PDMAUDIOSTRMSTS_FLAG_NONE            0
     400/** Whether this stream has been initialized by the
     401 *  backend or not. */
     402#define PDMAUDIOSTRMSTS_FLAG_INITIALIZED     RT_BIT_32(0)
    349403/** Whether this stream is enabled or disabled. */
    350 #define PDMAUDIOSTRMSTS_FLAG_ENABLED         RT_BIT_32(0)
     404#define PDMAUDIOSTRMSTS_FLAG_ENABLED         RT_BIT_32(1)
    351405/** Whether this stream has been paused or not. This also implies
    352406 *  that this is an enabled stream! */
    353 #define PDMAUDIOSTRMSTS_FLAG_PAUSED          RT_BIT_32(1)
     407#define PDMAUDIOSTRMSTS_FLAG_PAUSED          RT_BIT_32(2)
    354408/** Whether this stream was marked as being disabled
    355409 *  but there are still associated guest output streams
    356410 *  which rely on its data. */
    357 #define PDMAUDIOSTRMSTS_FLAG_PENDING_DISABLE RT_BIT_32(2)
     411#define PDMAUDIOSTRMSTS_FLAG_PENDING_DISABLE RT_BIT_32(3)
    358412/** Validation mask. */
    359 #define PDMAUDIOSTRMSTS_VALID_MASK           UINT32_C(0x00000007)
     413#define PDMAUDIOSTRMSTS_VALID_MASK           UINT32_C(0x0000000F)
    360414
    361415/**
     
    418472    bool                   fEmpty;
    419473    /** Name of this stream. */
    420     char                  *pszName;
     474    char                   szName[64];
    421475    /** Number of references to this stream. Only can be
    422476     *  destroyed if the reference count is reaching 0. */
    423     uint8_t                cRefs;
     477    uint32_t               cRefs;
    424478} PDMAUDIOGSTSTRMSTATE, *PPDMAUDIOGSTSTRMSTATE;
    425479
     
    515569/**
    516570 * Audio connector interface (up).
     571 ** @todo Get rid of the separate XXXIn and XXXOut methods and unify the In/Out structs with a union,
     572 **       so that we only have one guest and one host stream ultimately.
    517573 */
    518574typedef struct PDMIAUDIOCONNECTOR
    519575{
    520576    DECLR3CALLBACKMEMBER(int, pfnQueryStatus, (PPDMIAUDIOCONNECTOR pInterface, uint32_t *pcbAvailIn, uint32_t *pcbFreeOut, uint32_t *pcSamplesLive));
     577
     578    /**
     579     * Adds a reference to the specified input stream.
     580     *
     581     * @returns New reference count.
     582     * @param   pInterface      Pointer to the interface structure containing the called function pointer.
     583     * @param   pGstStrmIn      Pointer to guest input stream adding the reference to.
     584     */
     585    DECLR3CALLBACKMEMBER(uint32_t, pfnAddRefIn, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOGSTSTRMIN pGstStrmIn));
     586
     587    /**
     588     * Adds a reference to the specified output stream.
     589     *
     590     * @returns New reference count.
     591     * @param   pInterface      Pointer to the interface structure containing the called function pointer.
     592     * @param   pGstStrmOut     Pointer to guest output stream adding the reference to.
     593     */
     594    DECLR3CALLBACKMEMBER(uint32_t, pfnAddRefOut, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOGSTSTRMOUT pGstStrmOut));
     595
     596    /**
     597     * Releases a reference from the input specified stream.
     598     *
     599     * @returns New reference count.
     600     * @param   pInterface      Pointer to the interface structure containing the called function pointer.
     601     * @param   pGstStrmIn      Pointer to guest input stream releasing a reference from.
     602     */
     603    DECLR3CALLBACKMEMBER(uint32_t, pfnReleaseIn, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOGSTSTRMIN pGstStrmIn));
     604
     605    /**
     606     * Releases a reference from the output specified stream.
     607     *
     608     * @returns New reference count.
     609     * @param   pInterface      Pointer to the interface structure containing the called function pointer.
     610     * @param   pGstStrmOut     Pointer to guest output stream releasing a reference from.
     611     */
     612    DECLR3CALLBACKMEMBER(uint32_t, pfnReleaseOut, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOGSTSTRMOUT pGstStrmOut));
    521613
    522614    /**
     
    552644     * @param   pCfg            Where to store the host audio backend configuration data.
    553645     */
    554     DECLR3CALLBACKMEMBER(int, pfnGetConfiguration, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOBACKENDCFG pCfg));
     646    DECLR3CALLBACKMEMBER(int, pfnGetConfig, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOBACKENDCFG pCfg));
    555647
    556648    /**
     
    616708     * @param   pInterface           Pointer to the interface structure containing the called function pointer.
    617709     * @param   pszName              Friendly name of this input stream.
    618      * @param   pCfg                 Pointer to PDMAUDIOSTREAMCFG to use.
    619710     * @param   ppGstStrmIn          Pointer where to return the guest guest input stream on success.
    620711     */
    621     DECLR3CALLBACKMEMBER(int, pfnCreateIn, (PPDMIAUDIOCONNECTOR pInterface, const char *pszName,
    622                                             PPDMAUDIOSTREAMCFG pCfg, PPDMAUDIOGSTSTRMIN *ppGstStrmIn));
     712    DECLR3CALLBACKMEMBER(int, pfnCreateIn, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAMCFG pCfg,
     713                                            PPDMAUDIOGSTSTRMIN *ppGstStrmIn));
    623714    /**
    624715     * Creates a guest output stream.
     
    626717     * @returns VBox status code.
    627718     * @param   pInterface           Pointer to the interface structure containing the called function pointer.
    628      * @param   pszName              Friendly name of this output stream.
    629719     * @param   pCfg                 Pointer to PDMAUDIOSTREAMCFG to use.
    630720     * @param   ppGstStrmOut         Pointer where to return the guest guest input stream on success.
    631721     */
    632     DECLR3CALLBACKMEMBER(int, pfnCreateOut, (PPDMIAUDIOCONNECTOR pInterface, const char *pszName,
    633                                              PPDMAUDIOSTREAMCFG pCfg, PPDMAUDIOGSTSTRMOUT *ppGstStrmOut));
    634 
     722    DECLR3CALLBACKMEMBER(int, pfnCreateOut, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAMCFG pCfg,
     723                                             PPDMAUDIOGSTSTRMOUT *ppGstStrmOut));
    635724    /**
    636725     * Destroys a guest input stream.
     
    666755
    667756/** PDMIAUDIOCONNECTOR interface ID. */
    668 #define PDMIAUDIOCONNECTOR_IID                  "f0ef4012-ae89-4528-9dad-4ef496894df8"
     757#define PDMIAUDIOCONNECTOR_IID                  "5bba362c-092a-493b-854b-5d0ad3acecc4"
    669758
    670759
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