Index: /components/AutomaticGainControl/trunk/AutomaticGainControl/AutomaticGainControl.cpp
===================================================================
--- /components/AutomaticGainControl/trunk/AutomaticGainControl/AutomaticGainControl.cpp	(revision 2411)
+++ /components/AutomaticGainControl/trunk/AutomaticGainControl/AutomaticGainControl.cpp	(revision 2433)
@@ -26,4 +26,6 @@
 #include "AutomaticGainControl.h"
 
+#undef VERBOSE
+
 AutomaticGainControl_i::AutomaticGainControl_i(const char *uuid, omni_condition *condition) : Resource_impl(uuid), component_running(condition) 
 {
@@ -31,8 +33,15 @@
     dataIn_0 = new standardInterfaces_i::complexShort_p("data_in");
 
+    // set initial values
+    // these particular values are good for 8kHz audio
+    energy_lo = 4000.0f;
+    energy_hi = 8000.0f;
+    k_attack = 0.002f;
+    k_release = 0.0005f;
+    g_min = 1.0f;
+    g_max = 100.0f;
 
     //Create the thread for the writer's processing function 
-    processing_thread = new omni_thread(process_data, (void *) this);
-
+    processing_thread = new omni_thread(run, (void *) this);
 
     //Start the thread containing the writer's processing function 
@@ -46,4 +55,9 @@
 }
 
