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>
This commit is contained in:
Zebediah Figura 2019-10-21 16:54:48 -05:00 committed by Alexandre Julliard
parent 1c0985013e
commit 539fa6922b
3 changed files with 37 additions and 26 deletions

View File

@ -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;
if (!pCurrent)
TRACE("graph %p, current %p.\n", graph, current);
if (!current)
return E_POINTER;
EnterCriticalSection(&This->cs);
if (This->state == State_Running && This->refClock && This->start_time >= 0)
{
IReferenceClock_GetTime(This->refClock, &time);
if (time)
time -= This->start_time;
}
if (This->pause_time > 0)
time += This->pause_time;
*pCurrent = time;
LeaveCriticalSection(&This->cs);
EnterCriticalSection(&graph->cs);
TRACE("Time: %u.%03u\n", (DWORD)(*pCurrent / 10000000), (DWORD)((*pCurrent / 10000)%1000));
if (graph->state == State_Running && graph->refClock && graph->start_time >= 0)
{
REFERENCE_TIME time;
IReferenceClock_GetTime(graph->refClock, &time);
if (time)
ret += time - graph->start_time;
}
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, &current, current_flags, &stop, stop_flags);
filter_hr = IMediaSeeking_SetPositions(seeking, &current,
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)
{

View File

@ -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, &current, &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, &current, &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, &current, &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));

View File

@ -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);