Index: /trunk/src/VBox/Devices/Audio/DrvHostAudioNull.cpp
===================================================================
--- /trunk/src/VBox/Devices/Audio/DrvHostAudioNull.cpp	(revision 88455)
+++ /trunk/src/VBox/Devices/Audio/DrvHostAudioNull.cpp	(revision 88456)
@@ -1,5 +1,5 @@
 /* $Id$ */
 /** @file
- * Host audio driver - NULL.
+ * Host audio driver - NULL (bitbucket).
  *
  * This also acts as a fallback if no other backend is available.
@@ -16,29 +16,4 @@
  * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
  * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
- * --------------------------------------------------------------------
- *
- * This code is based on: noaudio.c QEMU based code.
- *
- * QEMU Timer based audio emulation
- *
- * Copyright (c) 2004-2005 Vassili Karpov (malc)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
  */
 
@@ -61,9 +36,12 @@
 *   Structures and Typedefs                                                                                                      *
 *********************************************************************************************************************************/
+/** Null audio stream. */
 typedef struct NULLAUDIOSTREAM
 {
     /** The stream's acquired configuration. */
-    PPDMAUDIOSTREAMCFG pCfg;
-} NULLAUDIOSTREAM, *PNULLAUDIOSTREAM;
+    PDMAUDIOSTREAMCFG   Cfg;
+} NULLAUDIOSTREAM;
+/** Pointer to a null audio stream.   */
+typedef NULLAUDIOSTREAM *PNULLAUDIOSTREAM;
 
 /**
@@ -77,5 +55,7 @@
     /** Pointer to host audio interface. */
     PDMIHOSTAUDIO       IHostAudio;
-} DRVHOSTNULLAUDIO, *PDRVHOSTNULLAUDIO;
+} DRVHOSTNULLAUDIO;
+/** Pointer to the instance data for a null audio host driver. */
+typedef DRVHOSTNULLAUDIO *PDRVHOSTNULLAUDIO;
 
 
@@ -89,5 +69,5 @@
     AssertPtrReturn(pBackendCfg, VERR_INVALID_POINTER);
 
-    RTStrPrintf2(pBackendCfg->szName, sizeof(pBackendCfg->szName), "NULL audio");
+    RTStrCopy(pBackendCfg->szName, sizeof(pBackendCfg->szName), "NULL audio");
 
     pBackendCfg->cbStreamOut    = sizeof(NULLAUDIOSTREAM);
@@ -106,8 +86,85 @@
 static DECLCALLBACK(PDMAUDIOBACKENDSTS) drvHostNullAudioHA_GetStatus(PPDMIHOSTAUDIO pInterface, PDMAUDIODIR enmDir)
 {
-    RT_NOREF(enmDir);
-    AssertPtrReturn(pInterface, PDMAUDIOBACKENDSTS_UNKNOWN);
-
+    RT_NOREF(pInterface, enmDir);
     return PDMAUDIOBACKENDSTS_RUNNING;
+}
+
+
+/**
+ * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCreate}
+ */
+static DECLCALLBACK(int) drvHostNullAudioHA_StreamCreate(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,
+                                                         PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq)
+{
+    RT_NOREF(pInterface);
+    PNULLAUDIOSTREAM pStreamNull = (PNULLAUDIOSTREAM)pStream;
+    AssertPtrReturn(pStreamNull, VERR_INVALID_POINTER);
+    AssertPtrReturn(pCfgReq, VERR_INVALID_POINTER);
+    AssertPtrReturn(pCfgAcq, VERR_INVALID_POINTER);
+
+    PDMAudioStrmCfgCopy(&pStreamNull->Cfg, pCfgAcq);
+    return VINF_SUCCESS;
+}
+
+
+/**
+ * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamDestroy}
+ */
+static DECLCALLBACK(int) drvHostNullAudioHA_StreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
+{
+    RT_NOREF(pInterface, pStream);
+    return VINF_SUCCESS;
+}
+
+
+/**
+ * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamControl}
+ */
+static DECLCALLBACK(int) drvHostNullAudioHA_StreamControl(PPDMIHOSTAUDIO pInterface,
+                                                          PPDMAUDIOBACKENDSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd)
+{
+    RT_NOREF(pInterface, pStream, enmStreamCmd);
+    return VINF_SUCCESS;
+}
+
+
+/**
+ * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}
+ */
+static DECLCALLBACK(uint32_t) drvHostNullAudioHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
+{
+    RT_NOREF(pInterface, pStream);
+    /** @todo rate limit this?   */
+    return UINT32_MAX;
+}
+
+
+/**
+ * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable}
+ */
+static DECLCALLBACK(uint32_t) drvHostNullAudioHA_StreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
+{
+    RT_NOREF(pInterface, pStream);
+    return UINT32_MAX;
+}
+
+
+/**
+ * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetPending}
+ */
+static DECLCALLBACK(uint32_t) drvHostNullAudioHA_StreamGetPending(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
+{
+    RT_NOREF(pInterface, pStream);
+    return 0;
+}
+
+
+/**
+ * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus}
+ */
+static DECLCALLBACK(PDMAUDIOSTREAMSTS) drvHostNullAudioHA_StreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
+{
+    RT_NOREF(pInterface, pStream);
+    return PDMAUDIOSTREAMSTS_FLAGS_INITIALIZED | PDMAUDIOSTREAMSTS_FLAGS_ENABLED;
 }
 
@@ -131,150 +188,16 @@
  */
 static DECLCALLBACK(int) drvHostNullAudioHA_StreamCapture(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,
-                                                          void *pvBuf, uint32_t uBufSize, uint32_t *puRead)
-{
-    RT_NOREF(pInterface, pStream);
-
+                                                          void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead)
+{
+    RT_NOREF(pInterface);
     PNULLAUDIOSTREAM pStreamNull = (PNULLAUDIOSTREAM)pStream;
 
+    /** @todo rate limit this? */
+
     /* Return silence. */
-    Assert(pStreamNull->pCfg);
-    PDMAudioPropsClearBuffer(&pStreamNull->pCfg->Props, pvBuf, uBufSize, PDMAUDIOPCMPROPS_B2F(&pStreamNull->pCfg->Props, uBufSize));
-
-    if (puRead)
-        *puRead = uBufSize;
-
-    return VINF_SUCCESS;
-}
-
-
-static int nullCreateStreamIn(PNULLAUDIOSTREAM pStreamNull, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq)
-{
-    RT_NOREF(pStreamNull, pCfgReq, pCfgAcq);
-
-    return VINF_SUCCESS;
-}
-
-
-static int nullCreateStreamOut(PNULLAUDIOSTREAM pStreamNull, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq)
-{
-    RT_NOREF(pStreamNull, pCfgReq, pCfgAcq);
-
-    return VINF_SUCCESS;
-}
-
-
-/**
- * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCreate}
- */
-static DECLCALLBACK(int) drvHostNullAudioHA_StreamCreate(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,
-                                                         PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq)
-{
-    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
-    AssertPtrReturn(pStream,    VERR_INVALID_POINTER);
-    AssertPtrReturn(pCfgReq,    VERR_INVALID_POINTER);
-    AssertPtrReturn(pCfgAcq,    VERR_INVALID_POINTER);
-
-    PNULLAUDIOSTREAM pStreamNull = (PNULLAUDIOSTREAM)pStream;
-
-    int rc;
-    if (pCfgReq->enmDir == PDMAUDIODIR_IN)
-        rc = nullCreateStreamIn( pStreamNull, pCfgReq, pCfgAcq);
-    else
-        rc = nullCreateStreamOut(pStreamNull, pCfgReq, pCfgAcq);
-
-    if (RT_SUCCESS(rc))
-    {
-        pStreamNull->pCfg = PDMAudioStrmCfgDup(pCfgAcq);
-        if (!pStreamNull->pCfg)
-            rc = VERR_NO_MEMORY;
-    }
-
-    return rc;
-}
-
-
-static int nullDestroyStreamIn(void)
-{
-    LogFlowFuncLeaveRC(VINF_SUCCESS);
-    return VINF_SUCCESS;
-}
-
-
-static int nullDestroyStreamOut(PNULLAUDIOSTREAM pStreamNull)
-{
-    RT_NOREF(pStreamNull);
-    return VINF_SUCCESS;
-}
-
-
-/**
- * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamDestroy}
- */
-static DECLCALLBACK(int) drvHostNullAudioHA_StreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
-{
-    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
-    AssertPtrReturn(pStream,    VERR_INVALID_POINTER);
-
-    PNULLAUDIOSTREAM pStreamNull = (PNULLAUDIOSTREAM)pStream;
-
-    if (!pStreamNull->pCfg) /* Not (yet) configured? Skip. */
-        return VINF_SUCCESS;
-
-    int rc;
-    if (pStreamNull->pCfg->enmDir == PDMAUDIODIR_IN)
-        rc = nullDestroyStreamIn();
-    else
-        rc = nullDestroyStreamOut(pStreamNull);
-
-    if (RT_SUCCESS(rc))
-    {
-        PDMAudioStrmCfgFree(pStreamNull->pCfg);
-        pStreamNull->pCfg = NULL;
-    }
-
-    return rc;
-}
-
-
-/**
- * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamControl}
- */
-static DECLCALLBACK(int) drvHostNullAudioHA_StreamControl(PPDMIHOSTAUDIO pInterface,
-                                                          PPDMAUDIOBACKENDSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd)
-{
-    RT_NOREF(pInterface, pStream, enmStreamCmd);
-    return VINF_SUCCESS;
-}
-
-
-/**
- * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}
- */
-static DECLCALLBACK(uint32_t) drvHostNullAudioHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
-{
-    RT_NOREF(pInterface, pStream);
-
-    return UINT32_MAX;
-}
-
-
-/**
- * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable}
- */
-static DECLCALLBACK(uint32_t) drvHostNullAudioHA_StreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
-{
-    RT_NOREF(pInterface, pStream);
-
-    return UINT32_MAX;
-}
-
-
-/**
- * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus}
- */
-static DECLCALLBACK(PDMAUDIOSTREAMSTS) drvHostNullAudioHA_StreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
-{
-    RT_NOREF(pInterface, pStream);
-    return PDMAUDIOSTREAMSTS_FLAGS_INITIALIZED | PDMAUDIOSTREAMSTS_FLAGS_ENABLED;
+    PDMAudioPropsClearBuffer(&pStreamNull->Cfg.Props, pvBuf, cbBuf,
+                             PDMAudioPropsBytesToFrames(&pStreamNull->Cfg.Props, cbBuf));
+    *pcbRead = cbBuf;
+    return VINF_SUCCESS;
 }
 
@@ -301,10 +224,7 @@
 static DECLCALLBACK(int) drvHostNullAudioConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags)
 {
+    PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns);
+    PDRVHOSTNULLAUDIO pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTNULLAUDIO);
     RT_NOREF(pCfg, fFlags);
-    PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns);
-    AssertPtrReturn(pDrvIns, VERR_INVALID_POINTER);
-    /* pCfg is optional. */
-
-    PDRVHOSTNULLAUDIO pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTNULLAUDIO);
     LogRel(("Audio: Initializing NULL driver\n"));
 
@@ -317,4 +237,5 @@
     /* IHostAudio */
     pThis->IHostAudio.pfnGetConfig          = drvHostNullAudioHA_GetConfig;
+    pThis->IHostAudio.pfnGetDevices         = NULL;
     pThis->IHostAudio.pfnGetStatus          = drvHostNullAudioHA_GetStatus;
     pThis->IHostAudio.pfnStreamCreate       = drvHostNullAudioHA_StreamCreate;
@@ -323,9 +244,8 @@
     pThis->IHostAudio.pfnStreamGetReadable  = drvHostNullAudioHA_StreamGetReadable;
     pThis->IHostAudio.pfnStreamGetWritable  = drvHostNullAudioHA_StreamGetWritable;
+    pThis->IHostAudio.pfnStreamGetPending   = drvHostNullAudioHA_StreamGetPending;
     pThis->IHostAudio.pfnStreamGetStatus    = drvHostNullAudioHA_StreamGetStatus;
     pThis->IHostAudio.pfnStreamPlay         = drvHostNullAudioHA_StreamPlay;
     pThis->IHostAudio.pfnStreamCapture      = drvHostNullAudioHA_StreamCapture;
-    pThis->IHostAudio.pfnGetDevices         = NULL;
-    pThis->IHostAudio.pfnStreamGetPending   = NULL;
 
     return VINF_SUCCESS;
Index: /trunk/src/VBox/Devices/Audio/DrvHostAudioValidationKit.cpp
===================================================================
--- /trunk/src/VBox/Devices/Audio/DrvHostAudioValidationKit.cpp	(revision 88455)
+++ /trunk/src/VBox/Devices/Audio/DrvHostAudioValidationKit.cpp	(revision 88456)
@@ -16,8 +16,15 @@
  */
 
-#include <iprt/alloc.h>
+
+/*********************************************************************************************************************************
+*   Defined Constants And Macros                                                                                                 *
+*********************************************************************************************************************************/
+#define LOG_GROUP LOG_GROUP_DRV_HOST_AUDIO
+#include <iprt/env.h>
+#include <iprt/mem.h>
+#include <iprt/path.h>
+#include <iprt/stream.h>
 #include <iprt/uuid.h> /* For PDMIBASE_2_PDMDRV. */
 
-#define LOG_GROUP LOG_GROUP_DRV_HOST_AUDIO
 #include <VBox/log.h>
 #include <VBox/vmm/pdmaudioifs.h>
@@ -28,19 +35,22 @@
 
 
-/**
- * Structure for keeping a VAKIT input/output stream.
+/*********************************************************************************************************************************
+*   Structures and Typedefs                                                                                                      *
+*********************************************************************************************************************************/
+/**
+ * Structure for keeping a validation kit input/output stream.
  */
 typedef struct VAKITAUDIOSTREAM
 {
     /** The stream's acquired configuration. */
-    PPDMAUDIOSTREAMCFG pCfg;
+    PPDMAUDIOSTREAMCFG  pCfg;
     /** Audio file to dump output to or read input from. */
-    PPDMAUDIOFILE      pFile;
+    PAUDIOHLPFILE       pFile;
     /** Text file to store timing of audio buffers submittions. */
-    RTFILE             hFileTiming;
+    PRTSTREAM           pFileTiming;
     /** Timestamp of the first play or record request. */
-    uint64_t           tsStarted;
+    uint64_t            tsStarted;
     /** Total number of frames played or recorded so far. */
-    uint32_t           cFramesSinceStarted;
+    uint32_t            cFramesSinceStarted;
     union
     {
@@ -48,18 +58,20 @@
         {
             /** Timestamp of last captured samples. */
-            uint64_t   tsLastCaptured;
+            uint64_t    tsLastCaptured;
         } In;
         struct
         {
             /** Timestamp of last played samples. */
-            uint64_t   tsLastPlayed;
-            uint8_t   *pu8PlayBuffer;
-            uint32_t   cbPlayBuffer;
+            uint64_t    tsLastPlayed;
+            uint8_t    *pbPlayBuffer;
+            uint32_t    cbPlayBuffer;
         } Out;
     };
-} VAKITAUDIOSTREAM, *PVAKITAUDIOSTREAM;
-
-/**
- * VAKIT audio driver instance data.
+} VAKITAUDIOSTREAM;
+/** Pointer to a validation kit stream. */
+typedef VAKITAUDIOSTREAM *PVAKITAUDIOSTREAM;
+
+/**
+ * Validation kit audio driver instance data.
  * @implements PDMIAUDIOCONNECTOR
  */
