Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
1e3e87d4
Commit
1e3e87d4
authored
Oct 25, 2002
by
Eric Pouech
Committed by
Alexandre Julliard
Oct 25, 2002
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify the global internal data handling.
parent
fb8bad49
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
99 additions
and
128 deletions
+99
-128
mci.c
dlls/winmm/mci.c
+0
-0
mmio.c
dlls/winmm/mmio.c
+25
-32
mmsystem.c
dlls/winmm/mmsystem.c
+8
-10
playsound.c
dlls/winmm/playsound.c
+17
-21
time.c
dlls/winmm/time.c
+25
-30
winemm.h
dlls/winmm/winemm.h
+5
-3
winmm.c
dlls/winmm/winmm.c
+19
-32
No files found.
dlls/winmm/mci.c
View file @
1e3e87d4
This diff is collapsed.
Click to expand it.
dlls/winmm/mmio.c
View file @
1e3e87d4
...
...
@@ -352,12 +352,9 @@ static LRESULT send_message(struct IOProcList* ioProc, LPMMIOINFO mmioinfo,
switch
(
ioProc
->
type
)
{
case
MMIO_PROC_16
:
{
LPWINE_MM_IDATA
iData
=
MULTIMEDIA_GetIData
();
if
(
iData
&&
iData
->
pFnMmioCallback16
)
result
=
iData
->
pFnMmioCallback16
((
SEGPTR
)
ioProc
->
pIOProc
,
mmioinfo
,
wMsg
,
lp1
,
lp2
);
}
if
(
WINMM_IData
&&
WINMM_IData
->
pFnMmioCallback16
)
result
=
WINMM_IData
->
pFnMmioCallback16
((
SEGPTR
)
ioProc
->
pIOProc
,
mmioinfo
,
wMsg
,
lp1
,
lp2
);
break
;
case
MMIO_PROC_32A
:
case
MMIO_PROC_32W
:
...
...
@@ -434,18 +431,16 @@ static FOURCC MMIO_ParseExtA(LPCSTR szFileName)
*
* Retrieves the mmio object from current process
*/
LPWINE_MMIO
MMIO_Get
(
LPWINE_MM_IDATA
iData
,
HMMIO
h
)
LPWINE_MMIO
MMIO_Get
(
HMMIO
h
)
{
LPWINE_MMIO
wm
=
NULL
;
if
(
!
iData
)
iData
=
MULTIMEDIA_GetIData
();
EnterCriticalSection
(
&
iData
->
cs
);
for
(
wm
=
iData
->
lpMMIO
;
wm
;
wm
=
wm
->
lpNext
)
{
EnterCriticalSection
(
&
WINMM_IData
->
cs
);
for
(
wm
=
WINMM_IData
->
lpMMIO
;
wm
;
wm
=
wm
->
lpNext
)
{
if
(
wm
->
info
.
hmmio
==
h
)
break
;
}
LeaveCriticalSection
(
&
i
Data
->
cs
);
LeaveCriticalSection
(
&
WINMM_I
Data
->
cs
);
return
wm
;
}
...
...
@@ -458,17 +453,16 @@ static LPWINE_MMIO MMIO_Create(void)
{
static
WORD
MMIO_counter
=
0
;
LPWINE_MMIO
wm
;
LPWINE_MM_IDATA
iData
=
MULTIMEDIA_GetIData
();
wm
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
WINE_MMIO
));
if
(
wm
)
{
EnterCriticalSection
(
&
i
Data
->
cs
);
EnterCriticalSection
(
&
WINMM_I
Data
->
cs
);
/* lookup next unallocated WORD handle, with a non NULL value */
while
(
++
MMIO_counter
==
0
||
MMIO_Get
(
iData
,
HMMIO_32
(
MMIO_counter
)));
while
(
++
MMIO_counter
==
0
||
MMIO_Get
(
HMMIO_32
(
MMIO_counter
)));
wm
->
info
.
hmmio
=
HMMIO_32
(
MMIO_counter
);
wm
->
lpNext
=
i
Data
->
lpMMIO
;
i
Data
->
lpMMIO
=
wm
;
LeaveCriticalSection
(
&
i
Data
->
cs
);
wm
->
lpNext
=
WINMM_I
Data
->
lpMMIO
;
WINMM_I
Data
->
lpMMIO
=
wm
;
LeaveCriticalSection
(
&
WINMM_I
Data
->
cs
);
}
return
wm
;
}
...
...
@@ -480,12 +474,11 @@ static LPWINE_MMIO MMIO_Create(void)
*/
static
BOOL
MMIO_Destroy
(
LPWINE_MMIO
wm
)
{
LPWINE_MM_IDATA
iData
=
MULTIMEDIA_GetIData
();
LPWINE_MMIO
*
m
;
EnterCriticalSection
(
&
i
Data
->
cs
);
EnterCriticalSection
(
&
WINMM_I
Data
->
cs
);
/* search for the matching one... */
m
=
&
(
i
Data
->
lpMMIO
);
m
=
&
(
WINMM_I
Data
->
lpMMIO
);
while
(
*
m
&&
*
m
!=
wm
)
m
=
&
(
*
m
)
->
lpNext
;
/* ...and destroy */
if
(
*
m
)
{
...
...
@@ -493,7 +486,7 @@ static BOOL MMIO_Destroy(LPWINE_MMIO wm)
HeapFree
(
GetProcessHeap
(),
0
,
wm
);
wm
=
NULL
;
}
LeaveCriticalSection
(
&
i
Data
->
cs
);
LeaveCriticalSection
(
&
WINMM_I
Data
->
cs
);
return
wm
?
FALSE
:
TRUE
;
}
...
...
@@ -726,7 +719,7 @@ MMRESULT WINAPI mmioClose(HMMIO hmmio, UINT uFlags)
TRACE
(
"(%04X, %04X);
\n
"
,
hmmio
,
uFlags
);
if
((
wm
=
MMIO_Get
(
NULL
,
hmmio
))
==
NULL
)
if
((
wm
=
MMIO_Get
(
hmmio
))
==
NULL
)
return
MMSYSERR_INVALHANDLE
;
if
((
result
=
MMIO_Flush
(
wm
,
0
))
!=
MMSYSERR_NOERROR
)
...
...
@@ -758,7 +751,7 @@ LONG WINAPI mmioRead(HMMIO hmmio, HPSTR pch, LONG cch)
TRACE
(
"(%04X, %p, %ld);
\n
"
,
hmmio
,
pch
,
cch
);
if
((
wm
=
MMIO_Get
(
NULL
,
hmmio
))
==
NULL
)
if
((
wm
=
MMIO_Get
(
hmmio
))
==
NULL
)
return
-
1
;
/* unbuffered case first */
...
...
@@ -808,7 +801,7 @@ LONG WINAPI mmioWrite(HMMIO hmmio, HPCSTR pch, LONG cch)
TRACE
(
"(%04X, %p, %ld);
\n
"
,
hmmio
,
pch
,
cch
);
if
((
wm
=
MMIO_Get
(
NULL
,
hmmio
))
==
NULL
)
if
((
wm
=
MMIO_Get
(
hmmio
))
==
NULL
)
return
-
1
;
if
(
wm
->
info
.
cchBuffer
)
{
...
...
@@ -863,7 +856,7 @@ LONG WINAPI mmioSeek(HMMIO hmmio, LONG lOffset, INT iOrigin)
TRACE
(
"(%04X, %08lX, %d);
\n
"
,
hmmio
,
lOffset
,
iOrigin
);
if
((
wm
=
MMIO_Get
(
NULL
,
hmmio
))
==
NULL
)
if
((
wm
=
MMIO_Get
(
hmmio
))
==
NULL
)
return
MMSYSERR_INVALHANDLE
;
/* not buffered, direct seek on file */
...
...
@@ -928,7 +921,7 @@ MMRESULT WINAPI mmioGetInfo(HMMIO hmmio, MMIOINFO* lpmmioinfo, UINT uFlags)
TRACE
(
"(0x%04x,%p,0x%08x)
\n
"
,
hmmio
,
lpmmioinfo
,
uFlags
);
if
((
wm
=
MMIO_Get
(
NULL
,
hmmio
))
==
NULL
)
if
((
wm
=
MMIO_Get
(
hmmio
))
==
NULL
)
return
MMSYSERR_INVALHANDLE
;
memcpy
(
lpmmioinfo
,
&
wm
->
info
,
sizeof
(
MMIOINFO
));
...
...
@@ -948,7 +941,7 @@ MMRESULT WINAPI mmioSetInfo(HMMIO hmmio, const MMIOINFO* lpmmioinfo, UINT uFlags
TRACE
(
"(0x%04x,%p,0x%08x)
\n
"
,
hmmio
,
lpmmioinfo
,
uFlags
);
if
((
wm
=
MMIO_Get
(
NULL
,
hmmio
))
==
NULL
)
if
((
wm
=
MMIO_Get
(
hmmio
))
==
NULL
)
return
MMSYSERR_INVALHANDLE
;
/* check pointers coherence */
...
...
@@ -976,7 +969,7 @@ MMRESULT WINAPI mmioSetBuffer(HMMIO hmmio, LPSTR pchBuffer, LONG cchBuffer, UINT
TRACE
(
"(hmmio=%04x, pchBuf=%p, cchBuf=%ld, uFlags=%#08x)
\n
"
,
hmmio
,
pchBuffer
,
cchBuffer
,
uFlags
);
if
((
wm
=
MMIO_Get
(
NULL
,
hmmio
))
==
NULL
)
if
((
wm
=
MMIO_Get
(
hmmio
))
==
NULL
)
return
MMSYSERR_INVALHANDLE
;
return
MMIO_SetBuffer
(
wm
,
pchBuffer
,
cchBuffer
,
uFlags
);
...
...
@@ -991,7 +984,7 @@ MMRESULT WINAPI mmioFlush(HMMIO hmmio, UINT uFlags)
TRACE
(
"(%04X, %04X)
\n
"
,
hmmio
,
uFlags
);
if
((
wm
=
MMIO_Get
(
NULL
,
hmmio
))
==
NULL
)
if
((
wm
=
MMIO_Get
(
hmmio
))
==
NULL
)
return
MMSYSERR_INVALHANDLE
;
return
MMIO_Flush
(
wm
,
uFlags
);
...
...
@@ -1009,7 +1002,7 @@ MMRESULT WINAPI mmioAdvance(HMMIO hmmio, MMIOINFO* lpmmioinfo, UINT uFlags)
/* NOTE: mmioAdvance16 heavily relies on parameters from lpmmioinfo we're using
* here. be sure if you change something here to check mmioAdvance16 as well
*/
if
((
wm
=
MMIO_Get
(
NULL
,
hmmio
))
==
NULL
)
if
((
wm
=
MMIO_Get
(
hmmio
))
==
NULL
)
return
MMSYSERR_INVALHANDLE
;
if
(
!
wm
->
info
.
cchBuffer
)
...
...
@@ -1116,7 +1109,7 @@ LRESULT MMIO_SendMessage(HMMIO hmmio, UINT uMessage, LPARAM lParam1,
if
(
uMessage
<
MMIOM_USER
)
return
MMSYSERR_INVALPARAM
;
if
((
wm
=
MMIO_Get
(
NULL
,
hmmio
))
==
NULL
)
if
((
wm
=
MMIO_Get
(
hmmio
))
==
NULL
)
return
MMSYSERR_INVALHANDLE
;
return
send_message
(
wm
->
ioProc
,
&
wm
->
info
,
uMessage
,
lParam1
,
lParam2
,
type
);
...
...
dlls/winmm/mmsystem.c
View file @
1e3e87d4
...
...
@@ -68,7 +68,6 @@ BOOL WINAPI MMSYSTEM_LibMain(DWORD fdwReason, HINSTANCE hinstDLL, WORD ds,
WORD
wHeapSize
,
DWORD
dwReserved1
,
WORD
wReserved2
)
{
HANDLE
hndl
;
LPWINE_MM_IDATA
iData
;
TRACE
(
"0x%x 0x%lx
\n
"
,
hinstDLL
,
fdwReason
);
...
...
@@ -84,14 +83,12 @@ BOOL WINAPI MMSYSTEM_LibMain(DWORD fdwReason, HINSTANCE hinstDLL, WORD ds,
ERR
(
"Could not load sibling WinMM.dll
\n
"
);
return
FALSE
;
}
iData
=
MULTIMEDIA_GetIData
();
iData
->
hWinMM16Instance
=
hinstDLL
;
iData
->
h16Module32
=
hndl
;
iData
->
pFnMmioCallback16
=
mmioCallback16
;
WINMM_IData
->
hWinMM16Instance
=
hinstDLL
;
WINMM_IData
->
h16Module32
=
hndl
;
WINMM_IData
->
pFnMmioCallback16
=
mmioCallback16
;
break
;
case
DLL_PROCESS_DETACH
:
iData
=
MULTIMEDIA_GetIData
();
FreeLibrary
(
iData
->
h16Module32
);
FreeLibrary
(
WINMM_IData
->
h16Module32
);
break
;
case
DLL_THREAD_ATTACH
:
case
DLL_THREAD_DETACH
:
...
...
@@ -2243,7 +2240,8 @@ MMRESULT16 WINAPI timeGetSystemTime16(LPMMTIME16 lpTime, UINT16 wSize)
if
(
wSize
>=
sizeof
(
*
lpTime
))
{
lpTime
->
wType
=
TIME_MS
;
lpTime
->
u
.
ms
=
TIME_MMTimeStart
()
->
mmSysTimeMS
;
TIME_MMTimeStart
();
lpTime
->
u
.
ms
=
WINMM_IData
->
mmSysTimeMS
;
TRACE
(
"=> %lu
\n
"
,
lpTime
->
u
.
ms
);
}
...
...
@@ -2447,7 +2445,7 @@ static LRESULT MMIO_SetSegmentedBuffer(HMMIO hmmio, SEGPTR ptr)
{
LPWINE_MMIO
wm
;
if
((
wm
=
MMIO_Get
(
NULL
,
hmmio
))
==
NULL
)
if
((
wm
=
MMIO_Get
(
hmmio
))
==
NULL
)
return
MMSYSERR_INVALHANDLE
;
wm
->
segBuffer16
=
ptr
;
return
MMSYSERR_NOERROR
;
...
...
@@ -2530,7 +2528,7 @@ MMRESULT16 WINAPI mmioGetInfo16(HMMIO16 hmmio, MMIOINFO16* lpmmioinfo, UINT16 uF
TRACE
(
"(0x%04x,%p,0x%08x)
\n
"
,
hmmio
,
lpmmioinfo
,
uFlags
);
if
((
wm
=
MMIO_Get
(
NULL
,
hmmio
))
==
NULL
)
if
((
wm
=
MMIO_Get
(
hmmio
))
==
NULL
)
return
MMSYSERR_INVALHANDLE
;
ret
=
mmioGetInfo
(
HMMIO_32
(
hmmio
),
&
mmioinfo
,
uFlags
);
...
...
dlls/winmm/playsound.c
View file @
1e3e87d4
...
...
@@ -180,14 +180,13 @@ static BOOL PlaySound_IsString(DWORD fdwSound, const void* psz)
static
void
PlaySound_Free
(
WINE_PLAYSOUND
*
wps
)
{
LPWINE_MM_IDATA
iData
=
MULTIMEDIA_GetIData
();
WINE_PLAYSOUND
**
p
;
EnterCriticalSection
(
&
i
Data
->
cs
);
for
(
p
=
&
i
Data
->
lpPlaySound
;
*
p
&&
*
p
!=
wps
;
p
=
&
((
*
p
)
->
lpNext
));
EnterCriticalSection
(
&
WINMM_I
Data
->
cs
);
for
(
p
=
&
WINMM_I
Data
->
lpPlaySound
;
*
p
&&
*
p
!=
wps
;
p
=
&
((
*
p
)
->
lpNext
));
if
(
*
p
)
*
p
=
(
*
p
)
->
lpNext
;
if
(
iData
->
lpPlaySound
==
NULL
)
SetEvent
(
i
Data
->
psLastEvent
);
LeaveCriticalSection
(
&
i
Data
->
cs
);
if
(
WINMM_IData
->
lpPlaySound
==
NULL
)
SetEvent
(
WINMM_I
Data
->
psLastEvent
);
LeaveCriticalSection
(
&
WINMM_I
Data
->
cs
);
if
(
wps
->
bAlloc
)
HeapFree
(
GetProcessHeap
(),
0
,
(
void
*
)
wps
->
pszSound
);
HeapFree
(
GetProcessHeap
(),
0
,
wps
);
}
...
...
@@ -236,7 +235,6 @@ static WINE_PLAYSOUND* PlaySound_Alloc(const void* pszSound, HMODULE hmod,
static
DWORD
WINAPI
proc_PlaySound
(
LPVOID
arg
)
{
WINE_PLAYSOUND
*
wps
=
(
WINE_PLAYSOUND
*
)
arg
;
LPWINE_MM_IDATA
iData
=
MULTIMEDIA_GetIData
();
BOOL
bRet
=
FALSE
;
HMMIO
hmmio
=
0
;
MMCKINFO
ckMainRIFF
;
...
...
@@ -369,7 +367,7 @@ static DWORD WINAPI proc_PlaySound(LPVOID arg)
mmioSeek
(
hmmio
,
mmckInfo
.
dwDataOffset
,
SEEK_SET
);
while
(
left
)
{
if
(
WaitForSingleObject
(
i
Data
->
psStopEvent
,
0
)
==
WAIT_OBJECT_0
)
if
(
WaitForSingleObject
(
WINMM_I
Data
->
psStopEvent
,
0
)
==
WAIT_OBJECT_0
)
{
wps
->
bLoop
=
FALSE
;
break
;
...
...
@@ -410,7 +408,6 @@ errCleanUp:
BOOL
MULTIMEDIA_PlaySound
(
const
void
*
pszSound
,
HMODULE
hmod
,
DWORD
fdwSound
,
BOOL
bUnicode
)
{
WINE_PLAYSOUND
*
wps
=
NULL
;
LPWINE_MM_IDATA
iData
=
MULTIMEDIA_GetIData
();
TRACE
(
"pszSound='%p' hmod=%04X fdwSound=%08lX
\n
"
,
pszSound
,
hmod
,
fdwSound
);
...
...
@@ -418,7 +415,7 @@ BOOL MULTIMEDIA_PlaySound(const void* pszSound, HMODULE hmod, DWORD fdwSound, BO
/* 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
))
&&
i
Data
->
lpPlaySound
!=
NULL
)
if
((
fdwSound
&
(
SND_NOWAIT
|
SND_NOSTOP
))
&&
WINMM_I
Data
->
lpPlaySound
!=
NULL
)
return
FALSE
;
/* alloc internal structure, if we need to play something */
...
...
@@ -428,27 +425,27 @@ BOOL MULTIMEDIA_PlaySound(const void* pszSound, HMODULE hmod, DWORD fdwSound, BO
return
FALSE
;
}
EnterCriticalSection
(
&
i
Data
->
cs
);
EnterCriticalSection
(
&
WINMM_I
Data
->
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
(
i
Data
->
lpPlaySound
!=
NULL
)
while
(
WINMM_I
Data
->
lpPlaySound
!=
NULL
)
{
ResetEvent
(
i
Data
->
psLastEvent
);
ResetEvent
(
WINMM_I
Data
->
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
(
i
Data
->
psStopEvent
);
SetEvent
(
WINMM_I
Data
->
psStopEvent
);
LeaveCriticalSection
(
&
i
Data
->
cs
);
WaitForSingleObject
(
i
Data
->
psLastEvent
,
INFINITE
);
EnterCriticalSection
(
&
i
Data
->
cs
);
LeaveCriticalSection
(
&
WINMM_I
Data
->
cs
);
WaitForSingleObject
(
WINMM_I
Data
->
psLastEvent
,
INFINITE
);
EnterCriticalSection
(
&
WINMM_I
Data
->
cs
);
ResetEvent
(
i
Data
->
psStopEvent
);
ResetEvent
(
WINMM_I
Data
->
psStopEvent
);
}
if
(
wps
)
wps
->
lpNext
=
i
Data
->
lpPlaySound
;
i
Data
->
lpPlaySound
=
wps
;
LeaveCriticalSection
(
&
i
Data
->
cs
);
if
(
wps
)
wps
->
lpNext
=
WINMM_I
Data
->
lpPlaySound
;
WINMM_I
Data
->
lpPlaySound
=
wps
;
LeaveCriticalSection
(
&
WINMM_I
Data
->
cs
);
if
(
!
pszSound
||
(
fdwSound
&
SND_PURGE
))
return
TRUE
;
...
...
@@ -568,4 +565,3 @@ BOOL WINAPI DriverCallback(DWORD dwCallBack, UINT uFlags, HDRVR hDev,
TRACE
(
"Done
\n
"
);
return
TRUE
;
}
dlls/winmm/time.c
View file @
1e3e87d4
...
...
@@ -176,25 +176,22 @@ static DWORD CALLBACK TIME_MMSysTimeThread(LPVOID arg)
/**************************************************************************
* TIME_MMTimeStart
*/
LPWINE_MM_IDATA
TIME_MMTimeStart
(
void
)
void
TIME_MMTimeStart
(
void
)
{
LPWINE_MM_IDATA
iData
=
MULTIMEDIA_GetIData
();
if
(
IsBadWritePtr
(
iData
,
sizeof
(
WINE_MM_IDATA
)))
{
if
(
IsBadWritePtr
(
WINMM_IData
,
sizeof
(
WINE_MM_IDATA
)))
{
ERR
(
"iData is not correctly set, please report. Expect failure.
\n
"
);
return
0
;
return
;
}
/* one could think it's possible to stop the service thread activity when no more
* mm timers are active, but this would require to keep mmSysTimeMS up-to-date
* without being incremented within the service thread callback.
*/
if
(
!
i
Data
->
hMMTimer
)
{
i
Data
->
mmSysTimeMS
=
GetTickCount
();
i
Data
->
lpTimerList
=
NULL
;
iData
->
hMMTimer
=
CreateThread
(
NULL
,
0
,
TIME_MMSysTimeThread
,
i
Data
,
0
,
NULL
);
if
(
!
WINMM_I
Data
->
hMMTimer
)
{
WINMM_I
Data
->
mmSysTimeMS
=
GetTickCount
();
WINMM_I
Data
->
lpTimerList
=
NULL
;
WINMM_IData
->
hMMTimer
=
CreateThread
(
NULL
,
0
,
TIME_MMSysTimeThread
,
WINMM_I
Data
,
0
,
NULL
);
}
return
iData
;
}
/**************************************************************************
...
...
@@ -202,15 +199,13 @@ LPWINE_MM_IDATA TIME_MMTimeStart(void)
*/
void
TIME_MMTimeStop
(
void
)
{
LPWINE_MM_IDATA
iData
=
MULTIMEDIA_GetIData
();
if
(
IsBadWritePtr
(
iData
,
sizeof
(
WINE_MM_IDATA
)))
{
ERR
(
"iData is not correctly set, please report. Expect failure.
\n
"
);
if
(
IsBadWritePtr
(
WINMM_IData
,
sizeof
(
WINE_MM_IDATA
)))
{
ERR
(
"WINMM_IData is not correctly set, please report. Expect failure.
\n
"
);
return
;
}
if
(
i
Data
->
hMMTimer
)
{
HANDLE
hMMTimer
=
i
Data
->
hMMTimer
;
i
Data
->
hMMTimer
=
0
;
if
(
WINMM_I
Data
->
hMMTimer
)
{
HANDLE
hMMTimer
=
WINMM_I
Data
->
hMMTimer
;
WINMM_I
Data
->
hMMTimer
=
0
;
WaitForSingleObject
(
hMMTimer
,
INFINITE
);
CloseHandle
(
hMMTimer
);
}
...
...
@@ -224,8 +219,9 @@ MMRESULT WINAPI timeGetSystemTime(LPMMTIME lpTime, UINT wSize)
TRACE
(
"(%p, %u);
\n
"
,
lpTime
,
wSize
);
if
(
wSize
>=
sizeof
(
*
lpTime
))
{
TIME_MMTimeStart
();
lpTime
->
wType
=
TIME_MS
;
lpTime
->
u
.
ms
=
TIME_MMTimeStart
()
->
mmSysTimeMS
;
lpTime
->
u
.
ms
=
WINMM_IData
->
mmSysTimeMS
;
TRACE
(
"=> %lu
\n
"
,
lpTime
->
u
.
ms
);
}
...
...
@@ -242,7 +238,6 @@ WORD timeSetEventInternal(UINT wDelay, UINT wResol,
WORD
wNewID
=
0
;
LPWINE_TIMERENTRY
lpNewTimer
;
LPWINE_TIMERENTRY
lpTimer
;
LPWINE_MM_IDATA
iData
;
TRACE
(
"(%u, %u, %p, %08lX, %04X);
\n
"
,
wDelay
,
wResol
,
lpFunc
,
dwUser
,
wFlags
);
...
...
@@ -253,7 +248,7 @@ WORD timeSetEventInternal(UINT wDelay, UINT wResol,
if
(
wDelay
<
MMSYSTIME_MININTERVAL
||
wDelay
>
MMSYSTIME_MAXINTERVAL
)
return
0
;
iData
=
TIME_MMTimeStart
();
TIME_MMTimeStart
();
lpNewTimer
->
uCurTime
=
wDelay
;
lpNewTimer
->
wDelay
=
wDelay
;
...
...
@@ -262,17 +257,17 @@ WORD timeSetEventInternal(UINT wDelay, UINT wResol,
lpNewTimer
->
dwUser
=
dwUser
;
lpNewTimer
->
wFlags
=
wFlags
;
EnterCriticalSection
(
&
i
Data
->
cs
);
EnterCriticalSection
(
&
WINMM_I
Data
->
cs
);
for
(
lpTimer
=
i
Data
->
lpTimerList
;
lpTimer
!=
NULL
;
lpTimer
=
lpTimer
->
lpNext
)
{
for
(
lpTimer
=
WINMM_I
Data
->
lpTimerList
;
lpTimer
!=
NULL
;
lpTimer
=
lpTimer
->
lpNext
)
{
wNewID
=
max
(
wNewID
,
lpTimer
->
wTimerID
);
}
lpNewTimer
->
lpNext
=
i
Data
->
lpTimerList
;
i
Data
->
lpTimerList
=
lpNewTimer
;
lpNewTimer
->
lpNext
=
WINMM_I
Data
->
lpTimerList
;
WINMM_I
Data
->
lpTimerList
=
lpNewTimer
;
lpNewTimer
->
wTimerID
=
wNewID
+
1
;
LeaveCriticalSection
(
&
i
Data
->
cs
);
LeaveCriticalSection
(
&
WINMM_I
Data
->
cs
);
TRACE
(
"=> %u
\n
"
,
wNewID
+
1
);
...
...
@@ -298,18 +293,17 @@ MMRESULT WINAPI timeSetEvent(UINT wDelay, UINT wResol, LPTIMECALLBACK lpFunc,
MMRESULT
WINAPI
timeKillEvent
(
UINT
wID
)
{
LPWINE_TIMERENTRY
*
lpTimer
;
LPWINE_MM_IDATA
iData
=
MULTIMEDIA_GetIData
();
MMRESULT
ret
=
MMSYSERR_INVALPARAM
;
TRACE
(
"(%u)
\n
"
,
wID
);
EnterCriticalSection
(
&
i
Data
->
cs
);
EnterCriticalSection
(
&
WINMM_I
Data
->
cs
);
/* remove WINE_TIMERENTRY from list */
for
(
lpTimer
=
&
i
Data
->
lpTimerList
;
*
lpTimer
;
lpTimer
=
&
(
*
lpTimer
)
->
lpNext
)
{
for
(
lpTimer
=
&
WINMM_I
Data
->
lpTimerList
;
*
lpTimer
;
lpTimer
=
&
(
*
lpTimer
)
->
lpNext
)
{
if
(
wID
==
(
*
lpTimer
)
->
wTimerID
)
{
break
;
}
}
LeaveCriticalSection
(
&
i
Data
->
cs
);
LeaveCriticalSection
(
&
WINMM_I
Data
->
cs
);
if
(
*
lpTimer
)
{
LPWINE_TIMERENTRY
lpTemp
=
*
lpTimer
;
...
...
@@ -373,5 +367,6 @@ DWORD WINAPI timeGetTime(void)
DWORD
count
;
ReleaseThunkLock
(
&
count
);
RestoreThunkLock
(
count
);
return
TIME_MMTimeStart
()
->
mmSysTimeMS
;
TIME_MMTimeStart
();
return
WINMM_IData
->
mmSysTimeMS
;
}
dlls/winmm/winemm.h
View file @
1e3e87d4
...
...
@@ -257,15 +257,17 @@ LPMMIOPROC MMIO_InstallIOProc(FOURCC fccIOProc, LPMMIOPROC
DWORD
dwFlags
,
enum
mmioProcType
type
);
LRESULT
MMIO_SendMessage
(
HMMIO
hmmio
,
UINT
uMessage
,
LPARAM
lParam1
,
LPARAM
lParam2
,
enum
mmioProcType
type
);
LPWINE_MMIO
MMIO_Get
(
LPWINE_MM_IDATA
iData
,
HMMIO
h
);
LPWINE_MMIO
MMIO_Get
(
HMMIO
h
);
BOOL
MULTIMEDIA_MciInit
(
void
);
LPWINE_MM_IDATA
MULTIMEDIA_GetIData
(
void
);
BOOL
MULTIMEDIA_PlaySound
(
const
void
*
pszSound
,
HMODULE
hmod
,
DWORD
fdwSound
,
BOOL
bUnicode
);
LPWINE_MM_IDATA
TIME_MMTimeStart
(
void
);
void
TIME_MMTimeStart
(
void
);
void
TIME_MMTimeStop
(
void
);
/* Global variables */
extern
LPWINE_MM_IDATA
WINMM_IData
;
/* HANDLE16 -> HANDLE conversions */
#define HDRVR_32(h16) ((HDRVR)(ULONG_PTR)(h16))
#define HMIDI_32(h16) ((HMIDI)(ULONG_PTR)(h16))
...
...
dlls/winmm/winmm.c
View file @
1e3e87d4
...
...
@@ -72,36 +72,23 @@ void MMSYSTEM_MMTIME16to32(LPMMTIME mmt32, const MMTIME16* mmt16)
* G L O B A L S E T T I N G S
* ========================================================================*/
static
LPWINE_MM_IDATA
S_IData
=
NULL
;
/**************************************************************************
* MULTIMEDIA_GetIData [internal]
*/
LPWINE_MM_IDATA
MULTIMEDIA_GetIData
(
void
)
{
if
(
!
S_IData
)
{
ERR
(
"IData not found for pid=%08lx. Suicide !!!
\n
"
,
GetCurrentProcessId
());
DbgBreakPoint
();
ExitProcess
(
0
);
}
return
S_IData
;
}
LPWINE_MM_IDATA
WINMM_IData
/* = NULL */
;
/**************************************************************************
* MULTIMEDIA_CreateIData [internal]
*/
static
BOOL
MULTIMEDIA_CreateIData
(
HINSTANCE
hInstDLL
)
{
S
_IData
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
WINE_MM_IDATA
));
WINMM
_IData
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
WINE_MM_IDATA
));
if
(
!
S
_IData
)
if
(
!
WINMM
_IData
)
return
FALSE
;
S
_IData
->
hWinMM32Instance
=
hInstDLL
;
InitializeCriticalSection
(
&
S
_IData
->
cs
);
S
_IData
->
cs
.
DebugInfo
=
(
void
*
)
__FILE__
": WinMM"
;
S
_IData
->
psStopEvent
=
CreateEventA
(
NULL
,
TRUE
,
FALSE
,
NULL
);
S
_IData
->
psLastEvent
=
CreateEventA
(
NULL
,
TRUE
,
FALSE
,
NULL
);
TRACE
(
"Created IData (%p)
\n
"
,
S
_IData
);
WINMM
_IData
->
hWinMM32Instance
=
hInstDLL
;
InitializeCriticalSection
(
&
WINMM
_IData
->
cs
);
WINMM
_IData
->
cs
.
DebugInfo
=
(
void
*
)
__FILE__
": WinMM"
;
WINMM
_IData
->
psStopEvent
=
CreateEventA
(
NULL
,
TRUE
,
FALSE
,
NULL
);
WINMM
_IData
->
psLastEvent
=
CreateEventA
(
NULL
,
TRUE
,
FALSE
,
NULL
);
TRACE
(
"Created IData (%p)
\n
"
,
WINMM
_IData
);
return
TRUE
;
}
...
...
@@ -110,16 +97,16 @@ static BOOL MULTIMEDIA_CreateIData(HINSTANCE hInstDLL)
*/
static
void
MULTIMEDIA_DeleteIData
(
void
)
{
if
(
S
_IData
)
{
if
(
WINMM
_IData
)
{
TIME_MMTimeStop
();
/* FIXME: should also free content and resources allocated
* inside
S
_IData */
CloseHandle
(
S
_IData
->
psStopEvent
);
CloseHandle
(
S
_IData
->
psLastEvent
);
DeleteCriticalSection
(
&
S
_IData
->
cs
);
HeapFree
(
GetProcessHeap
(),
0
,
S
_IData
);
S
_IData
=
NULL
;
* inside
WINMM
_IData */
CloseHandle
(
WINMM
_IData
->
psStopEvent
);
CloseHandle
(
WINMM
_IData
->
psLastEvent
);
DeleteCriticalSection
(
&
WINMM
_IData
->
cs
);
HeapFree
(
GetProcessHeap
(),
0
,
WINMM
_IData
);
WINMM
_IData
=
NULL
;
}
}
...
...
@@ -701,7 +688,7 @@ BOOL WINAPI mciGetErrorStringA(DWORD dwError, LPSTR lpstrBuffer, UINT uLength)
if
(
lpstrBuffer
!=
NULL
&&
uLength
>
0
&&
dwError
>=
MCIERR_BASE
&&
dwError
<=
MCIERR_CUSTOM_DRIVER_BASE
)
{
if
(
LoadStringA
(
MULTIMEDIA_GetIData
()
->
hWinMM32Instance
,
if
(
LoadStringA
(
WINMM_IData
->
hWinMM32Instance
,
dwError
,
lpstrBuffer
,
uLength
)
>
0
)
{
ret
=
TRUE
;
}
...
...
@@ -986,7 +973,7 @@ static UINT16 MIDI_GetErrorText(UINT16 uError, LPSTR lpText, UINT16 uSize)
(
/*uError >= MMSYSERR_BASE && */
uError
<=
MMSYSERR_LASTERROR
)
||
(
uError
>=
MIDIERR_BASE
&&
uError
<=
MIDIERR_LASTERROR
))
{
if
(
LoadStringA
(
MULTIMEDIA_GetIData
()
->
hWinMM32Instance
,
if
(
LoadStringA
(
WINMM_IData
->
hWinMM32Instance
,
uError
,
lpText
,
uSize
)
>
0
)
{
ret
=
MMSYSERR_NOERROR
;
}
...
...
@@ -2286,7 +2273,7 @@ static UINT16 WAVE_GetErrorText(UINT16 uError, LPSTR lpText, UINT16 uSize)
(
/*uError >= MMSYSERR_BASE && */
uError
<=
MMSYSERR_LASTERROR
)
||
(
uError
>=
WAVERR_BASE
&&
uError
<=
WAVERR_LASTERROR
))
{
if
(
LoadStringA
(
MULTIMEDIA_GetIData
()
->
hWinMM32Instance
,
if
(
LoadStringA
(
WINMM_IData
->
hWinMM32Instance
,
uError
,
lpText
,
uSize
)
>
0
)
{
ret
=
MMSYSERR_NOERROR
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment