ReactOS 0.4.16-dev-197-g92996da
mmio.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "mmsystem.h"
#include "vfw.h"
#include "wine/test.h"
Include dependency graph for mmio.c:

Go to the source code of this file.

Macros

#define expect_buf_offset(a1, a2)   expect_buf_offset_dbg(a1, a2, __LINE__)
 
#define FOURCC_XYZ   mmioFOURCC('X', 'Y', 'Z', ' ')
 

Functions

static void expect_buf_offset_dbg (HMMIO hmmio, LONG off, int line)
 
static void test_mmioDescend (char *fname)
 
static void test_mmioOpen (char *fname)
 
static void test_mmioSetBuffer (char *fname)
 
static LRESULT CALLBACK mmio_test_IOProc (LPSTR lpMMIOInfo, UINT uMessage, LPARAM lParam1, LPARAM lParam2)
 
static void test_mmioOpen_fourcc (void)
 
static BOOL create_test_file (char *temp_file)
 
static void test_mmioSeek (void)
 
static void test_mmio_end_of_file (void)
 
static void test_mmio_buffer_pointer (void)
 
static void test_riff_write (void)
 
 START_TEST (mmio)
 

Variables

static DWORD RIFF_buf []
 

Macro Definition Documentation

◆ expect_buf_offset

#define expect_buf_offset (   a1,
  a2 
)    expect_buf_offset_dbg(a1, a2, __LINE__)

Definition at line 60 of file mmio.c.

◆ FOURCC_XYZ

#define FOURCC_XYZ   mmioFOURCC('X', 'Y', 'Z', ' ')

Definition at line 597 of file mmio.c.

Function Documentation

◆ create_test_file()

static BOOL create_test_file ( char temp_file)
static

Definition at line 672 of file mmio.c.

673{
674 char temp_path[MAX_PATH];
675 DWORD ret, written;
676 HANDLE h;
677
679 ok(ret, "Failed to get a temp path, err %d\n", GetLastError());
680 if (!ret)
681 return FALSE;
682
684 ok(ret, "Failed to get a temp name, err %d\n", GetLastError());
685 if (!ret)
686 return FALSE;
687
690 ok(h != INVALID_HANDLE_VALUE, "Failed to create a file, err %d\n", GetLastError());
691 if (h == INVALID_HANDLE_VALUE) return FALSE;
692
693 ret = WriteFile(h, RIFF_buf, sizeof(RIFF_buf), &written, NULL);
694 ok(ret, "Failed to write a file, err %d\n", GetLastError());
695 CloseHandle(h);
697 return ret;
698}
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define MAX_PATH
Definition: compat.h:34
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2054
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Definition: filename.c:26
unsigned long DWORD
Definition: ntddk_ex.h:95
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define CREATE_ALWAYS
Definition: disk.h:72
static DWORD RIFF_buf[]
Definition: mmio.c:30
char temp_path[MAX_PATH]
Definition: mspatcha.c:123
#define GENERIC_WRITE
Definition: nt_native.h:90
Definition: fci.c:110
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by test_mmio_buffer_pointer(), test_mmio_end_of_file(), and test_mmioSeek().

◆ expect_buf_offset_dbg()

static void expect_buf_offset_dbg ( HMMIO  hmmio,
LONG  off,
int  line 
)
static

Definition at line 47 of file mmio.c.

48{
49 MMIOINFO mmio;
50 LONG ret;
51
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);
58}
#define ok_(x1, x2)
Definition: atltest.h:61
LONG WINAPI mmioSeek(HMMIO hmmio, LONG lOffset, INT iOrigin)
Definition: mmio.c:836
MMRESULT WINAPI mmioGetInfo(HMMIO hmmio, MMIOINFO *lpmmioinfo, UINT uFlags)
Definition: mmio.c:901
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define SEEK_CUR
Definition: util.h:63
long LONG
Definition: pedump.c:60
#define memset(x, y, z)
Definition: compat.h:39
LONG lBufOffset
Definition: mmsystem.h:1496
Definition: parser.c:49

◆ mmio_test_IOProc()

static LRESULT CALLBACK mmio_test_IOProc ( LPSTR  lpMMIOInfo,
UINT  uMessage,
LPARAM  lParam1,
LPARAM  lParam2 
)
static

Definition at line 599 of file mmio.c.

600{
601 LPMMIOINFO lpInfo = (LPMMIOINFO) lpMMIOInfo;
602 int i;
603
604 switch (uMessage)
605 {
606 case MMIOM_OPEN:
607 if (lpInfo->fccIOProc == FOURCC_DOS)
608 lpInfo->fccIOProc = mmioFOURCC('F', 'A', 'I', 'L');
609 for (i = 0; i < ARRAY_SIZE(lpInfo->adwInfo); i++)
610 ok(lpInfo->adwInfo[i] == 0, "[%d] Expected 0, got %u\n", i, lpInfo->adwInfo[i]);
611 return MMSYSERR_NOERROR;
612 case MMIOM_CLOSE:
613 return MMSYSERR_NOERROR;
614 case MMIOM_SEEK:
615 lpInfo->adwInfo[1]++;
616 lpInfo->lDiskOffset = 0xdeadbeef;
617 return 0;
618 default:
619 return 0;
620 }
621}
#define ARRAY_SIZE(A)
Definition: main.h:20
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define FOURCC_DOS
Definition: mmsystem.h:566
#define MMIOM_CLOSE
Definition: mmsystem.h:560
struct _MMIOINFO * LPMMIOINFO
#define MMIOM_SEEK
Definition: mmsystem.h:558
#define MMIOM_OPEN
Definition: mmsystem.h:559
#define mmioFOURCC(c0, c1, c2, c3)
Definition: mmsystem.h:38
LONG lDiskOffset
Definition: mmsystem.h:1497
FOURCC fccIOProc
Definition: mmsystem.h:1487
DWORD adwInfo[3]
Definition: mmsystem.h:1498

Referenced by test_mmioOpen_fourcc().

◆ START_TEST()

START_TEST ( mmio  )

Definition at line 1007 of file mmio.c.

1008{
1009 /* Make it possible to run the tests against a specific AVI file in
1010 * addition to the builtin test data. This is mostly meant as a
1011 * debugging aid and is not part of the standard tests.
1012 */
1013 char fname[] = "msrle.avi";
1014
1016 test_mmioDescend(fname);
1018 test_mmioOpen(fname);
1020 test_mmioSetBuffer(fname);
1022 test_mmioSeek();
1026}
static void test_mmioSeek(void)
Definition: mmio.c:700
static void test_mmioOpen_fourcc(void)
Definition: mmio.c:623
static void test_mmioDescend(char *fname)
Definition: mmio.c:62
static void test_mmioOpen(char *fname)
Definition: mmio.c:229
static void test_mmioSetBuffer(char *fname)
Definition: mmio.c:474
static void test_riff_write(void)
Definition: mmio.c:925
static void test_mmio_buffer_pointer(void)
Definition: mmio.c:858
static void test_mmio_end_of_file(void)
Definition: mmio.c:820

