playsound.c 17.5 KB
Newer Older
1 2 3
/* -*- tab-width: 8; c-basic-offset: 4 -*- */

/*
4
 * MMSYSTEM functions
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
 *
 * Copyright 1993      Martin Ayotte
 *           1998-2002 Eric Pouech
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
21
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 23
 */

24
#include <stdarg.h>
25 26
#include <string.h>

27
#include "windef.h"
28
#include "winbase.h"
29
#include "mmsystem.h"
30 31 32 33
#include "wingdi.h"
#include "winuser.h"
#include "winreg.h"
#include "winemm.h"
34
#include "winternl.h"
35 36 37 38 39

#include "wine/debug.h"

WINE_DEFAULT_DEBUG_CHANNEL(winmm);

40 41 42 43 44 45 46
typedef struct tagWINE_PLAYSOUND
{
    unsigned                    bLoop : 1,
                                bAlloc : 1;
    LPCWSTR                     pszSound;
    HMODULE                     hMod;
    DWORD                       fdwSound;
47
    HWAVEOUT                    hWave;
48 49
} WINE_PLAYSOUND;

50
static WINE_PLAYSOUND *PlaySoundCurrent;
51
static BOOL bPlaySoundStop;
52

53 54 55 56 57 58 59 60 61
static HMMIO	get_mmioFromFile(LPCWSTR lpszName)
{
    HMMIO       ret;
    WCHAR       buf[256];
    LPWSTR      dummy;

    ret = mmioOpenW((LPWSTR)lpszName, NULL,
                    MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE);
    if (ret != 0) return ret;
62
    if (SearchPathW(NULL, lpszName, L".wav", ARRAY_SIZE(buf), buf, &dummy))
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
    {
        return mmioOpenW(buf, NULL,
                         MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE);
    }
    return 0;
}

static HMMIO	get_mmioFromProfile(UINT uFlags, LPCWSTR lpszName)
{
    WCHAR	str[128];
    LPWSTR	ptr;
    HMMIO  	hmmio;
    HKEY        hRegSnd, hRegApp, hScheme, hSnd;
    DWORD       err, type, count;

    TRACE("searching in SystemSound list for %s\n", debugstr_w(lpszName));
79
    GetProfileStringW(L"Sounds", lpszName, L"", str, ARRAY_SIZE(str));
80
    if (!*str)
81 82
    {
	if (uFlags & SND_NODEFAULT) goto next;
83
	GetProfileStringW(L"Sounds", L"Default", L"", str, ARRAY_SIZE(str));
84
	if (!*str) goto next;
85 86 87 88 89 90 91 92 93 94
    }
    for (ptr = str; *ptr && *ptr != ','; ptr++);
    if (*ptr) *ptr = 0;
    hmmio = mmioOpenW(str, NULL, MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE);
    if (hmmio != 0) return hmmio;
 next:
    /* we look up the registry under
     *      HKCU\AppEvents\Schemes\Apps\.Default
     *      HKCU\AppEvents\Schemes\Apps\<AppName>
     */
95
    if (RegOpenKeyW(HKEY_CURRENT_USER, L"AppEvents\\Schemes\\Apps", &hRegSnd) != 0) goto none;
96 97
    if (uFlags & SND_APPLICATION)
    {
98 99
        DWORD len;

100
        err = 1; /* error */
101 102
        len = GetModuleFileNameW(0, str, ARRAY_SIZE(str));
        if (len > 0 && len < ARRAY_SIZE(str))
103 104 105 106 107 108
        {
            for (ptr = str + lstrlenW(str) - 1; ptr >= str; ptr--)
            {
                if (*ptr == '.') *ptr = 0;
                if (*ptr == '\\')
                {
Mike McCormack's avatar
Mike McCormack committed
109
                    err = RegOpenKeyW(hRegSnd, ptr+1, &hRegApp);
110 111 112 113 114 115 116
                    break;
                }
            }
        }
    }
    else
    {
117
        err = RegOpenKeyW(hRegSnd, L".Default", &hRegApp);
118 119 120 121 122 123
    }
    RegCloseKey(hRegSnd);
    if (err != 0) goto none;
    err = RegOpenKeyW(hRegApp, lpszName, &hScheme);
    RegCloseKey(hRegApp);
    if (err != 0) goto none;
Mike McCormack's avatar
Mike McCormack committed
124
    /* what's the difference between .Current and .Default ? */
125
    err = RegOpenKeyW(hScheme, L".Default", &hSnd);
Mike McCormack's avatar
Mike McCormack committed
126 127
    if (err != 0)
    {
128
        err = RegOpenKeyW(hScheme, L".Current", &hSnd);
Mike McCormack's avatar
Mike McCormack committed
129 130 131 132
        RegCloseKey(hScheme);
        if (err != 0)
            goto none;
    }
133
    count = sizeof(str);
134 135 136 137 138 139
    err = RegQueryValueExW(hSnd, NULL, 0, &type, (LPBYTE)str, &count);
    RegCloseKey(hSnd);
    if (err != 0 || !*str) goto none;
    hmmio = mmioOpenW(str, NULL, MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE);
    if (hmmio) return hmmio;
 none:
140
    WARN("can't find SystemSound=%s !\n", debugstr_w(lpszName));
141 142 143 144 145 146
    return 0;
}

