I had a look at this testsuite failure:

  FAIL: Microphone_asv7.swf: setGain(77) failed, got 76 Microphone_as.hx: 244
  FAIL: Microphone_asv8.swf: setGain(77) failed, got 76 Microphone_as.hx: 244
  FAIL: Microphone_asv6.swf: setGain(77) failed, got 76 Microphone_as.hx: 244

The cause is in the gst implementation of setGain()/gain(), which
transform the input value of 0-100 to -60-60, and get a rounding error
that converts 77 to 76.

To avoid this, I propose to change the AudioInputGst class
implementation to store the original value set using setGain() in its
state, and convert it to the gst range when it is passed to gstreamer.
This patch implement that change.

In addition, I noticed from
<URL: 
http://www.adobe.us/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary490.html
 >
that the default gain value should be 50, so the default need to
change when the object is created.

diff --git a/libmedia/gst/AudioInputGst.cpp b/libmedia/gst/AudioInputGst.cpp
index d3bbadb..b8e6c2b 100644
--- a/libmedia/gst/AudioInputGst.cpp
+++ b/libmedia/gst/AudioInputGst.cpp
@@ -61,7 +61,7 @@ GnashAudioPrivate::GnashAudioPrivate() {
 AudioInputGst::AudioInputGst()
     :
     _activityLevel(-1),
-    _gain(0),
+    _gain(50),
     _index(0),
     _muted(true),
     _rate(8000),
@@ -306,10 +306,13 @@ AudioInputGst::audioChangeSourceBin(GnashAudioPrivate 
*audio)
         return true;
     }

+    /// Interface range is 0..100, gst range is -60 to 60
+    double gstgain = (gain() - 50) * 1.2;
+
     command = g_strdup_printf ("%s name=audioSource device=%s ! capsfilter 
name=capsfilter 
caps=audio/x-raw-int,signed=true,channels=2,rate=%i;audio/x-raw-float,channels=2,rate=%i
 ! rgvolume pre-amp=%f",
         audio->_audioDevice->getGstreamerSrc(),
         audio->_audioDevice->getDevLocation(),
-        _rate, _rate, _gain);
+        _rate, _rate, gstgain);

     log_debug ("GstPipeline command is: %s\n", command);

@@ -362,10 +365,14 @@ AudioInputGst::audioCreateSourceBin(GnashAudioPrivate 
*audio)
                     "audioSource");
         return true;
     } else {
+
+    /// Interface range is 0..100, gst range is -60 to 60
+    double gstgain = (gain() - 50) * 1.2;
+
     command = g_strdup_printf ("%s name=audioSource device=%s ! capsfilter 
name=capsfilter 
caps=audio/x-raw-int,signed=true,channels=2,rate=%i;audio/x-raw-float,channels=2,rate=%i
 ! rgvolume pre-amp=%f",
         audio->_audioDevice->getGstreamerSrc(),
         audio->_audioDevice->getDevLocation(),
-        _rate, _rate, _gain);
+        _rate, _rate, gstgain);

     log_debug ("GstPipeline command is: %s", command);

diff --git a/libmedia/gst/AudioInputGst.h b/libmedia/gst/AudioInputGst.h
index 12485fc..6c66308 100644
--- a/libmedia/gst/AudioInputGst.h
+++ b/libmedia/gst/AudioInputGst.h
@@ -260,22 +260,20 @@ public:

     /// Set the input's gain
     //
-    /// Interface range is 0..100, gst range is -60 to 60
     /// TODO: shouldn't we set the value in the input rather than storing
     /// it here?
     virtual void setGain(double g) {
         assert (g >= 0 && g <= 100);
-        _gain = (g - 50) * 1.2;
+        _gain = g;
         audioChangeSourceBin(getGlobalAudio());
     }

     /// Get the input's gain
     //
-    /// Interface range is 0..100, gst range is -60 to 60
     /// TODO: shouldn't we query the value from the input rather than storing
     /// it here?
     virtual double gain() const {
-        return (_gain / 1.2) + 50;
+        return _gain;
     }

     virtual void setIndex(int i) {

Is this change sensible?

Happy hacking,
-- 
Petter Reinholdtsen

_______________________________________________
Gnash-dev mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/gnash-dev

Reply via email to