VirtualBox

Changeset 58372 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Oct 22, 2015 10:48:08 AM (9 years ago)
Author:
vboxsync
Message:

DrvHostNullAudio.cpp: Cleanup.

File:
1 edited

Legend:

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

    r57827 r58372  
    5555{
    5656    /** Note: Always must come first! */
    57     PDMAUDIOHSTSTRMOUT hw;
    58     uint64_t u64TicksLast;
    59     uint64_t csPlayBuffer;
    60     uint8_t *pu8PlayBuffer;
    61 } NULLAUDIOSTREAMOUT;
     57    PDMAUDIOHSTSTRMOUT streamOut;
     58    uint64_t           u64TicksLast;
     59    uint64_t           csPlayBuffer;
     60    uint8_t           *pu8PlayBuffer;
     61} NULLAUDIOSTREAMOUT, *PNULLAUDIOSTREAMOUT;
    6262
    6363typedef struct NULLAUDIOSTREAMIN
    6464{
    6565    /** Note: Always must come first! */
    66     PDMAUDIOHSTSTRMIN hw;
    67 } NULLAUDIOSTREAMIN;
     66    PDMAUDIOHSTSTRMIN  streamIn;
     67} NULLAUDIOSTREAMIN, *PNULLAUDIOSTREAMIN;
    6868
    6969/**
     
    132132    if (RT_SUCCESS(rc))
    133133    {
    134         NULLAUDIOSTREAMOUT *pNullStrmOut = (NULLAUDIOSTREAMOUT *)pHstStrmOut;
    135         pNullStrmOut->u64TicksLast = 0;
    136         pNullStrmOut->csPlayBuffer = _1K;
     134        PNULLAUDIOSTREAMOUT pNullStrmOut = (PNULLAUDIOSTREAMOUT)pHstStrmOut;
     135        pNullStrmOut->u64TicksLast  = 0;
     136        pNullStrmOut->csPlayBuffer  = _1K;
    137137        pNullStrmOut->pu8PlayBuffer = (uint8_t *)RTMemAlloc(_1K << pHstStrmOut->Props.cShift);
    138138        if (pNullStrmOut->pu8PlayBuffer)
     
    161161{
    162162    PDRVHOSTNULLAUDIO pDrv = RT_FROM_MEMBER(pInterface, DRVHOSTNULLAUDIO, IHostAudio);
    163     NULLAUDIOSTREAMOUT *pNullStrmOut = (NULLAUDIOSTREAMOUT *)pHstStrmOut;
     163    PNULLAUDIOSTREAMOUT pNullStrmOut = (PNULLAUDIOSTREAMOUT)pHstStrmOut;
    164164
    165165    /* Consume as many samples as would be played at the current frequency since last call. */
    166     uint32_t csLive = drvAudioHstOutSamplesLive(pHstStrmOut);
    167     uint64_t u64TicksNow = PDMDrvHlpTMGetVirtualTime(pDrv->pDrvIns);
     166    uint32_t csLive          = drvAudioHstOutSamplesLive(pHstStrmOut);
     167    uint64_t u64TicksNow     = PDMDrvHlpTMGetVirtualTime(pDrv->pDrvIns);
    168168    uint64_t u64TicksElapsed = u64TicksNow  - pNullStrmOut->u64TicksLast;
    169     uint64_t u64TicksFreq = PDMDrvHlpTMGetVirtualFreq(pDrv->pDrvIns);
     169    uint64_t u64TicksFreq    = PDMDrvHlpTMGetVirtualFreq(pDrv->pDrvIns);
    170170
    171171    /* Remember when samples were consumed. */
    172172    pNullStrmOut->u64TicksLast = u64TicksNow;
    173173
    174     /* Minimize the rounding error by adding 0.5: samples = int((u64TicksElapsed * samplesFreq) / u64TicksFreq + 0.5).
     174    /*
     175     * Minimize the rounding error by adding 0.5: samples = int((u64TicksElapsed * samplesFreq) / u64TicksFreq + 0.5).
    175176     * If rounding is not taken into account then the playback rate will be consistently lower that expected.
    176177     */
     
    230231static DECLCALLBACK(int) drvHostNullAudioFiniOut(PPDMIHOSTAUDIO pInterface, PPDMAUDIOHSTSTRMOUT pHstStrmOut)
    231232{
    232     NULLAUDIOSTREAMOUT *pNullStrmOut = (NULLAUDIOSTREAMOUT *)pHstStrmOut;
    233     RTMemFree(pNullStrmOut->pu8PlayBuffer);
     233    PNULLAUDIOSTREAMOUT pNullStrmOut = (PNULLAUDIOSTREAMOUT)pHstStrmOut;
     234    if (   pNullStrmOut
     235        && pNullStrmOut->pu8PlayBuffer)
     236    {
     237        RTMemFree(pNullStrmOut->pu8PlayBuffer);
     238    }
    234239    return VINF_SUCCESS;
    235240}
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