Commit 9d7f98ee authored by Derek Lesho's avatar Derek Lesho Committed by Alexandre Julliard

mfreadwrite: Abort ReadSample when unable to request any samples.

parent ef81152c
......@@ -439,7 +439,8 @@ static HRESULT source_reader_new_stream_handler(struct source_reader *reader, IM
}
if (reader->streams[i].requests)
source_reader_request_sample(reader, &reader->streams[i]);
if (FAILED(source_reader_request_sample(reader, &reader->streams[i])))
WakeAllConditionVariable(&reader->sample_event);
}
break;
}
......@@ -1780,10 +1781,16 @@ static HRESULT source_reader_read_sample(struct source_reader *reader, DWORD ind
stream->requests++;
if (FAILED(hr = source_reader_request_sample(reader, stream)))
WARN("Failed to request a sample, hr %#x.\n", hr);
if (stream->stream && !(stream->flags & STREAM_FLAG_SAMPLE_REQUESTED))
{
*stream_flags = MF_SOURCE_READERF_ERROR;
*timestamp = 0;
break;
}
SleepConditionVariableCS(&reader->sample_event, &reader->cs, INFINITE);
}
source_reader_get_read_result(reader, stream, flags, &hr, actual_index, stream_flags,
if (SUCCEEDED(hr))
source_reader_get_read_result(reader, stream, flags, &hr, actual_index, stream_flags,
timestamp, sample);
}
}
......
......@@ -158,6 +158,8 @@ static HRESULT WINAPI test_media_stream_GetStreamDescriptor(IMFMediaStream *ifac
return S_OK;
}
static BOOL fail_request_sample;
static HRESULT WINAPI test_media_stream_RequestSample(IMFMediaStream *iface, IUnknown *token)
{
struct test_media_stream *stream = impl_from_IMFMediaStream(iface);
......@@ -165,6 +167,9 @@ static HRESULT WINAPI test_media_stream_RequestSample(IMFMediaStream *iface, IUn
IMFSample *sample;
HRESULT hr;
if (fail_request_sample)
return E_NOTIMPL;
hr = MFCreateSample(&sample);
ok(hr == S_OK, "Failed to create a sample, hr %#x.\n", hr);
hr = IMFSample_SetSampleTime(sample, 123);
......@@ -977,6 +982,27 @@ static void test_source_reader_from_media_source(void)
ok(hr == MF_E_NOTACCEPTING, "Unexpected hr %#x.\n", hr);
IMFSourceReader_Release(reader);
IMFMediaSource_Release(source);
/* RequestSample failure. */
source = create_test_source();
ok(!!source, "Failed to create test source.\n");
fail_request_sample = TRUE;
hr = MFCreateSourceReaderFromMediaSource(source, NULL, &reader);
ok(hr == S_OK, "Failed to create source reader, hr %#x.\n", hr);
hr = IMFSourceReader_SetStreamSelection(reader, 0, TRUE);
ok(hr == S_OK, "Failed to select a stream, hr %#x.\n", hr);
hr = IMFSourceReader_ReadSample(reader, 0, 0, &actual_index, &stream_flags, &timestamp, &sample);
ok(hr == E_NOTIMPL, "Unexpected ReadSample result, hr %#x.\n", hr);
IMFSourceReader_Release(reader);
IMFMediaSource_Release(source);
fail_request_sample = FALSE;
}
START_TEST(mfplat)
......
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