struct playsound_data
{
    HANDLE	hEvent;
147
    LONG	dwEventCount;
148 149 150
};

static void CALLBACK PlaySound_Callback(HWAVEOUT hwo, UINT uMsg,
151 152
					DWORD_PTR dwInstance,
					DWORD_PTR dwParam1, DWORD_PTR dwParam2)
153 154 155 156 157 158 159 160 161
{
    struct playsound_data*	s = (struct playsound_data*)dwInstance;

    switch (uMsg) {
    case WOM_OPEN:
    case WOM_CLOSE:
	break;
    case WOM_DONE:
	InterlockedIncrement(&s->dwEventCount);
162
	TRACE("Returning waveHdr=%Ix\n", dwParam1);
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
	SetEvent(s->hEvent);
	break;
    default:
	ERR("Unknown uMsg=%d\n", uMsg);
    }
}

static void PlaySound_WaitDone(struct playsound_data* s)
{
    for (;;) {
	if (InterlockedDecrement(&s->dwEventCount) >= 0) break;
	InterlockedIncrement(&s->dwEventCount);

	WaitForSingleObject(s->hEvent, INFINITE);
    }
}

static BOOL PlaySound_IsString(DWORD fdwSound, const void* psz)
{
    /* SND_RESOURCE is 0x40004 while
     * SND_MEMORY is 0x00004
     */
185
    switch (fdwSound & (SND_RESOURCE|SND_ALIAS_ID|SND_FILENAME))
186 187
    {
    case SND_RESOURCE:  return HIWORD(psz) != 0; /* by name or by ID ? */
188
    case SND_ALIAS_ID:
189
    case SND_MEMORY:    return FALSE;
190
    case SND_ALIAS:
191
    case SND_FILENAME:
192
    case SND_ALIAS|SND_FILENAME:
193 194 195 196 197 198 199
    case 0:             return TRUE;
    default:            FIXME("WTF\n"); return FALSE;
    }
}

static void     PlaySound_Free(WINE_PLAYSOUND* wps)
{
200
    EnterCriticalSection(&WINMM_cs);
201 202
    PlaySoundCurrent = NULL;
    SetEvent(psLastEvent);
203
    LeaveCriticalSection(&WINMM_cs);
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
    if (wps->bAlloc) HeapFree(GetProcessHeap(), 0, (void*)wps->pszSound);
    HeapFree(GetProcessHeap(), 0, wps);
}

static WINE_PLAYSOUND*  PlaySound_Alloc(const void* pszSound, HMODULE hmod,
                                        DWORD fdwSound, BOOL bUnicode)
{
    WINE_PLAYSOUND* wps;

    wps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*wps));
    if (!wps) return NULL;

    wps->hMod = hmod;
    wps->fdwSound = fdwSound;
    if (PlaySound_IsString(fdwSound, pszSound))
    {
        if (bUnicode)
        {
            if (fdwSound & SND_ASYNC)
            {
224 225 226 227
                LPWSTR sound = HeapAlloc(GetProcessHeap(), 0,
                                         (lstrlenW(pszSound)+1) * sizeof(WCHAR));
                if (!sound) goto oom_error;
                wps->pszSound = lstrcpyW(sound, pszSound);
228 229 230 231 232 233 234
                wps->bAlloc = TRUE;
            }
            else
                wps->pszSound = pszSound;
        }
        else
        {
235 236 237
            UNICODE_STRING usBuffer;
            RtlCreateUnicodeStringFromAsciiz(&usBuffer, pszSound);
            wps->pszSound = usBuffer.Buffer;
238 239 240 241 242 243 244 245 246
            if (!wps->pszSound) goto oom_error;
            wps->bAlloc = TRUE;
        }
    }
    else
        wps->pszSound = pszSound;

    return wps;
 oom_error:
247 248
    if (wps->bAlloc) HeapFree(GetProcessHeap(), 0, (void*)wps->pszSound);
    HeapFree(GetProcessHeap(), 0, wps);
249 250 251 252 253
    return NULL;
}

static DWORD WINAPI proc_PlaySound(LPVOID arg)
{
254
    WINE_PLAYSOUND*     wps = arg;
255 256 257 258 259
    BOOL		bRet = FALSE;
    HMMIO		hmmio = 0;
    MMCKINFO		ckMainRIFF;
    MMCKINFO        	mmckInfo;
    LPWAVEFORMATEX      lpWaveFormat = NULL;
260
    HWAVEOUT		hWave = 0;
261 262 263 264
    LPWAVEHDR		waveHdr = NULL;
    INT			count, bufsize, left, index;
    struct playsound_data	s;
    void*               data;
265
    LONG                r;
266 267 268

    s.hEvent = 0;

269
    TRACE("SoundName=%s !\n", debugstr_w(wps->pszSound));
270 271 272 273 274 275

    /* if resource, grab it */
    if ((wps->fdwSound & SND_RESOURCE) == SND_RESOURCE) {
        HRSRC	hRes;
        HGLOBAL	hGlob;

276
        if ((hRes = FindResourceW(wps->hMod, wps->pszSound, L"WAVE")) == 0 ||
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293
            (hGlob = LoadResource(wps->hMod, hRes)) == 0)
            goto errCleanUp;
        if ((data = LockResource(hGlob)) == NULL) {
            FreeResource(hGlob);
            goto errCleanUp;
        }
        FreeResource(hGlob);
    } else
        data = (void*)wps->pszSound;

    /* construct an MMIO stream (either in memory, or from a file */
    if (wps->fdwSound & SND_MEMORY)
    { /* NOTE: SND_RESOURCE has the SND_MEMORY bit set */
	MMIOINFO	mminfo;

	memset(&mminfo, 0, sizeof(mminfo));
	mminfo.fccIOProc = FOURCC_MEM;
294
	mminfo.pchBuffer = data;
295 296 297 298
	mminfo.cchBuffer = -1; /* FIXME: when a resource, could grab real size */
	TRACE("Memory sound %p\n", data);
	hmmio = mmioOpenW(NULL, &mminfo, MMIO_READ);
    }
299
    if (!hmmio && wps->fdwSound & SND_ALIAS)
300
    {
301
        if ((wps->fdwSound & SND_ALIAS_ID) == SND_ALIAS_ID)
302 303 304
        {
            wps->fdwSound &= ~(SND_ALIAS_ID ^ SND_ALIAS);
            if (wps->pszSound == (LPCWSTR)SND_ALIAS_SYSTEMASTERISK)
305
                wps->pszSound = L"SystemAsterisk";
306
            else if (wps->pszSound == (LPCWSTR)SND_ALIAS_SYSTEMDEFAULT)
307
                wps->pszSound = L"SystemDefault";
308
            else if (wps->pszSound == (LPCWSTR)SND_ALIAS_SYSTEMEXCLAMATION)
309
                wps->pszSound = L"SystemExclamation";
310
            else if (wps->pszSound == (LPCWSTR)SND_ALIAS_SYSTEMEXIT)
311
                wps->pszSound = L"SystemExit";
312
            else if (wps->pszSound == (LPCWSTR)SND_ALIAS_SYSTEMHAND)
313
                wps->pszSound = L"SystemHand";
314
            else if (wps->pszSound == (LPCWSTR)SND_ALIAS_SYSTEMQUESTION)
315
                wps->pszSound = L"SystemQuestion";
316
            else if (wps->pszSound == (LPCWSTR)SND_ALIAS_SYSTEMSTART)
317
                wps->pszSound = L"SystemStart";
318
            else if (wps->pszSound == (LPCWSTR)SND_ALIAS_SYSTEMWELCOME)
319
                wps->pszSound = L"SystemWelcome";
320
            else goto errCleanUp;
321
        }
322
        hmmio = get_mmioFromProfile(wps->fdwSound, wps->pszSound);
323 324 325 326 327
        if (!hmmio)
        {
            wps->fdwSound &= ~SND_ALIAS;
            wps->fdwSound |= SND_FILENAME;
        }
328
    }
329
    if (!hmmio && wps->fdwSound & SND_FILENAME)
330 331 332
    {
        hmmio = get_mmioFromFile(wps->pszSound);
    }
333
    if (!(wps->fdwSound & (SND_FILENAME|SND_ALIAS|SND_MEMORY)))
334 335 336 337 338 339 340 341 342 343 344 345 346 347
    {
        if ((hmmio = get_mmioFromProfile(wps->fdwSound | SND_NODEFAULT, wps->pszSound)) == 0)
        {
            if ((hmmio = get_mmioFromFile(wps->pszSound)) == 0)
            {
                hmmio = get_mmioFromProfile(wps->fdwSound, wps->pszSound);
            }
        }
    }
    if (hmmio == 0) goto errCleanUp;

    if (mmioDescend(hmmio, &ckMainRIFF, NULL, 0))
	goto errCleanUp;

348
    TRACE("ParentChunk ckid=%.4s fccType=%.4s cksize=%08lX\n",
349 350 351 352 353 354 355 356 357 358
	  (LPSTR)&ckMainRIFF.ckid, (LPSTR)&ckMainRIFF.fccType, ckMainRIFF.cksize);

    if ((ckMainRIFF.ckid != FOURCC_RIFF) ||
	(ckMainRIFF.fccType != mmioFOURCC('W', 'A', 'V', 'E')))
	goto errCleanUp;

    mmckInfo.ckid = mmioFOURCC('f', 'm', 't', ' ');
    if (mmioDescend(hmmio, &mmckInfo, &ckMainRIFF, MMIO_FINDCHUNK))
	goto errCleanUp;

359
    TRACE("Chunk Found ckid=%.4s fccType=%08lx cksize=%08lX\n",
360
	  (LPSTR)&mmckInfo.ckid, mmckInfo.fccType, mmckInfo.cksize);
361 362

    lpWaveFormat = HeapAlloc(GetProcessHeap(), 0, mmckInfo.cksize);
363 364
    if (!lpWaveFormat)
	goto errCleanUp;
365 366
    r = mmioRead(hmmio, (HPSTR)lpWaveFormat, mmckInfo.cksize);
    if (r < 0 || r < sizeof(PCMWAVEFORMAT))
367 368 369
	goto errCleanUp;

    TRACE("wFormatTag=%04X !\n", 	lpWaveFormat->wFormatTag);
370
    TRACE("nChannels=%d\n", 		lpWaveFormat->nChannels);
371 372
    TRACE("nSamplesPerSec=%ld\n", 	lpWaveFormat->nSamplesPerSec);
    TRACE("nAvgBytesPerSec=%ld\n", 	lpWaveFormat->nAvgBytesPerSec);
373
    TRACE("nBlockAlign=%d\n", 		lpWaveFormat->nBlockAlign);
374 375 376 377 378 379 380 381 382
    TRACE("wBitsPerSample=%u !\n", 	lpWaveFormat->wBitsPerSample);

    /* move to end of 'fmt ' chunk */
    mmioAscend(hmmio, &mmckInfo, 0);

    mmckInfo.ckid = mmioFOURCC('d', 'a', 't', 'a');
    if (mmioDescend(hmmio, &mmckInfo, &ckMainRIFF, MMIO_FINDCHUNK))
	goto errCleanUp;

383
    TRACE("Chunk Found ckid=%.4s fccType=%08lx cksize=%08lX\n",
384
	  (LPSTR)&mmckInfo.ckid, mmckInfo.fccType, mmckInfo.cksize);
385

386
    s.hEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
387
    if (!s.hEvent || bPlaySoundStop)
388
	goto errCleanUp;
389

390
    if (waveOutOpen(&hWave, WAVE_MAPPER, lpWaveFormat, (DWORD_PTR)PlaySound_Callback,
391
		    (DWORD_PTR)&s, CALLBACK_FUNCTION) != MMSYSERR_NOERROR)
392 393 394 395 396 397
	goto errCleanUp;

    /* make it so that 3 buffers per second are needed */
    bufsize = (((lpWaveFormat->nAvgBytesPerSec / 3) - 1) / lpWaveFormat->nBlockAlign + 1) *
	lpWaveFormat->nBlockAlign;
    waveHdr = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(WAVEHDR) + 2 * bufsize);
398 399
    if (!waveHdr)
	goto errCleanUp;
400 401 402 403 404 405
    waveHdr[0].lpData = (char*)waveHdr + 2 * sizeof(WAVEHDR);
    waveHdr[1].lpData = (char*)waveHdr + 2 * sizeof(WAVEHDR) + bufsize;
    waveHdr[0].dwUser = waveHdr[1].dwUser = 0L;
    waveHdr[0].dwLoops = waveHdr[1].dwLoops = 0L;
    waveHdr[0].dwFlags = waveHdr[1].dwFlags = 0L;
    waveHdr[0].dwBufferLength = waveHdr[1].dwBufferLength = bufsize;
406 407
    if (waveOutPrepareHeader(hWave, &waveHdr[0], sizeof(WAVEHDR)) ||
	waveOutPrepareHeader(hWave, &waveHdr[1], sizeof(WAVEHDR))) {
408 409 410
	goto errCleanUp;
    }

411
    wps->hWave = hWave;
412
    s.dwEventCount = 1L; /* for first buffer */
413
    index = 0;
414 415 416 417 418 419 420

    do {
	left = mmckInfo.cksize;

	mmioSeek(hmmio, mmckInfo.dwDataOffset, SEEK_SET);
	while (left)
        {
421
	    if (bPlaySoundStop)
422 423 424 425 426 427 428 429
            {
		wps->bLoop = FALSE;
		break;
	    }
	    count = mmioRead(hmmio, waveHdr[index].lpData, min(bufsize, left));
	    if (count < 1) break;
	    left -= count;
	    waveHdr[index].dwBufferLength = count;
430
	    if (waveOutWrite(hWave, &waveHdr[index], sizeof(WAVEHDR)) == MMSYSERR_NOERROR) {
431 432 433
                index ^= 1;
                PlaySound_WaitDone(&s);
            }
434 435 436 437 438
            else {
		ERR("Aborting play loop, waveOutWrite error\n");
		wps->bLoop = FALSE;
		break;
	    }
439 440 441 442
	}
	bRet = TRUE;
    } while (wps->bLoop);

443
    PlaySound_WaitDone(&s); /* to balance first buffer */
444
    waveOutReset(hWave);
445

446 447
    waveOutUnprepareHeader(hWave, &waveHdr[0], sizeof(WAVEHDR));
    waveOutUnprepareHeader(hWave, &waveHdr[1], sizeof(WAVEHDR));
448 449

errCleanUp:
450
    TRACE("Done playing=%s => %s!\n", debugstr_w(wps->pszSound), bRet ? "ok" : "ko");
451
    HeapFree(GetProcessHeap(), 0, lpWaveFormat);
452 453 454 455 456 457 458 459 460
    if (hWave)
    {
        EnterCriticalSection(&WINMM_cs);
        /* the CS prevents a concurrent waveOutReset */
        wps->hWave = 0;
        LeaveCriticalSection(&WINMM_cs);
        while (waveOutClose(hWave) == WAVERR_STILLPLAYING)
            Sleep(100);
    }
461 462
    CloseHandle(s.hEvent);
    HeapFree(GetProcessHeap(), 0, waveHdr);
463 464 465 466 467 468 469
    if (hmmio) 		mmioClose(hmmio, 0);

    PlaySound_Free(wps);

    return bRet;
}

470
static BOOL MULTIMEDIA_PlaySound(const void* pszSound, HMODULE hmod, DWORD fdwSound, BOOL bUnicode)
471 472 473
{
    WINE_PLAYSOUND*     wps = NULL;

474
    TRACE("pszSound='%p' hmod=%p fdwSound=%08lX\n",
475 476
	  pszSound, hmod, fdwSound);

477
    /* SND_NOWAIT is ignored in w95/2k/xp. */
478
    if ((fdwSound & SND_NOSTOP) && PlaySoundCurrent != NULL)
479 480 481 482 483 484 485 486 487
	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;
    }

