Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- dlls/mfplat/tests/mfplat.c | 47 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-)
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 65ab72bd57b..cfc22f35927 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -654,12 +654,15 @@ static void test_source_resolver(void) IMFStreamDescriptor *sd; IUnknown *cancel_cookie; IMFByteStream *stream; + IMFGetService *get_service; + IMFRateSupport *rate_support; WCHAR pathW[MAX_PATH]; int i, sample_count; WCHAR *filename; PROPVARIANT var; HRESULT hr; GUID guid; + float rate;
if (!pMFCreateSourceResolver) { @@ -763,8 +766,46 @@ static void test_source_resolver(void) ok(mediasource != NULL, "got %p\n", mediasource); ok(obj_type == MF_OBJECT_MEDIASOURCE, "got %d\n", obj_type);
- check_interface(mediasource, &IID_IMFGetService, TRUE); - check_service_interface(mediasource, &MF_RATE_CONTROL_SERVICE, &IID_IMFRateSupport, TRUE); + hr = IMFMediaSource_QueryInterface(mediasource, &IID_IMFGetService, (void**)&get_service); + ok(hr == S_OK, "Failed to get service interface, hr %#x.\n", hr); + + hr = IMFGetService_GetService(get_service, &MF_RATE_CONTROL_SERVICE, &IID_IMFRateSupport, (void**)&rate_support); + ok(hr == S_OK, "Failed to get rate support interface, hr %#x.\n", hr); + + hr = IMFRateSupport_GetFastestRate(rate_support, MFRATE_FORWARD, FALSE, &rate); + ok(hr == S_OK, "Failed to query fastest rate, hr %#x.\n", hr); +todo_wine + ok(rate == 1e6f, "Unexpected fastest rate %f.\n", rate); + hr = IMFRateSupport_GetFastestRate(rate_support, MFRATE_FORWARD, TRUE, &rate); + ok(hr == S_OK, "Failed to query fastest rate, hr %#x.\n", hr); +todo_wine + ok(rate == 1e6f, "Unexpected fastest rate %f.\n", rate); + hr = IMFRateSupport_GetFastestRate(rate_support, MFRATE_REVERSE, FALSE, &rate); + ok(hr == S_OK, "Failed to query fastest rate, hr %#x.\n", hr); +todo_wine + ok(rate == -1e6f, "Unexpected fastest rate %f.\n", rate); + hr = IMFRateSupport_GetFastestRate(rate_support, MFRATE_REVERSE, TRUE, &rate); + ok(hr == S_OK, "Failed to query fastest rate, hr %#x.\n", hr); +todo_wine + ok(rate == -1e6f, "Unexpected fastest rate %f.\n", rate); + + hr = IMFRateSupport_GetSlowestRate(rate_support, MFRATE_FORWARD, FALSE, &rate); + ok(hr == S_OK, "Failed to query slowest rate, hr %#x.\n", hr); +todo_wine + ok(rate == 0.0f, "Unexpected slowest rate %f.\n", rate); + hr = IMFRateSupport_GetSlowestRate(rate_support, MFRATE_FORWARD, TRUE, &rate); + ok(hr == S_OK, "Failed to query slowest rate, hr %#x.\n", hr); +todo_wine + ok(rate == 0.0f, "Unexpected slowest rate %f.\n", rate); + hr = IMFRateSupport_GetSlowestRate(rate_support, MFRATE_REVERSE, FALSE, &rate); + ok(hr == S_OK, "Failed to query slowest rate, hr %#x.\n", hr); +todo_wine + ok(rate == 0.0f, "Unexpected slowest rate %f.\n", rate); + hr = IMFRateSupport_GetSlowestRate(rate_support, MFRATE_REVERSE, TRUE, &rate); + ok(hr == S_OK, "Failed to query slowest rate, hr %#x.\n", hr); +todo_wine + ok(rate == 0.0f, "Unexpected slowest rate %f.\n", rate); + check_service_interface(mediasource, &MF_RATE_CONTROL_SERVICE, &IID_IMFRateControl, TRUE); hr = IMFMediaSource_CreatePresentationDescriptor(mediasource, &descriptor); ok(hr == S_OK, "Failed to get presentation descriptor, hr %#x.\n", hr); @@ -878,6 +919,8 @@ todo_wine hr = IMFMediaSource_CreatePresentationDescriptor(mediasource, NULL); ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
+ IMFRateSupport_Release(rate_support); + IMFGetService_Release(get_service); IMFMediaSource_Release(mediasource); IMFByteStream_Release(stream);
Let winegstreamer's media source emit the same rate limits that Windows exposes for media sources generated with the standard source resolver.
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- dlls/mfplat/tests/mfplat.c | 8 -------- dlls/winegstreamer/media_source.c | 6 +++--- 2 files changed, 3 insertions(+), 11 deletions(-)
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index cfc22f35927..60b86c75eb5 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -774,36 +774,28 @@ static void test_source_resolver(void)
hr = IMFRateSupport_GetFastestRate(rate_support, MFRATE_FORWARD, FALSE, &rate); ok(hr == S_OK, "Failed to query fastest rate, hr %#x.\n", hr); -todo_wine ok(rate == 1e6f, "Unexpected fastest rate %f.\n", rate); hr = IMFRateSupport_GetFastestRate(rate_support, MFRATE_FORWARD, TRUE, &rate); ok(hr == S_OK, "Failed to query fastest rate, hr %#x.\n", hr); -todo_wine ok(rate == 1e6f, "Unexpected fastest rate %f.\n", rate); hr = IMFRateSupport_GetFastestRate(rate_support, MFRATE_REVERSE, FALSE, &rate); ok(hr == S_OK, "Failed to query fastest rate, hr %#x.\n", hr); -todo_wine ok(rate == -1e6f, "Unexpected fastest rate %f.\n", rate); hr = IMFRateSupport_GetFastestRate(rate_support, MFRATE_REVERSE, TRUE, &rate); ok(hr == S_OK, "Failed to query fastest rate, hr %#x.\n", hr); -todo_wine ok(rate == -1e6f, "Unexpected fastest rate %f.\n", rate);
hr = IMFRateSupport_GetSlowestRate(rate_support, MFRATE_FORWARD, FALSE, &rate); ok(hr == S_OK, "Failed to query slowest rate, hr %#x.\n", hr); -todo_wine ok(rate == 0.0f, "Unexpected slowest rate %f.\n", rate); hr = IMFRateSupport_GetSlowestRate(rate_support, MFRATE_FORWARD, TRUE, &rate); ok(hr == S_OK, "Failed to query slowest rate, hr %#x.\n", hr); -todo_wine ok(rate == 0.0f, "Unexpected slowest rate %f.\n", rate); hr = IMFRateSupport_GetSlowestRate(rate_support, MFRATE_REVERSE, FALSE, &rate); ok(hr == S_OK, "Failed to query slowest rate, hr %#x.\n", hr); -todo_wine ok(rate == 0.0f, "Unexpected slowest rate %f.\n", rate); hr = IMFRateSupport_GetSlowestRate(rate_support, MFRATE_REVERSE, TRUE, &rate); ok(hr == S_OK, "Failed to query slowest rate, hr %#x.\n", hr); -todo_wine ok(rate == 0.0f, "Unexpected slowest rate %f.\n", rate);
check_service_interface(mediasource, &MF_RATE_CONTROL_SERVICE, &IID_IMFRateControl, TRUE); diff --git a/dlls/winegstreamer/media_source.c b/dlls/winegstreamer/media_source.c index e153c8e9161..d013a60e150 100644 --- a/dlls/winegstreamer/media_source.c +++ b/dlls/winegstreamer/media_source.c @@ -933,7 +933,7 @@ static HRESULT WINAPI media_source_rate_support_GetSlowestRate(IMFRateSupport *i { TRACE("%p, %d, %d, %p.\n", iface, direction, thin, rate);
- *rate = direction == MFRATE_FORWARD ? 1.0f : -1.0f; + *rate = 0.0f;
return S_OK; } @@ -942,14 +942,14 @@ static HRESULT WINAPI media_source_rate_support_GetFastestRate(IMFRateSupport *i { TRACE("%p, %d, %d, %p.\n", iface, direction, thin, rate);
- *rate = direction == MFRATE_FORWARD ? 1.0f : -1.0f; + *rate = direction == MFRATE_FORWARD ? 1e6f : -1e6f;
return S_OK; }
static HRESULT WINAPI media_source_rate_support_IsRateSupported(IMFRateSupport *iface, BOOL thin, float rate, float *nearest_support_rate) { - const float supported_rate = rate >= 0.0f ? 1.0f : -1.0f; + const float supported_rate = max(min(rate, 1e6f), -1e6f);
TRACE("%p, %d, %f, %p.\n", iface, thin, rate, nearest_support_rate);
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=91734
Your paranoid android.
=== debiant2 (32 bit Hindi:India report) ===
mfplat: mfplat.c:3039: Test failed: Unexpected counter value 0. Unhandled exception: page fault on execute access to 0xc38904ec in 32-bit code (0xc38904ec).
The current algorithm correctly only considers the absolute value of nodes' rates when computing maximum and minimum, but omits negating the result when in reverse direction.
Also, when computing the minimum intializing with zero is wrong, as it would always give final result zero. We have to initialize with a number that is bigger than at least one operand, e.g. FLT_MAX.
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- dlls/mf/session.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/dlls/mf/session.c b/dlls/mf/session.c index 925a8c93d20..275b1e3dd98 100644 --- a/dlls/mf/session.c +++ b/dlls/mf/session.c @@ -18,6 +18,7 @@
#include <stdarg.h> #include <math.h> +#include <float.h>
#define COBJMACROS
@@ -3532,7 +3533,7 @@ static HRESULT session_get_presentation_rate(struct media_session *session, MFRA struct media_sink *sink; HRESULT hr = E_POINTER;
- *result = 0.0f; + *result = fastest ? FLT_MAX : 0.0f;
EnterCriticalSection(&session->cs);
@@ -3556,6 +3557,9 @@ static HRESULT session_get_presentation_rate(struct media_session *session, MFRA
LeaveCriticalSection(&session->cs);
+ if (direction == MFRATE_REVERSE) + *result = -*result; + return hr; }