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
c2cf4ddb
Commit
c2cf4ddb
authored
Nov 29, 2012
by
Akihiro Sagawa
Committed by
Alexandre Julliard
Nov 28, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winmm: Fix handling of mmio file buffers.
parent
579f4f9d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
26 deletions
+22
-26
mmio.c
dlls/winmm/mmio.c
+14
-18
mmio.c
dlls/winmm/tests/mmio.c
+8
-8
No files found.
dlls/winmm/mmio.c
View file @
c2cf4ddb
...
...
@@ -771,6 +771,8 @@ LONG WINAPI mmioRead(HMMIO hmmio, HPSTR pch, LONG cch)
return
send_message
(
wm
->
ioProc
,
&
wm
->
info
,
MMIOM_READ
,
(
LPARAM
)
pch
,
cch
,
FALSE
);
/* first try from current buffer */
if
(
cch
&&
wm
->
info
.
fccIOProc
!=
FOURCC_MEM
&&
wm
->
info
.
pchNext
==
wm
->
info
.
pchEndRead
)
MMIO_GrabNextBuffer
(
wm
,
TRUE
);
if
(
wm
->
info
.
pchNext
!=
wm
->
info
.
pchEndRead
)
{
count
=
wm
->
info
.
pchEndRead
-
wm
->
info
.
pchNext
;
if
(
count
>
cch
||
count
<
0
)
count
=
cch
;
...
...
@@ -796,6 +798,8 @@ LONG WINAPI mmioRead(HMMIO hmmio, HPSTR pch, LONG cch)
cch
-=
size
;
count
+=
size
;
}
wm
->
bBufferLoaded
=
FALSE
;
mmioSeek
(
hmmio
,
0
,
SEEK_CUR
);
}
TRACE
(
"count=%d
\n
"
,
count
);
...
...
@@ -887,35 +891,27 @@ LONG WINAPI mmioSeek(HMMIO hmmio, LONG lOffset, INT iOrigin)
return
-
1
;
}
if
(
offset
&&
offset
>=
wm
->
dwFileSize
&&
wm
->
info
.
fccIOProc
!=
FOURCC_MEM
)
{
/* should check that write mode exists */
if
(
MMIO_Flush
(
wm
,
0
)
!=
MMSYSERR_NOERROR
)
return
-
1
;
wm
->
info
.
lBufOffset
=
offset
;
wm
->
info
.
pchEndRead
=
wm
->
info
.
pchBuffer
;
wm
->
info
.
pchEndWrite
=
wm
->
info
.
pchBuffer
+
wm
->
info
.
cchBuffer
;
if
((
wm
->
info
.
dwFlags
&
MMIO_RWMODE
)
==
MMIO_READ
)
{
wm
->
info
.
lDiskOffset
=
wm
->
dwFileSize
;
}
}
else
if
((
wm
->
info
.
cchBuffer
>
0
)
&&
/* stay in same buffer ? */
/* some memory mapped buffers are defined with -1 as a size */
if
((
wm
->
info
.
cchBuffer
>
0
)
&&
((
offset
<
wm
->
info
.
lBufOffset
)
||
(
offset
>=
wm
->
info
.
lBufOffset
+
wm
->
info
.
cchBuffer
)
||
(
offset
>
wm
->
dwFileSize
&&
wm
->
info
.
fccIOProc
!=
FOURCC_MEM
)
||
!
wm
->
bBufferLoaded
))
{
/* stay in same buffer ? */
/* some memory mapped buffers are defined with -1 as a size */
/* condition to change buffer */
if
((
wm
->
info
.
fccIOProc
==
FOURCC_MEM
)
||
MMIO_Flush
(
wm
,
0
)
!=
MMSYSERR_NOERROR
||
/* this also sets the wm->info.lDiskOffset field */
send_message
(
wm
->
ioProc
,
&
wm
->
info
,
MMIOM_SEEK
,
(
offset
/
wm
->
info
.
cchBuffer
)
*
wm
->
info
.
cchBuffer
,
SEEK_SET
,
FALSE
)
==
-
1
)
offset
,
SEEK_SET
,
FALSE
)
==
-
1
)
return
-
1
;
MMIO_GrabNextBuffer
(
wm
,
TRUE
);
wm
->
info
.
lBufOffset
=
offset
;
wm
->
bBufferLoaded
=
FALSE
;
wm
->
info
.
pchNext
=
wm
->
info
.
pchEndRead
=
wm
->
info
.
pchBuffer
;
}
wm
->
info
.
pchNext
=
wm
->
info
.
pchBuffer
+
(
offset
-
wm
->
info
.
lBufOffset
);
else
wm
->
info
.
pchNext
=
wm
->
info
.
pchBuffer
+
(
offset
-
wm
->
info
.
lBufOffset
);
TRACE
(
"=> %d
\n
"
,
offset
);
return
offset
;
...
...
dlls/winmm/tests/mmio.c
View file @
c2cf4ddb
...
...
@@ -812,14 +812,14 @@ static void test_mmio_end_of_file(void)
ok
(
sizeof
(
RIFF_buf
)
==
ret
,
"got %d
\n
"
,
ret
);
ret
=
mmioRead
(
hmmio
,
data
,
sizeof
(
data
));
todo_wine
ok
(
ret
==
0
,
"expected %d, got %d
\n
"
,
0
,
ret
);
ok
(
ret
==
0
,
"expected %d, got %d
\n
"
,
0
,
ret
);
res
=
mmioGetInfo
(
hmmio
,
&
mmio
,
0
);
ok
(
res
==
MMSYSERR_NOERROR
,
"expected 0, got %d
\n
"
,
res
);
res
=
mmioAdvance
(
hmmio
,
&
mmio
,
MMIO_READ
);
ok
(
res
==
MMSYSERR_NOERROR
,
"expected 0, got %d
\n
"
,
res
);
todo_wine
ok
(
mmio
.
pchNext
==
mmio
.
pchEndRead
,
"expected %p, got %p
\n
"
,
mmio
.
pchEndRead
,
mmio
.
pchNext
);
ok
(
mmio
.
pchNext
==
mmio
.
pchEndRead
,
"expected %p, got %p
\n
"
,
mmio
.
pchEndRead
,
mmio
.
pchNext
);
mmioClose
(
hmmio
,
0
);
DeleteFileA
(
test_file
);
...
...
@@ -874,18 +874,18 @@ static void test_mmio_buffer_pointer(void)
ok
(
pos
==
size
,
"failed to seek, got %d
\n
"
,
pos
);
res
=
mmioGetInfo
(
hmmio
,
&
mmio
,
0
);
ok
(
res
==
MMSYSERR_NOERROR
,
"expected 0, got %d
\n
"
,
res
);
todo_wine
ok
(
mmio
.
lBufOffset
==
size
,
"expected %d, got %d
\n
"
,
size
,
mmio
.
lBufOffset
);
todo_wine
ok
(
mmio
.
pchNext
==
mmio
.
pchBuffer
,
"expected %p, got %p
\n
"
,
mmio
.
pchBuffer
,
mmio
.
pchNext
);
todo_wine
ok
(
mmio
.
pchEndRead
==
mmio
.
pchBuffer
,
"expected %p, got %p
\n
"
,
mmio
.
pchBuffer
,
mmio
.
pchEndRead
);
ok
(
mmio
.
lBufOffset
==
size
,
"expected %d, got %d
\n
"
,
size
,
mmio
.
lBufOffset
);
ok
(
mmio
.
pchNext
==
mmio
.
pchBuffer
,
"expected %p, got %p
\n
"
,
mmio
.
pchBuffer
,
mmio
.
pchNext
);
ok
(
mmio
.
pchEndRead
==
mmio
.
pchBuffer
,
"expected %p, got %p
\n
"
,
mmio
.
pchBuffer
,
mmio
.
pchEndRead
);
/* reading a lot (as sizeof(data) > mmio.cchBuffer), the buffer is empty */
size
=
mmioRead
(
hmmio
,
data
,
sizeof
(
data
));
ok
(
size
==
sizeof
(
data
),
"failed to read, got %d
\n
"
,
size
);
res
=
mmioGetInfo
(
hmmio
,
&
mmio
,
0
);
ok
(
res
==
MMSYSERR_NOERROR
,
"expected 0, got %d
\n
"
,
res
);
todo_wine
ok
(
mmio
.
lBufOffset
==
pos
+
size
,
"expected %d, got %d
\n
"
,
pos
+
size
,
mmio
.
lBufOffset
);
todo_wine
ok
(
mmio
.
pchNext
==
mmio
.
pchBuffer
,
"expected %p, got %p
\n
"
,
mmio
.
pchBuffer
,
mmio
.
pchNext
);
todo_wine
ok
(
mmio
.
pchEndRead
==
mmio
.
pchBuffer
,
"expected %p, got %p
\n
"
,
mmio
.
pchBuffer
,
mmio
.
pchEndRead
);
ok
(
mmio
.
lBufOffset
==
pos
+
size
,
"expected %d, got %d
\n
"
,
pos
+
size
,
mmio
.
lBufOffset
);
ok
(
mmio
.
pchNext
==
mmio
.
pchBuffer
,
"expected %p, got %p
\n
"
,
mmio
.
pchBuffer
,
mmio
.
pchNext
);
ok
(
mmio
.
pchEndRead
==
mmio
.
pchBuffer
,
"expected %p, got %p
\n
"
,
mmio
.
pchBuffer
,
mmio
.
pchEndRead
);
mmioClose
(
hmmio
,
0
);
DeleteFileA
(
test_file
);
...
...
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