Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/filesource.c | 5 +++++ dlls/quartz/tests/filesource.c | 3 --- 2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/dlls/quartz/filesource.c b/dlls/quartz/filesource.c index 71724af700..9e3605757b 100644 --- a/dlls/quartz/filesource.c +++ b/dlls/quartz/filesource.c @@ -1292,6 +1292,8 @@ static BOOL sync_read(HANDLE file, LONGLONG offset, LONG length, BYTE *buffer, D ovl.u.s.Offset = (DWORD)offset; ovl.u.s.OffsetHigh = offset >> 32;
+ *read_len = 0; + ret = ReadFile(file, buffer, length, NULL, &ovl); if (ret || GetLastError() == ERROR_IO_PENDING) ret = GetOverlappedResult(file, &ovl, read_len, TRUE); @@ -1331,6 +1333,9 @@ static HRESULT WINAPI FileAsyncReader_SyncReadAligned(IAsyncReader *iface, IMedi hr = HRESULT_FROM_WIN32(GetLastError()); }
+ if (SUCCEEDED(hr)) + IMediaSample_SetActualDataLength(sample, read_len); + return hr; }
diff --git a/dlls/quartz/tests/filesource.c b/dlls/quartz/tests/filesource.c index 340d1c4e2e..36a25395cd 100644 --- a/dlls/quartz/tests/filesource.c +++ b/dlls/quartz/tests/filesource.c @@ -687,7 +687,6 @@ static void test_sync_read_aligned(IAsyncReader *reader, IMemAllocator *allocato ok(hr == S_OK, "Got hr %#x.\n", hr);
len = IMediaSample_GetActualDataLength(sample); -todo_wine ok(len == 512, "Got length %d.\n", len);
for (i = 0; i < 512; i++) @@ -702,7 +701,6 @@ todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr);
len = IMediaSample_GetActualDataLength(sample); -todo_wine ok(len == 88, "Got length %d.\n", len);
for (i = 0; i < 88; i++) @@ -717,7 +715,6 @@ todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
len = IMediaSample_GetActualDataLength(sample); -todo_wine ok(len == 0, "Got length %d.\n", len);
IMediaSample_Release(sample);
There's no point checking the sample's time again. Moreover, short reads are not an error.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/filesource.c | 10 ---------- 1 file changed, 10 deletions(-)
diff --git a/dlls/quartz/filesource.c b/dlls/quartz/filesource.c index 9e3605757b..fc3e508960 100644 --- a/dlls/quartz/filesource.c +++ b/dlls/quartz/filesource.c @@ -1222,7 +1222,6 @@ static HRESULT WINAPI FileAsyncReader_WaitForNext(IAsyncReader * iface, DWORD dw if (SUCCEEDED(hr)) { REFERENCE_TIME rtStart, rtStop; - REFERENCE_TIME rtSampleStart, rtSampleStop; DATAREQUEST *pDataRq = This->sample_list + buffer; DWORD dwBytes = 0;
@@ -1247,16 +1246,7 @@ static HRESULT WINAPI FileAsyncReader_WaitForNext(IAsyncReader * iface, DWORD dw rtStart = MEDIATIME_FROM_BYTES(rtStart); rtStop = rtStart + MEDIATIME_FROM_BYTES(dwBytes);
- IMediaSample_GetTime(pDataRq->pSample, &rtSampleStart, &rtSampleStop); - assert(rtStart == rtSampleStart); - assert(rtStop <= rtSampleStop); - IMediaSample_SetTime(pDataRq->pSample, &rtStart, &rtStop); - assert(rtStart == rtSampleStart); - if (hr == S_OK) - assert(rtStop == rtSampleStop); - else - assert(rtStop == rtStart);
This->sample_list[buffer].pSample = NULL; assert(This->oldest_sample < This->samples);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/tests/filesource.c | 94 ++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+)
diff --git a/dlls/quartz/tests/filesource.c b/dlls/quartz/tests/filesource.c index 36a25395cd..d5262365fd 100644 --- a/dlls/quartz/tests/filesource.c +++ b/dlls/quartz/tests/filesource.c @@ -720,6 +720,99 @@ static void test_sync_read_aligned(IAsyncReader *reader, IMemAllocator *allocato IMediaSample_Release(sample); }
+static void test_request(IAsyncReader *reader, IMemAllocator *allocator) +{ + IMediaSample *sample, *sample2, *ret_sample; + REFERENCE_TIME start_time, end_time; + BYTE *data, *data2; + DWORD_PTR cookie; + HRESULT hr; + LONG len; + int i; + + IMemAllocator_GetBuffer(allocator, &sample, NULL, NULL, 0); + IMediaSample_GetPointer(sample, &data); + IMemAllocator_GetBuffer(allocator, &sample2, NULL, NULL, 0); + IMediaSample_GetPointer(sample2, &data2); + + hr = IAsyncReader_WaitForNext(reader, 0, &ret_sample, &cookie); + ok(hr == VFW_E_TIMEOUT, "Got hr %#x.\n", hr); + + start_time = 0; + end_time = 512 * (LONGLONG)10000000; + hr = IMediaSample_SetTime(sample, &start_time, &end_time); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IAsyncReader_Request(reader, sample, 123); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IAsyncReader_WaitForNext(reader, 1000, &ret_sample, &cookie); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(ret_sample == sample, "Expected sample %p, got %p.\n", sample, ret_sample); + ok(cookie == 123, "Got cookie %lu.\n", cookie); + + len = IMediaSample_GetActualDataLength(sample); + ok(len == 512, "Got length %d.\n", hr); + + for (i = 0; i < 512; i++) + ok(data[i] == i % 111, "Got wrong byte %02x at %u.\n", data[i], i); + + start_time = 1024 * (LONGLONG)10000000; + end_time = 1536 * (LONGLONG)10000000; + hr = IMediaSample_SetTime(sample, &start_time, &end_time); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IAsyncReader_Request(reader, sample, 123); + ok(hr == HRESULT_FROM_WIN32(ERROR_HANDLE_EOF), "Got hr %#x.\n", hr); + + start_time = 0; + end_time = 512 * (LONGLONG)10000000; + hr = IMediaSample_SetTime(sample, &start_time, &end_time); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IAsyncReader_Request(reader, sample, 123); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + start_time = 512 * (LONGLONG)10000000; + end_time = 1024 * (LONGLONG)10000000; + hr = IMediaSample_SetTime(sample2, &start_time, &end_time); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IAsyncReader_Request(reader, sample2, 456); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IAsyncReader_WaitForNext(reader, 1000, &ret_sample, &cookie); + ok(hr == S_OK, "Got hr %#x.\n", hr); + if (cookie == 123) + { + ok(ret_sample == sample, "Expected sample %p, got %p.\n", sample, ret_sample); + + hr = IAsyncReader_WaitForNext(reader, 1000, &ret_sample, &cookie); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(ret_sample == sample2, "Expected sample %p, got %p.\n", sample2, ret_sample); + ok(cookie == 456, "Got cookie %lu.\n", cookie); + } + else + { + ok(cookie == 456, "Got cookie %lu.\n", cookie); + ok(ret_sample == sample2, "Expected sample %p, got %p.\n", sample2, ret_sample); + + hr = IAsyncReader_WaitForNext(reader, 1000, &ret_sample, &cookie); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(ret_sample == sample, "Expected sample %p, got %p.\n", sample, ret_sample); + ok(cookie == 123, "Got cookie %lu.\n", cookie); + } + + for (i = 0; i < 512; i++) + ok(data[i] == i % 111, "Got wrong byte %02x at %u.\n", data[i], i); + + for (i = 0; i < 88; i++) + ok(data2[i] == (512 + i) % 111, "Got wrong byte %02x at %u.\n", data2[i], i); + + IMediaSample_Release(sample); + IMediaSample_Release(sample2); +} + static void test_async_reader(void) { ALLOCATOR_PROPERTIES req_props = {2, 1024, 512, 0}, ret_props; @@ -800,6 +893,7 @@ static void test_async_reader(void) IMemAllocator_Commit(allocator);
test_sync_read_aligned(reader, allocator); + test_request(reader, allocator);
IMemAllocator_Release(allocator); IAsyncReader_Release(reader);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/tests/filesource.c | 61 ++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+)
diff --git a/dlls/quartz/tests/filesource.c b/dlls/quartz/tests/filesource.c index d5262365fd..3960639558 100644 --- a/dlls/quartz/tests/filesource.c +++ b/dlls/quartz/tests/filesource.c @@ -813,6 +813,66 @@ static void test_request(IAsyncReader *reader, IMemAllocator *allocator) IMediaSample_Release(sample2); }
+static void test_flush(IAsyncReader *reader, IMemAllocator *allocator) +{ + REFERENCE_TIME start_time, end_time; + IMediaSample *sample, *ret_sample; + BYTE buffer[20], *data; + DWORD_PTR cookie; + HRESULT hr; + int i; + + IMemAllocator_GetBuffer(allocator, &sample, NULL, NULL, 0); + IMediaSample_GetPointer(sample, &data); + + start_time = 0; + end_time = 512 * (LONGLONG)10000000; + hr = IMediaSample_SetTime(sample, &start_time, &end_time); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IAsyncReader_BeginFlush(reader); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IAsyncReader_SyncRead(reader, 0, 20, buffer); + ok(hr == S_OK, "Got hr %#x.\n", hr); + for (i = 0; i < 20; i++) + ok(buffer[i] == i % 111, "Got wrong byte %02x at %u.\n", buffer[i], i); + + start_time = 0; + end_time = 512 * (LONGLONG)10000000; + hr = IMediaSample_SetTime(sample, &start_time, &end_time); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IAsyncReader_SyncReadAligned(reader, sample); + ok(hr == S_OK, "Got hr %#x.\n", hr); + for (i = 0; i < 512; i++) + ok(data[i] == i % 111, "Got wrong byte %02x at %u.\n", data[i], i); + + hr = IAsyncReader_Request(reader, sample, 456); + ok(hr == VFW_E_WRONG_STATE, "Got hr %#x.\n", hr); + + hr = IAsyncReader_EndFlush(reader); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IAsyncReader_WaitForNext(reader, 0, &ret_sample, &cookie); + ok(hr == VFW_E_TIMEOUT, "Got hr %#x.\n", hr); + + start_time = 0; + end_time = 512 * (LONGLONG)10000000; + hr = IAsyncReader_Request(reader, sample, 123); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IAsyncReader_WaitForNext(reader, 1000, &ret_sample, &cookie); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(ret_sample == sample, "Expected sample %p, got %p.\n", sample, ret_sample); + ok(cookie == 123, "Got cookie %lu.\n", cookie); + + for (i = 0; i < 512; i++) + ok(data[i] == i % 111, "Got wrong byte %02x at %u.\n", data[i], i); + + IMediaSample_Release(sample); +} + static void test_async_reader(void) { ALLOCATOR_PROPERTIES req_props = {2, 1024, 512, 0}, ret_props; @@ -894,6 +954,7 @@ static void test_async_reader(void)
test_sync_read_aligned(reader, allocator); test_request(reader, allocator); + test_flush(reader, allocator);
IMemAllocator_Release(allocator); IAsyncReader_Release(reader);
To match the Wine source file.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/tests/Makefile.in | 2 +- dlls/quartz/tests/{avisplitter.c => avisplit.c} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename dlls/quartz/tests/{avisplitter.c => avisplit.c} (99%)
diff --git a/dlls/quartz/tests/Makefile.in b/dlls/quartz/tests/Makefile.in index 8ecced9d00..03f13899d3 100644 --- a/dlls/quartz/tests/Makefile.in +++ b/dlls/quartz/tests/Makefile.in @@ -2,7 +2,7 @@ TESTDLL = quartz.dll IMPORTS = oleaut32 ole32 advapi32 user32
C_SRCS = \ - avisplitter.c \ + avisplit.c \ dsoundrender.c \ filesource.c \ filtergraph.c \ diff --git a/dlls/quartz/tests/avisplitter.c b/dlls/quartz/tests/avisplit.c similarity index 99% rename from dlls/quartz/tests/avisplitter.c rename to dlls/quartz/tests/avisplit.c index 757b71c640..be9ec18e94 100644 --- a/dlls/quartz/tests/avisplitter.c +++ b/dlls/quartz/tests/avisplit.c @@ -414,7 +414,7 @@ fail: DeleteFileW(filename); }
-START_TEST(avisplitter) +START_TEST(avisplit) { CoInitialize(NULL);