◆ test_mmio_buffer_pointer()

static void test_mmio_buffer_pointer ( void  )
static

Definition at line 858 of file mmio.c.

859{
860 char test_file[MAX_PATH];
861 char buffer[5], data[16];
862 MMIOINFO mmio;
863 HMMIO hmmio;
864 LONG size, pos;
866
867 if (!create_test_file(test_file)) return;
868
869 memset(&mmio, 0, sizeof(mmio));
870 mmio.fccIOProc = FOURCC_DOS;
871 mmio.pchBuffer = buffer;
872 mmio.cchBuffer = sizeof(buffer);
873 hmmio = mmioOpenA(test_file, &mmio, MMIO_READ);
874 ok(hmmio != 0, "mmioOpenA error %u\n", mmio.wErrorRet);
875 if (hmmio == NULL) {
877 return;
878 }
879
880 /* the buffer is empty */
881 size = mmioRead(hmmio, data, 0);
882 ok(size == 0, "expected 0, got %d\n", size);
883 res = mmioGetInfo(hmmio, &mmio, 0);
884 ok(res == MMSYSERR_NOERROR, "expected 0, got %d\n", res);
885 ok(mmio.pchEndRead == mmio.pchBuffer, "expected %p, got %p\n", mmio.pchBuffer, mmio.pchEndRead);
886
887 /* fill the buffer */
888 res = mmioAdvance(hmmio, &mmio, MMIO_READ);
889 ok(res == MMSYSERR_NOERROR, "mmioAdvance failed %x\n", res);
890 ok(mmio.pchEndRead-mmio.pchBuffer == sizeof(buffer), "got %d\n", (int)(mmio.pchEndRead-mmio.pchBuffer));
891
892 /* seeking to the same buffer chunk, the buffer is kept */
893 size = sizeof(buffer)/2;
894 pos = mmioSeek(hmmio, size, SEEK_SET);
895 ok(pos == size, "failed to seek, expected %d, got %d\n", size, pos);
896 res = mmioGetInfo(hmmio, &mmio, 0);
897 ok(res == MMSYSERR_NOERROR, "expected 0, got %d\n", res);
898 ok(mmio.lBufOffset == 0, "expected 0, got %d\n", mmio.lBufOffset);
899 ok(mmio.pchNext-mmio.pchBuffer == size, "expected %d, got %d\n", size, (int)(mmio.pchNext-mmio.pchBuffer));
900 ok(mmio.pchEndRead-mmio.pchBuffer == sizeof(buffer), "got %d\n", (int)(mmio.pchEndRead-mmio.pchBuffer));
901
902 /* seeking to another buffer chunk, the buffer is empty */
903 size = sizeof(buffer) * 3 + sizeof(buffer) / 2;
904 pos = mmioSeek(hmmio, size, SEEK_SET);
905 ok(pos == size, "failed to seek, got %d\n", pos);
906 res = mmioGetInfo(hmmio, &mmio, 0);
907 ok(res == MMSYSERR_NOERROR, "expected 0, got %d\n", res);
908 ok(mmio.lBufOffset == size, "expected %d, got %d\n", size, mmio.lBufOffset);
909 ok(mmio.pchNext == mmio.pchBuffer, "expected %p, got %p\n", mmio.pchBuffer, mmio.pchNext);
910 ok(mmio.pchEndRead == mmio.pchBuffer, "expected %p, got %p\n", mmio.pchBuffer, mmio.pchEndRead);
911
912 /* reading a lot (as sizeof(data) > mmio.cchBuffer), the buffer is empty */
913 size = mmioRead(hmmio, data, sizeof(data));
914 ok(size == sizeof(data), "failed to read, got %d\n", size);
915 res = mmioGetInfo(hmmio, &mmio, 0);
916 ok(res == MMSYSERR_NOERROR, "expected 0, got %d\n", res);
917 ok(mmio.lBufOffset == pos+size, "expected %d, got %d\n", pos+size, mmio.lBufOffset);
918 ok(mmio.pchNext == mmio.pchBuffer, "expected %p, got %p\n", mmio.pchBuffer, mmio.pchNext);
919 ok(mmio.pchEndRead == mmio.pchBuffer, "expected %p, got %p\n", mmio.pchBuffer, mmio.pchEndRead);
920
921 mmioClose(hmmio, 0);
923}
HMMIO WINAPI mmioOpenA(LPSTR szFileName, MMIOINFO *lpmmioinfo, DWORD dwOpenFlags)
Definition: mmio.c:693
MMRESULT WINAPI mmioClose(HMMIO hmmio, UINT uFlags)
Definition: mmio.c:702
LONG WINAPI mmioRead(HMMIO hmmio, HPSTR pch, LONG cch)
Definition: mmio.c:733
MMRESULT WINAPI mmioAdvance(HMMIO hmmio, MMIOINFO *lpmmioinfo, UINT uFlags)
Definition: mmio.c:976
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
GLuint res
Definition: glext.h:9613
GLuint buffer
Definition: glext.h:5915
#define SEEK_SET
Definition: jmemansi.c:26
UINT MMRESULT
Definition: mmsystem.h:962
#define MMIO_READ
Definition: mmsystem.h:535
static IBackgroundCopyFile * test_file
Definition: file.c:39
static BOOL create_test_file(char *temp_file)
Definition: mmio.c:672
HPSTR pchEndRead
Definition: mmsystem.h:1494
LONG cchBuffer
Definition: mmsystem.h:1491
HPSTR pchNext
Definition: mmsystem.h:1493
HPSTR pchBuffer
Definition: mmsystem.h:1492
UINT wErrorRet
Definition: mmsystem.h:1489

Referenced by START_TEST().

◆ test_mmio_end_of_file()

static void test_mmio_end_of_file ( void  )
static

Definition at line 820 of file mmio.c.

821{
822 char test_file[MAX_PATH], buffer[128], data[16];
823 MMIOINFO mmio;
824 HMMIO hmmio;
825 LONG ret;
827
828 if (!create_test_file(test_file)) return;
829
830 memset(&mmio, 0, sizeof(mmio));
831 mmio.fccIOProc = FOURCC_DOS;
832 mmio.pchBuffer = buffer;
833 mmio.cchBuffer = sizeof(buffer);
834 hmmio = mmioOpenA(test_file, &mmio, MMIO_READ);
835 ok(hmmio != 0, "mmioOpenA error %u\n", mmio.wErrorRet);
836 if (hmmio == NULL) {
838 return;
839 }
840
841 ret = mmioSeek(hmmio, 0, SEEK_END);
842 ok(sizeof(RIFF_buf) == ret, "got %d\n", ret);
843
844 ret = mmioRead(hmmio, data, sizeof(data));
845 ok(ret == 0, "expected %d, got %d\n", 0, ret);
846
847 res = mmioGetInfo(hmmio, &mmio, 0);
848 ok(res == MMSYSERR_NOERROR, "expected 0, got %d\n", res);
849
850 res = mmioAdvance(hmmio, &mmio, MMIO_READ);
851 ok(res == MMSYSERR_NOERROR, "expected 0, got %d\n", res);
852 ok(mmio.pchNext == mmio.pchEndRead, "expected %p, got %p\n", mmio.pchEndRead, mmio.pchNext);
853
854 mmioClose(hmmio, 0);
856}
#define SEEK_END
Definition: cabinet.c:29

Referenced by START_TEST().

◆ test_mmioDescend()

static void test_mmioDescend ( char fname)
static

Definition at line 62 of file mmio.c.

63{
65 HMMIO hmmio;
66 MMIOINFO mmio;
67 MMCKINFO ckRiff, ckList, ck, ckList2;
68
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);
74 if (fname && !hmmio)
75 {
76 trace("No optional %s file. Skipping the test\n", fname);
77 return;
78 }
79 ok(hmmio != 0, "mmioOpenA error %u\n", mmio.wErrorRet);
80
81 expect_buf_offset(hmmio, 0);
82
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);
92
93 expect_buf_offset(hmmio, 12);
94
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);
103
104 expect_buf_offset(hmmio, 24);
105
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);
113
114 expect_buf_offset(hmmio, 32);
115
116 /* Skip chunk data */
117 ret = mmioSeek(hmmio, ck.cksize, SEEK_CUR);
118 ok(ret == 0x58, "expected 0x58, got %#x\n", ret);
119
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);
127
128 expect_buf_offset(hmmio, 100);
129
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);
137
138 expect_buf_offset(hmmio, 108);
139
140 /* test various mmioDescend flags */
141
142 mmioSeek(hmmio, 0, SEEK_SET);
143 memset(&ck, 0x66, sizeof(ck));
144 ret = mmioDescend(hmmio, &ck, NULL, MMIO_FINDRIFF);
146 ret == MMIOERR_INVALIDFILE, "mmioDescend returned %u\n", ret);
147
148 mmioSeek(hmmio, 0, SEEK_SET);
149 memset(&ck, 0x66, sizeof(ck));
150 ck.ckid = 0;
151 ret = mmioDescend(hmmio, &ck, NULL, MMIO_FINDRIFF);
153 ret == MMIOERR_INVALIDFILE, "mmioDescend returned %u\n", ret);
154
155 mmioSeek(hmmio, 0, SEEK_SET);
156 memset(&ck, 0x66, sizeof(ck));
157 ck.fccType = 0;
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);
162
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);
169
170 /* do NOT seek, use current file position */
171 memset(&ck, 0x66, sizeof(ck));
172 ck.fccType = 0;
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);
177
178 mmioSeek(hmmio, 0, SEEK_SET);
179 memset(&ck, 0x66, sizeof(ck));
180 ck.ckid = 0;
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);
186
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);
194
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);
202
203 /* do NOT seek, use current file position */
204 memset(&ckList, 0x66, sizeof(ckList));
205 ckList.ckid = 0;
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);
210
211 mmioSeek(hmmio, 0, SEEK_SET);
212 memset(&ck, 0x66, sizeof(ck));
213 ret = mmioDescend(hmmio, &ck, NULL, MMIO_FINDCHUNK);
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);
219
220 mmioSeek(hmmio, 0, SEEK_SET);
221 memset(&ck, 0x66, sizeof(ck));
222 ret = mmioDescend(hmmio, &ck, NULL, MMIO_FINDRIFF);
224 ret == MMIOERR_INVALIDFILE, "mmioDescend returned %u\n", ret);
225
226 mmioClose(hmmio, 0);
227}
#define trace
Definition: atltest.h:70
#define ckidSTREAMHEADER
Definition: aviriff.h:88
MMRESULT WINAPI mmioDescend(HMMIO hmmio, LPMMCKINFO lpck, const MMCKINFO *lpckParent, UINT uFlags)
Definition: mmio.c:1107
#define MMIO_FINDRIFF
Definition: mmsystem.h:552
#define FOURCC_RIFF
Definition: mmsystem.h:564
#define MMIOERR_CHUNKNOTFOUND
Definition: mmsystem.h:517
#define MMIO_FINDCHUNK
Definition: mmsystem.h:551
#define FOURCC_LIST
Definition: mmsystem.h:565
#define MMIOERR_INVALIDFILE
Definition: mmsystem.h:524
#define FOURCC_MEM
Definition: mmsystem.h:567
#define MMIO_FINDLIST
Definition: mmsystem.h:553
#define expect_buf_offset(a1, a2)
Definition: mmio.c:60
FOURCC ckid
Definition: mmsystem.h:1507
DWORD cksize
Definition: mmsystem.h:1508
DWORD dwDataOffset
Definition: mmsystem.h:1510
DWORD dwFlags
Definition: mmsystem.h:1511
FOURCC fccType
Definition: mmsystem.h:1509
#define listtypeSTREAMHEADER
Definition: vfw.h:892
#define listtypeAVIHEADER
Definition: vfw.h:890
#define ckidAVIMAINHDR
Definition: vfw.h:891
#define formtypeAVI
Definition: vfw.h:889
const char * LPCSTR
Definition: xmlstorage.h:183

Referenced by START_TEST().

◆ test_mmioOpen()

static void test_mmioOpen ( char fname)
static

Definition at line 229 of file mmio.c.

