From 40f48834fcfb7f308394a6b3221785b7c8ba45cc Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 18 Oct 2010 23:43:14 +0000 Subject: [PATCH] Correctly handle S_FALSE return value of IActiveMovie::get_Duration(). IActiveMovie::get_Duration() can return S_FALSE in which case outDuration isn't initialized and so wxAMMediaBackend::GetDuration() would return a completely wrong value. Fix this by returning 0 from it instead which seems like the only reasonable thing to do (in the absence of documentation of this interface it's not really clear what does S_FALSE return value mean nor why didn't it return it before). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65845 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/mediactrl_am.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/msw/mediactrl_am.cpp b/src/msw/mediactrl_am.cpp index a1d78e14f3..97541c9105 100644 --- a/src/msw/mediactrl_am.cpp +++ b/src/msw/mediactrl_am.cpp @@ -2009,18 +2009,19 @@ wxLongLong wxAMMediaBackend::GetDuration() { double outDuration; HRESULT hr = GetAM()->get_Duration(&outDuration); - if(FAILED(hr)) + switch ( hr ) { - wxAMLOG(hr); - return 0; - } + default: + wxAMLOG(hr); + // fall through - // h,m,s,milli - outDuration is in 1 second (double) - outDuration *= 1000; - wxLongLong ll; - ll.Assign(outDuration); + case S_FALSE: + return 0; - return ll; + case S_OK: + // outDuration is in seconds, we need milliseconds + return outDuration * 1000; + } } //--------------------------------------------------------------------------- -- 2.45.2