VirtualBox

Changeset 88061 in vbox


Ignore:
Timestamp:
Mar 9, 2021 6:14:19 PM (4 years ago)
Author:
vboxsync
Message:

Audio: Should use versioned magics like for other PDM structures, sorry guys. Added magic to PDMAUDIOMIXBUF. bugref:9890

Location:
trunk
Files:
5 edited

Legend:

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

    r88055 r88061  
    9292        Assert(pDev->uMagic == PDMAUDIOHOSTDEV_MAGIC);
    9393        Assert(pDev->cRefCount == 0);
    94         pDev->uMagic = PDMAUDIOHOSTDEV_MAGIC_DEAD;
     94        pDev->uMagic = ~PDMAUDIOHOSTDEV_MAGIC;
    9595        pDev->cbSelf = 0;
    9696
  • trunk/include/VBox/vmm/pdmaudioifs.h

    r88059 r88061  
    236236
    237237#include <VBox/types.h>
     238# include <VBox/vmm/pdmcommon.h>
    238239#ifdef VBOX_WITH_STATISTICS
    239240# include <VBox/vmm/stam.h>
     
    404405typedef PDMAUDIOHOSTDEV const *PCPDMAUDIOHOSTDEV;
    405406
    406 /** Magic value for PDMAUDIOHOSTDEV. (Armando Anthony "Chick" Corea) */
    407 #define PDMAUDIOHOSTDEV_MAGIC           UINT32_C(0x19410612)
    408 /** Magic value for PDMAUDIOHOSTDEV after free. */
    409 #define PDMAUDIOHOSTDEV_MAGIC_DEAD      UINT32_C(0x20210209)
     407/** Magic value for PDMAUDIOHOSTDEV.  */
     408#define PDMAUDIOHOSTDEV_MAGIC       PDM_VERSION_MAKE(0xa0d0, 1, 0)
    410409
    411410
     
    429428typedef PDMAUDIOHOSTENUM const *PCPDMAUDIOHOSTENUM;
    430429
    431 /** Magic for the host audio device enumeration. (Herbert Jeffrey "Herbie" Hancock) */
    432 #define PDMAUDIOHOSTENUM_MAGIC      UINT32_C(0x19400412)
     430/** Magic for the host audio device enumeration. */
     431#define PDMAUDIOHOSTENUM_MAGIC      PDM_VERSION_MAKE(0xa0d1, 1, 0)
    433432
    434433
     
    999998typedef struct PDMAUDIOMIXBUF
    1000999{
    1001     RTLISTNODE                Node;
     1000    /** Magic value (PDMAUDIOMIXBUF_MAGIC). */
     1001    uint32_t                    uMagic;
     1002    /** For quickly converting frames <-> bytes and vice versa. */
     1003    uint8_t                     cShift;
     1004    uint8_t                     abPadding[3];
     1005    /* ???Undocumented??? */
     1006    RTLISTNODE                  Node;
    10021007    /** Name of the buffer. */
    1003     char                     *pszName;
     1008    char                       *pszName;
    10041009    /** Frame buffer. */
    1005     PPDMAUDIOFRAME            pFrames;
     1010    PPDMAUDIOFRAME              pFrames;
    10061011    /** Size of the frame buffer (in audio frames). */
    1007     uint32_t                  cFrames;
     1012    uint32_t                    cFrames;
    10081013    /** The current read position (in frames). */
    1009     uint32_t                  offRead;
     1014    uint32_t                    offRead;
    10101015    /** The current write position (in frames). */
    1011     uint32_t                  offWrite;
    1012     /**
    1013      * Total frames already mixed down to the parent buffer (if any).
     1016    uint32_t                    offWrite;
     1017    /** Total frames already mixed down to the parent buffer (if any).
    10141018     *
    10151019     * Always starting at the parent's offRead position.
    10161020     * @note Count always is specified in parent frames, as the sample count can
    1017      *       differ between parent and child.
    1018      */
    1019     uint32_t                  cMixed;
     1021     *       differ between parent and child.  */
     1022    uint32_t                    cMixed;
    10201023    /** How much audio frames are currently being used
    10211024     *  in this buffer.
    10221025     *  Note: This also is known as the distance in ring buffer terms. */
    1023     uint32_t                  cUsed;
     1026    uint32_t                    cUsed;
     1027    /** Number of children mix buffers kept in lstChildren. */
     1028    uint32_t                    cChildren;
     1029    /** List of children mix buffers to keep in sync with (if being a parent buffer). */
     1030    RTLISTANCHOR                lstChildren;
    10241031    /** Pointer to parent buffer (if any). */
    1025     PPDMAUDIOMIXBUF           pParent;
    1026     /** List of children mix buffers to keep in sync with (if being a parent buffer). */
    1027     RTLISTANCHOR              lstChildren;
    1028     /** Number of children mix buffers kept in lstChildren. */
    1029     uint32_t                  cChildren;
     1032    PPDMAUDIOMIXBUF             pParent;
    10301033    /** Intermediate structure for buffer conversion tasks. */
    1031     PPDMAUDIOSTREAMRATE       pRate;
     1034    PPDMAUDIOSTREAMRATE         pRate;
    10321035    /** Internal representation of current volume used for mixing. */
    1033     PDMAUDMIXBUFVOL           Volume;
     1036    PDMAUDMIXBUFVOL             Volume;
    10341037    /** This buffer's audio format.
    10351038     * @todo r=bird: This seems to be a value created by AUDMIXBUF_AUDIO_FMT_MAKE(),
    10361039     *       which is not define here.  Does this structure really belong here at
    10371040     *       all?  */
    1038     PDMAUDIOMIXBUFFMT         uAudioFmt;
     1041    PDMAUDIOMIXBUFFMT           uAudioFmt;
    10391042    /** Standard conversion-to function for set uAudioFmt. */
    1040     PFNPDMAUDIOMIXBUFCONVTO   pfnConvTo;
     1043    PFNPDMAUDIOMIXBUFCONVTO     pfnConvTo;
    10411044    /** Standard conversion-from function for set uAudioFmt. */
    1042     PFNPDMAUDIOMIXBUFCONVFROM pfnConvFrom;
    1043     /**
    1044      * Ratio of the associated parent stream's frequency by this stream's
     1045    PFNPDMAUDIOMIXBUFCONVFROM   pfnConvFrom;
     1046    /** Ratio of the associated parent stream's frequency by this stream's
    10451047     * frequency (1<<32), represented as a signed 64 bit integer.
    10461048     *
     
    10491051     * (44/11 * (1 << 32)).
    10501052     *
    1051      * Currently this does not get changed once assigned.
    1052      */
    1053     int64_t                   iFreqRatio;
    1054     /** For quickly converting frames <-> bytes and vice versa. */
    1055     uint8_t                   cShift;
     1053     * Currently this does not get changed once assigned. */
     1054    int64_t                     iFreqRatio;
    10561055} PDMAUDIOMIXBUF;
     1056
     1057/** Magic value for PDMAUDIOMIXBUF. */
     1058#define PDMAUDIOMIXBUF_MAGIC                PDM_VERSION_MAKE(0xa0d2, 1, 0)
    10571059
    10581060/** @name PDMAUDIOFILE_FLAGS_XXX
     
    11821184        PPDMAUDIOFILE   pFileCaptureNonInterleaved;
    11831185    } Dbg;
    1184 #ifdef VBOX_WITH_STATISTICS
    11851186    struct
    11861187    {
     
    11921193        STAMCOUNTER     TotalTimesRead;
    11931194    } Stats;
    1194 #endif
    11951195} PDMAUDIOSTREAMIN;
    11961196/** Pointer to the specifics for an audio input stream. */
     
    12111211        PPDMAUDIOFILE   pFilePlayNonInterleaved;
    12121212    } Dbg;
    1213 #ifdef VBOX_WITH_STATISTICS
    12141213    struct
    12151214    {
     
    12211220        STAMCOUNTER     TotalTimesWritten;
    12221221    } Stats;
    1223 #endif
    12241222} PDMAUDIOSTREAMOUT;
    12251223/** Pointer to the specifics for an audio output stream. */
     
    13121310} PDMAUDIOSTREAM;
    13131311
    1314 /** Magic value for PDMAUDIOSTREAM. (Ahmad Jamal)   */
    1315 #define PDMAUDIOSTREAM_MAGIC    UINT32_C(0x19300702)
     1312/** Magic value for PDMAUDIOSTREAM. */
     1313#define PDMAUDIOSTREAM_MAGIC    PDM_VERSION_MAKE(0xa0d3, 1, 0)
    13161314
    13171315
     
    13961394/**
    13971395 * Host audio callback function.
     1396 *
    13981397 * This function will be called from a backend to communicate with the host audio interface.
    13991398 *
  • trunk/src/VBox/Devices/Audio/AudioMixBuffer.cpp

    r87936 r88061  
    332332    if (!pMixBuf)
    333333        return;
     334
     335    /* Ignore calls for an uninitialized (zeroed) or already destroyed instance.  Happens a lot. */
     336    if (   pMixBuf->uMagic == 0
     337        || pMixBuf->uMagic == ~PDMAUDIOMIXBUF_MAGIC)
     338    {
     339        Assert(!pMixBuf->pszName);
     340        Assert(!pMixBuf->pRate);
     341        Assert(!pMixBuf->pFrames);
     342        Assert(!pMixBuf->cFrames);
     343        return;
     344    }
     345
     346    Assert(pMixBuf->uMagic == PDMAUDIOMIXBUF_MAGIC);
     347    pMixBuf->uMagic = ~PDMAUDIOMIXBUF_MAGIC;
    334348
    335349    AudioMixBufUnlink(pMixBuf);
     
    816830    AssertPtrReturn(pProps,  VERR_INVALID_POINTER);
    817831
     832    pMixBuf->uMagic  = PDMAUDIOMIXBUF_MAGIC;
    818833    pMixBuf->pParent = NULL;
    819834
  • trunk/src/VBox/Devices/Audio/DrvAudio.cpp

    r88060 r88061  
    553553 * @param   pCfgGuest           Stream configuration to use for the guest side.
    554554 */
    555 static int drvAudioStreamInitInternal(PDRVAUDIO pThis,
    556                                       PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgHost, PPDMAUDIOSTREAMCFG pCfgGuest)
     555static int drvAudioStreamInitInternal(PDRVAUDIO pThis, PPDMAUDIOSTREAM pStream,
     556                                      PPDMAUDIOSTREAMCFG pCfgHost, PPDMAUDIOSTREAMCFG pCfgGuest)
    557557{
    558558    AssertPtrReturn(pThis,     VERR_INVALID_POINTER);
     
    767767        LogFunc(("[%s]\n", pStream->szName));
    768768        Assert(pStream->uMagic == PDMAUDIOSTREAM_MAGIC);
    769         pStream->uMagic = ~PDMAUDIOSTREAM_MAGIC;
    770 
    771         if (pStream->pvBackend)
    772         {
    773             Assert(pStream->cbBackend);
    774             RTMemFree(pStream->pvBackend);
    775             pStream->pvBackend = NULL;
    776         }
     769
     770        pStream->uMagic    = ~PDMAUDIOSTREAM_MAGIC;
     771        pStream->pvBackend = NULL;
    777772
    778773        RTMemFree(pStream);
     
    26052600         * Allocate and initialize common state.
    26062601         */
    2607         pStream = (PPDMAUDIOSTREAM)RTMemAllocZ(sizeof(PDMAUDIOSTREAM));
     2602        pStream = (PPDMAUDIOSTREAM)RTMemAllocZ(sizeof(PDMAUDIOSTREAM) + RT_ALIGN_Z(cbHstStrm, 64));
    26082603        AssertPtrBreakStmt(pStream, rc = VERR_NO_MEMORY);
    26092604
     
    26192614                    pCfgHost->szName[0] != '\0' ? pCfgHost->szName : "<Untitled>");
    26202615
    2621         pStream->enmDir = pCfgHost->enmDir;
    2622 
    2623         /*
    2624          * Allocate and init backend-specific data.
    2625          */
    2626         if (cbHstStrm) /* High unlikely that backends do not have an own space for data, but better check. */
    2627         {
    2628             pStream->pvBackend = RTMemAllocZ(cbHstStrm);
    2629             AssertBreakStmt(pStream->pvBackend, rc = VERR_NO_MEMORY);
    2630 
    2631             pStream->cbBackend = (uint32_t)cbHstStrm;
    2632         }
     2616        pStream->enmDir    = pCfgHost->enmDir;
     2617        pStream->cbBackend = (uint32_t)cbHstStrm;
     2618        if (cbHstStrm)
     2619            pStream->pvBackend = pStream + 1;
    26332620
    26342621        /*
  • trunk/src/VBox/Devices/Audio/DrvHostCoreAudio.cpp

    r88055 r88061  
    101101    RTCRITSECT              CritSect;
    102102    /** Current (last reported) device enumeration. */
    103     PDMAUDIOHOSTENUM      Devices;
     103    PDMAUDIOHOSTENUM        Devices;
    104104    /** Pointer to the currently used input device in the device enumeration.
    105105     *  Can be NULL if none assigned. */
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