amstream: Implement IAudioStreamSample::CompletionStatus().

Signed-off-by: Anton Baskanov <baskanov@gmail.com>
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Anton Baskanov 2020-04-22 15:16:16 -05:00 committed by Alexandre Julliard
parent bdf5188d16
commit 0884111fec
2 changed files with 187 additions and 2 deletions

View File

@ -295,11 +295,26 @@ static HRESULT WINAPI IAudioStreamSampleImpl_Update(IAudioStreamSample *iface,
static HRESULT WINAPI IAudioStreamSampleImpl_CompletionStatus(IAudioStreamSample *iface, DWORD flags, DWORD milliseconds)
{
FIXME("(%p)->(%x,%u): stub\n", iface, flags, milliseconds);
IAudioStreamSampleImpl *sample = impl_from_IAudioStreamSample(iface);
HRESULT hr;
TRACE("sample %p, flags %#x, milliseconds %u.\n", sample, flags, milliseconds);
if (flags)
{
FIXME("Unhandled flags %#x.\n", flags);
return E_NOTIMPL;
}
EnterCriticalSection(&sample->parent->cs);
hr = sample->update_hr;
LeaveCriticalSection(&sample->parent->cs);
return hr;
}
/*** IAudioStreamSample methods ***/
static HRESULT WINAPI IAudioStreamSampleImpl_GetAudioData(IAudioStreamSample *iface, IAudioData **audio_data)
{

View File

@ -3345,6 +3345,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();
@ -3521,6 +3690,7 @@ START_TEST(amstream)
test_audiostream_receive();
test_audiostreamsample_update();
test_audiostreamsample_completion_status();
test_mediastreamfilter_get_state();
test_mediastreamfilter_stop_pause_run();