[PATCH 6/6] amstream: Implement audio stream sample CompletionStatus.
Anton Baskanov
baskanov at gmail.com
Sat Apr 18 09:34:37 CDT 2020
Signed-off-by: Anton Baskanov <baskanov at gmail.com>
---
dlls/amstream/audiostream.c | 33 +++++--
dlls/amstream/tests/amstream.c | 170 +++++++++++++++++++++++++++++++++
2 files changed, 196 insertions(+), 7 deletions(-)
diff --git a/dlls/amstream/audiostream.c b/dlls/amstream/audiostream.c
index 5176a6cb36..2bd3b00b90 100644
--- a/dlls/amstream/audiostream.c
+++ b/dlls/amstream/audiostream.c
@@ -119,13 +119,7 @@ static HRESULT WINAPI IAudioStreamSampleImpl_SetSampleTimes(IAudioStreamSample *
static HRESULT WINAPI IAudioStreamSampleImpl_Update(IAudioStreamSample *iface, DWORD flags, HANDLE event,
PAPCFUNC func_APC, DWORD APC_data);
-
-static HRESULT WINAPI IAudioStreamSampleImpl_CompletionStatus(IAudioStreamSample *iface, DWORD flags, DWORD milliseconds)
-{
- FIXME("(%p)->(%x,%u): stub\n", iface, flags, milliseconds);
-
- return E_NOTIMPL;
-}
+static HRESULT WINAPI IAudioStreamSampleImpl_CompletionStatus(IAudioStreamSample *iface, DWORD flags, DWORD milliseconds);
/*** IAudioStreamSample methods ***/
static HRESULT WINAPI IAudioStreamSampleImpl_GetAudioData(IAudioStreamSample *iface, IAudioData **audio_data)
@@ -582,6 +576,31 @@ static HRESULT WINAPI IAudioStreamSampleImpl_Update(IAudioStreamSample *iface, D
return sample->update_hr;
}
+static HRESULT WINAPI IAudioStreamSampleImpl_CompletionStatus(IAudioStreamSample *iface, DWORD flags, DWORD milliseconds)
+{
+ IAudioStreamSampleImpl *sample = impl_from_IAudioStreamSample(iface);
+ struct audio_stream *stream;
+ HRESULT hr;
+
+ TRACE("(%p)->(%x,%u)\n", iface, flags, milliseconds);
+
+ stream = impl_from_IAudioMediaStream(sample->parent);
+
+ if (flags)
+ {
+ FIXME("Unsupported flags: %x\n", flags);
+ return E_NOTIMPL;
+ }
+
+ EnterCriticalSection(&stream->cs);
+
+ hr = sample->update_hr;
+
+ LeaveCriticalSection(&stream->cs);
+
+ return hr;
+}
+
/*** IUnknown methods ***/
static HRESULT WINAPI audio_IAudioMediaStream_QueryInterface(IAudioMediaStream *iface,
REFIID riid, void **ret_iface)
diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c
index d5040747b8..fe56b22943 100644
--- a/dlls/amstream/tests/amstream.c
+++ b/dlls/amstream/tests/amstream.c
@@ -3342,6 +3342,175 @@ static void test_audiostreamsample_update(void)
ok(!ref, "Got outstanding refcount %d.\n", ref);
}
+void test_audiostreamsample_completion_status(void)
+{
+ static const WAVEFORMATEX format =
+ {
+ .wFormatTag = WAVE_FORMAT_PCM,
+ .nChannels = 1,
+ .nSamplesPerSec = 11025,
+ .wBitsPerSample = 16,
+ .nBlockAlign = 2,
+ .nAvgBytesPerSec = 2 * 11025,
+ };
+
+ const AM_MEDIA_TYPE mt =
+ {
+ .majortype = MEDIATYPE_Audio,
+ .subtype = MEDIASUBTYPE_PCM,
+ .formattype = FORMAT_WaveFormatEx,
+ .cbFormat = sizeof(WAVEFORMATEX),
+ .pbFormat = (BYTE *)&format,
+ };
+
+ static const BYTE test_data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
+ IAMMultiMediaStream *mmstream = create_ammultimediastream();
+ IAudioStreamSample *stream_sample1;
+ IAudioStreamSample *stream_sample2;
+ IAudioMediaStream *audio_stream;
+ IMediaSample *media_sample;
+ struct testfilter source;
+ IAudioData *audio_data1;
+ IAudioData *audio_data2;
+ IGraphBuilder *graph;
+ IMediaStream *stream;
+ HANDLE event;
+ HRESULT hr;
+ ULONG ref;
+ IPin *pin;
+
+ event = CreateEventW(NULL, FALSE, FALSE, NULL);
+ ok(event != NULL, "Expected non-NULL event.");
+
+ 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 = IMediaStream_QueryInterface(stream, &IID_IPin, (void **)&pin);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = IAMMultiMediaStream_GetFilterGraph(mmstream, &graph);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(graph != NULL, "Expected non-null graph\n");
+ testfilter_init(&source);
+ hr = IGraphBuilder_AddFilter(graph, &source.filter.IBaseFilter_iface, NULL);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = CoCreateInstance(&CLSID_AMAudioData, NULL, CLSCTX_INPROC_SERVER, &IID_IAudioData, (void **)&audio_data1);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = CoCreateInstance(&CLSID_AMAudioData, NULL, CLSCTX_INPROC_SERVER, &IID_IAudioData, (void **)&audio_data2);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = IAudioData_SetBuffer(audio_data1, 6, NULL, 0);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = IAudioData_SetBuffer(audio_data2, 6, NULL, 0);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = IAudioMediaStream_CreateSample(audio_stream, audio_data1, 0, &stream_sample1);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = IAudioMediaStream_CreateSample(audio_stream, audio_data2, 0, &stream_sample2);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IGraphBuilder_ConnectDirect(graph, &source.source.pin.IPin_iface, pin, &mt);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_RUN);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IAudioStreamSample_CompletionStatus(stream_sample1, 0, 0);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IAudioStreamSample_Update(stream_sample1, SSUPDATE_ASYNC, NULL, NULL, 0);
+ ok(hr == MS_S_PENDING, "Got hr %#x.\n", hr);
+
+ hr = IAudioStreamSample_CompletionStatus(stream_sample1, 0, 0);
+ ok(hr == MS_S_PENDING, "Got hr %#x.\n", hr);
+
+ media_sample = audiostream_allocate_sample(&source, test_data, 6);
+ hr = IMemInputPin_Receive(source.source.pMemInputPin, media_sample);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ref = IMediaSample_Release(media_sample);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+
+ hr = IAudioStreamSample_CompletionStatus(stream_sample1, 0, 0);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IAudioStreamSample_Update(stream_sample1, SSUPDATE_ASYNC, NULL, NULL, 0);
+ ok(hr == MS_S_PENDING, "Got hr %#x.\n", hr);
+
+ hr = IAudioStreamSample_Update(stream_sample2, SSUPDATE_ASYNC, NULL, NULL, 0);
+ ok(hr == MS_S_PENDING, "Got hr %#x.\n", hr);
+
+ media_sample = audiostream_allocate_sample(&source, test_data, 12);
+ hr = IMemInputPin_Receive(source.source.pMemInputPin, media_sample);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ref = IMediaSample_Release(media_sample);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+
+ hr = IAudioStreamSample_CompletionStatus(stream_sample1, 0, 0);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IAudioStreamSample_CompletionStatus(stream_sample2, 0, 0);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IAudioStreamSample_Update(stream_sample1, SSUPDATE_ASYNC, NULL, NULL, 0);
+ ok(hr == MS_S_PENDING, "Got hr %#x.\n", hr);
+
+ hr = IPin_EndOfStream(pin);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IAudioStreamSample_CompletionStatus(stream_sample1, 0, 0);
+ ok(hr == MS_S_ENDOFSTREAM, "Got hr %#x.\n", hr);
+
+ hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_STOP);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_RUN);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IAudioStreamSample_Update(stream_sample1, SSUPDATE_ASYNC, NULL, NULL, 0);
+ ok(hr == MS_S_PENDING, "Got hr %#x.\n", hr);
+
+ hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_STOP);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IAudioStreamSample_CompletionStatus(stream_sample1, 0, 0);
+ ok(hr == MS_S_PENDING, "Got hr %#x.\n", hr);
+
+ hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_RUN);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ media_sample = audiostream_allocate_sample(&source, test_data, 6);
+ hr = IMemInputPin_Receive(source.source.pMemInputPin, media_sample);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ref = IMediaSample_Release(media_sample);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+
+ hr = IAudioStreamSample_CompletionStatus(stream_sample1, 0, 0);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_STOP);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ IGraphBuilder_Disconnect(graph, pin);
+ IGraphBuilder_Disconnect(graph, &source.source.pin.IPin_iface);
+
+ ref = IAudioStreamSample_Release(stream_sample1);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+ ref = IAudioStreamSample_Release(stream_sample2);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+ ref = IAudioData_Release(audio_data1);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+ ref = IAudioData_Release(audio_data2);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+ ref = IAMMultiMediaStream_Release(mmstream);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+ ref = IGraphBuilder_Release(graph);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+ IPin_Release(pin);
+ IAudioMediaStream_Release(audio_stream);
+ ref = IMediaStream_Release(stream);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+
+ CloseHandle(event);
+}
+
void test_mediastreamfilter_get_state(void)
{
IAMMultiMediaStream *mmstream = create_ammultimediastream();
@@ -3518,6 +3687,7 @@ START_TEST(amstream)
test_audiostream_receive();
test_audiostreamsample_update();
+ test_audiostreamsample_completion_status();
test_mediastreamfilter_get_state();
test_mediastreamfilter_stop_pause_run();
--
2.17.1
More information about the wine-devel
mailing list