VirtualBox

Changeset 82254 in vbox for trunk/src/VBox/Main/src-client


Ignore:
Timestamp:
Nov 27, 2019 10:09:17 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
135072
Message:

vmm/pdmaudioifs.h: The prefix 'cf' reads 'count-of-flags', so if you want 'count-of-frames' in a non-confusing way you have to spell it out. The prefix 'cx' means 'count-of-x-coordinates', i.e. width in pixels, and is not in any way suited to combine 'cb' and 'cFrames' in this context (PDM). bugref:9218

Location:
trunk/src/VBox/Main/src-client
Files:
2 edited

Legend:

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

    r82252 r82254  
    554554
    555555                    /* Every Opus frame marks a period for now. Optimize this later. */
    556                     pCfgAcq->Backend.cfPeriod     = DrvAudioHlpMilliToFrames(pSink->Codec.Opus.msFrame, &pCfgAcq->Props);
    557                     pCfgAcq->Backend.cfBufferSize = DrvAudioHlpMilliToFrames(100 /* ms */, &pCfgAcq->Props); /** @todo Make this configurable. */
    558                     pCfgAcq->Backend.cfPreBuf     = pCfgAcq->Backend.cfPeriod * 2;
     556                    pCfgAcq->Backend.cFramesPeriod     = DrvAudioHlpMilliToFrames(pSink->Codec.Opus.msFrame, &pCfgAcq->Props);
     557                    pCfgAcq->Backend.cFramesBufferSize = DrvAudioHlpMilliToFrames(100 /* ms */, &pCfgAcq->Props); /** @todo Make this configurable. */
     558                    pCfgAcq->Backend.cFramesPreBuffering     = pCfgAcq->Backend.cFramesPeriod * 2;
    559559                }
    560560            }
     
    675675 */
    676676static DECLCALLBACK(int) drvAudioVideoRecStreamCapture(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,
    677                                                        void *pvBuf, uint32_t cxBuf, uint32_t *pcxRead)
    678 {
    679     RT_NOREF(pInterface, pStream, pvBuf, cxBuf);
    680 
    681     if (pcxRead)
    682         *pcxRead = 0;
     677                                                       void *pvBuf, uint32_t uBufSize, uint32_t *puRead)
     678{
     679    RT_NOREF(pInterface, pStream, pvBuf, uBufSize);
     680
     681    if (puRead)
     682        *puRead = 0;
    683683
    684684    return VINF_SUCCESS;
     
    690690 */
    691691static DECLCALLBACK(int) drvAudioVideoRecStreamPlay(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,
    692                                                     const void *pvBuf, uint32_t cxBuf, uint32_t *pcxWritten)
     692                                                    const void *pvBuf, uint32_t uBufSize, uint32_t *puWritten)
    693693{
    694694    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
    695695    AssertPtrReturn(pStream,    VERR_INVALID_POINTER);
    696696    AssertPtrReturn(pvBuf,      VERR_INVALID_POINTER);
    697     AssertReturn(cxBuf,         VERR_INVALID_PARAMETER);
    698     /* pcxWritten is optional. */
     697    AssertReturn(uBufSize,         VERR_INVALID_PARAMETER);
     698    /* puWritten is optional. */
    699699
    700700    PDRVAUDIORECORDING pThis     = PDMIHOSTAUDIO_2_DRVAUDIORECORDING(pInterface);
     
    720720    size_t cbCircBuf;
    721721
    722     uint32_t cbToWrite = cxBuf;
     722    uint32_t cbToWrite = uBufSize;
    723723
    724724    /*
     
    858858    }
    859859
    860     if (pcxWritten)
    861         *pcxWritten = cbWrittenTotal;
     860    if (puWritten)
     861        *puWritten = cbWrittenTotal;
    862862#else
    863863    /* Report back all data as being processed. */
    864     if (pcxWritten)
    865         *pcxWritten = cxBuf;
     864    if (puWritten)
     865        *puWritten = uBufSize;
    866866
    867867    rc = VERR_NOT_SUPPORTED;
  • trunk/src/VBox/Main/src-client/DrvAudioVRDE.cpp

    r82252 r82254  
    9393
    9494    /* According to the VRDP docs, the VRDP server stores audio in 200ms chunks. */
    95     const uint32_t cfVRDPServer = DrvAudioHlpMilliToFrames(200  /* ms */, &pCfgAcq->Props);
    96 
    97     int rc = RTCircBufCreate(&pStreamVRDE->In.pCircBuf, DrvAudioHlpFramesToBytes(cfVRDPServer, &pCfgAcq->Props));
     95    const uint32_t cFramesVrdpServer = DrvAudioHlpMilliToFrames(200  /* ms */, &pCfgAcq->Props);
     96
     97    int rc = RTCircBufCreate(&pStreamVRDE->In.pCircBuf, DrvAudioHlpFramesToBytes(cFramesVrdpServer, &pCfgAcq->Props));
    9898    if (RT_SUCCESS(rc))
    9999    {
     
    105105         * the data without any layout modification needed.
    106106         */
    107         pCfgAcq->enmLayout        = PDMAUDIOSTREAMLAYOUT_RAW;
    108 
    109         pCfgAcq->Backend.cfPeriod     = cfVRDPServer;
    110         pCfgAcq->Backend.cfBufferSize = pCfgAcq->Backend.cfPeriod * 2; /* Use "double buffering". */
    111         pCfgAcq->Backend.cfPreBuf     = pCfgAcq->Backend.cfPeriod;
     107        pCfgAcq->enmLayout                      = PDMAUDIOSTREAMLAYOUT_RAW;
     108        pCfgAcq->Backend.cFramesPeriod          = cFramesVrdpServer;
     109        pCfgAcq->Backend.cFramesBufferSize      = pCfgAcq->Backend.cFramesPeriod * 2; /* Use "double buffering". */
     110        pCfgAcq->Backend.cFramesPreBuffering    = pCfgAcq->Backend.cFramesPeriod;
    112111    }
    113112
     
    138137
    139138        /* According to the VRDP docs, the VRDP server stores audio in 200ms chunks. */
    140         pCfgAcq->Backend.cfPeriod     = DrvAudioHlpMilliToFrames(20  /* ms */, &pCfgAcq->Props);
    141         pCfgAcq->Backend.cfBufferSize = DrvAudioHlpMilliToFrames(100 /* ms */, &pCfgAcq->Props);
    142         pCfgAcq->Backend.cfPreBuf     = pCfgAcq->Backend.cfPeriod * 2;
     139        pCfgAcq->Backend.cFramesPeriod     = DrvAudioHlpMilliToFrames(20  /* ms */, &pCfgAcq->Props);
     140        pCfgAcq->Backend.cFramesBufferSize = DrvAudioHlpMilliToFrames(100 /* ms */, &pCfgAcq->Props);
     141        pCfgAcq->Backend.cFramesPreBuffering     = pCfgAcq->Backend.cFramesPeriod * 2;
    143142    }
    144143
     
    233232 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCapture}
    234233 */
    235 static DECLCALLBACK(int) drvAudioVRDEStreamCapture(PPDMIHOSTAUDIO pInterface,
    236                                                    PPDMAUDIOBACKENDSTREAM pStream, void *pvBuf, uint32_t cxBuf, uint32_t *pcxRead)
     234static DECLCALLBACK(int) drvAudioVRDEStreamCapture(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,
     235                                                   void *pvBuf, uint32_t uBufSize, uint32_t *puRead)
    237236{
    238237    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
    239238    AssertPtrReturn(pStream,    VERR_INVALID_POINTER);
    240239    AssertPtrReturn(pvBuf,      VERR_INVALID_POINTER);
    241     AssertReturn(cxBuf,         VERR_INVALID_PARAMETER);
    242     /* pcxRead is optional. */
     240    AssertReturn(uBufSize,         VERR_INVALID_PARAMETER);
     241    /* puRead is optional. */
    243242
    244243    PVRDESTREAM pStreamVRDE = (PVRDESTREAM)pStream;
     
    250249        void *pvData;
    251250
    252         RTCircBufAcquireReadBlock(pStreamVRDE->In.pCircBuf, cxBuf, &pvData, &cbData);
     251        RTCircBufAcquireReadBlock(pStreamVRDE->In.pCircBuf, uBufSize, &pvData, &cbData);
    253252
    254253        if (cbData)
     
    258257    }
    259258
    260     if (pcxRead)
    261         *pcxRead = (uint32_t)cbData;
     259    if (puRead)
     260        *puRead = (uint32_t)cbData;
    262261
    263262    return VINF_SUCCESS;
     
    269268 */
    270269static DECLCALLBACK(int) drvAudioVRDEStreamPlay(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,
    271                                                 const void *pvBuf, uint32_t cxBuf, uint32_t *pcxWritten)
     270                                                const void *pvBuf, uint32_t uBufSize, uint32_t *puWritten)
    272271{
    273272    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
    274273    AssertPtrReturn(pStream,    VERR_INVALID_POINTER);
    275274    AssertPtrReturn(pvBuf,      VERR_INVALID_POINTER);
    276     AssertReturn(cxBuf,         VERR_INVALID_PARAMETER);
    277     /* pcxWritten is optional. */
     275    AssertReturn(uBufSize,         VERR_INVALID_PARAMETER);
     276    /* puWritten is optional. */
    278277
    279278    PDRVAUDIOVRDE pDrv        = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio);
     
    283282        return VERR_NOT_AVAILABLE;
    284283
    285     /* Note: We get the number of *frames* in cxBuf
     284    /* Note: We get the number of *frames* in uBufSize
    286285     *       (since we specified PDMAUDIOSTREAMLAYOUT_RAW as the audio data layout) on stream creation. */
    287     uint32_t cfLive           = cxBuf;
    288 
    289     PPDMAUDIOPCMPROPS pProps  = &pStreamVRDE->pCfg->Props;
     286    uint32_t cFramesLive = uBufSize;
     287
     288    PPDMAUDIOPCMPROPS pProps = &pStreamVRDE->pCfg->Props;
    290289
    291290    VRDEAUDIOFORMAT format = VRDE_AUDIO_FMT_MAKE(pProps->uHz,
     
    296295    /* Use the internal counter to track if we (still) can write to the VRDP server
    297296     * or if we need to wait another round (time slot). */
    298     uint32_t cfToWrite = cfLive;
    299 
    300     Log3Func(("cfLive=%RU32, cfToWrite=%RU32\n", cfLive, cfToWrite));
     297    uint32_t cFramesToWrite = cFramesLive;
     298
     299    Log3Func(("cFramesLive=%RU32, cFramesToWrite=%RU32\n", cFramesLive, cFramesToWrite));
    301300
    302301    /* Don't play more than available. */
    303     if (cfToWrite > cfLive)
    304         cfToWrite = cfLive;
     302    if (cFramesToWrite > cFramesLive)
     303        cFramesToWrite = cFramesLive;
    305304
    306305    int rc = VINF_SUCCESS;
     
    313312     */
    314313    uint32_t cfWritten = 0;
    315     while (cfToWrite)
    316     {
    317         uint32_t cfChunk = cfToWrite; /** @todo For now write all at once. */
     314    while (cFramesToWrite)
     315    {
     316        uint32_t cfChunk = cFramesToWrite; /** @todo For now write all at once. */
    318317
    319318        if (!cfChunk) /* Nothing to send. Bail out. */
     
    325324
    326325        cfWritten += cfChunk;
    327         Assert(cfWritten <= cfLive);
    328 
    329         Assert(cfToWrite >= cfChunk);
    330         cfToWrite -= cfChunk;
     326        Assert(cfWritten <= cFramesLive);
     327
     328        Assert(cFramesToWrite >= cfChunk);
     329        cFramesToWrite -= cfChunk;
    331330    }
    332331
     
    335334        /* Return frames instead of bytes here
    336335         * (since we specified PDMAUDIOSTREAMLAYOUT_RAW as the audio data layout). */
    337         if (pcxWritten)
    338             *pcxWritten = cfWritten;
     336        if (puWritten)
     337            *puWritten = cfWritten;
    339338    }
    340339
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