Commit 7a5224be authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

winegstreamer: Move wg_parser flushing to the Unix library.

parent aa695e21
......@@ -215,6 +215,9 @@ struct unix_funcs
HRESULT (CDECL *wg_parser_connect)(struct wg_parser *parser, uint64_t file_size);
void (CDECL *wg_parser_disconnect)(struct wg_parser *parser);
void (CDECL *wg_parser_begin_flush)(struct wg_parser *parser);
void (CDECL *wg_parser_end_flush)(struct wg_parser *parser);
uint32_t (CDECL *wg_parser_get_stream_count)(struct wg_parser *parser);
struct wg_parser_stream *(CDECL *wg_parser_get_stream)(struct wg_parser *parser, uint32_t index);
......
......@@ -856,9 +856,7 @@ static HRESULT parser_init_stream(struct strmbase_filter *iface)
return S_OK;
filter->streaming = true;
pthread_mutex_lock(&parser->mutex);
parser->flushing = false;
pthread_mutex_unlock(&parser->mutex);
unix_funcs->wg_parser_end_flush(filter->wg_parser);
/* DirectShow retains the old seek positions, but resets to them every time
* it transitions from stopped -> paused. */
......@@ -899,17 +897,7 @@ static HRESULT parser_cleanup_stream(struct strmbase_filter *iface)
return S_OK;
filter->streaming = false;
pthread_mutex_lock(&parser->mutex);
parser->flushing = true;
pthread_mutex_unlock(&parser->mutex);
for (i = 0; i < parser->stream_count; ++i)
{
struct wg_parser_stream *stream = parser->streams[i];
if (stream->enabled)
pthread_cond_signal(&stream->event_cond);
}
unix_funcs->wg_parser_begin_flush(filter->wg_parser);
for (i = 0; i < filter->source_count; ++i)
{
......@@ -1228,7 +1216,6 @@ static HRESULT WINAPI GST_Seeking_SetPositions(IMediaSeeking *iface,
struct parser_source *pin = impl_from_IMediaSeeking(iface);
struct wg_parser_stream *stream = pin->wg_stream;
struct parser *filter = impl_from_strmbase_filter(pin->pin.pin.filter);
struct wg_parser *parser = filter->wg_parser;
GstSeekFlags flags = 0;
HRESULT hr = S_OK;
int i;
......@@ -1247,17 +1234,12 @@ static HRESULT WINAPI GST_Seeking_SetPositions(IMediaSeeking *iface,
if (!(current_flags & AM_SEEKING_NoFlush))
{
pthread_mutex_lock(&parser->mutex);
parser->flushing = true;
pthread_mutex_unlock(&parser->mutex);
unix_funcs->wg_parser_begin_flush(filter->wg_parser);
for (i = 0; i < filter->source_count; ++i)
{
if (filter->sources[i]->pin.pin.peer)
{
pthread_cond_signal(&stream->event_cond);
IPin_BeginFlush(filter->sources[i]->pin.pin.peer);
}
}
if (filter->reader)
......@@ -1296,9 +1278,7 @@ static HRESULT WINAPI GST_Seeking_SetPositions(IMediaSeeking *iface,
if (!(current_flags & AM_SEEKING_NoFlush))
{
pthread_mutex_lock(&parser->mutex);
parser->flushing = false;
pthread_mutex_unlock(&parser->mutex);
unix_funcs->wg_parser_end_flush(filter->wg_parser);
for (i = 0; i < filter->source_count; ++i)
{
......
......@@ -327,6 +327,28 @@ static struct wg_parser_stream * CDECL wg_parser_get_stream(struct wg_parser *pa
return parser->streams[index];
}
static void CDECL wg_parser_begin_flush(struct wg_parser *parser)
{
unsigned int i;
pthread_mutex_lock(&parser->mutex);
parser->flushing = true;
pthread_mutex_unlock(&parser->mutex);
for (i = 0; i < parser->stream_count; ++i)
{
if (parser->streams[i]->enabled)
pthread_cond_signal(&parser->streams[i]->event_cond);
}
}
static void CDECL wg_parser_end_flush(struct wg_parser *parser)
{
pthread_mutex_lock(&parser->mutex);
parser->flushing = false;
pthread_mutex_unlock(&parser->mutex);
}
static void CDECL wg_parser_stream_get_preferred_format(struct wg_parser_stream *stream, struct wg_format *format)
{
*format = stream->preferred_format;
......@@ -1520,6 +1542,9 @@ static const struct unix_funcs funcs =
wg_parser_connect,
wg_parser_disconnect,
wg_parser_begin_flush,
wg_parser_end_flush,
wg_parser_get_stream_count,
wg_parser_get_stream,
......
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