VirtualBox

Changeset 88718 in vbox for trunk/src


Ignore:
Timestamp:
Apr 26, 2021 9:21:24 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
144036
Message:

Audio: Changed PPDMAUDIOBACKENDSTREAM from opaque to a common base-structure which the backends can extend with their own data. bugref:9890

Location:
trunk/src/VBox
Files:
12 edited

Legend:

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

    r88717 r88718  
    14181418        return rc;
    14191419    }
     1420    AssertLogRelReturn(pStreamEx->pBackend->uMagic  == PDMAUDIOBACKENDSTREAM_MAGIC, VERR_INTERNAL_ERROR_3);
     1421    AssertLogRelReturn(pStreamEx->pBackend->pStream == &pStreamEx->Core, VERR_INTERNAL_ERROR_3);
    14201422
    14211423    /* Validate acquired configuration. */
     
    17691771    }
    17701772    size_t const cbHstStrm = pThis->BackendCfg.cbStream;
     1773    AssertStmt(cbHstStrm >= sizeof(PDMAUDIOBACKENDSTREAM), rc = VERR_OUT_OF_RANGE);
    17711774    AssertStmt(cbHstStrm < _16M, rc = VERR_OUT_OF_RANGE);
    17721775    if (RT_SUCCESS(rc))
     
    17831786                        pThis->BackendCfg.szName, pCfgHost->szName[0] != '\0' ? pCfgHost->szName : "<Untitled>");
    17841787
    1785             pStreamEx->Core.enmDir    = pCfgHost->enmDir;
    1786             pStreamEx->Core.cbBackend = (uint32_t)cbHstStrm;
    1787             if (cbHstStrm)
    1788                 pStreamEx->pBackend   = (PPDMAUDIOBACKENDSTREAM)(pStreamEx + 1);
    1789             pStreamEx->fNoMixBufs     = RT_BOOL(fFlags & PDMAUDIOSTREAM_CREATE_F_NO_MIXBUF);
    1790             pStreamEx->uMagic         = DRVAUDIOSTREAM_MAGIC;
     1788            PPDMAUDIOBACKENDSTREAM pBackend = (PPDMAUDIOBACKENDSTREAM)(pStreamEx + 1);
     1789            pBackend->uMagic            = PDMAUDIOBACKENDSTREAM_MAGIC;
     1790            pBackend->pStream           = &pStreamEx->Core;
     1791            pStreamEx->pBackend         = pBackend;
     1792            pStreamEx->Core.enmDir      = pCfgHost->enmDir;
     1793            pStreamEx->Core.cbBackend   = (uint32_t)cbHstStrm;
     1794            pStreamEx->fNoMixBufs       = RT_BOOL(fFlags & PDMAUDIOSTREAM_CREATE_F_NO_MIXBUF);
     1795            pStreamEx->uMagic           = DRVAUDIOSTREAM_MAGIC;
    17911796
    17921797            /*
     
    19881993    Assert(pStreamEx->Core.uMagic == PDMAUDIOSTREAM_MAGIC);
    19891994    Assert(pStreamEx->uMagic == DRVAUDIOSTREAM_MAGIC);
     1995    Assert(pStreamEx->pBackend && pStreamEx->pBackend->uMagic == PDMAUDIOBACKENDSTREAM_MAGIC);
    19901996
    19911997    int rc = RTCritSectEnter(&pThis->CritSect);
  • trunk/src/VBox/Devices/Audio/DrvHostAudioAlsa.cpp

    r88672 r88718  
    109109typedef struct ALSAAUDIOSTREAM
    110110{
     111    /** Common part. */
     112    PDMAUDIOBACKENDSTREAM   Core;
     113
    111114    /** Handle to the ALSA PCM stream. */
    112     snd_pcm_t          *hPCM;
     115    snd_pcm_t              *hPCM;
    113116    /** Internal stream offset (for debugging). */
    114     uint64_t            offInternal;
     117    uint64_t                offInternal;
    115118
    116119    /** The stream's acquired configuration. */
    117     PDMAUDIOSTREAMCFG   Cfg;
     120    PDMAUDIOSTREAMCFG       Cfg;
    118121    /** The acquired ALSA stream config (same as Cfg). */
    119     ALSAAUDIOSTREAMCFG  AlsaCfg;
     122    ALSAAUDIOSTREAMCFG      AlsaCfg;
    120123} ALSAAUDIOSTREAM;
    121124/** Pointer to the ALSA host audio specific stream data. */
  • trunk/src/VBox/Devices/Audio/DrvHostAudioCoreAudio.cpp

    r88534 r88718  
    374374typedef struct COREAUDIOSTREAM
    375375{
     376    /** Common part. */
     377    PDMAUDIOBACKENDSTREAM       Core;
     378
    376379    /** The stream's acquired configuration. */
    377380    PPDMAUDIOSTREAMCFG          pCfg;
  • trunk/src/VBox/Devices/Audio/DrvHostAudioDSound.cpp

    r88691 r88718  
    108108typedef struct DSOUNDSTREAM
    109109{
     110    /** Common part. */
     111    PDMAUDIOBACKENDSTREAM   Core;
    110112    /** Entry in DRVHOSTDSOUND::HeadStreams. */
    111     RTLISTNODE          ListEntry;
     113    RTLISTNODE              ListEntry;
    112114    /** The stream's acquired configuration. */
    113     PDMAUDIOSTREAMCFG   Cfg;
     115    PDMAUDIOSTREAMCFG       Cfg;
    114116    /** Buffer alignment. */
    115     uint8_t             uAlign;
     117    uint8_t                 uAlign;
    116118    /** Whether this stream is in an enable state on the DirectSound side. */
    117     bool                fEnabled;
    118     bool                afPadding[2];
     119    bool                    fEnabled;
     120    bool                    afPadding[2];
    119121    /** Size (in bytes) of the DirectSound buffer. */
    120     DWORD               cbBufSize;
     122    DWORD                   cbBufSize;
    121123    union
    122124    {
     
    163165    /** Timestamp (in ms) of the last transfer from the internal buffer to/from the
    164166     *  DirectSound buffer. */
    165     uint64_t            msLastTransfer;
     167    uint64_t                msLastTransfer;
    166168    /** The stream's critical section for synchronizing access. */
    167     RTCRITSECT          CritSect;
     169    RTCRITSECT              CritSect;
    168170    /** Used for formatting the current DSound status. */
    169     char                szStatus[127];
     171    char                    szStatus[127];
    170172    /** Fixed zero terminator. */
    171     char const          chStateZero;
     173    char const              chStateZero;
    172174} DSOUNDSTREAM, *PDSOUNDSTREAM;
    173175
  • trunk/src/VBox/Devices/Audio/DrvHostAudioDebug.cpp

    r88534 r88718  
    4343typedef struct DEBUGAUDIOSTREAM
    4444{
     45    /** Common part. */
     46    PDMAUDIOBACKENDSTREAM   Core;
    4547    /** The stream's acquired configuration. */
    46     PDMAUDIOSTREAMCFG   Cfg;
     48    PDMAUDIOSTREAMCFG       Cfg;
    4749    /** Audio file to dump output to or read input from. */
    48     PAUDIOHLPFILE       pFile;
     50    PAUDIOHLPFILE           pFile;
    4951    union
    5052    {
     
    5254        {
    5355            /** Current sample index for generate the sine wave. */
    54             uint64_t    uSample;
     56            uint64_t        uSample;
    5557            /** The fixed portion of the sin() input. */
    56             double      rdFixed;
     58            double          rdFixed;
    5759            /** Timestamp of last captured samples. */
    58             uint64_t    tsLastCaptured;
     60            uint64_t        tsLastCaptured;
    5961            /** Frequency (in Hz) of the sine wave to generate. */
    60             double      rdFreqHz;
     62            double          rdFreqHz;
    6163        } In;
    6264    };
  • trunk/src/VBox/Devices/Audio/DrvHostAudioNull.cpp

    r88693 r88718  
    3838typedef struct NULLAUDIOSTREAM
    3939{
     40    /** Common part. */
     41    PDMAUDIOBACKENDSTREAM   Core;
    4042    /** The stream's acquired configuration. */
    41     PDMAUDIOSTREAMCFG   Cfg;
     43    PDMAUDIOSTREAMCFG       Cfg;
    4244} NULLAUDIOSTREAM;
    4345/** Pointer to a null audio stream.   */
  • trunk/src/VBox/Devices/Audio/DrvHostAudioOss.cpp

    r88534 r88718  
    8787typedef struct OSSAUDIOSTREAM
    8888{
     89    /** Common part. */
     90    PDMAUDIOBACKENDSTREAM   Core;
    8991    /** The file descriptor. */
    90     int                 hFile;
     92    int                     hFile;
    9193    /** Buffer alignment. */
    92     uint8_t             uAlign;
     94    uint8_t                 uAlign;
    9395    /** Set if we're draining the stream (output only). */
    94     bool                fDraining;
     96    bool                    fDraining;
    9597    /** Internal stream byte offset. */
    96     uint64_t            offInternal;
     98    uint64_t                offInternal;
    9799    /** The stream's acquired configuration. */
    98     PDMAUDIOSTREAMCFG   Cfg;
     100    PDMAUDIOSTREAMCFG       Cfg;
    99101    /** The acquired OSS configuration. */
    100     OSSAUDIOSTREAMCFG   OssCfg;
     102    OSSAUDIOSTREAMCFG       OssCfg;
    101103    /** Handle to the thread draining output streams. */
    102     RTTHREAD            hThreadDrain;
    103 
     104    RTTHREAD                hThreadDrain;
    104105} OSSAUDIOSTREAM;
    105106/** Pointer to an OSS audio stream. */
  • trunk/src/VBox/Devices/Audio/DrvHostAudioPulseAudio.cpp

    r88672 r88718  
    133133typedef struct PULSEAUDIOSTREAM
    134134{
     135    /** Common part. */
     136    PDMAUDIOBACKENDSTREAM   Core;
    135137    /** The stream's acquired configuration. */
    136     PDMAUDIOSTREAMCFG      Cfg;
     138    PDMAUDIOSTREAMCFG       Cfg;
    137139    /** Pointer to driver instance. */
    138     PDRVHOSTPULSEAUDIO     pDrv;
     140    PDRVHOSTPULSEAUDIO      pDrv;
    139141    /** Pointer to opaque PulseAudio stream. */
    140     pa_stream             *pStream;
     142    pa_stream              *pStream;
    141143    /** Pulse sample format and attribute specification. */
    142     pa_sample_spec         SampleSpec;
     144    pa_sample_spec          SampleSpec;
    143145    /** Pulse playback and buffer metrics. */
    144     pa_buffer_attr         BufAttr;
     146    pa_buffer_attr          BufAttr;
    145147    /** Input: Pointer to Pulse sample peek buffer. */
    146     const uint8_t         *pbPeekBuf;
     148    const uint8_t          *pbPeekBuf;
    147149    /** Input: Current size (in bytes) of peeked data in buffer. */
    148     size_t                 cbPeekBuf;
     150    size_t                  cbPeekBuf;
    149151    /** Input: Our offset (in bytes) in peek data buffer. */
    150     size_t                 offPeekBuf;
     152    size_t                  offPeekBuf;
    151153    /** Output: Asynchronous drain operation.  This is used as an indicator of
    152154     *  whether we're currently draining the stream (will be cleaned up before
    153155     *  resume/re-enable). */
    154     pa_operation          *pDrainOp;
     156    pa_operation           *pDrainOp;
    155157    /** Asynchronous cork/uncork operation.
    156158     * (This solely for cancelling before destroying the stream, so the callback
    157159     * won't do any after-freed accesses.) */
    158     pa_operation          *pCorkOp;
     160    pa_operation           *pCorkOp;
    159161    /** Asynchronous trigger operation.
    160162     * (This solely for cancelling before destroying the stream, so the callback
    161163     * won't do any after-freed accesses.) */
    162     pa_operation          *pTriggerOp;
     164    pa_operation           *pTriggerOp;
    163165    /** Output: Current latency (in microsecs). */
    164     uint64_t               cUsLatency;
     166    uint64_t                cUsLatency;
    165167#ifdef LOG_ENABLED
    166168    /** Creation timestamp (in microsecs) of stream playback / recording. */
    167     pa_usec_t              tsStartUs;
     169    pa_usec_t               tsStartUs;
    168170    /** Timestamp (in microsecs) when last read from / written to the stream. */
    169     pa_usec_t              tsLastReadWrittenUs;
     171    pa_usec_t               tsLastReadWrittenUs;
    170172#endif
    171173#ifdef DEBUG
    172174    /** Number of occurred audio data underflows. */
    173     uint32_t               cUnderflows;
     175    uint32_t                cUnderflows;
    174176#endif
    175177} PULSEAUDIOSTREAM;
  • trunk/src/VBox/Devices/Audio/DrvHostAudioValidationKit.cpp

    r88534 r88718  
    4343typedef struct VAKITAUDIOSTREAM
    4444{
     45    /** Common part. */
     46    PDMAUDIOBACKENDSTREAM   Core;
    4547    /** The stream's acquired configuration. */
    46     PDMAUDIOSTREAMCFG   Cfg;
     48    PDMAUDIOSTREAMCFG       Cfg;
    4749    /** Audio file to dump output to or read input from. */
    48     PAUDIOHLPFILE       pFile;
     50    PAUDIOHLPFILE           pFile;
    4951    /** Text file to store timing of audio buffers submittions. */
    50     PRTSTREAM           pFileTiming;
     52    PRTSTREAM               pFileTiming;
    5153    /** Timestamp of the first play or record request. */
    52     uint64_t            tsStarted;
     54    uint64_t                tsStarted;
    5355    /** Total number of frames played or recorded so far. */
    54     uint32_t            cFramesSinceStarted;
     56    uint32_t                cFramesSinceStarted;
    5557    union
    5658    {
     
    5860        {
    5961            /** Timestamp of last captured samples. */
    60             uint64_t    tsLastCaptured;
     62            uint64_t        tsLastCaptured;
    6163        } In;
    6264        struct
    6365        {
    6466            /** Timestamp of last played samples. */
    65             uint64_t    tsLastPlayed;
    66             uint8_t    *pbPlayBuffer;
    67             uint32_t    cbPlayBuffer;
     67            uint64_t        tsLastPlayed;
     68            uint8_t        *pbPlayBuffer;
     69            uint32_t        cbPlayBuffer;
    6870        } Out;
    6971    };
  • trunk/src/VBox/Devices/Audio/DrvHostAudioWasApi.cpp

    r88706 r88718  
    138138typedef struct DRVHOSTAUDIOWASSTREAM
    139139{
     140    /** Common part. */
     141    PDMAUDIOBACKENDSTREAM       Core;
     142
    140143    /** Entry in DRVHOSTAUDIOWAS::StreamHead. */
    141144    RTLISTNODE                  ListEntry;
  • trunk/src/VBox/Main/src-client/DrvAudioRec.cpp

    r88534 r88718  
    246246typedef struct AVRECSTREAM
    247247{
     248    /** Common part. */
     249    PDMAUDIOBACKENDSTREAM   Core;
    248250    /** The stream's acquired configuration. */
    249     PDMAUDIOSTREAMCFG    Cfg;
     251    PDMAUDIOSTREAMCFG       Cfg;
    250252    /** (Audio) frame buffer. */
    251     PRTCIRCBUF           pCircBuf;
     253    PRTCIRCBUF              pCircBuf;
    252254    /** Pointer to sink to use for writing. */
    253     PAVRECSINK           pSink;
     255    PAVRECSINK              pSink;
    254256    /** Last encoded PTS (in ms). */
    255     uint64_t             uLastPTSMs;
     257    uint64_t                uLastPTSMs;
    256258    /** Temporary buffer for the input (source) data to encode. */
    257     void                *pvSrcBuf;
     259    void                   *pvSrcBuf;
    258260    /** Size (in bytes) of the temporary buffer holding the input (source) data to encode. */
    259     size_t               cbSrcBuf;
     261    size_t                  cbSrcBuf;
    260262    /** Temporary buffer for the encoded output (destination) data. */
    261     void                *pvDstBuf;
     263    void                   *pvDstBuf;
    262264    /** Size (in bytes) of the temporary buffer holding the encoded output (destination) data. */
    263     size_t               cbDstBuf;
     265    size_t                  cbDstBuf;
    264266} AVRECSTREAM, *PAVRECSTREAM;
    265267
  • trunk/src/VBox/Main/src-client/DrvAudioVRDE.cpp

    r88534 r88718  
    4848typedef struct VRDESTREAM
    4949{
     50    /** Common part. */
     51    PDMAUDIOBACKENDSTREAM   Core;
    5052    /** The stream's acquired configuration. */
    51     PDMAUDIOSTREAMCFG   Cfg;
     53    PDMAUDIOSTREAMCFG       Cfg;
    5254    union
    5355    {
     
    5557        {
    5658            /** Circular buffer for holding the recorded audio frames from the host. */
    57             PRTCIRCBUF  pCircBuf;
     59            PRTCIRCBUF      pCircBuf;
    5860        } In;
    5961    };
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