[PATCH 5/6] amstream: Implement IAudioStreamSample::GetAudioData().

Gijs Vermeulen gijsvrm at gmail.com
Wed Jul 29 05:30:36 CDT 2020


Signed-off-by: Gijs Vermeulen <gijsvrm at gmail.com>
---
 dlls/amstream/audiostream.c    | 12 +++++++--
 dlls/amstream/tests/amstream.c | 48 ++++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+), 2 deletions(-)

diff --git a/dlls/amstream/audiostream.c b/dlls/amstream/audiostream.c
index 72bfd1c3a7..3610cd0353 100644
--- a/dlls/amstream/audiostream.c
+++ b/dlls/amstream/audiostream.c
@@ -351,9 +351,17 @@ static HRESULT WINAPI IAudioStreamSampleImpl_CompletionStatus(IAudioStreamSample
 /*** IAudioStreamSample methods ***/
 static HRESULT WINAPI IAudioStreamSampleImpl_GetAudioData(IAudioStreamSample *iface, IAudioData **audio_data)
 {
-    FIXME("(%p)->(%p): stub\n", iface, audio_data);
+    IAudioStreamSampleImpl *sample = impl_from_IAudioStreamSample(iface);
 
-    return E_NOTIMPL;
+    TRACE("sample %p, audio_data %p.\n", sample, audio_data);
+
+    if (!audio_data)
+        return E_POINTER;
+
+    IAudioData_AddRef(sample->audio_data);
+    *audio_data = sample->audio_data;
+
+    return S_OK;
 }
 
 static const struct IAudioStreamSampleVtbl AudioStreamSample_Vtbl =
diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c
index ddebd10c0a..595abbb0f9 100644
--- a/dlls/amstream/tests/amstream.c
+++ b/dlls/amstream/tests/amstream.c
@@ -5338,6 +5338,53 @@ static void test_audiostreamsample_get_media_stream(void)
     ok(!ref, "Got outstanding refcount %d.\n", ref);
 }
 
+static void test_audiostreamsample_get_audio_data(void)
+{
+    IAMMultiMediaStream *mmstream = create_ammultimediastream();
+    IAudioData *audio_data, *audio_data2;
+    IAudioStreamSample *audio_sample;
+    IAudioMediaStream *audio_stream;
+    IMediaStream *stream;
+    HRESULT hr;
+    ULONG ref;
+
+    hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL);
+    ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+    hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryAudio, 0, &stream);
+    ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+    hr = IMediaStream_QueryInterface(stream, &IID_IAudioMediaStream, (void **)&audio_stream);
+    ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+    hr = CoCreateInstance(&CLSID_AMAudioData, NULL, CLSCTX_INPROC_SERVER, &IID_IAudioData, (void **)&audio_data);
+    ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+    hr = IAudioMediaStream_CreateSample(audio_stream, audio_data, 0, &audio_sample);
+    ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+    hr = IAudioStreamSample_GetAudioData(audio_sample, NULL);
+    ok(hr == E_POINTER, "Got hr %#x.\n", hr);
+
+    EXPECT_REF(audio_data, 2);
+    hr = IAudioStreamSample_GetAudioData(audio_sample, &audio_data2);
+    ok(hr == S_OK, "Got hr %#x.\n", hr);
+    ok(audio_data2 == audio_data, "Expected audio data %p, got %p.\n", audio_data, audio_data2);
+    EXPECT_REF(audio_data, 3);
+
+    IAudioData_Release(audio_data2);
+
+    IAudioMediaStream_Release(audio_stream);
+    ref = IAudioStreamSample_Release(audio_sample);
+    ok(!ref, "Got outstanding refcount %d.\n", ref);
+    ref = IAudioData_Release(audio_data);
+    ok(!ref, "Got outstanding refcount %d.\n", ref);
+    ref = IAMMultiMediaStream_Release(mmstream);
+    ok(!ref, "Got outstanding refcount %d.\n", ref);
+    ref = IMediaStream_Release(stream);
+    ok(!ref, "Got outstanding refcount %d.\n", ref);
+}
+
 START_TEST(amstream)
 {
     const WCHAR *test_avi_path;
@@ -5384,6 +5431,7 @@ START_TEST(amstream)
     test_audiostreamsample_completion_status();
     test_audiostreamsample_get_sample_times();
     test_audiostreamsample_get_media_stream();
+    test_audiostreamsample_get_audio_data();
 
     test_ddrawstream_initialize();
     test_ddrawstream_getsetdirectdraw();
-- 
2.27.0




More information about the wine-devel mailing list