Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mfplat/mfplat.spec | 2 +- dlls/mfplat/queue.c | 10 ---------- 2 files changed, 1 insertion(+), 11 deletions(-)
diff --git a/dlls/mfplat/mfplat.spec b/dlls/mfplat/mfplat.spec index 5af717419b..31d3777e87 100644 --- a/dlls/mfplat/mfplat.spec +++ b/dlls/mfplat/mfplat.spec @@ -136,7 +136,7 @@ @ stdcall MFRegisterLocalSchemeHandler(wstr ptr) @ stdcall MFRemovePeriodicCallback(long) rtworkq.RtwqRemovePeriodicCallback @ stdcall MFScheduleWorkItem(ptr ptr int64 ptr) -@ stdcall MFScheduleWorkItemEx(ptr int64 ptr) +@ stdcall MFScheduleWorkItemEx(ptr int64 ptr) rtworkq.RtwqScheduleWorkItem @ stub MFSerializeAttributesToStream @ stub MFSerializeEvent @ stub MFSerializeMediaTypeToStream diff --git a/dlls/mfplat/queue.c b/dlls/mfplat/queue.c index 6ad3977e59..2080a79f84 100644 --- a/dlls/mfplat/queue.c +++ b/dlls/mfplat/queue.c @@ -119,16 +119,6 @@ HRESULT WINAPI MFScheduleWorkItem(IMFAsyncCallback *callback, IUnknown *state, I return hr; }
-/*********************************************************************** - * MFScheduleWorkItemEx (mfplat.@) - */ -HRESULT WINAPI MFScheduleWorkItemEx(IMFAsyncResult *result, INT64 timeout, MFWORKITEM_KEY *key) -{ - TRACE("%p, %s, %p.\n", result, wine_dbgstr_longlong(timeout), key); - - return RtwqScheduleWorkItem((IRtwqAsyncResult *)result, timeout, key); -} - /*********************************************************************** * MFInvokeCallback (mfplat.@) */
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mfplat/main.c | 22 +++++++- dlls/mfplat/tests/mfplat.c | 109 ++++++++++++++++++++++++++++++++++++- 2 files changed, 129 insertions(+), 2 deletions(-)
diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c index 889961b8d1..37ea744313 100644 --- a/dlls/mfplat/main.c +++ b/dlls/mfplat/main.c @@ -8058,15 +8058,35 @@ static HRESULT WINAPI system_time_source_sink_OnClockStart(IMFClockStateSink *if LONGLONG start_offset) { struct system_time_source *source = impl_from_IMFClockStateSink(iface); + MFCLOCK_STATE state; HRESULT hr;
TRACE("%p, %s, %s.\n", iface, debugstr_time(system_time), debugstr_time(start_offset));
EnterCriticalSection(&source->cs); + state = source->state; if (SUCCEEDED(hr = system_time_source_change_state(source, CLOCK_CMD_START))) { system_time_source_apply_rate(source, &system_time); - source->start_offset = -system_time + start_offset; + if (start_offset == PRESENTATION_CURRENT_POSITION) + { + switch (state) + { + case MFCLOCK_STATE_RUNNING: + break; + case MFCLOCK_STATE_PAUSED: + source->start_offset -= system_time; + break; + default: + source->start_offset = -system_time; + break; + ; + } + } + else + { + source->start_offset = -system_time + start_offset; + } } LeaveCriticalSection(&source->cs);
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 497c451f72..185bacdebe 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -3127,7 +3127,6 @@ static void test_system_time_source(void) hr = IMFPresentationTimeSource_GetCorrelatedTime(time_source, 0, &time, &systime); ok(hr == S_OK, "Failed to get time %#x.\n", hr); ok(time == 0, "Unexpected time stamp %s, %s.\n", wine_dbgstr_longlong(time), wine_dbgstr_longlong(systime)); - IMFClockStateSink_Release(statesink);
hr = IMFClockStateSink_OnClockStart(statesink, 10, 0); ok(hr == S_OK, "Failed to start source, hr %#x.\n", hr); @@ -3172,6 +3171,114 @@ static void test_system_time_source(void) ok(time == -6, "Unexpected time stamp %s, %s.\n", wine_dbgstr_longlong(time), wine_dbgstr_longlong(systime));
+ IMFClockStateSink_Release(statesink); + IMFPresentationTimeSource_Release(time_source); + + /* PRESENTATION_CURRENT_POSITION */ + hr = MFCreateSystemTimeSource(&time_source); + ok(hr == S_OK, "Failed to create time source, hr %#x.\n", hr); + + hr = IMFPresentationTimeSource_QueryInterface(time_source, &IID_IMFClockStateSink, (void **)&statesink); + ok(hr == S_OK, "Failed to get sink interface, hr %#x.\n", hr); + + hr = IMFPresentationTimeSource_GetCorrelatedTime(time_source, 0, &time, &systime); + ok(hr == S_OK, "Failed to get time %#x.\n", hr); + ok(!time && systime, "Unexpected time stamp %s, %s.\n", wine_dbgstr_longlong(time), + wine_dbgstr_longlong(systime)); + + /* INVALID -> RUNNING */ + hr = IMFClockStateSink_OnClockStart(statesink, 10, PRESENTATION_CURRENT_POSITION); + ok(hr == S_OK, "Failed to start source, hr %#x.\n", hr); + + hr = IMFPresentationTimeSource_GetCorrelatedTime(time_source, 0, &time, &systime); + ok(hr == S_OK, "Failed to get time %#x.\n", hr); + ok(time == systime - 10, "Unexpected time stamp %s, %s.\n", wine_dbgstr_longlong(time), + wine_dbgstr_longlong(systime)); + + /* RUNNING -> RUNNING */ + hr = IMFClockStateSink_OnClockStart(statesink, 20, PRESENTATION_CURRENT_POSITION); + ok(hr == S_OK, "Failed to start source, hr %#x.\n", hr); + + hr = IMFPresentationTimeSource_GetCorrelatedTime(time_source, 0, &time, &systime); + ok(hr == S_OK, "Failed to get time %#x.\n", hr); + ok(time == systime - 10, "Unexpected time stamp %s, %s.\n", wine_dbgstr_longlong(time), + wine_dbgstr_longlong(systime)); + + hr = IMFClockStateSink_OnClockStart(statesink, 0, PRESENTATION_CURRENT_POSITION); + ok(hr == S_OK, "Failed to start source, hr %#x.\n", hr); + + hr = IMFPresentationTimeSource_GetCorrelatedTime(time_source, 0, &time, &systime); + ok(hr == S_OK, "Failed to get time %#x.\n", hr); + ok(time == systime - 10, "Unexpected time stamp %s, %s.\n", wine_dbgstr_longlong(time), + wine_dbgstr_longlong(systime)); + + hr = IMFClockStateSink_OnClockStart(statesink, 0, 0); + ok(hr == S_OK, "Failed to start source, hr %#x.\n", hr); + + hr = IMFPresentationTimeSource_GetCorrelatedTime(time_source, 0, &time, &systime); + ok(hr == S_OK, "Failed to get time %#x.\n", hr); + ok(time == systime, "Unexpected time stamp %s, %s.\n", wine_dbgstr_longlong(time), + wine_dbgstr_longlong(systime)); + + hr = IMFClockStateSink_OnClockStart(statesink, 30, PRESENTATION_CURRENT_POSITION); + ok(hr == S_OK, "Failed to start source, hr %#x.\n", hr); + + hr = IMFPresentationTimeSource_GetCorrelatedTime(time_source, 0, &time, &systime); + ok(hr == S_OK, "Failed to get time %#x.\n", hr); + ok(time == systime, "Unexpected time stamp %s, %s.\n", wine_dbgstr_longlong(time), + wine_dbgstr_longlong(systime)); + + /* STOPPED -> RUNNING */ + hr = IMFClockStateSink_OnClockStop(statesink, 567); + ok(hr == S_OK, "Failed to stop source, hr %#x.\n", hr); + + hr = IMFPresentationTimeSource_GetCorrelatedTime(time_source, 0, &time, &systime); + ok(hr == S_OK, "Failed to get time %#x.\n", hr); + ok(!time && systime != 0, "Unexpected time stamp %s, %s.\n", wine_dbgstr_longlong(time), + wine_dbgstr_longlong(systime)); + + hr = IMFClockStateSink_OnClockStart(statesink, 30, PRESENTATION_CURRENT_POSITION); + ok(hr == S_OK, "Failed to start source, hr %#x.\n", hr); + + hr = IMFPresentationTimeSource_GetCorrelatedTime(time_source, 0, &time, &systime); + ok(hr == S_OK, "Failed to get time %#x.\n", hr); + ok(time == systime - 30, "Unexpected time stamp %s, %s.\n", wine_dbgstr_longlong(time), + wine_dbgstr_longlong(systime)); + + /* PAUSED -> RUNNING */ + hr = IMFClockStateSink_OnClockPause(statesink, 8); + ok(hr == S_OK, "Failed to pause source, hr %#x.\n", hr); + + hr = IMFPresentationTimeSource_GetCorrelatedTime(time_source, 0, &time, &systime); + ok(hr == S_OK, "Failed to get time %#x.\n", hr); + ok(time == (-30 + 8) && systime != 0, "Unexpected time stamp %s, %s.\n", wine_dbgstr_longlong(time), + wine_dbgstr_longlong(systime)); + + hr = IMFClockStateSink_OnClockStart(statesink, 40, PRESENTATION_CURRENT_POSITION); + ok(hr == S_OK, "Failed to start source, hr %#x.\n", hr); + + hr = IMFPresentationTimeSource_GetCorrelatedTime(time_source, 0, &time, &systime); + ok(hr == S_OK, "Failed to get time %#x.\n", hr); + ok(time == systime + (-30 + 8 - 40), "Unexpected time stamp %s, %s.\n", wine_dbgstr_longlong(time), + wine_dbgstr_longlong(systime)); + + hr = IMFClockStateSink_OnClockPause(statesink, 7); + ok(hr == S_OK, "Failed to pause source, hr %#x.\n", hr); + + hr = IMFPresentationTimeSource_GetCorrelatedTime(time_source, 0, &time, &systime); + ok(hr == S_OK, "Failed to get time %#x.\n", hr); + ok(time == (-30 + 8 - 40 + 7) && systime != 0, "Unexpected time stamp %s, %s.\n", wine_dbgstr_longlong(time), + wine_dbgstr_longlong(systime)); + + hr = IMFClockStateSink_OnClockStart(statesink, 50, 7); + ok(hr == S_OK, "Failed to start source, hr %#x.\n", hr); + + hr = IMFPresentationTimeSource_GetCorrelatedTime(time_source, 0, &time, &systime); + ok(hr == S_OK, "Failed to get time %#x.\n", hr); + ok(time == systime + (-50 + 7), "Unexpected time stamp %s, %s.\n", wine_dbgstr_longlong(time), + wine_dbgstr_longlong(systime)); + + IMFClockStateSink_Release(statesink); IMFPresentationTimeSource_Release(time_source); }
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mfplat/tests/mfplat.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-)
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 185bacdebe..78d73b7580 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -76,8 +76,6 @@ static HRESULT (WINAPI *pMFCopyImage)(BYTE *dest, LONG deststride, const BYTE *s static HRESULT (WINAPI *pMFCreateDXGIDeviceManager)(UINT *token, IMFDXGIDeviceManager **manager); static HRESULT (WINAPI *pMFCreateSourceResolver)(IMFSourceResolver **resolver); static HRESULT (WINAPI *pMFCreateMFByteStreamOnStream)(IStream *stream, IMFByteStream **bytestream); -static void* (WINAPI *pMFHeapAlloc)(SIZE_T size, ULONG flags, char *file, int line, EAllocationType type); -static void (WINAPI *pMFHeapFree)(void *p); static HRESULT (WINAPI *pMFPutWaitingWorkItem)(HANDLE event, LONG priority, IMFAsyncResult *result, MFWORKITEM_KEY *key); static HRESULT (WINAPI *pMFAllocateSerialWorkQueue)(DWORD queue, DWORD *serial_queue); static HRESULT (WINAPI *pMFAddPeriodicCallback)(MFPERIODICCALLBACK callback, IUnknown *context, DWORD *key); @@ -678,8 +676,6 @@ static void init_functions(void) X(MFCreateTransformActivate); X(MFGetPlaneSize); X(MFGetStrideForBitmapInfoHeader); - X(MFHeapAlloc); - X(MFHeapFree); X(MFPutWaitingWorkItem); X(MFRegisterLocalByteStreamHandler); X(MFRegisterLocalSchemeHandler); @@ -2483,16 +2479,10 @@ static void test_MFHeapAlloc(void) { void *res;
- if (!pMFHeapAlloc) - { - win_skip("MFHeapAlloc() is not available.\n"); - return; - } - - res = pMFHeapAlloc(16, 0, NULL, 0, eAllocationTypeIgnore); + res = MFHeapAlloc(16, 0, NULL, 0, eAllocationTypeIgnore); ok(res != NULL, "MFHeapAlloc failed.\n");
- pMFHeapFree(res); + MFHeapFree(res); }
static void test_scheduled_items(void)
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mf/main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/dlls/mf/main.c b/dlls/mf/main.c index ac80c51016..01fe17866c 100644 --- a/dlls/mf/main.c +++ b/dlls/mf/main.c @@ -760,17 +760,20 @@ static HRESULT WINAPI file_scheme_handler_BeginCreateObject(IMFSchemeHandler *if
hr = MFCreateAsyncResult(&context->IUnknown_iface, &handler->IMFAsyncCallback_iface, (IUnknown *)caller, &item); IUnknown_Release(&context->IUnknown_iface); - IMFAsyncResult_Release(caller); if (SUCCEEDED(hr)) { if (SUCCEEDED(hr = MFPutWorkItemEx(MFASYNC_CALLBACK_QUEUE_IO, item))) { if (cancel_cookie) - IMFAsyncResult_GetState(item, cancel_cookie); + { + *cancel_cookie = (IUnknown *)caller; + IUnknown_AddRef(*cancel_cookie); + } }
IMFAsyncResult_Release(item); } + IMFAsyncResult_Release(caller);
return hr; }
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mfplat/buffer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dlls/mfplat/buffer.c b/dlls/mfplat/buffer.c index 4bbb36b683..1a31299d24 100644 --- a/dlls/mfplat/buffer.c +++ b/dlls/mfplat/buffer.c @@ -1211,7 +1211,8 @@ static HRESULT sample_copy_to_buffer(struct sample *sample, IMFMediaBuffer *buff } }
- IMFMediaBuffer_SetCurrentLength(buffer, dst_current_length); + if (FAILED(IMFMediaBuffer_SetCurrentLength(buffer, dst_current_length))) + WARN("Failed to set buffer length.\n");
if (locked) IMFMediaBuffer_Unlock(buffer);
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mfreadwrite/reader.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/dlls/mfreadwrite/reader.c b/dlls/mfreadwrite/reader.c index 3b024fc80c..9a7c5e5fd7 100644 --- a/dlls/mfreadwrite/reader.c +++ b/dlls/mfreadwrite/reader.c @@ -895,7 +895,7 @@ static BOOL source_reader_get_read_result(struct source_reader *reader, struct m source_reader_release_response(response); }
- return request_sample; + return !request_sample; }
static HRESULT source_reader_get_stream_read_index(struct source_reader *reader, DWORD index, DWORD *stream_index) @@ -984,8 +984,8 @@ static HRESULT WINAPI source_reader_async_commands_callback_Invoke(IMFAsyncCallb struct source_reader_async_command *command; struct stream_response *response; DWORD stream_index, stream_flags; - BOOL request_sample = FALSE; struct media_stream *stream; + BOOL report_sample = FALSE; IMFSample *sample = NULL; LONGLONG timestamp = 0; HRESULT hr, status; @@ -1008,10 +1008,8 @@ static HRESULT WINAPI source_reader_async_commands_callback_Invoke(IMFAsyncCallb
if (SUCCEEDED(hr = source_reader_start_source(reader))) { - request_sample = source_reader_get_read_result(reader, stream, command->flags, &status, &stream_index, - &stream_flags, ×tamp, &sample); - - if (request_sample) + if (!(report_sample = source_reader_get_read_result(reader, stream, command->flags, &status, &stream_index, + &stream_flags, ×tamp, &sample))) { stream->requests++; source_reader_request_sample(reader, stream); @@ -1021,7 +1019,7 @@ static HRESULT WINAPI source_reader_async_commands_callback_Invoke(IMFAsyncCallb
LeaveCriticalSection(&stream->cs);
- if (!request_sample) + if (report_sample) IMFSourceReaderCallback_OnReadSample(reader->async_callback, status, stream_index, stream_flags, timestamp, sample);
@@ -1532,7 +1530,6 @@ static HRESULT source_reader_read_sample(struct source_reader *reader, DWORD ind unsigned int actual_index_tmp; struct media_stream *stream; LONGLONG timestamp_tmp; - BOOL request_sample; DWORD stream_index; HRESULT hr = S_OK;
@@ -1563,10 +1560,8 @@ static HRESULT source_reader_read_sample(struct source_reader *reader, DWORD ind
if (SUCCEEDED(hr = source_reader_start_source(reader))) { - request_sample = source_reader_get_read_result(reader, stream, flags, &hr, actual_index, stream_flags, - timestamp, sample); - - if (request_sample) + if (!source_reader_get_read_result(reader, stream, flags, &hr, actual_index, stream_flags, + timestamp, sample)) { while (list_empty(&stream->responses) && stream->state != STREAM_STATE_EOS) {