Signed-off-by: Anton Baskanov baskanov@gmail.com --- dlls/amstream/multimedia.c | 8 +++--- dlls/amstream/tests/amstream.c | 52 +++++++++++++++++++++++++++------- 2 files changed, 46 insertions(+), 14 deletions(-)
diff --git a/dlls/amstream/multimedia.c b/dlls/amstream/multimedia.c index 5c04c771535..b34634d89d2 100644 --- a/dlls/amstream/multimedia.c +++ b/dlls/amstream/multimedia.c @@ -174,13 +174,13 @@ static HRESULT WINAPI multimedia_stream_SetState(IAMMultiMediaStream *iface, STR return hr; }
-static HRESULT WINAPI multimedia_stream_GetTime(IAMMultiMediaStream *iface, STREAM_TIME *pCurrentTime) +static HRESULT WINAPI multimedia_stream_GetTime(IAMMultiMediaStream *iface, STREAM_TIME *time) { - struct multimedia_stream *This = impl_from_IAMMultiMediaStream(iface); + struct multimedia_stream *stream = impl_from_IAMMultiMediaStream(iface);
- FIXME("(%p/%p)->(%p) stub!\n", This, iface, pCurrentTime); + TRACE("stream %p, time %p.\n", stream, time);
- return E_NOTIMPL; + return IMediaStreamFilter_GetCurrentStreamTime(stream->filter, time); }
static HRESULT WINAPI multimedia_stream_GetDuration(IAMMultiMediaStream *iface, STREAM_TIME *duration) diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index b69e6070a35..3027226848a 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -6487,14 +6487,27 @@ static void test_mediastreamfilter_seeking(void)
static void test_mediastreamfilter_get_current_stream_time(void) { + IAMMultiMediaStream *mmstream = create_ammultimediastream(); + STREAM_TIME filter_start_time; IMediaStreamFilter *filter; + IMediaFilter *media_filter; struct testclock clock; - REFERENCE_TIME time; + IGraphBuilder *graph; + STREAM_TIME time; HRESULT hr; ULONG ref;
- hr = CoCreateInstance(&CLSID_MediaStreamFilter, NULL, CLSCTX_INPROC_SERVER, - &IID_IMediaStreamFilter, (void **)&filter); + hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_GetFilter(mmstream, &filter); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(!!filter, "Expected non-null filter.\n"); + hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryAudio, 0, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_GetFilterGraph(mmstream, &graph); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(graph != NULL, "Expected non-NULL graph.\n"); + hr = IGraphBuilder_QueryInterface(graph, &IID_IMediaFilter, (void **)&media_filter); ok(hr == S_OK, "Got hr %#x.\n", hr); testclock_init(&clock);
@@ -6503,14 +6516,20 @@ static void test_mediastreamfilter_get_current_stream_time(void) { hr = IMediaStreamFilter_GetCurrentStreamTime(filter, NULL); ok(hr == E_POINTER, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_GetTime(mmstream, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); }
time = 0xdeadbeefdeadbeef; hr = IMediaStreamFilter_GetCurrentStreamTime(filter, &time); ok(hr == S_FALSE, "Got hr %#x.\n", hr); ok(time == 0, "Got time %s.\n", wine_dbgstr_longlong(time)); + time = 0xdeadbeefdeadbeef; + hr = IAMMultiMediaStream_GetTime(mmstream, &time); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(time == 0, "Got time %s.\n", wine_dbgstr_longlong(time));
- hr = IMediaStreamFilter_SetSyncSource(filter, &clock.IReferenceClock_iface); + hr = IMediaFilter_SetSyncSource(media_filter, &clock.IReferenceClock_iface); ok(hr == S_OK, "Got hr %#x.\n", hr);
clock.get_time_hr = E_FAIL; @@ -6519,23 +6538,36 @@ static void test_mediastreamfilter_get_current_stream_time(void) hr = IMediaStreamFilter_GetCurrentStreamTime(filter, &time); ok(hr == S_FALSE, "Got hr %#x.\n", hr); ok(time == 0, "Got time %s.\n", wine_dbgstr_longlong(time)); + time = 0xdeadbeefdeadbeef; + hr = IAMMultiMediaStream_GetTime(mmstream, &time); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(time == 0, "Got time %s.\n", wine_dbgstr_longlong(time));
- hr = IMediaStreamFilter_Run(filter, 23456789); + clock.time = 23456789; + clock.get_time_hr = S_OK; + + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_RUN); ok(hr == S_OK, "Got hr %#x.\n", hr);
- time = 0xdeadbeefdeadbeef; - hr = IMediaStreamFilter_GetCurrentStreamTime(filter, &time); + hr = IMediaStreamFilter_GetCurrentStreamTime(filter, &filter_start_time); ok(hr == S_OK, "Got hr %#x.\n", hr); - ok(time == 0xdeadbeefdd47d2da, "Got time %s.\n", wine_dbgstr_longlong(time));
clock.time = 34567890; - clock.get_time_hr = S_OK;
time = 0xdeadbeefdeadbeef; hr = IMediaStreamFilter_GetCurrentStreamTime(filter, &time); ok(hr == S_OK, "Got hr %#x.\n", hr); - ok(time == 11111101, "Got time %s.\n", wine_dbgstr_longlong(time)); + ok(time == 11111101 + filter_start_time, "Got time %s.\n", wine_dbgstr_longlong(time)); + time = 0xdeadbeefdeadbeef; + hr = IAMMultiMediaStream_GetTime(mmstream, &time); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(time == 11111101 + filter_start_time, "Got time %s.\n", wine_dbgstr_longlong(time));
+ ref = IAMMultiMediaStream_Release(mmstream); + ok(!ref, "Got outstanding refcount %d.\n", ref); + IMediaFilter_Release(media_filter); + ref = IGraphBuilder_Release(graph); + ok(!ref, "Got outstanding refcount %d.\n", ref); ref = IMediaStreamFilter_Release(filter); ok(!ref, "Got outstanding refcount %d.\n", ref); }