Commit 488c9c66 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

winegstreamer: Move IWMReaderCallbackAdvanced *callback_advanced to a local variable.

parent 4a433122
......@@ -181,8 +181,6 @@ struct wm_reader
struct wm_stream *streams;
WORD stream_count;
IWMReaderCallbackAdvanced *callback_advanced;
const struct wm_reader_ops *ops;
};
......@@ -202,7 +200,7 @@ HRESULT wm_reader_get_output_props(struct wm_reader *reader, DWORD output,
IWMOutputMediaProps **props);
struct wm_stream *wm_reader_get_stream_by_stream_number(struct wm_reader *reader,
WORD stream_number);
HRESULT wm_reader_get_stream_sample(struct wm_reader *reader, WORD stream_number,
HRESULT wm_reader_get_stream_sample(struct wm_reader *reader, IWMReaderCallbackAdvanced *callback_advanced, WORD stream_number,
INSSBuffer **ret_sample, QWORD *pts, QWORD *duration, DWORD *flags, WORD *ret_stream_number);
HRESULT wm_reader_get_stream_selection(struct wm_reader *reader,
WORD stream_number, WMT_STREAM_SELECTION *selection);
......
......@@ -57,22 +57,17 @@ static REFERENCE_TIME get_current_time(const struct async_reader *reader)
static void open_stream(struct async_reader *reader, IWMReaderCallback *callback, void *context)
{
static const DWORD zero;
HRESULT hr;
IWMReaderCallback_AddRef(reader->callback = callback);
reader->context = context;
IWMReaderCallback_OnStatus(callback, WMT_OPENED, S_OK, WMT_TYPE_DWORD, (BYTE *)&zero, context);
if (FAILED(hr = IWMReaderCallback_QueryInterface(callback,
&IID_IWMReaderCallbackAdvanced, (void **)&reader->reader.callback_advanced)))
reader->reader.callback_advanced = NULL;
TRACE("Querying for IWMReaderCallbackAdvanced returned %#lx.\n", hr);
}
static DWORD WINAPI stream_thread(void *arg)
{
struct async_reader *reader = arg;
IWMReaderCallback *callback = reader->callback;
IWMReaderCallbackAdvanced *callback_advanced;
REFERENCE_TIME start_time;
struct wm_stream *stream;
static const DWORD zero;
......@@ -86,9 +81,14 @@ static DWORD WINAPI stream_thread(void *arg)
EnterCriticalSection(&reader->stream_cs);
if (FAILED(hr = IWMReaderCallback_QueryInterface(callback,
&IID_IWMReaderCallbackAdvanced, (void **)&callback_advanced)))
callback_advanced = NULL;
TRACE("Querying for IWMReaderCallbackAdvanced returned %#lx.\n", hr);
while (reader->running)
{
hr = wm_reader_get_stream_sample(&reader->reader, 0, &sample, &pts, &duration, &flags, &stream_number);
hr = wm_reader_get_stream_sample(&reader->reader, callback_advanced, 0, &sample, &pts, &duration, &flags, &stream_number);
if (hr != S_OK)
break;
......@@ -98,10 +98,10 @@ static DWORD WINAPI stream_thread(void *arg)
{
QWORD user_time = reader->user_time;
if (pts > user_time && reader->reader.callback_advanced)
if (pts > user_time && callback_advanced)
{
LeaveCriticalSection(&reader->stream_cs);
IWMReaderCallbackAdvanced_OnTime(reader->reader.callback_advanced, user_time, reader->context);
IWMReaderCallbackAdvanced_OnTime(callback_advanced, user_time, reader->context);
EnterCriticalSection(&reader->stream_cs);
}
......@@ -126,7 +126,7 @@ static DWORD WINAPI stream_thread(void *arg)
{
LeaveCriticalSection(&reader->stream_cs);
if (stream->read_compressed)
hr = IWMReaderCallbackAdvanced_OnStreamSample(reader->reader.callback_advanced,
hr = IWMReaderCallbackAdvanced_OnStreamSample(callback_advanced,
stream_number, pts, duration, flags, sample, reader->context);
else
hr = IWMReaderCallback_OnSample(callback, stream_number - 1, pts, duration,
......@@ -148,12 +148,12 @@ static DWORD WINAPI stream_thread(void *arg)
IWMReaderCallback_OnStatus(callback, WMT_EOF, S_OK,
WMT_TYPE_DWORD, (BYTE *)&zero, reader->context);
if (reader->user_clock && reader->reader.callback_advanced)
if (reader->user_clock && callback_advanced)
{
/* We can only get here if user_time is greater than the PTS
* of all samples, in which case we cannot have sent this
* notification already. */
IWMReaderCallbackAdvanced_OnTime(reader->reader.callback_advanced,
IWMReaderCallbackAdvanced_OnTime(callback_advanced,
reader->user_time, reader->context);
}
......@@ -164,6 +164,9 @@ static DWORD WINAPI stream_thread(void *arg)
ERR("Failed to get sample, hr %#lx.\n", hr);
}
if (callback_advanced)
IWMReaderCallbackAdvanced_Release(callback_advanced);
TRACE("Reader is stopping; exiting.\n");
return 0;
}
......
......@@ -1607,10 +1607,6 @@ HRESULT wm_reader_close(struct wm_reader *reader)
CloseHandle(reader->read_thread);
reader->read_thread = NULL;
if (reader->callback_advanced)
IWMReaderCallbackAdvanced_Release(reader->callback_advanced);
reader->callback_advanced = NULL;
wg_parser_destroy(reader->wg_parser);
reader->wg_parser = NULL;
......@@ -1871,10 +1867,9 @@ static WORD get_earliest_buffer(struct wm_reader *reader, struct wg_parser_buffe
return stream_number;
}
HRESULT wm_reader_get_stream_sample(struct wm_reader *reader, WORD stream_number,
HRESULT wm_reader_get_stream_sample(struct wm_reader *reader, IWMReaderCallbackAdvanced *callback_advanced, WORD stream_number,
INSSBuffer **ret_sample, QWORD *pts, QWORD *duration, DWORD *flags, WORD *ret_stream_number)
{
IWMReaderCallbackAdvanced *callback_advanced = reader->callback_advanced;
struct wg_parser_stream *wg_stream;
struct wg_parser_buffer wg_buffer;
struct wm_stream *stream;
......
......@@ -92,7 +92,7 @@ static HRESULT WINAPI WMSyncReader_GetNextSample(IWMSyncReader2 *iface,
EnterCriticalSection(&reader->reader.cs);
hr = wm_reader_get_stream_sample(&reader->reader, stream_number, sample, pts, duration, flags, &stream_number);
hr = wm_reader_get_stream_sample(&reader->reader, NULL, stream_number, sample, pts, duration, flags, &stream_number);
if (output_number && hr == S_OK)
*output_number = stream_number - 1;
if (ret_stream_number && (hr == S_OK || stream_number))
......
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