gst/gstscheduler.c: Aplied clock distribution patch, this should fix bug #148787.

Original commit message from CVS:
* gst/gstscheduler.c: (gst_scheduler_add_element),
(gst_scheduler_remove_element), (gst_scheduler_state_transition):
Aplied clock distribution patch, this should fix bug
#148787.
This commit is contained in:
Wim Taymans 2004-11-02 12:33:24 +00:00
parent 47dd0dca68
commit 3207eb2f42
2 changed files with 42 additions and 2 deletions

View file

@ -1,3 +1,10 @@
2004-11-02 Wim Taymans <wim@fluendo.com>
* gst/gstscheduler.c: (gst_scheduler_add_element),
(gst_scheduler_remove_element), (gst_scheduler_state_transition):
Aplied clock distribution patch, this should fix bug
#148787.
2004-10-27 Thomas Vander Stichele <thomas at apestaart dot org>
Submitted by: Kjartan Maraas <kmaraas@broadpark.no>

View file

@ -215,6 +215,7 @@ void
gst_scheduler_add_element (GstScheduler * sched, GstElement * element)
{
GstSchedulerClass *sclass;
gboolean redistribute_clock = FALSE;
g_return_if_fail (GST_IS_SCHEDULER (sched));
g_return_if_fail (GST_IS_ELEMENT (element));
@ -233,15 +234,24 @@ gst_scheduler_add_element (GstScheduler * sched, GstElement * element)
sched->clock_providers = g_list_prepend (sched->clock_providers, element);
GST_CAT_DEBUG (GST_CAT_CLOCK, "added clock provider %s",
GST_ELEMENT_NAME (element));
redistribute_clock = TRUE;
}
if (gst_element_requires_clock (element)) {
sched->clock_receivers = g_list_prepend (sched->clock_receivers, element);
GST_CAT_DEBUG (GST_CAT_CLOCK, "added clock receiver %s",
GST_ELEMENT_NAME (element));
redistribute_clock = TRUE;
}
gst_element_set_scheduler (element, sched);
if (redistribute_clock) {
GstClock *clock;
clock = gst_scheduler_get_clock (sched);
gst_scheduler_set_clock (sched, clock);
}
sclass = GST_SCHEDULER_GET_CLASS (sched);
if (sclass->add_element)
@ -259,12 +269,33 @@ void
gst_scheduler_remove_element (GstScheduler * sched, GstElement * element)
{
GstSchedulerClass *sclass;
GList *link;
gboolean redistribute_clock = FALSE;
g_return_if_fail (GST_IS_SCHEDULER (sched));
g_return_if_fail (GST_IS_ELEMENT (element));
sched->clock_providers = g_list_remove (sched->clock_providers, element);
sched->clock_receivers = g_list_remove (sched->clock_receivers, element);
link = g_list_find (sched->clock_providers, element);
if (link) {
sched->clock_providers = g_list_delete_link (sched->clock_providers, link);
GST_CAT_DEBUG (GST_CAT_CLOCK, "removed clock provider %s",
GST_ELEMENT_NAME (element));
redistribute_clock = TRUE;
}
link = g_list_find (sched->clock_receivers, element);
if (link) {
sched->clock_receivers = g_list_delete_link (sched->clock_receivers, link);
GST_CAT_DEBUG (GST_CAT_CLOCK, "removed clock receiver %s",
GST_ELEMENT_NAME (element));
redistribute_clock = TRUE;
}
if (redistribute_clock) {
GstClock *clock;
clock = gst_scheduler_get_clock (sched);
gst_scheduler_set_clock (sched, clock);
}
sclass = GST_SCHEDULER_GET_CLASS (sched);
@ -295,6 +326,8 @@ gst_scheduler_state_transition (GstScheduler * sched, GstElement * element,
g_return_val_if_fail (GST_IS_ELEMENT (element), GST_STATE_FAILURE);
if (element == sched->parent && sched->parent_sched == NULL) {
/* FIXME is distributing the clock in the state change still needed
* when we distribute as soon as we add/remove elements? I think not.*/
switch (transition) {
case GST_STATE_READY_TO_PAUSED:
{