libs/gst/net/gstnettimeprovider.c (gst_net_time_provider_class_init, gst_net_time_provider_init) (gst_net_time_provid...

Original commit message from CVS:
2005-12-12  Andy Wingo  <wingo@pobox.com>

* libs/gst/net/gstnettimeprovider.c
(gst_net_time_provider_class_init, gst_net_time_provider_init)
(gst_net_time_provider_set_property)
(gst_net_time_provider_get_property): Export "active" as a GObject
property.
(gst_net_time_provider_thread): Only respond to time queries if
the time provider is active.

* libs/gst/net/gstnettimeprovider.h: Add an "active" boolean to
NetTimeProvider, preserving binary compat.
This commit is contained in:
Andy Wingo 2005-12-12 15:02:02 +00:00
parent a84923e6cc
commit 6c96798fd2
3 changed files with 42 additions and 8 deletions

View file

@ -1,3 +1,16 @@
2005-12-12 Andy Wingo <wingo@pobox.com>
* libs/gst/net/gstnettimeprovider.c
(gst_net_time_provider_class_init, gst_net_time_provider_init)
(gst_net_time_provider_set_property)
(gst_net_time_provider_get_property): Export "active" as a GObject
property.
(gst_net_time_provider_thread): Only respond to time queries if
the time provider is active.
* libs/gst/net/gstnettimeprovider.h: Add an "active" boolean to
NetTimeProvider, preserving binary compat.
2005-12-12 Stefan Kost <ensonic@users.sf.net> 2005-12-12 Stefan Kost <ensonic@users.sf.net>
* tests/examples/controller/audio-example.c: (main): * tests/examples/controller/audio-example.c: (main):

View file

@ -74,12 +74,15 @@ G_STMT_START { \
#define DEFAULT_ADDRESS "0.0.0.0" #define DEFAULT_ADDRESS "0.0.0.0"
#define DEFAULT_PORT 5637 #define DEFAULT_PORT 5637
#define IS_ACTIVE(self) (g_atomic_int_get (&((self)->active.active)))
enum enum
{ {
PROP_0, PROP_0,
PROP_PORT, PROP_PORT,
PROP_ADDRESS, PROP_ADDRESS,
PROP_CLOCK PROP_CLOCK,
PROP_ACTIVE
/* FILL ME */ /* FILL ME */
}; };
@ -129,6 +132,10 @@ gst_net_time_provider_class_init (GstNetTimeProviderClass * klass)
g_param_spec_object ("clock", "Clock", g_param_spec_object ("clock", "Clock",
"The clock to export over the network", GST_TYPE_CLOCK, "The clock to export over the network", GST_TYPE_CLOCK,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_ACTIVE,
g_param_spec_boolean ("active", "Active",
"TRUE if the clock will respond to queries over the network", TRUE,
G_PARAM_READWRITE));
} }
static void static void
@ -139,6 +146,7 @@ gst_net_time_provider_init (GstNetTimeProvider * self,
self->sock = -1; self->sock = -1;
self->address = g_strdup (DEFAULT_ADDRESS); self->address = g_strdup (DEFAULT_ADDRESS);
self->thread = NULL; self->thread = NULL;
self->active.active = TRUE;
READ_SOCKET (self) = -1; READ_SOCKET (self) = -1;
WRITE_SOCKET (self) = -1; WRITE_SOCKET (self) = -1;
@ -234,12 +242,14 @@ gst_net_time_provider_thread (gpointer data)
if (!packet) if (!packet)
goto receive_error; goto receive_error;
/* do what we were asked to and send the packet back */ if (IS_ACTIVE (self)) {
packet->remote_time = gst_clock_get_time (self->clock); /* do what we were asked to and send the packet back */
packet->remote_time = gst_clock_get_time (self->clock);
/* ignore errors */ /* ignore errors */
gst_net_time_packet_send (packet, self->sock, gst_net_time_packet_send (packet, self->sock,
(struct sockaddr *) &tmpaddr, len); (struct sockaddr *) &tmpaddr, len);
}
g_free (packet); g_free (packet);
@ -297,6 +307,9 @@ gst_net_time_provider_set_property (GObject * object, guint prop_id,
gst_object_replace ((GstObject **) & self->clock, gst_object_replace ((GstObject **) & self->clock,
(GstObject *) g_value_get_object (value)); (GstObject *) g_value_get_object (value));
break; break;
case PROP_ACTIVE:
gst_atomic_int_set (&self->active.active, g_value_get_boolean (value));
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -319,6 +332,9 @@ gst_net_time_provider_get_property (GObject * object, guint prop_id,
case PROP_CLOCK: case PROP_CLOCK:
g_value_set_object (value, self->clock); g_value_set_object (value, self->clock);
break; break;
case PROP_ACTIVE:
g_value_set_boolean (value, IS_ACTIVE (self));
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;

View file

@ -68,8 +68,13 @@ struct _GstNetTimeProvider {
GstClock *clock; GstClock *clock;
/*< private >*/ union {
gpointer _gst_reserved[GST_PADDING]; gpointer _gst_reserved1;
/* has to be a gint, we use atomic ops here */
gint active;
} active;
gpointer _gst_reserved[GST_PADDING - 1];
}; };
struct _GstNetTimeProviderClass { struct _GstNetTimeProviderClass {