Commit eb927dbb authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

mfreadwrite: Handle async reads when flush is in progress.

parent e81d2cf5
......@@ -1658,29 +1658,46 @@ static HRESULT source_reader_read_sample(struct source_reader *reader, DWORD ind
return hr;
}
static HRESULT WINAPI src_reader_ReadSample(IMFSourceReader *iface, DWORD index, DWORD flags, DWORD *actual_index,
DWORD *stream_flags, LONGLONG *timestamp, IMFSample **sample)
static HRESULT source_reader_read_sample_async(struct source_reader *reader, unsigned int index, unsigned int flags,
unsigned int *actual_index, unsigned int *stream_flags, LONGLONG *timestamp, IMFSample **sample)
{
struct source_reader *reader = impl_from_IMFSourceReader(iface);
struct source_reader_async_command *command;
HRESULT hr;
TRACE("%p, %#x, %#x, %p, %p, %p, %p\n", iface, index, flags, actual_index, stream_flags, timestamp, sample);
if (actual_index || stream_flags || timestamp || sample)
return E_INVALIDARG;
if (reader->async_callback)
EnterCriticalSection(&reader->cs);
if (reader->flags & SOURCE_READER_FLUSHING)
hr = MF_E_NOTACCEPTING;
else
{
if (actual_index || stream_flags || timestamp || sample)
return E_INVALIDARG;
if (SUCCEEDED(hr = source_reader_create_async_op(SOURCE_READER_ASYNC_READ, &command)))
{
command->stream_index = index;
command->flags = flags;
if (FAILED(hr = source_reader_create_async_op(SOURCE_READER_ASYNC_READ, &command)))
return hr;
hr = MFPutWorkItem(MFASYNC_CALLBACK_QUEUE_STANDARD, &reader->async_commands_callback, &command->IUnknown_iface);
IUnknown_Release(&command->IUnknown_iface);
}
}
LeaveCriticalSection(&reader->cs);
command->stream_index = index;
command->flags = flags;
return hr;
}
hr = MFPutWorkItem(MFASYNC_CALLBACK_QUEUE_STANDARD, &reader->async_commands_callback, &command->IUnknown_iface);
IUnknown_Release(&command->IUnknown_iface);
}
static HRESULT WINAPI src_reader_ReadSample(IMFSourceReader *iface, DWORD index, DWORD flags, DWORD *actual_index,
DWORD *stream_flags, LONGLONG *timestamp, IMFSample **sample)
{
struct source_reader *reader = impl_from_IMFSourceReader(iface);
HRESULT hr;
TRACE("%p, %#x, %#x, %p, %p, %p, %p\n", iface, index, flags, actual_index, stream_flags, timestamp, sample);
if (reader->async_callback)
hr = source_reader_read_sample_async(reader, index, flags, actual_index, stream_flags, timestamp, sample);
else
hr = source_reader_read_sample(reader, index, flags, actual_index, stream_flags, timestamp, sample);
......
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