@@ -67,10 +79,11 @@
 {
     /** Pointer to the driver instance structure. */
-    PPDMDRVINS    pDrvIns;
+    PPDMDRVINS          pDrvIns;
     /** Pointer to host audio interface. */
-    PDMIHOSTAUDIO IHostAudio;
-} DRVHOSTVAKITAUDIO, *PDRVHOSTVAKITAUDIO;
-
-/*******************************************PDM_AUDIO_DRIVER******************************/
+    PDMIHOSTAUDIO       IHostAudio;
+} DRVHOSTVAKITAUDIO;
+/** Pointer to a validation kit host audio driver instance. */
+typedef DRVHOSTVAKITAUDIO *PDRVHOSTVAKITAUDIO;
+
 
 
@@ -107,55 +120,70 @@
 
 
-static int drvHostValKitAudioCreateStreamIn(PDRVHOSTVAKITAUDIO pDrv, PVAKITAUDIOSTREAM pStreamDbg,
+static int drvHostValKitAudioCreateStreamIn(PDRVHOSTVAKITAUDIO pThis, PVAKITAUDIOSTREAM pStreamDbg,
                                             PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq)
 {
-    RT_NOREF(pDrv, pStreamDbg, pCfgReq, pCfgAcq);
-
-    return VINF_SUCCESS;
-}
-
-
-static int drvHostValKitAudioCreateStreamOut(PDRVHOSTVAKITAUDIO pDrv, PVAKITAUDIOSTREAM pStreamDbg,
+    RT_NOREF(pThis, pStreamDbg, pCfgReq, pCfgAcq);
+
+    return VINF_SUCCESS;
+}
+
+
+static int drvHostValKitAudioCreateStreamOut(PDRVHOSTVAKITAUDIO pThis, PVAKITAUDIOSTREAM pStreamDbg,
                                              PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq)
 {
-    RT_NOREF(pDrv, pCfgAcq);
-
-    pStreamDbg->tsStarted = 0;
+    RT_NOREF(pThis, pCfgAcq);
+
+    /* Use the test box scratch dir if we're running in such an
+       environment, otherwise just dump the output in the temp
+       directory. */
+    char szTemp[RTPATH_MAX];
+    int rc = RTEnvGetEx(RTENV_DEFAULT, "TESTBOX_PATH_SCRATCH", szTemp, sizeof(szTemp), NULL);
+    if (RT_FAILURE(rc))
+    {
+        rc = RTPathTemp(szTemp, sizeof(szTemp));
+        if (RT_SUCCESS(rc))
+            rc = RTPathAppend(szTemp, sizeof(szTemp), "VBoxAudioValKit");
+        AssertRCReturn(rc, rc);
+    }
+
+    /* Get down to things that may fail and need cleanup. */
+    pStreamDbg->tsStarted           = 0;
     pStreamDbg->cFramesSinceStarted = 0;
-    pStreamDbg->Out.tsLastPlayed  = 0;
-    pStreamDbg->Out.cbPlayBuffer  = PDMAudioPropsFramesToBytes(&pCfgReq->Props, pCfgReq->Backend.cFramesBufferSize);
-    pStreamDbg->Out.pu8PlayBuffer = (uint8_t *)RTMemAlloc(pStreamDbg->Out.cbPlayBuffer);
-    AssertReturn(pStreamDbg->Out.pu8PlayBuffer, VERR_NO_MEMORY);
-
-    char szTemp[RTPATH_MAX];
-    int rc = RTPathTemp(szTemp, sizeof(szTemp));
+    pStreamDbg->Out.tsLastPlayed    = 0;
+    pStreamDbg->Out.cbPlayBuffer    = PDMAudioPropsFramesToBytes(&pCfgReq->Props, pCfgReq->Backend.cFramesBufferSize);
+    pStreamDbg->Out.pbPlayBuffer    = (uint8_t *)RTMemAlloc(pStreamDbg->Out.cbPlayBuffer);
+    AssertReturn(pStreamDbg->Out.pbPlayBuffer, VERR_NO_MEMORY);
+
+    rc = AudioHlpFileCreateAndOpenEx(&pStreamDbg->pFile, AUDIOHLPFILETYPE_WAV, szTemp, "ValKit",
+                                     pThis->pDrvIns->iInstance, AUDIOHLPFILENAME_FLAGS_NONE, AUDIOHLPFILE_FLAGS_NONE,
+                                     &pCfgReq->Props, AUDIOHLPFILE_DEFAULT_OPEN_FLAGS);
     if (RT_SUCCESS(rc))
-        rc = RTPathAppend(szTemp, sizeof(szTemp), "VBoxTestTmp\\VBoxAudioValKit");
-    if (RT_SUCCESS(rc))
-    {
-        char szFile[RTPATH_MAX];
-        rc = AudioHlpFileNameGet(szFile, sizeof(szFile), szTemp, "VaKit",
-                                 0 /* Instance */, PDMAUDIOFILETYPE_WAV, PDMAUDIOFILENAME_FLAGS_NONE);
+    {
+        rc = RTPathAppend(szTemp, sizeof(szTemp), "ValKitTimings.txt");
         if (RT_SUCCESS(rc))
         {
-            rc = AudioHlpFileCreate(PDMAUDIOFILETYPE_WAV, szFile, PDMAUDIOFILE_FLAGS_NONE, &pStreamDbg->pFile);
+            rc = RTStrmOpen(szTemp, "w", &pStreamDbg->pFileTiming);
             if (RT_SUCCESS(rc))
-                rc = AudioHlpFileOpen(pStreamDbg->pFile, PDMAUDIOFILE_DEFAULT_OPEN_FLAGS, &pCfgReq->Props);
+            {
+                RTStrmPrintf(pStreamDbg->pFileTiming, "# %uHz %uch %ubit\n",
+                             PDMAudioPropsHz(&pCfgReq->Props),
+                             PDMAudioPropsChannels(&pCfgReq->Props),
+                             PDMAudioPropsSampleBits(&pCfgReq->Props));
+                return VINF_SUCCESS;
+            }
+
+            LogRel(("ValKitAudio: Opening output file '%s' failed: %Rrc\n", szTemp, rc));
         }
-
-        if (RT_FAILURE(rc))
-            LogRel(("VaKitAudio: Creating output file '%s' failed with %Rrc\n", szFile, rc));
         else
-        {
-            size_t cch;
-            char szTimingInfo[128];
-            cch = RTStrPrintf(szTimingInfo, sizeof(szTimingInfo), "# %uHz %uch %ubit\n",
-                              pCfgReq->Props.uHz, pCfgReq->Props.cChannels, pCfgReq->Props.cbSample * 8);
-
-            RTFileWrite(pStreamDbg->hFileTiming, szTimingInfo, cch, NULL);
-        }
+            LogRel(("ValKitAudio: Constructing timing file path: %Rrc\n", rc));
+
+        AudioHlpFileDestroy(pStreamDbg->pFile);
+        pStreamDbg->pFile = NULL;
     }
     else
-        LogRel(("VaKitAudio: Unable to retrieve temp dir: %Rrc\n", rc));
+        LogRel(("ValKitAudio: Creating output file 'ValKit' in '%s' failed: %Rrc\n", szTemp, rc));
+
+    RTMemFree(pStreamDbg->Out.pbPlayBuffer);
+    pStreamDbg->Out.pbPlayBuffer = NULL;
     return rc;
 }
@@ -168,18 +196,15 @@
                                                            PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq)
 {
-    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
-    AssertPtrReturn(pStream,    VERR_INVALID_POINTER);
-    AssertPtrReturn(pCfgReq,    VERR_INVALID_POINTER);
-    AssertPtrReturn(pCfgAcq,    VERR_INVALID_POINTER);
-
-    PDRVHOSTVAKITAUDIO pDrv       = RT_FROM_MEMBER(pInterface, DRVHOSTVAKITAUDIO, IHostAudio);
+    PDRVHOSTVAKITAUDIO pThis       = RT_FROM_MEMBER(pInterface, DRVHOSTVAKITAUDIO, IHostAudio);
     PVAKITAUDIOSTREAM  pStreamDbg = (PVAKITAUDIOSTREAM)pStream;
+    AssertPtrReturn(pStreamDbg, VERR_INVALID_POINTER);
+    AssertPtrReturn(pCfgReq, VERR_INVALID_POINTER);
+    AssertPtrReturn(pCfgAcq, VERR_INVALID_POINTER);
 
     int rc;
     if (pCfgReq->enmDir == PDMAUDIODIR_IN)
-        rc = drvHostValKitAudioCreateStreamIn( pDrv, pStreamDbg, pCfgReq, pCfgAcq);
+        rc = drvHostValKitAudioCreateStreamIn( pThis, pStreamDbg, pCfgReq, pCfgAcq);
     else
-        rc = drvHostValKitAudioCreateStreamOut(pDrv, pStreamDbg, pCfgReq, pCfgAcq);
-
+        rc = drvHostValKitAudioCreateStreamOut(pThis, pStreamDbg, pCfgReq, pCfgAcq);
     if (RT_SUCCESS(rc))
     {
@@ -190,4 +215,94 @@
 
     return rc;
+}
+
+
+/**
+ * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamDestroy}
+ */
+static DECLCALLBACK(int) drvHostValKitAudioHA_StreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
+{
+    RT_NOREF(pInterface); //PDRVHOSTVAKITAUDIO pThis     = RT_FROM_MEMBER(pInterface, DRVHOSTVAKITAUDIO, IHostAudio);
+    PVAKITAUDIOSTREAM  pStreamDbg = (PVAKITAUDIOSTREAM)pStream;
+    AssertPtrReturn(pStreamDbg, VERR_INVALID_POINTER);
+
+    if (   pStreamDbg->pCfg->enmDir == PDMAUDIODIR_OUT
+        && pStreamDbg->Out.pbPlayBuffer)
+    {
+        RTMemFree(pStreamDbg->Out.pbPlayBuffer);
+        pStreamDbg->Out.pbPlayBuffer = NULL;
+    }
+
+    if (pStreamDbg->pFile)
+    {
+        size_t cbDataSize = AudioHlpFileGetDataSize(pStreamDbg->pFile);
+        if (cbDataSize)
+            LogRel(("ValKitAudio: Created output file '%s' (%zu bytes)\n", pStreamDbg->pFile->szName, cbDataSize));
+
+        AudioHlpFileDestroy(pStreamDbg->pFile);
+        pStreamDbg->pFile = NULL;
+    }
+
+    if (pStreamDbg->pFileTiming)
+    {
+        RTStrmClose(pStreamDbg->pFileTiming);
+        pStreamDbg->pFileTiming = NULL;
+    }
+
+    if (pStreamDbg->pCfg)
+    {
+        PDMAudioStrmCfgFree(pStreamDbg->pCfg);
+        pStreamDbg->pCfg = NULL;
+    }
+
+    return VINF_SUCCESS;
+}
+
+
+/**
+ * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamControl}
+ */
+static DECLCALLBACK(int) drvHostValKitAudioHA_StreamControl(PPDMIHOSTAUDIO pInterface,
+                                                            PPDMAUDIOBACKENDSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd)
+{
+    RT_NOREF(pInterface, enmStreamCmd);
+    PVAKITAUDIOSTREAM  pStreamDbg = (PVAKITAUDIOSTREAM)pStream;
+    AssertPtrReturn(pStreamDbg, VERR_INVALID_POINTER);
+
+    if (pStreamDbg->pFileTiming)
+        RTStrmFlush(pStreamDbg->pFileTiming);
+
+    return VINF_SUCCESS;
+}
+
+
+/**
+ * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}
+ */
+static DECLCALLBACK(uint32_t) drvHostValKitAudioHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
+{
+    RT_NOREF(pInterface, pStream);
+    return UINT32_MAX;
+}
+
+
+/**
+ * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable}
+ */
+static DECLCALLBACK(uint32_t) drvHostValKitAudioHA_StreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
+{
+    RT_NOREF(pInterface, pStream);
+    return UINT32_MAX;
+}
+
+
+/**
+ * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus}
+ */
+static DECLCALLBACK(PDMAUDIOSTREAMSTS) drvHostValKitAudioHA_StreamGetStatus(PPDMIHOSTAUDIO pInterface,
+                                                                            PPDMAUDIOBACKENDSTREAM pStream)
+{
+    RT_NOREF(pInterface, pStream);
+    return PDMAUDIOSTREAMSTS_FLAGS_INITIALIZED | PDMAUDIOSTREAMSTS_FLAGS_ENABLED;
 }
 
@@ -214,25 +329,23 @@
     // Microseconds are used everythere below
     uint32_t const cFrames = PDMAudioPropsBytesToFrames(&pStreamDbg->pCfg->Props, cbBuf);
-    char szTimingInfo[128];
-    size_t cch = RTStrPrintf(szTimingInfo, sizeof(szTimingInfo), "%d %d %d %d\n",
-                             // Host time elapsed since Guest submitted the first buffer for playback:
-                             (uint32_t)(cNsSinceStart / 1000),
-                             // how long all the samples submitted previously were played:
-                             (uint32_t)(pStreamDbg->cFramesSinceStarted * 1.0E6 / pStreamDbg->pCfg->Props.uHz),
-                             // how long a new uSamplesReady samples should/will be played:
-                             (uint32_t)(cFrames * 1.0E6 / pStreamDbg->pCfg->Props.uHz),
-                             cFrames);
-    RTFileWrite(pStreamDbg->hFileTiming, szTimingInfo, cch, NULL);
+    RTStrmPrintf(pStreamDbg->pFileTiming, "%d %d %d %d\n",
+                 // Host time elapsed since Guest submitted the first buffer for playback:
+                 (uint32_t)(cNsSinceStart / 1000),
+                 // how long all the samples submitted previously were played:
+                 (uint32_t)(pStreamDbg->cFramesSinceStarted * 1.0E6 / pStreamDbg->pCfg->Props.uHz),
+                 // how long a new uSamplesReady samples should/will be played:
+                 (uint32_t)(cFrames * 1.0E6 / pStreamDbg->pCfg->Props.uHz),
+                 cFrames);
+
     pStreamDbg->cFramesSinceStarted += cFrames;
 
     /* Remember when samples were consumed. */
-   // pStreamDbg->Out.tsLastPlayed = PDMDrvHlpTMGetVirtualTime(pThis->pDrvIns);
+    // pStreamDbg->Out.tsLastPlayed = PDMDrvHlpTMGetVirtualTime(pThis->pDrvIns);
 
     int rc2 = AudioHlpFileWrite(pStreamDbg->pFile, pvBuf, cbBuf, 0 /* fFlags */);
     if (RT_FAILURE(rc2))
-        LogRel(("VaKitAudio: Writing output failed with %Rrc\n", rc2));
+        LogRel(("ValKitAudio: Writing output failed with %Rrc\n", rc2));
 
     *pcbWritten = cbBuf;
-
     return VINF_SUCCESS;
 }
@@ -243,110 +356,13 @@
  */
 static DECLCALLBACK(int) drvHostValKitAudioHA_StreamCapture(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,
-                                                            void *pvBuf, uint32_t uBufSize, uint32_t *puRead)
-{
-    RT_NOREF(pInterface, pStream, pvBuf, uBufSize);
+                                                            void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead)
+{
+    RT_NOREF(pInterface, pStream, pvBuf, cbBuf);
 
     /* Never capture anything. */
-    if (puRead)
-        *puRead = 0;
-
-    return VINF_SUCCESS;
-}
-
-
-static int vakitDestroyStreamIn(PDRVHOSTVAKITAUDIO pDrv, PVAKITAUDIOSTREAM pStreamDbg)
-{
-    RT_NOREF(pDrv, pStreamDbg);
-    return VINF_SUCCESS;
-}
-
-
-static int vakitDestroyStreamOut(PDRVHOSTVAKITAUDIO pDrv, PVAKITAUDIOSTREAM pStreamDbg)
-{
-    RT_NOREF(pDrv);
-
-    if (pStreamDbg->Out.pu8PlayBuffer)
-    {
-        RTMemFree(pStreamDbg->Out.pu8PlayBuffer);
-        pStreamDbg->Out.pu8PlayBuffer = NULL;
-    }
-
-    if (pStreamDbg->pFile)
-    {
-        size_t cbDataSize = AudioHlpFileGetDataSize(pStreamDbg->pFile);
-        if (cbDataSize)
-            LogRel(("VaKitAudio: Created output file '%s' (%zu bytes)\n", pStreamDbg->pFile->szName, cbDataSize));
-
-        AudioHlpFileDestroy(pStreamDbg->pFile);
-        pStreamDbg->pFile = NULL;
-    }
-
-    return VINF_SUCCESS;
-}
-
-
-static DECLCALLBACK(int) drvHostValKitAudioHA_StreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
-{
-    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
-
-    PDRVHOSTVAKITAUDIO pDrv       = RT_FROM_MEMBER(pInterface, DRVHOSTVAKITAUDIO, IHostAudio);
-    PVAKITAUDIOSTREAM  pStreamDbg = (PVAKITAUDIOSTREAM)pStream;
-
-    if (!pStreamDbg->pCfg) /* Not (yet) configured? Skip. */
-        return VINF_SUCCESS;
-
-    int rc;
-    if (pStreamDbg->pCfg->enmDir == PDMAUDIODIR_IN)
-        rc = vakitDestroyStreamIn (pDrv, pStreamDbg);
-    else
-        rc = vakitDestroyStreamOut(pDrv, pStreamDbg);
-
-    if (RT_SUCCESS(rc))
-    {
-        PDMAudioStrmCfgFree(pStreamDbg->pCfg);
-        pStreamDbg->pCfg = NULL;
-    }
-
-    return rc;
-}
-
-static DECLCALLBACK(int) drvHostValKitAudioHA_StreamControl(PPDMIHOSTAUDIO pInterface,
-                                                            PPDMAUDIOBACKENDSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd)
-{
-    RT_NOREF(enmStreamCmd);
-    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
-    AssertPtrReturn(pStream,    VERR_INVALID_POINTER);
-
-    return VINF_SUCCESS;
-}
-
-/**
- * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}
- */
-static DECLCALLBACK(uint32_t) drvHostValKitAudioHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
-{
-    RT_NOREF(pInterface, pStream);
-
-    return UINT32_MAX;
-}
-
-
-/**
- * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable}
- */
-static DECLCALLBACK(uint32_t) drvHostValKitAudioHA_StreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
-{
-    RT_NOREF(pInterface, pStream);
-
-    return UINT32_MAX;
-}
-
-static DECLCALLBACK(PDMAUDIOSTREAMSTS) drvHostValKitAudioHA_StreamGetStatus(PPDMIHOSTAUDIO pInterface,
-                                                                            PPDMAUDIOBACKENDSTREAM pStream)
-{
-    RT_NOREF(pInterface, pStream);
-
-    return PDMAUDIOSTREAMSTS_FLAGS_INITIALIZED | PDMAUDIOSTREAMSTS_FLAGS_ENABLED;
-}
+    *pcbRead = 0;
+    return VINF_SUCCESS;
+}
+
 
 /**
@@ -374,5 +390,5 @@
     PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns);
     PDRVHOSTVAKITAUDIO pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTVAKITAUDIO);
-    LogRel(("Audio: Initializing VAKIT driver\n"));
+    LogRel(("Audio: Initializing VALKIT driver\n"));
 
     /*
@@ -384,4 +400,5 @@
     /* IHostAudio */
     pThis->IHostAudio.pfnGetConfig          = drvHostValKitAudioHA_GetConfig;
+    pThis->IHostAudio.pfnGetDevices         = NULL;
     pThis->IHostAudio.pfnGetStatus          = drvHostValKitAudioHA_GetStatus;
     pThis->IHostAudio.pfnStreamCreate       = drvHostValKitAudioHA_StreamCreate;
@@ -390,9 +407,8 @@
     pThis->IHostAudio.pfnStreamGetReadable  = drvHostValKitAudioHA_StreamGetReadable;
     pThis->IHostAudio.pfnStreamGetWritable  = drvHostValKitAudioHA_StreamGetWritable;
+    pThis->IHostAudio.pfnStreamGetPending   = NULL;
     pThis->IHostAudio.pfnStreamGetStatus    = drvHostValKitAudioHA_StreamGetStatus;
     pThis->IHostAudio.pfnStreamPlay         = drvHostValKitAudioHA_StreamPlay;
     pThis->IHostAudio.pfnStreamCapture      = drvHostValKitAudioHA_StreamCapture;
-    pThis->IHostAudio.pfnGetDevices         = NULL;
-    pThis->IHostAudio.pfnStreamGetPending   = NULL;
 
     return VINF_SUCCESS;
