https://git.reactos.org/?p=reactos.git;a=commitdiff;h=323975a79ec326490d20bc...
commit 323975a79ec326490d20bc31d2c5e78734e320fd Author: Amine Khaldi amine.khaldi@reactos.org AuthorDate: Sat Nov 9 21:56:33 2019 +0100 Commit: Amine Khaldi amine.khaldi@reactos.org CommitDate: Sat Nov 9 21:56:33 2019 +0100
[MSACM32] Sync with Wine Staging 4.18. CORE-16441 --- dll/win32/msacm32/driver.c | 14 +++------ dll/win32/msacm32/format.c | 11 +++---- dll/win32/msacm32/internal.c | 66 ++++++++++++++++++++++++---------------- dll/win32/msacm32/pcmconverter.c | 1 - dll/win32/msacm32/precomp.h | 3 -- dll/win32/msacm32/wineacm.h | 1 + media/doc/README.WINE | 2 +- 7 files changed, 51 insertions(+), 47 deletions(-)
diff --git a/dll/win32/msacm32/driver.c b/dll/win32/msacm32/driver.c index e0c5fdd90ef..f0d003f648b 100644 --- a/dll/win32/msacm32/driver.c +++ b/dll/win32/msacm32/driver.c @@ -21,8 +21,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
-#include "config.h" -#include "wine/port.h"
#include <stdarg.h> #include <stdio.h> @@ -38,7 +36,6 @@ #include "msacmdrv.h" #include "wineacm.h" #include "wine/debug.h" -#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL(msacm);
@@ -441,11 +438,11 @@ LRESULT WINAPI acmDriverMessage(HACMDRIVER had, UINT uMsg, LPARAM lParam1, LPARA
pConfigInfo->dwDCISize = iStructSize;
- section_name = HeapAlloc(MSACM_hHeap, 0, (strlenW(drivers32) + 1) * sizeof(WCHAR)); - if (section_name) strcpyW(section_name, drivers32); + section_name = HeapAlloc(MSACM_hHeap, 0, (lstrlenW(drivers32) + 1) * sizeof(WCHAR)); + if (section_name) lstrcpyW(section_name, drivers32); pConfigInfo->lpszDCISectionName = section_name; - alias_name = HeapAlloc(MSACM_hHeap, 0, (strlenW(pAlias) + 1) * sizeof(WCHAR)); - if (alias_name) strcpyW(alias_name, pAlias); + alias_name = HeapAlloc(MSACM_hHeap, 0, (lstrlenW(pAlias) + 1) * sizeof(WCHAR)); + if (alias_name) lstrcpyW(alias_name, pAlias); pConfigInfo->lpszDCIAliasName = alias_name;
if (pConfigInfo->lpszDCISectionName == NULL || pConfigInfo->lpszDCIAliasName == NULL) { @@ -600,8 +597,7 @@ MMRESULT WINAPI acmDriverOpen(PHACMDRIVER phad, HACMDRIVERID hadid, DWORD fdwOpe return MMSYSERR_NOERROR; gotError: WARN("failed: ret = %08x\n", ret); - if (pad && !pad->hDrvr) - HeapFree(MSACM_hHeap, 0, pad); + HeapFree(MSACM_hHeap, 0, pad); return ret; }
diff --git a/dll/win32/msacm32/format.c b/dll/win32/msacm32/format.c index fcc0d9b1c62..284633ccefe 100644 --- a/dll/win32/msacm32/format.c +++ b/dll/win32/msacm32/format.c @@ -27,7 +27,6 @@ #include "winerror.h" #include "wingdi.h" #include "winuser.h" -#include "wine/unicode.h" #include "wine/debug.h" #include "mmsystem.h" #include "mmreg.h" @@ -75,7 +74,7 @@ static BOOL CALLBACK MSACM_FillFormatTagsCB(HACMDRIVERID hadid, } break; case WINE_ACMFF_FORMAT: - if (strcmpW(affd->szFormatTag, paftd->szFormatTag) == 0) { + if (lstrcmpW(affd->szFormatTag, paftd->szFormatTag) == 0) { HACMDRIVER had;
if (acmDriverOpen(&had, hadid, 0) == MMSYSERR_NOERROR) { @@ -102,7 +101,7 @@ static BOOL CALLBACK MSACM_FillFormatTagsCB(HACMDRIVERID hadid, mmr = acmFormatDetailsW(had, &afd, ACM_FORMATDETAILSF_INDEX); if (mmr == MMSYSERR_NOERROR) { lstrcpynW(buffer, afd.szFormat, ACMFORMATTAGDETAILS_FORMATTAG_CHARS + 1); - len = strlenW(buffer); + len = lstrlenW(buffer); for (j = len; j < ACMFORMATTAGDETAILS_FORMATTAG_CHARS; j++) buffer[j] = ' '; wsprintfW(buffer + ACMFORMATTAGDETAILS_FORMATTAG_CHARS, @@ -123,7 +122,7 @@ static BOOL CALLBACK MSACM_FillFormatTagsCB(HACMDRIVERID hadid, } break; case WINE_ACMFF_WFX: - if (strcmpW(affd->szFormatTag, paftd->szFormatTag) == 0) { + if (lstrcmpW(affd->szFormatTag, paftd->szFormatTag) == 0) { HACMDRIVER had;
if (acmDriverOpen(&had, hadid, 0) == MMSYSERR_NOERROR) { @@ -504,8 +503,8 @@ MMRESULT WINAPI acmFormatDetailsW(HACMDRIVER had, PACMFORMATDETAILSW pafd, DWORD pafd->pwfx->wBitsPerSample); } MultiByteToWideChar(CP_ACP, 0, (pafd->pwfx->nChannels == 1) ? "; Mono" : "; Stereo", -1, - pafd->szFormat + strlenW(pafd->szFormat), - ARRAY_SIZE(pafd->szFormat) - strlenW(pafd->szFormat)); + pafd->szFormat + lstrlenW(pafd->szFormat), + ARRAY_SIZE(pafd->szFormat) - lstrlenW(pafd->szFormat)); }
TRACE("=> %d\n", mmr); diff --git a/dll/win32/msacm32/internal.c b/dll/win32/msacm32/internal.c index aad071e8ade..222cf16d5d6 100644 --- a/dll/win32/msacm32/internal.c +++ b/dll/win32/msacm32/internal.c @@ -23,6 +23,9 @@
#include <stdarg.h> #include <string.h> +#ifdef __REACTOS__ +#include <wchar.h> +#endif
#include "windef.h" #include "winbase.h" @@ -36,7 +39,6 @@ #include "msacmdrv.h" #include "wineacm.h" #include "wine/debug.h" -#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL(msacm);
@@ -72,7 +74,7 @@ PWINE_ACMDRIVERID MSACM_RegisterDriverFromRegistry(LPCWSTR pszRegEntry) /* The requested registry entry must have the format msacm.XXXXX in order to be recognized in any future sessions of msacm */ - if (0 == strncmpiW(pszRegEntry, msacmW, ARRAY_SIZE(msacmW))) { + if (0 == _wcsnicmp(pszRegEntry, msacmW, ARRAY_SIZE(msacmW))) { lRet = RegOpenKeyExW(HKEY_LOCAL_MACHINE, drvkey, 0, KEY_QUERY_VALUE, &hKey); if (lRet != ERROR_SUCCESS) { WARN("unable to open registry key - 0x%08x\n", lRet); @@ -192,12 +194,12 @@ static LPWSTR MSACM_GetRegistryKey(const WINE_ACMDRIVERID* padid) ERR("No alias needed for registry entry\n"); return NULL; } - len = strlenW(baseKey); - ret = HeapAlloc(MSACM_hHeap, 0, (len + strlenW(padid->pszDriverAlias) + 1) * sizeof(WCHAR)); + len = lstrlenW(baseKey); + ret = HeapAlloc(MSACM_hHeap, 0, (len + lstrlenW(padid->pszDriverAlias) + 1) * sizeof(WCHAR)); if (!ret) return NULL;
- strcpyW(ret, baseKey); - strcpyW(ret + len, padid->pszDriverAlias); + lstrcpyW(ret, baseKey); + lstrcpyW(ret + len, padid->pszDriverAlias); CharLowerW(ret + len); return ret; } @@ -296,23 +298,23 @@ PWINE_ACMDRIVERID MSACM_RegisterDriver(LPCWSTR pszDriverAlias, LPCWSTR pszFileNa padid->pszDriverAlias = NULL; if (pszDriverAlias) { - padid->pszDriverAlias = HeapAlloc( MSACM_hHeap, 0, (strlenW(pszDriverAlias)+1) * sizeof(WCHAR) ); + padid->pszDriverAlias = HeapAlloc( MSACM_hHeap, 0, (lstrlenW(pszDriverAlias)+1) * sizeof(WCHAR) ); if (!padid->pszDriverAlias) { HeapFree(MSACM_hHeap, 0, padid); return NULL; } - strcpyW( padid->pszDriverAlias, pszDriverAlias ); + lstrcpyW( padid->pszDriverAlias, pszDriverAlias ); } padid->pszFileName = NULL; if (pszFileName) { - padid->pszFileName = HeapAlloc( MSACM_hHeap, 0, (strlenW(pszFileName)+1) * sizeof(WCHAR) ); + padid->pszFileName = HeapAlloc( MSACM_hHeap, 0, (lstrlenW(pszFileName)+1) * sizeof(WCHAR) ); if (!padid->pszFileName) { HeapFree(MSACM_hHeap, 0, padid->pszDriverAlias); HeapFree(MSACM_hHeap, 0, padid); return NULL; } - strcpyW( padid->pszFileName, pszFileName ); + lstrcpyW( padid->pszFileName, pszFileName ); } padid->pLocalDriver = pLocalDriver;
@@ -376,8 +378,8 @@ void MSACM_RegisterAllDrivers(void) bufLen = ARRAY_SIZE(buf); lRet = RegEnumKeyExW(hKey, i, buf, &bufLen, 0, 0, 0, &lastWrite); if (lRet != ERROR_SUCCESS) continue; - if (strncmpiW(buf, msacmW, ARRAY_SIZE(msacmW))) continue; - if (!(name = strchrW(buf, '='))) continue; + if (_wcsnicmp(buf, msacmW, ARRAY_SIZE(msacmW))) continue; + if (!(name = wcschr(buf, '='))) continue; *name = 0; MSACM_RegisterDriver(buf, name + 1, 0); } @@ -386,7 +388,7 @@ void MSACM_RegisterAllDrivers(void) bufLen = sizeof(buf); while(RegEnumValueW(hKey, i, valname, &cnt, 0, &type, (BYTE*)buf, &bufLen) == ERROR_SUCCESS){ - if (!strncmpiW(valname, msacmW, ARRAY_SIZE(msacmW))) + if (!_wcsnicmp(valname, msacmW, ARRAY_SIZE(msacmW))) MSACM_RegisterDriver(valname, buf, 0); ++i; } @@ -395,10 +397,10 @@ void MSACM_RegisterAllDrivers(void)
if (GetPrivateProfileSectionW(drv32, buf, ARRAY_SIZE(buf), sys)) { - for(s = buf; *s; s += strlenW(s) + 1) + for(s = buf; *s; s += lstrlenW(s) + 1) { - if (strncmpiW(s, msacmW, ARRAY_SIZE(msacmW))) continue; - if (!(name = strchrW(s, '='))) continue; + if (_wcsnicmp(s, msacmW, ARRAY_SIZE(msacmW))) continue; + if (!(name = wcschr(s, '='))) continue; *name = 0; MSACM_RegisterDriver(s, name + 1, 0); *name = '='; @@ -614,7 +616,7 @@ static void MSACM_ReorderDriversByPriority(void) static const WCHAR sPrefix[] = {'m','s','a','c','m','.','\0'};
/* Build expected entry name */ - snprintfW(szSubKey, 17, priorityTmpl, i + 1); + swprintf(szSubKey, priorityTmpl, i + 1); lBufferLength = sizeof(szBuffer); lError = RegQueryValueExW(hPriorityKey, szSubKey, NULL, NULL, (LPBYTE)szBuffer, (LPDWORD)&lBufferLength); if (lError != ERROR_SUCCESS) continue; @@ -623,11 +625,11 @@ static void MSACM_ReorderDriversByPriority(void) iTargetPosition = i;
/* Locate driver alias in driver list */ - pAlias = strstrW(szBuffer, sPrefix); + pAlias = wcsstr(szBuffer, sPrefix); if (pAlias == NULL) continue;
for (iCurrentPosition = 0; iCurrentPosition < iNumDrivers; iCurrentPosition++) { - if (strcmpiW(driverList[iCurrentPosition]->pszDriverAlias, pAlias) == 0) + if (wcsicmp(driverList[iCurrentPosition]->pszDriverAlias, pAlias) == 0) break; } if (iCurrentPosition < iNumDrivers && iTargetPosition != iCurrentPosition) { @@ -703,13 +705,13 @@ void MSACM_WriteCurrentPriorities(void)
/* Build required value name */ dwPriorityCounter++; - snprintfW(szSubKey, 17, priorityTmpl, dwPriorityCounter); + swprintf(szSubKey, priorityTmpl, dwPriorityCounter);
/* Value has a 1 in front for enabled drivers and 0 for disabled drivers */ - snprintfW(szBuffer, 256, valueTmpl, (padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) ? '0' : '1', padid->pszDriverAlias); - strlwrW(szBuffer); + swprintf(szBuffer, valueTmpl, (padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) ? '0' : '1', padid->pszDriverAlias); + _wcslwr(szBuffer);
- lError = RegSetValueExW(hPriorityKey, szSubKey, 0, REG_SZ, (BYTE *)szBuffer, (strlenW(szBuffer) + 1) * sizeof(WCHAR)); + lError = RegSetValueExW(hPriorityKey, szSubKey, 0, REG_SZ, (BYTE *)szBuffer, (lstrlenW(szBuffer) + 1) * sizeof(WCHAR)); if (lError != ERROR_SUCCESS) { ERR("unable to write value for %s under key %s (0x%08x)\n", debugstr_w(padid->pszDriverAlias), debugstr_w(basePriorityKey), lError); @@ -718,12 +720,12 @@ void MSACM_WriteCurrentPriorities(void)
/* Build required value name */ dwPriorityCounter++; - snprintfW(szSubKey, 17, priorityTmpl, dwPriorityCounter); + swprintf(szSubKey, priorityTmpl, dwPriorityCounter);
/* Value has a 1 in front for enabled drivers and 0 for disabled drivers */ - snprintfW(szBuffer, 256, valueTmpl, '1', converterAlias); + swprintf(szBuffer, valueTmpl, '1', converterAlias);
- lError = RegSetValueExW(hPriorityKey, szSubKey, 0, REG_SZ, (BYTE *)szBuffer, (strlenW(szBuffer) + 1) * sizeof(WCHAR)); + lError = RegSetValueExW(hPriorityKey, szSubKey, 0, REG_SZ, (BYTE *)szBuffer, (lstrlenW(szBuffer) + 1) * sizeof(WCHAR)); if (lError != ERROR_SUCCESS) { ERR("unable to write value for %s under key %s (0x%08x)\n", debugstr_w(converterAlias), debugstr_w(basePriorityKey), lError); @@ -737,12 +739,17 @@ static PWINE_ACMLOCALDRIVER MSACM_pLastACMLocalDriver; static PWINE_ACMLOCALDRIVER MSACM_UnregisterLocalDriver(PWINE_ACMLOCALDRIVER paldrv) { PWINE_ACMLOCALDRIVER pNextACMLocalDriver; + LONG ref;
if (paldrv->pACMInstList) { ERR("local driver instances still present after closing all drivers - memory leak\n"); return NULL; }
+ ref = InterlockedDecrement(&paldrv->ref); + if (ref) + return paldrv; + if (paldrv == MSACM_pFirstACMLocalDriver) MSACM_pFirstACMLocalDriver = paldrv->pNextACMLocalDrv; if (paldrv == MSACM_pLastACMLocalDriver) @@ -883,7 +890,11 @@ PWINE_ACMLOCALDRIVER MSACM_RegisterLocalDriver(HMODULE hModule, DRIVERPROC lpDri /* look up previous instance of local driver module */ for (paldrv = MSACM_pFirstACMLocalDriver; paldrv; paldrv = paldrv->pNextACMLocalDrv) { - if (paldrv->hModule == hModule && paldrv->lpDrvProc == lpDriverProc) return paldrv; + if (paldrv->hModule == hModule && paldrv->lpDrvProc == lpDriverProc) + { + InterlockedIncrement(&paldrv->ref); + return paldrv; + } }
paldrv = HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMLOCALDRIVER)); @@ -892,6 +903,7 @@ PWINE_ACMLOCALDRIVER MSACM_RegisterLocalDriver(HMODULE hModule, DRIVERPROC lpDri paldrv->hModule = hModule; paldrv->lpDrvProc = lpDriverProc; paldrv->pACMInstList = NULL; + paldrv->ref = 1;
paldrv->pNextACMLocalDrv = NULL; paldrv->pPrevACMLocalDrv = MSACM_pLastACMLocalDriver; diff --git a/dll/win32/msacm32/pcmconverter.c b/dll/win32/msacm32/pcmconverter.c index dc10f11e7ad..d528a6d35fb 100644 --- a/dll/win32/msacm32/pcmconverter.c +++ b/dll/win32/msacm32/pcmconverter.c @@ -26,7 +26,6 @@ * embedded driver handling scheme in msacm32.dll which isn't done yet */
-#include "config.h"
#include <assert.h> #include <stdarg.h> diff --git a/dll/win32/msacm32/precomp.h b/dll/win32/msacm32/precomp.h index dae503337ba..6beb48616ee 100644 --- a/dll/win32/msacm32/precomp.h +++ b/dll/win32/msacm32/precomp.h @@ -2,8 +2,6 @@ #ifndef _WINEACM_PRECOMP_H #define _WINEACM_PRECOMP_H
-#include <wine/config.h> - #include <stdarg.h>
#define WIN32_NO_STATUS @@ -12,6 +10,5 @@ #include "wineacm.h"
#include <wine/debug.h> -#include <wine/unicode.h>
#endif /* !_WINEACM_PRECOMP_H */ diff --git a/dll/win32/msacm32/wineacm.h b/dll/win32/msacm32/wineacm.h index 37d639d2150..72f6cdb3e1b 100644 --- a/dll/win32/msacm32/wineacm.h +++ b/dll/win32/msacm32/wineacm.h @@ -55,6 +55,7 @@ typedef struct _WINE_ACMLOCALDRIVER PWINE_ACMLOCALDRIVERINST pACMInstList; PWINE_ACMLOCALDRIVER pNextACMLocalDrv; PWINE_ACMLOCALDRIVER pPrevACMLocalDrv; + LONG ref; } WINE_ACMLOCALDRIVER;
typedef struct _WINE_ACMLOCALDRIVERINST diff --git a/media/doc/README.WINE b/media/doc/README.WINE index 4cf3263f96c..6ef81693421 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -101,7 +101,7 @@ dll/win32/mlang # Synced to WineStaging-4.18 dll/win32/mmdevapi # Synced to WineStaging-4.18 dll/win32/mpr # Synced to WineStaging-4.18 dll/win32/mprapi # Synced to WineStaging-3.3 -dll/win32/msacm32 # Synced to WineStaging-4.0 +dll/win32/msacm32 # Synced to WineStaging-4.18 dll/win32/msacm32.drv # Synced to WineStaging-3.3 dll/win32/msadp32.acm # Synced to WineStaging-4.0 dll/win32/mscat32 # Synced to WineStaging-3.3