From bc52edc19d8a45b9062d9568652403251872026e Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Thu, 28 Oct 2021 11:46:00 -0500 Subject: [PATCH] winegstreamer: Implement IWMSyncReader::GetOutputFormatCount(). Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard --- dlls/winegstreamer/gst_private.h | 1 + dlls/winegstreamer/wm_reader.c | 30 ++++++++++++++++++++++++++++++ dlls/winegstreamer/wm_syncreader.c | 10 ++++++---- dlls/wmvcore/tests/wmvcore.c | 8 ++++---- 4 files changed, 41 insertions(+), 8 deletions(-) diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h index da36d53abff..9219a86c094 100644 --- a/dlls/winegstreamer/gst_private.h +++ b/dlls/winegstreamer/gst_private.h @@ -155,6 +155,7 @@ void wm_reader_cleanup(struct wm_reader *reader); HRESULT wm_reader_close(struct wm_reader *reader); HRESULT wm_reader_get_output_format(struct wm_reader *reader, DWORD output, DWORD index, IWMOutputMediaProps **props); +HRESULT wm_reader_get_output_format_count(struct wm_reader *reader, DWORD output, DWORD *count); HRESULT wm_reader_get_output_props(struct wm_reader *reader, DWORD output, IWMOutputMediaProps **props); void wm_reader_init(struct wm_reader *reader, const struct wm_reader_ops *ops); diff --git a/dlls/winegstreamer/wm_reader.c b/dlls/winegstreamer/wm_reader.c index f6820121bf0..79a89c9a332 100644 --- a/dlls/winegstreamer/wm_reader.c +++ b/dlls/winegstreamer/wm_reader.c @@ -1306,6 +1306,36 @@ static const enum wg_video_format video_formats[] = WG_VIDEO_FORMAT_RGB15, }; +HRESULT wm_reader_get_output_format_count(struct wm_reader *reader, DWORD output, DWORD *count) +{ + struct wm_stream *stream; + struct wg_format format; + + EnterCriticalSection(&reader->cs); + + if (!(stream = get_stream_by_output_number(reader, output))) + { + LeaveCriticalSection(&reader->cs); + return E_INVALIDARG; + } + + wg_parser_stream_get_preferred_format(stream->wg_stream, &format); + switch (format.major_type) + { + case WG_MAJOR_TYPE_VIDEO: + *count = ARRAY_SIZE(video_formats); + break; + + case WG_MAJOR_TYPE_AUDIO: + case WG_MAJOR_TYPE_UNKNOWN: + *count = 1; + break; + } + + LeaveCriticalSection(&reader->cs); + return S_OK; +} + HRESULT wm_reader_get_output_format(struct wm_reader *reader, DWORD output, DWORD index, IWMOutputMediaProps **props) { diff --git a/dlls/winegstreamer/wm_syncreader.c b/dlls/winegstreamer/wm_syncreader.c index 7becd88b63e..54c53dee3bd 100644 --- a/dlls/winegstreamer/wm_syncreader.c +++ b/dlls/winegstreamer/wm_syncreader.c @@ -107,11 +107,13 @@ static HRESULT WINAPI WMSyncReader_GetOutputFormat(IWMSyncReader2 *iface, return wm_reader_get_output_format(&reader->reader, output, index, props); } -static HRESULT WINAPI WMSyncReader_GetOutputFormatCount(IWMSyncReader2 *iface, DWORD output_num, DWORD *formats) +static HRESULT WINAPI WMSyncReader_GetOutputFormatCount(IWMSyncReader2 *iface, DWORD output, DWORD *count) { - struct sync_reader *This = impl_from_IWMSyncReader2(iface); - FIXME("(%p)->(%u %p): stub!\n", This, output_num, formats); - return E_NOTIMPL; + struct sync_reader *reader = impl_from_IWMSyncReader2(iface); + + TRACE("reader %p, output %u, count %p.\n", reader, output, count); + + return wm_reader_get_output_format_count(&reader->reader, output, count); } static HRESULT WINAPI WMSyncReader_GetOutputNumberForStream(IWMSyncReader2 *iface, diff --git a/dlls/wmvcore/tests/wmvcore.c b/dlls/wmvcore/tests/wmvcore.c index 5c1a47b65d1..ebfdfdf0107 100644 --- a/dlls/wmvcore/tests/wmvcore.c +++ b/dlls/wmvcore/tests/wmvcore.c @@ -747,8 +747,8 @@ static void test_sync_reader_types(void) count = 0; hr = IWMSyncReader_GetOutputFormatCount(reader, output_number, &count); - todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(count > 0, "Got count %u.\n", count); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(count > 0, "Got count %u.\n", count); for (j = 0; j < count; ++j) { @@ -824,7 +824,7 @@ static void test_sync_reader_types(void) } hr = IWMSyncReader_GetOutputFormat(reader, output_number, count, &output_props); - todo_wine ok(hr == NS_E_INVALID_OUTPUT_FORMAT, "Got hr %#x.\n", hr); + ok(hr == NS_E_INVALID_OUTPUT_FORMAT, "Got hr %#x.\n", hr); hr = IWMSyncReader_GetOutputProps(reader, output_number, &output_props); ok(hr == S_OK, "Got hr %#x.\n", hr); @@ -846,7 +846,7 @@ static void test_sync_reader_types(void) count = 0xdeadbeef; hr = IWMSyncReader_GetOutputFormatCount(reader, 2, &count); - todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); ok(count == 0xdeadbeef, "Got count %#x.\n", count); output_props = (void *)0xdeadbeef;