Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/winegstreamer/gst_private.h | 3 ++ dlls/winegstreamer/wm_reader.c | 48 ++++++++++++++++++++++++++++++ dlls/winegstreamer/wm_syncreader.c | 21 ++++++++----- 3 files changed, 65 insertions(+), 7 deletions(-)
diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h index 9674ee35052..c7c72ab65fc 100644 --- a/dlls/winegstreamer/gst_private.h +++ b/dlls/winegstreamer/gst_private.h @@ -123,6 +123,7 @@ struct wm_stream WORD index; bool eos; struct wg_format format; + WMT_STREAM_SELECTION selection; };
struct wm_reader @@ -173,5 +174,7 @@ HRESULT wm_reader_open_stream(struct wm_reader *reader, IStream *stream); void wm_reader_seek(struct wm_reader *reader, QWORD start, LONGLONG duration); HRESULT wm_reader_set_output_props(struct wm_reader *reader, DWORD output, IWMOutputMediaProps *props); +HRESULT wm_reader_set_streams_selected(struct wm_reader *reader, WORD count, + const WORD *stream_numbers, const WMT_STREAM_SELECTION *selections);
#endif /* __GST_PRIVATE_INCLUDED__ */ diff --git a/dlls/winegstreamer/wm_reader.c b/dlls/winegstreamer/wm_reader.c index bcae50e5d1e..6b29415e363 100644 --- a/dlls/winegstreamer/wm_reader.c +++ b/dlls/winegstreamer/wm_reader.c @@ -1413,6 +1413,7 @@ static HRESULT init_stream(struct wm_reader *reader, QWORD file_size) stream->wg_stream = wg_parser_get_stream(reader->wg_parser, i); stream->reader = reader; stream->index = i; + stream->selection = WMT_ON; wg_parser_stream_get_preferred_format(stream->wg_stream, &stream->format); if (stream->format.major_type == WG_MAJOR_TYPE_AUDIO) { @@ -1739,6 +1740,9 @@ HRESULT wm_reader_get_stream_sample(struct wm_stream *stream, struct wg_parser_event event; struct buffer *object;
+ if (stream->selection == WMT_OFF) + return NS_E_INVALID_REQUEST; + if (stream->eos) return NS_E_NO_MORE_SAMPLES;
@@ -1824,6 +1828,50 @@ void wm_reader_seek(struct wm_reader *reader, QWORD start, LONGLONG duration) LeaveCriticalSection(&reader->cs); }
+HRESULT wm_reader_set_streams_selected(struct wm_reader *reader, WORD count, + const WORD *stream_numbers, const WMT_STREAM_SELECTION *selections) +{ + struct wm_stream *stream; + WORD i; + + if (!count) + return E_INVALIDARG; + + EnterCriticalSection(&reader->cs); + + for (i = 0; i < count; ++i) + { + if (!(stream = wm_reader_get_stream_by_stream_number(reader, stream_numbers[i]))) + { + LeaveCriticalSection(&reader->cs); + WARN("Invalid stream number %u; returning NS_E_INVALID_REQUEST.\n", stream_numbers[i]); + return NS_E_INVALID_REQUEST; + } + } + + for (i = 0; i < count; ++i) + { + stream = wm_reader_get_stream_by_stream_number(reader, stream_numbers[i]); + stream->selection = selections[i]; + if (selections[i] == WMT_OFF) + { + TRACE("Disabling stream %u.\n", stream_numbers[i]); + wg_parser_stream_disable(stream->wg_stream); + } + else if (selections[i] == WMT_ON) + { + if (selections[i] != WMT_ON) + FIXME("Ignoring selection %#x for stream %u; treating as enabled.\n", + selections[i], stream_numbers[i]); + TRACE("Enabling stream %u.\n", stream_numbers[i]); + wg_parser_stream_enable(stream->wg_stream, &stream->format); + } + } + + LeaveCriticalSection(&reader->cs); + return S_OK; +} + void wm_reader_init(struct wm_reader *reader, const struct wm_reader_ops *ops) { reader->IWMHeaderInfo3_iface.lpVtbl = &header_info_vtbl; diff --git a/dlls/winegstreamer/wm_syncreader.c b/dlls/winegstreamer/wm_syncreader.c index fff048df06e..3e980c59601 100644 --- a/dlls/winegstreamer/wm_syncreader.c +++ b/dlls/winegstreamer/wm_syncreader.c @@ -83,8 +83,8 @@ static HRESULT WINAPI WMSyncReader_GetNextSample(IWMSyncReader2 *iface, DWORD *flags, DWORD *output_number, WORD *ret_stream_number) { struct sync_reader *reader = impl_from_IWMSyncReader2(iface); + HRESULT hr = NS_E_NO_MORE_SAMPLES; struct wm_stream *stream; - HRESULT hr; WORD i;
TRACE("reader %p, stream_number %u, sample %p, pts %p, duration %p," @@ -104,8 +104,12 @@ static HRESULT WINAPI WMSyncReader_GetNextSample(IWMSyncReader2 *iface, for (i = 0; i < reader->reader.stream_count; ++i) { WORD index = (i + reader->last_read_stream + 1) % reader->reader.stream_count; + struct wm_stream *stream = &reader->reader.streams[index];
- hr = wm_reader_get_stream_sample(&reader->reader.streams[index], sample, pts, duration, flags); + if (stream->selection == WMT_OFF) + continue; + + hr = wm_reader_get_stream_sample(stream, sample, pts, duration, flags); if (hr == S_OK) { if (output_number) @@ -296,12 +300,15 @@ static HRESULT WINAPI WMSyncReader_SetReadStreamSamples(IWMSyncReader2 *iface, W return E_NOTIMPL; }
-static HRESULT WINAPI WMSyncReader_SetStreamsSelected(IWMSyncReader2 *iface, WORD stream_count, - WORD *stream_numbers, WMT_STREAM_SELECTION *selections) +static HRESULT WINAPI WMSyncReader_SetStreamsSelected(IWMSyncReader2 *iface, + WORD count, WORD *stream_numbers, WMT_STREAM_SELECTION *selections) { - struct sync_reader *This = impl_from_IWMSyncReader2(iface); - FIXME("(%p)->(%d %p %p): stub!\n", This, stream_count, stream_numbers, selections); - return S_OK; + struct sync_reader *reader = impl_from_IWMSyncReader2(iface); + + TRACE("reader %p, count %u, stream_numbers %p, selections %p.\n", + reader, count, stream_numbers, selections); + + return wm_reader_set_streams_selected(&reader->reader, count, stream_numbers, selections); }
static HRESULT WINAPI WMSyncReader2_SetRangeByTimecode(IWMSyncReader2 *iface, WORD stream_num,
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/winegstreamer/wm_asyncreader.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/dlls/winegstreamer/wm_asyncreader.c b/dlls/winegstreamer/wm_asyncreader.c index b7b96c8b884..ced02d454a2 100644 --- a/dlls/winegstreamer/wm_asyncreader.c +++ b/dlls/winegstreamer/wm_asyncreader.c @@ -85,7 +85,12 @@ static DWORD WINAPI stream_thread(void *arg)
for (i = 0; i < stream_count; ++i) { - hr = wm_reader_get_stream_sample(&reader->reader.streams[i], &sample, &pts, &duration, &flags); + struct wm_stream *stream = &reader->reader.streams[i]; + + if (stream->selection == WMT_OFF) + continue; + + hr = wm_reader_get_stream_sample(stream, &sample, &pts, &duration, &flags); if (hr == S_OK) { if (reader->user_clock) @@ -441,12 +446,15 @@ static HRESULT WINAPI WMReaderAdvanced_GetManualStreamSelection(IWMReaderAdvance return E_NOTIMPL; }
-static HRESULT WINAPI WMReaderAdvanced_SetStreamsSelected(IWMReaderAdvanced6 *iface, WORD stream_count, - WORD *stream_numbers, WMT_STREAM_SELECTION *selections) +static HRESULT WINAPI WMReaderAdvanced_SetStreamsSelected(IWMReaderAdvanced6 *iface, + WORD count, WORD *stream_numbers, WMT_STREAM_SELECTION *selections) { - struct async_reader *This = impl_from_IWMReaderAdvanced6(iface); - FIXME("(%p)->(%d %p %p)\n", This, stream_count, stream_numbers, selections); - return E_NOTIMPL; + struct async_reader *reader = impl_from_IWMReaderAdvanced6(iface); + + TRACE("reader %p, count %u, stream_numbers %p, selections %p.\n", + reader, count, stream_numbers, selections); + + return wm_reader_set_streams_selected(&reader->reader, count, stream_numbers, selections); }
static HRESULT WINAPI WMReaderAdvanced_GetStreamSelected(IWMReaderAdvanced6 *iface, WORD stream_num,
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/winegstreamer/gst_private.h | 2 ++ dlls/winegstreamer/wm_reader.c | 19 +++++++++++++++++++ dlls/winegstreamer/wm_syncreader.c | 11 +++++++---- 3 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h index c7c72ab65fc..e1dec7b755c 100644 --- a/dlls/winegstreamer/gst_private.h +++ b/dlls/winegstreamer/gst_private.h @@ -168,6 +168,8 @@ struct wm_stream *wm_reader_get_stream_by_stream_number(struct wm_reader *reader WORD stream_number); HRESULT wm_reader_get_stream_sample(struct wm_stream *stream, INSSBuffer **sample, QWORD *pts, QWORD *duration, DWORD *flags); +HRESULT wm_reader_get_stream_selection(struct wm_reader *reader, + WORD stream_number, WMT_STREAM_SELECTION *selection); void wm_reader_init(struct wm_reader *reader, const struct wm_reader_ops *ops); HRESULT wm_reader_open_file(struct wm_reader *reader, const WCHAR *filename); HRESULT wm_reader_open_stream(struct wm_reader *reader, IStream *stream); diff --git a/dlls/winegstreamer/wm_reader.c b/dlls/winegstreamer/wm_reader.c index 6b29415e363..0e0c639d504 100644 --- a/dlls/winegstreamer/wm_reader.c +++ b/dlls/winegstreamer/wm_reader.c @@ -1872,6 +1872,25 @@ HRESULT wm_reader_set_streams_selected(struct wm_reader *reader, WORD count, return S_OK; }
+HRESULT wm_reader_get_stream_selection(struct wm_reader *reader, + WORD stream_number, WMT_STREAM_SELECTION *selection) +{ + struct wm_stream *stream; + + EnterCriticalSection(&reader->cs); + + if (!(stream = wm_reader_get_stream_by_stream_number(reader, stream_number))) + { + LeaveCriticalSection(&reader->cs); + return E_INVALIDARG; + } + + *selection = stream->selection; + + LeaveCriticalSection(&reader->cs); + return S_OK; +} + void wm_reader_init(struct wm_reader *reader, const struct wm_reader_ops *ops) { reader->IWMHeaderInfo3_iface.lpVtbl = &header_info_vtbl; diff --git a/dlls/winegstreamer/wm_syncreader.c b/dlls/winegstreamer/wm_syncreader.c index 3e980c59601..73bbf18898f 100644 --- a/dlls/winegstreamer/wm_syncreader.c +++ b/dlls/winegstreamer/wm_syncreader.c @@ -221,11 +221,14 @@ static HRESULT WINAPI WMSyncReader_GetStreamNumberForOutput(IWMSyncReader2 *ifac return S_OK; }
-static HRESULT WINAPI WMSyncReader_GetStreamSelected(IWMSyncReader2 *iface, WORD stream_num, WMT_STREAM_SELECTION *selection) +static HRESULT WINAPI WMSyncReader_GetStreamSelected(IWMSyncReader2 *iface, + WORD stream_number, WMT_STREAM_SELECTION *selection) { - struct sync_reader *This = impl_from_IWMSyncReader2(iface); - FIXME("(%p)->(%d %p): stub!\n", This, stream_num, selection); - return E_NOTIMPL; + struct sync_reader *reader = impl_from_IWMSyncReader2(iface); + + TRACE("reader %p, stream_number %u, selection %p.\n", reader, stream_number, selection); + + return wm_reader_get_stream_selection(&reader->reader, stream_number, selection); }
static HRESULT WINAPI WMSyncReader_Open(IWMSyncReader2 *iface, const WCHAR *filename)
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/winegstreamer/wm_asyncreader.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/dlls/winegstreamer/wm_asyncreader.c b/dlls/winegstreamer/wm_asyncreader.c index ced02d454a2..35ed8221aa0 100644 --- a/dlls/winegstreamer/wm_asyncreader.c +++ b/dlls/winegstreamer/wm_asyncreader.c @@ -457,12 +457,14 @@ static HRESULT WINAPI WMReaderAdvanced_SetStreamsSelected(IWMReaderAdvanced6 *if return wm_reader_set_streams_selected(&reader->reader, count, stream_numbers, selections); }
-static HRESULT WINAPI WMReaderAdvanced_GetStreamSelected(IWMReaderAdvanced6 *iface, WORD stream_num, - WMT_STREAM_SELECTION *selection) +static HRESULT WINAPI WMReaderAdvanced_GetStreamSelected(IWMReaderAdvanced6 *iface, + WORD stream_number, WMT_STREAM_SELECTION *selection) { - struct async_reader *This = impl_from_IWMReaderAdvanced6(iface); - FIXME("(%p)->(%d %p)\n", This, stream_num, selection); - return E_NOTIMPL; + struct async_reader *reader = impl_from_IWMReaderAdvanced6(iface); + + TRACE("reader %p, stream_number %u, selection %p.\n", reader, stream_number, selection); + + return wm_reader_get_stream_selection(&reader->reader, stream_number, selection); }
static HRESULT WINAPI WMReaderAdvanced_SetReceiveSelectionCallbacks(IWMReaderAdvanced6 *iface, BOOL get_callbacks)
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/wmvcore/tests/wmvcore.c | 236 ++++++++++++++++++++++++++++++++++- 1 file changed, 234 insertions(+), 2 deletions(-)
diff --git a/dlls/wmvcore/tests/wmvcore.c b/dlls/wmvcore/tests/wmvcore.c index ec66fb1bb74..76586822c84 100644 --- a/dlls/wmvcore/tests/wmvcore.c +++ b/dlls/wmvcore/tests/wmvcore.c @@ -589,6 +589,122 @@ static void test_reader_attributes(IWMProfile *profile) IWMHeaderInfo_Release(header_info); }
+static void test_sync_reader_selection(IWMSyncReader *reader) +{ + WMT_STREAM_SELECTION selections[2]; + WORD stream_numbers[2]; + QWORD pts, duration; + INSSBuffer *sample; + DWORD flags; + HRESULT hr; + + selections[0] = 0xdeadbeef; + hr = IWMSyncReader_GetStreamSelected(reader, 0, &selections[0]); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + ok(selections[0] == 0xdeadbeef, "Got selection %#x.\n", selections[0]); + + selections[0] = 0xdeadbeef; + hr = IWMSyncReader_GetStreamSelected(reader, 1, &selections[0]); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(selections[0] == WMT_ON, "Got selection %#x.\n", selections[0]); + + selections[0] = 0xdeadbeef; + hr = IWMSyncReader_GetStreamSelected(reader, 2, &selections[0]); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(selections[0] == WMT_ON, "Got selection %#x.\n", selections[0]); + + selections[0] = 0xdeadbeef; + hr = IWMSyncReader_GetStreamSelected(reader, 3, &selections[0]); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + ok(selections[0] == 0xdeadbeef, "Got selection %#x.\n", selections[0]); + + hr = IWMSyncReader_SetStreamsSelected(reader, 0, NULL, NULL); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + + stream_numbers[0] = 1; + stream_numbers[1] = 0; + selections[0] = selections[1] = WMT_OFF; + hr = IWMSyncReader_SetStreamsSelected(reader, 2, stream_numbers, selections); + ok(hr == NS_E_INVALID_REQUEST, "Got hr %#x.\n", hr); + + selections[0] = 0xdeadbeef; + hr = IWMSyncReader_GetStreamSelected(reader, 1, &selections[0]); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(selections[0] == WMT_ON, "Got selection %#x.\n", selections[0]); + + stream_numbers[0] = stream_numbers[1] = 1; + selections[0] = selections[1] = WMT_OFF; + hr = IWMSyncReader_SetStreamsSelected(reader, 2, stream_numbers, selections); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + selections[0] = 0xdeadbeef; + hr = IWMSyncReader_GetStreamSelected(reader, 1, &selections[0]); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(selections[0] == WMT_OFF, "Got selection %#x.\n", selections[0]); + + selections[0] = 0xdeadbeef; + hr = IWMSyncReader_GetStreamSelected(reader, 2, &selections[0]); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(selections[0] == WMT_ON, "Got selection %#x.\n", selections[0]); + + hr = IWMSyncReader_GetNextSample(reader, 1, &sample, &pts, &duration, &flags, NULL, NULL); + ok(hr == NS_E_INVALID_REQUEST, "Got hr %#x.\n", hr); + + hr = IWMSyncReader_GetNextSample(reader, 2, &sample, &pts, &duration, &flags, NULL, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + INSSBuffer_Release(sample); + + for (;;) + { + hr = IWMSyncReader_GetNextSample(reader, 2, &sample, &pts, &duration, &flags, NULL, NULL); + if (hr == NS_E_NO_MORE_SAMPLES) + break; + ok(hr == S_OK, "Got hr %#x.\n", hr); + INSSBuffer_Release(sample); + } + + hr = IWMSyncReader_GetNextSample(reader, 1, &sample, &pts, &duration, &flags, NULL, NULL); + ok(hr == NS_E_INVALID_REQUEST, "Got hr %#x.\n", hr); + + hr = IWMSyncReader_SetRange(reader, 0, 0); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IWMSyncReader_GetNextSample(reader, 0, &sample, &pts, &duration, + &flags, NULL, &stream_numbers[0]); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(stream_numbers[0] == 2, "Got stream number %u.\n", stream_numbers[0]); + INSSBuffer_Release(sample); + + for (;;) + { + hr = IWMSyncReader_GetNextSample(reader, 0, &sample, &pts, &duration, + &flags, NULL, &stream_numbers[0]); + if (hr == NS_E_NO_MORE_SAMPLES) + break; + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(stream_numbers[0] == 2, "Got stream number %u.\n", stream_numbers[0]); + INSSBuffer_Release(sample); + } + + stream_numbers[0] = stream_numbers[1] = 2; + selections[0] = selections[1] = WMT_OFF; + hr = IWMSyncReader_SetStreamsSelected(reader, 2, stream_numbers, selections); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IWMSyncReader_SetRange(reader, 0, 0); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IWMSyncReader_GetNextSample(reader, 0, &sample, &pts, &duration, + &flags, NULL, &stream_numbers[0]); + ok(hr == NS_E_NO_MORE_SAMPLES, "Got hr %#x.\n", hr); + + stream_numbers[0] = 1; + stream_numbers[1] = 2; + selections[0] = selections[1] = WMT_ON; + hr = IWMSyncReader_SetStreamsSelected(reader, 2, stream_numbers, selections); + ok(hr == S_OK, "Got hr %#x.\n", hr); +} + static void test_sync_reader_streaming(void) { DWORD size, capacity, flags, output_number, expect_output_number; @@ -792,6 +908,11 @@ static void test_sync_reader_streaming(void) &pts, &duration, &flags, NULL, NULL); ok(hr == NS_E_NO_MORE_SAMPLES, "Got hr %#x.\n", hr);
+ hr = IWMSyncReader_SetRange(reader, 0, 0); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + test_sync_reader_selection(reader); + test_reader_attributes(profile);
hr = IWMSyncReader_Close(reader); @@ -1112,6 +1233,7 @@ struct callback LONG refcount; HANDLE got_opened, got_stopped, eof_event; unsigned int got_closed, got_started, got_sample, got_end_of_streaming, got_eof; + bool all_streams_off; };
static struct callback *impl_from_IWMReaderCallback(IWMReaderCallback *iface) @@ -1196,7 +1318,10 @@ static HRESULT WINAPI callback_OnStatus(IWMReaderCallback *iface, WMT_STATUS sta ok(type == WMT_TYPE_DWORD, "Got type %#x.\n", type); ok(!*(DWORD *)value, "Got value %#x.\n", *(DWORD *)value); ok(context == (void *)0xfacade, "Got unexpected context %p.\n", context); - ok(callback->got_sample > 0, "Got no samples.\n"); + if (callback->all_streams_off) + ok(callback->got_sample == 0, "Got %u samples.\n", callback->got_sample); + else + ok(callback->got_sample > 0, "Got no samples.\n"); ok(callback->got_end_of_streaming == 1, "Got %u WMT_END_OF_STREAMING callbacks.\n", callback->got_end_of_streaming); ++callback->got_eof; @@ -1208,7 +1333,10 @@ static HRESULT WINAPI callback_OnStatus(IWMReaderCallback *iface, WMT_STATUS sta ok(type == WMT_TYPE_QWORD, "Got type %#x.\n", type); ok(*(QWORD *)value == 3000, "Got value %#x.\n", *(DWORD *)value); ok(context == (void *)0xfacade, "Got unexpected context %p.\n", context); - ok(callback->got_sample > 0, "Got no samples.\n"); + if (callback->all_streams_off) + ok(callback->got_sample == 0, "Got %u samples.\n", callback->got_sample); + else + ok(callback->got_sample > 0, "Got no samples.\n"); ok(callback->got_eof == 1, "Got %u WMT_EOF callbacks.\n", callback->got_eof); break;
@@ -1289,6 +1417,109 @@ static void callback_cleanup(struct callback *callback) CloseHandle(callback->eof_event); }
+static void run_async_reader(IWMReader *reader, IWMReaderAdvanced2 *advanced, struct callback *callback) +{ + HRESULT hr; + DWORD ret; + + callback->got_closed = 0; + callback->got_started = 0; + callback->got_sample = 0; + callback->got_end_of_streaming = 0; + callback->got_eof = 0; + + hr = IWMReader_Start(reader, 0, 0, 1.0f, (void *)0xfacade); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IWMReaderAdvanced2_SetUserProvidedClock(advanced, TRUE); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IWMReaderAdvanced2_DeliverTime(advanced, 3000 * 10000); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + ret = WaitForSingleObject(callback->eof_event, 1000); + ok(!ret, "Wait timed out.\n"); + ok(callback->got_eof == 1, "Got %u WMT_EOF callbacks.\n", callback->got_eof); + + hr = IWMReader_Stop(reader); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ret = WaitForSingleObject(callback->got_stopped, 1000); + ok(!ret, "Wait timed out.\n"); +} + +static void test_async_reader_selection(IWMReader *reader, + IWMReaderAdvanced2 *advanced, struct callback *callback) +{ + WMT_STREAM_SELECTION selections[2]; + WORD stream_numbers[2]; + HRESULT hr; + + selections[0] = 0xdeadbeef; + hr = IWMReaderAdvanced2_GetStreamSelected(advanced, 0, &selections[0]); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + ok(selections[0] == 0xdeadbeef, "Got selection %#x.\n", selections[0]); + + selections[0] = 0xdeadbeef; + hr = IWMReaderAdvanced2_GetStreamSelected(advanced, 1, &selections[0]); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(selections[0] == WMT_ON, "Got selection %#x.\n", selections[0]); + + selections[0] = 0xdeadbeef; + hr = IWMReaderAdvanced2_GetStreamSelected(advanced, 2, &selections[0]); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(selections[0] == WMT_ON, "Got selection %#x.\n", selections[0]); + + selections[0] = 0xdeadbeef; + hr = IWMReaderAdvanced2_GetStreamSelected(advanced, 3, &selections[0]); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + ok(selections[0] == 0xdeadbeef, "Got selection %#x.\n", selections[0]); + + hr = IWMReaderAdvanced2_SetStreamsSelected(advanced, 0, NULL, NULL); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + + stream_numbers[0] = 1; + stream_numbers[1] = 0; + selections[0] = selections[1] = WMT_OFF; + hr = IWMReaderAdvanced2_SetStreamsSelected(advanced, 2, stream_numbers, selections); + ok(hr == NS_E_INVALID_REQUEST, "Got hr %#x.\n", hr); + + selections[0] = 0xdeadbeef; + hr = IWMReaderAdvanced2_GetStreamSelected(advanced, 1, &selections[0]); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(selections[0] == WMT_ON, "Got selection %#x.\n", selections[0]); + + stream_numbers[0] = stream_numbers[1] = 1; + selections[0] = selections[1] = WMT_OFF; + hr = IWMReaderAdvanced2_SetStreamsSelected(advanced, 2, stream_numbers, selections); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + selections[0] = 0xdeadbeef; + hr = IWMReaderAdvanced2_GetStreamSelected(advanced, 1, &selections[0]); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(selections[0] == WMT_OFF, "Got selection %#x.\n", selections[0]); + + selections[0] = 0xdeadbeef; + hr = IWMReaderAdvanced2_GetStreamSelected(advanced, 2, &selections[0]); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(selections[0] == WMT_ON, "Got selection %#x.\n", selections[0]); + + run_async_reader(reader, advanced, callback); + + stream_numbers[0] = stream_numbers[1] = 2; + selections[0] = selections[1] = WMT_OFF; + hr = IWMReaderAdvanced2_SetStreamsSelected(advanced, 2, stream_numbers, selections); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + callback->all_streams_off = true; + run_async_reader(reader, advanced, callback); + callback->all_streams_off = false; + + stream_numbers[0] = 1; + stream_numbers[1] = 2; + selections[0] = selections[1] = WMT_ON; + hr = IWMReaderAdvanced2_SetStreamsSelected(advanced, 2, stream_numbers, selections); + ok(hr == S_OK, "Got hr %#x.\n", hr); +} + static void test_async_reader_streaming(void) { const WCHAR *filename = load_resource(L"test.wmv"); @@ -1379,6 +1610,7 @@ static void test_async_reader_streaming(void) ok(!ret, "Wait timed out.\n");
test_reader_attributes(profile); + test_async_reader_selection(reader, advanced, &callback);
hr = IWMReader_Close(reader); ok(hr == S_OK, "Got hr %#x.\n", hr);