230{
233 HMMIO hmmio;
234 MMIOINFO mmio;
235
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);
241 if (fname && !hmmio)
242 {
243 trace("No optional %s file. Skipping the test\n", fname);
244 return;
245 }
246 ok(hmmio != 0, "mmioOpenA error %u\n", mmio.wErrorRet);
247
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);
259 else
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);
264
265 ret = mmioSeek(hmmio, 0, SEEK_CUR);
266 ok(ret == 0, "expected 0, got %d\n", ret);
267
268 mmioClose(hmmio, 0);
269
270 memset(&mmio, 0, sizeof(mmio));
271 mmio.fccIOProc = fname ? FOURCC_DOS : FOURCC_MEM;
272 mmio.cchBuffer = 0;
273 mmio.pchBuffer = buf;
274 hmmio = mmioOpenA(fname, &mmio, MMIO_READ);
275 ok(hmmio != 0, "mmioOpenA error %u\n", mmio.wErrorRet);
276
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);
290
291 ret = mmioSeek(hmmio, 0, SEEK_CUR);
292 ok(ret == 0, "expected 0, got %d\n", ret);
293
294 mmioClose(hmmio, 0);
295
296 memset(&mmio, 0, sizeof(mmio));
297 mmio.fccIOProc = fname ? FOURCC_DOS : FOURCC_MEM;
298 mmio.cchBuffer = 0;
299 mmio.pchBuffer = NULL;
300 hmmio = mmioOpenA(fname, &mmio, MMIO_READ);
301 ok(hmmio != 0, "mmioOpenA error %u\n", mmio.wErrorRet);
302
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);
316
317 ret = mmioSeek(hmmio, 0, SEEK_CUR);
318 ok(ret == 0, "expected 0, got %d\n", ret);
319
320 mmioClose(hmmio, 0);
321
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);
328
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);
340 else
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);
345
346 ret = mmioSeek(hmmio, 0, SEEK_CUR);
347 ok(ret == 0, "expected 0, got %d\n", ret);
348
349 mmioClose(hmmio, 0);
350
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);
357
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);
369 else
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);
374
375 ret = mmioSeek(hmmio, 0, SEEK_CUR);
376 ok(ret == 0, "expected 0, got %d\n", ret);
377
378 mmioClose(hmmio, 0);
379
380 memset(&mmio, 0, sizeof(mmio));
381 mmio.fccIOProc = fname ? FOURCC_DOS : FOURCC_MEM;
382 mmio.cchBuffer = 0;
383 mmio.pchBuffer = NULL;
384 hmmio = mmioOpenA(fname, &mmio, MMIO_READ | MMIO_ALLOCBUF);
385 ok(hmmio != 0, "mmioOpenA error %u\n", mmio.wErrorRet);
386
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);
398 else
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);
403
404 ret = mmioSeek(hmmio, 0, SEEK_CUR);
405 ok(ret == 0, "expected 0, got %d\n", ret);
406
407 mmioClose(hmmio, 0);
408
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);
415
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);
427 else
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);
432
433 ret = mmioSeek(hmmio, 0, SEEK_CUR);
434 ok(ret == 0, "expected 0, got %d\n", ret);
435
436 mmioClose(hmmio, 0);
437
438 memset(&mmio, 0, sizeof(mmio));
439 mmio.fccIOProc = fname ? FOURCC_DOS : FOURCC_MEM;
440 mmio.cchBuffer = 0;
441 mmio.pchBuffer = buf;
442 hmmio = mmioOpenA(fname, &mmio, MMIO_READ | MMIO_ALLOCBUF);
443 if (!hmmio && mmio.wErrorRet == ERROR_BAD_FORMAT)
444 {
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");
447 return;
448 }
449 ok(hmmio != 0, "mmioOpenA error %u\n", mmio.wErrorRet);
450
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);
462 else
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);
467
468 ret = mmioSeek(hmmio, 0, SEEK_CUR);
469 ok(ret == 0, "expected 0, got %d\n", ret);
470
471 mmioClose(hmmio, 0);
472}
#define skip(...)
Definition: atltest.h:64
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define MMIO_ALLOCBUF
Definition: mmsystem.h:532
#define MMIO_DEFAULTBUFFER
Definition: mmsystem.h:568
DWORD dwFlags
Definition: mmsystem.h:1486
HPSTR pchEndWrite
Definition: mmsystem.h:1495
#define ERROR_BAD_FORMAT
Definition: winerror.h:114

Referenced by START_TEST().

◆ test_mmioOpen_fourcc()

static void test_mmioOpen_fourcc ( void  )
static

Definition at line 623 of file mmio.c.

624{
625 char fname[] = "file+name.xyz+one.two";
626
627 LPMMIOPROC lpProc;
628 HMMIO hmmio;
629 MMIOINFO mmio;
630
632 ok(lpProc == mmio_test_IOProc, "mmioInstallIOProcA error\n");
633
635 ok(lpProc == mmio_test_IOProc, "mmioInstallIOProcA error\n");
636
637 memset(&mmio, 0, sizeof(mmio));
638 hmmio = mmioOpenA(fname, &mmio, MMIO_READ);
639 mmioGetInfo(hmmio, &mmio, 0);
640 ok(hmmio && mmio.fccIOProc == FOURCC_XYZ, "mmioOpenA error %u, got %4.4s\n",
641 mmio.wErrorRet, (LPCSTR)&mmio.fccIOProc);
642 ok(mmio.adwInfo[1] == 0, "mmioOpenA sent MMIOM_SEEK, got %d\n",
643 mmio.adwInfo[1]);
644 ok(mmio.lDiskOffset == 0, "mmioOpenA updated lDiskOffset, got %d\n",
645 mmio.lDiskOffset);
646 mmioClose(hmmio, 0);
647
648 /* Same test with NULL info */
649 memset(&mmio, 0, sizeof(mmio));
650 hmmio = mmioOpenA(fname, NULL, MMIO_READ);
651 mmioGetInfo(hmmio, &mmio, 0);
652 ok(hmmio && mmio.fccIOProc == FOURCC_XYZ, "mmioOpenA error %u, got %4.4s\n",
653 mmio.wErrorRet, (LPCSTR)&mmio.fccIOProc);
654 ok(mmio.adwInfo[1] == 0, "mmioOpenA sent MMIOM_SEEK, got %d\n",
655 mmio.adwInfo[1]);
656 ok(mmio.lDiskOffset == 0, "mmioOpenA updated lDiskOffset, got %d\n",
657 mmio.lDiskOffset);
658 mmioClose(hmmio, 0);
659
661
662 memset(&mmio, 0, sizeof(mmio));
663 hmmio = mmioOpenA(fname, &mmio, MMIO_READ);
664 mmioGetInfo(hmmio, &mmio, 0);
665 ok(!hmmio && mmio.wErrorRet == MMIOERR_FILENOTFOUND, "mmioOpenA error %u, got %4.4s\n",
666 mmio.wErrorRet, (LPCSTR)&mmio.fccIOProc);
667 mmioClose(hmmio, 0);
668
670}
LPMMIOPROC WINAPI mmioInstallIOProcA(FOURCC fccIOProc, LPMMIOPROC pIOProc, DWORD dwFlags)
Definition: mmio.c:1059
#define MMIOERR_FILENOTFOUND
Definition: mmsystem.h:509
MMIOPROC * LPMMIOPROC
Definition: mmsystem.h:1483
#define MMIO_REMOVEPROC
Definition: mmsystem.h:548
#define MMIO_INSTALLPROC
Definition: mmsystem.h:546
#define FOURCC_XYZ
Definition: mmio.c:597
static LRESULT CALLBACK mmio_test_IOProc(LPSTR lpMMIOInfo, UINT uMessage, LPARAM lParam1, LPARAM lParam2)
Definition: mmio.c:599

