From ba42b262d1350754e66e234dc0e79cd7ccc0334e Mon Sep 17 00:00:00 2001
From: Eric Pouech <Eric.Pouech@wanadoo.fr>
Date: Sun, 5 Dec 1999 02:17:18 +0000
Subject: [PATCH] Fixed improper acm streams closing.

---
 dlls/msacm32/stream.c  | 7 +++++--
 dlls/msacm32/wineacm.h | 1 +
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/dlls/msacm32/stream.c b/dlls/msacm32/stream.c
index 0d3f595753b..c8f3436a6c9 100644
--- a/dlls/msacm32/stream.c
+++ b/dlls/msacm32/stream.c
@@ -45,7 +45,8 @@ MMRESULT WINAPI acmStreamClose(HACMSTREAM has, DWORD fdwClose)
     }
     ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_CLOSE, (DWORD)&was->drvInst, 0);
     if (ret == MMSYSERR_NOERROR) {
-	/* FIXME: shall the was->pDrv->hDrvr be also closed ? */
+	if (was->hAcmDriver)
+	    acmDriverClose(was->hAcmDriver, 0L);	
 	HeapFree(MSACM_hHeap, 0, was);
     }
     TRACE("=> (%d)\n", ret);
@@ -166,7 +167,8 @@ MMRESULT WINAPI acmStreamOpen(PHACMSTREAM phas, HACMDRIVER had, PWAVEFORMATEX pw
 	
 	was->obj.pACMDriverID = wad->obj.pACMDriverID;
 	was->pDrv = wad;
-	
+	was->hAcmDriver = 0; /* not to close it in acmStreamClose */
+
 	ret = SendDriverMessage(wad->hDrvr, ACMDM_STREAM_OPEN, (DWORD)&was->drvInst, 0L);
 	if (ret != MMSYSERR_NOERROR)
 	    goto errCleanUp;
@@ -180,6 +182,7 @@ MMRESULT WINAPI acmStreamOpen(PHACMSTREAM phas, HACMDRIVER had, PWAVEFORMATEX pw
 		if ((wad = MSACM_GetDriver(had)) != 0) {
 		    was->obj.pACMDriverID = wad->obj.pACMDriverID;
 		    was->pDrv = wad;
+		    was->hAcmDriver = had;
 		    
 		    ret = SendDriverMessage(wad->hDrvr, ACMDM_STREAM_OPEN, (DWORD)&was->drvInst, 0L);
 		    /* FIXME: when shall the acmDriver be Close():d ? */
diff --git a/dlls/msacm32/wineacm.h b/dlls/msacm32/wineacm.h
index 117d7451ca0..dfe1730ab56 100644
--- a/dlls/msacm32/wineacm.h
+++ b/dlls/msacm32/wineacm.h
@@ -22,6 +22,7 @@ typedef struct _WINE_ACMSTREAM
     WINE_ACMOBJ		obj;
     PWINE_ACMDRIVER	pDrv;
     ACMDRVSTREAMINSTANCE drvInst;
+    HACMDRIVER		hAcmDriver;
 } WINE_ACMSTREAM, *PWINE_ACMSTREAM;
 
 typedef struct _WINE_ACMDRIVERID
-- 
GitLab