gst_plugins_base/gst/volume/gstvolume.c
branchRCL_3
changeset 30 7e817e7e631c
parent 29 567bb019e3e3
--- a/gst_plugins_base/gst/volume/gstvolume.c	Tue Aug 31 15:30:33 2010 +0300
+++ b/gst_plugins_base/gst/volume/gstvolume.c	Wed Sep 01 12:16:41 2010 +0100
@@ -24,15 +24,19 @@
 /**
  * SECTION:element-volume
  *
+ * <refsect2>
+ * <para>
  * The volume element changes the volume of the audio data.
- *
- * <refsect2>
+ * </para>
  * <title>Example launch line</title>
- * |[
+ * <para>
+ * <programlisting>
  * gst-launch -v -m audiotestsrc ! volume volume=0.5 ! level ! fakesink silent=TRUE
- * ]| This pipeline shows that the level of audiotestsrc has been halved
+ * </programlisting>
+ * This pipeline shows that the level of audiotestsrc has been halved
  * (peak values are around -6 dB and RMS around -9 dB) compared to
  * the same pipeline without the volume element.
+ * </para>
  * </refsect2>
  */
 
@@ -48,10 +52,9 @@
 #include <gst/controller/gstcontroller.h>
 #include <gst/audio/audio.h>
 #include <gst/audio/gstaudiofilter.h>
-#include <liboil/liboil.h>
-#ifdef __SYMBIAN32__
-#include <liboil/globals.h>
-#endif
+
+#include <gst/liboil.h>
+
 #include "gstvolume.h"
 
 /* some defines for audio processing */
@@ -82,6 +85,11 @@
 #define GST_CAT_DEFAULT gst_volume_debug
 GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
 
+static const GstElementDetails volume_details = GST_ELEMENT_DETAILS ("Volume",
+    "Filter/Effect/Audio",
+    "Set volume on audio/raw streams",
+    "Andy Wingo <wingo@pobox.com>");
+
 /* Filter signals and args */
 enum
 {
@@ -89,12 +97,10 @@
   LAST_SIGNAL
 };
 
-#define DEFAULT_PROP_MUTE       FALSE
-#define DEFAULT_PROP_VOLUME     1.0
-
 enum
 {
   PROP_0,
+  PROP_SILENT,
   PROP_MUTE,
   PROP_VOLUME
 };
@@ -162,9 +168,9 @@
     const GValue * value, GParamSpec * pspec);
 static void volume_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * pspec);
+static void volume_update_volume (const GValue * value, gpointer data);
+static void volume_update_mute (const GValue * value, gpointer data);
 
-static void volume_before_transform (GstBaseTransform * base,
-    GstBuffer * buffer);
 static GstFlowReturn volume_transform_ip (GstBaseTransform * base,
     GstBuffer * outbuf);
 static gboolean volume_setup (GstAudioFilter * filter,
@@ -207,36 +213,36 @@
       switch (GST_AUDIO_FILTER (this)->format.width) {
         case 32:
           /* only clamp if the gain is greater than 1.0
-           * FIXME: current_vol_i can change while processing the buffer!
+           * FIXME: real_vol_i can change while processing the buffer!
            */
-          if (this->current_vol_i32 > VOLUME_UNITY_INT32)
+          if (this->real_vol_i32 > VOLUME_UNITY_INT32)
             this->process = volume_process_int32_clamp;
           else
             this->process = volume_process_int32;
           break;
         case 24:
           /* only clamp if the gain is greater than 1.0
-           * FIXME: current_vol_i can change while processing the buffer!
+           * FIXME: real_vol_i can change while processing the buffer!
            */
-          if (this->current_vol_i24 > VOLUME_UNITY_INT24)
+          if (this->real_vol_i24 > VOLUME_UNITY_INT24)
             this->process = volume_process_int24_clamp;
           else
             this->process = volume_process_int24;
           break;
         case 16:
           /* only clamp if the gain is greater than 1.0
-           * FIXME: current_vol_i can change while processing the buffer!
+           * FIXME: real_vol_i can change while processing the buffer!
            */
-          if (this->current_vol_i16 > VOLUME_UNITY_INT16)
+          if (this->real_vol_i16 > VOLUME_UNITY_INT16)
             this->process = volume_process_int16_clamp;
           else
             this->process = volume_process_int16;
           break;
         case 8:
           /* only clamp if the gain is greater than 1.0
-           * FIXME: current_vol_i can change while processing the buffer!
+           * FIXME: real_vol_i can change while processing the buffer!
            */
-          if (this->current_vol_i16 > VOLUME_UNITY_INT8)
+          if (this->real_vol_i16 > VOLUME_UNITY_INT8)
             this->process = volume_process_int8_clamp;
           else
             this->process = volume_process_int8;
@@ -260,43 +266,27 @@
   return (this->process != NULL);
 }
 
-static gboolean
-volume_update_volume (GstVolume * this, gfloat volume, gboolean mute)
+static void
+volume_update_real_volume (GstVolume * this)
 {
-  gboolean passthrough;
-  gboolean res;
-
-  GST_DEBUG_OBJECT (this, "configure mute %d, volume %f", mute, volume);
+  gboolean passthrough = FALSE;
 
-  if (mute) {
-    this->current_mute = TRUE;
-    this->current_volume = 0.0;
-
-    this->current_vol_i8 = 0;
-    this->current_vol_i16 = 0;
-    this->current_vol_i24 = 0;
-    this->current_vol_i32 = 0;
-
-    passthrough = FALSE;
+  if (this->mute) {
+    this->real_vol_f = 0.0;
+    this->real_vol_i8 = this->real_vol_i16 = this->real_vol_i24 =
+        this->real_vol_i32 = 0;
   } else {
-    this->current_mute = FALSE;
-    this->current_volume = volume;
-
-    this->current_vol_i8 = volume * VOLUME_UNITY_INT8;
-    this->current_vol_i16 = volume * VOLUME_UNITY_INT16;
-    this->current_vol_i24 = volume * VOLUME_UNITY_INT24;
-    this->current_vol_i32 = volume * VOLUME_UNITY_INT32;
-
-    passthrough = (this->current_vol_i16 == VOLUME_UNITY_INT16);
+    this->real_vol_f = this->volume_f;
+    this->real_vol_i8 = this->volume_i8;
+    this->real_vol_i16 = this->volume_i16;
+    this->real_vol_i24 = this->volume_i24;
+    this->real_vol_i32 = this->volume_i32;
+    passthrough = (this->volume_i16 == VOLUME_UNITY_INT16);
   }
-
-  GST_DEBUG_OBJECT (this, "set passthrough %d", passthrough);
-
+  if (this->real_vol_f != 0.0)
+    this->silent_buffer = FALSE;
+  volume_choose_func (this);
   gst_base_transform_set_passthrough (GST_BASE_TRANSFORM (this), passthrough);
-
-  res = this->negotiated = volume_choose_func (this);
-
-  return res;
 }
 
 /* Mixer interface */
@@ -304,7 +294,7 @@
 static gboolean
 gst_volume_interface_supported (GstImplementsInterface * iface, GType type)
 {
-  g_return_val_if_fail (type == GST_TYPE_MIXER, FALSE);
+  g_assert (type == GST_TYPE_MIXER);
   return TRUE;
 }
 
@@ -333,9 +323,13 @@
   g_return_if_fail (this != NULL);
   g_return_if_fail (GST_IS_VOLUME (this));
 
-  GST_OBJECT_LOCK (this);
-  this->volume = (gfloat) volumes[0] / VOLUME_STEPS;
-  GST_OBJECT_UNLOCK (this);
+  this->volume_f = (gfloat) volumes[0] / VOLUME_STEPS;
+  this->volume_i32 = this->volume_f * VOLUME_UNITY_INT32;
+  this->volume_i24 = this->volume_f * VOLUME_UNITY_INT24;
+  this->volume_i16 = this->volume_f * VOLUME_UNITY_INT16;
+  this->volume_i8 = this->volume_f * VOLUME_UNITY_INT8;
+
+  volume_update_real_volume (this);
 }
 
 static void
@@ -346,9 +340,7 @@
   g_return_if_fail (this != NULL);
   g_return_if_fail (GST_IS_VOLUME (this));
 
-  GST_OBJECT_LOCK (this);
-  volumes[0] = (gint) this->volume * VOLUME_STEPS;
-  GST_OBJECT_UNLOCK (this);
+  volumes[0] = (gint) this->volume_f * VOLUME_STEPS;
 }
 
 static void
@@ -359,9 +351,9 @@
   g_return_if_fail (this != NULL);
   g_return_if_fail (GST_IS_VOLUME (this));
 
-  GST_OBJECT_LOCK (this);
   this->mute = mute;
