Erich Hoover : quartz: Fix converting between the media time and REFTIME.
Alexandre Julliard
julliard at winehq.org
Mon Sep 12 11:43:01 CDT 2011
Module: wine
Branch: master
Commit: 09f134cb69209a94ca1a61da8841ea39d470f2a2
URL: http://source.winehq.org/git/wine.git/?a=commit;h=09f134cb69209a94ca1a61da8841ea39d470f2a2
Author: Erich Hoover <ehoover at mines.edu>
Date: Sun Sep 11 14:11:10 2011 -0600
quartz: Fix converting between the media time and REFTIME.
---
dlls/quartz/filtergraph.c | 67 +++++++++++++++++++++++++++++++++++++++------
1 files changed, 58 insertions(+), 9 deletions(-)
diff --git a/dlls/quartz/filtergraph.c b/dlls/quartz/filtergraph.c
index 1becf11..c154f92 100644
--- a/dlls/quartz/filtergraph.c
+++ b/dlls/quartz/filtergraph.c
@@ -2621,21 +2621,62 @@ static HRESULT WINAPI MediaPosition_Invoke(IMediaPosition* iface, DISPID dispIdM
return E_NOTIMPL;
}
+static HRESULT ConvertFromREFTIME(IMediaSeeking *seek, REFTIME time_in, LONGLONG *time_out)
+{
+ GUID time_format;
+ HRESULT hr;
+
+ hr = MediaSeeking_GetTimeFormat(seek, &time_format);
+ if (FAILED(hr))
+ return hr;
+ if (!IsEqualGUID(&TIME_FORMAT_MEDIA_TIME, &time_format))
+ {
+ FIXME("Unsupported time format.\n");
+ return E_NOTIMPL;
+ }
+
+ *time_out = (LONGLONG) (time_in * 10000000); /* convert from 1 second intervals to 100 ns intervals */
+ return S_OK;
+}
+
+static HRESULT ConvertToREFTIME(IMediaSeeking *seek, LONGLONG time_in, REFTIME *time_out)
+{
+ GUID time_format;
+ HRESULT hr;
+
+ hr = MediaSeeking_GetTimeFormat(seek, &time_format);
+ if (FAILED(hr))
+ return hr;
+ if (!IsEqualGUID(&TIME_FORMAT_MEDIA_TIME, &time_format))
+ {
+ FIXME("Unsupported time format.\n");
+ return E_NOTIMPL;
+ }
+
+ *time_out = (REFTIME)time_in / 10000000; /* convert from 100 ns intervals to 1 second intervals */
+ return S_OK;
+}
+
/*** IMediaPosition methods ***/
static HRESULT WINAPI MediaPosition_get_Duration(IMediaPosition * iface, REFTIME *plength)
{
LONGLONG duration;
IFilterGraphImpl *This = impl_from_IMediaPosition( iface );
HRESULT hr = IMediaSeeking_GetDuration(&This->IMediaSeeking_iface, &duration);
- if (SUCCEEDED(hr)) *plength = duration;
- return hr;
+ if (FAILED(hr))
+ return hr;
+ return ConvertToREFTIME(&This->IMediaSeeking_iface, duration, plength);
}
static HRESULT WINAPI MediaPosition_put_CurrentPosition(IMediaPosition * iface, REFTIME llTime)
{
IFilterGraphImpl *This = impl_from_IMediaPosition( iface );
- LONGLONG reftime = llTime;
+ LONGLONG reftime;
+ HRESULT hr;
+ hr = ConvertFromREFTIME(&This->IMediaSeeking_iface, llTime, &reftime);
+ if (FAILED(hr))
+ return hr;
return IMediaSeeking_SetPositions(&This->IMediaSeeking_iface, &reftime,
AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
}
@@ -2644,9 +2685,12 @@ static HRESULT WINAPI MediaPosition_get_CurrentPosition(IMediaPosition * iface,
{
IFilterGraphImpl *This = impl_from_IMediaPosition( iface );
LONGLONG pos;
- HRESULT hr = IMediaSeeking_GetCurrentPosition(&This->IMediaSeeking_iface, &pos);
- if (SUCCEEDED(hr)) *pllTime = pos;
- return hr;
+ HRESULT hr;
+
+ hr = IMediaSeeking_GetCurrentPosition(&This->IMediaSeeking_iface, &pos);
+ if (FAILED(hr))
+ return hr;
+ return ConvertToREFTIME(&This->IMediaSeeking_iface, pos, pllTime);
}
static HRESULT WINAPI MediaPosition_get_StopTime(IMediaPosition * iface, REFTIME *pllTime)
@@ -2654,15 +2698,20 @@ static HRESULT WINAPI MediaPosition_get_StopTime(IMediaPosition * iface, REFTIME
IFilterGraphImpl *This = impl_from_IMediaPosition( iface );
LONGLONG pos;
HRESULT hr = IMediaSeeking_GetStopPosition(&This->IMediaSeeking_iface, &pos);
- if (SUCCEEDED(hr)) *pllTime = pos;
- return hr;
+ if (FAILED(hr))
+ return hr;
+ return ConvertToREFTIME(&This->IMediaSeeking_iface, pos, pllTime);
}
static HRESULT WINAPI MediaPosition_put_StopTime(IMediaPosition * iface, REFTIME llTime)
{
IFilterGraphImpl *This = impl_from_IMediaPosition( iface );
- LONGLONG reftime = llTime;
+ LONGLONG reftime;
+ HRESULT hr;
+ hr = ConvertFromREFTIME(&This->IMediaSeeking_iface, llTime, &reftime);
+ if (FAILED(hr))
+ return hr;
return IMediaSeeking_SetPositions(&This->IMediaSeeking_iface, NULL, AM_SEEKING_NoPositioning,
&reftime, AM_SEEKING_AbsolutePositioning);
}
More information about the wine-cvs
mailing list