[PATCH v5 2/3] amstream: Implement IAMMultiMediaStream::GetDuration.
Zebediah Figura
z.figura12 at gmail.com
Tue Jul 28 16:14:00 CDT 2020
From: Myah Caron <qsniyg at protonmail.com>
Signed-off-by: Myah Caron <qsniyg at protonmail.com>
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
v5: Style tweaks, don't mark VFW_E_NO_AUDIO_HARDWARE results as broken.
dlls/amstream/multimedia.c | 10 +++--
dlls/amstream/tests/amstream.c | 80 ++++++++++++++++++++++++++++++++++
2 files changed, 86 insertions(+), 4 deletions(-)
diff --git a/dlls/amstream/multimedia.c b/dlls/amstream/multimedia.c
index 200bd5c4a5e..414a903cf20 100644
--- a/dlls/amstream/multimedia.c
+++ b/dlls/amstream/multimedia.c
@@ -173,13 +173,15 @@ static HRESULT WINAPI multimedia_stream_GetTime(IAMMultiMediaStream *iface, STRE
return E_NOTIMPL;
}
-static HRESULT WINAPI multimedia_stream_GetDuration(IAMMultiMediaStream *iface, STREAM_TIME *pDuration)
+static HRESULT WINAPI multimedia_stream_GetDuration(IAMMultiMediaStream *iface, STREAM_TIME *duration)
{
- struct multimedia_stream *This = impl_from_IAMMultiMediaStream(iface);
+ struct multimedia_stream *mmstream = impl_from_IAMMultiMediaStream(iface);
- FIXME("(%p/%p)->(%p) stub!\n", This, iface, pDuration);
+ TRACE("mmstream %p, duration %p.\n", mmstream, duration);
- return E_NOTIMPL;
+ if (!mmstream->media_seeking)
+ return E_NOINTERFACE;
+ return IMediaSeeking_GetDuration(mmstream->media_seeking, duration);
}
static HRESULT WINAPI multimedia_stream_Seek(IAMMultiMediaStream *iface, STREAM_TIME seek_time)
diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c
index 5402734b3df..85dcac91ad3 100644
--- a/dlls/amstream/tests/amstream.c
+++ b/dlls/amstream/tests/amstream.c
@@ -336,6 +336,85 @@ static void test_openfile(const WCHAR *test_avi_path)
ok(!ref, "Got outstanding refcount %d.\n", ref);
}
+static void test_mmstream_get_duration(const WCHAR *test_avi_path)
+{
+ IAMMultiMediaStream *mmstream = create_ammultimediastream();
+ HRESULT hr, audio_hr;
+ LONGLONG duration;
+ ULONG ref;
+
+ duration = 0xdeadbeefdeadbeefULL;
+ hr = IAMMultiMediaStream_GetDuration(mmstream, &duration);
+ ok(hr == E_NOINTERFACE, "Got hr %#x.\n", hr);
+ ok(duration == 0xdeadbeefdeadbeefULL, "Got duration %s.\n", wine_dbgstr_longlong(duration));
+
+ hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryVideo, 0, NULL);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryAudio, AMMSF_ADDDEFAULTRENDERER, NULL);
+ ok(hr == S_OK || hr == VFW_E_NO_AUDIO_HARDWARE, "Got hr %#x.\n", hr);
+ audio_hr = hr;
+
+ hr = IAMMultiMediaStream_OpenFile(mmstream, test_avi_path, 0);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ duration = 0xdeadbeefdeadbeefULL;
+ hr = IAMMultiMediaStream_GetDuration(mmstream, &duration);
+ if (audio_hr == S_OK)
+ {
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(duration == 1000000LL, "Got duration %s.\n", wine_dbgstr_longlong(duration));
+ }
+ else
+ {
+ ok(hr == S_FALSE, "Got hr %#x.\n", hr);
+ ok(!duration, "Got duration %s.\n", wine_dbgstr_longlong(duration));
+ }
+
+ ref = IAMMultiMediaStream_Release(mmstream);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+
+ mmstream = create_ammultimediastream();
+ hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryAudio, 0, NULL);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ duration = 0xdeadbeefdeadbeefULL;
+ hr = IAMMultiMediaStream_GetDuration(mmstream, &duration);
+ todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr);
+ ok(duration == 0, "Got duration %s.\n", wine_dbgstr_longlong(duration));
+
+ ref = IAMMultiMediaStream_Release(mmstream);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+
+ mmstream = create_ammultimediastream();
+
+ hr = IAMMultiMediaStream_OpenFile(mmstream, test_avi_path, 0);
+ todo_wine ok(hr == VFW_E_CANNOT_CONNECT, "Got hr %#x.\n", hr);
+
+ duration = 0xdeadbeefdeadbeefULL;
+ hr = IAMMultiMediaStream_GetDuration(mmstream, &duration);
+ todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr);
+ todo_wine ok(duration == 0, "Got duration %s.\n", wine_dbgstr_longlong(duration));
+
+ ref = IAMMultiMediaStream_Release(mmstream);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+
+ mmstream = create_ammultimediastream();
+ hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryAudio, 0, NULL);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IAMMultiMediaStream_OpenFile(mmstream, test_avi_path, AMMSF_NORENDER);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ duration = 0xdeadbeefdeadbeefULL;
+ hr = IAMMultiMediaStream_GetDuration(mmstream, &duration);
+ todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr);
+ ok(duration == 0, "Got duration %s.\n", wine_dbgstr_longlong(duration));
+
+ ref = IAMMultiMediaStream_Release(mmstream);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+}
+
static void test_renderfile(const WCHAR *test_avi_path)
{
IAMMultiMediaStream *pams;
@@ -5432,6 +5511,7 @@ START_TEST(amstream)
test_avi_path = load_resource(L"test.avi");
test_openfile(test_avi_path);
+ test_mmstream_get_duration(test_avi_path);
test_renderfile(test_avi_path);
unload_resource(test_avi_path);
--
2.27.0
More information about the wine-devel
mailing list