Signed-off-by: Anton Baskanov baskanov@gmail.com --- dlls/amstream/audiostream.c | 16 +++++++++++--- dlls/amstream/tests/amstream.c | 39 ++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 3 deletions(-)
diff --git a/dlls/amstream/audiostream.c b/dlls/amstream/audiostream.c index 2379a59350..efa3e2aac5 100644 --- a/dlls/amstream/audiostream.c +++ b/dlls/amstream/audiostream.c @@ -505,11 +505,21 @@ static HRESULT WINAPI audio_IAMMediaStream_SendEndOfStream(IAMMediaStream *iface static HRESULT WINAPI audio_IAMMediaStream_Initialize(IAMMediaStream *iface, IUnknown *source_object, DWORD flags, REFMSPID purpose_id, const STREAM_TYPE stream_type) { - struct audio_stream *This = impl_from_IAMMediaStream(iface); + struct audio_stream *stream = impl_from_IAMMediaStream(iface);
- 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; + + return S_OK; }
static HRESULT WINAPI audio_IAMMediaStream_SetState(IAMMediaStream *iface, FILTER_STATE state) diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 073e372c94..e233337e6f 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -3046,6 +3046,44 @@ static void test_audiostream_receive(void) ok(!ref, "Got outstanding refcount %d.\n", ref); }
+static void test_audiostream_initialize(void) +{ + IAMMediaStream *stream; + STREAM_TYPE type; + MSPID mspid; + HRESULT hr; + ULONG ref; + + hr = CoCreateInstance(&CLSID_AMAudioStream, NULL, CLSCTX_INPROC_SERVER, &IID_IAMMediaStream, (void **)&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, NULL, 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); + + ref = IAMMediaStream_Release(stream); + ok(!ref, "Got outstanding refcount %d.\n", ref); +} + static void CALLBACK apc_func(ULONG_PTR param) { } @@ -3681,6 +3719,7 @@ START_TEST(amstream) test_audiostream_set_state(); test_audiostream_end_of_stream(); test_audiostream_receive(); + test_audiostream_initialize();
test_audiostreamsample_update(); test_audiostreamsample_completion_status();