winmm: Inherit the seek position when using standard file handle.
This commit is contained in:
parent
80f6197fdc
commit
7a22250867
|
@ -670,9 +670,9 @@ static HMMIO MMIO_Open(LPSTR szFileName, MMIOINFO* refmminfo, DWORD dwOpenFlags,
|
|||
refmminfo->wErrorRet = send_message(wm->ioProc, &wm->info, MMIOM_OPEN,
|
||||
(LPARAM)szFileName, 0, FALSE);
|
||||
|
||||
/* grab file size, when possible */
|
||||
/* update offsets and grab file size, when possible */
|
||||
if (wm->info.fccIOProc != FOURCC_MEM && (send_message(wm->ioProc, &wm->info, MMIOM_SEEK, 0, SEEK_CUR, FALSE)) != -1) {
|
||||
pos = wm->info.lDiskOffset;
|
||||
pos = wm->info.lBufOffset = wm->info.lDiskOffset;
|
||||
send_message(wm->ioProc, &wm->info, MMIOM_SEEK, 0, SEEK_END, FALSE);
|
||||
wm->dwFileSize = wm->info.lDiskOffset;
|
||||
send_message(wm->ioProc, &wm->info, MMIOM_SEEK, pos, SEEK_SET, FALSE);
|
||||
|
|
|
@ -704,6 +704,8 @@ static void test_mmioSeek(void)
|
|||
const LONG size = sizeof(RIFF_buf), offset = 16;
|
||||
char test_file[MAX_PATH];
|
||||
MMRESULT res;
|
||||
HFILE hfile;
|
||||
OFSTRUCT ofs;
|
||||
|
||||
/* test memory file */
|
||||
memset(&mmio, 0, sizeof(mmio));
|
||||
|
@ -784,6 +786,24 @@ static void test_mmioSeek(void)
|
|||
mmioClose(hmmio, 0);
|
||||
}
|
||||
|
||||
/* test seek position inheritance from standard file handle */
|
||||
hfile = OpenFile(test_file, &ofs, OF_READ);
|
||||
ok(hfile != HFILE_ERROR, "Failed to open the file, err %d\n", GetLastError());
|
||||
if (hfile != HFILE_ERROR) {
|
||||
pos = _llseek(hfile, offset, SEEK_SET);
|
||||
ok(pos != HFILE_ERROR, "Failed to seek, err %d\n", GetLastError());
|
||||
memset(&mmio, 0, sizeof(mmio));
|
||||
mmio.fccIOProc = FOURCC_DOS;
|
||||
mmio.adwInfo[0] = (DWORD)hfile;
|
||||
hmmio = mmioOpen(NULL, &mmio, MMIO_READ | MMIO_DENYWRITE | MMIO_ALLOCBUF);
|
||||
ok(hmmio != NULL, "mmioOpen error %u\n", mmio.wErrorRet);
|
||||
if (hmmio != NULL) {
|
||||
pos = mmioSeek(hmmio, 0, SEEK_CUR);
|
||||
ok(pos == offset, "expected %d, got %d\n", offset, pos);
|
||||
mmioClose(hmmio, 0);
|
||||
}
|
||||
}
|
||||
|
||||
DeleteFileA(test_file);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue