Commit 830efe87 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

winegstreamer: Factor out more of the init_gst callback into wg_parser_connect().

parent f9486e98
......@@ -1494,6 +1494,7 @@ static HRESULT CDECL wg_parser_connect(struct wg_parser *parser, uint64_t file_s
GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE("quartz_src",
GST_PAD_SRC, GST_PAD_ALWAYS, GST_STATIC_CAPS_ANY);
unsigned int i;
int ret;
parser->file_size = file_size;
parser->sink_connected = true;
......@@ -1516,12 +1517,29 @@ static HRESULT CDECL wg_parser_connect(struct wg_parser *parser, uint64_t file_s
parser->start_offset = parser->next_offset = parser->stop_offset = 0;
parser->next_pull_offset = 0;
parser->error = false;
if (!parser->init_gst(parser))
return E_FAIL;
gst_element_set_state(parser->container, GST_STATE_PAUSED);
ret = gst_element_get_state(parser->container, NULL, NULL, -1);
if (ret == GST_STATE_CHANGE_FAILURE)
{
GST_ERROR("Failed to play stream.\n");
return E_FAIL;
}
pthread_mutex_lock(&parser->mutex);
while (!parser->no_more_pads && !parser->error)
pthread_cond_wait(&parser->init_cond, &parser->mutex);
if (parser->error)
{
pthread_mutex_unlock(&parser->mutex);
return E_FAIL;
}
for (i = 0; i < parser->stream_count; ++i)
{
struct wg_parser_stream *stream = parser->streams[i];
......@@ -1677,7 +1695,7 @@ static BOOL decodebin_parser_init_gst(struct wg_parser *parser)
parser->their_sink = gst_element_get_static_pad(element, "sink");
pthread_mutex_lock(&parser->mutex);
parser->no_more_pads = parser->error = false;
parser->no_more_pads = false;
pthread_mutex_unlock(&parser->mutex);
if ((ret = gst_pad_link(parser->my_src, parser->their_sink)) < 0)
......@@ -1686,24 +1704,6 @@ static BOOL decodebin_parser_init_gst(struct wg_parser *parser)
return FALSE;
}
gst_element_set_state(parser->container, GST_STATE_PAUSED);
ret = gst_element_get_state(parser->container, NULL, NULL, -1);
if (ret == GST_STATE_CHANGE_FAILURE)
{
GST_ERROR("Failed to play stream.\n");
return FALSE;
}
pthread_mutex_lock(&parser->mutex);
while (!parser->no_more_pads && !parser->error)
pthread_cond_wait(&parser->init_cond, &parser->mutex);
if (parser->error)
{
pthread_mutex_unlock(&parser->mutex);
return FALSE;
}
pthread_mutex_unlock(&parser->mutex);
return TRUE;
}
......@@ -1724,7 +1724,7 @@ static BOOL avi_parser_init_gst(struct wg_parser *parser)
parser->their_sink = gst_element_get_static_pad(element, "sink");
pthread_mutex_lock(&parser->mutex);
parser->no_more_pads = parser->error = false;
parser->no_more_pads = false;
pthread_mutex_unlock(&parser->mutex);
if ((ret = gst_pad_link(parser->my_src, parser->their_sink)) < 0)
......@@ -1733,24 +1733,6 @@ static BOOL avi_parser_init_gst(struct wg_parser *parser)
return FALSE;
}
gst_element_set_state(parser->container, GST_STATE_PAUSED);
ret = gst_element_get_state(parser->container, NULL, NULL, -1);
if (ret == GST_STATE_CHANGE_FAILURE)
{
GST_ERROR("Failed to play stream.\n");
return FALSE;
}
pthread_mutex_lock(&parser->mutex);
while (!parser->no_more_pads && !parser->error)
pthread_cond_wait(&parser->init_cond, &parser->mutex);
if (parser->error)
{
pthread_mutex_unlock(&parser->mutex);
return FALSE;
}
pthread_mutex_unlock(&parser->mutex);
return TRUE;
}
......@@ -1781,15 +1763,9 @@ static BOOL mpeg_audio_parser_init_gst(struct wg_parser *parser)
GST_ERROR("Failed to link source pads, error %d.\n", ret);
return FALSE;
}
gst_pad_set_active(stream->my_sink, 1);
gst_element_set_state(parser->container, GST_STATE_PAUSED);
ret = gst_element_get_state(parser->container, NULL, NULL, -1);
if (ret == GST_STATE_CHANGE_FAILURE)
{
GST_ERROR("Failed to play stream.\n");
return FALSE;
}
parser->no_more_pads = true;
return TRUE;
}
......@@ -1822,15 +1798,9 @@ static BOOL wave_parser_init_gst(struct wg_parser *parser)
GST_ERROR("Failed to link source pads, error %d.\n", ret);
return FALSE;
}
gst_pad_set_active(stream->my_sink, 1);
gst_element_set_state(parser->container, GST_STATE_PAUSED);
ret = gst_element_get_state(parser->container, NULL, NULL, -1);
if (ret == GST_STATE_CHANGE_FAILURE)
{
GST_ERROR("Failed to play stream.\n");
return FALSE;
}
parser->no_more_pads = true;
return TRUE;
}
......
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