Referenced by START_TEST().

◆ test_mmioSeek()

static void test_mmioSeek ( void  )
static

Definition at line 700 of file mmio.c.

701{
702 HMMIO hmmio;
703 MMIOINFO mmio;
704 LONG end, pos;
705 const LONG size = sizeof(RIFF_buf), offset = 16;
706 char test_file[MAX_PATH];
708 HFILE hfile;
709 OFSTRUCT ofs;
710
711 /* test memory file */
712 memset(&mmio, 0, sizeof(mmio));
713 mmio.fccIOProc = FOURCC_MEM;
714 mmio.pchBuffer = (char*)&RIFF_buf;
715 mmio.cchBuffer = sizeof(RIFF_buf);
716 hmmio = mmioOpenA(NULL, &mmio, MMIO_READ);
717 ok(hmmio != 0, "mmioOpenA error %u\n", mmio.wErrorRet);
718 if (hmmio != NULL) {
719 /* seek to the end */
720 end = mmioSeek(hmmio, 0, SEEK_END);
721 ok(end == size, "expected %d, got %d\n", size, end);
722
723 /* test MMIOINFO values */
724 res = mmioGetInfo(hmmio, &mmio, 0);
725 ok(res == MMSYSERR_NOERROR, "expected 0, got %d\n", res);
726 ok(mmio.pchNext == mmio.pchBuffer + mmio.cchBuffer, "expected %p + %d, got %p\n", mmio.pchBuffer, mmio.cchBuffer, mmio.pchNext);
727 ok(mmio.pchEndRead == mmio.pchBuffer + mmio.cchBuffer, "expected %p + %d, got %p\n", mmio.pchBuffer, mmio.cchBuffer, mmio.pchEndRead);
728 ok(mmio.pchEndWrite == mmio.pchBuffer + mmio.cchBuffer, "expected %p + %d, got %p\n", mmio.pchBuffer, mmio.cchBuffer, mmio.pchEndWrite);
729 ok(mmio.lBufOffset == 0, "expected %d, got %d\n", 0, mmio.lBufOffset);
730 ok(mmio.lDiskOffset == 0, "expected %d, got %d\n", 0, mmio.lDiskOffset);
731
732 /* seek backward from the end */
733 pos = mmioSeek(hmmio, offset, SEEK_END);
734 ok(pos == size-offset, "expected %d, got %d\n", size-offset, pos);
735
736 mmioClose(hmmio, 0);
737 }
738
739 if (!create_test_file(test_file)) return;
740
741 /* test standard file without buffering */
742 hmmio = NULL;
743 memset(&mmio, 0, sizeof(mmio));
744 mmio.fccIOProc = FOURCC_DOS;
745 mmio.pchBuffer = 0;
746 mmio.cchBuffer = 0;
747 hmmio = mmioOpenA(test_file, &mmio, MMIO_READ);
748 ok(hmmio != 0, "mmioOpenA error %u\n", mmio.wErrorRet);
749 if (hmmio != NULL) {
750 /* seek to the end */
751 end = mmioSeek(hmmio, 0, SEEK_END);
752 ok(end == size, "expected %d, got %d\n", size, end);
753
754 /* test MMIOINFO values */
755 res = mmioGetInfo(hmmio, &mmio, 0);
756 ok(res == MMSYSERR_NOERROR, "expected 0, got %d\n", res);
757 ok(mmio.pchNext == mmio.pchBuffer, "expected %p, got %p\n", mmio.pchBuffer, mmio.pchNext);
758 ok(mmio.pchEndRead == mmio.pchBuffer, "expected %p, got %p\n", mmio.pchBuffer, mmio.pchEndRead);
759 ok(mmio.pchEndWrite == mmio.pchBuffer + mmio.cchBuffer, "expected %p + %d, got %p\n", mmio.pchBuffer, mmio.cchBuffer, mmio.pchEndWrite);
760 ok(mmio.lBufOffset == size, "expected %d, got %d\n", size, mmio.lBufOffset);
761 ok(mmio.lDiskOffset == size, "expected %d, got %d\n", size, mmio.lDiskOffset);
762
763 /* seek backward from the end */
764 pos = mmioSeek(hmmio, offset, SEEK_END);
765 ok(pos == size-offset, "expected %d, got %d\n", size-offset, pos);
766
767 mmioClose(hmmio, 0);
768 }
769
770 /* test standard file with buffering */
771 hmmio = NULL;
772 memset(&mmio, 0, sizeof(mmio));
773 mmio.fccIOProc = FOURCC_DOS;
774 mmio.pchBuffer = 0;
775 mmio.cchBuffer = 0;
776 hmmio = mmioOpenA(test_file, &mmio, MMIO_READ | MMIO_ALLOCBUF);
777 ok(hmmio != 0, "mmioOpenA error %u\n", mmio.wErrorRet);
778 if (hmmio != NULL) {
779 /* seek to the end */
780 end = mmioSeek(hmmio, 0, SEEK_END);
781 ok(end == size, "expected %d, got %d\n", size, end);
782
783 /* test MMIOINFO values */
784 res = mmioGetInfo(hmmio, &mmio, 0);
785 ok(res == MMSYSERR_NOERROR, "expected 0, got %d\n", res);
786 ok(mmio.pchNext == mmio.pchBuffer, "expected %p, got %p\n", mmio.pchBuffer, mmio.pchNext);
787 ok(mmio.pchEndRead == mmio.pchBuffer, "expected %p, got %p\n", mmio.pchBuffer, mmio.pchEndRead);
788 ok(mmio.pchEndWrite == mmio.pchBuffer + mmio.cchBuffer, "expected %p + %d, got %p\n", mmio.pchBuffer, mmio.cchBuffer, mmio.pchEndWrite);
789 ok(mmio.lBufOffset == end, "expected %d, got %d\n", end, mmio.lBufOffset);
790 ok(mmio.lDiskOffset == size, "expected %d, got %d\n", size, mmio.lDiskOffset);
791
792 /* seek backward from the end */
793 pos = mmioSeek(hmmio, offset, SEEK_END);
794 ok(pos == size-offset, "expected %d, got %d\n", size-offset, pos);
795
796 mmioClose(hmmio, 0);
797 }
798
799 /* test seek position inheritance from standard file handle */
800 hfile = OpenFile(test_file, &ofs, OF_READ);
801 ok(hfile != HFILE_ERROR, "Failed to open the file, err %d\n", GetLastError());
802 if (hfile != HFILE_ERROR) {
803 pos = _llseek(hfile, offset, SEEK_SET);
804 ok(pos != HFILE_ERROR, "Failed to seek, err %d\n", GetLastError());
805 memset(&mmio, 0, sizeof(mmio));
806 mmio.fccIOProc = FOURCC_DOS;
807 mmio.adwInfo[0] = (DWORD)hfile;
809 ok(hmmio != 0, "mmioOpenA error %u\n", mmio.wErrorRet);
810 if (hmmio != NULL) {
811 pos = mmioSeek(hmmio, 0, SEEK_CUR);
812 ok(pos == offset, "expected %d, got %d\n", offset, pos);
813 mmioClose(hmmio, 0);
814 }
815 }
816
818}
HFILE WINAPI OpenFile(LPCSTR lpFileName, LPOFSTRUCT lpReOpenBuff, UINT uStyle)
Definition: create.c:368
GLuint GLuint end
Definition: gl.h:1545
GLintptr offset
Definition: glext.h:5920
LONG WINAPI _llseek(HFILE hFile, LONG lOffset, int iOrigin)
Definition: lfile.c:149
#define MMIO_DENYWRITE
Definition: mmsystem.h:540
#define DWORD
Definition: nt_native.h:44
#define HFILE_ERROR
Definition: winbase.h:111
#define OF_READ
Definition: winbase.h:116
int HFILE
Definition: windef.h:298