-  GST_OBJECT_UNLOCK (this);
+
+  volume_update_real_volume (this);
 }
 
 static void
@@ -400,9 +392,7 @@
   GstAudioFilterClass *filter_class = GST_AUDIO_FILTER_CLASS (g_class);
   GstCaps *caps;
 
-  gst_element_class_set_details_simple (element_class, "Volume",
-      "Filter/Effect/Audio",
-      "Set volume on audio/raw streams", "Andy Wingo <wingo@pobox.com>");
+  gst_element_class_set_details (element_class, &volume_details);
 
   caps = gst_caps_from_string (ALLOWED_CAPS);
   gst_audio_filter_class_add_pad_templates (filter_class, caps);
@@ -426,15 +416,15 @@
 
   g_object_class_install_property (gobject_class, PROP_MUTE,
       g_param_spec_boolean ("mute", "Mute", "mute channel",
-          DEFAULT_PROP_MUTE,
-          G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
+          FALSE, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
 
   g_object_class_install_property (gobject_class, PROP_VOLUME,
-      g_param_spec_double ("volume", "Volume", "volume factor, 1.0=100%",
-          0.0, VOLUME_MAX_DOUBLE, DEFAULT_PROP_VOLUME,
-          G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
+      g_param_spec_double ("volume", "Volume", "volume factor",
+          0.0, VOLUME_MAX_DOUBLE, 1.0,
+          G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
 
-  trans_class->before_transform = GST_DEBUG_FUNCPTR (volume_before_transform);
+  GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "volume", 0, "Volume gain");
+
   trans_class->transform_ip = GST_DEBUG_FUNCPTR (volume_transform_ip);
   filter_class->setup = GST_DEBUG_FUNCPTR (volume_setup);
 }
@@ -444,11 +434,13 @@
 {
   GstMixerTrack *track = NULL;
 
-  this->mute = DEFAULT_PROP_MUTE;;
-  this->volume = DEFAULT_PROP_VOLUME;
-
+  this->mute = FALSE;
+  this->volume_i8 = this->real_vol_i8 = VOLUME_UNITY_INT8;
+  this->volume_i16 = this->real_vol_i16 = VOLUME_UNITY_INT16;
+  this->volume_i24 = this->real_vol_i24 = VOLUME_UNITY_INT24;
+  this->volume_i32 = this->real_vol_i32 = VOLUME_UNITY_INT32;
+  this->volume_f = this->real_vol_f = 1.0;
   this->tracklist = NULL;
-  this->negotiated = FALSE;
 
   track = g_object_new (GST_TYPE_MIXER_TRACK, NULL);
 
@@ -464,15 +456,20 @@
   gst_base_transform_set_gap_aware (GST_BASE_TRANSFORM (this), TRUE);
 }
 
+/* NOTE: although it might be tempting to have volume_process_mute() which uses
+ *       memset(bytes, 0, nbytes) for the vol=0 case, this has the downside that
+ *       unmuting would only take place after processing a buffer.
+ */
+
 static void
 volume_process_double (GstVolume * this, gpointer bytes, guint n_bytes)
 {
   gdouble *data = (gdouble *) bytes;
-  guint num_samples = n_bytes / sizeof (gdouble);
+  guint i, num_samples = n_bytes / sizeof (gdouble);
 
-  gdouble vol = this->current_volume;
-
-  oil_scalarmultiply_f64_ns (data, data, &vol, num_samples);
+  for (i = 0; i < num_samples; i++) {
+    *data++ *= this->real_vol_f;
+  }
 }
 
 static void
@@ -481,17 +478,16 @@
   gfloat *data = (gfloat *) bytes;
   guint num_samples = n_bytes / sizeof (gfloat);
 
-#if 0
-  guint i;
-
-  for (i = 0; i < num_samples; i++) {
-    *data++ *= this->real_vol_f;
-  }
-  /* time "gst-launch 2>/dev/null audiotestsrc wave=7 num-buffers=10000 ! audio/x-raw-float !
-   * volume volume=1.5 ! fakesink" goes from 0m0.850s -> 0m0.717s with liboil
+  /*
+     guint i;
+     for (i = 0; i < num_samples; i++) {
+     *data++ *= this->real_vol_f;
+     }
    */
-#endif
-  oil_scalarmultiply_f32_ns (data, data, &this->current_volume, num_samples);
+  /* time gst-launch 2>/dev/null audiotestsrc wave=7 num-buffers=10000 ! audio/x-raw-float ! volume volume=1.5 ! fakesink
+   * goes from 0m0.850s -> 0m0.717s with liboil
+   */
+  oil_scalarmultiply_f32_ns (data, data, &this->real_vol_f, num_samples);
 }
 
 static void
@@ -505,9 +501,7 @@
   for (i = 0; i < num_samples; i++) {
     /* we use bitshifting instead of dividing by UNITY_INT for speed */
     val = (gint64) * data;
-    val =
-        (((gint64) this->current_vol_i32 *
-            val) >> VOLUME_UNITY_INT32_BIT_SHIFT);
+    val = (((gint64) this->real_vol_i32 * val) >> VOLUME_UNITY_INT32_BIT_SHIFT);
     *data++ = (gint32) val;
   }
 }
@@ -524,31 +518,17 @@
   for (i = 0; i < num_samples; i++) {
     /* we use bitshifting instead of dividing by UNITY_INT for speed */
     val = (gint64) * data;
-    val =
-        (((gint64) this->current_vol_i32 *
-            val) >> VOLUME_UNITY_INT32_BIT_SHIFT);
+    val = (((gint64) this->real_vol_i32 * val) >> VOLUME_UNITY_INT32_BIT_SHIFT);
     *data++ = (gint32) CLAMP (val, VOLUME_MIN_INT32, VOLUME_MAX_INT32);
   }
 }
 
 #if (G_BYTE_ORDER == G_LITTLE_ENDIAN)
 #define get_unaligned_i24(_x) ( (((guint8*)_x)[0]) | ((((guint8*)_x)[1]) << 8) | ((((gint8*)_x)[2]) << 16) )
-
-#define write_unaligned_u24(_x,samp) \
-G_STMT_START { \
-  *(_x)++ = samp & 0xFF; \
-  *(_x)++ = (samp >> 8) & 0xFF; \
-  *(_x)++ = (samp >> 16) & 0xFF; \
-} G_STMT_END
-
+#define write_unaligned_u24(_x,samp) do { *(_x)++ = samp & 0xFF; *(_x)++ = (samp >> 8) & 0xFF; *(_x)++ = (samp >> 16) & 0xFF; } while (0)
 #else /* BIG ENDIAN */
 #define get_unaligned_i24(_x) ( (((guint8*)_x)[2]) | ((((guint8*)_x)[1]) << 8) | ((((gint8*)_x)[0]) << 16) )
-#define write_unaligned_u24(_x,samp) \
-G_STMT_START { \
-  *(_x)++ = (samp >> 16) & 0xFF; \
-  *(_x)++ = (samp >> 8) & 0xFF; \
-  *(_x)++ = samp & 0xFF; \
-} G_STMT_END
+#define write_unaligned_u24(_x,samp) do { *(_x)++ = (samp >> 16) & 0xFF; *(_x)++ = (samp >> 8) & 0xFF; *(_x)++ = samp & 0xFF; } while (0)
 #endif
 
 static void
@@ -564,9 +544,7 @@
     samp = get_unaligned_i24 (data);
 
     val = (gint32) samp;
-    val =
-        (((gint64) this->current_vol_i24 *
-            val) >> VOLUME_UNITY_INT24_BIT_SHIFT);
+    val = (((gint64) this->real_vol_i24 * val) >> VOLUME_UNITY_INT24_BIT_SHIFT);
     samp = (guint32) val;
 
     /* write the value back into the stream */
@@ -587,9 +565,7 @@
     samp = get_unaligned_i24 (data);
 
     val = (gint32) samp;
-    val =
-        (((gint64) this->current_vol_i24 *
-            val) >> VOLUME_UNITY_INT24_BIT_SHIFT);
+    val = (((gint64) this->real_vol_i24 * val) >> VOLUME_UNITY_INT24_BIT_SHIFT);
     samp = (guint32) CLAMP (val, VOLUME_MIN_INT24, VOLUME_MAX_INT24);
 
     /* write the value back into the stream */
@@ -611,8 +587,7 @@
     /* we use bitshifting instead of dividing by UNITY_INT for speed */
     val = (gint) * data;
     *data++ =
-        (gint16) ((this->current_vol_i16 *
-            val) >> VOLUME_UNITY_INT16_BIT_SHIFT);
+        (gint16) ((this->real_vol_i16 * val) >> VOLUME_UNITY_INT16_BIT_SHIFT);
   }
 #else
   /* FIXME: need oil_scalarmultiply_s16_ns ?
@@ -623,7 +598,7 @@
    * time gst-launch 2>/dev/null audiotestsrc wave=7 num-buffers=100 ! volume volume=1.5 ! fakesink
    */
   oil_scalarmult_s16 (data, 0, data, 0,
-      ((gint16 *) (void *) (&this->current_vol_i)), num_samples);
+      ((gint16 *) (void *) (&this->real_vol_i)), num_samples);
 #endif
 }
 
@@ -643,7 +618,7 @@
     /* we use bitshifting instead of dividing by UNITY_INT for speed */
     val = (gint) * data;
     *data++ =
-        (gint16) CLAMP ((this->current_vol_i16 *
+        (gint16) CLAMP ((this->real_vol_i16 *
             val) >> VOLUME_UNITY_INT16_BIT_SHIFT, VOLUME_MIN_INT16,
         VOLUME_MAX_INT16);
   }
@@ -661,7 +636,7 @@
     /* we use bitshifting instead of dividing by UNITY_INT for speed */
     val = (gint) * data;
     *data++ =
-        (gint8) ((this->current_vol_i8 * val) >> VOLUME_UNITY_INT8_BIT_SHIFT);
+        (gint8) ((this->real_vol_i8 * val) >> VOLUME_UNITY_INT8_BIT_SHIFT);
   }
 }
 
@@ -678,7 +653,7 @@
     /* we use bitshifting instead of dividing by UNITY_INT for speed */
     val = (gint) * data;
     *data++ =
-        (gint8) CLAMP ((this->current_vol_i8 *
+        (gint8) CLAMP ((this->real_vol_i8 *
             val) >> VOLUME_UNITY_INT8_BIT_SHIFT, VOLUME_MIN_INT8,
         VOLUME_MAX_INT8);
   }
@@ -690,57 +665,14 @@
 static gboolean
 volume_setup (GstAudioFilter * filter, GstRingBufferSpec * format)
 {
-  gboolean res;
   GstVolume *this = GST_VOLUME (filter);
-  gfloat volume;
-  gboolean mute;
 
-  GST_OBJECT_LOCK (this);
-  volume = this->volume;
-  mute = this->mute;
-  GST_OBJECT_UNLOCK (this);
-
-  res = volume_update_volume (this, volume, mute);
-  if (!res) {
+  if (volume_choose_func (this)) {
+    return TRUE;
+  } else {
     GST_ELEMENT_ERROR (this, CORE, NEGOTIATION,
         ("Invalid incoming format"), (NULL));
-  }
-  this->negotiated = res;
-
-  return res;
-}
-
-static void
-volume_before_transform (GstBaseTransform * base, GstBuffer * buffer)
-{
-  GstClockTime timestamp;
-  GstVolume *this = GST_VOLUME (base);
-  gfloat volume;
-  gboolean mute;
-
-  /* FIXME: if controllers are bound, subdivide GST_BUFFER_SIZE into small
-   * chunks for smooth fades, what is small? 1/10th sec.
-   */
-  timestamp = GST_BUFFER_TIMESTAMP (buffer);
-  timestamp =
-      gst_segment_to_stream_time (&base->segment, GST_FORMAT_TIME, timestamp);
-
-  GST_DEBUG_OBJECT (base, "sync to %" GST_TIME_FORMAT,
-      GST_TIME_ARGS (timestamp));
-
-  if (GST_CLOCK_TIME_IS_VALID (timestamp))
-    gst_object_sync_values (G_OBJECT (this), timestamp);
-
-  /* get latest values */
-  GST_OBJECT_LOCK (this);
-  volume = this->volume;
-  mute = this->mute;
-  GST_OBJECT_UNLOCK (this);
-
-  if ((volume != this->current_volume) || (mute != this->current_mute)) {
-    /* the volume or mute was updated, update our internal state before
-     * we continue processing. */
-    volume_update_volume (this, volume, mute);
+    return FALSE;
   }
 }
 
@@ -752,36 +684,68 @@
 volume_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
 {
   GstVolume *this = GST_VOLUME (base);
-  guint8 *data;
-  guint size;
+  GstClockTime timestamp;
 
-  if (G_UNLIKELY (!this->negotiated))
-    goto not_negotiated;
+  /* FIXME: if controllers are bound, subdivide GST_BUFFER_SIZE into small
+   * chunks for smooth fades, what is small? 1/10th sec.
+   */
+  timestamp = GST_BUFFER_TIMESTAMP (outbuf);
+  timestamp =
+      gst_segment_to_stream_time (&base->segment, GST_FORMAT_TIME, timestamp);
+
+  GST_DEBUG_OBJECT (base, "sync to %" GST_TIME_FORMAT,
+      GST_TIME_ARGS (timestamp));
+
+  if (GST_CLOCK_TIME_IS_VALID (timestamp))
+    gst_object_sync_values (G_OBJECT (this), timestamp);
 
   /* don't process data in passthrough-mode */
   if (gst_base_transform_is_passthrough (base) ||
       GST_BUFFER_FLAG_IS_SET (outbuf, GST_BUFFER_FLAG_GAP))
     return GST_FLOW_OK;
 
-  data = GST_BUFFER_DATA (outbuf);
-  size = GST_BUFFER_SIZE (outbuf);
+  if (this->real_vol_f == 0.0)
+    this->silent_buffer = TRUE;
+
+  this->process (this, GST_BUFFER_DATA (outbuf), GST_BUFFER_SIZE (outbuf));
+
+  if (this->silent_buffer)
+    GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_GAP);
+  this->silent_buffer = FALSE;
+
+  return GST_FLOW_OK;
+}
 
-  if (this->current_volume == 0.0) {
-    memset (data, 0, size);
-    GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_GAP);
-  } else if (this->current_volume != 1.0) {
-    this->process (this, data, size);
+static void
+volume_update_mute (const GValue * value, gpointer data)
+{
+  GstVolume *this = (GstVolume *) data;
+
+  g_return_if_fail (GST_IS_VOLUME (this));
+
+  if (G_VALUE_HOLDS_BOOLEAN (value)) {
+    this->mute = g_value_get_boolean (value);
+  } else if (G_VALUE_HOLDS_INT (value)) {
+    this->mute = (g_value_get_int (value) == 1);
   }
 
-  return GST_FLOW_OK;
+  volume_update_real_volume (this);
+}
+
+static void
+volume_update_volume (const GValue * value, gpointer data)
+{
+  GstVolume *this = (GstVolume *) data;
 
-  /* ERRORS */
-not_negotiated:
-  {
-    GST_ELEMENT_ERROR (this, CORE, NEGOTIATION,
-        ("No format was negotiated"), (NULL));
-    return GST_FLOW_NOT_NEGOTIATED;
-  }
+  g_return_if_fail (GST_IS_VOLUME (this));
+
+  this->volume_f = g_value_get_double (value);
+  this->volume_i8 = this->volume_f * VOLUME_UNITY_INT8;
+  this->volume_i16 = this->volume_f * VOLUME_UNITY_INT16;
+  this->volume_i24 = this->volume_f * VOLUME_UNITY_INT24;
+  this->volume_i32 = this->volume_f * VOLUME_UNITY_INT32;
+
+  volume_update_real_volume (this);
 }
 
 static void
@@ -792,14 +756,10 @@
 
   switch (prop_id) {
     case PROP_MUTE:
-      GST_OBJECT_LOCK (this);
-      this->mute = g_value_get_boolean (value);
-      GST_OBJECT_UNLOCK (this);
+      volume_update_mute (value, this);
       break;
     case PROP_VOLUME:
-      GST_OBJECT_LOCK (this);
-      this->volume = g_value_get_double (value);
-      GST_OBJECT_UNLOCK (this);
+      volume_update_volume (value, this);
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -815,14 +775,10 @@
 
   switch (prop_id) {
     case PROP_MUTE:
-      GST_OBJECT_LOCK (this);
       g_value_set_boolean (value, this->mute);
-      GST_OBJECT_UNLOCK (this);
       break;
     case PROP_VOLUME:
-      GST_OBJECT_LOCK (this);
-      g_value_set_double (value, this->volume);
-      GST_OBJECT_UNLOCK (this);
+      g_value_set_double (value, this->volume_f);
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -833,17 +789,13 @@
 static gboolean
 plugin_init (GstPlugin * plugin)
 {
+#ifndef __SYMBIAN32__
   oil_init ();
+#endif  
 
   /* initialize gst controller library */
   gst_controller_init (NULL, NULL);
 
-  GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "volume", 0, "Volume gain");
-
-  /* ref class from a thread-safe context to work around missing bit of
-   * thread-safety in GObject */
-  g_type_class_ref (GST_TYPE_MIXER_TRACK);
-
   return gst_element_register (plugin, "volume", GST_RANK_NONE,
       GST_TYPE_VOLUME);
 }