2 * Unit tests for mmio APIs
4 * Copyright 2005 Dmitry Timoshkov
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
28 #include "wine/test.h"
30 static DWORD RIFF_buf
[] =
32 FOURCC_RIFF
, 32*sizeof(DWORD
), mmioFOURCC('A','V','I',' '),
33 FOURCC_LIST
, 29*sizeof(DWORD
), listtypeAVIHEADER
, ckidAVIMAINHDR
,
34 sizeof(MainAVIHeader
), 0xdeadbeef, 0xdeadbeef, 0xdeadbeef,
35 0xdeadbeef, 0xdeadbeef, 0xdeadbeef,0xdeadbeef,
36 0xdeadbeef, 0xdeadbeef, 0xdeadbeef,0xdeadbeef,
37 0xdeadbeef, 0xdeadbeef, 0xdeadbeef,
38 FOURCC_LIST
, 10*sizeof(DWORD
),listtypeSTREAMHEADER
, ckidSTREAMHEADER
,
39 7*sizeof(DWORD
), streamtypeVIDEO
, 0xdeadbeef, 0xdeadbeef,
40 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef,
41 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
42 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
43 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
44 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
47 static void expect_buf_offset_dbg(HMMIO hmmio
, LONG off
, int line
)
52 memset(&mmio
, 0, sizeof(mmio
));
53 ret
= mmioGetInfo(hmmio
, &mmio
, 0);
54 ok_(__FILE__
, line
)(ret
== MMSYSERR_NOERROR
, "mmioGetInfo error %u\n", ret
);
55 ok_(__FILE__
, line
)(mmio
.lBufOffset
== 0, "expected 0, got %d\n", mmio
.lBufOffset
);
56 ret
= mmioSeek(hmmio
, 0, SEEK_CUR
);
57 ok_(__FILE__
, line
)(ret
== off
, "expected %d, got %d\n", off
, ret
);
60 #define expect_buf_offset(a1, a2) expect_buf_offset_dbg(a1, a2, __LINE__)
62 static void test_mmioDescend(char *fname
)
67 MMCKINFO ckRiff
, ckList
, ck
, ckList2
;
69 memset(&mmio
, 0, sizeof(mmio
));
70 mmio
.fccIOProc
= fname
? FOURCC_DOS
: FOURCC_MEM
;
71 mmio
.cchBuffer
= sizeof(RIFF_buf
);
72 mmio
.pchBuffer
= (char *)RIFF_buf
;
73 hmmio
= mmioOpenA(fname
, &mmio
, MMIO_READ
);
76 trace("No optional %s file. Skipping the test\n", fname
);
79 ok(hmmio
!= 0, "mmioOpenA error %u\n", mmio
.wErrorRet
);
81 expect_buf_offset(hmmio
, 0);
83 /* first normal RIFF AVI parsing */
84 ret
= mmioDescend(hmmio
, &ckRiff
, NULL
, 0);
85 ok(ret
== MMSYSERR_NOERROR
, "mmioDescend error %u\n", ret
);
86 ok(ckRiff
.ckid
== FOURCC_RIFF
, "wrong ckid: %04x\n", ckRiff
.ckid
);
87 ok(ckRiff
.fccType
== formtypeAVI
, "wrong fccType: %04x\n", ckRiff
.fccType
);
88 ok(ckRiff
.dwDataOffset
== 8, "expected 8 got %u\n", ckRiff
.dwDataOffset
);
89 trace("ckid %4.4s cksize %04x fccType %4.4s off %04x flags %04x\n",
90 (LPCSTR
)&ckRiff
.ckid
, ckRiff
.cksize
, (LPCSTR
)&ckRiff
.fccType
,
91 ckRiff
.dwDataOffset
, ckRiff
.dwFlags
);
93 expect_buf_offset(hmmio
, 12);
95 ret
= mmioDescend(hmmio
, &ckList
, &ckRiff
, 0);
96 ok(ret
== MMSYSERR_NOERROR
, "mmioDescend error %u\n", ret
);
97 ok(ckList
.ckid
== FOURCC_LIST
, "wrong ckid: %04x\n", ckList
.ckid
);
98 ok(ckList
.fccType
== listtypeAVIHEADER
, "wrong fccType: %04x\n", ckList
.fccType
);
99 ok(ckList
.dwDataOffset
== 20, "expected 20 got %u\n", ckList
.dwDataOffset
);
100 trace("ckid %4.4s cksize %04x fccType %4.4s off %04x flags %04x\n",
101 (LPCSTR
)&ckList
.ckid
, ckList
.cksize
, (LPCSTR
)&ckList
.fccType
,
102 ckList
.dwDataOffset
, ckList
.dwFlags
);
104 expect_buf_offset(hmmio
, 24);
106 ret
= mmioDescend(hmmio
, &ck
, &ckList
, 0);
107 ok(ret
== MMSYSERR_NOERROR
, "mmioDescend error %u\n", ret
);
108 ok(ck
.ckid
== ckidAVIMAINHDR
, "wrong ckid: %04x\n", ck
.ckid
);
109 ok(ck
.fccType
== 0, "wrong fccType: %04x\n", ck
.fccType
);
110 trace("ckid %4.4s cksize %04x fccType %4.4s off %04x flags %04x\n",
111 (LPCSTR
)&ck
.ckid
, ck
.cksize
, (LPCSTR
)&ck
.fccType
,
112 ck
.dwDataOffset
, ck
.dwFlags
);
114 expect_buf_offset(hmmio
, 32);
116 /* Skip chunk data */
117 ret
= mmioSeek(hmmio
, ck
.cksize
, SEEK_CUR
);
118 ok(ret
== 0x58, "expected 0x58, got %#x\n", ret
);
120 ret
= mmioDescend(hmmio
, &ckList2
, &ckList
, 0);
121 ok(ret
== MMSYSERR_NOERROR
, "mmioDescend error %u\n", ret
);
122 ok(ckList2
.ckid
== FOURCC_LIST
, "wrong ckid: %04x\n", ckList2
.ckid
);
123 ok(ckList2
.fccType
== listtypeSTREAMHEADER
, "wrong fccType: %04x\n", ckList2
.fccType
);
124 trace("ckid %4.4s cksize %04x fccType %4.4s off %04x flags %04x\n",
125 (LPCSTR
)&ckList2
.ckid
, ckList2
.cksize
, (LPCSTR
)&ckList2
.fccType
,
126 ckList2
.dwDataOffset
, ckList2
.dwFlags
);
128 expect_buf_offset(hmmio
, 100);
130 ret
= mmioDescend(hmmio
, &ck
, &ckList2
, 0);
131 ok(ret
== MMSYSERR_NOERROR
, "mmioDescend error %u\n", ret
);
132 ok(ck
.ckid
== ckidSTREAMHEADER
, "wrong ckid: %04x\n", ck
.ckid
);
133 ok(ck
.fccType
== 0, "wrong fccType: %04x\n", ck
.fccType
);
134 trace("ckid %4.4s cksize %04x fccType %4.4s off %04x flags %04x\n",
135 (LPCSTR
)&ck
.ckid
, ck
.cksize
, (LPCSTR
)&ck
.fccType
,
136 ck
.dwDataOffset
, ck
.dwFlags
);
138 expect_buf_offset(hmmio
, 108);
140 /* test various mmioDescend flags */
142 mmioSeek(hmmio
, 0, SEEK_SET
);
143 memset(&ck
, 0x66, sizeof(ck
));
144 ret
= mmioDescend(hmmio
, &ck
, NULL
, MMIO_FINDRIFF
);
145 ok(ret
== MMIOERR_CHUNKNOTFOUND
||
146 ret
== MMIOERR_INVALIDFILE
, "mmioDescend returned %u\n", ret
);
148 mmioSeek(hmmio
, 0, SEEK_SET
);
149 memset(&ck
, 0x66, sizeof(ck
));
151 ret
= mmioDescend(hmmio
, &ck
, NULL
, MMIO_FINDRIFF
);
152 ok(ret
== MMIOERR_CHUNKNOTFOUND
||
153 ret
== MMIOERR_INVALIDFILE
, "mmioDescend returned %u\n", ret
);
155 mmioSeek(hmmio
, 0, SEEK_SET
);
156 memset(&ck
, 0x66, sizeof(ck
));
158 ret
= mmioDescend(hmmio
, &ck
, NULL
, MMIO_FINDRIFF
);
159 ok(ret
== MMSYSERR_NOERROR
, "mmioDescend error %u\n", ret
);
160 ok(ck
.ckid
== FOURCC_RIFF
, "wrong ckid: %04x\n", ck
.ckid
);
161 ok(ck
.fccType
== formtypeAVI
, "wrong fccType: %04x\n", ck
.fccType
);
163 mmioSeek(hmmio
, 0, SEEK_SET
);
164 memset(&ck
, 0x66, sizeof(ck
));
165 ret
= mmioDescend(hmmio
, &ck
, NULL
, 0);
166 ok(ret
== MMSYSERR_NOERROR
, "mmioDescend error %u\n", ret
);
167 ok(ck
.ckid
== FOURCC_RIFF
, "wrong ckid: %04x\n", ck
.ckid
);
168 ok(ck
.fccType
== formtypeAVI
, "wrong fccType: %04x\n", ck
.fccType
);
170 /* do NOT seek, use current file position */
171 memset(&ck
, 0x66, sizeof(ck
));
173 ret
= mmioDescend(hmmio
, &ck
, NULL
, MMIO_FINDLIST
);
174 ok(ret
== MMSYSERR_NOERROR
, "mmioDescend error %u\n", ret
);
175 ok(ck
.ckid
== FOURCC_LIST
, "wrong ckid: %04x\n", ck
.ckid
);
176 ok(ck
.fccType
== listtypeAVIHEADER
, "wrong fccType: %04x\n", ck
.fccType
);
178 mmioSeek(hmmio
, 0, SEEK_SET
);
179 memset(&ck
, 0x66, sizeof(ck
));
181 ck
.fccType
= listtypeAVIHEADER
;
182 ret
= mmioDescend(hmmio
, &ck
, NULL
, MMIO_FINDCHUNK
);
183 ok(ret
== MMSYSERR_NOERROR
, "mmioDescend error %u\n", ret
);
184 ok(ck
.ckid
== FOURCC_RIFF
, "wrong ckid: %04x\n", ck
.ckid
);
185 ok(ck
.fccType
== formtypeAVI
, "wrong fccType: %04x\n", ck
.fccType
);
187 /* do NOT seek, use current file position */
188 memset(&ck
, 0x66, sizeof(ck
));
189 ck
.ckid
= FOURCC_LIST
;
190 ret
= mmioDescend(hmmio
, &ck
, NULL
, MMIO_FINDCHUNK
);
191 ok(ret
== MMSYSERR_NOERROR
, "mmioDescend error %u\n", ret
);
192 ok(ck
.ckid
== FOURCC_LIST
, "wrong ckid: %04x\n", ck
.ckid
);
193 ok(ck
.fccType
== listtypeAVIHEADER
, "wrong fccType: %04x\n", ck
.fccType
);
195 mmioSeek(hmmio
, 0, SEEK_SET
);
196 memset(&ck
, 0x66, sizeof(ck
));
197 ck
.ckid
= FOURCC_RIFF
;
198 ret
= mmioDescend(hmmio
, &ck
, NULL
, MMIO_FINDCHUNK
);
199 ok(ret
== MMSYSERR_NOERROR
, "mmioDescend error %u\n", ret
);
200 ok(ck
.ckid
== FOURCC_RIFF
, "wrong ckid: %04x\n", ck
.ckid
);
201 ok(ck
.fccType
== formtypeAVI
, "wrong fccType: %04x\n", ck
.fccType
);
203 /* do NOT seek, use current file position */
204 memset(&ckList
, 0x66, sizeof(ckList
));
206 ret
= mmioDescend(hmmio
, &ckList
, &ck
, MMIO_FINDCHUNK
);
207 ok(ret
== MMSYSERR_NOERROR
, "mmioDescend error %u\n", ret
);
208 ok(ckList
.ckid
== FOURCC_LIST
, "wrong ckid: %04x\n", ckList
.ckid
);
209 ok(ckList
.fccType
== listtypeAVIHEADER
, "wrong fccType: %04x\n", ckList
.fccType
);
211 mmioSeek(hmmio
, 0, SEEK_SET
);
212 memset(&ck
, 0x66, sizeof(ck
));
213 ret
= mmioDescend(hmmio
, &ck
, NULL
, MMIO_FINDCHUNK
);
214 ok(ret
== MMIOERR_CHUNKNOTFOUND
||
215 ret
== MMIOERR_INVALIDFILE
, "mmioDescend returned %u\n", ret
);
216 ok(ck
.ckid
!= 0x66666666, "wrong ckid: %04x\n", ck
.ckid
);
217 ok(ck
.fccType
!= 0x66666666, "wrong fccType: %04x\n", ck
.fccType
);
218 ok(ck
.dwDataOffset
!= 0x66666666, "wrong dwDataOffset: %04x\n", ck
.dwDataOffset
);
220 mmioSeek(hmmio
, 0, SEEK_SET
);
221 memset(&ck
, 0x66, sizeof(ck
));
222 ret
= mmioDescend(hmmio
, &ck
, NULL
, MMIO_FINDRIFF
);
223 ok(ret
== MMIOERR_CHUNKNOTFOUND
||
224 ret
== MMIOERR_INVALIDFILE
, "mmioDescend returned %u\n", ret
);
229 static void test_mmioOpen(char *fname
)
231 char buf
[MMIO_DEFAULTBUFFER
];
236 memset(&mmio
, 0, sizeof(mmio
));
237 mmio
.fccIOProc
= fname
? FOURCC_DOS
: FOURCC_MEM
;
238 mmio
.cchBuffer
= sizeof(buf
);
239 mmio
.pchBuffer
= buf
;
240 hmmio
= mmioOpenA(fname
, &mmio
, MMIO_READ
);
243 trace("No optional %s file. Skipping the test\n", fname
);
246 ok(hmmio
!= 0, "mmioOpenA error %u\n", mmio
.wErrorRet
);
248 memset(&mmio
, 0, sizeof(mmio
));
249 ret
= mmioGetInfo(hmmio
, &mmio
, 0);
250 ok(ret
== MMSYSERR_NOERROR
, "mmioGetInfo error %u\n", ret
);
251 ok(mmio
.dwFlags
== MMIO_READ
, "expected MMIO_READ, got %x\n", mmio
.dwFlags
);
252 ok(mmio
.wErrorRet
== MMSYSERR_NOERROR
, "expected MMSYSERR_NOERROR, got %u\n", mmio
.wErrorRet
);
253 ok(mmio
.fccIOProc
== (fname
? FOURCC_DOS
: FOURCC_MEM
), "got %4.4s\n", (LPCSTR
)&mmio
.fccIOProc
);
254 ok(mmio
.cchBuffer
== sizeof(buf
), "got %u\n", mmio
.cchBuffer
);
255 ok(mmio
.pchBuffer
== buf
, "expected %p, got %p\n", buf
, mmio
.pchBuffer
);
256 ok(mmio
.pchNext
== mmio
.pchBuffer
, "expected %p, got %p\n", mmio
.pchBuffer
, mmio
.pchNext
);
257 if (mmio
.fccIOProc
== FOURCC_DOS
)
258 ok(mmio
.pchEndRead
== mmio
.pchBuffer
, "expected %p, got %p\n", mmio
.pchBuffer
, mmio
.pchEndRead
);
260 ok(mmio
.pchEndRead
== mmio
.pchBuffer
+ mmio
.cchBuffer
, "expected %p + %d, got %p\n", mmio
.pchBuffer
, mmio
.cchBuffer
, mmio
.pchEndRead
);
261 ok(mmio
.pchEndWrite
== mmio
.pchBuffer
+ mmio
.cchBuffer
, "expected %p + %d, got %p\n", mmio
.pchBuffer
, mmio
.cchBuffer
, mmio
.pchEndWrite
);
262 ok(mmio
.lBufOffset
== 0, "expected 0, got %d\n", mmio
.lBufOffset
);
263 ok(mmio
.lDiskOffset
== 0, "expected 0, got %d\n", mmio
.lDiskOffset
);
265 ret
= mmioSeek(hmmio
, 0, SEEK_CUR
);
266 ok(ret
== 0, "expected 0, got %d\n", ret
);
270 memset(&mmio
, 0, sizeof(mmio
));
271 mmio
.fccIOProc
= fname
? FOURCC_DOS
: FOURCC_MEM
;
273 mmio
.pchBuffer
= buf
;
274 hmmio
= mmioOpenA(fname
, &mmio
, MMIO_READ
);
275 ok(hmmio
!= 0, "mmioOpenA error %u\n", mmio
.wErrorRet
);
277 memset(&mmio
, 0, sizeof(mmio
));
278 ret
= mmioGetInfo(hmmio
, &mmio
, 0);
279 ok(ret
== MMSYSERR_NOERROR
, "mmioGetInfo error %u\n", ret
);
280 ok(mmio
.dwFlags
== MMIO_READ
, "expected MMIO_READ, got %x\n", mmio
.dwFlags
);
281 ok(mmio
.wErrorRet
== MMSYSERR_NOERROR
, "expected MMSYSERR_NOERROR, got %u\n", mmio
.wErrorRet
);
282 ok(mmio
.fccIOProc
== (fname
? FOURCC_DOS
: FOURCC_MEM
), "got %4.4s\n", (LPCSTR
)&mmio
.fccIOProc
);
283 ok(mmio
.cchBuffer
== 0, "expected 0, got %u\n", mmio
.cchBuffer
);
284 ok(mmio
.pchBuffer
== buf
, "expected %p, got %p\n", buf
, mmio
.pchBuffer
);
285 ok(mmio
.pchNext
== mmio
.pchBuffer
, "expected %p, got %p\n", mmio
.pchBuffer
, mmio
.pchNext
);
286 ok(mmio
.pchEndRead
== mmio
.pchBuffer
, "expected %p, got %p\n", mmio
.pchBuffer
, mmio
.pchEndRead
);
287 ok(mmio
.pchEndWrite
== mmio
.pchBuffer
, "expected %p, got %p\n", mmio
.pchBuffer
, mmio
.pchEndWrite
);
288 ok(mmio
.lBufOffset
== 0, "expected 0, got %d\n", mmio
.lBufOffset
);
289 ok(mmio
.lDiskOffset
== 0, "expected 0, got %d\n", mmio
.lDiskOffset
);
291 ret
= mmioSeek(hmmio
, 0, SEEK_CUR
);
292 ok(ret
== 0, "expected 0, got %d\n", ret
);
296 memset(&mmio
, 0, sizeof(mmio
));
297 mmio
.fccIOProc
= fname
? FOURCC_DOS
: FOURCC_MEM
;
299 mmio
.pchBuffer
= NULL
;
300 hmmio
= mmioOpenA(fname
, &mmio
, MMIO_READ
);
301 ok(hmmio
!= 0, "mmioOpenA error %u\n", mmio
.wErrorRet
);
303 memset(&mmio
, 0, sizeof(mmio
));
304 ret
= mmioGetInfo(hmmio
, &mmio
, 0);
305 ok(ret
== MMSYSERR_NOERROR
, "mmioGetInfo error %u\n", ret
);
306 ok(mmio
.dwFlags
== MMIO_READ
, "expected MMIO_READ, got %x\n", mmio
.dwFlags
);
307 ok(mmio
.wErrorRet
== MMSYSERR_NOERROR
, "expected MMSYSERR_NOERROR, got %u\n", mmio
.wErrorRet
);
308 ok(mmio
.fccIOProc
== (fname
? FOURCC_DOS
: FOURCC_MEM
), "got %4.4s\n", (LPCSTR
)&mmio
.fccIOProc
);
309 ok(mmio
.cchBuffer
== 0, "expected 0, got %u\n", mmio
.cchBuffer
);
310 ok(mmio
.pchBuffer
== NULL
, "expected NULL\n");
311 ok(mmio
.pchNext
== NULL
, "expected NULL\n");
312 ok(mmio
.pchEndRead
== NULL
, "expected NULL\n");
313 ok(mmio
.pchEndWrite
== NULL
, "expected NULL\n");
314 ok(mmio
.lBufOffset
== 0, "expected 0, got %d\n", mmio
.lBufOffset
);
315 ok(mmio
.lDiskOffset
== 0, "expected 0, got %d\n", mmio
.lDiskOffset
);
317 ret
= mmioSeek(hmmio
, 0, SEEK_CUR
);
318 ok(ret
== 0, "expected 0, got %d\n", ret
);
322 memset(&mmio
, 0, sizeof(mmio
));
323 mmio
.fccIOProc
= fname
? FOURCC_DOS
: FOURCC_MEM
;
324 mmio
.cchBuffer
= 256;
325 mmio
.pchBuffer
= NULL
;
326 hmmio
= mmioOpenA(fname
, &mmio
, MMIO_READ
);
327 ok(hmmio
!= 0, "mmioOpenA error %u\n", mmio
.wErrorRet
);
329 memset(&mmio
, 0, sizeof(mmio
));
330 ret
= mmioGetInfo(hmmio
, &mmio
, 0);
331 ok(ret
== MMSYSERR_NOERROR
, "mmioGetInfo error %u\n", ret
);
332 ok(mmio
.dwFlags
== (MMIO_READ
|MMIO_ALLOCBUF
), "expected MMIO_READ|MMIO_ALLOCBUF, got %x\n", mmio
.dwFlags
);
333 ok(mmio
.wErrorRet
== MMSYSERR_NOERROR
, "expected MMSYSERR_NOERROR, got %u\n", mmio
.wErrorRet
);
334 ok(mmio
.fccIOProc
== (fname
? FOURCC_DOS
: FOURCC_MEM
), "got %4.4s\n", (LPCSTR
)&mmio
.fccIOProc
);
335 ok(mmio
.cchBuffer
== 256, "expected 256, got %u\n", mmio
.cchBuffer
);
336 ok(mmio
.pchBuffer
!= NULL
, "expected not NULL\n");
337 ok(mmio
.pchNext
== mmio
.pchBuffer
, "expected %p, got %p\n", mmio
.pchBuffer
, mmio
.pchNext
);
338 if (mmio
.fccIOProc
== FOURCC_DOS
)
339 ok(mmio
.pchEndRead
== mmio
.pchBuffer
, "expected %p, got %p\n", mmio
.pchBuffer
, mmio
.pchEndRead
);
341 ok(mmio
.pchEndRead
== mmio
.pchBuffer
+ mmio
.cchBuffer
, "expected %p + %d, got %p\n", mmio
.pchBuffer
, mmio
.cchBuffer
, mmio
.pchEndRead
);
342 ok(mmio
.pchEndWrite
== mmio
.pchBuffer
+ mmio
.cchBuffer
, "expected %p + %d, got %p\n", mmio
.pchBuffer
, mmio
.cchBuffer
, mmio
.pchEndWrite
);
343 ok(mmio
.lBufOffset
== 0, "expected 0, got %d\n", mmio
.lBufOffset
);
344 ok(mmio
.lDiskOffset
== 0, "expected 0, got %d\n", mmio
.lDiskOffset
);
346 ret
= mmioSeek(hmmio
, 0, SEEK_CUR
);
347 ok(ret
== 0, "expected 0, got %d\n", ret
);
351 memset(&mmio
, 0, sizeof(mmio
));
352 mmio
.fccIOProc
= fname
? FOURCC_DOS
: FOURCC_MEM
;
353 mmio
.cchBuffer
= sizeof(buf
);
354 mmio
.pchBuffer
= buf
;
355 hmmio
= mmioOpenA(fname
, &mmio
, MMIO_READ
| MMIO_ALLOCBUF
);
356 ok(hmmio
!= 0, "mmioOpenA error %u\n", mmio
.wErrorRet
);
358 memset(&mmio
, 0, sizeof(mmio
));
359 ret
= mmioGetInfo(hmmio
, &mmio
, 0);
360 ok(ret
== MMSYSERR_NOERROR
, "mmioGetInfo error %u\n", ret
);
361 ok(mmio
.dwFlags
== MMIO_READ
, "expected MMIO_READ, got %x\n", mmio
.dwFlags
);
362 ok(mmio
.wErrorRet
== MMSYSERR_NOERROR
, "expected MMSYSERR_NOERROR, got %u\n", mmio
.wErrorRet
);
363 ok(mmio
.fccIOProc
== (fname
? FOURCC_DOS
: FOURCC_MEM
), "got %4.4s\n", (LPCSTR
)&mmio
.fccIOProc
);
364 ok(mmio
.cchBuffer
== sizeof(buf
), "got %u\n", mmio
.cchBuffer
);
365 ok(mmio
.pchBuffer
== buf
, "expected %p, got %p\n", buf
, mmio
.pchBuffer
);
366 ok(mmio
.pchNext
== mmio
.pchBuffer
, "expected %p, got %p\n", mmio
.pchBuffer
, mmio
.pchNext
);
367 if (mmio
.fccIOProc
== FOURCC_DOS
)
368 ok(mmio
.pchEndRead
== mmio
.pchBuffer
, "expected %p, got %p\n", mmio
.pchBuffer
, mmio
.pchEndRead
);
370 ok(mmio
.pchEndRead
== mmio
.pchBuffer
+ mmio
.cchBuffer
, "expected %p + %d, got %p\n", mmio
.pchBuffer
, mmio
.cchBuffer
, mmio
.pchEndRead
);
371 ok(mmio
.pchEndWrite
== mmio
.pchBuffer
+ mmio
.cchBuffer
, "expected %p + %d, got %p\n", mmio
.pchBuffer
, mmio
.cchBuffer
, mmio
.pchEndWrite
);
372 ok(mmio
.lBufOffset
== 0, "expected 0, got %d\n", mmio
.lBufOffset
);
373 ok(mmio
.lDiskOffset
== 0, "expected 0, got %d\n", mmio
.lDiskOffset
);
375 ret
= mmioSeek(hmmio
, 0, SEEK_CUR
);
376 ok(ret
== 0, "expected 0, got %d\n", ret
);
380 memset(&mmio
, 0, sizeof(mmio
));
381 mmio
.fccIOProc
= fname
? FOURCC_DOS
: FOURCC_MEM
;
383 mmio
.pchBuffer
= NULL
;
384 hmmio
= mmioOpenA(fname
, &mmio
, MMIO_READ
| MMIO_ALLOCBUF
);
385 ok(hmmio
!= 0, "mmioOpenA error %u\n", mmio
.wErrorRet
);
387 memset(&mmio
, 0, sizeof(mmio
));
388 ret
= mmioGetInfo(hmmio
, &mmio
, 0);
389 ok(ret
== MMSYSERR_NOERROR
, "mmioGetInfo error %u\n", ret
);
390 ok(mmio
.dwFlags
== (MMIO_READ
|MMIO_ALLOCBUF
), "expected MMIO_READ|MMIO_ALLOCBUF, got %x\n", mmio
.dwFlags
);
391 ok(mmio
.wErrorRet
== MMSYSERR_NOERROR
, "expected MMSYSERR_NOERROR, got %u\n", mmio
.wErrorRet
);
392 ok(mmio
.fccIOProc
== (fname
? FOURCC_DOS
: FOURCC_MEM
), "got %4.4s\n", (LPCSTR
)&mmio
.fccIOProc
);
393 ok(mmio
.cchBuffer
== MMIO_DEFAULTBUFFER
, "expected MMIO_DEFAULTBUFFER, got %u\n", mmio
.cchBuffer
);
394 ok(mmio
.pchBuffer
!= NULL
, "expected not NULL\n");
395 ok(mmio
.pchNext
== mmio
.pchBuffer
, "expected %p, got %p\n", mmio
.pchBuffer
, mmio
.pchNext
);
396 if (mmio
.fccIOProc
== FOURCC_DOS
)
397 ok(mmio
.pchEndRead
== mmio
.pchBuffer
, "expected %p, got %p\n", mmio
.pchBuffer
, mmio
.pchEndRead
);
399 ok(mmio
.pchEndRead
== mmio
.pchBuffer
+ mmio
.cchBuffer
, "expected %p + %d, got %p\n", mmio
.pchBuffer
, mmio
.cchBuffer
, mmio
.pchEndRead
);
400 ok(mmio
.pchEndWrite
== mmio
.pchBuffer
+ mmio
.cchBuffer
, "expected %p + %d, got %p\n", mmio
.pchBuffer
, mmio
.cchBuffer
, mmio
.pchEndWrite
);
401 ok(mmio
.lBufOffset
== 0, "expected 0, got %d\n", mmio
.lBufOffset
);
402 ok(mmio
.lDiskOffset
== 0, "expected 0, got %d\n", mmio
.lDiskOffset
);
404 ret
= mmioSeek(hmmio
, 0, SEEK_CUR
);
405 ok(ret
== 0, "expected 0, got %d\n", ret
);
409 memset(&mmio
, 0, sizeof(mmio
));
410 mmio
.fccIOProc
= fname
? FOURCC_DOS
: FOURCC_MEM
;
411 mmio
.cchBuffer
= 256;
412 mmio
.pchBuffer
= NULL
;
413 hmmio
= mmioOpenA(fname
, &mmio
, MMIO_READ
| MMIO_ALLOCBUF
);
414 ok(hmmio
!= 0, "mmioOpenA error %u\n", mmio
.wErrorRet
);
416 memset(&mmio
, 0, sizeof(mmio
));
417 ret
= mmioGetInfo(hmmio
, &mmio
, 0);
418 ok(ret
== MMSYSERR_NOERROR
, "mmioGetInfo error %u\n", ret
);
419 ok(mmio
.dwFlags
== (MMIO_READ
|MMIO_ALLOCBUF
), "expected MMIO_READ|MMIO_ALLOCBUF, got %x\n", mmio
.dwFlags
);
420 ok(mmio
.wErrorRet
== MMSYSERR_NOERROR
, "expected MMSYSERR_NOERROR, got %u\n", mmio
.wErrorRet
);
421 ok(mmio
.fccIOProc
== (fname
? FOURCC_DOS
: FOURCC_MEM
), "got %4.4s\n", (LPCSTR
)&mmio
.fccIOProc
);
422 ok(mmio
.cchBuffer
== 256, "expected 256, got %u\n", mmio
.cchBuffer
);
423 ok(mmio
.pchBuffer
!= NULL
, "expected not NULL\n");
424 ok(mmio
.pchNext
== mmio
.pchBuffer
, "expected %p, got %p\n", mmio
.pchBuffer
, mmio
.pchNext
);
425 if (mmio
.fccIOProc
== FOURCC_DOS
)
426 ok(mmio
.pchEndRead
== mmio
.pchBuffer
, "expected %p, got %p\n", mmio
.pchBuffer
, mmio
.pchEndRead
);
428 ok(mmio
.pchEndRead
== mmio
.pchBuffer
+ mmio
.cchBuffer
, "expected %p + %d, got %p\n", mmio
.pchBuffer
, mmio
.cchBuffer
, mmio
.pchEndRead
);
429 ok(mmio
.pchEndWrite
== mmio
.pchBuffer
+ mmio
.cchBuffer
, "expected %p + %d, got %p\n", mmio
.pchBuffer
, mmio
.cchBuffer
, mmio
.pchEndWrite
);
430 ok(mmio
.lBufOffset
== 0, "expected 0, got %d\n", mmio
.lBufOffset
);
431 ok(mmio
.lDiskOffset
== 0, "expected 0, got %d\n", mmio
.lDiskOffset
);
433 ret
= mmioSeek(hmmio
, 0, SEEK_CUR
);
434 ok(ret
== 0, "expected 0, got %d\n", ret
);
438 memset(&mmio
, 0, sizeof(mmio
));
439 mmio
.fccIOProc
= fname
? FOURCC_DOS
: FOURCC_MEM
;
441 mmio
.pchBuffer
= buf
;
442 hmmio
= mmioOpenA(fname
, &mmio
, MMIO_READ
| MMIO_ALLOCBUF
);
443 if (!hmmio
&& mmio
.wErrorRet
== ERROR_BAD_FORMAT
)
445 /* Seen on Win9x, WinMe but also XP-SP1 */
446 skip("Some Windows versions don't like a 0 size and a given buffer\n");
449 ok(hmmio
!= 0, "mmioOpenA error %u\n", mmio
.wErrorRet
);
451 memset(&mmio
, 0, sizeof(mmio
));
452 ret
= mmioGetInfo(hmmio
, &mmio
, 0);
453 ok(ret
== MMSYSERR_NOERROR
, "mmioGetInfo error %u\n", ret
);
454 ok(mmio
.dwFlags
== MMIO_READ
, "expected MMIO_READ, got %x\n", mmio
.dwFlags
);
455 ok(mmio
.wErrorRet
== MMSYSERR_NOERROR
, "expected MMSYSERR_NOERROR, got %u\n", mmio
.wErrorRet
);
456 ok(mmio
.fccIOProc
== (fname
? FOURCC_DOS
: FOURCC_MEM
), "got %4.4s\n", (LPCSTR
)&mmio
.fccIOProc
);
457 ok(mmio
.cchBuffer
== MMIO_DEFAULTBUFFER
, "expected MMIO_DEFAULTBUFFER, got %u\n", mmio
.cchBuffer
);
458 ok(mmio
.pchBuffer
== buf
, "expected %p, got %p\n", buf
, mmio
.pchBuffer
);
459 ok(mmio
.pchNext
== mmio
.pchBuffer
, "expected %p, got %p\n", mmio
.pchBuffer
, mmio
.pchNext
);
460 if (mmio
.fccIOProc
== FOURCC_DOS
)
461 ok(mmio
.pchEndRead
== mmio
.pchBuffer
, "expected %p, got %p\n", mmio
.pchBuffer
, mmio
.pchEndRead
);
463 ok(mmio
.pchEndRead
== mmio
.pchBuffer
+ mmio
.cchBuffer
, "expected %p + %d, got %p\n", mmio
.pchBuffer
, mmio
.cchBuffer
, mmio
.pchEndRead
);
464 ok(mmio
.pchEndWrite
== mmio
.pchBuffer
+ mmio
.cchBuffer
, "expected %p + %d, got %p\n", mmio
.pchBuffer
, mmio
.cchBuffer
, mmio
.pchEndWrite
);
465 ok(mmio
.lBufOffset
== 0, "expected 0, got %d\n", mmio
.lBufOffset
);
466 ok(mmio
.lDiskOffset
== 0, "expected 0, got %d\n", mmio
.lDiskOffset
);
468 ret
= mmioSeek(hmmio
, 0, SEEK_CUR
);
469 ok(ret
== 0, "expected 0, got %d\n", ret
);
474 static void test_mmioOpen_create(void)
478 WCHAR cwd
[MAX_PATH
], temp_dir
[MAX_PATH
];
479 /* According to docs, filename must be no more than 128 bytes, but it will
480 * actually allow longer than that. */
481 WCHAR long_filename
[] = L
"very_long_filename_"
482 L
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
483 L
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
484 L
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
485 WCHAR buffer
[MAX_PATH
], expect
[MAX_PATH
];
486 char exedir_filename
[MAX_PATH
], bufferA
[MAX_PATH
], expectA
[MAX_PATH
];
491 GetModuleFileNameA(NULL
, exedir_filename
, ARRAY_SIZE(exedir_filename
));
492 strcpy(strrchr(exedir_filename
, '\\') + 1, "test_mmio_path");
493 f
= fopen(exedir_filename
, "w");
494 ok(!!f
, "failed to create %s: %s\n", debugstr_a(exedir_filename
), strerror(errno
));
497 GetCurrentDirectoryW(ARRAY_SIZE(cwd
), cwd
);
498 GetTempPathW(ARRAY_SIZE(temp_dir
), temp_dir
);
499 SetCurrentDirectoryW(temp_dir
);
501 DeleteFileW(long_filename
);
503 /* open with MMIO_DENYNONE */
504 hmmio
= mmioOpenW(long_filename
, NULL
, MMIO_CREATE
| MMIO_WRITE
| MMIO_DENYNONE
);
505 ok(hmmio
!= NULL
, "mmioOpen failed\n");
507 /* MMIO_DENYNONE lets us open it here, too */
508 handle
= CreateFileW(long_filename
, GENERIC_READ
,
509 FILE_SHARE_WRITE
| FILE_SHARE_READ
| FILE_SHARE_DELETE
, NULL
,
510 OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
511 ok(handle
!= INVALID_HANDLE_VALUE
, "Couldn't open non-exclusive file\n");
516 DeleteFileW(long_filename
);
518 /* open with MMIO_EXCLUSIVE */
519 hmmio
= mmioOpenW(long_filename
, NULL
, MMIO_CREATE
| MMIO_WRITE
| MMIO_EXCLUSIVE
);
520 ok(hmmio
!= NULL
, "mmioOpen failed\n");
522 /* should fail due to MMIO_EXCLUSIVE */
523 handle
= CreateFileW(long_filename
, GENERIC_READ
,
524 FILE_SHARE_WRITE
| FILE_SHARE_READ
| FILE_SHARE_DELETE
, NULL
,
525 OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
526 ok(handle
== INVALID_HANDLE_VALUE
, "Opening exclusive file should have failed\n");
527 if(handle
!= INVALID_HANDLE_VALUE
)
532 DeleteFileW(long_filename
);
534 wcscpy(buffer
, long_filename
);
535 info
.wErrorRet
= 0xdead;
536 hmmio
= mmioOpenW(buffer
, &info
, MMIO_PARSE
);
537 todo_wine
ok(hmmio
== (HMMIO
)FALSE
, "failed to parse file name, error %#x\n", info
.wErrorRet
);
538 todo_wine
ok(info
.wErrorRet
== MMIOERR_OUTOFMEMORY
, "got error %#x\n", info
.wErrorRet
);
539 wcscpy(expect
, temp_dir
);
540 wcscat(expect
, long_filename
);
542 todo_wine
ok(!wcscmp(buffer
, expect
), "expected %s, got %s\n", debugstr_w(expect
), debugstr_w(buffer
));
544 WideCharToMultiByte(CP_ACP
, 0, long_filename
, -1, bufferA
, sizeof(bufferA
), NULL
, NULL
);
545 info
.wErrorRet
= 0xdead;
546 hmmio
= mmioOpenA(bufferA
, &info
, MMIO_PARSE
);
547 todo_wine
ok(hmmio
== (HMMIO
)FALSE
, "failed to parse file name, error %#x\n", info
.wErrorRet
);
548 todo_wine
ok(info
.wErrorRet
== MMIOERR_OUTOFMEMORY
, "got error %#x\n", info
.wErrorRet
);
549 WideCharToMultiByte(CP_ACP
, 0, long_filename
, -1, expectA
, sizeof(expectA
), NULL
, NULL
);
550 todo_wine
ok(!strcmp(bufferA
, expectA
), "expected %s, got %s\n", debugstr_a(expectA
), debugstr_a(bufferA
));
552 wcscpy(buffer
, L
"test_mmio_path");
553 hmmio
= mmioOpenW(buffer
, &info
, MMIO_WRITE
);
554 ok(!!hmmio
, "failed to open file, error %#x\n", info
.wErrorRet
);
557 wcscpy(buffer
, L
"test_mmio_path");
558 hmmio
= mmioOpenW(buffer
, &info
, MMIO_PARSE
);
559 ok(hmmio
== (HMMIO
)TRUE
, "failed to parse file name, error %#x\n", info
.wErrorRet
);
560 wcscpy(expect
, temp_dir
);
561 wcscat(expect
, L
"test_mmio_path");
562 todo_wine
ok(!wcscmp(buffer
, expect
), "expected %s, got %s\n", debugstr_w(expect
), debugstr_w(buffer
));
564 wcscpy(buffer
, L
"test_mmio_path");
565 info
.wErrorRet
= 0xdead;
566 hmmio
= mmioOpenW(buffer
, &info
, MMIO_EXIST
);
567 ok(hmmio
== (HMMIO
)FALSE
, "file should exist\n");
568 todo_wine
ok(info
.wErrorRet
== MMIOERR_FILENOTFOUND
, "got error %#x\n", info
.wErrorRet
);
570 ret
= DeleteFileA("test_mmio_path");
571 ok(!ret
, "expected failure\n");
572 ok(GetLastError() == ERROR_FILE_NOT_FOUND
, "got error %u\n", GetLastError());
574 wcscpy(buffer
, L
"test_mmio_path");
575 hmmio
= mmioOpenW(buffer
, &info
, MMIO_WRITE
| MMIO_CREATE
);
576 ok(!!hmmio
, "failed to open file, error %#x\n", info
.wErrorRet
);
579 ret
= DeleteFileA("test_mmio_path");
580 ok(ret
, "got error %u\n", GetLastError());
582 SetCurrentDirectoryW(cwd
);
584 ret
= DeleteFileA(exedir_filename
);
585 ok(ret
, "got error %u\n", GetLastError());
588 static void test_mmioSetBuffer(char *fname
)
595 memset(&mmio
, 0, sizeof(mmio
));
596 mmio
.fccIOProc
= fname
? FOURCC_DOS
: FOURCC_MEM
;
597 mmio
.cchBuffer
= sizeof(buf
);
598 mmio
.pchBuffer
= buf
;
599 hmmio
= mmioOpenA(fname
, &mmio
, MMIO_READ
);
602 trace("No optional %s file. Skipping the test\n", fname
);
605 ok(hmmio
!= 0, "mmioOpenA error %u\n", mmio
.wErrorRet
);
607 memset(&mmio
, 0, sizeof(mmio
));
608 ret
= mmioGetInfo(hmmio
, &mmio
, 0);
609 ok(ret
== MMSYSERR_NOERROR
, "mmioGetInfo error %u\n", ret
);
610 ok(mmio
.dwFlags
== MMIO_READ
, "expected MMIO_READ, got %x\n", mmio
.dwFlags
);
611 ok(mmio
.wErrorRet
== MMSYSERR_NOERROR
, "expected MMSYSERR_NOERROR, got %u\n", mmio
.wErrorRet
);
612 ok(mmio
.fccIOProc
== (fname
? FOURCC_DOS
: FOURCC_MEM
), "got %4.4s\n", (LPCSTR
)&mmio
.fccIOProc
);
613 ok(mmio
.cchBuffer
== sizeof(buf
), "got %u\n", mmio
.cchBuffer
);
614 ok(mmio
.pchBuffer
== buf
, "expected %p, got %p\n", buf
, mmio
.pchBuffer
);
615 ok(mmio
.pchNext
== mmio
.pchBuffer
, "expected %p, got %p\n", mmio
.pchBuffer
, mmio
.pchNext
);
616 if (mmio
.fccIOProc
== FOURCC_DOS
)
617 ok(mmio
.pchEndRead
== mmio
.pchBuffer
, "expected %p, got %p\n", mmio
.pchBuffer
, mmio
.pchEndRead
);
619 ok(mmio
.pchEndRead
== mmio
.pchBuffer
+ mmio
.cchBuffer
, "expected %p + %d, got %p\n", mmio
.pchBuffer
, mmio
.cchBuffer
, mmio
.pchEndRead
);
620 ok(mmio
.pchEndWrite
== mmio
.pchBuffer
+ mmio
.cchBuffer
, "expected %p + %d, got %p\n", mmio
.pchBuffer
, mmio
.cchBuffer
, mmio
.pchEndWrite
);
621 ok(mmio
.lBufOffset
== 0, "expected 0, got %d\n", mmio
.lBufOffset
);
622 ok(mmio
.lDiskOffset
== 0, "expected 0, got %d\n", mmio
.lDiskOffset
);
624 ret
= mmioSeek(hmmio
, 0, SEEK_CUR
);
625 ok(ret
== 0, "expected 0, got %d\n", ret
);
627 ret
= mmioSetBuffer(hmmio
, NULL
, 0, 0);
628 ok(ret
== MMSYSERR_NOERROR
, "mmioSetBuffer error %u\n", ret
);
630 memset(&mmio
, 0, sizeof(mmio
));
631 ret
= mmioGetInfo(hmmio
, &mmio
, 0);
632 ok(ret
== MMSYSERR_NOERROR
, "mmioGetInfo error %u\n", ret
);
633 ok(mmio
.dwFlags
== MMIO_READ
, "expected MMIO_READ, got %x\n", mmio
.dwFlags
);
634 ok(mmio
.wErrorRet
== MMSYSERR_NOERROR
, "expected MMSYSERR_NOERROR, got %u\n", mmio
.wErrorRet
);
635 ok(mmio
.fccIOProc
== (fname
? FOURCC_DOS
: FOURCC_MEM
), "got %4.4s\n", (LPCSTR
)&mmio
.fccIOProc
);
636 ok(mmio
.cchBuffer
== 0, "got not 0\n");
637 ok(mmio
.pchBuffer
== NULL
, "got not NULL buf\n");
638 ok(mmio
.pchNext
== mmio
.pchBuffer
, "expected %p, got %p\n", mmio
.pchBuffer
, mmio
.pchNext
);
639 ok(mmio
.pchEndRead
== mmio
.pchBuffer
, "expected %p, got %p\n", mmio
.pchBuffer
, mmio
.pchEndRead
);
640 ok(mmio
.pchEndWrite
== mmio
.pchBuffer
, "expected %p, got %p\n", mmio
.pchBuffer
, mmio
.pchEndWrite
);
641 ok(mmio
.lBufOffset
== 0, "expected 0, got %d\n", mmio
.lBufOffset
);
642 ok(mmio
.lDiskOffset
== 0, "expected 0, got %d\n", mmio
.lDiskOffset
);
644 ret
= mmioSeek(hmmio
, 0, SEEK_CUR
);
645 ok(ret
== 0, "expected 0, got %d\n", ret
);
647 ret
= mmioSetBuffer(hmmio
, NULL
, 0, MMIO_ALLOCBUF
);
648 ok(ret
== MMSYSERR_NOERROR
, "mmioSetBuffer error %u\n", ret
);
650 memset(&mmio
, 0, sizeof(mmio
));
651 ret
= mmioGetInfo(hmmio
, &mmio
, 0);
652 ok(ret
== MMSYSERR_NOERROR
, "mmioGetInfo error %u\n", ret
);
653 ok(mmio
.dwFlags
== MMIO_READ
, "expected MMIO_READ, got %x\n", mmio
.dwFlags
);
654 ok(mmio
.wErrorRet
== MMSYSERR_NOERROR
, "expected MMSYSERR_NOERROR, got %u\n", mmio
.wErrorRet
);
655 ok(mmio
.fccIOProc
== (fname
? FOURCC_DOS
: FOURCC_MEM
), "got %4.4s\n", (LPCSTR
)&mmio
.fccIOProc
);
656 ok(mmio
.cchBuffer
== 0, "got not 0\n");
657 ok(mmio
.pchBuffer
== NULL
, "got not NULL buf\n");
658 ok(mmio
.pchNext
== mmio
.pchBuffer
, "expected %p, got %p\n", mmio
.pchBuffer
, mmio
.pchNext
);
659 ok(mmio
.pchEndRead
== mmio
.pchBuffer
, "expected %p, got %p\n", mmio
.pchBuffer
, mmio
.pchEndRead
);
660 ok(mmio
.pchEndWrite
== mmio
.pchBuffer
, "expected %p, got %p\n", mmio
.pchBuffer
, mmio
.pchEndWrite
);
661 ok(mmio
.lBufOffset
== 0, "expected 0, got %d\n", mmio
.lBufOffset
);
662 ok(mmio
.lDiskOffset
== 0, "expected 0, got %d\n", mmio
.lDiskOffset
);
664 ret
= mmioSeek(hmmio
, 0, SEEK_CUR
);
665 ok(ret
== 0, "expected 0, got %d\n", ret
);
667 ret
= mmioSetBuffer(hmmio
, buf
, 0, MMIO_ALLOCBUF
);
668 ok(ret
== MMSYSERR_NOERROR
, "mmioSetBuffer error %u\n", ret
);
670 memset(&mmio
, 0, sizeof(mmio
));
671 ret
= mmioGetInfo(hmmio
, &mmio
, 0);
672 ok(ret
== MMSYSERR_NOERROR
, "mmioGetInfo error %u\n", ret
);
673 ok(mmio
.dwFlags
== MMIO_READ
, "expected MMIO_READ, got %x\n", mmio
.dwFlags
);
674 ok(mmio
.wErrorRet
== MMSYSERR_NOERROR
, "expected MMSYSERR_NOERROR, got %u\n", mmio
.wErrorRet
);
675 ok(mmio
.fccIOProc
== (fname
? FOURCC_DOS
: FOURCC_MEM
), "got %4.4s\n", (LPCSTR
)&mmio
.fccIOProc
);
676 ok(mmio
.cchBuffer
== 0, "got not 0\n");
677 ok(mmio
.pchBuffer
== buf
, "expected %p, got %p\n", buf
, mmio
.pchBuffer
);
678 ok(mmio
.pchNext
== mmio
.pchBuffer
, "expected %p, got %p\n", mmio
.pchBuffer
, mmio
.pchNext
);
679 ok(mmio
.pchEndRead
== mmio
.pchBuffer
, "expected %p, got %p\n", mmio
.pchBuffer
, mmio
.pchEndRead
);
680 ok(mmio
.pchEndWrite
== mmio
.pchBuffer
, "expected %p, got %p\n", mmio
.pchBuffer
, mmio
.pchEndWrite
);
681 ok(mmio
.lBufOffset
== 0, "expected 0, got %d\n", mmio
.lBufOffset
);
682 ok(mmio
.lDiskOffset
== 0, "expected 0, got %d\n", mmio
.lDiskOffset
);
684 ret
= mmioSeek(hmmio
, 0, SEEK_CUR
);
685 ok(ret
== 0, "expected 0, got %d\n", ret
);
687 ret
= mmioSetBuffer(hmmio
, NULL
, 256, MMIO_WRITE
|MMIO_ALLOCBUF
);
688 ok(ret
== MMSYSERR_NOERROR
, "mmioSetBuffer error %u\n", ret
);
690 memset(&mmio
, 0, sizeof(mmio
));
691 ret
= mmioGetInfo(hmmio
, &mmio
, 0);
692 ok(ret
== MMSYSERR_NOERROR
, "mmioGetInfo error %u\n", ret
);
693 ok(mmio
.dwFlags
== (MMIO_READ
|MMIO_ALLOCBUF
), "expected MMIO_READ|MMIO_ALLOCBUF, got %x\n", mmio
.dwFlags
);
694 ok(mmio
.wErrorRet
== MMSYSERR_NOERROR
, "expected MMSYSERR_NOERROR, got %u\n", mmio
.wErrorRet
);
695 ok(mmio
.fccIOProc
== (fname
? FOURCC_DOS
: FOURCC_MEM
), "got %4.4s\n", (LPCSTR
)&mmio
.fccIOProc
);
696 ok(mmio
.cchBuffer
== 256, "got %u\n", mmio
.cchBuffer
);
697 ok(mmio
.pchBuffer
!= NULL
, "expected not NULL\n");
698 ok(mmio
.pchBuffer
!= buf
, "expected != buf\n");
699 ok(mmio
.pchNext
== mmio
.pchBuffer
, "expected %p, got %p\n", mmio
.pchBuffer
, mmio
.pchNext
);
700 ok(mmio
.pchEndRead
== mmio
.pchBuffer
, "expected %p, got %p\n", buf
, mmio
.pchEndRead
);
701 ok(mmio
.pchEndWrite
== mmio
.pchBuffer
+ mmio
.cchBuffer
, "expected %p + %d, got %p\n", mmio
.pchBuffer
, mmio
.cchBuffer
, mmio
.pchEndWrite
);
702 ok(mmio
.lBufOffset
== 0, "expected 0, got %d\n", mmio
.lBufOffset
);
703 ok(mmio
.lDiskOffset
== 0, "expected 0, got %d\n", mmio
.lDiskOffset
);
705 ret
= mmioSeek(hmmio
, 0, SEEK_CUR
);
706 ok(ret
== 0, "expected 0, got %d\n", ret
);
711 #define FOURCC_XYZ mmioFOURCC('X', 'Y', 'Z', ' ')
713 static LRESULT CALLBACK
mmio_test_IOProc(LPSTR lpMMIOInfo
, UINT uMessage
, LPARAM lParam1
, LPARAM lParam2
)
715 LPMMIOINFO lpInfo
= (LPMMIOINFO
) lpMMIOInfo
;
721 if (lpInfo
->fccIOProc
== FOURCC_DOS
)
722 lpInfo
->fccIOProc
= mmioFOURCC('F', 'A', 'I', 'L');
723 for (i
= 0; i
< ARRAY_SIZE(lpInfo
->adwInfo
); i
++)
724 ok(lpInfo
->adwInfo
[i
] == 0, "[%d] Expected 0, got %u\n", i
, lpInfo
->adwInfo
[i
]);
725 return MMSYSERR_NOERROR
;
727 return MMSYSERR_NOERROR
;
729 lpInfo
->adwInfo
[1]++;
730 lpInfo
->lDiskOffset
= 0xdeadbeef;
737 static void test_mmioOpen_fourcc(void)
739 char fname
[] = "file+name.xyz+one.two";
745 lpProc
= mmioInstallIOProcA(FOURCC_DOS
, mmio_test_IOProc
, MMIO_INSTALLPROC
);
746 ok(lpProc
== mmio_test_IOProc
, "mmioInstallIOProcA error\n");
748 lpProc
= mmioInstallIOProcA(FOURCC_XYZ
, mmio_test_IOProc
, MMIO_INSTALLPROC
);
749 ok(lpProc
== mmio_test_IOProc
, "mmioInstallIOProcA error\n");
751 memset(&mmio
, 0, sizeof(mmio
));
752 hmmio
= mmioOpenA(fname
, &mmio
, MMIO_READ
);
753 mmioGetInfo(hmmio
, &mmio
, 0);
754 ok(hmmio
&& mmio
.fccIOProc
== FOURCC_XYZ
, "mmioOpenA error %u, got %4.4s\n",
755 mmio
.wErrorRet
, (LPCSTR
)&mmio
.fccIOProc
);
756 ok(mmio
.adwInfo
[1] == 0, "mmioOpenA sent MMIOM_SEEK, got %d\n",
758 ok(mmio
.lDiskOffset
== 0, "mmioOpenA updated lDiskOffset, got %d\n",
762 /* Same test with NULL info */
763 memset(&mmio
, 0, sizeof(mmio
));
764 hmmio
= mmioOpenA(fname
, NULL
, MMIO_READ
);
765 mmioGetInfo(hmmio
, &mmio
, 0);
766 ok(hmmio
&& mmio
.fccIOProc
== FOURCC_XYZ
, "mmioOpenA error %u, got %4.4s\n",
767 mmio
.wErrorRet
, (LPCSTR
)&mmio
.fccIOProc
);
768 ok(mmio
.adwInfo
[1] == 0, "mmioOpenA sent MMIOM_SEEK, got %d\n",
770 ok(mmio
.lDiskOffset
== 0, "mmioOpenA updated lDiskOffset, got %d\n",
774 mmioInstallIOProcA(FOURCC_XYZ
, NULL
, MMIO_REMOVEPROC
);
776 memset(&mmio
, 0, sizeof(mmio
));
777 hmmio
= mmioOpenA(fname
, &mmio
, MMIO_READ
);
778 mmioGetInfo(hmmio
, &mmio
, 0);
779 ok(!hmmio
&& mmio
.wErrorRet
== MMIOERR_FILENOTFOUND
, "mmioOpenA error %u, got %4.4s\n",
780 mmio
.wErrorRet
, (LPCSTR
)&mmio
.fccIOProc
);
783 mmioInstallIOProcA(FOURCC_DOS
, NULL
, MMIO_REMOVEPROC
);
786 static BOOL
create_test_file(char *temp_file
)
788 char temp_path
[MAX_PATH
];
792 ret
= GetTempPathA(sizeof(temp_path
), temp_path
);
793 ok(ret
, "Failed to get a temp path, err %d\n", GetLastError());
797 ret
= GetTempFileNameA(temp_path
, "mmio", 0, temp_file
);
798 ok(ret
, "Failed to get a temp name, err %d\n", GetLastError());
802 h
= CreateFileA(temp_file
, GENERIC_WRITE
, 0, NULL
,
803 CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
804 ok(h
!= INVALID_HANDLE_VALUE
, "Failed to create a file, err %d\n", GetLastError());
805 if (h
== INVALID_HANDLE_VALUE
) return FALSE
;
807 ret
= WriteFile(h
, RIFF_buf
, sizeof(RIFF_buf
), &written
, NULL
);
808 ok(ret
, "Failed to write a file, err %d\n", GetLastError());
810 if (!ret
) DeleteFileA(temp_file
);
814 static void test_mmioSeek(void)
819 const LONG size
= sizeof(RIFF_buf
), offset
= 16;
820 char test_file
[MAX_PATH
];
825 /* test memory file */
826 memset(&mmio
, 0, sizeof(mmio
));
827 mmio
.fccIOProc
= FOURCC_MEM
;
828 mmio
.pchBuffer
= (char*)&RIFF_buf
;
829 mmio
.cchBuffer
= sizeof(RIFF_buf
);
830 hmmio
= mmioOpenA(NULL
, &mmio
, MMIO_READ
);
831 ok(hmmio
!= 0, "mmioOpenA error %u\n", mmio
.wErrorRet
);
833 /* seek to the end */
834 end
= mmioSeek(hmmio
, 0, SEEK_END
);
835 ok(end
== size
, "expected %d, got %d\n", size
, end
);
837 /* test MMIOINFO values */
838 res
= mmioGetInfo(hmmio
, &mmio
, 0);
839 ok(res
== MMSYSERR_NOERROR
, "expected 0, got %d\n", res
);
840 ok(mmio
.pchNext
== mmio
.pchBuffer
+ mmio
.cchBuffer
, "expected %p + %d, got %p\n", mmio
.pchBuffer
, mmio
.cchBuffer
, mmio
.pchNext
);
841 ok(mmio
.pchEndRead
== mmio
.pchBuffer
+ mmio
.cchBuffer
, "expected %p + %d, got %p\n", mmio
.pchBuffer
, mmio
.cchBuffer
, mmio
.pchEndRead
);
842 ok(mmio
.pchEndWrite
== mmio
.pchBuffer
+ mmio
.cchBuffer
, "expected %p + %d, got %p\n", mmio
.pchBuffer
, mmio
.cchBuffer
, mmio
.pchEndWrite
);
843 ok(mmio
.lBufOffset
== 0, "expected %d, got %d\n", 0, mmio
.lBufOffset
);
844 ok(mmio
.lDiskOffset
== 0, "expected %d, got %d\n", 0, mmio
.lDiskOffset
);
846 /* seek backward from the end */
847 pos
= mmioSeek(hmmio
, offset
, SEEK_END
);
848 ok(pos
== size
-offset
, "expected %d, got %d\n", size
-offset
, pos
);
853 if (!create_test_file(test_file
)) return;
855 /* test standard file without buffering */
857 memset(&mmio
, 0, sizeof(mmio
));
858 mmio
.fccIOProc
= FOURCC_DOS
;
861 hmmio
= mmioOpenA(test_file
, &mmio
, MMIO_READ
);
862 ok(hmmio
!= 0, "mmioOpenA error %u\n", mmio
.wErrorRet
);
864 /* seek to the end */
865 end
= mmioSeek(hmmio
, 0, SEEK_END
);
866 ok(end
== size
, "expected %d, got %d\n", size
, end
);
868 /* test MMIOINFO values */
869 res
= mmioGetInfo(hmmio
, &mmio
, 0);
870 ok(res
== MMSYSERR_NOERROR
, "expected 0, got %d\n", res
);
871 ok(mmio
.pchNext
== mmio
.pchBuffer
, "expected %p, got %p\n", mmio
.pchBuffer
, mmio
.pchNext
);
872 ok(mmio
.pchEndRead
== mmio
.pchBuffer
, "expected %p, got %p\n", mmio
.pchBuffer
, mmio
.pchEndRead
);
873 ok(mmio
.pchEndWrite
== mmio
.pchBuffer
+ mmio
.cchBuffer
, "expected %p + %d, got %p\n", mmio
.pchBuffer
, mmio
.cchBuffer
, mmio
.pchEndWrite
);
874 ok(mmio
.lBufOffset
== size
, "expected %d, got %d\n", size
, mmio
.lBufOffset
);
875 ok(mmio
.lDiskOffset
== size
, "expected %d, got %d\n", size
, mmio
.lDiskOffset
);
877 /* seek backward from the end */
878 pos
= mmioSeek(hmmio
, offset
, SEEK_END
);
879 ok(pos
== size
-offset
, "expected %d, got %d\n", size
-offset
, pos
);
884 /* test standard file with buffering */
886 memset(&mmio
, 0, sizeof(mmio
));
887 mmio
.fccIOProc
= FOURCC_DOS
;
890 hmmio
= mmioOpenA(test_file
, &mmio
, MMIO_READ
| MMIO_ALLOCBUF
);
891 ok(hmmio
!= 0, "mmioOpenA error %u\n", mmio
.wErrorRet
);
893 /* seek to the end */
894 end
= mmioSeek(hmmio
, 0, SEEK_END
);
895 ok(end
== size
, "expected %d, got %d\n", size
, end
);
897 /* test MMIOINFO values */
898 res
= mmioGetInfo(hmmio
, &mmio
, 0);
899 ok(res
== MMSYSERR_NOERROR
, "expected 0, got %d\n", res
);
900 ok(mmio
.pchNext
== mmio
.pchBuffer
, "expected %p, got %p\n", mmio
.pchBuffer
, mmio
.pchNext
);
901 ok(mmio
.pchEndRead
== mmio
.pchBuffer
, "expected %p, got %p\n", mmio
.pchBuffer
, mmio
.pchEndRead
);
902 ok(mmio
.pchEndWrite
== mmio
.pchBuffer
+ mmio
.cchBuffer
, "expected %p + %d, got %p\n", mmio
.pchBuffer
, mmio
.cchBuffer
, mmio
.pchEndWrite
);
903 ok(mmio
.lBufOffset
== end
, "expected %d, got %d\n", end
, mmio
.lBufOffset
);
904 ok(mmio
.lDiskOffset
== size
, "expected %d, got %d\n", size
, mmio
.lDiskOffset
);
906 /* seek backward from the end */
907 pos
= mmioSeek(hmmio
, offset
, SEEK_END
);
908 ok(pos
== size
-offset
, "expected %d, got %d\n", size
-offset
, pos
);
913 /* test seek position inheritance from standard file handle */
914 hfile
= OpenFile(test_file
, &ofs
, OF_READ
);
915 ok(hfile
!= HFILE_ERROR
, "Failed to open the file, err %d\n", GetLastError());
916 if (hfile
!= HFILE_ERROR
) {
917 pos
= _llseek(hfile
, offset
, SEEK_SET
);
918 ok(pos
!= HFILE_ERROR
, "Failed to seek, err %d\n", GetLastError());
919 memset(&mmio
, 0, sizeof(mmio
));
920 mmio
.fccIOProc
= FOURCC_DOS
;
921 mmio
.adwInfo
[0] = (DWORD
)hfile
;
922 hmmio
= mmioOpenA(NULL
, &mmio
, MMIO_READ
| MMIO_DENYWRITE
| MMIO_ALLOCBUF
);
923 ok(hmmio
!= 0, "mmioOpenA error %u\n", mmio
.wErrorRet
);
925 pos
= mmioSeek(hmmio
, 0, SEEK_CUR
);
926 ok(pos
== offset
, "expected %d, got %d\n", offset
, pos
);
931 DeleteFileA(test_file
);
934 static void test_mmio_end_of_file(void)
936 char test_file
[MAX_PATH
], buffer
[128], data
[16];
942 if (!create_test_file(test_file
)) return;
944 memset(&mmio
, 0, sizeof(mmio
));
945 mmio
.fccIOProc
= FOURCC_DOS
;
946 mmio
.pchBuffer
= buffer
;
947 mmio
.cchBuffer
= sizeof(buffer
);
948 hmmio
= mmioOpenA(test_file
, &mmio
, MMIO_READ
);
949 ok(hmmio
!= 0, "mmioOpenA error %u\n", mmio
.wErrorRet
);
951 DeleteFileA(test_file
);
955 ret
= mmioSeek(hmmio
, 0, SEEK_END
);
956 ok(sizeof(RIFF_buf
) == ret
, "got %d\n", ret
);
958 ret
= mmioRead(hmmio
, data
, sizeof(data
));
959 ok(ret
== 0, "expected %d, got %d\n", 0, ret
);
961 res
= mmioGetInfo(hmmio
, &mmio
, 0);
962 ok(res
== MMSYSERR_NOERROR
, "expected 0, got %d\n", res
);
964 res
= mmioAdvance(hmmio
, &mmio
, MMIO_READ
);
965 ok(res
== MMSYSERR_NOERROR
, "expected 0, got %d\n", res
);
966 ok(mmio
.pchNext
== mmio
.pchEndRead
, "expected %p, got %p\n", mmio
.pchEndRead
, mmio
.pchNext
);
969 DeleteFileA(test_file
);
972 static void test_mmio_buffer_pointer(void)
974 char test_file
[MAX_PATH
];
975 char buffer
[5], data
[16];
981 if (!create_test_file(test_file
)) return;
983 memset(&mmio
, 0, sizeof(mmio
));
984 mmio
.fccIOProc
= FOURCC_DOS
;
985 mmio
.pchBuffer
= buffer
;
986 mmio
.cchBuffer
= sizeof(buffer
);
987 hmmio
= mmioOpenA(test_file
, &mmio
, MMIO_READ
);
988 ok(hmmio
!= 0, "mmioOpenA error %u\n", mmio
.wErrorRet
);
990 DeleteFileA(test_file
);
994 /* the buffer is empty */
995 size
= mmioRead(hmmio
, data
, 0);
996 ok(size
== 0, "expected 0, got %d\n", size
);
997 res
= mmioGetInfo(hmmio
, &mmio
, 0);
998 ok(res
== MMSYSERR_NOERROR
, "expected 0, got %d\n", res
);
999 ok(mmio
.pchEndRead
== mmio
.pchBuffer
, "expected %p, got %p\n", mmio
.pchBuffer
, mmio
.pchEndRead
);
1001 /* fill the buffer */
1002 res
= mmioAdvance(hmmio
, &mmio
, MMIO_READ
);
1003 ok(res
== MMSYSERR_NOERROR
, "mmioAdvance failed %x\n", res
);
1004 ok(mmio
.pchEndRead
-mmio
.pchBuffer
== sizeof(buffer
), "got %d\n", (int)(mmio
.pchEndRead
-mmio
.pchBuffer
));
1006 /* seeking to the same buffer chunk, the buffer is kept */
1007 size
= sizeof(buffer
)/2;
1008 pos
= mmioSeek(hmmio
, size
, SEEK_SET
);
1009 ok(pos
== size
, "failed to seek, expected %d, got %d\n", size
, pos
);
1010 res
= mmioGetInfo(hmmio
, &mmio
, 0);
1011 ok(res
== MMSYSERR_NOERROR
, "expected 0, got %d\n", res
);
1012 ok(mmio
.lBufOffset
== 0, "expected 0, got %d\n", mmio
.lBufOffset
);
1013 ok(mmio
.pchNext
-mmio
.pchBuffer
== size
, "expected %d, got %d\n", size
, (int)(mmio
.pchNext
-mmio
.pchBuffer
));
1014 ok(mmio
.pchEndRead
-mmio
.pchBuffer
== sizeof(buffer
), "got %d\n", (int)(mmio
.pchEndRead
-mmio
.pchBuffer
));
1016 /* seeking to another buffer chunk, the buffer is empty */
1017 size
= sizeof(buffer
) * 3 + sizeof(buffer
) / 2;
1018 pos
= mmioSeek(hmmio
, size
, SEEK_SET
);
1019 ok(pos
== size
, "failed to seek, got %d\n", pos
);
1020 res
= mmioGetInfo(hmmio
, &mmio
, 0);
1021 ok(res
== MMSYSERR_NOERROR
, "expected 0, got %d\n", res
);
1022 ok(mmio
.lBufOffset
== size
, "expected %d, got %d\n", size
, mmio
.lBufOffset
);
1023 ok(mmio
.pchNext
== mmio
.pchBuffer
, "expected %p, got %p\n", mmio
.pchBuffer
, mmio
.pchNext
);
1024 ok(mmio
.pchEndRead
== mmio
.pchBuffer
, "expected %p, got %p\n", mmio
.pchBuffer
, mmio
.pchEndRead
);
1026 /* reading a lot (as sizeof(data) > mmio.cchBuffer), the buffer is empty */
1027 size
= mmioRead(hmmio
, data
, sizeof(data
));
1028 ok(size
== sizeof(data
), "failed to read, got %d\n", size
);
1029 res
= mmioGetInfo(hmmio
, &mmio
, 0);
1030 ok(res
== MMSYSERR_NOERROR
, "expected 0, got %d\n", res
);
1031 ok(mmio
.lBufOffset
== pos
+size
, "expected %d, got %d\n", pos
+size
, mmio
.lBufOffset
);
1032 ok(mmio
.pchNext
== mmio
.pchBuffer
, "expected %p, got %p\n", mmio
.pchBuffer
, mmio
.pchNext
);
1033 ok(mmio
.pchEndRead
== mmio
.pchBuffer
, "expected %p, got %p\n", mmio
.pchBuffer
, mmio
.pchEndRead
);
1035 mmioClose(hmmio
, 0);
1036 DeleteFileA(test_file
);
1039 static void test_riff_write(void)
1041 static const DWORD test_write_data
[] =
1043 FOURCC_RIFF
, 0x28, mmioFOURCC('W','A','V','E'), mmioFOURCC('d','a','t','a'),
1044 0x1b, 0xdededede, 0xdededede, 0xefefefef,
1045 0xefefefef, 0xbabababa, 0xbabababa, 0xefefef
1048 char name
[] = "test_write.wav";
1050 MMCKINFO chunk_info
[2];
1058 memset(chunk_info
, 0, sizeof(chunk_info
));
1060 mmio
= mmioOpenA(name
, NULL
, MMIO_ALLOCBUF
|MMIO_CREATE
|MMIO_READWRITE
);
1061 ok(mmio
!= NULL
, "mmioOpen failed\n");
1063 chunk_info
[0].fccType
= mmioFOURCC('W','A','V','E');
1064 ret
= mmioCreateChunk(mmio
, chunk_info
, MMIO_CREATERIFF
);
1065 ok(ret
== MMSYSERR_NOERROR
, "mmioCreateChunk failed %x\n", ret
);
1066 ok(chunk_info
[0].ckid
== FOURCC_RIFF
, "chunk_info[0].ckid = %x\n", chunk_info
[0].ckid
);
1067 ok(chunk_info
[0].cksize
== 0, "chunk_info[0].cksize = %d\n", chunk_info
[0].cksize
);
1068 ok(chunk_info
[0].dwDataOffset
== 8, "chunk_info[0].dwDataOffset = %d\n", chunk_info
[0].dwDataOffset
);
1069 ok(chunk_info
[0].dwFlags
== MMIO_DIRTY
, "chunk_info[0].dwFlags = %x\n", chunk_info
[0].dwFlags
);
1071 chunk_info
[1].ckid
= mmioFOURCC('d','a','t','a');
1072 ret
= mmioCreateChunk(mmio
, chunk_info
+1, 0);
1073 ok(ret
== MMSYSERR_NOERROR
, "mmioCreateChunk failed %x\n", ret
);
1074 ok(chunk_info
[1].ckid
== mmioFOURCC('d','a','t','a'), "chunk_info[1].ckid = %x\n", chunk_info
[1].ckid
);
1075 ok(chunk_info
[1].cksize
== 0, "chunk_info[1].cksize = %d\n", chunk_info
[1].cksize
);
1076 ok(chunk_info
[1].dwDataOffset
== 20, "chunk_info[1].dwDataOffset = %d\n", chunk_info
[1].dwDataOffset
);
1077 ok(chunk_info
[1].dwFlags
== MMIO_DIRTY
, "chunk_info[1].dwFlags = %x\n", chunk_info
[1].dwFlags
);
1079 memset(buf
, 0xde, sizeof(buf
));
1080 written
= mmioWrite(mmio
, buf
, 8);
1081 ok(written
== 8, "mmioWrite failed %x\n", ret
);
1083 ret
= mmioGetInfo(mmio
, &info
, 0);
1084 ok(ret
== MMSYSERR_NOERROR
, "mmioGetInfo failed %x\n", ret
);
1086 memset(info
.pchNext
, 0xef, 8);
1088 ret
= mmioAdvance(mmio
, &info
, 1);
1089 ok(ret
== MMSYSERR_NOERROR
, "mmioAdvance failed %x\n", ret
);
1090 ok(info
.lBufOffset
== 36, "info.lBufOffset = %d\n", info
.lBufOffset
);
1092 info
.dwFlags
|= MMIO_DIRTY
;
1093 memset(info
.pchNext
, 0xba, 8);
1095 ret
= mmioAdvance(mmio
, &info
, 1);
1096 ok(ret
== MMSYSERR_NOERROR
, "mmioAdvance failed %x\n", ret
);
1097 ok(info
.lBufOffset
== 44, "info.lBufOffset = %d\n", info
.lBufOffset
);
1099 info
.dwFlags
|= MMIO_DIRTY
;
1100 memset(info
.pchNext
, 0xef, 3);
1102 ret
= mmioSetInfo(mmio
, &info
, 0);
1103 ok(ret
== MMSYSERR_NOERROR
, "mmioSetInfo failed %x\n", ret
);
1105 ret
= mmioAscend(mmio
, chunk_info
+1, 0);
1106 ok(ret
== MMSYSERR_NOERROR
, "mmioAscend failed %x\n", ret
);
1107 ret
= mmioAscend(mmio
, chunk_info
, 0);
1108 ok(ret
== MMSYSERR_NOERROR
, "mmioAscend failed %x\n", ret
);
1109 ret
= mmioClose(mmio
, 0);
1110 ok(ret
== MMSYSERR_NOERROR
, "mmioClose failed %x\n", ret
);
1112 h
= CreateFileA("test_write.wav", GENERIC_READ
, 0, NULL
, OPEN_EXISTING
, 0, 0);
1113 ok(h
!= INVALID_HANDLE_VALUE
, "CreateFile failed\n");
1114 ok(ReadFile(h
, buf
, sizeof(buf
), &read
, NULL
), "ReadFile failed\n");
1116 ok(!memcmp(buf
, test_write_data
, sizeof(test_write_data
)), "created file is incorrect\n");
1118 DeleteFileA("test_write.wav");
1123 /* Make it possible to run the tests against a specific AVI file in
1124 * addition to the builtin test data. This is mostly meant as a
1125 * debugging aid and is not part of the standard tests.
1127 char fname
[] = "msrle.avi";
1129 test_mmioDescend(NULL
);
1130 test_mmioDescend(fname
);
1131 test_mmioOpen(NULL
);
1132 test_mmioOpen(fname
);
1133 test_mmioOpen_create();
1134 test_mmioSetBuffer(NULL
);
1135 test_mmioSetBuffer(fname
);
1136 test_mmioOpen_fourcc();
1138 test_mmio_end_of_file();
1139 test_mmio_buffer_pointer();