Changeset 21720 for branches/gcc-kmk/src/winmm/playsound.cpp
- Timestamp:
- Oct 19, 2011, 11:26:02 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gcc-kmk/src/winmm/playsound.cpp
r8470 r21720 24 24 #include <misc.h> 25 25 #include <string.h> 26 #include <win \debugtools.h>26 #include <win/debugtools.h> 27 27 28 28 #define DBG_LOCALLOG DBG_playsound … … 51 51 } 52 52 53 static HMMIO get_mmioFromProfile(UINT uFlags, LPCSTR lpszName) 53 static HMMIO get_mmioFromProfile(UINT uFlags, LPCSTR lpszName) 54 54 { 55 55 char str[128]; 56 56 LPSTR ptr; 57 57 HMMIO hmmio; 58 58 59 59 TRACE("searching in SystemSound List !\n"); 60 60 GetProfileStringA("Sounds", (LPSTR)lpszName, "", str, sizeof(str)); … … 78 78 }; 79 79 80 static void CALLBACK PlaySound_Callback(HWAVEOUT hwo, UINT uMsg, 81 DWORD dwInstance, 80 static void CALLBACK PlaySound_Callback(HWAVEOUT hwo, UINT uMsg, 81 DWORD dwInstance, 82 82 DWORD dwParam1, DWORD dwParam2) 83 83 { … … 98 98 } 99 99 100 static void PlaySound_WaitDone(struct playsound_data* s) 100 static void PlaySound_WaitDone(struct playsound_data* s) 101 101 { 102 102 for (;;) { … … 106 106 } 107 107 InterlockedIncrement((LPLONG)&s->dwEventCount); 108 108 109 109 WaitForSingleObject(s->hEvent, INFINITE); 110 110 } … … 141 141 hmmio = 0; 142 142 if (uFlags & SND_ALIAS) 143 if ((hmmio = get_mmioFromProfile(uFlags, lpszSoundName)) == 0) 143 if ((hmmio = get_mmioFromProfile(uFlags, lpszSoundName)) == 0) 144 144 return FALSE; 145 145 146 146 if (uFlags & SND_FILENAME) 147 147 if ((hmmio=get_mmioFromFile(lpszSoundName)) == 0) return FALSE; 148 148 149 149 if (PlaySound_SearchMode == 1) { 150 150 PlaySound_SearchMode = 0; 151 if ((hmmio = get_mmioFromFile(lpszSoundName)) == 0) 151 if ((hmmio = get_mmioFromFile(lpszSoundName)) == 0) 152 152 hmmio = get_mmioFromProfile(uFlags, lpszSoundName); 153 153 } 154 154 155 155 if (PlaySound_SearchMode == 2) { 156 156 PlaySound_SearchMode = 0; 157 if ((hmmio = get_mmioFromProfile(uFlags | SND_NODEFAULT, lpszSoundName)) == 0) 158 if ((hmmio = get_mmioFromFile(lpszSoundName)) == 0) 157 if ((hmmio = get_mmioFromProfile(uFlags | SND_NODEFAULT, lpszSoundName)) == 0) 158 if ((hmmio = get_mmioFromFile(lpszSoundName)) == 0) 159 159 hmmio = get_mmioFromProfile(uFlags, lpszSoundName); 160 160 } … … 197 197 goto errCleanUp; 198 198 199 TRACE("Chunk Found ckid=%.4s fccType=%.4s cksize=%08lX\n", 199 TRACE("Chunk Found ckid=%.4s fccType=%.4s cksize=%08lX\n", 200 200 (LPSTR)&mmckInfo.ckid, (LPSTR)&mmckInfo.fccType, mmckInfo.cksize); 201 201 … … 216 216 waveHdr[0].dwFlags = waveHdr[1].dwFlags = 0L; 217 217 waveHdr[0].dwBufferLength = waveHdr[1].dwBufferLength = bufsize; 218 if (waveOutPrepareHeader(hWave, &waveHdr[0], sizeof(WAVEHDR)) || 218 if (waveOutPrepareHeader(hWave, &waveHdr[0], sizeof(WAVEHDR)) || 219 219 waveOutPrepareHeader(hWave, &waveHdr[1], sizeof(WAVEHDR))) { 220 220 goto errCleanUp; … … 260 260 } 261 261 262 static DWORD WINAPI PlaySound_Thread(LPVOID arg) 262 static DWORD WINAPI PlaySound_Thread(LPVOID arg) 263 263 { 264 264 DWORD res; 265 265 266 266 for (;;) { 267 267 PlaySound_Playing = FALSE; … … 273 273 if (res != WAIT_OBJECT_0) continue; 274 274 PlaySound_Playing = TRUE; 275 275 276 276 if ((PlaySound_fdwSound & SND_RESOURCE) == SND_RESOURCE) { 277 277 HRSRC hRES; … … 292 292 continue; 293 293 } 294 PlaySound_Result = proc_PlaySound((LPCSTR)ptr, 294 PlaySound_Result = proc_PlaySound((LPCSTR)ptr, 295 295 ((UINT16)PlaySound_fdwSound ^ SND_RESOURCE) | SND_MEMORY); 296 296 FreeResource(hGLOB); … … 319 319 { 320 320 static LPSTR StrDup = NULL; 321 321 322 322 TRACE("pszSound='%p' hmod=%04X fdwSound=%08lX\n", 323 323 pszSound, hmod, fdwSound); 324 324 325 325 if (PlaySound_hThread == 0) { /* This is the first time they called us */ 326 326 DWORD id; … … 331 331 if ((PlaySound_hPlayEvent = CreateEventA(NULL, FALSE, FALSE, NULL)) == 0) 332 332 return FALSE; 333 if ((PlaySound_hThread = CreateThread(NULL, 0, PlaySound_Thread, 0, 0, &id)) == 0) 334 return FALSE; 335 } 336 337 /* FIXME? I see no difference between SND_WAIT and SND_NOSTOP ! */ 338 if ((fdwSound & (SND_NOWAIT | SND_NOSTOP)) && PlaySound_Playing) 333 if ((PlaySound_hThread = CreateThread(NULL, 0, PlaySound_Thread, 0, 0, &id)) == 0) 334 return FALSE; 335 } 336 337 /* FIXME? I see no difference between SND_WAIT and SND_NOSTOP ! */ 338 if ((fdwSound & (SND_NOWAIT | SND_NOSTOP)) && PlaySound_Playing) 339 339 return FALSE; 340 340 341 341 /* Trying to stop if playing */ 342 342 if (PlaySound_Playing) PlaySound_Stop = TRUE; 343 343 344 344 /* Waiting playing thread to get ready. I think 10 secs is ok & if not then leave*/ 345 345 if (WaitForSingleObject(PlaySound_hReadyEvent, 1000*10) != WAIT_OBJECT_0) 346 346 return FALSE; 347 348 if (!pszSound || (fdwSound & SND_PURGE)) 347 348 if (!pszSound || (fdwSound & SND_PURGE)) 349 349 return FALSE; /* We stoped playing so leaving */ 350 350 351 351 if (PlaySound_SearchMode != 1) PlaySound_SearchMode = 2; 352 352 if (!(fdwSound & SND_ASYNC)) { 353 if (fdwSound & SND_LOOP) 353 if (fdwSound & SND_LOOP) 354 354 return FALSE; 355 355 PlaySound_pszSound = pszSound; … … 358 358 PlaySound_Result = FALSE; 359 359 SetEvent(PlaySound_hPlayEvent); 360 if (WaitForSingleObject(PlaySound_hMiddleEvent, INFINITE) != WAIT_OBJECT_0) 361 return FALSE; 362 if (WaitForSingleObject(PlaySound_hReadyEvent, INFINITE) != WAIT_OBJECT_0) 360 if (WaitForSingleObject(PlaySound_hMiddleEvent, INFINITE) != WAIT_OBJECT_0) 361 return FALSE; 362 if (WaitForSingleObject(PlaySound_hReadyEvent, INFINITE) != WAIT_OBJECT_0) 363 363 return FALSE; 364 364 return PlaySound_Result; … … 371 371 StrDup = NULL; 372 372 } 373 if (!((fdwSound & SND_MEMORY) || ((fdwSound & SND_RESOURCE) && 373 if (!((fdwSound & SND_MEMORY) || ((fdwSound & SND_RESOURCE) && 374 374 !((DWORD)pszSound >> 16)) || !pszSound)) { 375 375 StrDup = HEAP_strdupA(GetProcessHeap(), 0,pszSound); … … 403 403 LPSTR pszSoundA; 404 404 BOOL bSound; 405 406 if (!((fdwSound & SND_MEMORY) || ((fdwSound & SND_RESOURCE) && 405 406 if (!((fdwSound & SND_MEMORY) || ((fdwSound & SND_RESOURCE) && 407 407 !((DWORD)pszSound >> 16)) || !pszSound)) { 408 408 pszSoundA = HEAP_strdupWtoA(GetProcessHeap(), 0,pszSound); 409 409 bSound = PlaySoundA(pszSoundA, hmod, fdwSound); 410 410 HeapFree(GetProcessHeap(), 0, pszSoundA); 411 } else 411 } else 412 412 bSound = PlaySoundA((LPCSTR)pszSound, hmod, fdwSound); 413 413 414 414 return bSound; 415 415 }
Note:
See TracChangeset
for help on using the changeset viewer.