mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
+ attempting to fix up playondemand ... still makes nasty crackly noises
Original commit message from CVS: + attempting to fix up playondemand ... still makes nasty crackly noises
This commit is contained in:
parent
90ec1eb652
commit
d5c716edbd
4 changed files with 30 additions and 22 deletions
|
@ -10,7 +10,7 @@ GtkWidget *play_button, *clear_button, *reset_button, *quit_button;
|
||||||
GtkWidget **beat_button;
|
GtkWidget **beat_button;
|
||||||
GtkWidget *speed_scale;
|
GtkWidget *speed_scale;
|
||||||
GtkObject *speed_adj;
|
GtkObject *speed_adj;
|
||||||
GstElement *src, *mad, *pod, *sink, *pipeline;
|
GstElement *src, *mad, *conv, *pod, *sink, *pipeline;
|
||||||
GstClock *element_clock;
|
GstClock *element_clock;
|
||||||
guint32 *beats;
|
guint32 *beats;
|
||||||
|
|
||||||
|
@ -63,6 +63,7 @@ beat (GtkToggleButton *button, gpointer data)
|
||||||
void
|
void
|
||||||
speed (GtkAdjustment *adjustment, gpointer data)
|
speed (GtkAdjustment *adjustment, gpointer data)
|
||||||
{
|
{
|
||||||
|
g_signal_stop_emission_by_name(G_OBJECT(pod), "deep-notify");
|
||||||
g_object_set(G_OBJECT(pod), "tick-rate", adjustment->value, NULL);
|
g_object_set(G_OBJECT(pod), "tick-rate", adjustment->value, NULL);
|
||||||
/*gst_clock_set_speed(element_clock, adjustment->value);*/
|
/*gst_clock_set_speed(element_clock, adjustment->value);*/
|
||||||
}
|
}
|
||||||
|
@ -72,11 +73,12 @@ setup_pipeline (gchar *filename)
|
||||||
{
|
{
|
||||||
src = gst_element_factory_make("filesrc", "filesrc");
|
src = gst_element_factory_make("filesrc", "filesrc");
|
||||||
mad = gst_element_factory_make("mad", "mad");
|
mad = gst_element_factory_make("mad", "mad");
|
||||||
|
conv = gst_element_factory_make("audioconvert", "audioconvert");
|
||||||
pod = gst_element_factory_make("playondemand", "playondemand");
|
pod = gst_element_factory_make("playondemand", "playondemand");
|
||||||
sink = gst_element_factory_make("alsasink", "alsasink");
|
sink = gst_element_factory_make("alsasink", "alsasink");
|
||||||
|
|
||||||
g_object_set(G_OBJECT(src), "location", filename, NULL);
|
g_object_set(G_OBJECT(src), "location", filename, NULL);
|
||||||
g_object_set(G_OBJECT(sink), "period-count", 32,
|
g_object_set(G_OBJECT(sink), "period-count", 64,
|
||||||
"period-size", 512, NULL);
|
"period-size", 512, NULL);
|
||||||
g_object_set(G_OBJECT(pod), "total-ticks", NUM_BEATS,
|
g_object_set(G_OBJECT(pod), "total-ticks", NUM_BEATS,
|
||||||
"tick-rate", 1.0,
|
"tick-rate", 1.0,
|
||||||
|
@ -86,8 +88,8 @@ setup_pipeline (gchar *filename)
|
||||||
|
|
||||||
pipeline = gst_pipeline_new("app");
|
pipeline = gst_pipeline_new("app");
|
||||||
|
|
||||||
gst_bin_add_many(GST_BIN(pipeline), src, mad, pod, sink, NULL);
|
gst_bin_add_many(GST_BIN(pipeline), src, mad, conv, pod, sink, NULL);
|
||||||
gst_element_link_many(src, mad, pod, sink, NULL);
|
gst_element_link_many(src, mad, conv, pod, sink, NULL);
|
||||||
|
|
||||||
element_clock = gst_bin_get_clock(GST_BIN(pipeline));
|
element_clock = gst_bin_get_clock(GST_BIN(pipeline));
|
||||||
gst_element_set_clock(GST_ELEMENT(pod), element_clock);
|
gst_element_set_clock(GST_ELEMENT(pod), element_clock);
|
||||||
|
|
|
@ -6,22 +6,23 @@ filter_data = (_TYPE_ *) filter->buffer;
|
||||||
num_filter = filter->buffer_bytes / sizeof(_TYPE_);
|
num_filter = filter->buffer_bytes / sizeof(_TYPE_);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
if (in == NULL && ! filter->eos) in = gst_pad_pull(filter->sinkpad);
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* see if we've got any events coming through ... */
|
/* see if we've got any events coming through ... */
|
||||||
|
|
||||||
while (! filter->eos && GST_IS_EVENT(in)) {
|
while (! filter->eos && GST_IS_EVENT(in)) {
|
||||||
if (GST_EVENT_TYPE(in) == GST_EVENT_EOS) {
|
if (GST_EVENT_TYPE(in) == GST_EVENT_EOS) {
|
||||||
gst_event_unref(in);
|
gst_event_unref(in);
|
||||||
|
gst_buffer_free(in);
|
||||||
filter->eos = TRUE;
|
filter->eos = TRUE;
|
||||||
} else if ((GST_EVENT_TYPE(in) == GST_EVENT_SEEK) ||
|
} else if ((GST_EVENT_TYPE(in) == GST_EVENT_SEEK) ||
|
||||||
(GST_EVENT_TYPE(in) == GST_EVENT_FLUSH)) {
|
(GST_EVENT_TYPE(in) == GST_EVENT_FLUSH)) {
|
||||||
|
gst_event_unref(in);
|
||||||
|
gst_buffer_free(in);
|
||||||
filter->eos = FALSE;
|
filter->eos = FALSE;
|
||||||
filter->write = 0;
|
filter->write = 0;
|
||||||
} else {
|
} else {
|
||||||
if ((GST_EVENT_TYPE(in) == GST_EVENT_SEEK) ||
|
|
||||||
(GST_EVENT_TYPE(in) == GST_EVENT_FLUSH))
|
|
||||||
filter->write = 0;
|
|
||||||
|
|
||||||
gst_pad_push(filter->srcpad, in);
|
gst_pad_push(filter->srcpad, in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,6 +50,8 @@ do {
|
||||||
out = gst_buffer_new_from_pool(filter->bufpool, 0, 0);
|
out = gst_buffer_new_from_pool(filter->bufpool, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
in = NULL;
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* check to see if we have to add new play pointers. */
|
/* check to see if we have to add new play pointers. */
|
||||||
|
|
||||||
|
@ -113,8 +116,6 @@ do {
|
||||||
|
|
||||||
gst_pad_push(filter->srcpad, out);
|
gst_pad_push(filter->srcpad, out);
|
||||||
|
|
||||||
in = (! filter->eos) ? gst_pad_pull(filter->sinkpad) : NULL;
|
|
||||||
|
|
||||||
if (gst_element_interrupt (GST_ELEMENT (filter))) break;
|
if (gst_element_interrupt (GST_ELEMENT (filter))) break;
|
||||||
|
|
||||||
} while (TRUE);
|
} while (TRUE);
|
||||||
|
|
|
@ -64,7 +64,7 @@ play_on_demand_sink_factory (void)
|
||||||
gst_caps_append(gst_caps_new ("sink_int", "audio/x-raw-int",
|
gst_caps_append(gst_caps_new ("sink_int", "audio/x-raw-int",
|
||||||
GST_AUDIO_INT_PAD_TEMPLATE_PROPS),
|
GST_AUDIO_INT_PAD_TEMPLATE_PROPS),
|
||||||
gst_caps_new ("sink_float", "audio/x-raw-float",
|
gst_caps_new ("sink_float", "audio/x-raw-float",
|
||||||
GST_AUDIO_FLOAT_MONO_PAD_TEMPLATE_PROPS)),
|
GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_PROPS)),
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
return template;
|
return template;
|
||||||
|
@ -80,7 +80,7 @@ play_on_demand_src_factory (void)
|
||||||
template = gst_pad_template_new
|
template = gst_pad_template_new
|
||||||
("src", GST_PAD_SRC, GST_PAD_ALWAYS,
|
("src", GST_PAD_SRC, GST_PAD_ALWAYS,
|
||||||
gst_caps_append (gst_caps_new ("src_float", "audio/x-raw-float",
|
gst_caps_append (gst_caps_new ("src_float", "audio/x-raw-float",
|
||||||
GST_AUDIO_FLOAT_MONO_PAD_TEMPLATE_PROPS),
|
GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_PROPS),
|
||||||
gst_caps_new ("src_int", "audio/x-raw-int",
|
gst_caps_new ("src_int", "audio/x-raw-int",
|
||||||
GST_AUDIO_INT_PAD_TEMPLATE_PROPS)),
|
GST_AUDIO_INT_PAD_TEMPLATE_PROPS)),
|
||||||
NULL);
|
NULL);
|
||||||
|
@ -140,6 +140,7 @@ gst_play_on_demand_get_type (void)
|
||||||
enum {
|
enum {
|
||||||
/* add signals here */
|
/* add signals here */
|
||||||
PLAYED_SIGNAL,
|
PLAYED_SIGNAL,
|
||||||
|
STOPPED_SIGNAL,
|
||||||
PLAY_SIGNAL,
|
PLAY_SIGNAL,
|
||||||
CLEAR_SIGNAL,
|
CLEAR_SIGNAL,
|
||||||
RESET_SIGNAL,
|
RESET_SIGNAL,
|
||||||
|
@ -174,6 +175,11 @@ play_on_demand_class_init (GstPlayOnDemandClass *klass)
|
||||||
G_STRUCT_OFFSET(GstPlayOnDemandClass, played),
|
G_STRUCT_OFFSET(GstPlayOnDemandClass, played),
|
||||||
NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
|
NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
|
||||||
|
|
||||||
|
gst_pod_filter_signals[STOPPED_SIGNAL] =
|
||||||
|
g_signal_new("stopped", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
|
||||||
|
G_STRUCT_OFFSET(GstPlayOnDemandClass, stopped),
|
||||||
|
NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
|
||||||
|
|
||||||
gst_pod_filter_signals[PLAY_SIGNAL] =
|
gst_pod_filter_signals[PLAY_SIGNAL] =
|
||||||
g_signal_new("play", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
|
g_signal_new("play", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
|
||||||
G_STRUCT_OFFSET(GstPlayOnDemandClass, play),
|
G_STRUCT_OFFSET(GstPlayOnDemandClass, play),
|
||||||
|
@ -206,7 +212,7 @@ play_on_demand_class_init (GstPlayOnDemandClass *klass)
|
||||||
FALSE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
FALSE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
||||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_BUFFER_TIME,
|
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_BUFFER_TIME,
|
||||||
g_param_spec_float("buffer-time", "Buffer length in seconds", "Number of seconds of audio the buffer holds",
|
g_param_spec_float("buffer-time", "Buffer length in seconds", "Number of seconds of audio the buffer holds",
|
||||||
0.0, G_MAXUINT / GST_AUDIO_MAX_RATE - 10, GST_POD_BUFFER_TIME, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
0.0, G_MAXFLOAT, GST_POD_BUFFER_TIME, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
||||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_MAX_PLAYS,
|
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_MAX_PLAYS,
|
||||||
g_param_spec_uint("max-plays", "Maximum simultaneous playbacks", "Maximum allowed number of simultaneous plays from the buffer",
|
g_param_spec_uint("max-plays", "Maximum simultaneous playbacks", "Maximum allowed number of simultaneous plays from the buffer",
|
||||||
1, G_MAXUINT, GST_POD_MAX_PLAYS, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
1, G_MAXUINT, GST_POD_MAX_PLAYS, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
||||||
|
@ -243,7 +249,6 @@ play_on_demand_init (GstPlayOnDemand *filter)
|
||||||
filter->plays = g_new(guint, filter->max_plays);
|
filter->plays = g_new(guint, filter->max_plays);
|
||||||
|
|
||||||
play_on_demand_resize_buffer(filter);
|
play_on_demand_resize_buffer(filter);
|
||||||
play_on_demand_clear_handler(GST_ELEMENT(filter));
|
|
||||||
play_on_demand_reset_handler(GST_ELEMENT(filter));
|
play_on_demand_reset_handler(GST_ELEMENT(filter));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,8 +273,7 @@ play_on_demand_set_property (GObject *object, guint prop_id,
|
||||||
play_on_demand_resize_buffer(filter);
|
play_on_demand_resize_buffer(filter);
|
||||||
|
|
||||||
/* clear out now-invalid play pointers */
|
/* clear out now-invalid play pointers */
|
||||||
for (i = 0; i < filter->max_plays; i++)
|
for (i = 0; i < filter->max_plays; i++) filter->plays[i] = G_MAXUINT;
|
||||||
filter->plays[i] = G_MAXUINT;
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case PROP_MAX_PLAYS:
|
case PROP_MAX_PLAYS:
|
||||||
|
@ -496,7 +500,7 @@ play_on_demand_clear_handler (GstElement *elem)
|
||||||
filter->eos = FALSE;
|
filter->eos = FALSE;
|
||||||
|
|
||||||
for (i = 0; i < filter->max_plays; i++) filter->plays[i] = G_MAXUINT;
|
for (i = 0; i < filter->max_plays; i++) filter->plays[i] = G_MAXUINT;
|
||||||
for (i = 0; i < filter->buffer_bytes; i++) filter->buffer[i] = 0;
|
for (i = 0; i < filter->buffer_bytes; i++) filter->buffer[i] = (gchar) 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -536,7 +540,7 @@ play_on_demand_resize_buffer (GstPlayOnDemand *filter)
|
||||||
|
|
||||||
new_buffer = g_new(gchar, new_size);
|
new_buffer = g_new(gchar, new_size);
|
||||||
for (i = 0; i < min_size; i++) new_buffer[i] = filter->buffer[i];
|
for (i = 0; i < min_size; i++) new_buffer[i] = filter->buffer[i];
|
||||||
for (i = min_size; i < new_size; i++) new_buffer[i] = 0;
|
for (i = min_size; i < new_size; i++) new_buffer[i] = (gchar) 0;
|
||||||
|
|
||||||
g_free(filter->buffer);
|
g_free(filter->buffer);
|
||||||
filter->buffer = new_buffer;
|
filter->buffer = new_buffer;
|
||||||
|
|
|
@ -90,6 +90,7 @@ struct _GstPlayOnDemandClass {
|
||||||
void (*clear) (GstElement *elem);
|
void (*clear) (GstElement *elem);
|
||||||
void (*reset) (GstElement *elem);
|
void (*reset) (GstElement *elem);
|
||||||
void (*played) (GstElement *elem);
|
void (*played) (GstElement *elem);
|
||||||
|
void (*stopped) (GstElement *elem);
|
||||||
};
|
};
|
||||||
|
|
||||||
GType gst_play_on_demand_get_type(void);
|
GType gst_play_on_demand_get_type(void);
|
||||||
|
|
Loading…
Reference in a new issue