winmm: Initialize COM for MULTITHREADED, not APARTMENTTHREADED.
[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     struct tagWINE_PLAYSOUND*   lpNext;
48 } WINE_PLAYSOUND;
49
50 static WINE_PLAYSOUND *PlaySoundList;
51 static BOOL bPlaySoundStop;
52
53 static HMMIO    get_mmioFromFile(LPCWSTR lpszName)
54 {
55     HMMIO       ret;
56     WCHAR       buf[256];
57     LPWSTR      dummy;
58
59     ret = mmioOpenW((LPWSTR)lpszName, NULL,
60                     MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE);
61     if (ret != 0) return ret;
62     if (SearchPathW(NULL, lpszName, NULL, sizeof(buf)/sizeof(buf[0]), buf, &dummy))
63     {
64         return mmioOpenW(buf, NULL,
65                          MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE);
66     }
67     return 0;
68 }
69
70 static HMMIO    get_mmioFromProfile(UINT uFlags, LPCWSTR lpszName)
71 {
72     WCHAR       str[128];
73     LPWSTR      ptr;
74     HMMIO       hmmio;
75     HKEY        hRegSnd, hRegApp, hScheme, hSnd;
76     DWORD       err, type, count;
77
78     static const WCHAR  wszSounds[] = {'S','o','u','n','d','s',0};
79     static const WCHAR  wszDefault[] = {'D','e','f','a','u','l','t',0};
80     static const WCHAR  wszKey[] = {'A','p','p','E','v','e','n','t','s','\\',
81                                     'S','c','h','e','m','e','s','\\',
82                                     'A','p','p','s',0};
83     static const WCHAR  wszDotDefault[] = {'.','D','e','f','a','u','l','t',0};
84     static const WCHAR  wszDotCurrent[] = {'.','C','u','r','r','e','n','t',0};
85     static const WCHAR  wszNull[] = {0};
86
87     TRACE("searching in SystemSound list for %s\n", debugstr_w(lpszName));
88     GetProfileStringW(wszSounds, lpszName, wszNull, str, sizeof(str)/sizeof(str[0]));
89     if (lstrlenW(str) == 0)
90     {
91         if (uFlags & SND_NODEFAULT) goto next;
92         GetProfileStringW(wszSounds, wszDefault, wszNull, str, sizeof(str)/sizeof(str[0]));
93         if (lstrlenW(str) == 0) goto next;
94     }
95     for (ptr = str; *ptr && *ptr != ','; ptr++);
96     if (*ptr) *ptr = 0;
97     hmmio = mmioOpenW(str, NULL, MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE);
98     if (hmmio != 0) return hmmio;
99  next:
100     /* we look up the registry under
101      *      HKCU\AppEvents\Schemes\Apps\.Default
102      *      HKCU\AppEvents\Schemes\Apps\<AppName>
103      */
104     if (RegOpenKeyW(HKEY_CURRENT_USER, wszKey, &hRegSnd) != 0) goto none;
105     if (uFlags & SND_APPLICATION)
106     {
107         DWORD len;
108
109         err = 1; /* error */
110         len = GetModuleFileNameW(0, str, sizeof(str)/sizeof(str[0]));
111         if (len > 0 && len < sizeof(str)/sizeof(str[0]))
112         {
113             for (ptr = str + lstrlenW(str) - 1; ptr >= str; ptr--)
114             {
115                 if (*ptr == '.') *ptr = 0;
116                 if (*ptr == '\\')
117                 {
118                     err = RegOpenKeyW(hRegSnd, ptr+1, &hRegApp);
119                     break;
120                 }
121             }
122         }
123     }
124     else
125     {
126         err = RegOpenKeyW(hRegSnd, wszDotDefault, &hRegApp);
127     }
128     RegCloseKey(hRegSnd);
129     if (err != 0) goto none;
130     err = RegOpenKeyW(hRegApp, lpszName, &hScheme);
131     RegCloseKey(hRegApp);
132     if (err != 0) goto none;
133     /* what's the difference between .Current and .Default ? */
134     err = RegOpenKeyW(hScheme, wszDotDefault, &hSnd);
135     if (err != 0)
136     {
137         err = RegOpenKeyW(hScheme, wszDotCurrent, &hSnd);
138         RegCloseKey(hScheme);
139         if (err != 0)
140             goto none;
141     }
142     count = sizeof(str)/sizeof(str[0]);
143     err = RegQueryValueExW(hSnd, NULL, 0, &type, (LPBYTE)str, &count);
144     RegCloseKey(hSnd);
145     if (err != 0 || !*str) goto none;
146     hmmio = mmioOpenW(str, NULL, MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE);
147     if (hmmio) return hmmio;
148  none:
149     WARN("can't find SystemSound=%s !\n", debugstr_w(lpszName));
150     return 0;
151 }
152
153 struct playsound_data
154 {
155     HANDLE      hEvent;
156     LONG        dwEventCount;
157 };
158
159 static void CALLBACK PlaySound_Callback(HWAVEOUT hwo, UINT uMsg,
160                                         DWORD_PTR dwInstance,
161                                         DWORD_PTR dwParam1, DWORD_PTR dwParam2)
162 {
163     struct playsound_data*      s = (struct playsound_data*)dwInstance;
164
165     switch (uMsg) {
166     case WOM_OPEN:
167     case WOM_CLOSE:
168         break;
169     case WOM_DONE:
170         InterlockedIncrement(&s->dwEventCount);
171         TRACE("Returning waveHdr=%lx\n", dwParam1);
172         SetEvent(s->hEvent);
173         break;
174     default:
175         ERR("Unknown uMsg=%d\n", uMsg);
176     }
177 }
178
179 static void PlaySound_WaitDone(struct playsound_data* s)
180 {
181     for (;;) {
182         if (InterlockedDecrement(&s->dwEventCount) >= 0) break;
183         InterlockedIncrement(&s->dwEventCount);
184
185         WaitForSingleObject(s->hEvent, INFINITE);
186     }
187 }
188
189 static BOOL PlaySound_IsString(DWORD fdwSound, const void* psz)
190 {
191     /* SND_RESOURCE is 0x40004 while
192      * SND_MEMORY is 0x00004
193      */
194     switch (fdwSound & (SND_RESOURCE|SND_ALIAS_ID|SND_FILENAME))
195     {
196     case SND_RESOURCE:  return HIWORD(psz) != 0; /* by name or by ID ? */
197     case SND_ALIAS_ID:
198     case SND_MEMORY:    return FALSE;
199     case SND_ALIAS:
200     case SND_FILENAME:
201     case SND_ALIAS|SND_FILENAME:
202     case 0:             return TRUE;
203     default:            FIXME("WTF\n"); return FALSE;
204     }
205 }
206
207 static void     PlaySound_Free(WINE_PLAYSOUND* wps)
208 {
209     WINE_PLAYSOUND**    p;
210
211     EnterCriticalSection(&WINMM_cs);
212     for (p = &PlaySoundList; *p && *p != wps; p = &((*p)->lpNext));
213     if (*p) *p = (*p)->lpNext;
214     if (PlaySoundList == NULL) SetEvent(psLastEvent);
215     LeaveCriticalSection(&WINMM_cs);
216     if (wps->bAlloc) HeapFree(GetProcessHeap(), 0, (void*)wps->pszSound);
217     HeapFree(GetProcessHeap(), 0, wps);
218 }
219
220 static WINE_PLAYSOUND*  PlaySound_Alloc(const void* pszSound, HMODULE hmod,
221                                         DWORD fdwSound, BOOL bUnicode)
222 {
223     WINE_PLAYSOUND* wps;
224
225     wps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*wps));
226     if (!wps) return NULL;
227
228     wps->hMod = hmod;
229     wps->fdwSound = fdwSound;
230     if (PlaySound_IsString(fdwSound, pszSound))
231     {
232         if (bUnicode)
233         {
234             if (fdwSound & SND_ASYNC)
235             {
236                 LPWSTR sound = HeapAlloc(GetProcessHeap(), 0,
237                                          (lstrlenW(pszSound)+1) * sizeof(WCHAR));
238                 if (!sound) goto oom_error;
239                 wps->pszSound = lstrcpyW(sound, pszSound);
240                 wps->bAlloc = TRUE;
241             }
242             else
243                 wps->pszSound = pszSound;
244         }
245         else
246         {
247             UNICODE_STRING usBuffer;
248             RtlCreateUnicodeStringFromAsciiz(&usBuffer, pszSound);
249             wps->pszSound = usBuffer.Buffer;
250             if (!wps->pszSound) goto oom_error;
251             wps->bAlloc = TRUE;
252         }
253     }
254     else
255         wps->pszSound = pszSound;
256
257     return wps;
258  oom_error:
259     if (wps->bAlloc) HeapFree(GetProcessHeap(), 0, (void*)wps->pszSound);
260     HeapFree(GetProcessHeap(), 0, wps);
261     return NULL;
262 }
263
264 static DWORD WINAPI proc_PlaySound(LPVOID arg)
265 {
266     WINE_PLAYSOUND*     wps = arg;
267     BOOL                bRet = FALSE;
268     HMMIO               hmmio = 0;
269     MMCKINFO            ckMainRIFF;
270     MMCKINFO            mmckInfo;
271     LPWAVEFORMATEX      lpWaveFormat = NULL;
272     HWAVEOUT            hWave = 0;
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     if (!hmmio && 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     if (!hmmio && wps->fdwSound & SND_FILENAME)
346     {
347         hmmio = get_mmioFromFile(wps->pszSound);
348     }
349     if (!(wps->fdwSound & (SND_FILENAME|SND_ALIAS|SND_MEMORY)))
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 (!lpWaveFormat)
380         goto errCleanUp;
381     if (mmioRead(hmmio, (HPSTR)lpWaveFormat, mmckInfo.cksize) < sizeof(PCMWAVEFORMAT))
382         goto errCleanUp;
383
384     TRACE("wFormatTag=%04X !\n",        lpWaveFormat->wFormatTag);
385     TRACE("nChannels=%d\n",             lpWaveFormat->nChannels);
386     TRACE("nSamplesPerSec=%d\n",        lpWaveFormat->nSamplesPerSec);
387     TRACE("nAvgBytesPerSec=%d\n",       lpWaveFormat->nAvgBytesPerSec);
388     TRACE("nBlockAlign=%d\n",           lpWaveFormat->nBlockAlign);
389     TRACE("wBitsPerSample=%u !\n",      lpWaveFormat->wBitsPerSample);
390
391     /* move to end of 'fmt ' chunk */
392     mmioAscend(hmmio, &mmckInfo, 0);
393
394     mmckInfo.ckid = mmioFOURCC('d', 'a', 't', 'a');
395     if (mmioDescend(hmmio, &mmckInfo, &ckMainRIFF, MMIO_FINDCHUNK))
396         goto errCleanUp;
397
398     TRACE("Chunk Found ckid=%.4s fccType=%08x cksize=%08X\n",
399           (LPSTR)&mmckInfo.ckid, mmckInfo.fccType, mmckInfo.cksize);
400
401     s.hEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
402     if (!s.hEvent)
403         goto errCleanUp;
404
405     if (waveOutOpen(&hWave, WAVE_MAPPER, lpWaveFormat, (DWORD_PTR)PlaySound_Callback,
406                     (DWORD_PTR)&s, CALLBACK_FUNCTION) != MMSYSERR_NOERROR)
407         goto errCleanUp;
408
409     /* make it so that 3 buffers per second are needed */
410     bufsize = (((lpWaveFormat->nAvgBytesPerSec / 3) - 1) / lpWaveFormat->nBlockAlign + 1) *
411         lpWaveFormat->nBlockAlign;
412     waveHdr = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(WAVEHDR) + 2 * bufsize);
413     if (!waveHdr)
414         goto errCleanUp;
415     waveHdr[0].lpData = (char*)waveHdr + 2 * sizeof(WAVEHDR);
416     waveHdr[1].lpData = (char*)waveHdr + 2 * sizeof(WAVEHDR) + bufsize;
417     waveHdr[0].dwUser = waveHdr[1].dwUser = 0L;
418     waveHdr[0].dwLoops = waveHdr[1].dwLoops = 0L;
419     waveHdr[0].dwFlags = waveHdr[1].dwFlags = 0L;
420     waveHdr[0].dwBufferLength = waveHdr[1].dwBufferLength = bufsize;
421     if (waveOutPrepareHeader(hWave, &waveHdr[0], sizeof(WAVEHDR)) ||
422         waveOutPrepareHeader(hWave, &waveHdr[1], sizeof(WAVEHDR))) {
423         goto errCleanUp;
424     }
425
426     s.dwEventCount = 1L; /* for first buffer */
427     index = 0;
428
429     do {
430         left = mmckInfo.cksize;
431
432         mmioSeek(hmmio, mmckInfo.dwDataOffset, SEEK_SET);
433         while (left)
434         {
435             if (bPlaySoundStop)
436             {
437                 waveOutReset(hWave);
438                 wps->bLoop = FALSE;
439                 break;
440             }
441             count = mmioRead(hmmio, waveHdr[index].lpData, min(bufsize, left));
442             if (count < 1) break;
443             left -= count;
444             waveHdr[index].dwBufferLength = count;
445             if (waveOutWrite(hWave, &waveHdr[index], sizeof(WAVEHDR)) == MMSYSERR_NOERROR) {
446                 index ^= 1;
447                 PlaySound_WaitDone(&s);
448             }
449             else {
450                 ERR("Aborting play loop, waveOutWrite error\n");
451                 wps->bLoop = FALSE;
452                 break;
453             }
454         }
455         bRet = TRUE;
456     } while (wps->bLoop);
457
458     PlaySound_WaitDone(&s); /* to balance first buffer */
459     waveOutReset(hWave);
460
461     waveOutUnprepareHeader(hWave, &waveHdr[0], sizeof(WAVEHDR));
462     waveOutUnprepareHeader(hWave, &waveHdr[1], sizeof(WAVEHDR));
463
464 errCleanUp:
465     TRACE("Done playing=%s => %s!\n", debugstr_w(wps->pszSound), bRet ? "ok" : "ko");
466     HeapFree(GetProcessHeap(), 0, lpWaveFormat);
467     if (hWave)          while (waveOutClose(hWave) == WAVERR_STILLPLAYING) Sleep(100);
468     CloseHandle(s.hEvent);
469     HeapFree(GetProcessHeap(), 0, waveHdr);
470     if (hmmio)          mmioClose(hmmio, 0);
471
472     PlaySound_Free(wps);
473
474     return bRet;
475 }
476
477 static BOOL MULTIMEDIA_PlaySound(const void* pszSound, HMODULE hmod, DWORD fdwSound, BOOL bUnicode)
478 {
479     WINE_PLAYSOUND*     wps = NULL;
480
481     TRACE("pszSound='%p' hmod=%p fdwSound=%08X\n",
482           pszSound, hmod, fdwSound);
483
484     /* SND_NOWAIT is ignored in w95/2k/xp. */
485     if ((fdwSound & SND_NOSTOP) && PlaySoundList != NULL)
486         return FALSE;
487
488     /* alloc internal structure, if we need to play something */
489     if (pszSound && !(fdwSound & SND_PURGE))
490     {
491         if (!(wps = PlaySound_Alloc(pszSound, hmod, fdwSound, bUnicode)))
492             return FALSE;
493     }
494
495     EnterCriticalSection(&WINMM_cs);
496     /* since several threads can enter PlaySound in parallel, we're not
497      * sure, at this point, that another thread didn't start a new playsound
498      */
499     while (PlaySoundList != NULL)
500     {
501         ResetEvent(psLastEvent);
502         /* FIXME: doc says we have to stop all instances of pszSound if it's non
503          * NULL... as of today, we stop all playing instances */
504         bPlaySoundStop = TRUE;
505
506         LeaveCriticalSection(&WINMM_cs);
507         WaitForSingleObject(psLastEvent, INFINITE);
508         EnterCriticalSection(&WINMM_cs);
509
510         bPlaySoundStop = FALSE;
511     }
512
513     if (wps) wps->lpNext = PlaySoundList;
514     PlaySoundList = wps;
515     LeaveCriticalSection(&WINMM_cs);
516
517     if (!wps) return TRUE;
518
519     if (fdwSound & SND_ASYNC)
520     {
521         HANDLE      handle;
522         wps->bLoop = (fdwSound & SND_LOOP) ? TRUE : FALSE;
523         if ((handle = CreateThread(NULL, 0, proc_PlaySound, wps, 0, NULL)) != 0) {
524             SetThreadPriority(handle, THREAD_PRIORITY_TIME_CRITICAL);
525             CloseHandle(handle);
526             return TRUE;
527         }
528     }
529     else return proc_PlaySound(wps);
530
531     /* error cases */
532     PlaySound_Free(wps);
533     return FALSE;
534 }
535
536 /**************************************************************************
537  *                              PlaySoundA              [WINMM.@]
538  */
539 BOOL WINAPI PlaySoundA(LPCSTR pszSoundA, HMODULE hmod, DWORD fdwSound)
540 {
541     return MULTIMEDIA_PlaySound(pszSoundA, hmod, fdwSound, FALSE);
542 }
543
544 /**************************************************************************
545  *                              PlaySoundW              [WINMM.@]
546  */
547 BOOL WINAPI PlaySoundW(LPCWSTR pszSoundW, HMODULE hmod, DWORD fdwSound)
548 {
549     return MULTIMEDIA_PlaySound(pszSoundW, hmod, fdwSound, TRUE);
550 }
551
552 /**************************************************************************
553  *                              sndPlaySoundA           [WINMM.@]
554  */
555 BOOL WINAPI sndPlaySoundA(LPCSTR pszSoundA, UINT uFlags)
556 {
557     uFlags &= SND_ASYNC|SND_LOOP|SND_MEMORY|SND_NODEFAULT|SND_NOSTOP|SND_SYNC;
558     return MULTIMEDIA_PlaySound(pszSoundA, 0, uFlags, FALSE);
559 }
560
561 /**************************************************************************
562  *                              sndPlaySoundW           [WINMM.@]
563  */
564 BOOL WINAPI sndPlaySoundW(LPCWSTR pszSound, UINT uFlags)
565 {
566     uFlags &= SND_ASYNC|SND_LOOP|SND_MEMORY|SND_NODEFAULT|SND_NOSTOP|SND_SYNC;
567     return MULTIMEDIA_PlaySound(pszSound, 0, uFlags, TRUE);
568 }
569
570 /**************************************************************************
571  *                              mmsystemGetVersion      [WINMM.@]
572  */
573 UINT WINAPI mmsystemGetVersion(void)
574 {
575     TRACE("3.10 (Win95?)\n");
576     return 0x030a;
577 }