VirtualBox

忽略:
時間撮記:
2016-8-12 下午01:58:38 (9 年 以前)
作者:
vboxsync
svn:sync-xref-src-repo-rev:
110001
訊息:

Audio: Added more defines / documentation for the host interfaces to keep the maintenance effort to a minimum in the future, misc. cleanup.

檔案:
修改 1 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Main/src-client/DrvAudioVRDE.cpp

    r63244 r63360  
    8585
    8686
     87
    8788static int vrdeCreateStreamIn(PPDMIHOSTAUDIO pInterface,
    88                               PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples)
    89 {
    90     PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio);
    91     AssertPtrReturn(pDrv, VERR_INVALID_POINTER);
    92 
     89                              PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq)
     90{
     91    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
     92    AssertPtrReturn(pStream,    VERR_INVALID_POINTER);
     93    AssertPtrReturn(pCfgReq,    VERR_INVALID_POINTER);
     94    AssertPtrReturn(pCfgAcq,    VERR_INVALID_POINTER);
     95
     96    PDRVAUDIOVRDE pDrv        = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio);
    9397    PVRDESTREAMIN pVRDEStrmIn = (PVRDESTREAMIN)pStream;
    94     AssertPtrReturn(pVRDEStrmIn, VERR_INVALID_POINTER);
    95 
    96     if (pcSamples)
    97         *pcSamples = _4K; /** @todo Make this configurable. */
    98 
    99     return DrvAudioHlpStreamCfgToProps(pCfg, &pVRDEStrmIn->Stream.Props);
    100 }
     98
     99    if (pCfgAcq)
     100        pCfgAcq->cSamples = _4K; /** @todo Make this configurable. */
     101
     102    LogFlowFuncLeaveRC(VINF_SUCCESS);
     103    return VINF_SUCCESS;
     104}
     105
    101106
    102107static int vrdeCreateStreamOut(PPDMIHOSTAUDIO pInterface,
    103                                PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples)
    104 {
    105     PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio);
    106     AssertPtrReturn(pDrv, VERR_INVALID_POINTER);
    107 
    108     LogFlowFunc(("pStream=%p, pCfg=%p\n", pStream, pCfg));
    109 
     108                               PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq)
     109{
     110    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
     111    AssertPtrReturn(pStream,    VERR_INVALID_POINTER);
     112    AssertPtrReturn(pCfgReq,    VERR_INVALID_POINTER);
     113    AssertPtrReturn(pCfgAcq,    VERR_INVALID_POINTER);
     114
     115    PDRVAUDIOVRDE  pDrv         = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio);
    110116    PVRDESTREAMOUT pVRDEStrmOut = (PVRDESTREAMOUT)pStream;
    111     AssertPtrReturn(pVRDEStrmOut, VERR_INVALID_POINTER);
    112 
    113     if (pcSamples)
    114         *pcSamples = _4K; /** @todo Make this configurable. */
    115 
    116     return DrvAudioHlpStreamCfgToProps(pCfg, &pVRDEStrmOut->Stream.Props);
    117 }
     117
     118    if (pCfgAcq)
     119        pCfgAcq->cSamples = _4K; /** @todo Make this configurable. */
     120
     121    LogFlowFuncLeaveRC(VINF_SUCCESS);
     122    return VINF_SUCCESS;
     123}
     124
    118125
    119126static int vrdeControlStreamOut(PPDMIHOSTAUDIO pInterface,
     
    133140    return VINF_SUCCESS;
    134141}
     142
    135143
    136144static int vrdeControlStreamIn(PPDMIHOSTAUDIO pInterface,
     
    174182}
    175183
    176 static DECLCALLBACK(int) drvAudioVRDEInit(PPDMIHOSTAUDIO pInterface)
     184
     185/**
     186 * @interface_method_impl{PDMIHOSTAUDIO,pfnInit}
     187 */
     188PDMAUDIO_IHOSTAUDIO_EMIT_INIT(drvAudioVRDE)
    177189{
    178190    RT_NOREF(pInterface);
     
    182194}
    183195
    184 /**
    185  * {FIXME - Missing brief description - FIXME}
    186  *
    187  * Transfers audio input formerly sent by a connected RDP client / VRDE backend
    188  * (using the onVRDEInputXXX methods) over to the VRDE host (VM). The audio device
    189  * emulation then will read and send the data to the guest.
    190  *
    191  * @return  IPRT status code.
    192  * @param   pInterface
    193  * @param   pStream
    194  * @param   pcSamplesCaptured
    195  */
    196 static DECLCALLBACK(int) drvAudioVRDEStreamCapture(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream,
    197                                                    uint32_t *pcSamplesCaptured)
     196
     197/**
     198 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCapture}
     199 */
     200PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCAPTURE(drvAudioVRDE)
    198201{
    199202    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
    200     AssertPtrReturn(pStream, VERR_INVALID_POINTER);
    201     AssertPtrReturn(pcSamplesCaptured, VERR_INVALID_POINTER);
    202 
    203     PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio);
    204     AssertPtrReturn(pDrv, VERR_INVALID_POINTER);
    205 
     203    AssertPtrReturn(pStream,    VERR_INVALID_POINTER);
     204    /* pcbRead is optional. */
     205
     206    PDRVAUDIOVRDE pDrv        = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio);
    206207    PVRDESTREAMIN pVRDEStrmIn = (PVRDESTREAMIN)pStream;
    207     AssertPtrReturn(pVRDEStrmIn, VERR_INVALID_POINTER);
    208208
    209209    /** @todo Use CritSect! */
     
    222222    if (RT_SUCCESS(rc))
    223223    {
    224         *pcSamplesCaptured = cProcessed;
    225 
    226224        Assert(pVRDEStrmIn->cSamplesCaptured >= cProcessed);
    227225        pVRDEStrmIn->cSamplesCaptured -= cProcessed;
     226
     227        if (pcbRead)
     228            *pcbRead = cProcessed;
    228229    }
    229230
     
    232233}
    233234
    234 /**
    235  * Transfers VM audio output to remote client.
    236  *
    237  * Transfers VM audio output over to the VRDE instance for playing remotely
    238  * on the client.
    239  *
    240  * @return  IPRT status code.
    241  * @param   pInterface
    242  * @param   pStream
    243  * @param   pcSamplesPlayed
    244  */
    245 static DECLCALLBACK(int) drvAudioVRDEStreamPlay(PPDMIHOSTAUDIO pInterface,
    246                                                 PPDMAUDIOSTREAM pStream, uint32_t *pcSamplesPlayed)
     235
     236/**
     237 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamPlay}
     238 */
     239PDMAUDIO_IHOSTAUDIO_EMIT_STREAMPLAY(drvAudioVRDE)
    247240{
    248241    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
    249242    AssertPtrReturn(pStream,    VERR_INVALID_POINTER);
    250     /* pcSamplesPlayed is optional. */
    251 
    252     PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio);
    253     AssertPtrReturn(pDrv, VERR_INVALID_POINTER);
    254 
     243    /* pcbWritten is optional. */
     244
     245    PDRVAUDIOVRDE  pDrv         = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio);
    255246    PVRDESTREAMOUT pVRDEStrmOut = (PVRDESTREAMOUT)pStream;
    256     AssertPtrReturn(pVRDEStrmOut, VERR_INVALID_POINTER);
    257247
    258248    uint32_t cLive = AudioMixBufLive(&pStream->MixBuf);
     
    316306     * VRDP server actually did process those.
    317307     */
    318     if (pcSamplesPlayed)
    319         *pcSamplesPlayed = cReadTotal;
     308    if (pcbWritten)
     309        *pcbWritten = cReadTotal;
    320310
    321311    LogFlowFunc(("cReadTotal=%RU32, rc=%Rrc\n", cReadTotal, rc));
    322312    return rc;
    323313}
     314
    324315
    325316static int vrdeDestroyStreamIn(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
     
    335326}
    336327
     328
    337329static int vrdeDestroyStreamOut(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
    338330{
     
    344336}
    345337
    346 static DECLCALLBACK(int) drvAudioVRDEGetConfig(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDCFG pCfg)
     338
     339/**
     340 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetConfig}
     341 */
     342PDMAUDIO_IHOSTAUDIO_EMIT_GETCONFIG(drvAudioVRDE)
    347343{
    348344    NOREF(pInterface);
    349     AssertPtrReturn(pCfg, VERR_INVALID_POINTER);
    350 
    351     pCfg->cbStreamOut    = sizeof(VRDESTREAMOUT);
    352     pCfg->cbStreamIn     = sizeof(VRDESTREAMIN);
    353     pCfg->cMaxStreamsIn  = UINT32_MAX;
    354     pCfg->cMaxStreamsOut = UINT32_MAX;
    355     pCfg->cSources       = 1;
    356     pCfg->cSinks         = 1;
    357 
    358     return VINF_SUCCESS;
    359 }
    360 
    361 static DECLCALLBACK(void) drvAudioVRDEShutdown(PPDMIHOSTAUDIO pInterface)
     345    AssertPtrReturn(pBackendCfg, VERR_INVALID_POINTER);
     346
     347    pBackendCfg->cbStreamOut    = sizeof(VRDESTREAMOUT);
     348    pBackendCfg->cbStreamIn     = sizeof(VRDESTREAMIN);
     349    pBackendCfg->cMaxStreamsIn  = UINT32_MAX;
     350    pBackendCfg->cMaxStreamsOut = UINT32_MAX;
     351    pBackendCfg->cSources       = 1;
     352    pBackendCfg->cSinks         = 1;
     353
     354    return VINF_SUCCESS;
     355}
     356
     357
     358/**
     359 * @interface_method_impl{PDMIHOSTAUDIO,pfnShutdown}
     360 */
     361PDMAUDIO_IHOSTAUDIO_EMIT_SHUTDOWN(drvAudioVRDE)
    362362{
    363363    PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio);
     
    368368}
    369369
    370 static DECLCALLBACK(PDMAUDIOBACKENDSTS) drvAudioVRDEGetStatus(PPDMIHOSTAUDIO pInterface, PDMAUDIODIR enmDir)
     370
     371/**
     372 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetStatus}
     373 */
     374PDMAUDIO_IHOSTAUDIO_EMIT_GETSTATUS(drvAudioVRDE)
    371375{
    372376    RT_NOREF(enmDir);
     
    376380}
    377381
    378 static DECLCALLBACK(int) drvAudioVRDEStreamCreate(PPDMIHOSTAUDIO pInterface,
    379                                                   PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples)
     382
     383/**
     384 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCreate}
     385 */
     386PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCREATE(drvAudioVRDE)
    380387{
    381388    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
    382389    AssertPtrReturn(pStream,    VERR_INVALID_POINTER);
    383     AssertPtrReturn(pCfg,       VERR_INVALID_POINTER);
     390    AssertPtrReturn(pCfgReq,    VERR_INVALID_POINTER);
     391    AssertPtrReturn(pCfgAcq,    VERR_INVALID_POINTER);
    384392
    385393    int rc;
    386     if (pCfg->enmDir == PDMAUDIODIR_IN)
    387         rc = vrdeCreateStreamIn(pInterface,  pStream, pCfg, pcSamples);
     394    if (pCfgReq->enmDir == PDMAUDIODIR_IN)
     395        rc = vrdeCreateStreamIn(pInterface,  pStream, pCfgReq, pCfgAcq);
    388396    else
    389         rc = vrdeCreateStreamOut(pInterface, pStream, pCfg, pcSamples);
    390 
    391     LogFlowFunc(("%s: rc=%Rrc\n", pStream->szName, rc));
     397        rc = vrdeCreateStreamOut(pInterface, pStream, pCfgReq, pCfgAcq);
     398
    392399    return rc;
    393400}
    394401
    395 static DECLCALLBACK(int) drvAudioVRDEStreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
     402
     403/**
     404 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamDestroy}
     405 */
     406PDMAUDIO_IHOSTAUDIO_EMIT_STREAMDESTROY(drvAudioVRDE)
    396407{
    397408    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
     
    407418}
    408419
    409 static DECLCALLBACK(int) drvAudioVRDEStreamControl(PPDMIHOSTAUDIO pInterface,
    410                                                    PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd)
     420
     421/**
     422 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamControl}
     423 */
     424PDMAUDIO_IHOSTAUDIO_EMIT_STREAMCONTROL(drvAudioVRDE)
    411425{
    412426    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
     
    424438}
    425439
    426 static DECLCALLBACK(PDMAUDIOSTRMSTS) drvAudioVRDEStreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
     440
     441/**
     442 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus}
     443 */
     444PDMAUDIO_IHOSTAUDIO_EMIT_STREAMGETSTATUS(drvAudioVRDE)
    427445{
    428446    NOREF(pInterface);
     
    433451}
    434452
    435 static DECLCALLBACK(int) drvAudioVRDEStreamIterate(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
     453
     454/**
     455 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamIterate}
     456 */
     457PDMAUDIO_IHOSTAUDIO_EMIT_STREAMITERATE(drvAudioVRDE)
    436458{
    437459    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
     
    443465    return VINF_SUCCESS;
    444466}
     467
    445468
    446469/**
     
    457480}
    458481
     482
    459483AudioVRDE::AudioVRDE(Console *pConsole)
    460484    : mpDrv(NULL),
     
    462486{
    463487}
     488
    464489
    465490AudioVRDE::~AudioVRDE(void)
     
    472497}
    473498
     499
    474500int AudioVRDE::onVRDEControl(bool fEnable, uint32_t uFlags)
    475501{
     
    484510    return VINF_SUCCESS; /* Never veto. */
    485511}
     512
    486513
    487514/**
     
    515542}
    516543
     544
    517545int AudioVRDE::onVRDEInputData(void *pvContext, const void *pvData, uint32_t cbData)
    518546{
     
    535563}
    536564
     565
    537566int AudioVRDE::onVRDEInputEnd(void *pvContext)
    538567{
     
    541570    return VINF_SUCCESS;
    542571}
     572
    543573
    544574int AudioVRDE::onVRDEInputIntercept(bool fEnabled)
     
    547577    return VINF_SUCCESS; /* Never veto. */
    548578}
     579
    549580
    550581/**
     
    557588{
    558589    RT_NOREF(fFlags);
     590
    559591    PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns);
    560592    PDRVAUDIOVRDE pThis = PDMINS_2_DATA(pDrvIns, PDRVAUDIOVRDE);
     593
    561594    AssertPtrReturn(pDrvIns, VERR_INVALID_POINTER);
    562595    AssertPtrReturn(pCfg, VERR_INVALID_POINTER);
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette