Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/winegstreamer/wm_syncreader.c | 29 +++++++++++++++++++++++++++-- dlls/wmvcore/tests/wmvcore.c | 6 +++--- 2 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/dlls/winegstreamer/wm_syncreader.c b/dlls/winegstreamer/wm_syncreader.c index a2cc747e9bf..063be2a94ab 100644 --- a/dlls/winegstreamer/wm_syncreader.c +++ b/dlls/winegstreamer/wm_syncreader.c @@ -25,6 +25,8 @@ struct sync_reader struct wm_reader reader;
IWMSyncReader2 IWMSyncReader2_iface; + + WORD last_read_stream; };
static struct sync_reader *impl_from_IWMSyncReader2(IWMSyncReader2 *iface) @@ -83,6 +85,7 @@ static HRESULT WINAPI WMSyncReader_GetNextSample(IWMSyncReader2 *iface, struct sync_reader *reader = impl_from_IWMSyncReader2(iface); struct wm_stream *stream; HRESULT hr; + WORD i;
TRACE("reader %p, stream_number %u, sample %p, pts %p, duration %p," " flags %p, output_number %p, ret_stream_number %p.\n", @@ -92,8 +95,30 @@ static HRESULT WINAPI WMSyncReader_GetNextSample(IWMSyncReader2 *iface,
if (!stream_number) { - FIXME("Reading from all streams is not implemented yet.\n"); - hr = E_NOTIMPL; + if (!output_number && !ret_stream_number) + { + LeaveCriticalSection(&reader->reader.cs); + return E_INVALIDARG; + } + + for (i = 0; i < reader->reader.stream_count; ++i) + { + WORD index = (i + reader->last_read_stream + 1) % reader->reader.stream_count; + + hr = wm_reader_get_stream_sample(&reader->reader.streams[index], sample, pts, duration, flags); + if (hr == S_OK) + { + if (output_number) + *output_number = index; + if (ret_stream_number) + *ret_stream_number = index + 1; + } + if (hr != NS_E_NO_MORE_SAMPLES) + { + reader->last_read_stream = index; + break; + } + } } else { diff --git a/dlls/wmvcore/tests/wmvcore.c b/dlls/wmvcore/tests/wmvcore.c index 419dea2f68d..48d585e73c0 100644 --- a/dlls/wmvcore/tests/wmvcore.c +++ b/dlls/wmvcore/tests/wmvcore.c @@ -550,7 +550,7 @@ static void test_sync_reader_streaming(void) INSSBuffer_Release(sample);
hr = IWMSyncReader_GetNextSample(reader, 0, &sample, &pts, &duration, &flags, NULL, NULL); - todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
hr = IWMSyncReader_GetNextSample(reader, 0, &sample, &pts, &duration, &flags, &output_number, NULL); todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); @@ -567,7 +567,7 @@ static void test_sync_reader_streaming(void) stream_number = pts = duration = flags = output_number = 0xdeadbeef; hr = IWMSyncReader_GetNextSample(reader, 0, &sample, &pts, &duration, &flags, &output_number, &stream_number); - todo_wine ok(hr == S_OK || hr == NS_E_NO_MORE_SAMPLES, "Got hr %#x.\n", hr); + ok(hr == S_OK || hr == NS_E_NO_MORE_SAMPLES, "Got hr %#x.\n", hr);
if (hr == S_OK) { @@ -589,7 +589,7 @@ static void test_sync_reader_streaming(void)
hr = IWMSyncReader_GetNextSample(reader, 0, &sample, &pts, &duration, &flags, NULL, &stream_number); - todo_wine ok(hr == NS_E_NO_MORE_SAMPLES, "Got hr %#x.\n", hr); + ok(hr == NS_E_NO_MORE_SAMPLES, "Got hr %#x.\n", hr);
hr = IWMSyncReader_GetNextSample(reader, stream_numbers[0], &sample, &pts, &duration, &flags, NULL, NULL);