gst/silence/gstsilence.*: Add sync property.

Original commit message from CVS:
* gst/silence/gstsilence.c: (gst_silence_class_init),
(gst_silence_set_clock), (gst_silence_get),
(gst_silence_set_property), (gst_silence_get_property):
* gst/silence/gstsilence.h: Add sync property.
* gst/sine/gstsinesrc.c: (gst_sinesrc_class_init),
(gst_sinesrc_init), (gst_sinesrc_set_clock), (gst_sinesrc_get),
(gst_sinesrc_set_property), (gst_sinesrc_get_property):
* gst/sine/gstsinesrc.h: Add sync property.
This commit is contained in:
David Schleef 2004-02-14 02:17:40 +00:00
parent 9bdec23a91
commit bb977a97a3
3 changed files with 40 additions and 0 deletions

View file

@ -1,3 +1,14 @@
2004-02-13 David Schleef <ds@schleef.org>
* gst/silence/gstsilence.c: (gst_silence_class_init),
(gst_silence_set_clock), (gst_silence_get),
(gst_silence_set_property), (gst_silence_get_property):
* gst/silence/gstsilence.h: Add sync property.
* gst/sine/gstsinesrc.c: (gst_sinesrc_class_init),
(gst_sinesrc_init), (gst_sinesrc_set_clock), (gst_sinesrc_get),
(gst_sinesrc_set_property), (gst_sinesrc_get_property):
* gst/sine/gstsinesrc.h: Add sync property.
2004-02-13 David Schleef <ds@schleef.org>
* gst/intfloat/gstint2float.c: (conv_f32_s16),

View file

@ -52,6 +52,7 @@ enum {
ARG_SAMPLES_PER_BUFFER,
ARG_FREQ,
ARG_VOLUME,
ARG_SYNC
};
static GstStaticPadTemplate gst_sinesrc_src_template =
@ -86,6 +87,7 @@ static GstPadLinkReturn
const GstCaps *caps);
static GstElementStateReturn
gst_sinesrc_change_state (GstElement *element);
static void gst_sinesrc_set_clock (GstElement *element, GstClock *clock);
static void gst_sinesrc_update_freq (const GValue *value,
gpointer data);
@ -159,12 +161,16 @@ gst_sinesrc_class_init (GstSineSrcClass *klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VOLUME,
g_param_spec_double ("volume", "Volume", "Volume",
0.0, 1.0, 0.8, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SYNC,
g_param_spec_boolean ("sync", "Sync", "Synchronize to clock",
TRUE, G_PARAM_READWRITE));
gobject_class->set_property = gst_sinesrc_set_property;
gobject_class->get_property = gst_sinesrc_get_property;
gobject_class->dispose = gst_sinesrc_dispose;
gstelement_class->change_state = gst_sinesrc_change_state;
gstelement_class->set_clock = gst_sinesrc_set_clock;
}
static void
@ -182,6 +188,7 @@ gst_sinesrc_init (GstSineSrc *src)
src->samplerate = 44100;
src->volume = 1.0;
src->freq = 440.0;
src->sync = TRUE;
src->table_pos = 0.0;
src->table_size = 1024;
@ -228,6 +235,14 @@ gst_sinesrc_dispose (GObject *object)
GST_CALL_PARENT (G_OBJECT_CLASS, dispose, (object));
}
static void
gst_sinesrc_set_clock (GstElement *element, GstClock *clock)
{
GstSineSrc *sinesrc = GST_SINESRC (element);
gst_object_replace ((GstObject **)&sinesrc->clock, (GstObject *)clock);
}
static GstCaps *
gst_sinesrc_src_fixate (GstPad *pad, const GstCaps *caps)
{
@ -345,6 +360,11 @@ gst_sinesrc_get (GstPad *pad)
buf = gst_buffer_new_and_alloc (src->samples_per_buffer * 2);
GST_BUFFER_TIMESTAMP(buf) = src->timestamp;
if (src->sync) {
if (src->clock) {
gst_element_wait (GST_ELEMENT(src), GST_BUFFER_TIMESTAMP (buf));
}
}
GST_BUFFER_OFFSET (buf) = src->offset;
GST_BUFFER_DURATION (buf) = tdiff;
@ -430,6 +450,9 @@ gst_sinesrc_set_property (GObject *object, guint prop_id,
gst_dpman_bypass_dparam (src->dpman, "volume");
src->volume = g_value_get_double (value);
break;
case ARG_SYNC:
src->sync = g_value_get_boolean (value);
break;
default:
break;
}
@ -458,6 +481,9 @@ gst_sinesrc_get_property (GObject *object, guint prop_id,
case ARG_VOLUME:
g_value_set_double (value, src->volume);
break;
case ARG_SYNC:
g_value_set_boolean (value, src->sync);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;

View file

@ -57,6 +57,7 @@ struct _GstSineSrc {
/* parameters */
gdouble volume;
gdouble freq;
gboolean sync;
/* lookup table data */
gdouble *table_data;
@ -79,6 +80,8 @@ struct _GstSineSrc {
gdouble accumulator;
gboolean tags_pushed;
GstClock *clock;
};
struct _GstSineSrcClass {