summaryrefslogtreecommitdiffstats
path: root/gst
diff options
context:
space:
mode:
Diffstat (limited to 'gst')
-rw-r--r--gst/playondemand/demo-mp3.c10
-rw-r--r--gst/playondemand/filter.func13
-rw-r--r--gst/playondemand/gstplayondemand.c20
-rw-r--r--gst/playondemand/gstplayondemand.h9
4 files changed, 30 insertions, 22 deletions
diff --git a/gst/playondemand/demo-mp3.c b/gst/playondemand/demo-mp3.c
index e239961d..7161aae4 100644
--- a/gst/playondemand/demo-mp3.c
+++ b/gst/playondemand/demo-mp3.c
@@ -10,7 +10,7 @@ GtkWidget *play_button, *clear_button, *reset_button, *quit_button;
GtkWidget **beat_button;
GtkWidget *speed_scale;
GtkObject *speed_adj;
-GstElement *src, *mad, *pod, *sink, *pipeline;
+GstElement *src, *mad, *conv, *pod, *sink, *pipeline;
GstClock *element_clock;
guint32 *beats;
@@ -63,6 +63,7 @@ beat (GtkToggleButton *button, gpointer data)
void
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);
/*gst_clock_set_speed(element_clock, adjustment->value);*/
}
@@ -72,11 +73,12 @@ setup_pipeline (gchar *filename)
{
src = gst_element_factory_make("filesrc", "filesrc");
mad = gst_element_factory_make("mad", "mad");
+ conv = gst_element_factory_make("audioconvert", "audioconvert");
pod = gst_element_factory_make("playondemand", "playondemand");
sink = gst_element_factory_make("alsasink", "alsasink");
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);
g_object_set(G_OBJECT(pod), "total-ticks", NUM_BEATS,
"tick-rate", 1.0,
@@ -86,8 +88,8 @@ setup_pipeline (gchar *filename)
pipeline = gst_pipeline_new("app");
- gst_bin_add_many(GST_BIN(pipeline), src, mad, pod, sink, NULL);
- gst_element_link_many(src, mad, pod, sink, NULL);
+ gst_bin_add_many(GST_BIN(pipeline), src, mad, conv, pod, sink, NULL);
+ gst_element_link_many(src, mad, conv, pod, sink, NULL);
element_clock = gst_bin_get_clock(GST_BIN(pipeline));
gst_element_set_clock(GST_ELEMENT(pod), element_clock);
diff --git a/gst/playondemand/filter.func b/gst/playondemand/filter.func
index 61c1cc56..7c9f4de7 100644
--- a/gst/playondemand/filter.func
+++ b/gst/playondemand/filter.func
@@ -6,22 +6,23 @@ filter_data = (_TYPE_ *) filter->buffer;
num_filter = filter->buffer_bytes / sizeof(_TYPE_);
do {
+ if (in == NULL && ! filter->eos) in = gst_pad_pull(filter->sinkpad);
+
/****************************************************************************/
/* see if we've got any events coming through ... */
while (! filter->eos && GST_IS_EVENT(in)) {
if (GST_EVENT_TYPE(in) == GST_EVENT_EOS) {
gst_event_unref(in);
+ gst_buffer_free(in);
filter->eos = TRUE;
} else if ((GST_EVENT_TYPE(in) == GST_EVENT_SEEK) ||
(GST_EVENT_TYPE(in) == GST_EVENT_FLUSH)) {
+ gst_event_unref(in);
+ gst_buffer_free(in);
filter->eos = FALSE;
filter->write = 0;
} 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);
}
@@ -49,6 +50,8 @@ do {
out = gst_buffer_new_from_pool(filter->bufpool, 0, 0);
}
+ in = NULL;
+
/****************************************************************************/
/* check to see if we have to add new play pointers. */
@@ -113,8 +116,6 @@ do {
gst_pad_push(filter->srcpad, out);
- in = (! filter->eos) ? gst_pad_pull(filter->sinkpad) : NULL;
-
if (gst_element_interrupt (GST_ELEMENT (filter))) break;
} while (TRUE);
diff --git a/gst/playondemand/gstplayondemand.c b/gst/playondemand/gstplayondemand.c
index eb8a296f..0876f7d0 100644
--- a/gst/playondemand/gstplayondemand.c
+++ b/gst/playondemand/gstplayondemand.c
@@ -64,7 +64,7 @@ play_on_demand_sink_factory (void)
gst_caps_append(gst_caps_new ("sink_int", "audio/x-raw-int",
GST_AUDIO_INT_PAD_TEMPLATE_PROPS),
gst_caps_new ("sink_float", "audio/x-raw-float",
- GST_AUDIO_FLOAT_MONO_PAD_TEMPLATE_PROPS)),
+ GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_PROPS)),
NULL);
}
return template;
@@ -80,7 +80,7 @@ play_on_demand_src_factory (void)
template = gst_pad_template_new
("src", GST_PAD_SRC, GST_PAD_ALWAYS,
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_AUDIO_INT_PAD_TEMPLATE_PROPS)),
NULL);
@@ -140,6 +140,7 @@ gst_play_on_demand_get_type (void)
enum {
/* add signals here */
PLAYED_SIGNAL,
+ STOPPED_SIGNAL,
PLAY_SIGNAL,
CLEAR_SIGNAL,
RESET_SIGNAL,
@@ -174,6 +175,11 @@ play_on_demand_class_init (GstPlayOnDemandClass *klass)
G_STRUCT_OFFSET(GstPlayOnDemandClass, played),
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] =
g_signal_new("play", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(GstPlayOnDemandClass, play),
@@ -206,7 +212,7 @@ play_on_demand_class_init (GstPlayOnDemandClass *klass)
FALSE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
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",
- 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_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));
@@ -243,7 +249,6 @@ play_on_demand_init (GstPlayOnDemand *filter)
filter->plays = g_new(guint, filter->max_plays);
play_on_demand_resize_buffer(filter);
- play_on_demand_clear_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);
/* clear out now-invalid play pointers */
- 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;
break;
case PROP_MAX_PLAYS:
@@ -496,7 +500,7 @@ play_on_demand_clear_handler (GstElement *elem)
filter->eos = FALSE;
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
@@ -536,7 +540,7 @@ play_on_demand_resize_buffer (GstPlayOnDemand *filter)
new_buffer = g_new(gchar, new_size);
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);
filter->buffer = new_buffer;
diff --git a/gst/playondemand/gstplayondemand.h b/gst/playondemand/gstplayondemand.h
index 893d77a2..20e9359e 100644
--- a/gst/playondemand/gstplayondemand.h
+++ b/gst/playondemand/gstplayondemand.h
@@ -86,10 +86,11 @@ struct _GstPlayOnDemand {
struct _GstPlayOnDemandClass {
GstElementClass parent_class;
- void (*play) (GstElement *elem);
- void (*clear) (GstElement *elem);
- void (*reset) (GstElement *elem);
- void (*played) (GstElement *elem);
+ void (*play) (GstElement *elem);
+ void (*clear) (GstElement *elem);
+ void (*reset) (GstElement *elem);
+ void (*played) (GstElement *elem);
+ void (*stopped) (GstElement *elem);
};
GType gst_play_on_demand_get_type(void);