Module: wine Branch: master Commit: 539fa6922b068440d3f3669cfa219d234e0c611e URL: https://source.winehq.org/git/wine.git/?a=commit;h=539fa6922b068440d3f3669cf...
Author: Zebediah Figura z.figura12@gmail.com Date: Mon Oct 21 16:54:48 2019 -0500
quartz/filtergraph: Store the current position and return it in IMediaSeeking::GetCurrentPosition().
Signed-off-by: Zebediah Figura z.figura12@gmail.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/quartz/filtergraph.c | 41 +++++++++++++++++++++++++++-------------- dlls/quartz/tests/filtergraph.c | 12 ++++++------ dlls/wmp/tests/media.c | 4 +--- 3 files changed, 34 insertions(+), 23 deletions(-)
diff --git a/dlls/quartz/filtergraph.c b/dlls/quartz/filtergraph.c index 966f427b15..f7ca192c13 100644 --- a/dlls/quartz/filtergraph.c +++ b/dlls/quartz/filtergraph.c @@ -210,6 +210,8 @@ typedef struct _IFilterGraphImpl {
HANDLE message_thread, message_thread_ret; DWORD message_thread_id; + + LONGLONG current_pos; } IFilterGraphImpl;
struct enum_filters @@ -2505,27 +2507,32 @@ static HRESULT WINAPI MediaSeeking_GetStopPosition(IMediaSeeking *iface, LONGLON return hr; }
-static HRESULT WINAPI MediaSeeking_GetCurrentPosition(IMediaSeeking *iface, LONGLONG *pCurrent) +static HRESULT WINAPI MediaSeeking_GetCurrentPosition(IMediaSeeking *iface, LONGLONG *current) { - IFilterGraphImpl *This = impl_from_IMediaSeeking(iface); - LONGLONG time = 0; + IFilterGraphImpl *graph = impl_from_IMediaSeeking(iface); + LONGLONG ret = graph->current_pos; + + TRACE("graph %p, current %p.\n", graph, current);
- if (!pCurrent) + if (!current) return E_POINTER;
- EnterCriticalSection(&This->cs); - if (This->state == State_Running && This->refClock && This->start_time >= 0) + EnterCriticalSection(&graph->cs); + + if (graph->state == State_Running && graph->refClock && graph->start_time >= 0) { - IReferenceClock_GetTime(This->refClock, &time); + REFERENCE_TIME time; + IReferenceClock_GetTime(graph->refClock, &time); if (time) - time -= This->start_time; + ret += time - graph->start_time; } - if (This->pause_time > 0) - time += This->pause_time; - *pCurrent = time; - LeaveCriticalSection(&This->cs);
- TRACE("Time: %u.%03u\n", (DWORD)(*pCurrent / 10000000), (DWORD)((*pCurrent / 10000)%1000)); + if (graph->pause_time > 0) + ret += graph->pause_time; + LeaveCriticalSection(&graph->cs); + + TRACE("Returning %s.\n", wine_dbgstr_longlong(ret)); + *current = ret;
return S_OK; } @@ -2586,7 +2593,8 @@ static HRESULT WINAPI MediaSeeking_SetPositions(IMediaSeeking *iface, LONGLONG * if (FAILED(IBaseFilter_QueryInterface(filter->filter, &IID_IMediaSeeking, (void **)&seeking))) continue;
- filter_hr = IMediaSeeking_SetPositions(seeking, ¤t, current_flags, &stop, stop_flags); + filter_hr = IMediaSeeking_SetPositions(seeking, ¤t, + current_flags | AM_SEEKING_ReturnTime, &stop, stop_flags); IMediaSeeking_Release(seeking); if (SUCCEEDED(filter_hr)) { @@ -2596,6 +2604,7 @@ static HRESULT WINAPI MediaSeeking_SetPositions(IMediaSeeking *iface, LONGLONG * *current_ptr = current; if (stop_ptr && (stop_flags & AM_SEEKING_ReturnTime)) *stop_ptr = stop; + graph->current_pos = current; } else if (filter_hr != E_NOTIMPL) { @@ -5220,7 +5229,10 @@ static HRESULT WINAPI MediaFilter_Pause(IMediaFilter *iface) IFilterGraph2_SetDefaultSyncSource(&graph->IFilterGraph2_iface);
if (graph->state == State_Running && graph->refClock && graph->start_time >= 0) + { IReferenceClock_GetTime(graph->refClock, &graph->pause_time); + graph->current_pos += graph->pause_time - graph->start_time; + } else graph->pause_time = -1;
@@ -5714,6 +5726,7 @@ static HRESULT filter_graph_common_create(IUnknown *outer, void **out, BOOL thre fimpl->punkFilterMapper2 = NULL; fimpl->recursioncount = 0; fimpl->version = 0; + fimpl->current_pos = 0;
if (threaded) { diff --git a/dlls/quartz/tests/filtergraph.c b/dlls/quartz/tests/filtergraph.c index bffbc82b98..d5e205ef79 100644 --- a/dlls/quartz/tests/filtergraph.c +++ b/dlls/quartz/tests/filtergraph.c @@ -3838,12 +3838,12 @@ static void test_graph_seeking(void)
hr = IMediaSeeking_GetCurrentPosition(seeking, &time); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(time == 12340000, "Got time %s.\n", wine_dbgstr_longlong(time)); + ok(time == 12340000, "Got time %s.\n", wine_dbgstr_longlong(time));
current = stop = 0xdeadbeef; hr = IMediaSeeking_GetPositions(seeking, ¤t, &stop); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(current == 12340000, "Got time %s.\n", wine_dbgstr_longlong(current)); + ok(current == 12340000, "Got time %s.\n", wine_dbgstr_longlong(current)); ok(stop == 0x321, "Got time %s.\n", wine_dbgstr_longlong(stop));
current = 0x123; @@ -3908,12 +3908,12 @@ static void test_graph_seeking(void)
hr = IMediaSeeking_GetCurrentPosition(seeking, &time); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(abs(time - 1234 * 10000) < 40 * 10000, + ok(abs(time - 1234 * 10000) < 40 * 10000, "Expected about 1234ms, got %s.\n", wine_dbgstr_longlong(time)); current = stop = 0xdeadbeef; hr = IMediaSeeking_GetPositions(seeking, ¤t, &stop); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(abs(current - 1234 * 10000) < 40 * 10000, + ok(abs(current - 1234 * 10000) < 40 * 10000, "Expected about 1234ms, got %s.\n", wine_dbgstr_longlong(current)); ok(stop == 9000 * 10000, "Got time %s.\n", wine_dbgstr_longlong(stop));
@@ -3921,12 +3921,12 @@ static void test_graph_seeking(void)
hr = IMediaSeeking_GetCurrentPosition(seeking, &time); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(abs(time - 1334 * 10000) < 40 * 10000, + ok(abs(time - 1334 * 10000) < 40 * 10000, "Expected about 1334ms, got %s.\n", wine_dbgstr_longlong(time)); current = stop = 0xdeadbeef; hr = IMediaSeeking_GetPositions(seeking, ¤t, &stop); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(abs(current - 1334 * 10000) < 40 * 10000, + ok(abs(current - 1334 * 10000) < 40 * 10000, "Expected about 1334ms, got %s.\n", wine_dbgstr_longlong(current)); ok(stop == 9000 * 10000, "Got time %s.\n", wine_dbgstr_longlong(stop));
diff --git a/dlls/wmp/tests/media.c b/dlls/wmp/tests/media.c index fee18fd556..9857a7e7ae 100644 --- a/dlls/wmp/tests/media.c +++ b/dlls/wmp/tests/media.c @@ -413,9 +413,7 @@ static BOOL test_wmp(void) duration = 0.0; hres = IWMPControls_get_currentPosition(controls, &duration); ok(hres == S_OK, "IWMPControls_get_currentPosition failed: %08x\n", hres); - /* builtin quartz does not handle this currently and resets to 0.0, works - * with native quartz */ - todo_wine ok(duration >= 1.05 /* save some fp errors */, "unexpected value %f\n", duration); + ok(duration >= 1.05 /* save some fp errors */, "unexpected value %f\n", duration);
hres = IWMPPlayer4_get_currentMedia(player4, &media); ok(hres == S_OK, "IWMPPlayer4_get_currentMedia failed: %08x\n", hres);