Changeset 90962 in vbox for trunk/src/VBox/Devices/Audio
- Timestamp:
- Aug 27, 2021 4:40:53 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 146601
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/AudioTestService.cpp
r90918 r90962 1001 1001 */ 1002 1002 PATSTRANSPORTCLIENT pTransportClient; 1003 rc = pThis->pTransport->pfnWaitForConnect(pThis->pTransportInst, &pTransportClient);1003 rc = pThis->pTransport->pfnWaitForConnect(pThis->pTransportInst, 1000 /* msTimeout */, &pTransportClient); 1004 1004 if (RT_FAILURE(rc)) 1005 1005 continue; -
trunk/src/VBox/Devices/Audio/AudioTestServiceClient.cpp
r90954 r90962 312 312 313 313 /** 314 * Connects to an ATS peer .314 * Connects to an ATS peer, extended version. 315 315 * 316 316 * @returns VBox status code. 317 317 * @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 */ 321 int AudioTestSvcClientConnectEx(PATSCLIENT pClient, RTMSINTERVAL msTimeout) 320 322 { 321 323 int rc = pClient->pTransport->pfnStart(pClient->pTransportInst); 322 324 if (RT_SUCCESS(rc)) 323 325 { 324 rc = pClient->pTransport->pfnWaitForConnect(pClient->pTransportInst, &pClient->pTransportClient); 326 rc = pClient->pTransport->pfnWaitForConnect(pClient->pTransportInst, 327 msTimeout, &pClient->pTransportClient); 325 328 if (RT_SUCCESS(rc)) 326 329 { … … 330 333 331 334 return rc; 335 } 336 337 /** 338 * Connects to an ATS peer. 339 * 340 * @returns VBox status code. 341 * @param pClient Client to connect. 342 */ 343 int AudioTestSvcClientConnect(PATSCLIENT pClient) 344 { 345 return AudioTestSvcClientConnectEx(pClient, 30 * 1000 /* msTimeout */); 332 346 } 333 347 -
trunk/src/VBox/Devices/Audio/AudioTestServiceClient.h
r90830 r90962 47 47 /** @name Connection handling. 48 48 * @{ */ 49 int AudioTestSvcClientConnectEx(PATSCLIENT pClient, RTMSINTERVAL msTimeout); 49 50 int AudioTestSvcClientConnect(PATSCLIENT pClient); 50 51 int AudioTestSvcClientClose(PATSCLIENT pClient); -
trunk/src/VBox/Devices/Audio/AudioTestServiceInternal.h
r89962 r90962 122 122 * Waits for a new client to connect and returns the client specific data on 123 123 * 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)); 126 133 127 134 /** -
trunk/src/VBox/Devices/Audio/AudioTestServiceTcp.cpp
r90954 r90962 110 110 /** Pointer to transport client to connect. */ 111 111 PATSTRANSPORTCLIENT pClient; 112 /** Connection timeout (in ms). 113 * Use RT_INDEFINITE_WAIT to wait indefinitely. */ 114 uint32_t msTimeout; 112 115 } ATSCONNCTX; 113 116 /** Pointer to an Audio Test Service (ATS) TCP/IP connection context. */ … … 201 204 PATSTRANSPORTCLIENT pClient = pConnCtx->pClient; 202 205 206 /** @todo Implement cancellation support for using pConnCtx->msTimeout. */ 207 203 208 RTSOCKET hTcpClient; 204 209 int rc = RTTcpServerListen2(pThis->pTcpServer, &hTcpClient); … … 226 231 PATSTRANSPORTCLIENT pClient = pConnCtx->pClient; 227 232 233 uint64_t msStartTs = RTTimeMilliTS(); 234 228 235 for (;;) 229 236 { … … 249 256 return rc; 250 257 258 if ( pConnCtx->msTimeout != RT_INDEFINITE_WAIT 259 && RTTimeMilliTS() - msStartTs >= pConnCtx->msTimeout) 260 { 261 return VERR_TIMEOUT; 262 } 263 251 264 /* Delay a wee bit before retrying. */ 252 265 RTThreadUserWait(hSelf, 1536); … … 294 307 * @interface_method_impl{ATSTRANSPORT,pfnWaitForConnect} 295 308 */ 296 static DECLCALLBACK(int) atsTcpWaitForConnect(PATSTRANSPORTINST pThis, PPATSTRANSPORTCLIENT ppClientNew)309 static DECLCALLBACK(int) atsTcpWaitForConnect(PATSTRANSPORTINST pThis, RTMSINTERVAL msTimeout, PPATSTRANSPORTCLIENT ppClientNew) 297 310 { 298 311 PATSTRANSPORTCLIENT pClient = (PATSTRANSPORTCLIENT)RTMemAllocZ(sizeof(ATSTRANSPORTCLIENT)); … … 301 314 int rc; 302 315 303 LogFunc(("enmConnMode=%#x\n", pThis->enmConnMode)); 316 LogFunc(("msTimeout=%RU32, enmConnMode=%#x\n", msTimeout, pThis->enmConnMode)); 317 318 uint64_t msStartTs = RTTimeMilliTS(); 304 319 305 320 if (pThis->enmConnMode == ATSCONNMODE_SERVER) 306 321 { 322 /** @todo Implement cancellation support for using \a msTimeout. */ 323 307 324 pClient->fFromServer = true; 308 325 rc = RTTcpServerListen2(pThis->pTcpServer, &pClient->hTcpClient); … … 320 337 break; 321 338 339 if ( msTimeout != RT_INDEFINITE_WAIT 340 && RTTimeMilliTS() - msStartTs >= msTimeout) 341 { 342 rc = VERR_TIMEOUT; 343 break; 344 } 345 322 346 if (pThis->fStopConnecting) 323 347 { … … 346 370 ATSCONNCTX ConnCtx; 347 371 RT_ZERO(ConnCtx); 348 ConnCtx.pInst = pThis; 349 ConnCtx.pClient = pClient; 372 ConnCtx.pInst = pThis; 373 ConnCtx.pClient = pClient; 374 ConnCtx.msTimeout = msTimeout; 350 375 351 376 rc = VINF_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.