wined3d: Pack hardcoded local constants in ARB.
[wine] / dlls / winmm / playsound.c
1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
2
3 /*
4  * MMSYSTEM functions
5  *
6  * Copyright 1993      Martin Ayotte
7  *           1998-2002 Eric Pouech
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * 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 #include <string.h>
26
27 #include "windef.h"
28 #include "winbase.h"
29 #include "mmsystem.h"
30 #include "wingdi.h"
31 #include "winuser.h"
32 #include "winreg.h"
33 #include "winemm.h"
34 #include "winternl.h"
35
36 #include "wine/debug.h"
37
38 WINE_DEFAULT_DEBUG_CHANNEL(winmm);
39
40 typedef struct tagWINE_PLAYSOUND
41 {
42     unsigned                    bLoop : 1,
43                                 bAlloc : 1;
44     LPCWSTR                     pszSound;
45     HMODULE                     hMod;
46     DWORD                       fdwSound;
47     HANDLE                      hThread;
48     HWAVEOUT                    hWave;
49     struct tagWINE_PLAYSOUND*   lpNext;
50 } WINE_PLAYSOUND;
51
52 static WINE_PLAYSOUND *PlaySoundList;
53
54 static HMMIO    get_mmioFromFile(LPCWSTR lpszName)
55 {
56     HMMIO       ret;
57     WCHAR       buf[256];
58     LPWSTR      dummy;
59
60     ret = mmioOpenW((LPWSTR)lpszName, NULL,
61                     MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE);
62     if (ret != 0) return ret;
63     if (SearchPathW(NULL, lpszName, NULL, sizeof(buf)/sizeof(buf[0]), buf, &dummy))
64     {
65         return mmioOpenW(buf, NULL,
66                          MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE);
67     }
68     return 0;
69 }
70
71 static HMMIO    get_mmioFromProfile(UINT uFlags, LPCWSTR lpszName)
72 {
73     WCHAR       str[128];
74     LPWSTR      ptr;
75     HMMIO       hmmio;
76     HKEY        hRegSnd, hRegApp, hScheme, hSnd;
77     DWORD       err, type, count;
78
79     static const WCHAR  wszSounds[] = {'S','o','u','n','d','s',0};
80     static const WCHAR  wszDefault[] = {'D','e','f','a','u','l','t',0};
81     static const WCHAR  wszKey[] = {'A','p','p','E','v','e','n','t','s','\\',
82                                     'S','c','h','e','m','e','s','\\',
83                                     'A','p','p','s',0};
84     static const WCHAR  wszDotDefault[] = {'.','D','e','f','a','u','l','t',0};
85     static const WCHAR  wszDotCurrent[] = {'.','C','u','r','r','e','n','t',0};
86     static const WCHAR  wszNull[] = {0};
87
88     TRACE("searching in SystemSound list for %s\n", debugstr_w(lpszName));
89     GetProfileStringW(wszSounds, lpszName, wszNull, str, sizeof(str)/sizeof(str[0]));
90     if (lstrlenW(str) == 0)
91     {
92         if (uFlags & SND_NODEFAULT) goto next;
93         GetProfileStringW(wszSounds, wszDefault, wszNull, str, sizeof(str)/sizeof(str[0]));
94         if (lstrlenW(str) == 0) goto next;
95     }
96     for (ptr = str; *ptr && *ptr != ','; ptr++);
97     if (*ptr) *ptr = 0;
98     hmmio = mmioOpenW(str, NULL, MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE);
99     if (hmmio != 0) return hmmio;
100  next:
101     /* we look up the registry under
102      *      HKCU\AppEvents\Schemes\Apps\.Default
103      *      HKCU\AppEvents\Schemes\Apps\<AppName>
104      */
105     if (RegOpenKeyW(HKEY_CURRENT_USER, wszKey, &hRegSnd) != 0) goto none;
106     if (uFlags & SND_APPLICATION)
107     {
108         DWORD len;
109
110         err = 1; /* error */
111         len = GetModuleFileNameW(0, str, sizeof(str)/sizeof(str[0]));
112         if (len > 0 && len < sizeof(str)/sizeof(str[0]))
113         {
114             for (ptr = str + lstrlenW(str) - 1; ptr >= str; ptr--)
115             {
116                 if (*ptr == '.') *ptr = 0;
117                 if (*ptr == '\\')
118                 {
119                     err = RegOpenKeyW(hRegSnd, ptr+1, &hRegApp);
120                     break;
121                 }
122             }
123         }
124     }
125     else
126     {
127         err = RegOpenKeyW(hRegSnd, wszDotDefault, &hRegApp);
128     }
129     RegCloseKey(hRegSnd);
130     if (err != 0) goto none;
131     err = RegOpenKeyW(hRegApp, lpszName, &hScheme);
132     RegCloseKey(hRegApp);
133     if (err != 0) goto none;
134     /* what's the difference between .Current and .Default ? */
135     err = RegOpenKeyW(hScheme, wszDotDefault, &hSnd);
136     if (err != 0)
137     {
138         err = RegOpenKeyW(hScheme, wszDotCurrent, &hSnd);
139         RegCloseKey(hScheme);
140         if (err != 0)
141             goto none;
142     }
143     count = sizeof(str)/sizeof(str[0]);
144     err = RegQueryValueExW(hSnd, NULL, 0, &type, (LPBYTE)str, &count);
145     RegCloseKey(hSnd);
146     if (err != 0 || !*str) goto none;
147     hmmio = mmioOpenW(str, NULL, MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE);
148     if (hmmio) return hmmio;
149  none:
150     WARN("can't find SystemSound=%s !\n", debugstr_w(lpszName));
151     return 0;
152 }
153
154 struct playsound_data
155 {
156     HANDLE      hEvent;
157     LONG        dwEventCount;
158 };
159
160 static void CALLBACK PlaySound_Callback(HWAVEOUT hwo, UINT uMsg,
161                                         DWORD dwInstance,
162                                         DWORD dwParam1, DWORD dwParam2)
163 {
164     struct playsound_data*      s = (struct playsound_data*)dwInstance;
165
166     switch (uMsg) {
167     case WOM_OPEN:
168     case WOM_CLOSE:
169         break;
170     case WOM_DONE:
171         InterlockedIncrement(&s->dwEventCount);
172         TRACE("Returning waveHdr=%x\n", dwParam1);
173         SetEvent(s->hEvent);
174         break;
175     default:
176         ERR("Unknown uMsg=%d\n", uMsg);
177     }
178 }
179
180 static void PlaySound_WaitDone(struct playsound_data* s)
181 {
182     for (;;) {
183         ResetEvent(s->hEvent);
184         if (InterlockedDecrement(&s->dwEventCount) >= 0) break;
185         InterlockedIncrement(&s->dwEventCount);
186
187         WaitForSingleObject(s->hEvent, INFINITE);
188     }
189 }
190
191 static BOOL PlaySound_IsString(DWORD fdwSound, const void* psz)
192 {
193     /* SND_RESOURCE is 0x40004 while
194      * SND_MEMORY is 0x00004
195      */
196     switch (fdwSound & (SND_RESOURCE|SND_ALIAS_ID|SND_FILENAME))
197     {
198     case SND_RESOURCE:  return HIWORD(psz) != 0; /* by name or by ID ? */
199     case SND_ALIAS_ID:
200     case SND_MEMORY:    return FALSE;
201     case SND_ALIAS:
202     case SND_FILENAME:
203     case 0:             return TRUE;
204     default:            FIXME("WTF\n"); return FALSE;
205     }
206 }
207
208 static void     PlaySound_Free(WINE_PLAYSOUND* wps)
209 {
210     WINE_PLAYSOUND**    p;
211
212     EnterCriticalSection(&WINMM_cs);
213     for (p = &PlaySoundList; *p && *p != wps; p = &((*p)->lpNext));
214     if (*p) *p = (*p)->lpNext;
215     if (PlaySoundList == NULL) SetEvent(psLastEvent);
216     LeaveCriticalSection(&WINMM_cs);
217     if (wps->bAlloc) HeapFree(GetProcessHeap(), 0, (void*)wps->pszSound);
218     if (wps->hThread) CloseHandle(wps->hThread);
219     HeapFree(GetProcessHeap(), 0, wps);
220 }
221
222 static WINE_PLAYSOUND*  PlaySound_Alloc(const void* pszSound, HMODULE hmod,
223                                         DWORD fdwSound, BOOL bUnicode)
224 {
225     WINE_PLAYSOUND* wps;
226
227     wps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*wps));
228     if (!wps) return NULL;
229
230     wps->hMod = hmod;
231     wps->fdwSound = fdwSound;
232     if (PlaySound_IsString(fdwSound, pszSound))
233     {
234         if (bUnicode)
235         {
236             if (fdwSound & SND_ASYNC)
237             {
238                 LPWSTR sound = HeapAlloc(GetProcessHeap(), 0,
239                                          (lstrlenW(pszSound)+1) * sizeof(WCHAR));
240                 if (!sound) goto oom_error;
241                 wps->pszSound = lstrcpyW(sound, pszSound);
242                 wps->bAlloc = TRUE;
243             }
244             else
245                 wps->pszSound = pszSound;
246         }
247         else
248         {
249             UNICODE_STRING usBuffer;
250             RtlCreateUnicodeStringFromAsciiz(&usBuffer, pszSound);
251             wps->pszSound = usBuffer.Buffer;
252             if (!wps->pszSound) goto oom_error;
253             wps->bAlloc = TRUE;
254         }
255     }
256     else
257         wps->pszSound = pszSound;
258
259     return wps;
260  oom_error:
261     PlaySound_Free(wps);
262     return NULL;
263 }
264
265 static DWORD WINAPI proc_PlaySound(LPVOID arg)
266 {
267     WINE_PLAYSOUND*     wps = arg;
268     BOOL                bRet = FALSE;
269     HMMIO               hmmio = 0;
270     MMCKINFO            ckMainRIFF;
271     MMCKINFO            mmckInfo;
272     LPWAVEFORMATEX      lpWaveFormat = NULL;
273     LPWAVEHDR           waveHdr = NULL;
274     INT                 count, bufsize, left, index;
275     struct playsound_data       s;
276     void*               data;
277
278     s.hEvent = 0;
279
280     TRACE("SoundName=%s !\n", debugstr_w(wps->pszSound));
281
282     /* if resource, grab it */
283     if ((wps->fdwSound & SND_RESOURCE) == SND_RESOURCE) {
284         static const WCHAR wszWave[] = {'W','A','V','E',0};
285         HRSRC   hRes;
286         HGLOBAL hGlob;
287
288         if ((hRes = FindResourceW(wps->hMod, wps->pszSound, wszWave)) == 0 ||
289             (hGlob = LoadResource(wps->hMod, hRes)) == 0)
290             goto errCleanUp;
291         if ((data = LockResource(hGlob)) == NULL) {
292             FreeResource(hGlob);
293             goto errCleanUp;
294         }
295         FreeResource(hGlob);
296     } else
297         data = (void*)wps->pszSound;
298
299     /* construct an MMIO stream (either in memory, or from a file */
300     if (wps->fdwSound & SND_MEMORY)
301     { /* NOTE: SND_RESOURCE has the SND_MEMORY bit set */
302         MMIOINFO        mminfo;
303
304         memset(&mminfo, 0, sizeof(mminfo));
305         mminfo.fccIOProc = FOURCC_MEM;
306         mminfo.pchBuffer = data;
307         mminfo.cchBuffer = -1; /* FIXME: when a resource, could grab real size */
308         TRACE("Memory sound %p\n", data);
309         hmmio = mmioOpenW(NULL, &mminfo, MMIO_READ);
310     }
311     else if (wps->fdwSound & SND_ALIAS)
312     {
313         if ((wps->fdwSound & SND_ALIAS_ID) == SND_ALIAS_ID)
314         {
315             static const WCHAR  wszSystemAsterisk[] = {'S','y','s','t','e','m','A','s','t','e','r','i','s','k',0};
316             static const WCHAR  wszSystemDefault[] = {'S','y','s','t','e','m','D','e','f','a','u','l','t',0};
317             static const WCHAR  wszSystemExclamation[] = {'S','y','s','t','e','m','E','x','c','l','a','m','a','t','i','o','n',0};
318             static const WCHAR  wszSystemExit[] = {'S','y','s','t','e','m','E','x','i','t',0};
319             static const WCHAR  wszSystemHand[] = {'S','y','s','t','e','m','H','a','n','d',0};
320             static const WCHAR  wszSystemQuestion[] = {'S','y','s','t','e','m','Q','u','e','s','t','i','o','n',0};
321             static const WCHAR  wszSystemStart[] = {'S','y','s','t','e','m','S','t','a','r','t',0};
322             static const WCHAR  wszSystemWelcome[] = {'S','y','s','t','e','m','W','e','l','c','o','m','e',0};
323
324             wps->fdwSound &= ~(SND_ALIAS_ID ^ SND_ALIAS);
325             if (wps->pszSound == (LPCWSTR)SND_ALIAS_SYSTEMASTERISK)
326                 wps->pszSound = wszSystemAsterisk;
327             else if (wps->pszSound == (LPCWSTR)SND_ALIAS_SYSTEMDEFAULT)
328                 wps->pszSound = wszSystemDefault;
329             else if (wps->pszSound == (LPCWSTR)SND_ALIAS_SYSTEMEXCLAMATION)
330                 wps->pszSound = wszSystemExclamation;
331             else if (wps->pszSound == (LPCWSTR)SND_ALIAS_SYSTEMEXIT)
332                 wps->pszSound = wszSystemExit;
333             else if (wps->pszSound == (LPCWSTR)SND_ALIAS_SYSTEMHAND)
334                 wps->pszSound = wszSystemHand;
335             else if (wps->pszSound == (LPCWSTR)SND_ALIAS_SYSTEMQUESTION)
336                 wps->pszSound = wszSystemQuestion;
337             else if (wps->pszSound == (LPCWSTR)SND_ALIAS_SYSTEMSTART)
338                 wps->pszSound = wszSystemStart;
339             else if (wps->pszSound == (LPCWSTR)SND_ALIAS_SYSTEMWELCOME)
340                 wps->pszSound = wszSystemWelcome;
341             else goto errCleanUp;
342         }
343         hmmio = get_mmioFromProfile(wps->fdwSound, wps->pszSound);
344     }
345     else if (wps->fdwSound & SND_FILENAME)
346     {
347         hmmio = get_mmioFromFile(wps->pszSound);
348     }
349     else
350     {
351         if ((hmmio = get_mmioFromProfile(wps->fdwSound | SND_NODEFAULT, wps->pszSound)) == 0)
352         {
353             if ((hmmio = get_mmioFromFile(wps->pszSound)) == 0)
354             {
355                 hmmio = get_mmioFromProfile(wps->fdwSound, wps->pszSound);
356             }
357         }
358     }
359     if (hmmio == 0) goto errCleanUp;
360
361     if (mmioDescend(hmmio, &ckMainRIFF, NULL, 0))
362         goto errCleanUp;
363
364     TRACE("ParentChunk ckid=%.4s fccType=%.4s cksize=%08X\n",
365           (LPSTR)&ckMainRIFF.ckid, (LPSTR)&ckMainRIFF.fccType, ckMainRIFF.cksize);
366
367     if ((ckMainRIFF.ckid != FOURCC_RIFF) ||
368         (ckMainRIFF.fccType != mmioFOURCC('W', 'A', 'V', 'E')))
369         goto errCleanUp;
370
371     mmckInfo.ckid = mmioFOURCC('f', 'm', 't', ' ');
372     if (mmioDescend(hmmio, &mmckInfo, &ckMainRIFF, MMIO_FINDCHUNK))
373         goto errCleanUp;
374
375     TRACE("Chunk Found ckid=%.4s fccType=%08x cksize=%08X\n",
376           (LPSTR)&mmckInfo.ckid, mmckInfo.fccType, mmckInfo.cksize);
377
378     lpWaveFormat = HeapAlloc(GetProcessHeap(), 0, mmckInfo.cksize);
379     if (mmioRead(hmmio, (HPSTR)lpWaveFormat, mmckInfo.cksize) < sizeof(WAVEFORMAT))
380         goto errCleanUp;
381
382     TRACE("wFormatTag=%04X !\n",        lpWaveFormat->wFormatTag);
383     TRACE("nChannels=%d\n",             lpWaveFormat->nChannels);
384     TRACE("nSamplesPerSec=%d\n",        lpWaveFormat->nSamplesPerSec);
385     TRACE("nAvgBytesPerSec=%d\n",       lpWaveFormat->nAvgBytesPerSec);
386     TRACE("nBlockAlign=%d\n",           lpWaveFormat->nBlockAlign);
387     TRACE("wBitsPerSample=%u !\n",      lpWaveFormat->wBitsPerSample);
388
389     /* move to end of 'fmt ' chunk */
390     mmioAscend(hmmio, &mmckInfo, 0);
391
392     mmckInfo.ckid = mmioFOURCC('d', 'a', 't', 'a');
393     if (mmioDescend(hmmio, &mmckInfo, &ckMainRIFF, MMIO_FINDCHUNK))
394         goto errCleanUp;
395
396     TRACE("Chunk Found ckid=%.4s fccType=%08x cksize=%08X\n",
397           (LPSTR)&mmckInfo.ckid, mmckInfo.fccType, mmckInfo.cksize);
398
399     s.hEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
400
401     if (waveOutOpen(&wps->hWave, WAVE_MAPPER, lpWaveFormat, (DWORD)PlaySound_Callback,
402                     (DWORD)&s, CALLBACK_FUNCTION) != MMSYSERR_NOERROR)
403         goto errCleanUp;
404
405     /* make it so that 3 buffers per second are needed */
406     bufsize = (((lpWaveFormat->nAvgBytesPerSec / 3) - 1) / lpWaveFormat->nBlockAlign + 1) *
407         lpWaveFormat->nBlockAlign;
408     waveHdr = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(WAVEHDR) + 2 * bufsize);
409     waveHdr[0].lpData = (char*)waveHdr + 2 * sizeof(WAVEHDR);
410     waveHdr[1].lpData = (char*)waveHdr + 2 * sizeof(WAVEHDR) + bufsize;
411     waveHdr[0].dwUser = waveHdr[1].dwUser = 0L;
412     waveHdr[0].dwLoops = waveHdr[1].dwLoops = 0L;
413     waveHdr[0].dwFlags = waveHdr[1].dwFlags = 0L;
414     waveHdr[0].dwBufferLength = waveHdr[1].dwBufferLength = bufsize;
415     if (waveOutPrepareHeader(wps->hWave, &waveHdr[0], sizeof(WAVEHDR)) ||
416         waveOutPrepareHeader(wps->hWave, &waveHdr[1], sizeof(WAVEHDR))) {
417         goto errCleanUp;
418     }
419
420     s.dwEventCount = 1L; /* for first buffer */
421     index = 0;
422
423     do {
424         left = mmckInfo.cksize;
425
426         mmioSeek(hmmio, mmckInfo.dwDataOffset, SEEK_SET);
427         while (left)
428         {
429             if (WaitForSingleObject(psStopEvent, 0) == WAIT_OBJECT_0)
430             {
431                 wps->bLoop = FALSE;
432                 break;
433             }
434             count = mmioRead(hmmio, waveHdr[index].lpData, min(bufsize, left));
435             if (count < 1) break;
436             left -= count;
437             waveHdr[index].dwBufferLength = count;
438             waveHdr[index].dwFlags &= ~WHDR_DONE;
439             if (waveOutWrite(wps->hWave, &waveHdr[index], sizeof(WAVEHDR)) == MMSYSERR_NOERROR) {
440                 index ^= 1;
441                 PlaySound_WaitDone(&s);
442             }
443             else FIXME("Couldn't play header\n");
444         }
445         bRet = TRUE;
446     } while (wps->bLoop);
447
448     PlaySound_WaitDone(&s); /* for last buffer */
449     waveOutReset(wps->hWave);
450
451     waveOutUnprepareHeader(wps->hWave, &waveHdr[0], sizeof(WAVEHDR));
452     waveOutUnprepareHeader(wps->hWave, &waveHdr[1], sizeof(WAVEHDR));
453
454 errCleanUp:
455     TRACE("Done playing=%s => %s!\n", debugstr_w(wps->pszSound), bRet ? "ok" : "ko");
456     CloseHandle(s.hEvent);
457     HeapFree(GetProcessHeap(), 0, waveHdr);
458     HeapFree(GetProcessHeap(), 0, lpWaveFormat);
459     if (wps->hWave)     while (waveOutClose(wps->hWave) == WAVERR_STILLPLAYING) Sleep(100);
460     if (hmmio)          mmioClose(hmmio, 0);
461
462     PlaySound_Free(wps);
463
464     return bRet;
465 }
466
467 static BOOL MULTIMEDIA_PlaySound(const void* pszSound, HMODULE hmod, DWORD fdwSound, BOOL bUnicode)
468 {
469     WINE_PLAYSOUND*     wps = NULL;
470
471     TRACE("pszSound='%p' hmod=%p fdwSound=%08X\n",
472           pszSound, hmod, fdwSound);
473
474     /* FIXME? I see no difference between SND_NOWAIT and SND_NOSTOP !
475      * there could be one if several sounds can be played at once...
476      */
477     if ((fdwSound & (SND_NOWAIT | SND_NOSTOP)) && PlaySoundList != NULL)
478         return FALSE;
479
480     /* alloc internal structure, if we need to play something */
481     if (pszSound && !(fdwSound & SND_PURGE))
482     {
483         if (!(wps = PlaySound_Alloc(pszSound, hmod, fdwSound, bUnicode)))
484             return FALSE;
485     }
486
487     EnterCriticalSection(&WINMM_cs);
488     /* since several threads can enter PlaySound in parallel, we're not
489      * sure, at this point, that another thread didn't start a new playsound
490      */
491     while (PlaySoundList != NULL)
492     {
493         ResetEvent(psLastEvent);
494         /* FIXME: doc says we have to stop all instances of pszSound if it's non
495          * NULL... as of today, we stop all playing instances */
496         SetEvent(psStopEvent);
497
498         waveOutReset(PlaySoundList->hWave);
499         LeaveCriticalSection(&WINMM_cs);
500         WaitForSingleObject(psLastEvent, INFINITE);
501         EnterCriticalSection(&WINMM_cs);
502
503         ResetEvent(psStopEvent);
504     }
505
506     if (wps) wps->lpNext = PlaySoundList;
507     PlaySoundList = wps;
508     LeaveCriticalSection(&WINMM_cs);
509
510     if (!pszSound || (fdwSound & SND_PURGE)) return TRUE;
511
512     if (fdwSound & SND_ASYNC)
513     {
514         DWORD       id;
515         HANDLE      handle;
516         wps->bLoop = (fdwSound & SND_LOOP) ? TRUE : FALSE;
517         if ((handle = CreateThread(NULL, 0, proc_PlaySound, wps, 0, &id)) != 0) {
518             wps->hThread = handle;
519             SetThreadPriority(handle, THREAD_PRIORITY_TIME_CRITICAL);
520             return TRUE;
521         }
522     }
523     else return proc_PlaySound(wps);
524
525     /* error cases */
526     PlaySound_Free(wps);
527     return FALSE;
528 }
529
530 /**************************************************************************
531  *                              PlaySoundA              [WINMM.@]
532  */
533 BOOL WINAPI PlaySoundA(LPCSTR pszSoundA, HMODULE hmod, DWORD fdwSound)
534 {
535     return MULTIMEDIA_PlaySound(pszSoundA, hmod, fdwSound, FALSE);
536 }
537
538 /**************************************************************************
539  *                              PlaySoundW              [WINMM.@]
540  */
541 BOOL WINAPI PlaySoundW(LPCWSTR pszSoundW, HMODULE hmod, DWORD fdwSound)
542 {
543     return MULTIMEDIA_PlaySound(pszSoundW, hmod, fdwSound, TRUE);
544 }
545
546 /**************************************************************************
547  *                              sndPlaySoundA           [WINMM.@]
548  */
549 BOOL WINAPI sndPlaySoundA(LPCSTR pszSoundA, UINT uFlags)
550 {
551     uFlags &= SND_ASYNC|SND_LOOP|SND_MEMORY|SND_NODEFAULT|SND_NOSTOP|SND_SYNC;
552     return MULTIMEDIA_PlaySound(pszSoundA, 0, uFlags, FALSE);
553 }
554
555 /**************************************************************************
556  *                              sndPlaySoundW           [WINMM.@]
557  */
558 BOOL WINAPI sndPlaySoundW(LPCWSTR pszSound, UINT uFlags)
559 {
560     uFlags &= SND_ASYNC|SND_LOOP|SND_MEMORY|SND_NODEFAULT|SND_NOSTOP|SND_SYNC;
561     return MULTIMEDIA_PlaySound(pszSound, 0, uFlags, TRUE);
562 }
563
564 /**************************************************************************
565  *                              mmsystemGetVersion      [WINMM.@]
566  */
567 UINT WINAPI mmsystemGetVersion(void)
568 {
569     TRACE("3.10 (Win95?)\n");
570     return 0x030a;
571 }