2000-12-28 22:12:02 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* 2000 Wim Taymans <wtay@chello.be>
|
2005-01-06 18:17:12 +00:00
|
|
|
* 2004 Wim Taymans <wim@fluendo.com>
|
2000-12-28 22:12:02 +00:00
|
|
|
*
|
|
|
|
* gstclock.c: Clock subsystem for maintaining time sync
|
2000-04-09 21:38:17 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2004-04-28 23:26:06 +00:00
|
|
|
#include <time.h>
|
2000-12-28 22:12:02 +00:00
|
|
|
|
|
|
|
#include "gst_private.h"
|
2003-06-29 14:05:49 +00:00
|
|
|
|
2000-12-15 01:57:34 +00:00
|
|
|
#include "gstclock.h"
|
2003-06-29 14:05:49 +00:00
|
|
|
#include "gstinfo.h"
|
2002-07-08 19:22:02 +00:00
|
|
|
#include "gstmemchunk.h"
|
gst/: Inline refcounting.. not sure why it wasn't before.
Original commit message from CVS:
* gst/gstcaps.c: (gst_caps_intersect):
* gst/gstclock.c: (gst_clock_id_ref), (gst_clock_id_unref),
(gst_clock_id_compare_func), (gst_clock_id_wait),
(gst_clock_id_wait_async), (gst_clock_init),
(gst_clock_adjust_unlocked), (gst_clock_get_time):
* gst/gstinfo.c:
* gst/gstobject.c: (gst_object_class_init), (gst_object_ref),
(gst_object_unref), (gst_object_sink), (gst_object_dispose),
(gst_object_dispatch_properties_changed), (gst_object_set_name),
(gst_object_set_parent), (gst_object_unparent),
(gst_object_check_uniqueness), (gst_object_get_path_string):
* gst/gstutils.c: (gst_element_finish_preroll),
(gst_element_get_compatible_pad_filtered),
(gst_element_link_pads_filtered), (gst_element_unlink),
(gst_pad_use_fixed_caps), (gst_pad_get_fixed_caps_func):
* gst/gstutils.h:
Inline refcounting.. not sure why it wasn't before.
Added use_fixed_caps method to change default getcaps
behaviour.
2005-02-03 17:05:21 +00:00
|
|
|
#include "gstatomic_impl.h"
|
2000-04-09 21:38:17 +00:00
|
|
|
|
2003-02-10 20:32:32 +00:00
|
|
|
#ifndef GST_DISABLE_TRACE
|
2003-02-02 19:21:06 +00:00
|
|
|
/* #define GST_WITH_ALLOC_TRACE */
|
2003-02-10 20:32:32 +00:00
|
|
|
#include "gsttrace.h"
|
|
|
|
static GstAllocTrace *_gst_clock_entry_trace;
|
|
|
|
#endif
|
2003-02-02 19:21:06 +00:00
|
|
|
|
2004-01-15 01:35:41 +00:00
|
|
|
#define DEFAULT_EVENT_DIFF (GST_SECOND)
|
2002-12-27 04:11:59 +00:00
|
|
|
#define DEFAULT_MAX_DIFF (2 * GST_SECOND)
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
enum
|
|
|
|
{
|
2002-11-02 13:54:34 +00:00
|
|
|
ARG_0,
|
|
|
|
ARG_STATS,
|
gst/gstclock.*: deprecate old interface and disable functions that aren't in use anymore.
Original commit message from CVS:
2004-01-13 Benjamin Otte <in7y118@public.uni-hamburg.de>
* gst/gstclock.c: (gst_clock_class_init), (gst_clock_init),
(gst_clock_set_speed), (gst_clock_set_active),
(gst_clock_is_active), (gst_clock_reset),
(gst_clock_handle_discont):
* gst/gstclock.h:
deprecate old interface and disable functions that aren't in use
anymore.
* gst/gstelement.h:
* gst/gstelement.c: (gst_element_get_time), (gst_element_wait),
(gst_element_set_time), (gst_element_adjust_time):
add concept of "element time" and functions to get/set this time.
* gst/gstelement.c: (gst_element_change_state):
update element time correctly.
* gst/gstelement.c: (gst_element_get_compatible_pad_filtered):
This is a debug message, not a g_critical.
* gst/gstpad.c: (gst_pad_event_default):
handle discontinuous events right with element time.
* gst/gstscheduler.c: (gst_scheduler_state_transition):
update to clocking fixes.
set clocks on elements in READY=>PAUSED. The old behaviour caused
a wrong element time on the first element that started playing.
* gst/schedulers/gstbasicscheduler.c:
(gst_basic_scheduler_class_init):
* gst/schedulers/gstoptimalscheduler.c:
(gst_opt_scheduler_class_init):
remove code that just implements the default behaviour.
* gst/elements/gstfakesink.c: (gst_fakesink_chain):
update to use new clocking functions
* testsuite/clock/clock1.c: (gst_clock_debug), (main):
* testsuite/clock/clock2.c: (gst_clock_debug), (main):
update to test new element time.
* gst/autoplug/gstspideridentity.c: (gst_spider_identity_getcaps):
use _get_allowed_caps instead of _get_caps. This catches filtered
caps correctly.
* testsuite/debug/commandline.c:
update for new GST_DEBUG syntax.
* testsuite/threads/Makefile.am:
disable a test that only works sometimes.
2004-01-14 00:46:48 +00:00
|
|
|
ARG_MAX_DIFF,
|
|
|
|
ARG_EVENT_DIFF
|
2002-11-02 13:54:34 +00:00
|
|
|
};
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static GstMemChunk *_gst_clock_entries_chunk;
|
|
|
|
|
|
|
|
static void gst_clock_class_init (GstClockClass * klass);
|
|
|
|
static void gst_clock_init (GstClock * clock);
|
|
|
|
static void gst_clock_dispose (GObject * object);
|
2003-02-02 19:21:06 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static void gst_clock_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_clock_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_clock_update_stats (GstClock * clock);
|
2002-02-03 20:07:09 +00:00
|
|
|
|
2002-03-30 17:05:03 +00:00
|
|
|
|
2002-02-03 20:07:09 +00:00
|
|
|
static GstObjectClass *parent_class = NULL;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-02-03 20:07:09 +00:00
|
|
|
/* static guint gst_clock_signals[LAST_SIGNAL] = { 0 }; */
|
|
|
|
|
2003-01-15 18:29:40 +00:00
|
|
|
static GstClockID
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_clock_entry_new (GstClock * clock, GstClockTime time,
|
|
|
|
GstClockTime interval, GstClockEntryType type)
|
2002-11-02 13:54:34 +00:00
|
|
|
{
|
|
|
|
GstClockEntry *entry;
|
2002-03-30 17:05:03 +00:00
|
|
|
|
2002-11-02 13:54:34 +00:00
|
|
|
entry = gst_mem_chunk_alloc (_gst_clock_entries_chunk);
|
2003-02-10 20:32:32 +00:00
|
|
|
#ifndef GST_DISABLE_TRACE
|
2003-02-02 19:21:06 +00:00
|
|
|
gst_alloc_trace_new (_gst_clock_entry_trace, entry);
|
2003-02-10 20:32:32 +00:00
|
|
|
#endif
|
2005-01-06 18:17:12 +00:00
|
|
|
GST_CAT_DEBUG (GST_CAT_CLOCK, "created entry %p", entry);
|
2002-03-30 17:05:03 +00:00
|
|
|
|
2005-01-06 18:17:12 +00:00
|
|
|
gst_atomic_int_init (&entry->refcount, 1);
|
2002-11-02 13:54:34 +00:00
|
|
|
entry->clock = clock;
|
|
|
|
entry->time = time;
|
2004-02-11 19:02:00 +00:00
|
|
|
entry->interval = interval;
|
2002-11-02 13:54:34 +00:00
|
|
|
entry->type = type;
|
2005-01-06 18:17:12 +00:00
|
|
|
entry->status = GST_CLOCK_BUSY;
|
2002-03-30 17:05:03 +00:00
|
|
|
|
2002-11-02 13:54:34 +00:00
|
|
|
return (GstClockID) entry;
|
|
|
|
}
|
2002-03-30 17:05:03 +00:00
|
|
|
|
2005-01-06 18:17:12 +00:00
|
|
|
/**
|
|
|
|
* gst_clock_id_ref:
|
|
|
|
* @id: The clockid to ref
|
|
|
|
*
|
|
|
|
* Increase the refcount of the given clockid.
|
|
|
|
*
|
|
|
|
* Returns: The same #GstClockID with increased refcount.
|
|
|
|
*
|
|
|
|
* MT safe.
|
|
|
|
*/
|
|
|
|
GstClockID
|
|
|
|
gst_clock_id_ref (GstClockID id)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (id != NULL, NULL);
|
|
|
|
|
|
|
|
gst_atomic_int_inc (&((GstClockEntry *) id)->refcount);
|
|
|
|
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_gst_clock_id_free (GstClockID id)
|
|
|
|
{
|
|
|
|
g_return_if_fail (id != NULL);
|
|
|
|
|
|
|
|
GST_CAT_DEBUG (GST_CAT_CLOCK, "freed entry %p", id);
|
|
|
|
|
|
|
|
#ifndef GST_DISABLE_TRACE
|
|
|
|
gst_alloc_trace_free (_gst_clock_entry_trace, id);
|
|
|
|
#endif
|
|
|
|
gst_mem_chunk_free (_gst_clock_entries_chunk, id);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_clock_id_unref:
|
|
|
|
* @id: The clockid to unref
|
|
|
|
*
|
|
|
|
* Unref the given clockid. When the refcount reaches 0 the
|
|
|
|
* #GstClockID will be freed.
|
|
|
|
*
|
|
|
|
* MT safe.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_clock_id_unref (GstClockID id)
|
|
|
|
{
|
|
|
|
gint zero;
|
|
|
|
|
|
|
|
g_return_if_fail (id != NULL);
|
|
|
|
|
|
|
|
zero = gst_atomic_int_dec_and_test (&((GstClockEntry *) id)->refcount);
|
|
|
|
/* if we ended up with the refcount at zero, free the id */
|
|
|
|
if (zero) {
|
|
|
|
_gst_clock_id_free (id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-11-02 13:54:34 +00:00
|
|
|
/**
|
|
|
|
* gst_clock_new_single_shot_id
|
|
|
|
* @clock: The clockid to get a single shot notification from
|
|
|
|
* @time: the requested time
|
|
|
|
*
|
|
|
|
* Get an ID from the given clock to trigger a single shot
|
2005-01-06 18:17:12 +00:00
|
|
|
* notification at the requested time. The single shot id should be
|
|
|
|
* unreffed after usage.
|
2002-11-02 13:54:34 +00:00
|
|
|
*
|
|
|
|
* Returns: An id that can be used to request the time notification.
|
2005-01-06 18:17:12 +00:00
|
|
|
*
|
|
|
|
* MT safe.
|
2002-11-02 13:54:34 +00:00
|
|
|
*/
|
|
|
|
GstClockID
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_clock_new_single_shot_id (GstClock * clock, GstClockTime time)
|
2002-11-02 13:54:34 +00:00
|
|
|
{
|
2002-11-27 20:47:39 +00:00
|
|
|
g_return_val_if_fail (GST_IS_CLOCK (clock), NULL);
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
return gst_clock_entry_new (clock,
|
|
|
|
time, GST_CLOCK_TIME_NONE, GST_CLOCK_ENTRY_SINGLE);
|
2002-11-02 13:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2002-12-14 13:02:16 +00:00
|
|
|
* gst_clock_new_periodic_id
|
2002-11-02 13:54:34 +00:00
|
|
|
* @clock: The clockid to get a periodic notification id from
|
|
|
|
* @start_time: the requested start time
|
|
|
|
* @interval: the requested interval
|
|
|
|
*
|
|
|
|
* Get an ID from the given clock to trigger a periodic notification.
|
|
|
|
* The periodeic notifications will be start at time start_time and
|
2005-01-06 18:17:12 +00:00
|
|
|
* will then be fired with the given interval. The id should be unreffed
|
|
|
|
* after usage.
|
2002-11-02 13:54:34 +00:00
|
|
|
*
|
|
|
|
* Returns: An id that can be used to request the time notification.
|
2005-01-06 18:17:12 +00:00
|
|
|
*
|
|
|
|
* MT safe.
|
2002-11-02 13:54:34 +00:00
|
|
|
*/
|
|
|
|
GstClockID
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_clock_new_periodic_id (GstClock * clock, GstClockTime start_time,
|
|
|
|
GstClockTime interval)
|
2002-11-02 13:54:34 +00:00
|
|
|
{
|
2002-11-27 20:47:39 +00:00
|
|
|
g_return_val_if_fail (GST_IS_CLOCK (clock), NULL);
|
2003-04-13 03:07:07 +00:00
|
|
|
g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (start_time), NULL);
|
2002-11-27 20:47:39 +00:00
|
|
|
g_return_val_if_fail (interval != 0, NULL);
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
return gst_clock_entry_new (clock,
|
|
|
|
start_time, interval, GST_CLOCK_ENTRY_PERIODIC);
|
2002-11-02 13:54:34 +00:00
|
|
|
}
|
|
|
|
|
2005-01-06 18:17:12 +00:00
|
|
|
/**
|
|
|
|
* gst_clock_id_compare_func
|
|
|
|
* @id1: A clockid
|
|
|
|
* @id2: A clockid to compare with
|
|
|
|
*
|
|
|
|
* Compares the two GstClockID instances. This function can be used
|
|
|
|
* as a GCompareFunc when sorting ids.
|
|
|
|
*
|
|
|
|
* Returns: negative value if a < b; zero if a = b; positive value if a > b
|
|
|
|
*
|
|
|
|
* MT safe.
|
|
|
|
*/
|
|
|
|
gint
|
|
|
|
gst_clock_id_compare_func (gconstpointer id1, gconstpointer id2)
|
|
|
|
{
|
|
|
|
GstClockEntry *entry1, *entry2;
|
|
|
|
|
|
|
|
entry1 = (GstClockEntry *) id1;
|
|
|
|
entry2 = (GstClockEntry *) id2;
|
|
|
|
|
Added more docs.
Original commit message from CVS:
* docs/design/part-clocks.txt:
* docs/design/part-events.txt:
* gst/elements/gstfakesrc.c: (gst_fakesrc_get_event_mask),
(gst_fakesrc_event_handler), (gst_fakesrc_loop),
(gst_fakesrc_activate):
* gst/gstclock.c: (gst_clock_id_ref), (gst_clock_id_unref),
(gst_clock_id_compare_func), (gst_clock_id_wait),
(gst_clock_id_wait_async), (gst_clock_init),
(gst_clock_adjust_unlocked), (gst_clock_get_time):
* gst/gstevent.c: (gst_event_new_discontinuous_valist),
(gst_event_discont_get_value), (gst_event_new_segment_seek):
* gst/gstevent.h:
* gst/gstpipeline.c: (gst_pipeline_init), (is_eos),
(pipeline_bus_handler), (gst_pipeline_change_state):
* gst/gstpipeline.h:
* gst/gstsystemclock.c: (gst_system_clock_init),
(gst_system_clock_async_thread),
(gst_system_clock_id_wait_unlocked),
(gst_system_clock_id_wait_async), (gst_system_clock_id_unschedule):
* libs/gst/dataprotocol/dataprotocol.c: (gst_dp_packet_from_event),
(gst_dp_event_from_packet):
* testsuite/clock/Makefile.am:
* testsuite/clock/clock4.c: (gst_clock_debug), (ok_callback),
(error_callback), (main):
Added more docs.
Remove more silly events.
Implement periodic clock notifications.
Add async testsuite.
2005-02-11 15:50:53 +00:00
|
|
|
if (GST_CLOCK_ENTRY_TIME (entry1) > GST_CLOCK_ENTRY_TIME (entry2)) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (GST_CLOCK_ENTRY_TIME (entry1) < GST_CLOCK_ENTRY_TIME (entry2)) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return entry1 - entry2;
|
2005-01-06 18:17:12 +00:00
|
|
|
}
|
|
|
|
|
2002-11-02 13:54:34 +00:00
|
|
|
/**
|
|
|
|
* gst_clock_id_get_time
|
|
|
|
* @id: The clockid to query
|
|
|
|
*
|
|
|
|
* Get the time of the clock ID
|
|
|
|
*
|
2005-01-06 18:17:12 +00:00
|
|
|
* Returns: the time of the given clock id.
|
|
|
|
*
|
|
|
|
* MT safe.
|
2002-11-02 13:54:34 +00:00
|
|
|
*/
|
|
|
|
GstClockTime
|
|
|
|
gst_clock_id_get_time (GstClockID id)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (id != NULL, GST_CLOCK_TIME_NONE);
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
return GST_CLOCK_ENTRY_TIME ((GstClockEntry *) id);
|
2002-11-02 13:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_clock_id_wait
|
|
|
|
* @id: The clockid to wait on
|
|
|
|
* @jitter: A pointer that will contain the jitter
|
|
|
|
*
|
|
|
|
* Perform a blocking wait on the given ID. The jitter arg can be
|
2005-01-06 18:17:12 +00:00
|
|
|
* NULL.
|
2002-11-02 13:54:34 +00:00
|
|
|
*
|
|
|
|
* Returns: the result of the blocking wait.
|
2005-01-06 18:17:12 +00:00
|
|
|
*
|
|
|
|
* MT safe.
|
2002-11-02 13:54:34 +00:00
|
|
|
*/
|
|
|
|
GstClockReturn
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_clock_id_wait (GstClockID id, GstClockTimeDiff * jitter)
|
2002-03-30 17:05:03 +00:00
|
|
|
{
|
|
|
|
GstClockEntry *entry;
|
2002-11-02 13:54:34 +00:00
|
|
|
GstClock *clock;
|
2005-01-06 18:17:12 +00:00
|
|
|
GstClockReturn res;
|
2002-11-02 13:54:34 +00:00
|
|
|
GstClockTime requested;
|
2002-12-19 21:31:03 +00:00
|
|
|
GstClockClass *cclass;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-11-02 13:54:34 +00:00
|
|
|
g_return_val_if_fail (id != NULL, GST_CLOCK_ERROR);
|
2002-03-30 17:05:03 +00:00
|
|
|
|
2002-11-02 13:54:34 +00:00
|
|
|
entry = (GstClockEntry *) id;
|
|
|
|
requested = GST_CLOCK_ENTRY_TIME (entry);
|
2002-11-27 20:47:39 +00:00
|
|
|
|
2005-01-06 18:17:12 +00:00
|
|
|
if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (requested)))
|
|
|
|
goto invalid_time;
|
2002-12-27 04:11:59 +00:00
|
|
|
|
Added more docs.
Original commit message from CVS:
* docs/design/part-clocks.txt:
* docs/design/part-events.txt:
* gst/elements/gstfakesrc.c: (gst_fakesrc_get_event_mask),
(gst_fakesrc_event_handler), (gst_fakesrc_loop),
(gst_fakesrc_activate):
* gst/gstclock.c: (gst_clock_id_ref), (gst_clock_id_unref),
(gst_clock_id_compare_func), (gst_clock_id_wait),
(gst_clock_id_wait_async), (gst_clock_init),
(gst_clock_adjust_unlocked), (gst_clock_get_time):
* gst/gstevent.c: (gst_event_new_discontinuous_valist),
(gst_event_discont_get_value), (gst_event_new_segment_seek):
* gst/gstevent.h:
* gst/gstpipeline.c: (gst_pipeline_init), (is_eos),
(pipeline_bus_handler), (gst_pipeline_change_state):
* gst/gstpipeline.h:
* gst/gstsystemclock.c: (gst_system_clock_init),
(gst_system_clock_async_thread),
(gst_system_clock_id_wait_unlocked),
(gst_system_clock_id_wait_async), (gst_system_clock_id_unschedule):
* libs/gst/dataprotocol/dataprotocol.c: (gst_dp_packet_from_event),
(gst_dp_event_from_packet):
* testsuite/clock/Makefile.am:
* testsuite/clock/clock4.c: (gst_clock_debug), (ok_callback),
(error_callback), (main):
Added more docs.
Remove more silly events.
Implement periodic clock notifications.
Add async testsuite.
2005-02-11 15:50:53 +00:00
|
|
|
if (G_UNLIKELY (entry->status == GST_CLOCK_UNSCHEDULED))
|
|
|
|
goto unscheduled;
|
|
|
|
|
2002-11-27 20:47:39 +00:00
|
|
|
clock = GST_CLOCK_ENTRY_CLOCK (entry);
|
2002-12-19 21:31:03 +00:00
|
|
|
cclass = GST_CLOCK_GET_CLASS (clock);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2005-01-06 18:17:12 +00:00
|
|
|
if (G_LIKELY (cclass->wait)) {
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2005-01-06 18:17:12 +00:00
|
|
|
GST_CAT_DEBUG (GST_CAT_CLOCK, "waiting on clock entry %p", id);
|
|
|
|
res = cclass->wait (clock, entry);
|
|
|
|
GST_CAT_DEBUG (GST_CAT_CLOCK, "done waiting entry %p", id);
|
2002-12-27 04:11:59 +00:00
|
|
|
|
2002-11-02 13:54:34 +00:00
|
|
|
if (jitter) {
|
2005-01-06 18:17:12 +00:00
|
|
|
GstClockTime now = gst_clock_get_time (clock);
|
|
|
|
|
2002-11-02 13:54:34 +00:00
|
|
|
*jitter = now - requested;
|
|
|
|
}
|
Added more docs.
Original commit message from CVS:
* docs/design/part-clocks.txt:
* docs/design/part-events.txt:
* gst/elements/gstfakesrc.c: (gst_fakesrc_get_event_mask),
(gst_fakesrc_event_handler), (gst_fakesrc_loop),
(gst_fakesrc_activate):
* gst/gstclock.c: (gst_clock_id_ref), (gst_clock_id_unref),
(gst_clock_id_compare_func), (gst_clock_id_wait),
(gst_clock_id_wait_async), (gst_clock_init),
(gst_clock_adjust_unlocked), (gst_clock_get_time):
* gst/gstevent.c: (gst_event_new_discontinuous_valist),
(gst_event_discont_get_value), (gst_event_new_segment_seek):
* gst/gstevent.h:
* gst/gstpipeline.c: (gst_pipeline_init), (is_eos),
(pipeline_bus_handler), (gst_pipeline_change_state):
* gst/gstpipeline.h:
* gst/gstsystemclock.c: (gst_system_clock_init),
(gst_system_clock_async_thread),
(gst_system_clock_id_wait_unlocked),
(gst_system_clock_id_wait_async), (gst_system_clock_id_unschedule):
* libs/gst/dataprotocol/dataprotocol.c: (gst_dp_packet_from_event),
(gst_dp_event_from_packet):
* testsuite/clock/Makefile.am:
* testsuite/clock/clock4.c: (gst_clock_debug), (ok_callback),
(error_callback), (main):
Added more docs.
Remove more silly events.
Implement periodic clock notifications.
Add async testsuite.
2005-02-11 15:50:53 +00:00
|
|
|
if (entry->type == GST_CLOCK_ENTRY_PERIODIC) {
|
|
|
|
entry->time += entry->interval;
|
|
|
|
}
|
2002-11-02 13:54:34 +00:00
|
|
|
|
|
|
|
if (clock->stats) {
|
|
|
|
gst_clock_update_stats (clock);
|
|
|
|
}
|
2005-01-06 18:17:12 +00:00
|
|
|
} else {
|
|
|
|
res = GST_CLOCK_UNSUPPORTED;
|
2002-11-02 13:54:34 +00:00
|
|
|
}
|
|
|
|
return res;
|
2005-01-06 18:17:12 +00:00
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
invalid_time:
|
|
|
|
{
|
|
|
|
GST_CAT_DEBUG (GST_CAT_CLOCK, "invalid time requested, returning _BADTIME");
|
|
|
|
return GST_CLOCK_BADTIME;
|
|
|
|
}
|
Added more docs.
Original commit message from CVS:
* docs/design/part-clocks.txt:
* docs/design/part-events.txt:
* gst/elements/gstfakesrc.c: (gst_fakesrc_get_event_mask),
(gst_fakesrc_event_handler), (gst_fakesrc_loop),
(gst_fakesrc_activate):
* gst/gstclock.c: (gst_clock_id_ref), (gst_clock_id_unref),
(gst_clock_id_compare_func), (gst_clock_id_wait),
(gst_clock_id_wait_async), (gst_clock_init),
(gst_clock_adjust_unlocked), (gst_clock_get_time):
* gst/gstevent.c: (gst_event_new_discontinuous_valist),
(gst_event_discont_get_value), (gst_event_new_segment_seek):
* gst/gstevent.h:
* gst/gstpipeline.c: (gst_pipeline_init), (is_eos),
(pipeline_bus_handler), (gst_pipeline_change_state):
* gst/gstpipeline.h:
* gst/gstsystemclock.c: (gst_system_clock_init),
(gst_system_clock_async_thread),
(gst_system_clock_id_wait_unlocked),
(gst_system_clock_id_wait_async), (gst_system_clock_id_unschedule):
* libs/gst/dataprotocol/dataprotocol.c: (gst_dp_packet_from_event),
(gst_dp_event_from_packet):
* testsuite/clock/Makefile.am:
* testsuite/clock/clock4.c: (gst_clock_debug), (ok_callback),
(error_callback), (main):
Added more docs.
Remove more silly events.
Implement periodic clock notifications.
Add async testsuite.
2005-02-11 15:50:53 +00:00
|
|
|
unscheduled:
|
|
|
|
{
|
|
|
|
GST_CAT_DEBUG (GST_CAT_CLOCK, "entry was unscheduled return _UNSCHEDULED");
|
|
|
|
return GST_CLOCK_UNSCHEDULED;
|
|
|
|
}
|
2002-11-02 13:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2002-12-14 13:02:16 +00:00
|
|
|
* gst_clock_id_wait_async:
|
|
|
|
* @id: a #GstClockID to wait on
|
2002-11-02 13:54:34 +00:00
|
|
|
* @func: The callback function
|
|
|
|
* @user_data: User data passed in the calback
|
|
|
|
*
|
2002-12-14 13:02:16 +00:00
|
|
|
* Register a callback on the given clockid with the given
|
2005-01-06 18:17:12 +00:00
|
|
|
* function and user_data. When passing an id with an invalid
|
|
|
|
* time to this function, the callback will be called immediatly
|
|
|
|
* with a time set to GST_CLOCK_TIME_NONE. The callback will
|
|
|
|
* be called when the time of the id has been reached.
|
2002-11-02 13:54:34 +00:00
|
|
|
*
|
2002-11-27 20:47:39 +00:00
|
|
|
* Returns: the result of the non blocking wait.
|
2005-01-06 18:17:12 +00:00
|
|
|
*
|
|
|
|
* MT safe.
|
2002-11-02 13:54:34 +00:00
|
|
|
*/
|
|
|
|
GstClockReturn
|
|
|
|
gst_clock_id_wait_async (GstClockID id,
|
2004-03-13 15:27:01 +00:00
|
|
|
GstClockCallback func, gpointer user_data)
|
2002-11-02 13:54:34 +00:00
|
|
|
{
|
|
|
|
GstClockEntry *entry;
|
|
|
|
GstClock *clock;
|
2005-01-06 18:17:12 +00:00
|
|
|
GstClockReturn res;
|
2002-12-19 21:31:03 +00:00
|
|
|
GstClockClass *cclass;
|
2005-01-06 18:17:12 +00:00
|
|
|
GstClockTime requested;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-11-02 13:54:34 +00:00
|
|
|
g_return_val_if_fail (id != NULL, GST_CLOCK_ERROR);
|
2002-11-27 20:47:39 +00:00
|
|
|
g_return_val_if_fail (func != NULL, GST_CLOCK_ERROR);
|
2002-11-02 13:54:34 +00:00
|
|
|
|
|
|
|
entry = (GstClockEntry *) id;
|
2005-01-06 18:17:12 +00:00
|
|
|
requested = GST_CLOCK_ENTRY_TIME (entry);
|
|
|
|
clock = GST_CLOCK_ENTRY_CLOCK (entry);
|
2002-11-02 13:54:34 +00:00
|
|
|
|
2005-01-06 18:17:12 +00:00
|
|
|
if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (requested)))
|
|
|
|
goto invalid_time;
|
2002-11-27 20:47:39 +00:00
|
|
|
|
Added more docs.
Original commit message from CVS:
* docs/design/part-clocks.txt:
* docs/design/part-events.txt:
* gst/elements/gstfakesrc.c: (gst_fakesrc_get_event_mask),
(gst_fakesrc_event_handler), (gst_fakesrc_loop),
(gst_fakesrc_activate):
* gst/gstclock.c: (gst_clock_id_ref), (gst_clock_id_unref),
(gst_clock_id_compare_func), (gst_clock_id_wait),
(gst_clock_id_wait_async), (gst_clock_init),
(gst_clock_adjust_unlocked), (gst_clock_get_time):
* gst/gstevent.c: (gst_event_new_discontinuous_valist),
(gst_event_discont_get_value), (gst_event_new_segment_seek):
* gst/gstevent.h:
* gst/gstpipeline.c: (gst_pipeline_init), (is_eos),
(pipeline_bus_handler), (gst_pipeline_change_state):
* gst/gstpipeline.h:
* gst/gstsystemclock.c: (gst_system_clock_init),
(gst_system_clock_async_thread),
(gst_system_clock_id_wait_unlocked),
(gst_system_clock_id_wait_async), (gst_system_clock_id_unschedule):
* libs/gst/dataprotocol/dataprotocol.c: (gst_dp_packet_from_event),
(gst_dp_event_from_packet):
* testsuite/clock/Makefile.am:
* testsuite/clock/clock4.c: (gst_clock_debug), (ok_callback),
(error_callback), (main):
Added more docs.
Remove more silly events.
Implement periodic clock notifications.
Add async testsuite.
2005-02-11 15:50:53 +00:00
|
|
|
if (G_UNLIKELY (entry->status == GST_CLOCK_UNSCHEDULED))
|
|
|
|
goto unscheduled;
|
|
|
|
|
2002-12-19 21:31:03 +00:00
|
|
|
cclass = GST_CLOCK_GET_CLASS (clock);
|
|
|
|
|
|
|
|
if (cclass->wait_async) {
|
|
|
|
entry->func = func;
|
|
|
|
entry->user_data = user_data;
|
|
|
|
|
|
|
|
res = cclass->wait_async (clock, entry);
|
2005-01-06 18:17:12 +00:00
|
|
|
} else {
|
|
|
|
res = GST_CLOCK_UNSUPPORTED;
|
2002-11-02 13:54:34 +00:00
|
|
|
}
|
|
|
|
return res;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2005-01-06 18:17:12 +00:00
|
|
|
/* ERRORS */
|
|
|
|
invalid_time:
|
|
|
|
{
|
|
|
|
(func) (clock, GST_CLOCK_TIME_NONE, id, user_data);
|
|
|
|
GST_CAT_DEBUG (GST_CAT_CLOCK, "invalid time requested, returning _BADTIME");
|
|
|
|
return GST_CLOCK_BADTIME;
|
|
|
|
}
|
Added more docs.
Original commit message from CVS:
* docs/design/part-clocks.txt:
* docs/design/part-events.txt:
* gst/elements/gstfakesrc.c: (gst_fakesrc_get_event_mask),
(gst_fakesrc_event_handler), (gst_fakesrc_loop),
(gst_fakesrc_activate):
* gst/gstclock.c: (gst_clock_id_ref), (gst_clock_id_unref),
(gst_clock_id_compare_func), (gst_clock_id_wait),
(gst_clock_id_wait_async), (gst_clock_init),
(gst_clock_adjust_unlocked), (gst_clock_get_time):
* gst/gstevent.c: (gst_event_new_discontinuous_valist),
(gst_event_discont_get_value), (gst_event_new_segment_seek):
* gst/gstevent.h:
* gst/gstpipeline.c: (gst_pipeline_init), (is_eos),
(pipeline_bus_handler), (gst_pipeline_change_state):
* gst/gstpipeline.h:
* gst/gstsystemclock.c: (gst_system_clock_init),
(gst_system_clock_async_thread),
(gst_system_clock_id_wait_unlocked),
(gst_system_clock_id_wait_async), (gst_system_clock_id_unschedule):
* libs/gst/dataprotocol/dataprotocol.c: (gst_dp_packet_from_event),
(gst_dp_event_from_packet):
* testsuite/clock/Makefile.am:
* testsuite/clock/clock4.c: (gst_clock_debug), (ok_callback),
(error_callback), (main):
Added more docs.
Remove more silly events.
Implement periodic clock notifications.
Add async testsuite.
2005-02-11 15:50:53 +00:00
|
|
|
unscheduled:
|
|
|
|
{
|
|
|
|
GST_CAT_DEBUG (GST_CAT_CLOCK, "entry was unscheduled return _UNSCHEDULED");
|
|
|
|
return GST_CLOCK_UNSCHEDULED;
|
|
|
|
}
|
2002-12-27 04:11:59 +00:00
|
|
|
}
|
|
|
|
|
2002-11-02 13:54:34 +00:00
|
|
|
/**
|
2002-12-14 13:02:16 +00:00
|
|
|
* gst_clock_id_unschedule:
|
|
|
|
* @id: The id to unschedule
|
2002-11-02 13:54:34 +00:00
|
|
|
*
|
2005-01-06 18:17:12 +00:00
|
|
|
* Cancel an outstanding request with the given ID. This can either
|
|
|
|
* be an outstanding async notification or a pending sync notification.
|
Added more docs.
Original commit message from CVS:
* docs/design/part-clocks.txt:
* docs/design/part-events.txt:
* gst/elements/gstfakesrc.c: (gst_fakesrc_get_event_mask),
(gst_fakesrc_event_handler), (gst_fakesrc_loop),
(gst_fakesrc_activate):
* gst/gstclock.c: (gst_clock_id_ref), (gst_clock_id_unref),
(gst_clock_id_compare_func), (gst_clock_id_wait),
(gst_clock_id_wait_async), (gst_clock_init),
(gst_clock_adjust_unlocked), (gst_clock_get_time):
* gst/gstevent.c: (gst_event_new_discontinuous_valist),
(gst_event_discont_get_value), (gst_event_new_segment_seek):
* gst/gstevent.h:
* gst/gstpipeline.c: (gst_pipeline_init), (is_eos),
(pipeline_bus_handler), (gst_pipeline_change_state):
* gst/gstpipeline.h:
* gst/gstsystemclock.c: (gst_system_clock_init),
(gst_system_clock_async_thread),
(gst_system_clock_id_wait_unlocked),
(gst_system_clock_id_wait_async), (gst_system_clock_id_unschedule):
* libs/gst/dataprotocol/dataprotocol.c: (gst_dp_packet_from_event),
(gst_dp_event_from_packet):
* testsuite/clock/Makefile.am:
* testsuite/clock/clock4.c: (gst_clock_debug), (ok_callback),
(error_callback), (main):
Added more docs.
Remove more silly events.
Implement periodic clock notifications.
Add async testsuite.
2005-02-11 15:50:53 +00:00
|
|
|
* After this call, the @id cannot be used anymore to receive sync or
|
|
|
|
* async notifications, you need to create a new GstClockID.
|
2005-01-06 18:17:12 +00:00
|
|
|
*
|
|
|
|
* MT safe.
|
2002-11-02 13:54:34 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_clock_id_unschedule (GstClockID id)
|
|
|
|
{
|
|
|
|
GstClockEntry *entry;
|
|
|
|
GstClock *clock;
|
2002-12-19 21:31:03 +00:00
|
|
|
GstClockClass *cclass;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-11-02 13:54:34 +00:00
|
|
|
g_return_if_fail (id != NULL);
|
|
|
|
|
|
|
|
entry = (GstClockEntry *) id;
|
|
|
|
clock = entry->clock;
|
2002-03-30 17:05:03 +00:00
|
|
|
|
2002-12-19 21:31:03 +00:00
|
|
|
cclass = GST_CLOCK_GET_CLASS (clock);
|
|
|
|
|
|
|
|
if (cclass->unschedule)
|
|
|
|
cclass->unschedule (clock, entry);
|
2002-03-30 17:05:03 +00:00
|
|
|
}
|
|
|
|
|
2002-11-02 13:54:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GstClock abstract base class implementation
|
|
|
|
*/
|
2002-02-03 20:07:09 +00:00
|
|
|
GType
|
|
|
|
gst_clock_get_type (void)
|
2000-11-11 15:13:50 +00:00
|
|
|
{
|
2002-02-03 20:07:09 +00:00
|
|
|
static GType clock_type = 0;
|
|
|
|
|
|
|
|
if (!clock_type) {
|
|
|
|
static const GTypeInfo clock_info = {
|
2002-03-30 17:05:03 +00:00
|
|
|
sizeof (GstClockClass),
|
2002-02-03 20:07:09 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
(GClassInitFunc) gst_clock_class_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2002-03-30 17:05:03 +00:00
|
|
|
sizeof (GstClock),
|
2004-04-09 19:05:03 +00:00
|
|
|
0,
|
2002-02-03 20:07:09 +00:00
|
|
|
(GInstanceInitFunc) gst_clock_init,
|
|
|
|
NULL
|
|
|
|
};
|
2004-03-15 19:27:17 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
clock_type = g_type_register_static (GST_TYPE_OBJECT, "GstClock",
|
2004-03-15 19:27:17 +00:00
|
|
|
&clock_info, G_TYPE_FLAG_ABSTRACT);
|
2002-02-03 20:07:09 +00:00
|
|
|
}
|
|
|
|
return clock_type;
|
|
|
|
}
|
2001-01-29 00:06:02 +00:00
|
|
|
|
2002-02-03 20:07:09 +00:00
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_clock_class_init (GstClockClass * klass)
|
2002-02-03 20:07:09 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstObjectClass *gstobject_class;
|
2001-01-29 00:06:02 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstobject_class = (GstObjectClass *) klass;
|
2001-01-29 00:06:02 +00:00
|
|
|
|
2002-02-03 20:07:09 +00:00
|
|
|
parent_class = g_type_class_ref (GST_TYPE_OBJECT);
|
2002-03-30 17:05:03 +00:00
|
|
|
|
2002-03-31 14:04:50 +00:00
|
|
|
if (!g_thread_supported ())
|
|
|
|
g_thread_init (NULL);
|
|
|
|
|
2002-07-08 19:22:02 +00:00
|
|
|
_gst_clock_entries_chunk = gst_mem_chunk_new ("GstClockEntries",
|
2004-03-13 15:27:01 +00:00
|
|
|
sizeof (GstClockEntry), sizeof (GstClockEntry) * 32, G_ALLOC_AND_FREE);
|
2002-11-02 13:54:34 +00:00
|
|
|
|
2003-02-10 20:32:32 +00:00
|
|
|
#ifndef GST_DISABLE_TRACE
|
2004-03-13 15:27:01 +00:00
|
|
|
_gst_clock_entry_trace =
|
|
|
|
gst_alloc_trace_register (GST_CLOCK_ENTRY_TRACE_NAME);
|
2003-02-10 20:32:32 +00:00
|
|
|
#endif
|
2002-11-02 13:54:34 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_clock_dispose);
|
2002-11-02 13:54:34 +00:00
|
|
|
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_clock_set_property);
|
|
|
|
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_clock_get_property);
|
|
|
|
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_STATS,
|
2004-03-13 15:27:01 +00:00
|
|
|
g_param_spec_boolean ("stats", "Stats", "Enable clock stats",
|
2004-03-15 19:27:17 +00:00
|
|
|
FALSE, G_PARAM_READWRITE));
|
2000-04-09 21:38:17 +00:00
|
|
|
}
|
|
|
|
|
2002-02-03 20:07:09 +00:00
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_clock_init (GstClock * clock)
|
2000-11-11 15:13:50 +00:00
|
|
|
{
|
Clock updates, remove deprecated methods, simplify operations.
Original commit message from CVS:
* gst/gstbin.c: (gst_bin_set_index), (gst_bin_set_clock),
(gst_bin_set_bus), (gst_bin_set_scheduler), (gst_bin_add_func),
(gst_bin_iterate_elements), (gst_bin_change_state),
(gst_bin_get_by_name_recurse_up):
* gst/gstbuffer.c: (gst_buffer_default_copy):
* gst/gstbuffer.h:
* gst/gstclock.c: (gst_clock_init), (gst_clock_get_time),
(gst_clock_set_time_adjust):
* gst/gstclock.h:
* gst/gstelement.h:
* gst/gstevent.h:
* gst/gstinfo.h:
* gst/gstpipeline.c: (is_eos), (pipeline_bus_handler),
(gst_pipeline_change_state):
* gst/gstpipeline.h:
* gst/gstsystemclock.c: (gst_system_clock_wait):
* gst/gstutils.c: (gst_element_finish_preroll),
(gst_element_get_compatible_pad_filtered),
(gst_element_link_pads_filtered), (gst_element_unlink):
* gst/registries/gstxmlregistry.c:
(gst_xml_registry_parse_element_factory),
(gst_xml_registry_end_element):
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer):
Clock updates, remove deprecated methods, simplify operations.
Fix clocking and time management in GstPipeline.
Preroll also occurs when going from playing to paused.
2004-12-31 10:44:46 +00:00
|
|
|
clock->adjust = 0;
|
2002-03-30 17:05:03 +00:00
|
|
|
clock->last_time = 0;
|
|
|
|
clock->entries = NULL;
|
2005-01-06 18:17:12 +00:00
|
|
|
clock->entries_changed = g_cond_new ();
|
2002-11-02 13:54:34 +00:00
|
|
|
clock->flags = 0;
|
|
|
|
clock->stats = FALSE;
|
2000-04-09 21:38:17 +00:00
|
|
|
}
|
|
|
|
|
2003-02-02 19:21:06 +00:00
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_clock_dispose (GObject * object)
|
2003-02-02 19:21:06 +00:00
|
|
|
{
|
2005-01-06 18:17:12 +00:00
|
|
|
GstClock *clock = GST_CLOCK (object);
|
|
|
|
|
|
|
|
g_cond_free (clock->entries_changed);
|
2003-02-02 19:21:06 +00:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
2002-03-31 14:04:50 +00:00
|
|
|
/**
|
2002-11-02 13:54:34 +00:00
|
|
|
* gst_clock_set_resolution
|
|
|
|
* @clock: The clock set the resolution on
|
|
|
|
* @resolution: The resolution to set
|
2002-03-31 14:04:50 +00:00
|
|
|
*
|
2002-11-02 13:54:34 +00:00
|
|
|
* Set the accuracy of the clock.
|
|
|
|
*
|
|
|
|
* Returns: the new resolution of the clock.
|
2002-03-31 14:04:50 +00:00
|
|
|
*/
|
2002-11-02 13:54:34 +00:00
|
|
|
guint64
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_clock_set_resolution (GstClock * clock, guint64 resolution)
|
2000-11-11 15:13:50 +00:00
|
|
|
{
|
2002-12-19 21:31:03 +00:00
|
|
|
GstClockClass *cclass;
|
|
|
|
|
2003-02-10 20:32:32 +00:00
|
|
|
g_return_val_if_fail (GST_IS_CLOCK (clock), G_GINT64_CONSTANT (0));
|
|
|
|
g_return_val_if_fail (resolution != 0, G_GINT64_CONSTANT (0));
|
2002-03-30 17:05:03 +00:00
|
|
|
|
2002-12-19 21:31:03 +00:00
|
|
|
cclass = GST_CLOCK_GET_CLASS (clock);
|
|
|
|
|
|
|
|
if (cclass->change_resolution)
|
2004-03-13 15:27:01 +00:00
|
|
|
clock->resolution =
|
2004-03-15 19:27:17 +00:00
|
|
|
cclass->change_resolution (clock, clock->resolution, resolution);
|
2002-02-03 20:07:09 +00:00
|
|
|
|
2002-11-02 13:54:34 +00:00
|
|
|
return clock->resolution;
|
|
|
|
}
|
2002-02-03 20:07:09 +00:00
|
|
|
|
2002-11-02 13:54:34 +00:00
|
|
|
/**
|
|
|
|
* gst_clock_get_resolution
|
|
|
|
* @clock: The clock get the resolution of
|
|
|
|
*
|
|
|
|
* Get the accuracy of the clock.
|
|
|
|
*
|
|
|
|
* Returns: the resolution of the clock in microseconds.
|
2005-01-18 10:52:08 +00:00
|
|
|
*
|
|
|
|
* MT safe.
|
2002-11-02 13:54:34 +00:00
|
|
|
*/
|
|
|
|
guint64
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_clock_get_resolution (GstClock * clock)
|
2002-11-02 13:54:34 +00:00
|
|
|
{
|
2002-12-19 21:31:03 +00:00
|
|
|
GstClockClass *cclass;
|
|
|
|
|
2003-02-10 20:32:32 +00:00
|
|
|
g_return_val_if_fail (GST_IS_CLOCK (clock), G_GINT64_CONSTANT (0));
|
2002-11-02 13:54:34 +00:00
|
|
|
|
2002-12-19 21:31:03 +00:00
|
|
|
cclass = GST_CLOCK_GET_CLASS (clock);
|
|
|
|
|
|
|
|
if (cclass->get_resolution)
|
|
|
|
return cclass->get_resolution (clock);
|
2002-11-02 13:54:34 +00:00
|
|
|
|
2003-02-10 20:32:32 +00:00
|
|
|
return G_GINT64_CONSTANT (1);
|
2000-04-09 21:38:17 +00:00
|
|
|
}
|
|
|
|
|
2005-01-26 10:56:09 +00:00
|
|
|
/**
|
|
|
|
* gst_clock_adjust_unlocked
|
|
|
|
* @clock: a #GstClock to use
|
|
|
|
* @internal: a clock time
|
|
|
|
*
|
|
|
|
* Converts the given @internal clock time to the real time, adjusting
|
|
|
|
* and making sure that the returned time is increasing.
|
|
|
|
* This function should be called with the clock lock held.
|
|
|
|
*
|
|
|
|
* Returns: the converted time of the clock.
|
|
|
|
*
|
|
|
|
* MT safe.
|
|
|
|
*/
|
|
|
|
GstClockTime
|
|
|
|
gst_clock_adjust_unlocked (GstClock * clock, GstClockTime internal)
|
|
|
|
{
|
|
|
|
GstClockTime ret;
|
|
|
|
|
|
|
|
ret = internal + clock->adjust;
|
|
|
|
/* make sure the time is increasing, else return last_time */
|
|
|
|
if ((gint64) ret < (gint64) clock->last_time) {
|
|
|
|
ret = clock->last_time;
|
|
|
|
} else {
|
|
|
|
clock->last_time = ret;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2002-03-31 14:04:50 +00:00
|
|
|
/**
|
|
|
|
* gst_clock_get_time
|
2002-04-23 15:01:56 +00:00
|
|
|
* @clock: a #GstClock to query
|
2002-03-31 14:04:50 +00:00
|
|
|
*
|
2002-04-23 15:01:56 +00:00
|
|
|
* Gets the current time of the given clock. The time is always
|
2002-03-31 14:04:50 +00:00
|
|
|
* monotonically increasing.
|
2002-12-11 21:33:07 +00:00
|
|
|
*
|
2005-01-06 18:17:12 +00:00
|
|
|
* Returns: the time of the clock. Or GST_CLOCK_TIME_NONE when
|
|
|
|
* giving wrong input.
|
|
|
|
*
|
|
|
|
* MT safe.
|
2002-03-31 14:04:50 +00:00
|
|
|
*/
|
2002-02-03 20:07:09 +00:00
|
|
|
GstClockTime
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_clock_get_time (GstClock * clock)
|
2002-02-03 20:07:09 +00:00
|
|
|
{
|
2005-01-06 18:17:12 +00:00
|
|
|
GstClockTime ret;
|
2004-01-16 22:56:34 +00:00
|
|
|
GstClockClass *cclass;
|
2002-03-30 17:05:03 +00:00
|
|
|
|
2005-01-06 18:17:12 +00:00
|
|
|
g_return_val_if_fail (GST_IS_CLOCK (clock), GST_CLOCK_TIME_NONE);
|
2002-02-03 20:07:09 +00:00
|
|
|
|
2004-01-16 22:56:34 +00:00
|
|
|
cclass = GST_CLOCK_GET_CLASS (clock);
|
2002-12-19 21:31:03 +00:00
|
|
|
|
2004-01-16 22:56:34 +00:00
|
|
|
if (cclass->get_internal_time) {
|
2005-01-06 18:17:12 +00:00
|
|
|
ret = cclass->get_internal_time (clock);
|
|
|
|
} else {
|
|
|
|
ret = G_GINT64_CONSTANT (0);
|
2004-01-16 22:56:34 +00:00
|
|
|
}
|
2005-01-26 10:56:09 +00:00
|
|
|
GST_CAT_DEBUG (GST_CAT_CLOCK, "internal time %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (ret));
|
2005-01-06 18:17:12 +00:00
|
|
|
|
|
|
|
GST_LOCK (clock);
|
2005-01-26 10:56:09 +00:00
|
|
|
ret = gst_clock_adjust_unlocked (clock, ret);
|
2005-01-06 18:17:12 +00:00
|
|
|
GST_UNLOCK (clock);
|
2002-02-03 20:07:09 +00:00
|
|
|
|
2005-01-26 10:56:09 +00:00
|
|
|
GST_CAT_DEBUG (GST_CAT_CLOCK, "adjusted time %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (ret));
|
|
|
|
|
2002-03-30 17:05:03 +00:00
|
|
|
return ret;
|
2002-02-03 20:07:09 +00:00
|
|
|
}
|
|
|
|
|
Clock updates, remove deprecated methods, simplify operations.
Original commit message from CVS:
* gst/gstbin.c: (gst_bin_set_index), (gst_bin_set_clock),
(gst_bin_set_bus), (gst_bin_set_scheduler), (gst_bin_add_func),
(gst_bin_iterate_elements), (gst_bin_change_state),
(gst_bin_get_by_name_recurse_up):
* gst/gstbuffer.c: (gst_buffer_default_copy):
* gst/gstbuffer.h:
* gst/gstclock.c: (gst_clock_init), (gst_clock_get_time),
(gst_clock_set_time_adjust):
* gst/gstclock.h:
* gst/gstelement.h:
* gst/gstevent.h:
* gst/gstinfo.h:
* gst/gstpipeline.c: (is_eos), (pipeline_bus_handler),
(gst_pipeline_change_state):
* gst/gstpipeline.h:
* gst/gstsystemclock.c: (gst_system_clock_wait):
* gst/gstutils.c: (gst_element_finish_preroll),
(gst_element_get_compatible_pad_filtered),
(gst_element_link_pads_filtered), (gst_element_unlink):
* gst/registries/gstxmlregistry.c:
(gst_xml_registry_parse_element_factory),
(gst_xml_registry_end_element):
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer):
Clock updates, remove deprecated methods, simplify operations.
Fix clocking and time management in GstPipeline.
Preroll also occurs when going from playing to paused.
2004-12-31 10:44:46 +00:00
|
|
|
/**
|
|
|
|
* gst_clock_set_time_adjust
|
|
|
|
* @clock: a #GstClock to adjust
|
|
|
|
* @adjust: the adjust value
|
|
|
|
*
|
|
|
|
* Adjusts the current time of the clock with the adjust value.
|
|
|
|
* A positive value moves the clock forwards and a backwards value
|
|
|
|
* moves it backwards. Note that _get_time() always returns
|
|
|
|
* increasing values so when you move the clock backwards, _get_time()
|
|
|
|
* will report the previous value until the clock catches up.
|
2005-01-06 18:17:12 +00:00
|
|
|
*
|
|
|
|
* MT safe.
|
Clock updates, remove deprecated methods, simplify operations.
Original commit message from CVS:
* gst/gstbin.c: (gst_bin_set_index), (gst_bin_set_clock),
(gst_bin_set_bus), (gst_bin_set_scheduler), (gst_bin_add_func),
(gst_bin_iterate_elements), (gst_bin_change_state),
(gst_bin_get_by_name_recurse_up):
* gst/gstbuffer.c: (gst_buffer_default_copy):
* gst/gstbuffer.h:
* gst/gstclock.c: (gst_clock_init), (gst_clock_get_time),
(gst_clock_set_time_adjust):
* gst/gstclock.h:
* gst/gstelement.h:
* gst/gstevent.h:
* gst/gstinfo.h:
* gst/gstpipeline.c: (is_eos), (pipeline_bus_handler),
(gst_pipeline_change_state):
* gst/gstpipeline.h:
* gst/gstsystemclock.c: (gst_system_clock_wait):
* gst/gstutils.c: (gst_element_finish_preroll),
(gst_element_get_compatible_pad_filtered),
(gst_element_link_pads_filtered), (gst_element_unlink):
* gst/registries/gstxmlregistry.c:
(gst_xml_registry_parse_element_factory),
(gst_xml_registry_end_element):
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer):
Clock updates, remove deprecated methods, simplify operations.
Fix clocking and time management in GstPipeline.
Preroll also occurs when going from playing to paused.
2004-12-31 10:44:46 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_clock_set_time_adjust (GstClock * clock, GstClockTime adjust)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_CLOCK (clock));
|
|
|
|
|
2002-03-30 17:05:03 +00:00
|
|
|
GST_LOCK (clock);
|
2005-01-06 18:17:12 +00:00
|
|
|
clock->adjust = adjust;
|
2002-03-30 17:05:03 +00:00
|
|
|
GST_UNLOCK (clock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_clock_update_stats (GstClock * clock)
|
2002-03-30 17:05:03 +00:00
|
|
|
{
|
2002-02-03 20:07:09 +00:00
|
|
|
}
|
|
|
|
|
2002-11-02 13:54:34 +00:00
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_clock_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
2002-02-03 20:07:09 +00:00
|
|
|
{
|
2002-11-02 13:54:34 +00:00
|
|
|
GstClock *clock;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-11-02 13:54:34 +00:00
|
|
|
clock = GST_CLOCK (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case ARG_STATS:
|
|
|
|
clock->stats = g_value_get_boolean (value);
|
gst/gstclock.*: deprecate old interface and disable functions that aren't in use anymore.
Original commit message from CVS:
2004-01-13 Benjamin Otte <in7y118@public.uni-hamburg.de>
* gst/gstclock.c: (gst_clock_class_init), (gst_clock_init),
(gst_clock_set_speed), (gst_clock_set_active),
(gst_clock_is_active), (gst_clock_reset),
(gst_clock_handle_discont):
* gst/gstclock.h:
deprecate old interface and disable functions that aren't in use
anymore.
* gst/gstelement.h:
* gst/gstelement.c: (gst_element_get_time), (gst_element_wait),
(gst_element_set_time), (gst_element_adjust_time):
add concept of "element time" and functions to get/set this time.
* gst/gstelement.c: (gst_element_change_state):
update element time correctly.
* gst/gstelement.c: (gst_element_get_compatible_pad_filtered):
This is a debug message, not a g_critical.
* gst/gstpad.c: (gst_pad_event_default):
handle discontinuous events right with element time.
* gst/gstscheduler.c: (gst_scheduler_state_transition):
update to clocking fixes.
set clocks on elements in READY=>PAUSED. The old behaviour caused
a wrong element time on the first element that started playing.
* gst/schedulers/gstbasicscheduler.c:
(gst_basic_scheduler_class_init):
* gst/schedulers/gstoptimalscheduler.c:
(gst_opt_scheduler_class_init):
remove code that just implements the default behaviour.
* gst/elements/gstfakesink.c: (gst_fakesink_chain):
update to use new clocking functions
* testsuite/clock/clock1.c: (gst_clock_debug), (main):
* testsuite/clock/clock2.c: (gst_clock_debug), (main):
update to test new element time.
* gst/autoplug/gstspideridentity.c: (gst_spider_identity_getcaps):
use _get_allowed_caps instead of _get_caps. This catches filtered
caps correctly.
* testsuite/debug/commandline.c:
update for new GST_DEBUG syntax.
* testsuite/threads/Makefile.am:
disable a test that only works sometimes.
2004-01-14 00:46:48 +00:00
|
|
|
g_object_notify (object, "stats");
|
2002-11-02 13:54:34 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
2004-03-13 15:27:01 +00:00
|
|
|
}
|
2000-04-09 21:38:17 +00:00
|
|
|
}
|
2002-02-03 20:07:09 +00:00
|
|
|
|
2002-11-02 13:54:34 +00:00
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_clock_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec)
|
2002-02-03 20:07:09 +00:00
|
|
|
{
|
2002-11-02 13:54:34 +00:00
|
|
|
GstClock *clock;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-11-02 13:54:34 +00:00
|
|
|
clock = GST_CLOCK (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case ARG_STATS:
|
|
|
|
g_value_set_boolean (value, clock->stats);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
2004-03-13 15:27:01 +00:00
|
|
|
}
|
2002-02-03 20:07:09 +00:00
|
|
|
}
|