Commit fdf43b9b authored by Anton Baskanov's avatar Anton Baskanov Committed by Alexandre Julliard

amstream: Implement AMDirectDrawStream::EndOfStream.

parent 999b59b7
......@@ -58,6 +58,7 @@ struct ddraw_stream
AM_MEDIA_TYPE mt;
struct format format;
FILTER_STATE state;
BOOL eos;
};
static HRESULT ddrawstreamsample_create(struct ddraw_stream *parent, IDirectDrawSurface *surface,
......@@ -267,6 +268,9 @@ static HRESULT WINAPI ddraw_IAMMediaStream_SetState(IAMMediaStream *iface, FILTE
EnterCriticalSection(&stream->cs);
if (stream->state == State_Stopped)
stream->eos = FALSE;
stream->state = state;
LeaveCriticalSection(&stream->cs);
......@@ -1061,8 +1065,23 @@ static HRESULT WINAPI ddraw_sink_QueryInternalConnections(IPin *iface, IPin **pi
static HRESULT WINAPI ddraw_sink_EndOfStream(IPin *iface)
{
FIXME("iface %p, stub!\n", iface);
return E_NOTIMPL;
struct ddraw_stream *stream = impl_from_IPin(iface);
TRACE("stream %p.\n", stream);
EnterCriticalSection(&stream->cs);
if (stream->eos)
{
LeaveCriticalSection(&stream->cs);
return E_FAIL;
}
stream->eos = TRUE;
LeaveCriticalSection(&stream->cs);
return S_OK;
}
static HRESULT WINAPI ddraw_sink_BeginFlush(IPin *iface)
......
......@@ -3613,65 +3613,6 @@ static void test_ddrawstream_receive_connection(void)
ok(!ref, "Got outstanding refcount %d.\n", ref);
}
void test_audiostream_end_of_stream(void)
{
IAMMultiMediaStream *mmstream = create_ammultimediastream();
struct testfilter source;
IGraphBuilder *graph;
IMediaStream *stream;
HRESULT hr;
ULONG ref;
IPin *pin;
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_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, "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 = IGraphBuilder_ConnectDirect(graph, &source.source.pin.IPin_iface, pin, &audio_mt);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IPin_EndOfStream(pin);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IPin_EndOfStream(pin);
ok(hr == E_FAIL, "Got hr %#x.\n", hr);
hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_RUN);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IPin_EndOfStream(pin);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IPin_EndOfStream(pin);
ok(hr == E_FAIL, "Got hr %#x.\n", hr);
hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_STOP);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IPin_EndOfStream(pin);
ok(hr == E_FAIL, "Got hr %#x.\n", hr);
IGraphBuilder_Disconnect(graph, pin);
IGraphBuilder_Disconnect(graph, &source.source.pin.IPin_iface);
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);
ref = IMediaStream_Release(stream);
ok(!ref, "Got outstanding refcount %d.\n", ref);
}
static void test_audiostream_receive(void)
{
ALLOCATOR_PROPERTIES properties =
......@@ -5364,6 +5305,71 @@ static void test_ammediastream_set_state(void)
check_ammediastream_set_state(&MSPID_PrimaryVideo);
}
static void check_ammediastream_end_of_stream(const MSPID *id, const AM_MEDIA_TYPE *mt)
{
IAMMultiMediaStream *mmstream = create_ammultimediastream();
struct testfilter source;
IGraphBuilder *graph;
IMediaStream *stream;
HRESULT hr;
ULONG ref;
IPin *pin;
hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, id, 0, &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, "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 = IGraphBuilder_ConnectDirect(graph, &source.source.pin.IPin_iface, pin, mt);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IPin_EndOfStream(pin);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IPin_EndOfStream(pin);
ok(hr == E_FAIL, "Got hr %#x.\n", hr);
hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_RUN);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IPin_EndOfStream(pin);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IPin_EndOfStream(pin);
ok(hr == E_FAIL, "Got hr %#x.\n", hr);
hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_STOP);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IPin_EndOfStream(pin);
ok(hr == E_FAIL, "Got hr %#x.\n", hr);
IGraphBuilder_Disconnect(graph, pin);
IGraphBuilder_Disconnect(graph, &source.source.pin.IPin_iface);
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);
ref = IMediaStream_Release(stream);
ok(!ref, "Got outstanding refcount %d.\n", ref);
}
static void test_ammediastream_end_of_stream(void)
{
check_ammediastream_end_of_stream(&MSPID_PrimaryAudio, &audio_mt);
check_ammediastream_end_of_stream(&MSPID_PrimaryVideo, &rgb32_mt);
}
void test_mediastreamfilter_get_state(void)
{
IAMMultiMediaStream *mmstream = create_ammultimediastream();
......@@ -6793,7 +6799,6 @@ START_TEST(amstream)
test_audiostream_get_format();
test_audiostream_set_format();
test_audiostream_receive_connection();
test_audiostream_end_of_stream();
test_audiostream_receive();
test_audiostream_initialize();
test_audiostream_begin_flush_end_flush();
......@@ -6818,6 +6823,7 @@ START_TEST(amstream)
test_ammediastream_join_filter();
test_ammediastream_join_filter_graph();
test_ammediastream_set_state();
test_ammediastream_end_of_stream();
test_mediastreamfilter_get_state();
test_mediastreamfilter_stop_pause_run();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment