volume param now uses the direct instead of the callback method to update

Original commit message from CVS:
volume param now uses the direct instead of the callback method to update
This commit is contained in:
Steve Baker 2001-09-16 16:54:34 +00:00
parent ed02a662ae
commit dc2006465a
4 changed files with 14 additions and 60 deletions

View file

@ -83,11 +83,9 @@ static void gst_sinesrc_get_property (GObject *object, guint prop_id,
//static void gst_sinesrc_close_audio(GstSineSrc *src); //static void gst_sinesrc_close_audio(GstSineSrc *src);
//static gboolean gst_sinesrc_open_audio(GstSineSrc *src); //static gboolean gst_sinesrc_open_audio(GstSineSrc *src);
static void gst_sinesrc_update_volume(GValue *value, gpointer data);
static void gst_sinesrc_update_freq(GValue *value, gpointer data); static void gst_sinesrc_update_freq(GValue *value, gpointer data);
static void gst_sinesrc_populate_sinetable (GstSineSrc *src); static void gst_sinesrc_populate_sinetable (GstSineSrc *src);
static inline void gst_sinesrc_update_table_inc (GstSineSrc *src); static inline void gst_sinesrc_update_table_inc (GstSineSrc *src);
static inline void gst_sinesrc_update_vol_scale (GstSineSrc *src);
static void gst_sinesrc_force_caps (GstSineSrc *src); static void gst_sinesrc_force_caps (GstSineSrc *src);
static GstBuffer* gst_sinesrc_get (GstPad *pad); static GstBuffer* gst_sinesrc_get (GstPad *pad);
@ -174,6 +172,7 @@ gst_sinesrc_init (GstSineSrc *src)
src->seq = 0; src->seq = 0;
dpman = gst_dpman_new ("sinesrc_dpman", GST_ELEMENT(src)); dpman = gst_dpman_new ("sinesrc_dpman", GST_ELEMENT(src));
gst_dpman_add_required_dparam_callback (dpman, "freq", G_TYPE_FLOAT, gst_sinesrc_update_freq, src); gst_dpman_add_required_dparam_callback (dpman, "freq", G_TYPE_FLOAT, gst_sinesrc_update_freq, src);
spec = gst_dpman_get_dparam_spec (dpman, "freq"); spec = gst_dpman_get_dparam_spec (dpman, "freq");
g_value_set_float(spec->min_val, 10.0); g_value_set_float(spec->min_val, 10.0);
@ -182,10 +181,10 @@ gst_sinesrc_init (GstSineSrc *src)
spec->unit_name = "frequency"; spec->unit_name = "frequency";
spec->is_log = TRUE; spec->is_log = TRUE;
gst_dpman_add_required_dparam_callback (dpman, "volume", G_TYPE_FLOAT, gst_sinesrc_update_volume, src); gst_dpman_add_required_dparam_direct (dpman, "volume", G_TYPE_FLOAT, &(src->volume));
spec = gst_dpman_get_dparam_spec (dpman, "volume"); spec = gst_dpman_get_dparam_spec (dpman, "volume");
g_value_set_float(spec->min_val, 0.0); g_value_set_float(spec->min_val, 0.0);
g_value_set_float(spec->max_val, 2.0); g_value_set_float(spec->max_val, 1.0);
g_value_set_float(spec->default_val, 0.8); g_value_set_float(spec->default_val, 0.8);
spec->unit_name = "scalar"; spec->unit_name = "scalar";
@ -195,8 +194,6 @@ gst_sinesrc_init (GstSineSrc *src)
GST_ELEMENT_DPARAM_MANAGER(element) = dpman; GST_ELEMENT_DPARAM_MANAGER(element) = dpman;
gst_sinesrc_update_vol_scale(src);
gst_sinesrc_populate_sinetable(src); gst_sinesrc_populate_sinetable(src);
gst_sinesrc_update_table_inc(src); gst_sinesrc_update_table_inc(src);
@ -241,7 +238,6 @@ gst_sinesrc_get(GstPad *pad)
frame_countdown = GST_DPMAN_PREPROCESS(dpman, src->buffer_size, src->timestamp); frame_countdown = GST_DPMAN_PREPROCESS(dpman, src->buffer_size, src->timestamp);
src->timestamp += (gint64)src->buffer_size * 1000000000LL / (gint64)src->samplerate; src->timestamp += (gint64)src->buffer_size * 1000000000LL / (gint64)src->samplerate;
// GST_DEBUG(GST_CAT_PARAMS, "vol_scale = %f\n", src->vol_scale);
while(GST_DPMAN_PROCESS_COUNTDOWN(dpman, frame_countdown, i)) { while(GST_DPMAN_PROCESS_COUNTDOWN(dpman, frame_countdown, i)) {
@ -262,7 +258,7 @@ gst_sinesrc_get(GstPad *pad)
//no interpolation //no interpolation
//samples[i] = src->table_data[src->table_lookup] //samples[i] = src->table_data[src->table_lookup]
// * src->vol_scale; // * src->volume * 32767.0;
//linear interpolation //linear interpolation
samples[i++] = ((src->table_interp samples[i++] = ((src->table_interp
@ -270,7 +266,7 @@ gst_sinesrc_get(GstPad *pad)
-src->table_data[src->table_lookup] -src->table_data[src->table_lookup]
) )
)+src->table_data[src->table_lookup] )+src->table_data[src->table_lookup]
)* src->vol_scale; )* src->volume * 32767.0;
} }
if (src->newcaps) { if (src->newcaps) {
@ -377,18 +373,6 @@ gst_sinesrc_populate_sinetable (GstSineSrc *src)
src->table_data = table; src->table_data = table;
} }
static void
gst_sinesrc_update_volume(GValue *value, gpointer data)
{
GstSineSrc *src = (GstSineSrc*)data;
g_return_if_fail(GST_IS_SINESRC(src));
src->volume = g_value_get_float(value);
src->vol_scale = 32767.0 * src->volume;
//GST_DEBUG(GST_CAT_PARAMS, "volume %f\n", src->volume);
}
static void static void
gst_sinesrc_update_freq(GValue *value, gpointer data) gst_sinesrc_update_freq(GValue *value, gpointer data)
{ {
@ -407,12 +391,6 @@ gst_sinesrc_update_table_inc (GstSineSrc *src)
src->table_inc = src->table_size * src->freq / src->samplerate; src->table_inc = src->table_size * src->freq / src->samplerate;
} }
static inline void
gst_sinesrc_update_vol_scale (GstSineSrc *src)
{
src->vol_scale = 32767.0 * src->volume;
}
static void static void
gst_sinesrc_force_caps(GstSineSrc *src) { gst_sinesrc_force_caps(GstSineSrc *src) {
GstCaps *caps; GstCaps *caps;

View file

@ -59,7 +59,6 @@ struct _GstSineSrc {
/* parameters */ /* parameters */
gfloat volume; gfloat volume;
gfloat freq; gfloat freq;
gfloat vol_scale;
/* lookup table data */ /* lookup table data */
gfloat *table_data; gfloat *table_data;

View file

@ -83,11 +83,9 @@ static void gst_sinesrc_get_property (GObject *object, guint prop_id,
//static void gst_sinesrc_close_audio(GstSineSrc *src); //static void gst_sinesrc_close_audio(GstSineSrc *src);
//static gboolean gst_sinesrc_open_audio(GstSineSrc *src); //static gboolean gst_sinesrc_open_audio(GstSineSrc *src);
static void gst_sinesrc_update_volume(GValue *value, gpointer data);
static void gst_sinesrc_update_freq(GValue *value, gpointer data); static void gst_sinesrc_update_freq(GValue *value, gpointer data);
static void gst_sinesrc_populate_sinetable (GstSineSrc *src); static void gst_sinesrc_populate_sinetable (GstSineSrc *src);
static inline void gst_sinesrc_update_table_inc (GstSineSrc *src); static inline void gst_sinesrc_update_table_inc (GstSineSrc *src);
static inline void gst_sinesrc_update_vol_scale (GstSineSrc *src);
static void gst_sinesrc_force_caps (GstSineSrc *src); static void gst_sinesrc_force_caps (GstSineSrc *src);
static GstBuffer* gst_sinesrc_get (GstPad *pad); static GstBuffer* gst_sinesrc_get (GstPad *pad);
@ -174,6 +172,7 @@ gst_sinesrc_init (GstSineSrc *src)
src->seq = 0; src->seq = 0;
dpman = gst_dpman_new ("sinesrc_dpman", GST_ELEMENT(src)); dpman = gst_dpman_new ("sinesrc_dpman", GST_ELEMENT(src));
gst_dpman_add_required_dparam_callback (dpman, "freq", G_TYPE_FLOAT, gst_sinesrc_update_freq, src); gst_dpman_add_required_dparam_callback (dpman, "freq", G_TYPE_FLOAT, gst_sinesrc_update_freq, src);
spec = gst_dpman_get_dparam_spec (dpman, "freq"); spec = gst_dpman_get_dparam_spec (dpman, "freq");
g_value_set_float(spec->min_val, 10.0); g_value_set_float(spec->min_val, 10.0);
@ -182,10 +181,10 @@ gst_sinesrc_init (GstSineSrc *src)
spec->unit_name = "frequency"; spec->unit_name = "frequency";
spec->is_log = TRUE; spec->is_log = TRUE;
gst_dpman_add_required_dparam_callback (dpman, "volume", G_TYPE_FLOAT, gst_sinesrc_update_volume, src); gst_dpman_add_required_dparam_direct (dpman, "volume", G_TYPE_FLOAT, &(src->volume));
spec = gst_dpman_get_dparam_spec (dpman, "volume"); spec = gst_dpman_get_dparam_spec (dpman, "volume");
g_value_set_float(spec->min_val, 0.0); g_value_set_float(spec->min_val, 0.0);
g_value_set_float(spec->max_val, 2.0); g_value_set_float(spec->max_val, 1.0);
g_value_set_float(spec->default_val, 0.8); g_value_set_float(spec->default_val, 0.8);
spec->unit_name = "scalar"; spec->unit_name = "scalar";
@ -195,8 +194,6 @@ gst_sinesrc_init (GstSineSrc *src)
GST_ELEMENT_DPARAM_MANAGER(element) = dpman; GST_ELEMENT_DPARAM_MANAGER(element) = dpman;
gst_sinesrc_update_vol_scale(src);
gst_sinesrc_populate_sinetable(src); gst_sinesrc_populate_sinetable(src);
gst_sinesrc_update_table_inc(src); gst_sinesrc_update_table_inc(src);
@ -241,7 +238,6 @@ gst_sinesrc_get(GstPad *pad)
frame_countdown = GST_DPMAN_PREPROCESS(dpman, src->buffer_size, src->timestamp); frame_countdown = GST_DPMAN_PREPROCESS(dpman, src->buffer_size, src->timestamp);
src->timestamp += (gint64)src->buffer_size * 1000000000LL / (gint64)src->samplerate; src->timestamp += (gint64)src->buffer_size * 1000000000LL / (gint64)src->samplerate;
// GST_DEBUG(GST_CAT_PARAMS, "vol_scale = %f\n", src->vol_scale);
while(GST_DPMAN_PROCESS_COUNTDOWN(dpman, frame_countdown, i)) { while(GST_DPMAN_PROCESS_COUNTDOWN(dpman, frame_countdown, i)) {
@ -262,7 +258,7 @@ gst_sinesrc_get(GstPad *pad)
//no interpolation //no interpolation
//samples[i] = src->table_data[src->table_lookup] //samples[i] = src->table_data[src->table_lookup]
// * src->vol_scale; // * src->volume * 32767.0;
//linear interpolation //linear interpolation
samples[i++] = ((src->table_interp samples[i++] = ((src->table_interp
@ -270,7 +266,7 @@ gst_sinesrc_get(GstPad *pad)
-src->table_data[src->table_lookup] -src->table_data[src->table_lookup]
) )
)+src->table_data[src->table_lookup] )+src->table_data[src->table_lookup]
)* src->vol_scale; )* src->volume * 32767.0;
} }
if (src->newcaps) { if (src->newcaps) {
@ -377,18 +373,6 @@ gst_sinesrc_populate_sinetable (GstSineSrc *src)
src->table_data = table; src->table_data = table;
} }
static void
gst_sinesrc_update_volume(GValue *value, gpointer data)
{
GstSineSrc *src = (GstSineSrc*)data;
g_return_if_fail(GST_IS_SINESRC(src));
src->volume = g_value_get_float(value);
src->vol_scale = 32767.0 * src->volume;
//GST_DEBUG(GST_CAT_PARAMS, "volume %f\n", src->volume);
}
static void static void
gst_sinesrc_update_freq(GValue *value, gpointer data) gst_sinesrc_update_freq(GValue *value, gpointer data)
{ {
@ -407,12 +391,6 @@ gst_sinesrc_update_table_inc (GstSineSrc *src)
src->table_inc = src->table_size * src->freq / src->samplerate; src->table_inc = src->table_size * src->freq / src->samplerate;
} }
static inline void
gst_sinesrc_update_vol_scale (GstSineSrc *src)
{
src->vol_scale = 32767.0 * src->volume;
}
static void static void
gst_sinesrc_force_caps(GstSineSrc *src) { gst_sinesrc_force_caps(GstSineSrc *src) {
GstCaps *caps; GstCaps *caps;

View file

@ -59,7 +59,6 @@ struct _GstSineSrc {
/* parameters */ /* parameters */
gfloat volume; gfloat volume;
gfloat freq; gfloat freq;
gfloat vol_scale;
/* lookup table data */ /* lookup table data */
gfloat *table_data; gfloat *table_data;