+void AutomaticGainControl_i::run(void * data)
+{
+    ((AutomaticGainControl_i*) data)->run_loop();
+}
+
 CORBA::Object_ptr AutomaticGainControl_i::getPort( const char* portName ) throw (CORBA::SystemException, CF::PortSupplier::UnknownPort)
 {
@@ -90,4 +104,6 @@
 void AutomaticGainControl_i::configure(const CF::Properties& props) throw (CORBA::SystemException, CF::PropertySet::InvalidConfiguration, CF::PropertySet::PartialConfiguration)
 {
+    CORBA::Float simple_temp;
+
     std::cout << "configure called on AutomaticGainControl" << std::endl;
     
@@ -100,42 +116,67 @@
         if (strcmp(props[i].id, "DCE:aaf97fa0-d184-4d88-9954-3a1334c73d6d") == 0)
         {
-            CORBA::Float simple_temp;
-            props[i].value >>= simple_temp;
-            simple_0_value = simple_temp;
+            // energy_lo
+            props[i].value >>= simple_temp;
+            omni_mutex_lock oml(accessPrivateData);
+            energy_lo = simple_temp;
+#ifdef VERBOSE
+            std::cout << "AGC prop (energy_lo): " << simple_temp << std::endl;
+#endif
         }
 
         if (strcmp(props[i].id, "DCE:346e17c9-6678-483a-bffb-1909c64bddc0") == 0)
         {
-            CORBA::Float simple_temp;
-            props[i].value >>= simple_temp;
-            simple_1_value = simple_temp;
+            // energy_hi
+            props[i].value >>= simple_temp;
+            omni_mutex_lock oml(accessPrivateData);
+            energy_hi = simple_temp;
+#ifdef VERBOSE
+            std::cout << "AGC prop (energy_hi): " << simple_temp << std::endl;
+#endif
+
         }
 
         if (strcmp(props[i].id, "DCE:4608b943-4fe2-49df-91fb-afa287b609d4") == 0)
         {
-            CORBA::Float simple_temp;
-            props[i].value >>= simple_temp;
-            simple_2_value = simple_temp;
+            // k_attack
+            props[i].value >>= simple_temp;
+            omni_mutex_lock oml(accessPrivateData);
+            k_attack = simple_temp;
+#ifdef VERBOSE
+            std::cout << "AGC prop (k_attack): " << simple_temp << std::endl;
+#endif
         }
 
         if (strcmp(props[i].id, "DCE:491ec3de-ed45-48af-a6fc-ca2d6465e136") == 0)
         {
-            CORBA::Float simple_temp;
-            props[i].value >>= simple_temp;
-            simple_3_value = simple_temp;
+            // k_release
+            props[i].value >>= simple_temp;
+            omni_mutex_lock oml(accessPrivateData);
+            k_release = simple_temp;
+#ifdef VERBOSE
+            std::cout << "AGC prop (k_release): " << simple_temp << std::endl;
+#endif
         }
 
         if (strcmp(props[i].id, "DCE:312f63fe-709a-4217-933b-c584c8d6a9bb") == 0)
         {
-            CORBA::Float simple_temp;
-            props[i].value >>= simple_temp;
-            simple_4_value = simple_temp;
+            // g_min
+            props[i].value >>= simple_temp;
+            omni_mutex_lock oml(accessPrivateData);
+            g_min = simple_temp;
+#ifdef VERBOSE
+            std::cout << "AGC prop (g_min): " << simple_temp << std::endl;
+#endif
         }
 
         if (strcmp(props[i].id, "DCE:8357ee0d-2417-46d9-8475-2e5778d797e4") == 0)
         {
-            CORBA::Float simple_temp;
-            props[i].value >>= simple_temp;
-            simple_5_value = simple_temp;
+            // g_max
+            props[i].value >>= simple_temp;
+            omni_mutex_lock oml(accessPrivateData);
+            g_max = simple_temp;
+#ifdef VERBOSE
+            std::cout << "AGC prop (g_max): " << simple_temp << std::endl;
+#endif
         }
 
@@ -143,10 +184,9 @@
 }
 
-void process_data(void *data)
+
+void AutomaticGainControl_i::run_loop()
 {
     std::cout << "AutomaticGainControl's process_data thread started" << std::endl;
 
-    AutomaticGainControl_i *mem = (AutomaticGainControl_i *) data;
-    
     PortTypes::ShortSequence I_out, Q_out;
     
@@ -155,47 +195,58 @@
 
     unsigned int i, N;
-    float gain(0.0f), energy(0.0f);
+    short I, Q;
 
     SigProc::agc * agc;
 
-    // override properties
-    mem->energy_lo = 4000.0f;
-    mem->energy_hi = 16000.0f;
-    mem->k_attack = 0.5f;
-    mem->k_release = 0.0f;
-    mem->g_max = 10.0f;
-    mem->g_min = 0.1f;
-
-    agc = new SigProc::agc(
-                 mem->energy_lo,
-                 mem->energy_hi,
-                 mem->k_attack,
-                 mem->k_release,
-                 mem->g_max,
-                 mem->g_min
-              );
-
+    agc = new SigProc::agc();
+    agc->set_values(
+           energy_lo,
+           energy_hi,
+           k_attack,
+           k_release,
+           g_min,
+           g_max
+         );
 
     while( true )
     {
-        std::cout << "AGC waiting for data..." << std::endl;
-        mem->dataIn_0->getData(I_in, Q_in);
-        std::cout << "AGC got " << I_in->length() << " samples" << std::endl;
-        
+        dataIn_0->getData(I_in, Q_in);
+
+        // overwrite agc values with properties
+        // lock mutex for asynchronous configure() invocation
+        {
+            omni_mutex_lock oml(accessPrivateData);
+            agc->set_values(
+                   energy_lo,
+                   energy_hi,
+                   k_attack,
+                   k_release,
+                   g_min,
+                   g_max
+                 );
+        }
+
         N = I_in->length();
 
-        I_out.length(N); //must define length of output
-        Q_out.length(N); //must define length of output
+        I_out.length(N); // define output length
+        Q_out.length(N); // define output length
 
         for (i=0; i<N; i++)
         {
-            I_out[i] = (*I_in)[i];
-            Q_out[i] = (*Q_in)[i];
-            agc->do_work(I_out[i], Q_out[i], gain, energy);
-        }
-        std::cout << "gain: " << gain << ", energy: " << energy << std::endl;
-
-        mem->dataIn_0->bufferEmptied();
-        mem->dataOut_0->pushPacket(I_out, Q_out);
+            I = (*I_in)[i];
+            Q = (*Q_in)[i];
+            agc->do_work(I, Q);
+            I_out[i] = I;
+            Q_out[i] = Q;
+        }
+#ifdef VERBOSE
+        float gain(0.0f), energy(0.0f);
+        agc->get_status(gain, energy);
+        std::cout << "AutomaticGainControl: gain: " << gain
+                  << ", energy: " << energy << std::endl;
+#endif
+
+        dataIn_0->bufferEmptied();
+        dataOut_0->pushPacket(I_out, Q_out);
     }
 }
Index: /components/AutomaticGainControl/trunk/AutomaticGainControl/AutomaticGainControl.prf.xml
===================================================================
--- /components/AutomaticGainControl/trunk/AutomaticGainControl/AutomaticGainControl.prf.xml	(revision 2410)
+++ /components/AutomaticGainControl/trunk/AutomaticGainControl/AutomaticGainControl.prf.xml	(revision 2433)
@@ -6,25 +6,25 @@
     <simple type="float" id="DCE:aaf97fa0-d184-4d88-9954-3a1334c73d6d" name="energy_lo" mode="readonly">
         <description>low energy threshold</description> 
-        <value>8000</value> 
+        <value>4000</value> 
         <kind kindtype="configure"/>
     </simple>
     <simple type="float" id="DCE:346e17c9-6678-483a-bffb-1909c64bddc0" name="energy_hi" mode="readonly">
         <description>high energy threshold</description> 
-        <value>16000</value> 
+        <value>8000</value> 
         <kind kindtype="configure"/>
     </simple>
     <simple type="float" id="DCE:4608b943-4fe2-49df-91fb-afa287b609d4" name="k_attack" mode="readonly">
         <description>attack time constant</description> 
-        <value>0.5</value> 
+        <value>0.002</value> 
         <kind kindtype="configure"/>
     </simple>
     <simple type="float" id="DCE:491ec3de-ed45-48af-a6fc-ca2d6465e136" name="k_release" mode="readonly">
         <description>release time constant</description> 
-        <value>0.05</value> 
+        <value>0.0005</value> 
         <kind kindtype="configure"/>
     </simple>
     <simple type="float" id="DCE:312f63fe-709a-4217-933b-c584c8d6a9bb" name="g_min" mode="readonly">
         <description>minimum gain value</description> 
-        <value>0.1</value> 
+        <value>1</value> 
         <kind kindtype="configure"/>
     </simple>
Index: /components/AutomaticGainControl/trunk/AutomaticGainControl/AutomaticGainControl.h
===================================================================
--- /components/AutomaticGainControl/trunk/AutomaticGainControl/AutomaticGainControl.h	(revision 2411)
+++ /components/AutomaticGainControl/trunk/AutomaticGainControl/AutomaticGainControl.h	(revision 2433)
@@ -44,5 +44,5 @@
 {
 
-    friend void process_data(void *data);
+    //friend void process_data(void *data);
 
     public:
@@ -52,4 +52,5 @@
         void start() throw (CF::Resource::StartError, CORBA::SystemException);
         void stop() throw (CF::Resource::StopError, CORBA::SystemException);
+        static void run(void *data);
 
         CORBA::Object_ptr getPort( const char* portName ) throw (CF::PortSupplier::UnknownPort, CORBA::SystemException);
@@ -64,28 +65,22 @@
         AutomaticGainControl_i();
         AutomaticGainControl_i(AutomaticGainControl_i&);
-   
-        omni_condition *component_running;  //for component shutdown
-        omni_thread *processing_thread;     //for component writer function
+        
+        void run_loop();
+        
+        omni_condition *component_running;  // for component shutdown
+        omni_thread *processing_thread;     // for component writer function
+        omni_mutex accessPrivateData;       // for asynchronous configure() invocation
     	
-        CORBA::Float simple_0_value;
-        CORBA::Float simple_1_value;
-        CORBA::Float simple_2_value;
-        CORBA::Float simple_3_value;
-        CORBA::Float simple_4_value;
-        CORBA::Float simple_5_value;
-
-        
         //list components provides and uses ports
         standardInterfaces_i::complexShort_u *dataOut_0;
         standardInterfaces_i::complexShort_p *dataIn_0;
 
-
         // algorithm variables
-        float energy_lo;
-        float energy_hi; 
-        float k_attack;
-        float k_release;
-        float g_max;
-        float g_min;
+        float energy_lo;  // low energy threshold
+        float energy_hi;  // high energy threshold
+        float k_attack;   // attack time constant
+        float k_release;  // release time constant
+        float g_max;      // maximum gain
+        float g_min;      // minimum gain
         
 };
