static BOOL MULTIMEDIA_PlaySound(const void* pszSound, HMODULE hmod, DWORD fdwSound, BOOL bUnicode) { WINE_PLAYSOUND* wps = NULL; TRACE("pszSound='%p' hmod=%p fdwSound=%08X\n", pszSound, hmod, fdwSound); /* SND_NOWAIT is ignored in w95/2k/xp. */ if ((fdwSound & SND_NOSTOP) && PlaySoundCurrent != NULL) return FALSE; /* alloc internal structure, if we need to play something */ if (pszSound && !(fdwSound & SND_PURGE)) { if (!(wps = PlaySound_Alloc(pszSound, hmod, fdwSound, bUnicode))) return FALSE; } EnterCriticalSection(&WINMM_cs); /* since several threads can enter PlaySound in parallel, we're not * sure, at this point, that another thread didn't start a new playsound */ while (PlaySoundCurrent != NULL) { ResetEvent(psLastEvent); /* FIXME: doc says we have to stop all instances of pszSound if it's non * NULL... as of today, we stop all playing instances */ bPlaySoundStop = TRUE; if(PlaySoundCurrent->hWave) waveOutReset(PlaySoundCurrent->hWave); LeaveCriticalSection(&WINMM_cs); WaitForSingleObject(psLastEvent, INFINITE); EnterCriticalSection(&WINMM_cs); bPlaySoundStop = FALSE; } PlaySoundCurrent = wps; LeaveCriticalSection(&WINMM_cs); if (!wps) return TRUE; if (fdwSound & SND_ASYNC) { HANDLE handle; wps->bLoop = (fdwSound & SND_LOOP) != 0; if ((handle = CreateThread(NULL, 0, proc_PlaySound, wps, 0, NULL)) != 0) { SetThreadPriority(handle, THREAD_PRIORITY_TIME_CRITICAL); CloseHandle(handle); return TRUE; } } else return proc_PlaySound(wps); /* error cases */ PlaySound_Free(wps); return FALSE; }
static BOOL MULTIMEDIA_PlaySound(const void* pszSound, HMODULE hmod, DWORD fdwSound, BOOL bUnicode) { WINE_PLAYSOUND* wps = NULL; TRACE("pszSound='%p' hmod=%p fdwSound=%08X\n", pszSound, hmod, fdwSound); /* FIXME? I see no difference between SND_NOWAIT and SND_NOSTOP ! * there could be one if several sounds can be played at once... */ if ((fdwSound & (SND_NOWAIT | SND_NOSTOP)) && PlaySoundList != NULL) return FALSE; /* alloc internal structure, if we need to play something */ if (pszSound && !(fdwSound & SND_PURGE)) { if (!(wps = PlaySound_Alloc(pszSound, hmod, fdwSound, bUnicode))) return FALSE; } EnterCriticalSection(&WINMM_cs); /* since several threads can enter PlaySound in parallel, we're not * sure, at this point, that another thread didn't start a new playsound */ while (PlaySoundList != NULL) { ResetEvent(psLastEvent); /* FIXME: doc says we have to stop all instances of pszSound if it's non * NULL... as of today, we stop all playing instances */ SetEvent(psStopEvent); waveOutReset(PlaySoundList->hWave); LeaveCriticalSection(&WINMM_cs); WaitForSingleObject(psLastEvent, INFINITE); EnterCriticalSection(&WINMM_cs); ResetEvent(psStopEvent); } if (wps) wps->lpNext = PlaySoundList; PlaySoundList = wps; LeaveCriticalSection(&WINMM_cs); if (!pszSound || (fdwSound & SND_PURGE)) return TRUE; if (fdwSound & SND_ASYNC) { DWORD id; HANDLE handle; wps->bLoop = (fdwSound & SND_LOOP) ? TRUE : FALSE; if ((handle = CreateThread(NULL, 0, proc_PlaySound, wps, 0, &id)) != 0) { wps->hThread = handle; SetThreadPriority(handle, THREAD_PRIORITY_TIME_CRITICAL); return TRUE; } } else return proc_PlaySound(wps); /* error cases */ PlaySound_Free(wps); return FALSE; }