Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com --- dlls/amstream/multimedia.c | 7 ++++++- dlls/amstream/tests/amstream.c | 8 ++++---- 2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/dlls/amstream/multimedia.c b/dlls/amstream/multimedia.c index e058e639dd..56512d19da 100644 --- a/dlls/amstream/multimedia.c +++ b/dlls/amstream/multimedia.c @@ -91,7 +91,11 @@ static ULONG WINAPI multimedia_stream_Release(IAMMultiMediaStream *iface) { if (This->ipin) IPin_Release(This->ipin); - IMediaStreamFilter_Release(This->filter); + if (This->filter) + { + IMediaStreamFilter_Release(This->filter); + IMediaStreamFilter_Release(This->filter); + } if (This->media_seeking) IMediaSeeking_Release(This->media_seeking); if (This->media_control) @@ -519,6 +523,7 @@ HRESULT multimedia_stream_create(IUnknown *outer, void **out) }
TRACE("Created multimedia stream %p.\n", object); + IMediaStreamFilter_AddRef(object->filter); *out = &object->IAMMultiMediaStream_iface;
return S_OK; diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 3fb77f277a..7ebd54f6da 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -1140,7 +1140,7 @@ static void test_enum_pins(void) ok(hr == S_OK, "Got hr %#x.\n", hr);
ref = get_refcount(filter); - todo_wine ok(ref == 3, "Got unexpected refcount %d.\n", ref); + ok(ref == 3, "Got unexpected refcount %d.\n", ref);
hr = IMediaStreamFilter_EnumPins(filter, NULL); ok(hr == E_POINTER, "Got hr %#x.\n", hr); @@ -1148,7 +1148,7 @@ static void test_enum_pins(void) hr = IMediaStreamFilter_EnumPins(filter, &enum1); ok(hr == S_OK, "Got hr %#x.\n", hr); ref = get_refcount(filter); - todo_wine ok(ref == 3, "Got unexpected refcount %d.\n", ref); + ok(ref == 3, "Got unexpected refcount %d.\n", ref); ref = get_refcount(enum1); ok(ref == 1, "Got unexpected refcount %d.\n", ref);
@@ -1186,7 +1186,7 @@ static void test_enum_pins(void) ok(hr == S_OK, "Got hr %#x.\n", hr);
ref = get_refcount(filter); - todo_wine ok(ref == 4, "Got unexpected refcount %d.\n", ref); + ok(ref == 4, "Got unexpected refcount %d.\n", ref); ref = get_refcount(enum1); ok(ref == 1, "Got unexpected refcount %d.\n", ref); ref = get_refcount(pin); @@ -1196,7 +1196,7 @@ static void test_enum_pins(void) ok(hr == S_OK, "Got hr %#x.\n", hr); ok(pins[0] == pin, "Expected pin %p, got %p.\n", pin, pins[0]); ref = get_refcount(filter); - todo_wine ok(ref == 4, "Got unexpected refcount %d.\n", ref); + ok(ref == 4, "Got unexpected refcount %d.\n", ref); ref = get_refcount(enum1); ok(ref == 1, "Got unexpected refcount %d.\n", ref); ref = get_refcount(pin);
Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com --- dlls/amstream/tests/amstream.c | 62 ++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+)
diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 7ebd54f6da..608bb2267f 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -4262,6 +4262,67 @@ static void test_ammediastream_join_am_multi_media_stream(void) check_ammediastream_join_am_multi_media_stream(&CLSID_AMDirectDrawStream); }
+static void check_ammediastream_join_filter(const CLSID *clsid) +{ + IAMMultiMediaStream *mmstream = create_ammultimediastream(); + IMediaStreamFilter *filter, *filter2, *filter3; + IAMMediaStream *stream; + HRESULT hr; + ULONG ref; + + hr = IAMMultiMediaStream_GetFilter(mmstream, &filter); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(!!filter, "Expected non-null filter.\n"); + EXPECT_REF(filter, 3); + + hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IAMMediaStream, (void **)&stream); + ok(hr == S_OK, "Got hr %#x.\n", hr); + EXPECT_REF(filter, 3); + + hr = CoCreateInstance(&CLSID_MediaStreamFilter, NULL, CLSCTX_INPROC_SERVER, + &IID_IMediaStreamFilter, (void **)&filter2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + EXPECT_REF(filter, 3); + EXPECT_REF(filter2, 1); + + hr = IAMMediaStream_JoinFilter(stream, filter2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + EXPECT_REF(filter, 3); + EXPECT_REF(filter2, 1); + + /* Crashes on native. */ + if (0) + { + hr = IAMMediaStream_JoinFilter(stream, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + } + + hr = IAMMultiMediaStream_GetFilter(mmstream, &filter3); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(filter3 == filter, "Expected filter %p, got %p.\n", filter, filter3); + EXPECT_REF(filter, 4); + + IMediaStreamFilter_Release(filter3); + EXPECT_REF(filter, 3); + + ref = IMediaStreamFilter_Release(filter2); + ok(!ref, "Got outstanding refcount %d.\n", ref); + ref = IAMMediaStream_Release(stream); + ok(!ref, "Got outstanding refcount %d.\n", ref); + EXPECT_REF(filter, 3); + ref = IAMMultiMediaStream_Release(mmstream); + ok(!ref, "Got outstanding refcount %d.\n", ref); + EXPECT_REF(filter, 1); + ref = IMediaStreamFilter_Release(filter); + ok(!ref, "Got outstanding refcount %d.\n", ref); +} + +static void test_ammediastream_join_filter(void) +{ + check_ammediastream_join_filter(&CLSID_AMAudioStream); + check_ammediastream_join_filter(&CLSID_AMDirectDrawStream); +} + void test_mediastreamfilter_get_state(void) { IAMMultiMediaStream *mmstream = create_ammultimediastream(); @@ -4956,6 +5017,7 @@ START_TEST(amstream) test_ddrawstream_getsetdirectdraw();
test_ammediastream_join_am_multi_media_stream(); + test_ammediastream_join_filter();
test_mediastreamfilter_get_state(); test_mediastreamfilter_stop_pause_run();
On 7/4/20 5:30 AM, Gijs Vermeulen wrote:
Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com
dlls/amstream/multimedia.c | 7 ++++++- dlls/amstream/tests/amstream.c | 8 ++++---- 2 files changed, 10 insertions(+), 5 deletions(-)
I think this behaviour is weird enough to deserve a comment in the code.
diff --git a/dlls/amstream/multimedia.c b/dlls/amstream/multimedia.c index e058e639dd..56512d19da 100644 --- a/dlls/amstream/multimedia.c +++ b/dlls/amstream/multimedia.c @@ -91,7 +91,11 @@ static ULONG WINAPI multimedia_stream_Release(IAMMultiMediaStream *iface) { if (This->ipin) IPin_Release(This->ipin);
IMediaStreamFilter_Release(This->filter);
if (This->filter)
{
IMediaStreamFilter_Release(This->filter);
IMediaStreamFilter_Release(This->filter);
}
You shouldn't have to check for the validity of This->filter; it's created along with the object.
if (This->media_seeking) IMediaSeeking_Release(This->media_seeking); if (This->media_control)
@@ -519,6 +523,7 @@ HRESULT multimedia_stream_create(IUnknown *outer, void **out) }
TRACE("Created multimedia stream %p.\n", object);
IMediaStreamFilter_AddRef(object->filter); *out = &object->IAMMultiMediaStream_iface;
return S_OK;
diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 3fb77f277a..7ebd54f6da 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -1140,7 +1140,7 @@ static void test_enum_pins(void) ok(hr == S_OK, "Got hr %#x.\n", hr);
ref = get_refcount(filter);
- todo_wine ok(ref == 3, "Got unexpected refcount %d.\n", ref);
ok(ref == 3, "Got unexpected refcount %d.\n", ref);
hr = IMediaStreamFilter_EnumPins(filter, NULL); ok(hr == E_POINTER, "Got hr %#x.\n", hr);
@@ -1148,7 +1148,7 @@ static void test_enum_pins(void) hr = IMediaStreamFilter_EnumPins(filter, &enum1); ok(hr == S_OK, "Got hr %#x.\n", hr); ref = get_refcount(filter);
- todo_wine ok(ref == 3, "Got unexpected refcount %d.\n", ref);
- ok(ref == 3, "Got unexpected refcount %d.\n", ref); ref = get_refcount(enum1); ok(ref == 1, "Got unexpected refcount %d.\n", ref);
@@ -1186,7 +1186,7 @@ static void test_enum_pins(void) ok(hr == S_OK, "Got hr %#x.\n", hr);
ref = get_refcount(filter);
- todo_wine ok(ref == 4, "Got unexpected refcount %d.\n", ref);
- ok(ref == 4, "Got unexpected refcount %d.\n", ref); ref = get_refcount(enum1); ok(ref == 1, "Got unexpected refcount %d.\n", ref); ref = get_refcount(pin);
@@ -1196,7 +1196,7 @@ static void test_enum_pins(void) ok(hr == S_OK, "Got hr %#x.\n", hr); ok(pins[0] == pin, "Expected pin %p, got %p.\n", pin, pins[0]); ref = get_refcount(filter);
- todo_wine ok(ref == 4, "Got unexpected refcount %d.\n", ref);
- ok(ref == 4, "Got unexpected refcount %d.\n", ref); ref = get_refcount(enum1); ok(ref == 1, "Got unexpected refcount %d.\n", ref); ref = get_refcount(pin);