488
    EnterCriticalSection(&WINMM_cs);
489 490 491
    /* since several threads can enter PlaySound in parallel, we're not
     * sure, at this point, that another thread didn't start a new playsound
     */
492
    while (PlaySoundCurrent != NULL)
493
    {
494
        ResetEvent(psLastEvent);
495 496
        /* FIXME: doc says we have to stop all instances of pszSound if it's non
         * NULL... as of today, we stop all playing instances */
497
        bPlaySoundStop = TRUE;
498 499
        if(PlaySoundCurrent->hWave)
            waveOutReset(PlaySoundCurrent->hWave);
500

501 502 503
        LeaveCriticalSection(&WINMM_cs);
        WaitForSingleObject(psLastEvent, INFINITE);
        EnterCriticalSection(&WINMM_cs);
504

505
        bPlaySoundStop = FALSE;
506 507
    }

508
    PlaySoundCurrent = wps;
509
    LeaveCriticalSection(&WINMM_cs);
510

511
    if (!wps) return TRUE;
512 513 514

    if (fdwSound & SND_ASYNC)
    {
Robert Reif's avatar
Robert Reif committed
515
        HANDLE      handle;
516
        wps->bLoop = (fdwSound & SND_LOOP) != 0;
517
        if ((handle = CreateThread(NULL, 0, proc_PlaySound, wps, 0, NULL)) != 0) {
518
            SetThreadPriority(handle, THREAD_PRIORITY_TIME_CRITICAL);
519
            CloseHandle(handle);
520
            return TRUE;
Robert Reif's avatar
Robert Reif committed
521
        }
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550
    }
    else return proc_PlaySound(wps);

    /* error cases */
    PlaySound_Free(wps);
    return FALSE;
}

/**************************************************************************
 * 				PlaySoundA		[WINMM.@]
 */
BOOL WINAPI PlaySoundA(LPCSTR pszSoundA, HMODULE hmod, DWORD fdwSound)
{
    return MULTIMEDIA_PlaySound(pszSoundA, hmod, fdwSound, FALSE);
}

/**************************************************************************
 * 				PlaySoundW		[WINMM.@]
 */
BOOL WINAPI PlaySoundW(LPCWSTR pszSoundW, HMODULE hmod, DWORD fdwSound)
{
    return MULTIMEDIA_PlaySound(pszSoundW, hmod, fdwSound, TRUE);
}

/**************************************************************************
 * 				sndPlaySoundA		[WINMM.@]
 */
BOOL WINAPI sndPlaySoundA(LPCSTR pszSoundA, UINT uFlags)
{
551
    uFlags &= SND_RESOURCE|SND_ALIAS_ID|SND_FILENAME|SND_ASYNC|SND_LOOP|SND_MEMORY|SND_NODEFAULT|SND_NOSTOP|SND_SYNC;
552 553 554 555 556 557 558 559
    return MULTIMEDIA_PlaySound(pszSoundA, 0, uFlags, FALSE);
}

/**************************************************************************
 * 				sndPlaySoundW		[WINMM.@]
 */
BOOL WINAPI sndPlaySoundW(LPCWSTR pszSound, UINT uFlags)
{
560
    uFlags &= SND_RESOURCE|SND_ALIAS_ID|SND_FILENAME|SND_ASYNC|SND_LOOP|SND_MEMORY|SND_NODEFAULT|SND_NOSTOP|SND_SYNC;
561 562 563 564 565 566 567 568 569 570 571
    return MULTIMEDIA_PlaySound(pszSound, 0, uFlags, TRUE);
}

/**************************************************************************
 * 				mmsystemGetVersion	[WINMM.@]
 */
UINT WINAPI mmsystemGetVersion(void)
{
    TRACE("3.10 (Win95?)\n");
    return 0x030a;
}