mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 15:08:53 +00:00
gst/base/gstbasesink.c: Simply set the right flag when going to playing, that's all we need to do instead of calling ...
Original commit message from CVS: * gst/base/gstbasesink.c: (gst_base_sink_commit_state), (gst_base_sink_get_position), (gst_base_sink_query), (gst_base_sink_change_state): Simply set the right flag when going to playing, that's all we need to do instead of calling a function inside the object lock (that could take the lock as well and deadlock)
This commit is contained in:
parent
c1f08609d1
commit
62cfdde715
3 changed files with 79 additions and 96 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2005-10-21 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
|
* gst/base/gstbasesink.c: (gst_base_sink_commit_state),
|
||||||
|
(gst_base_sink_get_position), (gst_base_sink_query),
|
||||||
|
(gst_base_sink_change_state):
|
||||||
|
Simply set the right flag when going to playing, that's all
|
||||||
|
we need to do instead of calling a function inside the object
|
||||||
|
lock (that could take the lock as well and deadlock)
|
||||||
|
|
||||||
2005-10-21 Wim Taymans <wim@fluendo.com>
|
2005-10-21 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
* gst/base/gstbasesrc.c: (gst_base_src_do_seek),
|
* gst/base/gstbasesrc.c: (gst_base_src_do_seek),
|
||||||
|
|
|
@ -98,8 +98,6 @@ gst_base_sink_get_type (void)
|
||||||
return base_sink_type;
|
return base_sink_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstStateChangeReturn do_playing (GstBaseSink * sink);
|
|
||||||
|
|
||||||
static void gst_base_sink_set_clock (GstElement * element, GstClock * clock);
|
static void gst_base_sink_set_clock (GstElement * element, GstClock * clock);
|
||||||
|
|
||||||
static void gst_base_sink_set_property (GObject * object, guint prop_id,
|
static void gst_base_sink_set_property (GObject * object, guint prop_id,
|
||||||
|
@ -443,6 +441,7 @@ gst_base_sink_preroll_queue_flush (GstBaseSink * basesink, GstPad * pad)
|
||||||
GST_PREROLL_SIGNAL (pad);
|
GST_PREROLL_SIGNAL (pad);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* with PREROLL_LOCK */
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_base_sink_commit_state (GstBaseSink * basesink)
|
gst_base_sink_commit_state (GstBaseSink * basesink)
|
||||||
{
|
{
|
||||||
|
@ -460,7 +459,7 @@ gst_base_sink_commit_state (GstBaseSink * basesink)
|
||||||
|
|
||||||
switch (pending) {
|
switch (pending) {
|
||||||
case GST_STATE_PLAYING:
|
case GST_STATE_PLAYING:
|
||||||
do_playing (basesink);
|
basesink->need_preroll = FALSE;
|
||||||
post_playing = TRUE;
|
post_playing = TRUE;
|
||||||
break;
|
break;
|
||||||
case GST_STATE_PAUSED:
|
case GST_STATE_PAUSED:
|
||||||
|
@ -1495,50 +1494,6 @@ gst_base_sink_query (GstElement * element, GstQuery * query)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* with PREROLL_LOCK */
|
|
||||||
static GstStateChangeReturn
|
|
||||||
do_playing (GstBaseSink * basesink)
|
|
||||||
{
|
|
||||||
GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
|
|
||||||
|
|
||||||
/* no preroll needed */
|
|
||||||
basesink->need_preroll = FALSE;
|
|
||||||
|
|
||||||
/* if we have EOS, we should empty the queue now as there will
|
|
||||||
* be no more data received in the chain function.
|
|
||||||
* FIXME, this could block the state change function too long when
|
|
||||||
* we are pushing and syncing the buffers, better start a new
|
|
||||||
* thread to do this. */
|
|
||||||
if (basesink->eos) {
|
|
||||||
gboolean do_eos = !basesink->eos_queued;
|
|
||||||
|
|
||||||
gst_base_sink_preroll_queue_empty (basesink, basesink->sinkpad);
|
|
||||||
|
|
||||||
/* need to post EOS message here if it was not in the preroll queue we
|
|
||||||
* just emptied. */
|
|
||||||
if (do_eos) {
|
|
||||||
GST_DEBUG_OBJECT (basesink, "Now posting EOS");
|
|
||||||
gst_element_post_message (GST_ELEMENT (basesink),
|
|
||||||
gst_message_new_eos (GST_OBJECT (basesink)));
|
|
||||||
}
|
|
||||||
} else if (!basesink->have_preroll) {
|
|
||||||
/* don't need preroll, but do queue a commit_state */
|
|
||||||
basesink->need_preroll = TRUE;
|
|
||||||
GST_DEBUG_OBJECT (basesink,
|
|
||||||
"PAUSED to PLAYING, !eos, !have_preroll, need preroll to FALSE");
|
|
||||||
ret = GST_STATE_CHANGE_ASYNC;
|
|
||||||
/* we know it's not waiting, no need to signal */
|
|
||||||
} else {
|
|
||||||
/* don't need the preroll anymore */
|
|
||||||
GST_DEBUG_OBJECT (basesink,
|
|
||||||
"PAUSED to PLAYING, !eos, have_preroll, need preroll to FALSE");
|
|
||||||
/* now let it play */
|
|
||||||
GST_PREROLL_SIGNAL (basesink->sinkpad);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstStateChangeReturn
|
static GstStateChangeReturn
|
||||||
gst_base_sink_change_state (GstElement * element, GstStateChange transition)
|
gst_base_sink_change_state (GstElement * element, GstStateChange transition)
|
||||||
{
|
{
|
||||||
|
@ -1573,7 +1528,39 @@ gst_base_sink_change_state (GstElement * element, GstStateChange transition)
|
||||||
break;
|
break;
|
||||||
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
||||||
GST_PREROLL_LOCK (basesink->sinkpad);
|
GST_PREROLL_LOCK (basesink->sinkpad);
|
||||||
ret = do_playing (basesink);
|
/* no preroll needed */
|
||||||
|
basesink->need_preroll = FALSE;
|
||||||
|
|
||||||
|
/* if we have EOS, we should empty the queue now as there will
|
||||||
|
* be no more data received in the chain function.
|
||||||
|
* FIXME, this could block the state change function too long when
|
||||||
|
* we are pushing and syncing the buffers, better start a new
|
||||||
|
* thread to do this. */
|
||||||
|
if (basesink->eos) {
|
||||||
|
gboolean do_eos = !basesink->eos_queued;
|
||||||
|
|
||||||
|
gst_base_sink_preroll_queue_empty (basesink, basesink->sinkpad);
|
||||||
|
|
||||||
|
/* need to post EOS message here if it was not in the preroll queue we
|
||||||
|
* just emptied. */
|
||||||
|
if (do_eos) {
|
||||||
|
GST_DEBUG_OBJECT (basesink, "Now posting EOS");
|
||||||
|
gst_element_post_message (GST_ELEMENT (basesink),
|
||||||
|
gst_message_new_eos (GST_OBJECT (basesink)));
|
||||||
|
}
|
||||||
|
} else if (!basesink->have_preroll) {
|
||||||
|
/* queue a commit_state */
|
||||||
|
basesink->need_preroll = TRUE;
|
||||||
|
GST_DEBUG_OBJECT (basesink,
|
||||||
|
"PAUSED to PLAYING, !eos, !have_preroll, need preroll to FALSE");
|
||||||
|
ret = GST_STATE_CHANGE_ASYNC;
|
||||||
|
/* we know it's not waiting, no need to signal */
|
||||||
|
} else {
|
||||||
|
GST_DEBUG_OBJECT (basesink,
|
||||||
|
"PAUSED to PLAYING, !eos, have_preroll, need preroll to FALSE");
|
||||||
|
/* now let it play */
|
||||||
|
GST_PREROLL_SIGNAL (basesink->sinkpad);
|
||||||
|
}
|
||||||
GST_PREROLL_UNLOCK (basesink->sinkpad);
|
GST_PREROLL_UNLOCK (basesink->sinkpad);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -98,8 +98,6 @@ gst_base_sink_get_type (void)
|
||||||
return base_sink_type;
|
return base_sink_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstStateChangeReturn do_playing (GstBaseSink * sink);
|
|
||||||
|
|
||||||
static void gst_base_sink_set_clock (GstElement * element, GstClock * clock);
|
static void gst_base_sink_set_clock (GstElement * element, GstClock * clock);
|
||||||
|
|
||||||
static void gst_base_sink_set_property (GObject * object, guint prop_id,
|
static void gst_base_sink_set_property (GObject * object, guint prop_id,
|
||||||
|
@ -443,6 +441,7 @@ gst_base_sink_preroll_queue_flush (GstBaseSink * basesink, GstPad * pad)
|
||||||
GST_PREROLL_SIGNAL (pad);
|
GST_PREROLL_SIGNAL (pad);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* with PREROLL_LOCK */
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_base_sink_commit_state (GstBaseSink * basesink)
|
gst_base_sink_commit_state (GstBaseSink * basesink)
|
||||||
{
|
{
|
||||||
|
@ -460,7 +459,7 @@ gst_base_sink_commit_state (GstBaseSink * basesink)
|
||||||
|
|
||||||
switch (pending) {
|
switch (pending) {
|
||||||
case GST_STATE_PLAYING:
|
case GST_STATE_PLAYING:
|
||||||
do_playing (basesink);
|
basesink->need_preroll = FALSE;
|
||||||
post_playing = TRUE;
|
post_playing = TRUE;
|
||||||
break;
|
break;
|
||||||
case GST_STATE_PAUSED:
|
case GST_STATE_PAUSED:
|
||||||
|
@ -1495,50 +1494,6 @@ gst_base_sink_query (GstElement * element, GstQuery * query)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* with PREROLL_LOCK */
|
|
||||||
static GstStateChangeReturn
|
|
||||||
do_playing (GstBaseSink * basesink)
|
|
||||||
{
|
|
||||||
GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
|
|
||||||
|
|
||||||
/* no preroll needed */
|
|
||||||
basesink->need_preroll = FALSE;
|
|
||||||
|
|
||||||
/* if we have EOS, we should empty the queue now as there will
|
|
||||||
* be no more data received in the chain function.
|
|
||||||
* FIXME, this could block the state change function too long when
|
|
||||||
* we are pushing and syncing the buffers, better start a new
|
|
||||||
* thread to do this. */
|
|
||||||
if (basesink->eos) {
|
|
||||||
gboolean do_eos = !basesink->eos_queued;
|
|
||||||
|
|
||||||
gst_base_sink_preroll_queue_empty (basesink, basesink->sinkpad);
|
|
||||||
|
|
||||||
/* need to post EOS message here if it was not in the preroll queue we
|
|
||||||
* just emptied. */
|
|
||||||
if (do_eos) {
|
|
||||||
GST_DEBUG_OBJECT (basesink, "Now posting EOS");
|
|
||||||
gst_element_post_message (GST_ELEMENT (basesink),
|
|
||||||
gst_message_new_eos (GST_OBJECT (basesink)));
|
|
||||||
}
|
|
||||||
} else if (!basesink->have_preroll) {
|
|
||||||
/* don't need preroll, but do queue a commit_state */
|
|
||||||
basesink->need_preroll = TRUE;
|
|
||||||
GST_DEBUG_OBJECT (basesink,
|
|
||||||
"PAUSED to PLAYING, !eos, !have_preroll, need preroll to FALSE");
|
|
||||||
ret = GST_STATE_CHANGE_ASYNC;
|
|
||||||
/* we know it's not waiting, no need to signal */
|
|
||||||
} else {
|
|
||||||
/* don't need the preroll anymore */
|
|
||||||
GST_DEBUG_OBJECT (basesink,
|
|
||||||
"PAUSED to PLAYING, !eos, have_preroll, need preroll to FALSE");
|
|
||||||
/* now let it play */
|
|
||||||
GST_PREROLL_SIGNAL (basesink->sinkpad);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstStateChangeReturn
|
static GstStateChangeReturn
|
||||||
gst_base_sink_change_state (GstElement * element, GstStateChange transition)
|
gst_base_sink_change_state (GstElement * element, GstStateChange transition)
|
||||||
{
|
{
|
||||||
|
@ -1573,7 +1528,39 @@ gst_base_sink_change_state (GstElement * element, GstStateChange transition)
|
||||||
break;
|
break;
|
||||||
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
||||||
GST_PREROLL_LOCK (basesink->sinkpad);
|
GST_PREROLL_LOCK (basesink->sinkpad);
|
||||||
ret = do_playing (basesink);
|
/* no preroll needed */
|
||||||
|
basesink->need_preroll = FALSE;
|
||||||
|
|
||||||
|
/* if we have EOS, we should empty the queue now as there will
|
||||||
|
* be no more data received in the chain function.
|
||||||
|
* FIXME, this could block the state change function too long when
|
||||||
|
* we are pushing and syncing the buffers, better start a new
|
||||||
|
* thread to do this. */
|
||||||
|
if (basesink->eos) {
|
||||||
|
gboolean do_eos = !basesink->eos_queued;
|
||||||
|
|
||||||
|
gst_base_sink_preroll_queue_empty (basesink, basesink->sinkpad);
|
||||||
|
|
||||||
|
/* need to post EOS message here if it was not in the preroll queue we
|
||||||
|
* just emptied. */
|
||||||
|
if (do_eos) {
|
||||||
|
GST_DEBUG_OBJECT (basesink, "Now posting EOS");
|
||||||
|
gst_element_post_message (GST_ELEMENT (basesink),
|
||||||
|
gst_message_new_eos (GST_OBJECT (basesink)));
|
||||||
|
}
|
||||||
|
} else if (!basesink->have_preroll) {
|
||||||
|
/* queue a commit_state */
|
||||||
|
basesink->need_preroll = TRUE;
|
||||||
|
GST_DEBUG_OBJECT (basesink,
|
||||||
|
"PAUSED to PLAYING, !eos, !have_preroll, need preroll to FALSE");
|
||||||
|
ret = GST_STATE_CHANGE_ASYNC;
|
||||||
|
/* we know it's not waiting, no need to signal */
|
||||||
|
} else {
|
||||||
|
GST_DEBUG_OBJECT (basesink,
|
||||||
|
"PAUSED to PLAYING, !eos, have_preroll, need preroll to FALSE");
|
||||||
|
/* now let it play */
|
||||||
|
GST_PREROLL_SIGNAL (basesink->sinkpad);
|
||||||
|
}
|
||||||
GST_PREROLL_UNLOCK (basesink->sinkpad);
|
GST_PREROLL_UNLOCK (basesink->sinkpad);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue