Index: trunk/src/VBox/Devices/Audio/AudioTestService.cpp
===================================================================
--- trunk/src/VBox/Devices/Audio/AudioTestService.cpp	(revision 89570)
+++ trunk/src/VBox/Devices/Audio/AudioTestService.cpp	(revision 89575)
@@ -905,6 +905,6 @@
      * Initialize the transport layer.
      */
-    int rc = pThis->pTransport->pfnInit(&pThis->TransportInst, pszBindAddr ? pszBindAddr : "127.0.0.1",
-                                         uBindPort ? uBindPort : ATS_TCP_DEFAULT_PORT);
+    int rc = pThis->pTransport->pfnInit(&pThis->TransportInst, pszBindAddr ? pszBindAddr : ATS_TCP_HOST_DEFAULT_ADDR_STR,
+                                         uBindPort ? uBindPort : ATS_TCP_HOST_DEFAULT_PORT);
     if (RT_SUCCESS(rc))
     {
Index: trunk/src/VBox/Devices/Audio/AudioTestService.h
===================================================================
--- trunk/src/VBox/Devices/Audio/AudioTestService.h	(revision 89570)
+++ trunk/src/VBox/Devices/Audio/AudioTestService.h	(revision 89575)
@@ -25,8 +25,10 @@
 
 
-/** Default TCP/IP port the ATS (Audio Test Service) is running on. */
-#define ATS_TCP_DEFAULT_PORT        6052
-/** Alternative TCP/IP port the ATS (Audio Test Service) is running on. */
-#define ATS_TCP_ALT_PORT            6042
+/** Default TCP/IP port the host ATS (Audio Test Service) is running on. */
+#define ATS_TCP_HOST_DEFAULT_PORT        6052
+/** Default TCP/IP address the host ATS (Audio Test Service) is running on. */
+#define ATS_TCP_HOST_DEFAULT_ADDR_STR    "127.0.0.1"
+/** Default TCP/IP port the guest ATS (Audio Test Service) is running on. */
+#define ATS_TCP_GUEST_DEFAULT_PORT       6042
 
 /**
Index: trunk/src/VBox/Devices/Audio/AudioTestServiceClient.cpp
===================================================================
--- trunk/src/VBox/Devices/Audio/AudioTestServiceClient.cpp	(revision 89570)
+++ trunk/src/VBox/Devices/Audio/AudioTestServiceClient.cpp	(revision 89575)
@@ -294,6 +294,5 @@
     audioTestSvcClientInit(pClient);
 
-    /* For simplicity we always run on the same port, localhost only. */
-    int rc = RTTcpClientConnect(pszAddr ? pszAddr : "127.0.0.1", uPort == 0 ? ATS_TCP_DEFAULT_PORT : uPort, &pClient->hSock);
+    int rc = RTTcpClientConnect(pszAddr ? pszAddr : ATS_TCP_HOST_DEFAULT_ADDR_STR, uPort == 0 ? ATS_TCP_HOST_DEFAULT_PORT : uPort, &pClient->hSock);
     if (RT_SUCCESS(rc))
     {
Index: trunk/src/VBox/Devices/Audio/DrvHostAudioValidationKit.cpp
===================================================================
--- trunk/src/VBox/Devices/Audio/DrvHostAudioValidationKit.cpp	(revision 89570)
+++ trunk/src/VBox/Devices/Audio/DrvHostAudioValidationKit.cpp	(revision 89575)
@@ -21,4 +21,5 @@
 *********************************************************************************************************************************/
 #define LOG_GROUP LOG_GROUP_DRV_HOST_AUDIO
+#include <iprt/dir.h>
 #include <iprt/env.h>
 #include <iprt/mem.h>
@@ -196,4 +197,5 @@
 }
 
+/** @copydoc ATSCALLBACKS::pfnTestSetBegin */
 static DECLCALLBACK(int) drvHostValKitTestSetBegin(void const *pvUser, const char *pszTag)
 {
@@ -201,9 +203,8 @@
 
     LogRel(("Audio: Validation Kit: Beginning test set '%s'\n", pszTag));
-
     return AudioTestSetCreate(&pThis->Set, pThis->szPathTemp, pszTag);
-
-}
-
+}
+
+/** @copydoc ATSCALLBACKS::pfnTestSetEnd */
 static DECLCALLBACK(int) drvHostValKitTestSetEnd(void const *pvUser, const char *pszTag)
 {
@@ -239,4 +240,5 @@
  *
  * Creates and registers a new test tone guest recording test.
+ * This backend will play (inject) input data to the guest.
  */
 static DECLCALLBACK(int) drvHostValKitRegisterGuestRecTest(void const *pvUser, PAUDIOTESTTONEPARMS pToneParms)
@@ -273,4 +275,5 @@
  *
  * Creates and registers a new test tone guest playback test.
+ * This backend will record the guest output data.
  */
 static DECLCALLBACK(int) drvHostValKitRegisterGuestPlayTest(void const *pvUser, PAUDIOTESTTONEPARMS pToneParms)
@@ -283,5 +286,5 @@
     memcpy(&pTestData->t.TestTone.Parms, pToneParms, sizeof(AUDIOTESTTONEPARMS));
 
-    pTestData->t.TestTone.u.Rec.cbToWrite = PDMAudioPropsMilliToBytes(&pToneParms->Props,
+    pTestData->t.TestTone.u.Play.cbToRead = PDMAudioPropsMilliToBytes(&pToneParms->Props,
                                                                       pTestData->t.TestTone.Parms.msDuration);
     int rc = RTCritSectEnter(&pThis->CritSect);
@@ -289,5 +292,5 @@
     {
         LogRel(("Audio: Validation Kit: Registered guest playback test (%RU32ms, %RU64 bytes)\n",
-                pTestData->t.TestTone.Parms.msDuration, pTestData->t.TestTone.u.Rec.cbToWrite));
+                pTestData->t.TestTone.Parms.msDuration, pTestData->t.TestTone.u.Play.cbToRead));
 
         RTListAppend(&pThis->lstTestsPlay, &pTestData->Node);
@@ -501,4 +504,6 @@
         AUDIOTESTPARMS Parms;
         RT_ZERO(Parms);
+        Parms.enmDir   = PDMAUDIODIR_IN;
+        Parms.enmType  = AUDIOTESTTYPE_TESTTONE_RECORD;
         Parms.TestTone = pTst->t.TestTone.Parms;
 
@@ -513,6 +518,5 @@
             pTst->msStartedTS = RTTimeMilliTS();
             LogRel(("Audio: Validation Kit: Recording audio data (%RU16Hz, %RU32ms) started\n",
-                    (uint16_t)pTst->t.TestTone.Tone.rdFreqHz,
-                    pTst->t.TestTone.Parms.msDuration));
+                    (uint16_t)Parms.TestTone.dbFreqHz, Parms.TestTone.msDuration));
         }
     }
