mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-24 02:31:03 +00:00
use new dparams api. run demo_dparams to hear how smooth it is now
Original commit message from CVS: use new dparams api. run demo_dparams to hear how smooth it is now
This commit is contained in:
parent
85a358dbe3
commit
6ad042fada
2 changed files with 14 additions and 11 deletions
|
@ -62,8 +62,9 @@ int main(int argc,char *argv[]) {
|
|||
gst_element_connect_many(sinesrc, volfilter, osssink, NULL);
|
||||
/* this breaks with current alsa oss compat lib */
|
||||
g_object_set(G_OBJECT(osssink),"fragment",0x00180008,NULL);
|
||||
g_object_set(G_OBJECT(osssink),"sync",FALSE,NULL);
|
||||
|
||||
g_object_set(G_OBJECT(sinesrc),"samplesperbuffer",64,NULL);
|
||||
g_object_set(G_OBJECT(sinesrc),"samplesperbuffer",1024,NULL);
|
||||
|
||||
/***** set up the GUI *****/
|
||||
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
|
@ -87,7 +88,7 @@ int main(int argc,char *argv[]) {
|
|||
|
||||
dpman = gst_dpman_get_manager (sinesrc);
|
||||
g_assert(gst_dpman_attach_dparam (dpman, "freq", freq));
|
||||
gst_dpman_set_mode(dpman, "synchronous");
|
||||
gst_dpman_set_mode(dpman, "asynchronous");
|
||||
|
||||
spec = (GParamSpecFloat*)gst_dpman_get_param_spec (dpman, "freq");
|
||||
freq_adj = (GtkAdjustment*)gtk_adjustment_new((gfloat)log(spec->default_value),
|
||||
|
@ -106,12 +107,12 @@ int main(int argc,char *argv[]) {
|
|||
/* this defines the maximum slope that this *
|
||||
* param can change. This says that in 50ms *
|
||||
* the value can change from 0.0 to 1.0 */
|
||||
g_object_set(G_OBJECT(volume), "slope_delta_float", 1.0F, NULL);
|
||||
g_object_set(G_OBJECT(volume), "slope_delta_float", 0.1F, NULL);
|
||||
g_object_set(G_OBJECT(volume), "slope_time", 50000000LL, NULL);
|
||||
|
||||
dpman = gst_dpman_get_manager (volfilter);
|
||||
g_assert(gst_dpman_attach_dparam (dpman, "volume", volume));
|
||||
gst_dpman_set_mode(dpman, "synchronous");
|
||||
gst_dpman_set_mode(dpman, "asynchronous");
|
||||
|
||||
g_object_set(G_OBJECT(volfilter), "mute", FALSE, NULL);
|
||||
|
||||
|
|
|
@ -196,8 +196,8 @@ gst_sinesrc_init (GstSineSrc *src)
|
|||
&(src->volume)
|
||||
);
|
||||
|
||||
gst_dpman_set_rate_change_pad(src->dpman, src->srcpad);
|
||||
|
||||
gst_dpman_set_rate(src->dpman, src->samplerate);
|
||||
|
||||
gst_sinesrc_populate_sinetable(src);
|
||||
gst_sinesrc_update_table_inc(src);
|
||||
|
||||
|
@ -210,7 +210,7 @@ gst_sinesrc_get(GstPad *pad)
|
|||
GstBuffer *buf;
|
||||
|
||||
gint16 *samples;
|
||||
gint i=0, frame_countdown;
|
||||
gint i=0;
|
||||
|
||||
g_return_val_if_fail (pad != NULL, NULL);
|
||||
src = GST_SINESRC(gst_pad_get_parent (pad));
|
||||
|
@ -224,12 +224,12 @@ gst_sinesrc_get(GstPad *pad)
|
|||
|
||||
samples = (gint16*)GST_BUFFER_DATA(buf);
|
||||
GST_BUFFER_DATA(buf) = (gpointer) samples;
|
||||
|
||||
frame_countdown = GST_DPMAN_PREPROCESS(src->dpman, src->samples_per_buffer, src->timestamp);
|
||||
|
||||
GST_DPMAN_PREPROCESS(src->dpman, src->samples_per_buffer, src->timestamp);
|
||||
|
||||
src->timestamp += (gint64)src->samples_per_buffer * 1000000000LL / (gint64)src->samplerate;
|
||||
|
||||
while(GST_DPMAN_PROCESS_COUNTDOWN(src->dpman, frame_countdown, i)) {
|
||||
while(GST_DPMAN_PROCESS(src->dpman, i)) {
|
||||
|
||||
src->table_lookup = (gint)(src->table_pos);
|
||||
src->table_lookup_next = src->table_lookup + 1;
|
||||
|
@ -251,12 +251,13 @@ gst_sinesrc_get(GstPad *pad)
|
|||
/* * src->volume * 32767.0; */
|
||||
|
||||
/*linear interpolation */
|
||||
samples[i++] = ((src->table_interp
|
||||
samples[i] = ((src->table_interp
|
||||
*(src->table_data[src->table_lookup_next]
|
||||
-src->table_data[src->table_lookup]
|
||||
)
|
||||
)+src->table_data[src->table_lookup]
|
||||
)* src->volume * 32767.0;
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
|
@ -282,6 +283,7 @@ gst_sinesrc_set_property (GObject *object, guint prop_id, const GValue *value, G
|
|||
break;
|
||||
case ARG_SAMPLERATE:
|
||||
src->samplerate = g_value_get_int (value);
|
||||
gst_dpman_set_rate(src->dpman, src->samplerate);
|
||||
src->newcaps=TRUE;
|
||||
gst_sinesrc_update_table_inc(src);
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue