VirtualBox

Changeset 68393 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Aug 11, 2017 12:41:23 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
117525
Message:

Main/DrvAudioVRDE: Renaming.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/DrvAudioVRDE.cpp

    r68391 r68393  
    7171            /** Number of audio frames this stream can handle at once. */
    7272            uint32_t    cfMax;
    73             /** Circular buffer for holding the recorded audio samples from the host. */
     73            /** Circular buffer for holding the recorded audio frames from the host. */
    7474            PRTCIRCBUF  pCircBuf;
    7575        } In;
     
    7878            /** Timestamp (in virtual time ticks) of the last audio playback (of the VRDP server). */
    7979            uint64_t    ticksPlayedLast;
    80             /** Internal counter (in audio samples) to track if and how much we can write to the VRDP server
     80            /** Internal counter (in audio frames) to track if and how much we can write to the VRDP server
    8181             *  for the current time period. */
    82             uint64_t    csToWrite;
     82            uint64_t    cfToWrite;
    8383        } Out;
    8484    };
     
    269269        return VERR_NOT_AVAILABLE;
    270270
    271     /* Note: We get the number of *samples* in cbBuf
     271    /* Note: We get the number of *frames* in cxBuf
    272272     *       (since we specified PDMAUDIOSTREAMLAYOUT_RAW as the audio data layout) on stream creation. */
    273     uint32_t csLive           = cxBuf;
     273    uint32_t cfLive           = cxBuf;
    274274
    275275    PPDMAUDIOPCMPROPS pProps  = &pStreamVRDE->pCfg->Props;
     
    282282    /* Use the internal counter to track if we (still) can write to the VRDP server
    283283     * or if we need to wait another round (time slot). */
    284     uint32_t csToWrite = pStreamVRDE->Out.csToWrite;
    285 
    286     Log3Func(("csLive=%RU32, csToWrite=%RU32\n", csLive, csToWrite));
     284    uint32_t cfToWrite = pStreamVRDE->Out.cfToWrite;
     285
     286    Log3Func(("cfLive=%RU32, cfToWrite=%RU32\n", cfLive, cfToWrite));
    287287
    288288    /* Don't play more than available. */
    289     if (csToWrite > csLive)
    290         csToWrite = csLive;
     289    if (cfToWrite > cfLive)
     290        cfToWrite = cfLive;
    291291
    292292    int rc = VINF_SUCCESS;
     
    298298     * Call the VRDP server with the data.
    299299     */
    300     uint32_t csWritten = 0;
    301     while (csToWrite)
    302     {
    303         uint32_t csChunk = csToWrite; /** @todo For now write all at once. */
    304 
    305         if (!csChunk) /* Nothing to send. Bail out. */
     300    uint32_t cfWritten = 0;
     301    while (cfToWrite)
     302    {
     303        uint32_t cfChunk = cfToWrite; /** @todo For now write all at once. */
     304
     305        if (!cfChunk) /* Nothing to send. Bail out. */
    306306            break;
    307307
    308308        /* Note: The VRDP server expects int64_t samples per channel, regardless of the actual
    309309         *       sample bits (e.g 8 or 16 bits). */
    310         pDrv->pConsoleVRDPServer->SendAudioSamples(paSampleBuf + csWritten, csChunk /* Samples */, format);
    311 
    312         csWritten += csChunk;
    313         Assert(csWritten <= csLive);
    314 
    315         Assert(csToWrite >= csChunk);
    316         csToWrite -= csChunk;
     310        pDrv->pConsoleVRDPServer->SendAudioSamples(paSampleBuf + cfWritten, cfChunk /* Frames */, format);
     311
     312        cfWritten += cfChunk;
     313        Assert(cfWritten <= cfLive);
     314
     315        Assert(cfToWrite >= cfChunk);
     316        cfToWrite -= cfChunk;
    317317    }
    318318
    319319    if (RT_SUCCESS(rc))
    320320    {
    321         /* Subtract written samples from the counter. */
    322         Assert(pStreamVRDE->Out.csToWrite >= csWritten);
    323         pStreamVRDE->Out.csToWrite      -= csWritten;
    324 
    325         /* Remember when samples were consumed. */
     321        /* Subtract written frames from the counter. */
     322        Assert(pStreamVRDE->Out.cfToWrite >= cfWritten);
     323        pStreamVRDE->Out.cfToWrite      -= cfWritten;
     324
     325        /* Remember when frames were consumed. */
    326326        pStreamVRDE->Out.ticksPlayedLast = PDMDrvHlpTMGetVirtualTime(pDrv->pDrvIns);
    327327
    328         /* Return samples instead of bytes here
     328        /* Return frames instead of bytes here
    329329         * (since we specified PDMAUDIOSTREAMLAYOUT_RAW as the audio data layout). */
    330330        if (pcxWritten)
    331             *pcxWritten = csWritten;
     331            *pcxWritten = cfWritten;
    332332    }
    333333
     
    499499    if (pStreamVRDE->pCfg->enmDir == PDMAUDIODIR_IN)
    500500    {
    501         /* Return samples instead of bytes here
     501        /* Return frames instead of bytes here
    502502         * (since we specified PDMAUDIOSTREAMLAYOUT_RAW as the audio data layout). */
    503503        return (uint32_t)PDMAUDIOSTREAMCFG_B2F(pStreamVRDE->pCfg, RTCircBufUsed(pStreamVRDE->In.pCircBuf));
     
    522522    PPDMAUDIOPCMPROPS pProps  = &pStreamVRDE->pCfg->Props;
    523523
    524     /* Minimize the rounding error: samples = int((ticks * freq) / ticks_per_second + 0.5). */
    525     pStreamVRDE->Out.csToWrite = (int)((2 * ticksElapsed * pProps->uHz + ticksPerSec) / ticksPerSec / 2);
    526 
    527     /* Return samples instead of bytes here
     524    /* Minimize the rounding error: frames = int((ticks * freq) / ticks_per_second + 0.5). */
     525    pStreamVRDE->Out.cfToWrite = (int)((2 * ticksElapsed * pProps->uHz + ticksPerSec) / ticksPerSec / 2);
     526
     527    /* Return frames instead of bytes here
    528528     * (since we specified PDMAUDIOSTREAMLAYOUT_RAW as the audio data layout). */
    529     return pStreamVRDE->Out.csToWrite;
     529    return pStreamVRDE->Out.cfToWrite;
    530530}
    531531
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