Index: /trunk/src/VBox/Devices/Audio/DrvHostDebugAudio.cpp
===================================================================
--- /trunk/src/VBox/Devices/Audio/DrvHostDebugAudio.cpp	(revision 73343)
+++ /trunk/src/VBox/Devices/Audio/DrvHostDebugAudio.cpp	(revision 73344)
@@ -7,5 +7,5 @@
 
 /*
- * Copyright (C) 2016-2017 Oracle Corporation
+ * Copyright (C) 2016-2018 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -45,9 +45,4 @@
             uint64_t   tsLastCaptured;
         } In;
-        struct
-        {
-            uint8_t   *auPlayBuffer;
-            uint32_t   cbPlayBuffer;
-        } Out;
     };
 } DEBUGAUDIOSTREAM, *PDEBUGAUDIOSTREAM;
@@ -136,38 +131,28 @@
     RT_NOREF(pDrv);
 
-    int rc = VINF_SUCCESS;
-
-    pStreamDbg->Out.cbPlayBuffer  = _1K * PDMAUDIOSTREAMCFG_F2B(pCfgReq, 1); /** @todo Make this configurable? */
-    pStreamDbg->Out.auPlayBuffer  = (uint8_t *)RTMemAlloc(pStreamDbg->Out.cbPlayBuffer);
-    if (!pStreamDbg->Out.auPlayBuffer)
-        rc = VERR_NO_MEMORY;
-
+    char szTemp[RTPATH_MAX];
+    int rc = RTPathTemp(szTemp, sizeof(szTemp));
     if (RT_SUCCESS(rc))
     {
-        char szTemp[RTPATH_MAX];
-        rc = RTPathTemp(szTemp, sizeof(szTemp));
+        char szFile[RTPATH_MAX];
+        rc = DrvAudioHlpGetFileName(szFile, RT_ELEMENTS(szFile), szTemp, "DebugAudioOut",
+                                    pDrv->pDrvIns->iInstance, PDMAUDIOFILETYPE_WAV, PDMAUDIOFILENAME_FLAG_NONE);
         if (RT_SUCCESS(rc))
         {
-            char szFile[RTPATH_MAX];
-            rc = DrvAudioHlpGetFileName(szFile, RT_ELEMENTS(szFile), szTemp, "DebugAudioOut",
-                                        pDrv->pDrvIns->iInstance, PDMAUDIOFILETYPE_WAV, PDMAUDIOFILENAME_FLAG_NONE);
+            rc = DrvAudioHlpFileCreate(PDMAUDIOFILETYPE_WAV, szFile, PDMAUDIOFILE_FLAG_NONE, &pStreamDbg->pFile);
             if (RT_SUCCESS(rc))
             {
-                rc = DrvAudioHlpFileCreate(PDMAUDIOFILETYPE_WAV, szFile, PDMAUDIOFILE_FLAG_NONE, &pStreamDbg->pFile);
-                if (RT_SUCCESS(rc))
-                {
-                    rc = DrvAudioHlpFileOpen(pStreamDbg->pFile, RTFILE_O_WRITE | RTFILE_O_DENY_WRITE | RTFILE_O_CREATE_REPLACE,
-                                             &pCfgReq->Props);
-                }
-
-                if (RT_FAILURE(rc))
-                    LogRel(("DebugAudio: Creating output file '%s' failed with %Rrc\n", szFile, rc));
+                rc = DrvAudioHlpFileOpen(pStreamDbg->pFile, RTFILE_O_WRITE | RTFILE_O_DENY_WRITE | RTFILE_O_CREATE_REPLACE,
+                                         &pCfgReq->Props);
             }
-            else
-                LogRel(("DebugAudio: Unable to build file name for temp dir '%s': %Rrc\n", szTemp, rc));
+
+            if (RT_FAILURE(rc))
+                LogRel(("DebugAudio: Creating output file '%s' failed with %Rrc\n", szFile, rc));
         }
         else
-            LogRel(("DebugAudio: Unable to retrieve temp dir: %Rrc\n", rc));
+            LogRel(("DebugAudio: Unable to build file name for temp dir '%s': %Rrc\n", szTemp, rc));
     }
+    else
+        LogRel(("DebugAudio: Unable to retrieve temp dir: %Rrc\n", rc));
 
     if (RT_SUCCESS(rc))
@@ -223,28 +208,13 @@
     PDEBUGAUDIOSTREAM  pStreamDbg = (PDEBUGAUDIOSTREAM)pStream;
 
-    uint32_t cbWrittenTotal = 0;
-
-    uint32_t cbAvail = cxBuf;
-    while (cbAvail)
-    {
-        uint32_t cbChunk = RT_MIN(cbAvail, pStreamDbg->Out.cbPlayBuffer);
-
-        memcpy(pStreamDbg->Out.auPlayBuffer, (uint8_t *)pvBuf + cbWrittenTotal, cbChunk);
-
-        int rc2 = DrvAudioHlpFileWrite(pStreamDbg->pFile, pStreamDbg->Out.auPlayBuffer, cbChunk, 0 /* fFlags */);
-        if (RT_FAILURE(rc2))
-        {
-            LogRel(("DebugAudio: Writing output failed with %Rrc\n", rc2));
-            break;
-        }
-
-        Assert(cbAvail >= cbChunk);
-        cbAvail        -= cbChunk;
-
-        cbWrittenTotal += cbChunk;
+    int rc = DrvAudioHlpFileWrite(pStreamDbg->pFile, pvBuf, cxBuf, 0 /* fFlags */);
+    if (RT_FAILURE(rc))
+    {
+        LogRel(("DebugAudio: Writing output failed with %Rrc\n", rc));
+        return rc;
     }
 
     if (pcxWritten)
-        *pcxWritten = cbWrittenTotal;
+        *pcxWritten = cxBuf;
 
     return VINF_SUCCESS;
@@ -278,10 +248,4 @@
 {
     RT_NOREF(pDrv);
-
-    if (pStreamDbg->Out.auPlayBuffer)
-    {
-        RTMemFree(pStreamDbg->Out.auPlayBuffer);
-        pStreamDbg->Out.auPlayBuffer = NULL;
-    }
 
     DrvAudioHlpFileDestroy(pStreamDbg->pFile);
