Changeset 89541 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Jun 7, 2021 9:26:07 AM (4 years ago)
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/AudioTest.cpp
r89468 r89541 292 292 } 293 293 294 295 294 /** 296 295 * Return the tag to use in the given buffer, generating one if needed. … … 302 301 * @param pszTagUser User specified tag, optional. 303 302 */ 304 int AudioTestCopyOrGenTag(char *pszTag, size_t cbTag, const char *pszTagUser)303 static int audioTestCopyOrGenTag(char *pszTag, size_t cbTag, const char *pszTagUser) 305 304 { 306 305 if (pszTagUser && *pszTagUser) … … 325 324 { 326 325 char szTag[AUDIOTEST_TAG_MAX]; 327 int rc = AudioTestCopyOrGenTag(szTag, sizeof(szTag), pszTag);326 int rc = audioTestCopyOrGenTag(szTag, sizeof(szTag), pszTag); 328 327 AssertRCReturn(rc, rc); 329 328 … … 674 673 audioTestSetInitInternal(pSet); 675 674 676 int rc = AudioTestCopyOrGenTag(pSet->szTag, sizeof(pSet->szTag), pszTag);675 int rc = audioTestCopyOrGenTag(pSet->szTag, sizeof(pSet->szTag), pszTag); 677 676 AssertRCReturn(rc, rc); 678 677 -
trunk/src/VBox/Devices/Audio/AudioTest.h
r89468 r89541 342 342 int AudioTestToneParamsInitRandom(PAUDIOTESTTONEPARMS pToneParams, PPDMAUDIOPCMPROPS pProps); 343 343 344 int AudioTestGenTag(char *pszTag, size_t cbTag); 345 344 346 int AudioTestPathGetTemp(char *pszPath, size_t cbPath); 345 347 int AudioTestPathCreateTemp(char *pszPath, size_t cbPath, const char *pszUUID); -
trunk/src/VBox/Devices/Audio/AudioTestService.cpp
r89458 r89541 143 143 Log(("atsSendPkt: cb=%#x opcode=%.8s\n", pPkt->cb, pPkt->achOpcode)); 144 144 Log2(("%.*Rhxd\n", RT_MIN(pPkt->cb, 256), pPkt)); 145 int rc = pThis->pTransport->pfnSendPkt( pClient->pTransportClient, pPkt);145 int rc = pThis->pTransport->pfnSendPkt(&pThis->TransportInst, pClient->pTransportClient, pPkt); 146 146 while (RT_UNLIKELY(rc == VERR_INTERRUPTED) && !pThis->fTerminate) 147 rc = pThis->pTransport->pfnSendPkt( pClient->pTransportClient, pPkt);147 rc = pThis->pTransport->pfnSendPkt(&pThis->TransportInst, pClient->pTransportClient, pPkt); 148 148 if (RT_FAILURE(rc)) 149 149 Log(("atsSendPkt: rc=%Rrc\n", rc)); … … 166 166 memcpy(Reply.achOpcode, pszOpcode, sizeof(Reply.achOpcode)); 167 167 168 pThis->pTransport->pfnBabble( pClient->pTransportClient, &Reply, 20*1000);168 pThis->pTransport->pfnBabble(&pThis->TransportInst, pClient->pTransportClient, &Reply, 20*1000); 169 169 } 170 170 … … 187 187 { 188 188 PATSPKTHDR pPktHdr; 189 int rc = pThis->pTransport->pfnRecvPkt( pClient->pTransportClient, &pPktHdr);189 int rc = pThis->pTransport->pfnRecvPkt(&pThis->TransportInst, pClient->pTransportClient, &pPktHdr); 190 190 if (RT_SUCCESS(rc)) 191 191 { … … 513 513 if (RT_SUCCESS(rc)) 514 514 { 515 pThis->pTransport->pfnNotifyHowdy( pClient->pTransportClient);515 pThis->pTransport->pfnNotifyHowdy(&pThis->TransportInst, pClient->pTransportClient); 516 516 pClient->enmState = ATSCLIENTSTATE_READY; 517 517 } … … 769 769 idxSlt++; 770 770 771 rc = pThis->pTransport->pfnPollSetAdd( pThis->hPollSet, pIt->pTransportClient, idxSlt + 1);771 rc = pThis->pTransport->pfnPollSetAdd(&pThis->TransportInst, pThis->hPollSet, pIt->pTransportClient, idxSlt + 1); 772 772 if (RT_SUCCESS(rc)) 773 773 { … … 777 777 else 778 778 { 779 pThis->pTransport->pfnNotifyBye( pIt->pTransportClient);779 pThis->pTransport->pfnNotifyBye(&pThis->TransportInst, pIt->pTransportClient); 780 780 atsClientDestroy(pIt); 781 781 } … … 783 783 else 784 784 { 785 pThis->pTransport->pfnNotifyBye( pIt->pTransportClient);785 pThis->pTransport->pfnNotifyBye(&pThis->TransportInst, pIt->pTransportClient); 786 786 atsClientDestroy(pIt); 787 787 } … … 801 801 { 802 802 /* Close connection and remove client from array. */ 803 rc = pThis->pTransport->pfnPollSetRemove( pThis->hPollSet, pClient->pTransportClient, uId);803 rc = pThis->pTransport->pfnPollSetRemove(&pThis->TransportInst, pThis->hPollSet, pClient->pTransportClient, uId); 804 804 AssertRC(rc); 805 805 806 pThis->pTransport->pfnNotifyBye( pClient->pTransportClient);806 pThis->pTransport->pfnNotifyBye(&pThis->TransportInst, pClient->pTransportClient); 807 807 papClients[uId - 1] = NULL; 808 808 cClientsCur--; … … 829 829 AssertPtrReturn(pThis, VERR_INVALID_POINTER); 830 830 831 int rc = VINF_SUCCESS; 831 int rc = RTThreadUserSignal(hThread); 832 AssertRCReturn(rc, rc); 832 833 833 834 while (!pThis->fTerminate) … … 838 839 */ 839 840 PATSTRANSPORTCLIENT pTransportClient; 840 rc = pThis->pTransport->pfnWaitForConnect(&pT ransportClient);841 rc = pThis->pTransport->pfnWaitForConnect(&pThis->TransportInst, &pTransportClient); 841 842 if (RT_FAILURE(rc)) 842 843 continue; … … 866 867 { 867 868 RTMsgError("Creating new client structure failed with out of memory error\n"); 868 pThis->pTransport->pfnNotifyBye( pTransportClient);869 pThis->pTransport->pfnNotifyBye(&pThis->TransportInst, pTransportClient); 869 870 } 870 871 } … … 878 879 * @returns VBox status code. 879 880 * @param pThis The ATS instance. 881 * @param pszBindAddr Bind address. Empty means any address. 882 * If set to NULL, "127.0.0.1" will be used. 883 * @param uBindPort Bind port. If set to 0, ATS_DEFAULT_PORT is being used. 880 884 * @param pCallbacks The callbacks table to use. 881 885 * */ 882 int AudioTestSvcInit(PATSSERVER pThis, PCATSCALLBACKS pCallbacks) 886 int AudioTestSvcInit(PATSSERVER pThis, 887 const char *pszBindAddr, uint32_t uBindPort, PCATSCALLBACKS pCallbacks) 883 888 { 884 889 memcpy(&pThis->Callbacks, pCallbacks, sizeof(ATSCALLBACKS)); … … 896 901 * Initialize the transport layer. 897 902 */ 898 int rc = pThis->pTransport->pfnInit(); 903 int rc = pThis->pTransport->pfnInit(&pThis->TransportInst, pszBindAddr ? pszBindAddr : "127.0.0.1", 904 uBindPort ? uBindPort : ATS_TCP_DEFAULT_PORT); 899 905 if (RT_SUCCESS(rc)) 900 906 { … … 950 956 "AUDTSTSRVM"); 951 957 if (RT_SUCCESS(rc)) 952 pThis->fStarted = true; 958 { 959 rc = RTThreadUserWait(pThis->hThreadMain, RT_MS_30SEC); 960 if (RT_SUCCESS(rc)) 961 pThis->fStarted = true; 962 } 953 963 954 964 return rc; … … 969 979 970 980 if (pThis->pTransport) 971 pThis->pTransport->pfnTerm( );981 pThis->pTransport->pfnTerm(&pThis->TransportInst); 972 982 973 983 size_t cbWritten; -
trunk/src/VBox/Devices/Audio/AudioTestService.h
r89458 r89541 26 26 27 27 /** Default TCP/IP port the ATS (Audio Test Service) is running on. */ 28 #define ATS_DEFAULT_PORT 6052 28 #define ATS_TCP_DEFAULT_PORT 6052 29 /** Alternative TCP/IP port the ATS (Audio Test Service) is running on. */ 30 #define ATS_TCP_ALT_PORT 6042 29 31 30 32 /** … … 76 78 77 79 /** 80 * Structure for keeping Audio Test Service (ATS) transport instance-specific data. 81 * 82 * Currently only TCP/IP is supported. 83 */ 84 typedef struct ATSTRANSPORTINST 85 { 86 /** The addresses to bind to. Empty string means any. */ 87 char szTcpBindAddr[256]; 88 /** The TCP port to listen to. */ 89 uint32_t uTcpBindPort; 90 /** Pointer to the TCP server instance. */ 91 PRTTCPSERVER pTcpServer; 92 } ATSTRANSPORTINST; 93 /** Pointer to an Audio Test Service (ATS) TCP/IP transport instance. */ 94 typedef ATSTRANSPORTINST *PATSTRANSPORTINSTTCP; 95 96 /** 78 97 * Structure for keeping an Audio Test Service (ATS) instance. 79 98 */ … … 82 101 /** The selected transport layer. */ 83 102 PCATSTRANSPORT pTransport; 103 /** The transport instance. */ 104 ATSTRANSPORTINST TransportInst; 84 105 /** The callbacks table. */ 85 106 ATSCALLBACKS Callbacks; … … 106 127 typedef ATSSERVER *PATSSERVER; 107 128 108 int AudioTestSvcInit(PATSSERVER pThis, PCATSCALLBACKS pCallbacks);129 int AudioTestSvcInit(PATSSERVER pThis, const char *pszBindAddr, uint32_t uBindPort, PCATSCALLBACKS pCallbacks); 109 130 int AudioTestSvcDestroy(PATSSERVER pThis); 110 131 int AudioTestSvcStart(PATSSERVER pThis); -
trunk/src/VBox/Devices/Audio/AudioTestServiceClient.cpp
r89458 r89541 295 295 296 296 /* For simplicity we always run on the same port, localhost only. */ 297 int rc = RTTcpClientConnect(pszAddr ? pszAddr : "127.0.0.1", uPort == 0 ? ATS_ DEFAULT_PORT : uPort, &pClient->hSock);297 int rc = RTTcpClientConnect(pszAddr ? pszAddr : "127.0.0.1", uPort == 0 ? ATS_TCP_DEFAULT_PORT : uPort, &pClient->hSock); 298 298 if (RT_SUCCESS(rc)) 299 299 { -
trunk/src/VBox/Devices/Audio/AudioTestServiceInternal.h
r89182 r89541 33 33 typedef PATSTRANSPORTCLIENT *PPATSTRANSPORTCLIENT; 34 34 35 /** Opaque ATS transport specific instance data. */ 36 typedef struct ATSTRANSPORTINST *PATSTRANSPORTINST; 37 typedef PATSTRANSPORTINST *PPATSTRANSPORTINST; 38 35 39 /** 36 40 * Transport layer descriptor. … … 42 46 /** The description. */ 43 47 const char *pszDesc; 44 /** Pointer to an array of options. */45 PCRTGETOPTDEF paOpts;46 /** The number of options in the array. */47 size_t cOpts;48 49 /**50 * Print the usage information for this transport layer.51 *52 * @param pStream The stream to print the usage info to.53 *54 * @remarks This is only required if TXSTRANSPORT::cOpts is greater than 0.55 */56 DECLR3CALLBACKMEMBER(void, pfnUsage, (PRTSTREAM pStream));57 58 /**59 * Handle an option.60 *61 * When encountering an options that is not part of the base options, we'll call62 * this method for each transport layer until one handles it.63 *64 * @retval VINF_SUCCESS if handled.65 * @retval VERR_TRY_AGAIN if not handled.66 * @retval VERR_INVALID_PARAMETER if we should exit with a non-zero status.67 *68 * @param ch The short option value.69 * @param pVal Pointer to the value union.70 *71 * @remarks This is only required if TXSTRANSPORT::cOpts is greater than 0.72 */73 DECLR3CALLBACKMEMBER(int, pfnOption, (int ch, PCRTGETOPTUNION pVal));74 48 75 49 /** … … 78 52 * @returns IPRT status code. On errors, the transport layer shall call 79 53 * RTMsgError to display the error details to the user. 54 * @param pThis The transport instance. 55 * @param pszBindAddr Bind address. Empty means any address. 56 * @param uBindPort Bind port. If set to 0, ATS_DEFAULT_PORT is being used. 80 57 */ 81 DECLR3CALLBACKMEMBER(int, pfnInit, ( void));58 DECLR3CALLBACKMEMBER(int, pfnInit, (PATSTRANSPORTINST pThis, const char *pszBindAddr, uint32_t uBindPort)); 82 59 83 60 /** … … 86 63 * On errors, the transport layer shall call RTMsgError to display the error 87 64 * details to the user. 65 * 66 * @param pThis The transport instance. 88 67 */ 89 DECLR3CALLBACKMEMBER(void, pfnTerm, ( void));68 DECLR3CALLBACKMEMBER(void, pfnTerm, (PATSTRANSPORTINST pThis)); 90 69 91 70 /** … … 93 72 * success. 94 73 */ 95 DECLR3CALLBACKMEMBER(int, pfnWaitForConnect, (P PATSTRANSPORTCLIENT ppClientNew));74 DECLR3CALLBACKMEMBER(int, pfnWaitForConnect, (PATSTRANSPORTINST pThis, PPATSTRANSPORTCLIENT ppClientNew)); 96 75 97 76 /** … … 99 78 * 100 79 * @returns true if there are pending packets, false if there isn't. 80 * @param pThis The transport instance. 101 81 * @param pClient The client to poll for data. 102 82 */ 103 DECLR3CALLBACKMEMBER(bool, pfnPollIn, (PATSTRANSPORT CLIENT pClient));83 DECLR3CALLBACKMEMBER(bool, pfnPollIn, (PATSTRANSPORTINST pThis, PATSTRANSPORTCLIENT pClient)); 104 84 105 85 /** … … 107 87 * 108 88 * @returns IPRT status code. 89 * @param pThis The transport instance. 109 90 * @param hPollSet The poll set to add them to. 110 91 * @param pClient The transport client structure. 111 92 * @param idStart The handle ID to start at. 112 93 */ 113 DECLR3CALLBACKMEMBER(int, pfnPollSetAdd, ( RTPOLLSET hPollSet, PATSTRANSPORTCLIENT pClient, uint32_t idStart));94 DECLR3CALLBACKMEMBER(int, pfnPollSetAdd, (PATSTRANSPORTINST pThis, RTPOLLSET hPollSet, PATSTRANSPORTCLIENT pClient, uint32_t idStart)); 114 95 115 96 /** … … 117 98 * 118 99 * @returns IPRT status code. 100 * @param pThis The transport instance. 119 101 * @param hPollSet The poll set to remove from. 120 102 * @param pClient The transport client structure. 121 103 * @param idStart The handle ID to remove. 122 104 */ 123 DECLR3CALLBACKMEMBER(int, pfnPollSetRemove, ( RTPOLLSET hPollSet, PATSTRANSPORTCLIENT pClient, uint32_t idStart));105 DECLR3CALLBACKMEMBER(int, pfnPollSetRemove, (PATSTRANSPORTINST pThis, RTPOLLSET hPollSet, PATSTRANSPORTCLIENT pClient, uint32_t idStart)); 124 106 125 107 /** … … 134 116 * receive call. 135 117 * 118 * @param pThis The transport instance. 136 119 * @param pClient The transport client structure. 137 120 * @param ppPktHdr Where to return the pointer to the packet we've … … 140 123 * free by calling RTMemFree. 141 124 */ 142 DECLR3CALLBACKMEMBER(int, pfnRecvPkt, (PATSTRANSPORT CLIENT pClient, PPATSPKTHDR ppPktHdr));125 DECLR3CALLBACKMEMBER(int, pfnRecvPkt, (PATSTRANSPORTINST pThis, PATSTRANSPORTCLIENT pClient, PPATSPKTHDR ppPktHdr)); 143 126 144 127 /** … … 150 133 * @retval VERR_INTERRUPTED if interrupted before anything was sent. 151 134 * 135 * @param pThis The transport instance. 152 136 * @param pClient The transport client structure. 153 137 * @param pPktHdr The packet to send. The size is given by … … 155 139 * ATSPKT_ALIGNMENT. 156 140 */ 157 DECLR3CALLBACKMEMBER(int, pfnSendPkt, (PATSTRANSPORT CLIENT pClient, PCATSPKTHDR pPktHdr));141 DECLR3CALLBACKMEMBER(int, pfnSendPkt, (PATSTRANSPORTINST pThis, PATSTRANSPORTCLIENT pClient, PCATSPKTHDR pPktHdr)); 158 142 159 143 /** 160 144 * Sends a babble packet and disconnects the client (if applicable). 161 145 * 146 * @param pThis The transport instance. 162 147 * @param pClient The transport client structure. 163 148 * @param pPktHdr The packet to send. The size is given by … … 166 151 * @param cMsSendTimeout The send timeout measured in milliseconds. 167 152 */ 168 DECLR3CALLBACKMEMBER(void, pfnBabble, (PATSTRANSPORT CLIENT pClient, PCATSPKTHDR pPktHdr, RTMSINTERVAL cMsSendTimeout));153 DECLR3CALLBACKMEMBER(void, pfnBabble, (PATSTRANSPORTINST pThis, PATSTRANSPORTCLIENT pClient, PCATSPKTHDR pPktHdr, RTMSINTERVAL cMsSendTimeout)); 169 154 170 155 /** 171 156 * Notification about a client HOWDY. 172 157 * 158 * @param pThis The transport instance. 173 159 * @param pClient The transport client structure. 174 160 */ 175 DECLR3CALLBACKMEMBER(void, pfnNotifyHowdy, (PATSTRANSPORT CLIENT pClient));161 DECLR3CALLBACKMEMBER(void, pfnNotifyHowdy, (PATSTRANSPORTINST pThis, PATSTRANSPORTCLIENT pClient)); 176 162 177 163 /** … … 181 167 * client at this point. 182 168 * 169 * @param pThis The transport instance. 183 170 * @param pClient The transport client structure. 184 171 */ 185 DECLR3CALLBACKMEMBER(void, pfnNotifyBye, (PATSTRANSPORT CLIENT pClient));172 DECLR3CALLBACKMEMBER(void, pfnNotifyBye, (PATSTRANSPORTINST pThis, PATSTRANSPORTCLIENT pClient)); 186 173 187 174 /** … … 190 177 * For connection oriented transport layers, stop listening for and 191 178 * accepting at this point. 179 * 180 * @param pThis The transport instance. 192 181 */ 193 DECLR3CALLBACKMEMBER(void, pfnNotifyReboot, ( void));182 DECLR3CALLBACKMEMBER(void, pfnNotifyReboot, (PATSTRANSPORTINST pThis)); 194 183 195 184 /** Non-zero end marker. */ -
trunk/src/VBox/Devices/Audio/AudioTestServiceTcp.cpp
r89204 r89541 34 34 #include <iprt/time.h> 35 35 36 #include "AudioTestService.h" 36 37 #include "AudioTestServiceInternal.h" 37 38 … … 40 41 * Defined Constants And Macros * 41 42 *********************************************************************************************************************************/ 42 /** The default server port.43 * Note: Do not choose/use 6042, as the Validation Kit TxsService already might use that port. */44 #define ATS_TCP_DEF_BIND_PORT 605245 /** The default server bind address. */46 #define ATS_TCP_DEF_BIND_ADDRESS ""47 43 48 44 … … 70 66 * Global Variables * 71 67 *********************************************************************************************************************************/ 72 /** @name TCP Parameters73 * @{ */74 /** The addresses to bind to. Empty string means any. */75 static char g_szTcpBindAddr[256] = ATS_TCP_DEF_BIND_ADDRESS;76 /** The TCP port to listen to. */77 static uint32_t g_uTcpBindPort = ATS_TCP_DEF_BIND_PORT;78 /** @} */79 80 /** Pointer to the TCP server instance. */81 static PRTTCPSERVER g_pTcpServer = NULL;82 #if 0 /* unused */83 /** Stop connecting attempts when set. */84 static bool g_fTcpStopConnecting = false;85 #endif86 87 88 68 89 69 /** 90 70 * Disconnects the current client and frees all stashed data. 91 71 */ 92 static void atsTcpDisconnectClient(PATSTRANSPORTCLIENT pClient) 93 { 72 static void atsTcpDisconnectClient(PATSTRANSPORTINST pThis, PATSTRANSPORTCLIENT pClient) 73 { 74 RT_NOREF(pThis); 75 94 76 if (pClient->hTcpClient != NIL_RTSOCKET) 95 77 { … … 109 91 * @interface_method_impl{ATSTRANSPORT,pfnWaitForConnect} 110 92 */ 111 static DECLCALLBACK(int) atsTcpWaitForConnect(P PATSTRANSPORTCLIENT ppClientNew)93 static DECLCALLBACK(int) atsTcpWaitForConnect(PATSTRANSPORTINST pThis, PPATSTRANSPORTCLIENT ppClientNew) 112 94 { 113 95 int rc; 114 96 RTSOCKET hClientNew; 115 97 116 rc = RTTcpServerListen2( g_pTcpServer, &hClientNew);98 rc = RTTcpServerListen2(pThis->pTcpServer, &hClientNew); 117 99 Log(("atsTcpWaitForConnect: RTTcpServerListen2 -> %Rrc\n", rc)); 118 100 … … 141 123 * @interface_method_impl{ATSTRANSPORT,pfnNotifyReboot} 142 124 */ 143 static DECLCALLBACK(void) atsTcpNotifyReboot( void)144 { 145 Log(("atsTcpNotifyReboot: RTTcpServerDestroy(%p)\n", g_pTcpServer));146 if ( g_pTcpServer)147 { 148 int rc = RTTcpServerDestroy( g_pTcpServer);125 static DECLCALLBACK(void) atsTcpNotifyReboot(PATSTRANSPORTINST pThis) 126 { 127 Log(("atsTcpNotifyReboot: RTTcpServerDestroy(%p)\n", pThis->pTcpServer)); 128 if (pThis->pTcpServer) 129 { 130 int rc = RTTcpServerDestroy(pThis->pTcpServer); 149 131 if (RT_FAILURE(rc)) 150 132 RTMsgInfo("RTTcpServerDestroy failed in atsTcpNotifyReboot: %Rrc", rc); 151 g_pTcpServer = NULL;133 pThis->pTcpServer = NULL; 152 134 } 153 135 } … … 156 138 * @interface_method_impl{ATSTRANSPORT,pfnNotifyBye} 157 139 */ 158 static DECLCALLBACK(void) atsTcpNotifyBye(PATSTRANSPORT CLIENT pClient)140 static DECLCALLBACK(void) atsTcpNotifyBye(PATSTRANSPORTINST pThis, PATSTRANSPORTCLIENT pClient) 159 141 { 160 142 Log(("atsTcpNotifyBye: atsTcpDisconnectClient %RTsock\n", pClient->hTcpClient)); 161 atsTcpDisconnectClient(p Client);143 atsTcpDisconnectClient(pThis, pClient); 162 144 RTMemFree(pClient); 163 145 } … … 166 148 * @interface_method_impl{ATSTRANSPORT,pfnNotifyHowdy} 167 149 */ 168 static DECLCALLBACK(void) atsTcpNotifyHowdy(PATSTRANSPORT CLIENT pClient)150 static DECLCALLBACK(void) atsTcpNotifyHowdy(PATSTRANSPORTINST pThis, PATSTRANSPORTCLIENT pClient) 169 151 { 170 152 /* nothing to do here */ 171 RT_NOREF 1(pClient);153 RT_NOREF(pThis, pClient); 172 154 } 173 155 … … 175 157 * @interface_method_impl{ATSTRANSPORT,pfnBabble} 176 158 */ 177 static DECLCALLBACK(void) atsTcpBabble(PATSTRANSPORT CLIENT pClient, PCATSPKTHDR pPktHdr, RTMSINTERVAL cMsSendTimeout)159 static DECLCALLBACK(void) atsTcpBabble(PATSTRANSPORTINST pThis, PATSTRANSPORTCLIENT pClient, PCATSPKTHDR pPktHdr, RTMSINTERVAL cMsSendTimeout) 178 160 { 179 161 /* … … 190 172 */ 191 173 Log(("atsTcpBabble: atsTcpDisconnectClient(%RTsock) (RTTcpWrite rc=%Rrc)\n", pClient->hTcpClient, rc)); 192 atsTcpDisconnectClient(p Client);174 atsTcpDisconnectClient(pThis, pClient); 193 175 } 194 176 … … 196 178 * @interface_method_impl{ATSTRANSPORT,pfnSendPkt} 197 179 */ 198 static DECLCALLBACK(int) atsTcpSendPkt(PATSTRANSPORT CLIENT pClient, PCATSPKTHDR pPktHdr)180 static DECLCALLBACK(int) atsTcpSendPkt(PATSTRANSPORTINST pThis, PATSTRANSPORTCLIENT pClient, PCATSPKTHDR pPktHdr) 199 181 { 200 182 Assert(pPktHdr->cb >= sizeof(ATSPKTHDR)); … … 210 192 /* assume fatal connection error. */ 211 193 Log(("RTTcpWrite -> %Rrc -> atsTcpDisconnectClient(%RTsock)\n", rc, pClient->hTcpClient)); 212 atsTcpDisconnectClient(p Client);194 atsTcpDisconnectClient(pThis, pClient); 213 195 } 214 196 … … 219 201 * @interface_method_impl{ATSTRANSPORT,pfnRecvPkt} 220 202 */ 221 static DECLCALLBACK(int) atsTcpRecvPkt(PATSTRANSPORT CLIENT pClient, PPATSPKTHDR ppPktHdr)203 static DECLCALLBACK(int) atsTcpRecvPkt(PATSTRANSPORTINST pThis, PATSTRANSPORTCLIENT pClient, PPATSPKTHDR ppPktHdr) 222 204 { 223 205 int rc = VINF_SUCCESS; … … 335 317 /* assume fatal connection error. */ 336 318 Log(("atsTcpRecvPkt: RTTcpRead -> %Rrc -> atsTcpDisconnectClient(%RTsock)\n", rc, pClient->hTcpClient)); 337 atsTcpDisconnectClient(p Client);319 atsTcpDisconnectClient(pThis, pClient); 338 320 } 339 321 } … … 345 327 * @interface_method_impl{ATSTRANSPORT,pfnPollSetAdd} 346 328 */ 347 static DECLCALLBACK(int) atsTcpPollSetAdd(RTPOLLSET hPollSet, PATSTRANSPORTCLIENT pClient, uint32_t idStart) 348 { 329 static DECLCALLBACK(int) atsTcpPollSetAdd(PATSTRANSPORTINST pThis, RTPOLLSET hPollSet, PATSTRANSPORTCLIENT pClient, uint32_t idStart) 330 { 331 RT_NOREF(pThis); 349 332 return RTPollSetAddSocket(hPollSet, pClient->hTcpClient, RTPOLL_EVT_READ | RTPOLL_EVT_ERROR, idStart); 350 333 } … … 353 336 * @interface_method_impl{ATSTRANSPORT,pfnPollSetRemove} 354 337 */ 355 static DECLCALLBACK(int) atsTcpPollSetRemove( RTPOLLSET hPollSet, PATSTRANSPORTCLIENT pClient, uint32_t idStart)356 { 357 RT_NOREF 1(pClient);338 static DECLCALLBACK(int) atsTcpPollSetRemove(PATSTRANSPORTINST pThis, RTPOLLSET hPollSet, PATSTRANSPORTCLIENT pClient, uint32_t idStart) 339 { 340 RT_NOREF(pThis, pClient); 358 341 return RTPollSetRemove(hPollSet, idStart); 359 342 } … … 362 345 * @interface_method_impl{ATSTRANSPORT,pfnPollIn} 363 346 */ 364 static DECLCALLBACK(bool) atsTcpPollIn(PATSTRANSPORTCLIENT pClient) 365 { 347 static DECLCALLBACK(bool) atsTcpPollIn(PATSTRANSPORTINST pThis, PATSTRANSPORTCLIENT pClient) 348 { 349 RT_NOREF(pThis); 366 350 int rc = RTTcpSelectOne(pClient->hTcpClient, 0/*cMillies*/); 367 351 return RT_SUCCESS(rc); … … 371 355 * @interface_method_impl{ATSTRANSPORT,pfnTerm} 372 356 */ 373 static DECLCALLBACK(void) atsTcpTerm( void)357 static DECLCALLBACK(void) atsTcpTerm(PATSTRANSPORTINST pThis) 374 358 { 375 359 /* Shut down the server (will wake up thread). */ 376 if ( g_pTcpServer)360 if (pThis->pTcpServer) 377 361 { 378 362 Log(("atsTcpTerm: Destroying server...\n")); 379 int rc = RTTcpServerDestroy( g_pTcpServer);363 int rc = RTTcpServerDestroy(pThis->pTcpServer); 380 364 if (RT_FAILURE(rc)) 381 365 RTMsgInfo("RTTcpServerDestroy failed in atsTcpTerm: %Rrc", rc); 382 g_pTcpServer = NULL;366 pThis->pTcpServer = NULL; 383 367 } 384 368 … … 389 373 * @interface_method_impl{ATSTRANSPORT,pfnInit} 390 374 */ 391 static DECLCALLBACK(int) atsTcpInit( void)392 { 393 int rc = RTTcpServerCreateEx( g_szTcpBindAddr[0] ? g_szTcpBindAddr : NULL, g_uTcpBindPort, &g_pTcpServer);375 static DECLCALLBACK(int) atsTcpInit(PATSTRANSPORTINST pThis, const char *pszBindAddr, uint32_t uBindPort) 376 { 377 int rc = RTTcpServerCreateEx(pszBindAddr[0] ? pszBindAddr : NULL, uBindPort, &pThis->pTcpServer); 394 378 if (RT_FAILURE(rc)) 395 379 { … … 397 381 { 398 382 RTMsgInfo("RTTcpServerCreateEx(%s, %u,) failed: %Rrc, retrying for 20 seconds...\n", 399 g_szTcpBindAddr[0] ? g_szTcpBindAddr : NULL, g_uTcpBindPort, rc);383 pszBindAddr[0] ? pszBindAddr : NULL, uBindPort, rc); 400 384 uint64_t StartMs = RTTimeMilliTS(); 401 385 do 402 386 { 403 387 RTThreadSleep(1000); 404 rc = RTTcpServerCreateEx( g_szTcpBindAddr[0] ? g_szTcpBindAddr : NULL, g_uTcpBindPort, &g_pTcpServer);388 rc = RTTcpServerCreateEx(pszBindAddr[0] ? pszBindAddr : NULL, uBindPort, &pThis->pTcpServer); 405 389 } while ( rc == VERR_NET_DOWN 406 390 && RTTimeMilliTS() - StartMs < 20000); … … 410 394 if (RT_FAILURE(rc)) 411 395 { 412 g_pTcpServer = NULL;396 pThis->pTcpServer = NULL; 413 397 RTMsgError("RTTcpServerCreateEx(%s, %u,) failed: %Rrc\n", 414 g_szTcpBindAddr[0] ? g_szTcpBindAddr : NULL, g_uTcpBindPort, rc);398 pszBindAddr[0] ? pszBindAddr : NULL, uBindPort, rc); 415 399 } 416 400 } … … 418 402 return rc; 419 403 } 420 421 /** Options */422 enum ATSTCPOPT423 {424 ATSTCPOPT_BIND_ADDRESS = 1000,425 ATSTCPOPT_BIND_PORT426 };427 428 /**429 * @interface_method_impl{ATSTRANSPORT,pfnOption}430 */431 static DECLCALLBACK(int) atsTcpOption(int ch, PCRTGETOPTUNION pVal)432 {433 int rc;434 435 switch (ch)436 {437 case ATSTCPOPT_BIND_ADDRESS:438 rc = RTStrCopy(g_szTcpBindAddr, sizeof(g_szTcpBindAddr), pVal->psz);439 if (RT_FAILURE(rc))440 return RTMsgErrorRc(VERR_INVALID_PARAMETER, "TCP bind address is too long (%Rrc)", rc);441 return VINF_SUCCESS;442 443 case ATSTCPOPT_BIND_PORT:444 g_uTcpBindPort = pVal->u16 == 0 ? ATS_TCP_DEF_BIND_PORT : pVal->u16;445 return VINF_SUCCESS;446 }447 return VERR_TRY_AGAIN;448 }449 450 /**451 * @interface_method_impl{ATSTRANSPORT,pfnUsage}452 */453 DECLCALLBACK(void) atsTcpUsage(PRTSTREAM pStream)454 {455 RTStrmPrintf(pStream,456 " --tcp-bind-address <address>\n"457 " The address(es) to listen to TCP connection on. Empty string\n"458 " means any address, this is the default.\n"459 " --tcp-bind-port <port>\n"460 " The port to listen to TCP connections on.\n"461 " Default: %u\n"462 , ATS_TCP_DEF_BIND_PORT);463 }464 465 /** Command line options for the TCP/IP transport layer. */466 static const RTGETOPTDEF g_TcpOpts[] =467 {468 { "--tcp-bind-address", ATSTCPOPT_BIND_ADDRESS, RTGETOPT_REQ_STRING },469 { "--tcp-bind-port", ATSTCPOPT_BIND_PORT, RTGETOPT_REQ_UINT16 }470 };471 404 472 405 /** TCP/IP transport layer. */ … … 475 408 /* .szName = */ "tcp", 476 409 /* .pszDesc = */ "TCP/IP", 477 /* .cOpts = */ &g_TcpOpts[0],478 /* .paOpts = */ RT_ELEMENTS(g_TcpOpts),479 /* .pfnUsage = */ atsTcpUsage,480 /* .pfnOption = */ atsTcpOption,481 410 /* .pfnInit = */ atsTcpInit, 482 411 /* .pfnTerm = */ atsTcpTerm, … … 493 422 /* .u32EndMarker = */ UINT32_C(0x12345678) 494 423 }; 424 -
trunk/src/VBox/Devices/Audio/DrvHostAudioValidationKit.cpp
r89510 r89541 155 155 pTst->pObj = NULL; 156 156 157 AssertPtrReturnVoid(pTst->pEntry); 158 AudioTestSetTestDone(pTst->pEntry); 159 pTst->pEntry = NULL; 157 if (pTst->pEntry) /* Set set entry assign? Mark as done. */ 158 { 159 AssertPtrReturnVoid(pTst->pEntry); 160 AudioTestSetTestDone(pTst->pEntry); 161 pTst->pEntry = NULL; 162 } 160 163 161 164 RTMemFree(pTst); … … 235 238 /** @copydoc ATSCALLBACKS::pfnTonePlay 236 239 * 237 * Creates and registers a new test tone recording test 238 * which later then gets recorded by the guest side. 240 * Creates and registers a new test tone guest recording test. 239 241 */ 240 242 static DECLCALLBACK(int) drvHostValKitRegisterGuestRecTest(void const *pvUser, PAUDIOTESTTONEPARMS pToneParms) … … 270 272 /** @copydoc ATSCALLBACKS::pfnToneRecord 271 273 * 272 * Creates and registers a new test tone playback test 273 * which later then records audio played back by the guest side. 274 * Creates and registers a new test tone guest playback test. 274 275 */ 275 276 static DECLCALLBACK(int) drvHostValKitRegisterGuestPlayTest(void const *pvUser, PAUDIOTESTTONEPARMS pToneParms) … … 283 284 284 285 pTestData->t.TestTone.u.Rec.cbToWrite = PDMAudioPropsMilliToBytes(&pToneParms->Props, 285 pTestData->t.TestTone.Parms.msDuration);286 pTestData->t.TestTone.Parms.msDuration); 286 287 int rc = RTCritSectEnter(&pThis->CritSect); 287 288 if (RT_SUCCESS(rc)) … … 714 715 Callbacks.pvUser = pThis; 715 716 716 LogRel(("Audio: Validation Kit: Starting Audio Test Service (ATS) ...\n")); 717 718 int rc = AudioTestSvcInit(&pThis->Srv, &Callbacks); 717 /** @todo Make this configurable via CFGM. */ 718 const char *pszTcpAddr = "127.0.0.1"; 719 uint32_t uTcpPort = ATS_TCP_DEFAULT_PORT; 720 721 LogRel(("Audio: Validation Kit: Starting Audio Test Service (ATS) at %s:%RU32...\n", 722 pszTcpAddr, uTcpPort)); 723 724 int rc = AudioTestSvcInit(&pThis->Srv, 725 /* We only allow connections from localhost for now. */ 726 pszTcpAddr, uTcpPort, &Callbacks); 719 727 if (RT_SUCCESS(rc)) 720 728 rc = AudioTestSvcStart(&pThis->Srv);
Note:
See TracChangeset
for help on using the changeset viewer.