VirtualBox

Changeset 90962 in vbox for trunk/src/VBox/Devices/Audio


Ignore:
Timestamp:
Aug 27, 2021 4:40:53 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
146601
Message:

Audio/Validation Kit: Implemented support for client-mode connection timeouts. ​bugref:10008

Location:
trunk/src/VBox/Devices/Audio
Files:
5 edited

Legend:

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

    r90918 r90962  
    10011001         */
    10021002        PATSTRANSPORTCLIENT pTransportClient;
    1003         rc = pThis->pTransport->pfnWaitForConnect(pThis->pTransportInst, &pTransportClient);
     1003        rc = pThis->pTransport->pfnWaitForConnect(pThis->pTransportInst, 1000 /* msTimeout */, &pTransportClient);
    10041004        if (RT_FAILURE(rc))
    10051005            continue;
  • trunk/src/VBox/Devices/Audio/AudioTestServiceClient.cpp

    r90954 r90962  
    312312
    313313/**
    314  * Connects to an ATS peer.
     314 * Connects to an ATS peer, extended version.
    315315 *
    316316 * @returns VBox status code.
    317317 * @param   pClient             Client to connect.
    318  */
    319 int AudioTestSvcClientConnect(PATSCLIENT pClient)
     318 * @param   msTimeout           Timeout (in ms) waiting for a connection to be established.
     319 *                              Use RT_INDEFINITE_WAIT to wait indefinitely.
     320 */
     321int AudioTestSvcClientConnectEx(PATSCLIENT pClient, RTMSINTERVAL msTimeout)
    320322{
    321323    int rc = pClient->pTransport->pfnStart(pClient->pTransportInst);
    322324    if (RT_SUCCESS(rc))
    323325    {
    324         rc = pClient->pTransport->pfnWaitForConnect(pClient->pTransportInst, &pClient->pTransportClient);
     326        rc = pClient->pTransport->pfnWaitForConnect(pClient->pTransportInst,
     327                                                    msTimeout, &pClient->pTransportClient);
    325328        if (RT_SUCCESS(rc))
    326329        {
     
    330333
    331334    return rc;
     335}
     336
     337/**
     338 * Connects to an ATS peer.
     339 *
     340 * @returns VBox status code.
     341 * @param   pClient             Client to connect.
     342 */
     343int AudioTestSvcClientConnect(PATSCLIENT pClient)
     344{
     345    return AudioTestSvcClientConnectEx(pClient, 30 * 1000 /* msTimeout */);
    332346}
    333347
  • trunk/src/VBox/Devices/Audio/AudioTestServiceClient.h

    r90830 r90962  
    4747/** @name Connection handling.
    4848 * @{ */
     49int AudioTestSvcClientConnectEx(PATSCLIENT pClient, RTMSINTERVAL msTimeout);
    4950int AudioTestSvcClientConnect(PATSCLIENT pClient);
    5051int AudioTestSvcClientClose(PATSCLIENT pClient);
  • trunk/src/VBox/Devices/Audio/AudioTestServiceInternal.h

    r89962 r90962  
    122122     * Waits for a new client to connect and returns the client specific data on
    123123     * success.
    124      */
    125     DECLR3CALLBACKMEMBER(int, pfnWaitForConnect, (PATSTRANSPORTINST pThis, PPATSTRANSPORTCLIENT ppClientNew));
     124     *
     125     * @returns VBox status code.
     126     * @param   pThis               The transport instance.
     127     * @param   msTimeout           Timeout (in ms) waiting for a connection to be established.
     128     *                              Use RT_INDEFINITE_WAIT to wait indefinitely.
     129     *                              This might or might not be supported by the specific transport implementation.
     130     * @param   ppClientNew         Where to return the allocated client on success.
     131     */
     132    DECLR3CALLBACKMEMBER(int, pfnWaitForConnect, (PATSTRANSPORTINST pThis, RTMSINTERVAL msTimeout, PPATSTRANSPORTCLIENT ppClientNew));
    126133
    127134    /**
  • trunk/src/VBox/Devices/Audio/AudioTestServiceTcp.cpp

    r90954 r90962  
    110110    /** Pointer to transport client to connect. */
    111111    PATSTRANSPORTCLIENT                pClient;
     112    /** Connection timeout (in ms).
     113     *  Use RT_INDEFINITE_WAIT to wait indefinitely. */
     114    uint32_t                           msTimeout;
    112115} ATSCONNCTX;
    113116/** Pointer to an Audio Test Service (ATS) TCP/IP connection context. */
     
    201204    PATSTRANSPORTCLIENT pClient  = pConnCtx->pClient;
    202205
     206    /** @todo Implement cancellation support for using pConnCtx->msTimeout. */
     207
    203208    RTSOCKET hTcpClient;
    204209    int rc = RTTcpServerListen2(pThis->pTcpServer, &hTcpClient);
     
    226231    PATSTRANSPORTCLIENT pClient  = pConnCtx->pClient;
    227232
     233    uint64_t msStartTs = RTTimeMilliTS();
     234
    228235    for (;;)
    229236    {
     
    249256            return rc;
    250257
     258        if (   pConnCtx->msTimeout         != RT_INDEFINITE_WAIT
     259            && RTTimeMilliTS() - msStartTs >= pConnCtx->msTimeout)
     260        {
     261            return VERR_TIMEOUT;
     262        }
     263
    251264        /* Delay a wee bit before retrying. */
    252265        RTThreadUserWait(hSelf, 1536);
     
    294307 * @interface_method_impl{ATSTRANSPORT,pfnWaitForConnect}
    295308 */
    296 static DECLCALLBACK(int) atsTcpWaitForConnect(PATSTRANSPORTINST pThis, PPATSTRANSPORTCLIENT ppClientNew)
     309static DECLCALLBACK(int) atsTcpWaitForConnect(PATSTRANSPORTINST pThis,  RTMSINTERVAL msTimeout, PPATSTRANSPORTCLIENT ppClientNew)
    297310{
    298311    PATSTRANSPORTCLIENT pClient = (PATSTRANSPORTCLIENT)RTMemAllocZ(sizeof(ATSTRANSPORTCLIENT));
     
    301314    int rc;
    302315
    303     LogFunc(("enmConnMode=%#x\n", pThis->enmConnMode));
     316    LogFunc(("msTimeout=%RU32, enmConnMode=%#x\n", msTimeout, pThis->enmConnMode));
     317
     318    uint64_t msStartTs = RTTimeMilliTS();
    304319
    305320    if (pThis->enmConnMode == ATSCONNMODE_SERVER)
    306321    {
     322        /** @todo Implement cancellation support for using \a msTimeout. */
     323
    307324        pClient->fFromServer = true;
    308325        rc = RTTcpServerListen2(pThis->pTcpServer, &pClient->hTcpClient);
     
    320337                break;
    321338
     339            if (   msTimeout                   != RT_INDEFINITE_WAIT
     340                && RTTimeMilliTS() - msStartTs >= msTimeout)
     341            {
     342                rc = VERR_TIMEOUT;
     343                break;
     344            }
     345
    322346            if (pThis->fStopConnecting)
    323347            {
     
    346370        ATSCONNCTX ConnCtx;
    347371        RT_ZERO(ConnCtx);
    348         ConnCtx.pInst   = pThis;
    349         ConnCtx.pClient = pClient;
     372        ConnCtx.pInst     = pThis;
     373        ConnCtx.pClient   = pClient;
     374        ConnCtx.msTimeout = msTimeout;
    350375
    351376        rc = VINF_SUCCESS;
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