wine/dlls/winmm mmsystem.c winemm.h
Eric Pouech
eric.pouech at wanadoo.fr
Thu May 16 15:03:17 CDT 2002
Eric Pouech a écrit :
oops the last hunk of the patch isn't part of the patch
so Alexandre, please use this file instead
A+
-------------- next part --------------
Name: ps_a2w
ChangeLog: fixed hangs when playing an ASCII resource
License: X11
GenDate: 2002/05/16 19:48:36 UTC
ModifiedFiles: dlls/winmm/mmsystem.c
AddedFiles:
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/dlls/winmm/mmsystem.c,v
retrieving revision 1.52
diff -u -u -r1.52 mmsystem.c
--- dlls/winmm/mmsystem.c 12 May 2002 03:10:26 -0000 1.52
+++ dlls/winmm/mmsystem.c 16 May 2002 19:39:46 -0000
@@ -447,6 +447,7 @@
waveOutUnprepareHeader(hWave, &waveHdr[1], sizeof(WAVEHDR));
errCleanUp:
+ TRACE("Done playing='%s' !\n", debugstr_w(wps->pszSound));
CloseHandle(s.hEvent);
HeapFree(GetProcessHeap(), 0, waveHdr);
HeapFree(GetProcessHeap(), 0, lpWaveFormat);
@@ -463,6 +464,21 @@
return bRet;
}
+static BOOL MULTIMEDIA_IsString(DWORD fdwSound, const void* psz)
+{
+ /* SND_RESOURCE is 0x40004 while
+ * SND_MEMORY is 0x00004
+ */
+ switch (fdwSound & SND_RESOURCE)
+ {
+ case SND_RESOURCE: return HIWORD(psz) != 0; /* by name or by ID ? */
+ case SND_MEMORY: return FALSE;
+ /* any other case (SND_ALIAS, SND_FILENAME... shall drop into this one) */
+ case 0: return TRUE;
+ default: FIXME("WTF\n"); return FALSE;
+ }
+}
+
static BOOL MULTIMEDIA_PlaySound(LPCWSTR pszSound, HMODULE hmod, DWORD fdwSound, DWORD search)
{
WINE_PLAYSOUND* wps = NULL;
@@ -515,10 +531,9 @@
} while (InterlockedCompareExchangePointer((void**)&iData->lpPlaySound, wps, NULL) != NULL);
if (fdwSound & SND_ASYNC) {
- if (!((fdwSound & SND_MEMORY) || ((fdwSound & SND_RESOURCE) &&
- !((DWORD)pszSound >> 16)) ||
- !pszSound)) {
- wps->pszSound = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(pszSound)+1) * sizeof(WCHAR) );
+ if (MULTIMEDIA_IsString(fdwSound, pszSound))
+ {
+ wps->pszSound = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(pszSound)+1) * sizeof(WCHAR));
lstrcpyW((LPWSTR)wps->pszSound, pszSound);
}
wps->bLoop = fdwSound & SND_LOOP;
@@ -541,16 +556,13 @@
{
LPWSTR pszSoundW;
BOOL bSound;
+
+ pszSoundW = (MULTIMEDIA_IsString(fdwSound, pszSoundA)) ?
+ HEAP_strdupAtoW(GetProcessHeap(), 0, pszSoundA) : (LPWSTR)pszSoundA;
- if (!((fdwSound & SND_MEMORY) ||
- ((fdwSound & SND_RESOURCE) && !((DWORD)pszSoundA >> 16)) ||
- !pszSoundA)) {
- pszSoundW = HEAP_strdupAtoW(GetProcessHeap(), 0, pszSoundA);
- bSound = PlaySoundW(pszSoundW, hmod, fdwSound);
- HeapFree(GetProcessHeap(), 0, pszSoundW);
- } else
- bSound = PlaySoundW((LPWSTR)pszSoundA, hmod, fdwSound);
-
+ bSound = PlaySoundW(pszSoundW, hmod, fdwSound);
+ if ((void*)pszSoundW != (void*)pszSoundA) HeapFree(GetProcessHeap(), 0, pszSoundW);
+
return bSound;
}
@@ -585,14 +597,12 @@
LPWSTR pszSoundW;
BOOL bSound;
- if (!((uFlags & SND_MEMORY) ||
- ((uFlags & SND_RESOURCE) && !((DWORD)pszSoundA >> 16)) ||
- !pszSoundA)) {
- pszSoundW = HEAP_strdupAtoW(GetProcessHeap(), 0, pszSoundA);
- bSound = sndPlaySoundW(pszSoundW, uFlags);
+ pszSoundW = (MULTIMEDIA_IsString(uFlags, pszSoundA)) ?
+ HEAP_strdupAtoW(GetProcessHeap(), 0, pszSoundA) : (LPWSTR)pszSoundA;
+
+ bSound = sndPlaySoundW(pszSoundW, uFlags);
+ if ((void*)pszSoundW != (void*)pszSoundA)
HeapFree(GetProcessHeap(), 0, pszSoundW);
- } else
- bSound = sndPlaySoundW((LPWSTR)pszSoundA, uFlags);
return bSound;
}
More information about the wine-patches
mailing list