Signed-off-by: Anton Baskanov baskanov@gmail.com --- dlls/amstream/ddrawstream.c | 21 +++++++++++-- dlls/amstream/tests/amstream.c | 57 ++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 3 deletions(-)
diff --git a/dlls/amstream/ddrawstream.c b/dlls/amstream/ddrawstream.c index 2b0c871d58..3bd5f46e02 100644 --- a/dlls/amstream/ddrawstream.c +++ b/dlls/amstream/ddrawstream.c @@ -198,11 +198,26 @@ static HRESULT WINAPI ddraw_IAMMediaStream_SendEndOfStream(IAMMediaStream *iface static HRESULT WINAPI ddraw_IAMMediaStream_Initialize(IAMMediaStream *iface, IUnknown *source_object, DWORD flags, REFMSPID purpose_id, const STREAM_TYPE stream_type) { - struct ddraw_stream *This = impl_from_IAMMediaStream(iface); + struct ddraw_stream *stream = impl_from_IAMMediaStream(iface); + HRESULT hr;
- FIXME("(%p/%p)->(%p,%x,%p,%u) stub!\n", This, iface, source_object, flags, purpose_id, stream_type); + TRACE("stream %p, source_object %p, flags %x, purpose_id %s, stream_type %u.\n", stream, source_object, flags, + debugstr_guid(purpose_id), stream_type);
- return S_FALSE; + if (!purpose_id) + return E_POINTER; + + if (flags & AMMSF_CREATEPEER) + FIXME("AMMSF_CREATEPEER is not yet supported.\n"); + + stream->purpose_id = *purpose_id; + stream->stream_type = stream_type; + + if (source_object + && FAILED(hr = IUnknown_QueryInterface(source_object, &IID_IDirectDraw7, (void **)&stream->ddraw))) + FIXME("Stream object doesn't implement IDirectDraw7 interface, hr %#x.\n", hr); + + return S_OK; }
static HRESULT WINAPI ddraw_IAMMediaStream_SetState(IAMMediaStream *iface, FILTER_STATE state) diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index e233337e6f..f6e9b0d992 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -3545,6 +3545,61 @@ void test_audiostreamsample_completion_status(void) CloseHandle(event); }
+static void test_ddrawstream_initialize(void) +{ + IDirectDrawMediaStream *ddraw_stream; + IAMMediaStream *stream; + IDirectDraw *ddraw2; + IDirectDraw *ddraw; + STREAM_TYPE type; + MSPID mspid; + HRESULT hr; + ULONG ref; + + hr = DirectDrawCreate(NULL, &ddraw, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = CoCreateInstance(&CLSID_AMDirectDrawStream, NULL, CLSCTX_INPROC_SERVER, &IID_IAMMediaStream, (void **)&stream); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IAMMediaStream_QueryInterface(stream, &IID_IDirectDrawMediaStream, (void **)&ddraw_stream); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + /* Crashes on native. */ + if (0) + { + hr = IAMMediaStream_Initialize(stream, NULL, 0, NULL, STREAMTYPE_WRITE); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + } + + hr = IAMMediaStream_Initialize(stream, NULL, 0, &test_mspid, STREAMTYPE_WRITE); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IAMMediaStream_GetInformation(stream, &mspid, &type); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(IsEqualGUID(&mspid, &test_mspid), "Got mspid %s.\n", wine_dbgstr_guid(&mspid)); + ok(type == STREAMTYPE_WRITE, "Got type %u.\n", type); + + hr = IAMMediaStream_Initialize(stream, (IUnknown *)ddraw, 0, &MSPID_PrimaryAudio, STREAMTYPE_READ); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IAMMediaStream_GetInformation(stream, &mspid, &type); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(IsEqualGUID(&mspid, &MSPID_PrimaryAudio), "Got mspid %s.\n", wine_dbgstr_guid(&mspid)); + ok(type == STREAMTYPE_READ, "Got type %u.\n", type); + + hr = IDirectDrawMediaStream_GetDirectDraw(ddraw_stream, &ddraw2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(ddraw2 == ddraw, "Expected ddraw %p, got %p.\n", ddraw, ddraw2); + + IDirectDrawMediaStream_Release(ddraw_stream); + ref = IAMMediaStream_Release(stream); + ok(!ref, "Got outstanding refcount %d.\n", ref); + IDirectDraw_Release(ddraw2); + ref = IDirectDraw_Release(ddraw); + ok(!ref, "Got outstanding refcount %d.\n", ref); +} + void test_mediastreamfilter_get_state(void) { IAMMultiMediaStream *mmstream = create_ammultimediastream(); @@ -3724,6 +3779,8 @@ START_TEST(amstream) test_audiostreamsample_update(); test_audiostreamsample_completion_status();
+ test_ddrawstream_initialize(); + test_mediastreamfilter_get_state(); test_mediastreamfilter_stop_pause_run();