VirtualBox

Changeset 88917 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 6, 2021 9:24:44 PM (4 years ago)
Author:
vboxsync
Message:

AudioMixer: Removed some more unused stuff; cleanups. bugref:9890

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

Legend:

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

    r88916 r88917  
    121121 *                      AUDIOMIXERSINK_STATUS_STR_MAX in length.
    122122 */
    123 static const char *dbgAudioMixerSinkStatusToStr(AUDMIXSINKSTS fStatus, char pszDst[AUDIOMIXERSINK_STATUS_STR_MAX])
     123static const char *dbgAudioMixerSinkStatusToStr(uint32_t fStatus, char pszDst[AUDIOMIXERSINK_STATUS_STR_MAX])
    124124{
    125125    if (!fStatus)
     
    215215 * @returns VBox status code.
    216216 * @param   pcszName            Name of the audio mixer.
    217  * @param   fFlags              Creation flags.
     217 * @param   fFlags              Creation flags - AUDMIXER_FLAGS_XXX.
    218218 * @param   ppMixer             Pointer which returns the created mixer object.
    219219 */
     
    531531 *                      in some unspecified way (see
    532532 *                      PDMIAUDIOCONNECTOR::pfnStreamCreate).
    533  * @param   fFlags      Stream flags. Currently unused, set to 0.
    534533 * @param   pDevIns     The device instance to register statistics with.
    535534 * @param   ppStream    Pointer which receives the newly created audio stream.
    536535 */
    537536int AudioMixerSinkCreateStream(PAUDMIXSINK pSink, PPDMIAUDIOCONNECTOR pConn, PPDMAUDIOSTREAMCFG pCfg,
    538                                AUDMIXSTREAMFLAGS fFlags, PPDMDEVINS pDevIns, PAUDMIXSTREAM *ppStream)
     537                               PPDMDEVINS pDevIns, PAUDMIXSTREAM *ppStream)
    539538{
    540539    AssertPtrReturn(pSink, VERR_INVALID_POINTER);
    541540    AssertPtrReturn(pConn, VERR_INVALID_POINTER);
    542     AssertPtrReturn(pCfg,  VERR_INVALID_POINTER);
    543     /** @todo Validate fFlags. */
    544     /* ppStream is optional. */
     541    AssertPtrReturn(pCfg, VERR_INVALID_POINTER);
     542    AssertPtrNullReturn(ppStream, VERR_INVALID_POINTER);
    545543    RT_NOREF(pDevIns); /* we'll probably be adding more statistics */
    546544
     
    560558    PAUDMIXSTREAM pMixStream = (PAUDMIXSTREAM)RTMemAllocZ(sizeof(AUDMIXSTREAM));
    561559    AssertReturn(pMixStream, VERR_NO_MEMORY);
    562 
    563     pMixStream->fFlags = fFlags;
    564560
    565561    /* Assign the backend's name to the mixer stream's name for easier identification in the (release) log. */
     
    579575            if (RT_SUCCESS(rc))
    580576            {
    581                 LogFlowFunc(("[%s] fFlags=0x%x (enmDir=%ld, %u bits, %RU8 channels, %RU32Hz)\n", pSink->pszName, fFlags, pCfg->enmDir,
     577                LogFlowFunc(("[%s] (enmDir=%ld, %u bits, %RU8 channels, %RU32Hz)\n", pSink->pszName, pCfg->enmDir,
    582578                             PDMAudioPropsSampleBits(&pCfg->Props), PDMAudioPropsChannels(&pCfg->Props), pCfg->Props.uHz));
    583579
     
    1000996 * Returns the current status of a mixer sink.
    1001997 *
    1002  * @returns The sink's current status.
     998 * @returns The sink's current status (AUDMIXSINK_STS_XXX).
    1003999 * @param   pSink               Mixer sink to return status for.
    10041000 */
    1005 AUDMIXSINKSTS AudioMixerSinkGetStatus(PAUDMIXSINK pSink)
     1001uint32_t AudioMixerSinkGetStatus(PAUDMIXSINK pSink)
    10061002{
    10071003    if (!pSink)
     
    10131009
    10141010    /* If the dirty flag is set, there is unprocessed data in the sink. */
    1015     AUDMIXSINKSTS stsSink = pSink->fStatus;
     1011    uint32_t const fStsSink = pSink->fStatus;
    10161012
    10171013    rc2 = RTCritSectLeave(&pSink->CritSect);
    10181014    AssertRC(rc2);
    10191015
    1020     return stsSink;
     1016    return fStsSink;
    10211017}
    10221018
  • trunk/src/VBox/Devices/Audio/AudioMixer.h

    r88916 r88917  
    5959
    6060
    61 /** Defines an audio mixer stream's flags. */
    62 #define AUDMIXSTREAMFLAGS uint32_t
    63 
    64 /** No flags specified. */
    65 #define AUDMIXSTREAM_F_NONE                     0
    66 /** The mixing stream is flagged as being enabled (active). */
    67 #define AUDMIXSTREAM_F_ENABLED                  RT_BIT(0)
    68 
    69 /** Defines an audio mixer stream's internal status. */
    70 #define AUDMIXSTREAMSTATUS uint32_t
    71 
    72 /** @name AUDMIXSTREAM_STATUS_XXX - mixer stream status.
    73  * (This is a destilled version of PDMAUDIOSTREAM_STS_XXX.)
    74  * @{ */
    75 /** No status set. */
    76 #define AUDMIXSTREAM_STATUS_NONE                0
    77 /** The mixing stream is enabled (active). */
    78 #define AUDMIXSTREAM_STATUS_ENABLED             RT_BIT(0)
    79 /** The mixing stream can be read from.
    80  * Always set together with AUDMIXSTREAM_STATUS_ENABLED. */
    81 #define AUDMIXSTREAM_STATUS_CAN_READ            RT_BIT(1)
    82 /** The mixing stream can be written to.
    83  * Always set together with AUDMIXSTREAM_STATUS_ENABLED. */
    84 #define AUDMIXSTREAM_STATUS_CAN_WRITE           RT_BIT(2)
    85 /** @} */
    86 
    87 
    8861/**
    8962 * Audio mixer stream.
     
    9164typedef struct AUDMIXSTREAM
    9265{
    93     /** List node. */
     66    /** List entry on AUDMIXSINK::lstStreams. */
    9467    RTLISTNODE              Node;
    9568    /** Name of this stream. */
     
    9972    /** Sink this stream is attached to. */
    10073    PAUDMIXSINK             pSink;
    101     /** Stream flags of type AUDMIXSTREAM_F_. */
    102     uint32_t                fFlags;
    10374    /** Stream status of type AUDMIXSTREAM_STATUS_. */
    10475    uint32_t                fStatus;
     
    11990    /** The streams's critical section. */
    12091    RTCRITSECT              CritSect;
    121 } AUDMIXSTREAM, *PAUDMIXSTREAM;
    122 
    123 /** Defines an audio sink's current status. */
    124 #define AUDMIXSINKSTS uint32_t
    125 
     92} AUDMIXSTREAM;
     93/** Pointer to an audio mixer stream. */
     94typedef AUDMIXSTREAM *PAUDMIXSTREAM;
     95
     96/** @name AUDMIXSTREAM_STATUS_XXX - mixer stream status.
     97 * (This is a destilled version of PDMAUDIOSTREAM_STS_XXX.)
     98 * @{ */
     99/** No status set. */
     100#define AUDMIXSTREAM_STATUS_NONE                UINT32_C(0)
     101/** The mixing stream is enabled (active). */
     102#define AUDMIXSTREAM_STATUS_ENABLED             RT_BIT_32(0)
     103/** The mixing stream can be read from.
     104 * Always set together with AUDMIXSTREAM_STATUS_ENABLED. */
     105#define AUDMIXSTREAM_STATUS_CAN_READ            RT_BIT_32(1)
     106/** The mixing stream can be written to.
     107 * Always set together with AUDMIXSTREAM_STATUS_ENABLED. */
     108#define AUDMIXSTREAM_STATUS_CAN_WRITE           RT_BIT_32(2)
     109/** @} */
     110
     111
     112/**
     113 * Audio mixer sink.
     114 */
     115typedef struct AUDMIXSINK
     116{
     117    /** List entry on AUDIOMIXER::lstSinks. */
     118    RTLISTNODE              Node;
     119    /** Pointer to mixer object this sink is bound to. */
     120    PAUDIOMIXER             pParent;
     121    /** Name of this sink. */
     122    char                   *pszName;
     123    /** The sink direction (either PDMAUDIODIR_IN or PDMAUDIODIR_OUT). */
     124    PDMAUDIODIR             enmDir;
     125    /** Scratch buffer for multiplexing / mixing. Might be NULL if not needed. */
     126    uint8_t                *pabScratchBuf;
     127    /** Size (in bytes) of pabScratchBuf. Might be 0 if not needed. */
     128    size_t                  cbScratchBuf;
     129    /** The sink's PCM format. */
     130    PDMAUDIOPCMPROPS        PCMProps;
     131    /** Sink status bits - AUDMIXSINK_STS_XXX. */
     132    uint32_t                fStatus;
     133    /** Number of streams assigned. */
     134    uint8_t                 cStreams;
     135    /** List of assigned streams.
     136     * @note All streams have the same PCM properties, so the mixer does not do
     137     *       any conversion.  bird: That is *NOT* true any more, the mixer has
     138     *       encoders/decoder states for each stream (well, input is still a todo).
     139     *
     140     * @todo Use something faster -- vector maybe?  bird: It won't be faster.  You
     141     *       will have a vector of stream pointers (because you cannot have a vector
     142     *       of full AUDMIXSTREAM structures since they'll move when the vector is
     143     *       reallocated and we need pointers to them to give out to devices), which
     144     *       is the same cost as going via Node.pNext/pPrev. */
     145    RTLISTANCHOR            lstStreams;
     146    /** The volume of this sink. The volume always will
     147     *  be combined with the mixer's master volume. */
     148    PDMAUDIOVOLUME          Volume;
     149    /** The volume of this sink, combined with the last set  master volume. */
     150    PDMAUDIOVOLUME          VolumeCombined;
     151    /** Timestamp since last update (in ms). */
     152    uint64_t                tsLastUpdatedMs;
     153    /** Last read (recording) / written (playback) timestamp (in ns). */
     154    uint64_t                tsLastReadWrittenNs;
     155    /** Union for input/output specifics. */
     156    union
     157    {
     158        struct
     159        {
     160            /** The current recording source. Can be NULL if not set. */
     161            PAUDMIXSTREAM  pStreamRecSource;
     162        } In;
     163        /*struct
     164        {
     165        } Out; */
     166    };
     167    struct
     168    {
     169        PAUDIOHLPFILE       pFile;
     170    } Dbg;
     171    /** This sink's mixing buffer, acting as
     172     * a parent buffer for all streams this sink owns. */
     173    AUDIOMIXBUF             MixBuf;
     174    /** The sink's critical section. */
     175    RTCRITSECT              CritSect;
     176} AUDMIXSINK;
     177
     178/** @name AUDMIXSINK_STS_XXX - Sink status bits.
     179 * @{ */
    126180/** No status specified. */
    127181#define AUDMIXSINK_STS_NONE                  0
     
    136190 *   recorded but not transferred to the destination yet. */
    137191#define AUDMIXSINK_STS_DIRTY                 RT_BIT(2)
    138 
    139 /**
    140  * Audio input sink specifics.
    141  *
    142  * Do not use directly. Instead, use AUDMIXSINK.
    143  */
    144 typedef struct AUDMIXSINKIN
    145 {
    146     /** The current recording source. Can be NULL if not set. */
    147     PAUDMIXSTREAM  pStreamRecSource;
    148 } AUDMIXSINKIN;
    149 
    150 /**
    151  * Audio output sink specifics.
    152  *
    153  * Do not use directly. Instead, use AUDMIXSINK.
    154  */
    155 typedef struct AUDMIXSINKOUT
    156 {
    157 } AUDMIXSINKOUT;
    158 
    159 /**
    160  * Audio mixer sink.
    161  */
    162 typedef struct AUDMIXSINK
    163 {
    164     RTLISTNODE              Node;
    165     /** Pointer to mixer object this sink is bound to. */
    166     PAUDIOMIXER             pParent;
    167     /** Name of this sink. */
    168     char                   *pszName;
    169     /** The sink direction (either PDMAUDIODIR_IN or PDMAUDIODIR_OUT). */
    170     PDMAUDIODIR             enmDir;
    171     /** The sink's critical section. */
    172     RTCRITSECT              CritSect;
    173     /** This sink's mixing buffer, acting as
    174      * a parent buffer for all streams this sink owns. */
    175     AUDIOMIXBUF          MixBuf;
    176     /** Scratch buffer for multiplexing / mixing. Might be NULL if not needed. */
    177     uint8_t                *pabScratchBuf;
    178     /** Size (in bytes) of pabScratchBuf. Might be 0 if not needed. */
    179     size_t                  cbScratchBuf;
    180     /** Union for input/output specifics. */
    181     union
    182     {
    183         AUDMIXSINKIN        In;
    184         AUDMIXSINKOUT       Out;
    185     };
    186     /** Sink status of type AUDMIXSINK_STS_XXX. */
    187     AUDMIXSINKSTS           fStatus;
    188     /** The sink's PCM format. */
    189     PDMAUDIOPCMPROPS        PCMProps;
    190     /** Number of streams assigned. */
    191     uint8_t                 cStreams;
    192     /** List of assigned streams.
    193      * @note All streams have the same PCM properties, so the mixer does not do
    194      *       any conversion. */
    195     /** @todo Use something faster -- vector maybe? */
    196     RTLISTANCHOR            lstStreams;
    197     /** The volume of this sink. The volume always will
    198      *  be combined with the mixer's master volume. */
    199     PDMAUDIOVOLUME          Volume;
    200     /** The volume of this sink, combined with the last set  master volume. */
    201     PDMAUDIOVOLUME          VolumeCombined;
    202     /** Timestamp since last update (in ms). */
    203     uint64_t                tsLastUpdatedMs;
    204     /** Last read (recording) / written (playback) timestamp (in ns). */
    205     uint64_t                tsLastReadWrittenNs;
    206     struct
    207     {
    208         PAUDIOHLPFILE       pFile;
    209     } Dbg;
    210 } AUDMIXSINK;
     192/** @} */
     193
    211194
    212195/**
     
    225208} AUDMIXOP;
    226209
     210
     211/** @name AUDMIXER_FLAGS_XXX - For AudioMixerCreate().
     212 * @{ */
    227213/** No mixer flags specified. */
    228214#define AUDMIXER_FLAGS_NONE             0
     
    232218/** Validation mask. */
    233219#define AUDMIXER_FLAGS_VALID_MASK       UINT32_C(0x00000001)
     220/** @} */
     221
    234222
    235223int AudioMixerCreate(const char *pszName, uint32_t fFlags, PAUDIOMIXER *ppMixer);
     
    242230int     AudioMixerSinkAddStream(PAUDMIXSINK pSink, PAUDMIXSTREAM pStream);
    243231int     AudioMixerSinkCreateStream(PAUDMIXSINK pSink, PPDMIAUDIOCONNECTOR pConnector, PPDMAUDIOSTREAMCFG pCfg,
    244                                    AUDMIXSTREAMFLAGS fFlags, PPDMDEVINS pDevIns, PAUDMIXSTREAM *ppStream);
     232                                   PPDMDEVINS pDevIns, PAUDMIXSTREAM *ppStream);
    245233int     AudioMixerSinkCtl(PAUDMIXSINK pSink, PDMAUDIOSTREAMCMD enmCmd);
    246234void AudioMixerSinkDestroy(PAUDMIXSINK pSink, PPDMDEVINS pDevIns);
     
    249237PDMAUDIODIR   AudioMixerSinkGetDir(PAUDMIXSINK pSink);
    250238PAUDMIXSTREAM AudioMixerSinkGetRecordingSource(PAUDMIXSINK pSink);
    251 AUDMIXSINKSTS AudioMixerSinkGetStatus(PAUDMIXSINK pSink);
     239uint32_t AudioMixerSinkGetStatus(PAUDMIXSINK pSink);
    252240bool AudioMixerSinkIsActive(PAUDMIXSINK pSink);
    253241int AudioMixerSinkRead(PAUDMIXSINK pSink, AUDMIXOP enmOp, void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead);
  • trunk/src/VBox/Devices/Audio/DevHda.cpp

    r88916 r88917  
    23292329
    23302330    PAUDMIXSTREAM pMixStrm = NULL;
    2331     int rc = AudioMixerSinkCreateStream(pMixSink, pDrv->pConnector, &StreamCfg, 0 /* fFlags */, pDevIns, &pMixStrm);
     2331    int rc = AudioMixerSinkCreateStream(pMixSink, pDrv->pConnector, &StreamCfg, pDevIns, &pMixStrm);
    23322332    LogFlowFunc(("LUN#%RU8: Created stream \"%s\" for sink, rc=%Rrc\n", pDrv->uLUN, StreamCfg.szName, rc));
    23332333    if (RT_SUCCESS(rc))
  • trunk/src/VBox/Devices/Audio/DevIchAc97.cpp

    r88916 r88917  
    18681868
    18691869        PAUDMIXSTREAM pMixStrm;
    1870         rc = AudioMixerSinkCreateStream(pMixSink, pDrv->pConnector, pStreamCfg, 0 /* fFlags */, pDevIns, &pMixStrm);
     1870        rc = AudioMixerSinkCreateStream(pMixSink, pDrv->pConnector, pStreamCfg, pDevIns, &pMixStrm);
    18711871        LogFlowFunc(("LUN#%RU8: Created stream \"%s\" for sink, rc=%Rrc\n", pDrv->uLUN, pStreamCfg->szName, rc));
    18721872        if (RT_SUCCESS(rc))
  • trunk/src/VBox/Devices/Audio/DevSB16.cpp

    r88916 r88917  
    20022002
    20032003        PAUDMIXSTREAM pMixStrm;
    2004         rc = AudioMixerSinkCreateStream(pMixSink, pDrv->pConnector, pStreamCfg, 0 /* fFlags */, pDevIns, &pMixStrm);
     2004        rc = AudioMixerSinkCreateStream(pMixSink, pDrv->pConnector, pStreamCfg, pDevIns, &pMixStrm);
    20052005        LogFlowFunc(("LUN#%RU8: Created stream \"%s\" for sink, rc=%Rrc\n", pDrv->uLUN, pStreamCfg->szName, rc));
    20062006        if (RT_SUCCESS(rc))
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