summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Sauer <ensonic@users.sf.net>2013-04-18 07:55:56 +0200
committerStefan Sauer <ensonic@users.sf.net>2013-04-21 16:11:41 +0200
commitfa9c0cdf6edf1dbb42ca441935487fa703e4bead (patch)
tree1d7deeeec8a0bda2b16532c83c85f29c01b0aa3c
parent9c94a1812f7cc99cc4134d6abb9b0c2998f1a80f (diff)
volume: skip controlled processing if we have no timestamp
-rw-r--r--gst/volume/gstvolume.c103
1 files changed, 53 insertions, 50 deletions
diff --git a/gst/volume/gstvolume.c b/gst/volume/gstvolume.c
index c6be1ee22..0f5b362dd 100644
--- a/gst/volume/gstvolume.c
+++ b/gst/volume/gstvolume.c
@@ -718,7 +718,7 @@ volume_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
GstAudioFilter *filter = GST_AUDIO_FILTER_CAST (base);
GstVolume *self = GST_VOLUME (base);
GstMapInfo map;
- GstControlBinding *mute_cb, *volume_cb;
+ GstClockTime ts;
if (G_UNLIKELY (!self->negotiated))
goto not_negotiated;
@@ -728,61 +728,64 @@ volume_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
return GST_FLOW_OK;
gst_buffer_map (outbuf, &map, GST_MAP_READWRITE);
+ ts = GST_BUFFER_TIMESTAMP (outbuf);
+ ts = gst_segment_to_stream_time (&base->segment, GST_FORMAT_TIME, ts);
+
+ if (GST_CLOCK_TIME_IS_VALID (ts)) {
+ GstControlBinding *mute_cb, *volume_cb;
+
+ mute_cb = gst_object_get_control_binding (GST_OBJECT (self), "mute");
+ volume_cb = gst_object_get_control_binding (GST_OBJECT (self), "volume");
+
+ if (mute_cb || (volume_cb && !self->current_mute)) {
+ gint rate = GST_AUDIO_INFO_RATE (&filter->info);
+ gint width = GST_AUDIO_FORMAT_INFO_WIDTH (filter->info.finfo) / 8;
+ gint channels = GST_AUDIO_INFO_CHANNELS (&filter->info);
+ guint nsamples = map.size / (width * channels);
+ GstClockTime interval = gst_util_uint64_scale_int (1, GST_SECOND, rate);
+ gboolean have_mutes = FALSE;
+ gboolean have_volumes = FALSE;
+
+ if (self->mutes_count < nsamples && mute_cb) {
+ self->mutes = g_realloc (self->mutes, sizeof (gboolean) * nsamples);
+ self->mutes_count = nsamples;
+ }
- mute_cb = gst_object_get_control_binding (GST_OBJECT (self), "mute");
- volume_cb = gst_object_get_control_binding (GST_OBJECT (self), "volume");
-
- if (mute_cb || (volume_cb && !self->current_mute)) {
- gint rate = GST_AUDIO_INFO_RATE (&filter->info);
- gint width = GST_AUDIO_FORMAT_INFO_WIDTH (filter->info.finfo) / 8;
- gint channels = GST_AUDIO_INFO_CHANNELS (&filter->info);
- guint nsamples = map.size / (width * channels);
- GstClockTime interval = gst_util_uint64_scale_int (1, GST_SECOND, rate);
- GstClockTime ts = GST_BUFFER_TIMESTAMP (outbuf);
- gboolean have_mutes = FALSE;
- gboolean have_volumes = FALSE;
-
- ts = gst_segment_to_stream_time (&base->segment, GST_FORMAT_TIME, ts);
+ if (self->volumes_count < nsamples) {
+ self->volumes = g_realloc (self->volumes, sizeof (gdouble) * nsamples);
+ self->volumes_count = nsamples;
+ }
- if (self->mutes_count < nsamples && mute_cb) {
- self->mutes = g_realloc (self->mutes, sizeof (gboolean) * nsamples);
- self->mutes_count = nsamples;
- }
+ if (volume_cb) {
+ have_volumes =
+ gst_control_binding_get_value_array (volume_cb, ts, interval,
+ nsamples, (gpointer) self->volumes);
+ gst_object_replace ((GstObject **) & volume_cb, NULL);
+ }
+ if (!have_volumes) {
+ volume_orc_memset_f64 (self->volumes, self->current_volume, nsamples);
+ }
- if (self->volumes_count < nsamples) {
- self->volumes = g_realloc (self->volumes, sizeof (gdouble) * nsamples);
- self->volumes_count = nsamples;
- }
+ if (mute_cb) {
+ have_mutes = gst_control_binding_get_value_array (mute_cb, ts, interval,
+ nsamples, (gpointer) self->mutes);
+ gst_object_replace ((GstObject **) & mute_cb, NULL);
+ }
+ if (have_mutes) {
+ volume_orc_prepare_volumes (self->volumes, self->mutes, nsamples);
+ } else {
+ g_free (self->mutes);
+ self->mutes = NULL;
+ self->mutes_count = 0;
+ }
- if (volume_cb) {
- have_volumes =
- gst_control_binding_get_value_array (volume_cb, ts, interval,
- nsamples, (gpointer) self->volumes);
- gst_object_replace ((GstObject **) & volume_cb, NULL);
- }
- if (!have_volumes) {
- volume_orc_memset_f64 (self->volumes, self->current_volume, nsamples);
- }
+ self->process_controlled (self, map.data, self->volumes, channels,
+ map.size);
- if (mute_cb) {
- have_mutes = gst_control_binding_get_value_array (mute_cb, ts, interval,
- nsamples, (gpointer) self->mutes);
- gst_object_replace ((GstObject **) & mute_cb, NULL);
- }
- if (have_mutes) {
- volume_orc_prepare_volumes (self->volumes, self->mutes, nsamples);
- } else {
- g_free (self->mutes);
- self->mutes = NULL;
- self->mutes_count = 0;
+ goto done;
+ } else if (volume_cb) {
+ gst_object_unref (volume_cb);
}
-
- self->process_controlled (self, map.data, self->volumes, channels,
- map.size);
-
- goto done;
- } else if (volume_cb) {
- gst_object_unref (volume_cb);
}
if (self->current_volume == 0.0 || self->current_mute) {