Referenced by START_TEST().

◆ test_mmioSetBuffer()

static void test_mmioSetBuffer ( char fname)
static

Definition at line 474 of file mmio.c.

475{
476 char buf[256];
478 HMMIO hmmio;
479 MMIOINFO mmio;
480
481 memset(&mmio, 0, sizeof(mmio));
482 mmio.fccIOProc = fname ? FOURCC_DOS : FOURCC_MEM;
483 mmio.cchBuffer = sizeof(buf);
484 mmio.pchBuffer = buf;
485 hmmio = mmioOpenA(fname, &mmio, MMIO_READ);
486 if (fname && !hmmio)
487 {
488 trace("No optional %s file. Skipping the test\n", fname);
489 return;
490 }
491 ok(hmmio != 0, "mmioOpenA error %u\n", mmio.wErrorRet);
492
493 memset(&mmio, 0, sizeof(mmio));
494 ret = mmioGetInfo(hmmio, &mmio, 0);
495 ok(ret == MMSYSERR_NOERROR, "mmioGetInfo error %u\n", ret);
496 ok(mmio.dwFlags == MMIO_READ, "expected MMIO_READ, got %x\n", mmio.dwFlags);
497 ok(mmio.wErrorRet == MMSYSERR_NOERROR, "expected MMSYSERR_NOERROR, got %u\n", mmio.wErrorRet);
498 ok(mmio.fccIOProc == (fname ? FOURCC_DOS : FOURCC_MEM), "got %4.4s\n", (LPCSTR)&mmio.fccIOProc);
499 ok(mmio.cchBuffer == sizeof(buf), "got %u\n", mmio.cchBuffer);
500 ok(mmio.pchBuffer == buf, "expected %p, got %p\n", buf, mmio.pchBuffer);
501 ok(mmio.pchNext == mmio.pchBuffer, "expected %p, got %p\n", mmio.pchBuffer, mmio.pchNext);
502 if (mmio.fccIOProc == FOURCC_DOS)
503 ok(mmio.pchEndRead == mmio.pchBuffer, "expected %p, got %p\n", mmio.pchBuffer, mmio.pchEndRead);
504 else
505 ok(mmio.pchEndRead == mmio.pchBuffer + mmio.cchBuffer, "expected %p + %d, got %p\n", mmio.pchBuffer, mmio.cchBuffer, mmio.pchEndRead);
506 ok(mmio.pchEndWrite == mmio.pchBuffer + mmio.cchBuffer, "expected %p + %d, got %p\n", mmio.pchBuffer, mmio.cchBuffer, mmio.pchEndWrite);
507 ok(mmio.lBufOffset == 0, "expected 0, got %d\n", mmio.lBufOffset);
508 ok(mmio.lDiskOffset == 0, "expected 0, got %d\n", mmio.lDiskOffset);
509
510 ret = mmioSeek(hmmio, 0, SEEK_CUR);
511 ok(ret == 0, "expected 0, got %d\n", ret);
512
513 ret = mmioSetBuffer(hmmio, NULL, 0, 0);
514 ok(ret == MMSYSERR_NOERROR, "mmioSetBuffer error %u\n", ret);
515
516 memset(&mmio, 0, sizeof(mmio));
517 ret = mmioGetInfo(hmmio, &mmio, 0);
518 ok(ret == MMSYSERR_NOERROR, "mmioGetInfo error %u\n", ret);
519 ok(mmio.dwFlags == MMIO_READ, "expected MMIO_READ, got %x\n", mmio.dwFlags);
520 ok(mmio.wErrorRet == MMSYSERR_NOERROR, "expected MMSYSERR_NOERROR, got %u\n", mmio.wErrorRet);
521 ok(mmio.fccIOProc == (fname ? FOURCC_DOS : FOURCC_MEM), "got %4.4s\n", (LPCSTR)&mmio.fccIOProc);
522 ok(mmio.cchBuffer == 0, "got not 0\n");
523 ok(mmio.pchBuffer == NULL, "got not NULL buf\n");
524 ok(mmio.pchNext == mmio.pchBuffer, "expected %p, got %p\n", mmio.pchBuffer, mmio.pchNext);
525 ok(mmio.pchEndRead == mmio.pchBuffer, "expected %p, got %p\n", mmio.pchBuffer, mmio.pchEndRead);
526 ok(mmio.pchEndWrite == mmio.pchBuffer, "expected %p, got %p\n", mmio.pchBuffer, mmio.pchEndWrite);
527 ok(mmio.lBufOffset == 0, "expected 0, got %d\n", mmio.lBufOffset);
528 ok(mmio.lDiskOffset == 0, "expected 0, got %d\n", mmio.lDiskOffset);
529
530 ret = mmioSeek(hmmio, 0, SEEK_CUR);
531 ok(ret == 0, "expected 0, got %d\n", ret);
532
533 ret = mmioSetBuffer(hmmio, NULL, 0, MMIO_ALLOCBUF);
534 ok(ret == MMSYSERR_NOERROR, "mmioSetBuffer error %u\n", ret);
535
536 memset(&mmio, 0, sizeof(mmio));
537 ret = mmioGetInfo(hmmio, &mmio, 0);
538 ok(ret == MMSYSERR_NOERROR, "mmioGetInfo error %u\n", ret);
539 ok(mmio.dwFlags == MMIO_READ, "expected MMIO_READ, got %x\n", mmio.dwFlags);
540 ok(mmio.wErrorRet == MMSYSERR_NOERROR, "expected MMSYSERR_NOERROR, got %u\n", mmio.wErrorRet);
541 ok(mmio.fccIOProc == (fname ? FOURCC_DOS : FOURCC_MEM), "got %4.4s\n", (LPCSTR)&mmio.fccIOProc);
542 ok(mmio.cchBuffer == 0, "got not 0\n");
543 ok(mmio.pchBuffer == NULL, "got not NULL buf\n");
544 ok(mmio.pchNext == mmio.pchBuffer, "expected %p, got %p\n", mmio.pchBuffer, mmio.pchNext);
545 ok(mmio.pchEndRead == mmio.pchBuffer, "expected %p, got %p\n", mmio.pchBuffer, mmio.pchEndRead);
546 ok(mmio.pchEndWrite == mmio.pchBuffer, "expected %p, got %p\n", mmio.pchBuffer, mmio.pchEndWrite);
547 ok(mmio.lBufOffset == 0, "expected 0, got %d\n", mmio.lBufOffset);
548 ok(mmio.lDiskOffset == 0, "expected 0, got %d\n", mmio.lDiskOffset);
549
550 ret = mmioSeek(hmmio, 0, SEEK_CUR);
551 ok(ret == 0, "expected 0, got %d\n", ret);
552
553 ret = mmioSetBuffer(hmmio, buf, 0, MMIO_ALLOCBUF);
554 ok(ret == MMSYSERR_NOERROR, "mmioSetBuffer error %u\n", ret);
555
556 memset(&mmio, 0, sizeof(mmio));
557 ret = mmioGetInfo(hmmio, &mmio, 0);
558 ok(ret == MMSYSERR_NOERROR, "mmioGetInfo error %u\n", ret);
559 ok(mmio.dwFlags == MMIO_READ, "expected MMIO_READ, got %x\n", mmio.dwFlags);
560 ok(mmio.wErrorRet == MMSYSERR_NOERROR, "expected MMSYSERR_NOERROR, got %u\n", mmio.wErrorRet);
561 ok(mmio.fccIOProc == (fname ? FOURCC_DOS : FOURCC_MEM), "got %4.4s\n", (LPCSTR)&mmio.fccIOProc);
562 ok(mmio.cchBuffer == 0, "got not 0\n");
563 ok(mmio.pchBuffer == buf, "expected %p, got %p\n", buf, mmio.pchBuffer);
564 ok(mmio.pchNext == mmio.pchBuffer, "expected %p, got %p\n", mmio.pchBuffer, mmio.pchNext);
565 ok(mmio.pchEndRead == mmio.pchBuffer, "expected %p, got %p\n", mmio.pchBuffer, mmio.pchEndRead);
566 ok(mmio.pchEndWrite == mmio.pchBuffer, "expected %p, got %p\n", mmio.pchBuffer, mmio.pchEndWrite);
567 ok(mmio.lBufOffset == 0, "expected 0, got %d\n", mmio.lBufOffset);
568 ok(mmio.lDiskOffset == 0, "expected 0, got %d\n", mmio.lDiskOffset);
569
570 ret = mmioSeek(hmmio, 0, SEEK_CUR);
571 ok(ret == 0, "expected 0, got %d\n", ret);
572
574 ok(ret == MMSYSERR_NOERROR, "mmioSetBuffer error %u\n", ret);
575
576 memset(&mmio, 0, sizeof(mmio));
577 ret = mmioGetInfo(hmmio, &mmio, 0);
578 ok(ret == MMSYSERR_NOERROR, "mmioGetInfo error %u\n", ret);
579 ok(mmio.dwFlags == (MMIO_READ|MMIO_ALLOCBUF), "expected MMIO_READ|MMIO_ALLOCBUF, got %x\n", mmio.dwFlags);
580 ok(mmio.wErrorRet == MMSYSERR_NOERROR, "expected MMSYSERR_NOERROR, got %u\n", mmio.wErrorRet);
581 ok(mmio.fccIOProc == (fname ? FOURCC_DOS : FOURCC_MEM), "got %4.4s\n", (LPCSTR)&mmio.fccIOProc);
582 ok(mmio.cchBuffer == 256, "got %u\n", mmio.cchBuffer);
583 ok(mmio.pchBuffer != NULL, "expected not NULL\n");
584 ok(mmio.pchBuffer != buf, "expected != buf\n");
585 ok(mmio.pchNext == mmio.pchBuffer, "expected %p, got %p\n", mmio.pchBuffer, mmio.pchNext);
586 ok(mmio.pchEndRead == mmio.pchBuffer, "expected %p, got %p\n", buf, mmio.pchEndRead);
587 ok(mmio.pchEndWrite == mmio.pchBuffer + mmio.cchBuffer, "expected %p + %d, got %p\n", mmio.pchBuffer, mmio.cchBuffer, mmio.pchEndWrite);
588 ok(mmio.lBufOffset == 0, "expected 0, got %d\n", mmio.lBufOffset);
589 ok(mmio.lDiskOffset == 0, "expected 0, got %d\n", mmio.lDiskOffset);
590
591 ret = mmioSeek(hmmio, 0, SEEK_CUR);
592 ok(ret == 0, "expected 0, got %d\n", ret);
593
594 mmioClose(hmmio, 0);
595}
MMRESULT WINAPI mmioSetBuffer(HMMIO hmmio, LPSTR pchBuffer, LONG cchBuffer, UINT uFlags)
Definition: mmio.c:945
#define MMIO_WRITE
Definition: mmsystem.h:536

Referenced by START_TEST().

◆ test_riff_write()

static void test_riff_write ( void  )
static

Definition at line 925 of file mmio.c.

926{
927 static const DWORD test_write_data[] =
928 {
929 FOURCC_RIFF, 0x28, mmioFOURCC('W','A','V','E'), mmioFOURCC('d','a','t','a'),
930 0x1b, 0xdededede, 0xdededede, 0xefefefef,
931 0xefefefef, 0xbabababa, 0xbabababa, 0xefefef
932 };
933
934 char name[] = "test_write.wav";
935 char buf[256];
936 MMCKINFO chunk_info[2];
938 HMMIO mmio;
940 LONG written;
941 DWORD read;
942 HANDLE h;
943
944 memset(chunk_info, 0, sizeof(chunk_info));
945
947 ok(mmio != NULL, "mmioOpen failed\n");
948
949 chunk_info[0].fccType = mmioFOURCC('W','A','V','E');
950 ret = mmioCreateChunk(mmio, chunk_info, MMIO_CREATERIFF);
951 ok(ret == MMSYSERR_NOERROR, "mmioCreateChunk failed %x\n", ret);
952 ok(chunk_info[0].ckid == FOURCC_RIFF, "chunk_info[0].ckid = %x\n", chunk_info[0].ckid);
953 ok(chunk_info[0].cksize == 0, "chunk_info[0].cksize = %d\n", chunk_info[0].cksize);
954 ok(chunk_info[0].dwDataOffset == 8, "chunk_info[0].dwDataOffset = %d\n", chunk_info[0].dwDataOffset);
955 ok(chunk_info[0].dwFlags == MMIO_DIRTY, "chunk_info[0].dwFlags = %x\n", chunk_info[0].dwFlags);
956
957 chunk_info[1].ckid = mmioFOURCC('d','a','t','a');
958 ret = mmioCreateChunk(mmio, chunk_info+1, 0);
959 ok(ret == MMSYSERR_NOERROR, "mmioCreateChunk failed %x\n", ret);
960 ok(chunk_info[1].ckid == mmioFOURCC('d','a','t','a'), "chunk_info[1].ckid = %x\n", chunk_info[1].ckid);
961 ok(chunk_info[1].cksize == 0, "chunk_info[1].cksize = %d\n", chunk_info[1].cksize);
962 ok(chunk_info[1].dwDataOffset == 20, "chunk_info[1].dwDataOffset = %d\n", chunk_info[1].dwDataOffset);
963 ok(chunk_info[1].dwFlags == MMIO_DIRTY, "chunk_info[1].dwFlags = %x\n", chunk_info[1].dwFlags);
964
965 memset(buf, 0xde, sizeof(buf));
966 written = mmioWrite(mmio, buf, 8);
967 ok(written == 8, "mmioWrite failed %x\n", ret);
968
969 ret = mmioGetInfo(mmio, &info, 0);
970 ok(ret == MMSYSERR_NOERROR, "mmioGetInfo failed %x\n", ret);
971
972 memset(info.pchNext, 0xef, 8);
973 info.pchNext += 8;
974 ret = mmioAdvance(mmio, &info, 1);
975 ok(ret == MMSYSERR_NOERROR, "mmioAdvance failed %x\n", ret);
976 ok(info.lBufOffset == 36, "info.lBufOffset = %d\n", info.lBufOffset);
977
978 info.dwFlags |= MMIO_DIRTY;
979 memset(info.pchNext, 0xba, 8);
980 info.pchNext += 8;
981 ret = mmioAdvance(mmio, &info, 1);
982 ok(ret == MMSYSERR_NOERROR, "mmioAdvance failed %x\n", ret);
983 ok(info.lBufOffset == 44, "info.lBufOffset = %d\n", info.lBufOffset);
984
985 info.dwFlags |= MMIO_DIRTY;
986 memset(info.pchNext, 0xef, 3);
987 info.pchNext += 3;
988 ret = mmioSetInfo(mmio, &info, 0);
989 ok(ret == MMSYSERR_NOERROR, "mmioSetInfo failed %x\n", ret);
990
991 ret = mmioAscend(mmio, chunk_info+1, 0);
992 ok(ret == MMSYSERR_NOERROR, "mmioAscend failed %x\n", ret);
993 ret = mmioAscend(mmio, chunk_info, 0);
994 ok(ret == MMSYSERR_NOERROR, "mmioAscend failed %x\n", ret);
995 ret = mmioClose(mmio, 0);
996 ok(ret == MMSYSERR_NOERROR, "mmioClose failed %x\n", ret);
997
998 h = CreateFileA("test_write.wav", GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0);
999 ok(h != INVALID_HANDLE_VALUE, "CreateFile failed\n");
1000 ok(ReadFile(h, buf, sizeof(buf), &read, NULL), "ReadFile failed\n");
1001 CloseHandle(h);
1002 ok(!memcmp(buf, test_write_data, sizeof(test_write_data)), "created file is incorrect\n");
1003
1004 DeleteFileA("test_write.wav");
1005}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define read
Definition: acwin.h:96
#define OPEN_EXISTING
Definition: compat.h:775
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define GENERIC_READ
Definition: compat.h:135
MMRESULT WINAPI mmioAscend(HMMIO hmmio, LPMMCKINFO lpck, UINT uFlags)
Definition: mmio.c:1205
LONG WINAPI mmioWrite(HMMIO hmmio, HPCSTR pch, LONG cch)
Definition: mmio.c:782
MMRESULT WINAPI mmioCreateChunk(HMMIO hmmio, MMCKINFO *lpck, UINT uFlags)
Definition: mmio.c:1239
MMRESULT WINAPI mmioSetInfo(HMMIO hmmio, const MMIOINFO *lpmmioinfo, UINT uFlags)
Definition: mmio.c:918
#define MMIO_READWRITE
Definition: mmsystem.h:537
#define MMIO_CREATE
Definition: mmsystem.h:528
#define MMIO_DIRTY
Definition: mmsystem.h:534
#define MMIO_CREATERIFF
Definition: mmsystem.h:554
Definition: name.c:39
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176

Referenced by START_TEST().

Variable Documentation

◆ RIFF_buf

DWORD RIFF_buf[]
static
Initial value:
=
{
FOURCC_RIFF, 32*sizeof(DWORD), mmioFOURCC('A','V','I',' '),
sizeof(MainAVIHeader), 0xdeadbeef, 0xdeadbeef, 0xdeadbeef,
0xdeadbeef, 0xdeadbeef, 0xdeadbeef,0xdeadbeef,
0xdeadbeef, 0xdeadbeef, 0xdeadbeef,0xdeadbeef,
0xdeadbeef, 0xdeadbeef, 0xdeadbeef,
7*sizeof(DWORD), streamtypeVIDEO, 0xdeadbeef, 0xdeadbeef,
0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}
#define streamtypeVIDEO
Definition: aviriff.h:92

Definition at line 30 of file mmio.c.

Referenced by create_test_file(), test_mmio_end_of_file(), test_mmioDescend(), and test_mmioSeek().