@@ -523,5 +527,5 @@
     {
         uint32_t cbToRead = RT_MIN(cbBuf,
-                                   pTst->t.TestTone.u.Play.cbToRead- pTst->t.TestTone.u.Play.cbRead);
+                                   pTst->t.TestTone.u.Play.cbToRead - pTst->t.TestTone.u.Play.cbRead);
 
         rc = AudioTestSetObjWrite(pTst->pObj, pvBuf, cbToRead);
@@ -544,8 +548,12 @@
                     drvHostValKiUnregisterPlayTest(pThis, pTst);
 
+                    pThis->pTestCur = NULL;
+
                     int rc2 = RTCritSectLeave(&pThis->CritSect);
                     AssertRC(rc2);
                 }
             }
+
+            cbWritten = cbToRead;
         }
     }
@@ -597,4 +605,6 @@
         AUDIOTESTPARMS Parms;
         RT_ZERO(Parms);
+        Parms.enmDir   = PDMAUDIODIR_OUT;
+        Parms.enmType  = AUDIOTESTTYPE_TESTTONE_PLAY;
         Parms.TestTone = pTst->t.TestTone.Parms;
 
@@ -622,7 +632,7 @@
             rc = AudioTestToneGenerate(&pTst->t.TestTone.Tone, pvBuf, RT_MIN(cbToWrite, cbBuf), &cbRead);
         if (   RT_SUCCESS(rc)
-            && cbToWrite)
+            && cbRead)
         {
-            rc = AudioTestSetObjWrite(pTst->pObj, pvBuf, cbToWrite);
+            rc = AudioTestSetObjWrite(pTst->pObj, pvBuf, cbRead);
             if (RT_SUCCESS(rc))
             {
@@ -641,4 +651,6 @@
                     {
                         drvHostValKiUnregisterRecTest(pThis, pTst);
+
+                        pThis->pTestCur = NULL;
 
                         int rc2 = RTCritSectLeave(&pThis->CritSect);
@@ -730,6 +742,6 @@
 
     /** @todo Make this configurable via CFGM. */
-    const char *pszTcpAddr = "127.0.0.1";
-       uint32_t uTcpPort   = ATS_TCP_DEFAULT_PORT;
+    const char *pszTcpAddr = ATS_TCP_HOST_DEFAULT_ADDR_STR;
+       uint32_t uTcpPort   = ATS_TCP_HOST_DEFAULT_PORT;
 
     LogRel(("Audio: Validation Kit: Starting Audio Test Service (ATS) at %s:%RU32...\n",
@@ -798,4 +810,8 @@
     else
         LogRel(("Audio: Validation Kit: Shutdown of Audio Test Service failed, rc=%Rrc\n", rc));
+
+    /* Try cleaning up a bit. */
+    RTDirRemove(pThis->szPathTemp);
+    RTDirRemove(pThis->szPathOut);
 
     if (RTCritSectIsInitialized(&pThis->CritSect))
