Signed-off-by: Myah Caron qsniyg@protonmail.com --- v4: Check if AddMediaStream returns VFW_E_NO_AUDIO_HARDWARE for detecting broken windows server 2008 tests.
I didn't implement the decimal duration printing in this revision, as I wasn't sure what a clean way to do this would be (as %lld and %llu appear to be unused except in unix sections of the code, and compiling with them produced warnings).
I looked around to check what other parts of the codebase used in this situation, but I wasn't able to find anything other than wine_dbgstr_longlong (though my grep-fu does leave a lot to be desired).
Sorry for the constant back-and-forth, and thank you for your patience.. I'm hoping my future patches will be cleaner from the get-go :)
dlls/amstream/multimedia.c | 7 ++- dlls/amstream/tests/amstream.c | 81 ++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 2 deletions(-)
diff --git a/dlls/amstream/multimedia.c b/dlls/amstream/multimedia.c index 200bd5c4a5..8f978b72ff 100644 --- a/dlls/amstream/multimedia.c +++ b/dlls/amstream/multimedia.c @@ -177,9 +177,12 @@ static HRESULT WINAPI multimedia_stream_GetDuration(IAMMultiMediaStream *iface, { struct multimedia_stream *This = impl_from_IAMMultiMediaStream(iface);
- FIXME("(%p/%p)->(%p) stub!\n", This, iface, pDuration); + TRACE("(%p/%p)->(%p)\n", This, iface, pDuration);
- return E_NOTIMPL; + if (!This->media_seeking) + return E_NOINTERFACE; + + return IMediaSeeking_GetDuration(This->media_seeking, pDuration); }
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 48953684f9..ca5c13da3a 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -335,6 +335,86 @@ 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(); + LONGLONG duration; + HRESULT hr; + ULONG ref; + BOOL no_audio = FALSE; + + 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); + if (hr == VFW_E_NO_AUDIO_HARDWARE) + no_audio = TRUE; + + hr = IAMMultiMediaStream_OpenFile(mmstream, test_avi_path, 0); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + duration = 0xdeadbeefdeadbeefULL; + hr = IAMMultiMediaStream_GetDuration(mmstream, &duration); + + ok(hr == S_OK || + broken(no_audio && hr == S_FALSE && duration == 0) /* win server */, + "Got hr %#x.\n", hr); + ok(duration == 1000000ULL || + broken(no_audio && hr == S_FALSE && duration == 0) /* win server */, + "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; @@ -5351,6 +5431,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