Changeset 1158
- Timestamp:
- 05/10/08 12:38:38 (15 years ago)
- Files:
-
- trunk/libffado/src/bebob/bebob_mixer.cpp (modified) (4 diffs)
- trunk/libffado/src/bebob/bebob_mixer.h (modified) (3 diffs)
- trunk/libffado/src/bebob/focusrite/focusrite_generic.cpp (modified) (9 diffs)
- trunk/libffado/src/bebob/focusrite/focusrite_generic.h (modified) (3 diffs)
- trunk/libffado/src/bebob/focusrite/focusrite_saffire.cpp (modified) (1 diff)
- trunk/libffado/src/bebob/focusrite/focusrite_saffirepro.cpp (modified) (6 diffs)
- trunk/libffado/src/bebob/focusrite/focusrite_saffirepro.h (modified) (1 diff)
- trunk/libffado/src/devicemanager.cpp (modified) (2 diffs)
- trunk/libffado/src/ffadodevice.cpp (modified) (3 diffs)
- trunk/libffado/src/fireworks/fireworks_control.cpp (modified) (8 diffs)
- trunk/libffado/src/fireworks/fireworks_control.h (modified) (3 diffs)
- trunk/libffado/src/fireworks/fireworks_device.cpp (modified) (1 diff)
- trunk/libffado/src/libavc/general/avc_plug.cpp (modified) (1 diff)
- trunk/libffado/src/libavc/general/avc_unit.cpp (modified) (1 diff)
- trunk/libffado/src/libcontrol/BasicElements.cpp (modified) (1 diff)
- trunk/libffado/src/libcontrol/BasicElements.h (modified) (6 diffs)
- trunk/libffado/src/libcontrol/ClockSelect.cpp (modified) (1 diff)
- trunk/libffado/src/libcontrol/Element.cpp (modified) (8 diffs)
- trunk/libffado/src/libcontrol/Element.h (modified) (6 diffs)
- trunk/libffado/src/libcontrol/MatrixMixer.cpp (modified) (1 diff)
- trunk/libffado/src/libcontrol/MatrixMixer.h (modified) (1 diff)
- trunk/libffado/src/libcontrol/Nickname.cpp (modified) (1 diff)
- trunk/libffado/src/libieee1394/configrom.cpp (modified) (2 diffs)
- trunk/libffado/src/motu/motu_avdevice.cpp (modified) (2 diffs)
- trunk/libffado/src/motu/motu_controls.cpp (modified) (2 diffs)
- trunk/libffado/src/motu/motu_controls.h (modified) (1 diff)
- trunk/libffado/support/dbus/controlserver.cpp (modified) (5 diffs)
- trunk/libffado/support/dbus/controlserver.h (modified) (1 diff)
- trunk/libffado/support/dbus/ffado-dbus-server.cpp (modified) (2 diffs)
- trunk/libffado/support/dbus/test-dbus-server.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/src/bebob/bebob_mixer.cpp
r1156 r1158 57 57 58 58 Mixer::Mixer(AvDevice &d) 59 : Control::Container( )59 : Control::Container(&d) 60 60 , m_device(d) 61 61 { … … 197 197 198 198 MixerFBFeature::MixerFBFeature(Mixer& parent, FunctionBlockFeature& s) 199 : Control::Continuous( )199 : Control::Continuous(&parent) 200 200 , m_Parent(parent) 201 201 , m_Slave(s) … … 248 248 249 249 EnhancedMixerFBFeature::EnhancedMixerFBFeature(Mixer& parent, FunctionBlockEnhancedMixer& s) 250 : Control::Continuous( )250 : Control::Continuous(&parent) 251 251 , m_Parent(parent) 252 252 , m_Slave(s) … … 287 287 288 288 MixerFBSelector::MixerFBSelector(Mixer& parent, FunctionBlockSelector& s) 289 : Control::Discrete( )289 : Control::Discrete(&parent) 290 290 , m_Parent(parent) 291 291 , m_Slave(s) trunk/libffado/src/bebob/bebob_mixer.h
r973 r1158 79 79 virtual bool setValue(int idx, double v); 80 80 virtual double getValue(int idx); 81 virtual double getMinimum() {return 0.0;}; 82 virtual double getMaximum() {return 0.0;}; 81 83 82 84 private: … … 93 95 virtual bool setValue(double v); 94 96 virtual double getValue(); 97 virtual bool setValue(int idx, double v) 98 {return setValue(v);}; 99 virtual double getValue(int idx) 100 {return getValue();}; 101 102 virtual double getMinimum() {return 0.0;}; 103 virtual double getMaximum() {return 0.0;}; 95 104 96 105 private: … … 107 116 virtual bool setValue(int v); 108 117 virtual int getValue(); 118 virtual bool setValue(int idx, int v) 119 {return setValue(v);}; 120 virtual int getValue(int idx) 121 {return getValue();}; 122 123 virtual int getMinimum() {return 0;}; 124 virtual int getMaximum() {return 0;}; 109 125 110 126 private: trunk/libffado/src/bebob/focusrite/focusrite_generic.cpp
r1136 r1158 201 201 202 202 BinaryControl::BinaryControl(FocusriteDevice& parent, int id, int bit) 203 : Control::Discrete( )203 : Control::Discrete(&parent) 204 204 , m_Parent(parent) 205 205 , m_cmd_id ( id ) … … 208 208 BinaryControl::BinaryControl(FocusriteDevice& parent, int id, int bit, 209 209 std::string name, std::string label, std::string descr) 210 : Control::Discrete( )210 : Control::Discrete(&parent) 211 211 , m_Parent(parent) 212 212 , m_cmd_id ( id ) … … 263 263 264 264 VolumeControl::VolumeControl(FocusriteDevice& parent, int id) 265 : Control::Discrete( )265 : Control::Discrete(&parent) 266 266 , m_Parent(parent) 267 267 , m_cmd_id ( id ) … … 269 269 VolumeControl::VolumeControl(FocusriteDevice& parent, int id, 270 270 std::string name, std::string label, std::string descr) 271 : Control::Discrete( )271 : Control::Discrete(&parent) 272 272 , m_Parent(parent) 273 273 , m_cmd_id ( id ) … … 310 310 // reg control 311 311 RegisterControl::RegisterControl(FocusriteDevice& parent) 312 : Control::Register( )312 : Control::Register(&parent) 313 313 , m_Parent(parent) 314 314 {} 315 315 RegisterControl::RegisterControl(FocusriteDevice& parent, 316 316 std::string name, std::string label, std::string descr) 317 : Control::Register( )317 : Control::Register(&parent) 318 318 , m_Parent(parent) 319 319 { … … 352 352 // low resolution volume control 353 353 VolumeControlLowRes::VolumeControlLowRes(FocusriteDevice& parent, int id, int shift) 354 : Control::Discrete( )354 : Control::Discrete(&parent) 355 355 , m_Parent(parent) 356 356 , m_cmd_id ( id ) … … 359 359 VolumeControlLowRes::VolumeControlLowRes(FocusriteDevice& parent, int id, int shift, 360 360 std::string name, std::string label, std::string descr) 361 : Control::Discrete( )361 : Control::Discrete(&parent) 362 362 , m_Parent(parent) 363 363 , m_cmd_id ( id ) … … 415 415 // Saffire pro matrix mixer element 416 416 FocusriteMatrixMixer::FocusriteMatrixMixer(FocusriteDevice& p) 417 : Control::MatrixMixer( "MatrixMixer")417 : Control::MatrixMixer(&p, "MatrixMixer") 418 418 , m_Parent(p) 419 419 { … … 421 421 422 422 FocusriteMatrixMixer::FocusriteMatrixMixer(FocusriteDevice& p,std::string n) 423 : Control::MatrixMixer( n)423 : Control::MatrixMixer(&p, n) 424 424 , m_Parent(p) 425 425 { trunk/libffado/src/bebob/focusrite/focusrite_generic.h
r965 r1158 49 49 virtual bool setValue(int v); 50 50 virtual int getValue(); 51 51 virtual bool setValue(int idx, int v) 52 {return setValue(v);}; 53 virtual int getValue(int idx) 54 {return getValue();}; 55 56 virtual int getMinimum() {return 0;}; 57 virtual int getMaximum() {return 1;}; 58 52 59 private: 53 60 FocusriteDevice& m_Parent; … … 63 70 VolumeControl(FocusriteDevice& parent, int id, 64 71 std::string name, std::string label, std::string descr); 65 72 66 73 virtual bool setValue(int v); 67 74 virtual int getValue(); 68 75 virtual bool setValue(int idx, int v) 76 {return setValue(v);}; 77 virtual int getValue(int idx) 78 {return getValue();}; 79 80 virtual int getMinimum() {return 0;}; 81 virtual int getMaximum() {return 0x07FFF;}; 82 69 83 private: 70 84 FocusriteDevice& m_Parent; … … 97 111 virtual bool setValue(int v); 98 112 virtual int getValue(); 99 113 virtual bool setValue(int idx, int v) 114 {return setValue(v);}; 115 virtual int getValue(int idx) 116 {return getValue();}; 117 118 virtual int getMinimum() {return 0;}; 119 virtual int getMaximum() {return 0x0FF;}; 100 120 private: 101 121 FocusriteDevice& m_Parent; trunk/libffado/src/bebob/focusrite/focusrite_saffire.cpp
r1072 r1158 56 56 57 57 // create the mixer object container 58 m_MixerContainer = new Control::Container( "Mixer");58 m_MixerContainer = new Control::Container(this, "Mixer"); 59 59 60 60 if (!m_MixerContainer) { trunk/libffado/src/bebob/focusrite/focusrite_saffirepro.cpp
r1136 r1158 63 63 64 64 // create the mixer object container 65 m_MixerContainer = new Control::Container( "Mixer");65 m_MixerContainer = new Control::Container(this, "Mixer"); 66 66 67 67 if (!m_MixerContainer) { … … 226 226 227 227 // special controls 228 m_ControlContainer = new Control::Container( "Control");228 m_ControlContainer = new Control::Container(this, "Control"); 229 229 if (!m_ControlContainer) { 230 230 debugError("Could not create mixer container...\n"); … … 307 307 return false; 308 308 } 309 310 309 311 310 return true; … … 791 790 // swiss army knife control element 792 791 SaffireProMultiControl::SaffireProMultiControl(SaffireProDevice& parent, enum eMultiControlType t) 793 : Control::Discrete( )792 : Control::Discrete(&parent) 794 793 , m_Parent(parent) 795 794 , m_type ( t ) … … 797 796 SaffireProMultiControl::SaffireProMultiControl(SaffireProDevice& parent, enum eMultiControlType t, 798 797 std::string name, std::string label, std::string descr) 799 : Control::Discrete( )798 : Control::Discrete(&parent) 800 799 , m_Parent(parent) 801 800 , m_type ( t ) … … 843 842 844 843 SaffireProDeviceNameControl::SaffireProDeviceNameControl(SaffireProDevice& parent) 845 : Control::Text( )844 : Control::Text(&parent) 846 845 , m_Parent(parent) 847 846 {} 848 847 SaffireProDeviceNameControl::SaffireProDeviceNameControl(SaffireProDevice& parent, 849 848 std::string name, std::string label, std::string descr) 850 : Control::Text( )849 : Control::Text(&parent) 851 850 , m_Parent(parent) 852 851 { trunk/libffado/src/bebob/focusrite/focusrite_saffirepro.h
r1107 r1158 279 279 virtual bool setValue(int v); 280 280 virtual int getValue(); 281 281 virtual bool setValue(int idx, int v) 282 {return setValue(v);}; 283 virtual int getValue(int idx) 284 {return getValue();}; 285 286 virtual int getMinimum() {return 0;}; 287 virtual int getMaximum() {return 0;}; 282 288 private: 283 289 SaffireProDevice& m_Parent; trunk/libffado/src/devicemanager.cpp
r1092 r1158 81 81 82 82 DeviceManager::DeviceManager() 83 : Control::Container( "devicemanager")83 : Control::Container(NULL, "devicemanager") // this is the control root node 84 84 , m_processorManager( new Streaming::StreamProcessorManager() ) 85 85 , m_deviceStringParser( new DeviceStringParser() ) … … 251 251 ( *func )(); 252 252 } 253 // display the new state 254 showDeviceInfo(); 253 255 } 254 256 trunk/libffado/src/ffadodevice.cpp
r1132 r1158 24 24 25 25 #include "ffadodevice.h" 26 #include "devicemanager.h" 26 27 27 28 #include "libieee1394/configrom.h" … … 40 41 41 42 FFADODevice::FFADODevice( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom ) ) 42 : Control::Container( )43 : Control::Container(&d) 43 44 , m_pConfigRom( configRom ) 44 45 , m_pDeviceManager( d ) … … 53 54 } 54 55 55 m_genericContainer = new Control::Container( "Generic");56 m_genericContainer = new Control::Container(this, "Generic"); 56 57 if(m_genericContainer == NULL) { 57 58 debugError("Could not create Control::Container for generic controls\n"); trunk/libffado/src/fireworks/fireworks_control.cpp
r864 r1158 38 38 39 39 MonitorControl::MonitorControl(FireWorks::Device& p, enum eMonitorControl c) 40 : Control::MatrixMixer( "MonitorControl")40 : Control::MatrixMixer(&p, "MonitorControl") 41 41 , m_control(c) 42 42 , m_Parent(p) … … 45 45 46 46 MonitorControl::MonitorControl(FireWorks::Device& p, enum eMonitorControl c, std::string n) 47 : Control::MatrixMixer( n)47 : Control::MatrixMixer(&p, n) 48 48 , m_control(c) 49 49 , m_Parent(p) … … 241 241 enum eMixerCommand c, 242 242 int channel) 243 : Control::Continuous( "SimpleControl")243 : Control::Continuous(&p, "SimpleControl") 244 244 , m_Slave(new EfcGenericMixerCmd(t, c, channel)) 245 245 , m_Parent(p) … … 252 252 int channel, 253 253 std::string n) 254 : Control::Continuous( n)254 : Control::Continuous(&p, n) 255 255 , m_Slave(new EfcGenericMixerCmd(t, c, channel)) 256 256 , m_Parent(p) … … 312 312 enum eMixerCommand c, 313 313 int channel, int bit) 314 : Control::Discrete( "BinaryControl")314 : Control::Discrete(&p, "BinaryControl") 315 315 , m_bit(bit) 316 316 , m_Slave(new EfcGenericMixerCmd(t, c, channel)) … … 324 324 int channel, int bit, 325 325 std::string n) 326 : Control::Discrete( n)326 : Control::Discrete(&p, n) 327 327 , m_bit(bit) 328 328 , m_Slave(new EfcGenericMixerCmd(t, c, channel)) … … 398 398 IOConfigControl::IOConfigControl(FireWorks::Device& parent, 399 399 enum eIOConfigRegister r) 400 : Control::Discrete( "IOConfigControl")400 : Control::Discrete(&parent, "IOConfigControl") 401 401 , m_Slave(new EfcGenericIOConfigCmd(r)) 402 402 , m_Parent(parent) … … 407 407 enum eIOConfigRegister r, 408 408 std::string n) 409 : Control::Discrete( n)409 : Control::Discrete(&parent, n) 410 410 , m_Slave(new EfcGenericIOConfigCmd(r)) 411 411 , m_Parent(parent) trunk/libffado/src/fireworks/fireworks_control.h
r864 r1158 91 91 virtual bool setValue( const double ); 92 92 virtual double getValue( ); 93 virtual bool setValue(int idx, double v) 94 {return setValue(v);}; 95 virtual double getValue(int idx) 96 {return getValue();}; 97 98 virtual double getMinimum() {return 0.0;}; 99 virtual double getMaximum() {return 0.0;}; 93 100 94 101 protected: … … 115 122 virtual bool setValue( const int ); 116 123 virtual int getValue( ); 124 virtual bool setValue(int idx, int v) 125 {return setValue(v);}; 126 virtual int getValue(int idx) 127 {return getValue();}; 117 128 129 virtual int getMinimum() {return 0;}; 130 virtual int getMaximum() {return 1;}; 118 131 protected: 119 132 int m_bit; … … 139 152 virtual bool setValue( const int ); 140 153 virtual int getValue( ); 154 virtual bool setValue(int idx, int v) 155 {return setValue(v);}; 156 virtual int getValue(int idx) 157 {return getValue();}; 158 159 virtual int getMinimum() {return 0;}; 160 virtual int getMaximum() {return 0;}; 141 161 142 162 protected: trunk/libffado/src/fireworks/fireworks_device.cpp
r1133 r1158 200 200 201 201 // create the mixer object container 202 m_MixerContainer = new Control::Container( "Mixer");202 m_MixerContainer = new Control::Container(this, "Mixer"); 203 203 204 204 if (!m_MixerContainer) { trunk/libffado/src/libavc/general/avc_plug.cpp
r1154 r1158 648 648 signalSourceCmd.setCommandType( AVCCommand::eCT_Control ); 649 649 signalSourceCmd.setVerbose( getDebugLevel() ); 650 signalSourceCmd.setVerbose( DEBUG_LEVEL_VERY_VERBOSE ); 650 651 651 652 if ( !signalSourceCmd.fire() ) { trunk/libffado/src/libavc/general/avc_unit.cpp
r1154 r1158 820 820 } 821 821 822 823 822 void 824 823 Unit::show() trunk/libffado/src/libcontrol/BasicElements.cpp
r998 r1158 25 25 26 26 namespace Control { 27 28 Continuous::Continuous() 29 : Element() 30 , m_Value( 0.0 ) 31 { 27 // no implementations 32 28 } 33 34 Continuous::Continuous(std::string n)35 : Element(n)36 , m_Value( 0.0 )37 {38 }39 40 void41 Continuous::show()42 {43 debugOutput( DEBUG_LEVEL_NORMAL, "Continuous Element %s, value=%lf\n",44 getName().c_str(), m_Value);45 }46 47 bool48 Continuous::setValue(double v)49 {50 debugOutput( DEBUG_LEVEL_VERBOSE, "%s setValue(%lf)\n",51 getName().c_str(), v);52 m_Value=v;53 return true;54 }55 56 double57 Continuous::getValue()58 {59 debugOutput( DEBUG_LEVEL_VERBOSE, "%s getValue()=%lf\n",60 getName().c_str(), m_Value);61 return m_Value;62 }63 64 double65 Continuous::getMinimum()66 {67 debugOutput( DEBUG_LEVEL_VERBOSE, "%s getMinimum()=%lf\n",68 getName().c_str(), m_Value);69 return m_Value;70 }71 72 double73 Continuous::getMaximum()74 {75 debugOutput( DEBUG_LEVEL_VERBOSE, "%s getMaximum()=%lf\n",76 getName().c_str(), m_Value);77 return m_Value;78 }79 80 bool81 Continuous::setValue(int idx, double v)82 {83 debugOutput( DEBUG_LEVEL_VERBOSE, "%s setValue(%d, %lf)\n",84 getName().c_str(), idx, v);85 return setValue(v);86 }87 88 double89 Continuous::getValue(int idx)90 {91 double retval = getValue();92 debugOutput( DEBUG_LEVEL_VERBOSE, "%s getValue()=%lf\n",93 getName().c_str(), retval);94 return retval;95 }96 97 //// ---98 99 Discrete::Discrete()100 : Element()101 , m_Value( 0 )102 {103 }104 105 Discrete::Discrete(std::string n)106 : Element(n)107 , m_Value( 0 )108 {109 }110 111 void112 Discrete::show()113 {114 debugOutput( DEBUG_LEVEL_NORMAL, "Discrete Element %s, value=%d\n",115 getName().c_str(), m_Value);116 }117 118 bool119 Discrete::setValue(int v)120 {121 debugOutput( DEBUG_LEVEL_VERBOSE, "%s setValue(%d)\n",122 getName().c_str(), v);123 m_Value=v;124 return true;125 }126 127 int128 Discrete::getValue()129 {130 debugOutput( DEBUG_LEVEL_VERBOSE, "%s getValue()=%d\n",131 getName().c_str(), m_Value);132 return m_Value;133 }134 bool135 Discrete::setValue(int idx, int v)136 {137 debugOutput( DEBUG_LEVEL_VERBOSE, "%s setValue(%d, %d)\n",138 getName().c_str(), idx, v);139 return setValue(v);140 }141 142 int143 Discrete::getValue(int idx)144 {145 int retval = getValue();146 debugOutput( DEBUG_LEVEL_VERBOSE, "%s getValue()=%d\n",147 getName().c_str(), retval);148 return retval;149 }150 151 //// ---152 153 Text::Text()154 : Element()155 , m_Value( "" )156 {157 }158 159 Text::Text(std::string n)160 : Element(n)161 , m_Value( "" )162 {163 }164 165 void166 Text::show()167 {168 debugOutput( DEBUG_LEVEL_NORMAL, "Text Element %s, value=%s\n",169 getName().c_str(), m_Value.c_str());170 }171 172 bool173 Text::setValue(std::string v)174 {175 debugOutput( DEBUG_LEVEL_VERBOSE, "%s setValue(%s)\n",176 getName().c_str(), v.c_str());177 m_Value=v;178 return true;179 }180 181 std::string182 Text::getValue()183 {184 debugOutput( DEBUG_LEVEL_VERBOSE, "%s getValue()=%s\n",185 getName().c_str(), m_Value.c_str());186 return m_Value;187 }188 189 //// ---190 191 Enum::Enum()192 : Element()193 , m_selected( -1 )194 {195 }196 197 Enum::Enum(std::string n)198 : Element(n)199 , m_selected( -1 )200 {201 }202 203 void204 Enum::show()205 {206 debugOutput( DEBUG_LEVEL_NORMAL, "Enum Element %s, selected=%d\n",207 getName().c_str(), m_selected);208 }209 210 // NOTE: dummy implementation for tests211 bool212 Enum::select(int idx)213 {214 if(idx <3) {215 m_selected=idx;216 return true;217 } else {218 return false;219 }220 }221 222 int223 Enum::selected()224 {225 return m_selected;226 }227 228 int229 Enum::count()230 {231 return 3;232 }233 234 std::string235 Enum::getEnumLabel(int idx)236 {237 switch(idx) {238 case 0: return "enum val 1";239 case 1: return "enum val 2";240 case 2: return "enum val 3";241 default: return "bad index";242 }243 }244 245 246 //// ---247 248 AttributeEnum::AttributeEnum()249 : Enum()250 {251 }252 253 AttributeEnum::AttributeEnum(std::string n)254 : Enum(n)255 {256 }257 258 void259 AttributeEnum::show()260 {261 debugOutput( DEBUG_LEVEL_NORMAL, "AttributeEnum Element %s\n",262 getName().c_str());263 Enum::show();264 }265 266 // NOTE: dummy implementation for tests267 int268 AttributeEnum::attributeCount()269 {270 return 2;271 }272 273 std::string274 AttributeEnum::getAttributeValue(int attridx)275 {276 switch(attridx) {277 case 0: return "attr val 1";278 case 1: return "attr val 2";279 default: return "bad attr index";280 }281 }282 283 std::string284 AttributeEnum::getAttributeName(int attridx)285 {286 switch(attridx) {287 case 0: return "attr 1";288 case 1: return "attr 2";289 default: return "bad attr index";290 }291 }292 293 } // namespace Controltrunk/libffado/src/libcontrol/BasicElements.h
r998 r1158 41 41 { 42 42 public: 43 Continuous( );44 Continuous( std::string n);43 Continuous(Element *p) : Element(p) {}; 44 Continuous(Element *p, std::string n) : Element(p, n) {}; 45 45 virtual ~Continuous() {}; 46 47 virtual bool setValue(double v);48 virtual double getValue();49 virtual double getMinimum();50 virtual double getMaximum();51 virtual bool setValue(int idx, double v);52 virtual double getValue(int idx);53 46 54 virtual void show(); 47 virtual bool setValue(double v) = 0; 48 virtual double getValue() = 0; 49 virtual bool setValue(int idx, double v) = 0; 50 virtual double getValue(int idx) = 0; 55 51 56 private: 57 double m_Value;52 virtual double getMinimum() = 0; 53 virtual double getMaximum() = 0; 58 54 }; 59 55 … … 65 61 { 66 62 public: 67 Discrete( );68 Discrete( std::string n);63 Discrete(Element *p) : Element(p) {}; 64 Discrete(Element *p, std::string n) : Element(p, n) {}; 69 65 virtual ~Discrete() {}; 70 71 virtual bool setValue(int v);72 virtual int getValue();73 virtual bool setValue(int idx, int v);74 virtual int getValue(int idx);75 66 76 virtual void show(); 67 virtual bool setValue(int v) = 0; 68 virtual int getValue() = 0; 69 virtual bool setValue(int idx, int v) = 0; 70 virtual int getValue(int idx) = 0; 77 71 78 private: 79 int m_Value; 72 virtual int getMinimum() = 0; 73 virtual int getMaximum() = 0; 74 80 75 }; 81 76 … … 87 82 { 88 83 public: 89 Text( );90 Text( std::string n);84 Text(Element *p) : Element(p) {}; 85 Text(Element *p, std::string n) : Element(p, n) {}; 91 86 virtual ~Text() {}; 92 87 93 virtual bool setValue(std::string v); 94 virtual std::string getValue(); 95 96 virtual void show(); 97 98 private: 99 std::string m_Value; 88 virtual bool setValue(std::string v) = 0; 89 virtual std::string getValue() = 0; 100 90 }; 101 91 … … 107 97 { 108 98 public: 109 Register( ) : Element() {};110 Register( std::string n) : Element(n) {};99 Register(Element *p) : Element(p) {}; 100 Register(Element *p, std::string n) : Element(p, n) {}; 111 101 virtual ~Register() {}; 112 102 113 103 virtual bool setValue(uint64_t addr, uint64_t value) = 0; 114 104 virtual uint64_t getValue(uint64_t addr) = 0; 115 private:116 105 }; 117 106 … … 123 112 { 124 113 public: 125 Enum( );126 Enum( std::string n);114 Enum(Element *p) : Element(p) {}; 115 Enum(Element *p, std::string n) : Element(p, n) {}; 127 116 virtual ~Enum() {}; 128 117 129 virtual bool select(int idx); 130 virtual int selected(); 131 virtual int count(); 132 virtual std::string getEnumLabel(int idx); 133 134 virtual void show(); 135 //private: // HACK 136 int m_selected; 118 virtual bool select(int idx) = 0; 119 virtual int selected() = 0; 120 virtual int count() = 0; 121 virtual std::string getEnumLabel(int idx) = 0; 137 122 }; 138 123 … … 159 144 { 160 145 public: 161 AttributeEnum( );162 AttributeEnum( std::string n);146 AttributeEnum(Element *p) : Enum(p) {}; 147 AttributeEnum(Element *p, std::string n) : Enum(p, n) {}; 163 148 virtual ~AttributeEnum() {}; 164 149 165 virtual int attributeCount() ;150 virtual int attributeCount() = 0; 166 151 ///> get a specific attribute value for the selected enum 167 virtual std::string getAttributeValue(int attridx) ;152 virtual std::string getAttributeValue(int attridx) = 0; 168 153 ///> get the name of the attribute with a certain index 169 virtual std::string getAttributeName(int attridx); 170 171 virtual void show(); 172 private: 154 virtual std::string getAttributeName(int attridx) = 0; 173 155 }; 174 156 trunk/libffado/src/libcontrol/ClockSelect.cpp
r997 r1158 29 29 //// --- ClockSelect --- //// 30 30 ClockSelect::ClockSelect(FFADODevice &d) 31 : AttributeEnum( )31 : AttributeEnum(&d) 32 32 , m_Device( d ) 33 33 { trunk/libffado/src/libcontrol/Element.cpp
r864 r1158 23 23 24 24 #include "Element.h" 25 26 #include "libutil/PosixMutex.h" 25 27 26 28 namespace Control { … … 37 39 static uint64_t GlobalElementCounter=0; 38 40 39 Element::Element() 40 : m_Name ( "NoName" ) 41 Element::Element(Element *parent) 42 : m_element_lock ( NULL ) 43 , m_parent( parent ) 44 , m_Name ( "NoName" ) 41 45 , m_Label ( "No Label" ) 42 46 , m_Description ( "No Description" ) 43 47 , m_id(GlobalElementCounter++) 44 48 { 45 } 46 47 Element::Element(std::string n) 48 : m_Name( n ) 49 // no parent, we are the root of an independent control tree 50 // this means we have to create a lock 51 if(parent == NULL) { 52 m_element_lock = new Util::PosixMutex(); 53 } 54 } 55 56 Element::Element(Element *parent, std::string n) 57 : m_element_lock ( NULL ) 58 , m_parent( parent ) 59 , m_Name( n ) 49 60 , m_Label ( "No Label" ) 50 61 , m_Description ( "No Description" ) 51 62 , m_id(GlobalElementCounter++) 52 63 { 64 // no parent, we are the root of an independent control tree 65 // this means we have to create a lock 66 if(parent == NULL) { 67 m_element_lock = new Util::PosixMutex(); 68 } 69 } 70 71 Element::~Element() 72 { 73 if(m_element_lock) delete m_element_lock; 74 } 75 76 void 77 Element::lockControl() 78 { 79 getLock().Lock(); 80 } 81 82 void 83 Element::unlockControl() 84 { 85 getLock().Unlock(); 86 } 87 88 Util::Mutex& 89 Element::getLock() 90 { 91 assert(m_parent != NULL || m_element_lock != NULL); 92 if(m_parent) { 93 return m_parent->getLock(); 94 } else { 95 return *m_element_lock; 96 } 53 97 } 54 98 … … 64 108 { 65 109 setDebugLevel(l); 110 if(m_element_lock) m_element_lock->setVerboseLevel(l); 111 if(m_element_lock) m_element_lock->setVerboseLevel(DEBUG_LEVEL_VERY_VERBOSE); 66 112 debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l ); 67 113 } 68 114 69 115 //// --- Container --- //// 70 Container::Container() 71 : Element() 72 { 73 } 74 75 Container::Container(std::string n) 76 : Element(n) 77 { 116 Container::Container(Element *p) 117 : Element(p) 118 { 119 } 120 121 Container::Container(Element *p, std::string n) 122 : Element(p, n) 123 { 124 } 125 126 unsigned int 127 Container::countElements() 128 { 129 lockControl(); 130 unsigned int s = m_Children.size(); 131 unlockControl(); 132 return s; 133 } 134 135 const ElementVector & 136 Container::getElementVector() 137 { 138 lockControl(); 139 return m_Children; 140 } 141 142 void 143 Container::releaseElementVector() 144 { 145 unlockControl(); 78 146 } 79 147 … … 81 149 Container::addElement(Element *e) 82 150 { 151 Util::MutexLockHelper lock(getLock()); 83 152 if (e==NULL) { 84 153 debugWarning("Cannot add NULL element\n"); … … 108 177 Container::deleteElement(Element *e) 109 178 { 110 assert(e); 179 Util::MutexLockHelper lock(getLock()); 180 if(e == NULL) return false; 111 181 debugOutput( DEBUG_LEVEL_VERBOSE, "Deleting Element %s from %s\n", 112 182 e->getName().c_str(), getName().c_str()); … … 129 199 Container::clearElements(bool delete_pointers) 130 200 { 201 Util::MutexLockHelper lock(getLock()); 131 202 while(m_Children.size()) { 132 203 Element *e=m_Children[0]; … … 140 211 Container::show() 141 212 { 213 Util::MutexLockHelper lock(getLock()); 142 214 debugOutput( DEBUG_LEVEL_NORMAL, "Container %s (%d Elements)\n", 143 215 getName().c_str(), m_Children.size()); … … 154 226 Container::setVerboseLevel(int l) 155 227 { 228 Util::MutexLockHelper lock(getLock()); 156 229 setDebugLevel(l); 157 230 for ( ElementVectorIterator it = m_Children.begin(); trunk/libffado/src/libcontrol/Element.h
r864 r1158 30 30 #include <string> 31 31 32 #include "libutil/Mutex.h" 33 32 34 namespace Control { 33 35 … … 40 42 { 41 43 public: 42 Element( );43 Element( std::string n);44 virtual ~Element() {};44 Element(Element *); 45 Element(Element *, std::string n); 46 virtual ~Element(); 45 47 46 48 virtual std::string getName() {return m_Name;}; … … 58 60 uint64_t getId() 59 61 {return m_id;}; 60 62 63 // these allow to prevent external access to the control elements 64 // e.g. when the config tree is rebuilt 65 virtual void lockControl(); 66 virtual void unlockControl(); 67 61 68 virtual void show(); 62 69 … … 65 72 */ 66 73 virtual void setVerboseLevel(int l); 74 virtual int getVerboseLevel() {return getDebugLevel();}; 75 76 protected: 77 Util::Mutex& getLock(); 67 78 68 79 private: 80 Util::Mutex* m_element_lock; 81 Element* m_parent; 69 82 std::string m_Name; 70 83 std::string m_Label; … … 94 107 { 95 108 public: 96 Container( );97 Container( std::string n);109 Container(Element *); 110 Container(Element *, std::string n); 98 111 virtual ~Container() {}; 99 112 … … 104 117 virtual bool clearElements(bool delete_pointers); 105 118 106 unsigned int countElements() 107 {return m_Children.size();}; 119 unsigned int countElements(); 108 120 109 const ElementVector & getElements() 110 {return m_Children;}; 121 122 /** 123 * Returns and locks the element vector. No changes will be made to the vector 124 * until releaseElementVector is called. 125 * @return 126 */ 127 const ElementVector & getElementVector(); 128 129 /** 130 * Releases the lock on the element vector. 131 */ 132 void releaseElementVector(); 111 133 112 134 virtual void show(); trunk/libffado/src/libcontrol/MatrixMixer.cpp
r864 r1158 25 25 26 26 namespace Control { 27 28 //// --- MatrixMixer --- //// 29 MatrixMixer::MatrixMixer() 30 : Element() 31 { 32 } 33 34 MatrixMixer::MatrixMixer(std::string n) 35 : Element(n) 36 { 37 } 38 27 // no implementation 39 28 } // namespace Control trunk/libffado/src/libcontrol/MatrixMixer.h
r864 r1158 41 41 { 42 42 public: 43 MatrixMixer( );44 MatrixMixer( std::string n);43 MatrixMixer(Element *p) : Element(p) {}; 44 MatrixMixer(Element *p, std::string n) : Element(p, n) {}; 45 45 virtual ~MatrixMixer() {}; 46 46 trunk/libffado/src/libcontrol/Nickname.cpp
r1063 r1158 29 29 //// --- Nickname --- //// 30 30 Nickname::Nickname(FFADODevice &d) 31 : Text( )31 : Text(&d) 32 32 , m_Device( d ) 33 33 { trunk/libffado/src/libieee1394/configrom.cpp
r1154 r1158 63 63 64 64 ConfigRom::ConfigRom( Ieee1394Service& ieee1394service, fb_nodeid_t nodeId ) 65 : Control::Element( "ConfigRom")65 : Control::Element(NULL, "ConfigRom") 66 66 , m_1394Service( ieee1394service ) 67 67 , m_nodeId( nodeId ) … … 90 90 91 91 ConfigRom::ConfigRom() 92 : Control::Element( "ConfigRom")92 : Control::Element(NULL, "ConfigRom") 93 93 , m_1394Service( *(new Ieee1394Service()) ) 94 94 , m_nodeId( -1 ) trunk/libffado/src/motu/motu_avdevice.cpp
r1141 r1158 349 349 350 350 // create the mixer object container 351 m_MixerContainer = new Control::Container( "Mixer");351 m_MixerContainer = new Control::Container(this, "Mixer"); 352 352 if (!m_MixerContainer) { 353 353 debugError("Could not create mixer container...\n"); … … 524 524 525 525 // Special controls 526 m_ControlContainer = new Control::Container( "Control");526 m_ControlContainer = new Control::Container(this, "Control"); 527 527 if (!m_ControlContainer) { 528 528 debugError("Could not create control container...\n"); trunk/libffado/src/motu/motu_controls.cpp
r1064 r1158 29 29 30 30 MotuDiscreteCtrl::MotuDiscreteCtrl(MotuDevice &parent, unsigned int dev_reg) 31 : Control::Discrete( )31 : Control::Discrete(&parent) 32 32 , m_parent(parent) 33 33 , m_register(dev_reg) … … 37 37 MotuDiscreteCtrl::MotuDiscreteCtrl(MotuDevice &parent, unsigned int dev_reg, 38 38 std::string name, std::string label, std::string descr) 39 : Control::Discrete( )39 : Control::Discrete(&parent) 40 40 , m_parent(parent) 41 41 , m_register(dev_reg) trunk/libffado/src/motu/motu_controls.h
r1064 r1158 91 91 std::string name, std::string label, std::string descr); 92 92 93 virtual bool setValue(int v) = 0; 94 virtual int getValue() = 0; 95 96 // default implementations 97 virtual bool setValue(int idx, int v) 98 {return setValue(v);}; 99 virtual int getValue(int idx) 100 {return getValue();}; 101 102 virtual int getMinimum() {return 0;}; 103 virtual int getMaximum() {return 0;}; 104 93 105 protected: 94 106 MotuDevice &m_parent; trunk/libffado/support/dbus/controlserver.cpp
r998 r1158 30 30 namespace DBusControl { 31 31 32 IMPL_DEBUG_MODULE( Element, Element, DEBUG_LEVEL_ VERBOSE);32 IMPL_DEBUG_MODULE( Element, Element, DEBUG_LEVEL_NORMAL ); 33 33 34 34 // --- Element … … 39 39 debugOutput( DEBUG_LEVEL_VERBOSE, "Created Element on '%s'\n", 40 40 path().c_str() ); 41 setVerboseLevel(m_Slave.getVerboseLevel()); 41 42 } 42 43 … … 74 75 75 76 // add children for the slave container 76 for ( Control::ConstElementVectorIterator it = slave.getElements().begin(); 77 it != slave.getElements().end(); 77 const Control::ElementVector elements = slave.getElementVector(); 78 for ( Control::ConstElementVectorIterator it = elements.begin(); 79 it != elements.end(); 78 80 ++it ) 79 81 { … … 86 88 } 87 89 } 90 slave.releaseElementVector(); 88 91 } 89 92 … … 106 109 int nbElements=m_Slave.countElements(); 107 110 if (i<nbElements) { 108 return m_Slave.getElements().at(i)->getName(); 111 const Control::ElementVector elements = m_Slave.getElementVector(); 112 Control::Element *e = elements.at(i); 113 std::string name; 114 if(e) name = e->getName(); 115 m_Slave.releaseElementVector(); 116 return name; 109 117 } else return ""; 110 118 } trunk/libffado/support/dbus/controlserver.h
r998 r1158 56 56 DBus::String getDescription( ); 57 57 58 void setVerboseLevel(int i) {setDebugLevel(i);}; 58 59 private: 59 60 Control::Element &m_Slave; trunk/libffado/support/dbus/ffado-dbus-server.cpp
r962 r1158 123 123 char* tail; 124 124 125 errno = 0; 125 126 switch (key) { 126 127 case 'q': case 's': … … 205 206 busresetHandler() 206 207 { 208 // this is a race condition: the control tree becomes invalid since we 209 // are redetecting the devices, but the dispatcher still allows access. 210 // at this point. This has to be split up in two. 207 211 debugOutput( DEBUG_LEVEL_NORMAL, "notified of bus reset...\n" ); 208 212 dispatcher.leave(); trunk/libffado/support/dbus/test-dbus-server.cpp
r958 r1158 108 108 conn.request_name(SERVER_NAME); 109 109 110 Control::Continuous c0("test0");111 c0.setVerboseLevel(DEBUG_LEVEL_VERBOSE);112 DBusControl::Continuous fader(conn, "/org/ffado/Control/Test/Fader", c0);113 114 Control::Container cont( "container1");110 // Control::Continuous c0("test0"); 111 // c0.setVerboseLevel(DEBUG_LEVEL_VERBOSE); 112 // DBusControl::Continuous fader(conn, "/org/ffado/Control/Test/Fader", c0); 113 // 114 Control::Container cont(NULL, "container1"); 115 115 cont.setVerboseLevel(DEBUG_LEVEL_VERBOSE); 116 117 Control::Container cont1("container2");118 cont1.setVerboseLevel(DEBUG_LEVEL_VERBOSE);119 120 cont.addElement(&cont1);121 122 Control::Continuous c1("test1");123 c1.setVerboseLevel(DEBUG_LEVEL_VERBOSE);124 cont.addElement(&c1);125 126 Control::Continuous c2("test2");127 c2.setVerboseLevel(DEBUG_LEVEL_VERBOSE);128 cont.addElement(&c2);129 130 Control::Continuous c3("test3");131 c3.setVerboseLevel(DEBUG_LEVEL_VERBOSE);132 cont.addElement(&c3);133 134 Control::Continuous c4("test4");135 c4.setVerboseLevel(DEBUG_LEVEL_VERBOSE);136 cont1.addElement(&c4);137 138 Control::Continuous c5("test5");139 c5.setVerboseLevel(DEBUG_LEVEL_VERBOSE);140 cont1.addElement(&c5);141 142 Control::Discrete d1("test_discr1");143 d1.setVerboseLevel(DEBUG_LEVEL_VERBOSE);144 cont1.addElement(&d1);145 146 Control::Enum e1("test_enum");147 e1.setVerboseLevel(DEBUG_LEVEL_VERBOSE);148 cont1.addElement(&e1);149 150 Control::AttributeEnum a1("test_attrenum");151 a1.setVerboseLevel(DEBUG_LEVEL_VERBOSE);152 cont1.addElement(&a1);153 154 Control::Text t1("test_text");155 t1.setVerboseLevel(DEBUG_LEVEL_VERBOSE);156 cont1.addElement(&t1);116 // 117 // Control::Container cont1("container2"); 118 // cont1.setVerboseLevel(DEBUG_LEVEL_VERBOSE); 119 // 120 // cont.addElement(&cont1); 121 // 122 // Control::Continuous c1("test1"); 123 // c1.setVerboseLevel(DEBUG_LEVEL_VERBOSE); 124 // cont.addElement(&c1); 125 // 126 // Control::Continuous c2("test2"); 127 // c2.setVerboseLevel(DEBUG_LEVEL_VERBOSE); 128 // cont.addElement(&c2); 129 // 130 // Control::Continuous c3("test3"); 131 // c3.setVerboseLevel(DEBUG_LEVEL_VERBOSE); 132 // cont.addElement(&c3); 133 // 134 // Control::Continuous c4("test4"); 135 // c4.setVerboseLevel(DEBUG_LEVEL_VERBOSE); 136 // cont1.addElement(&c4); 137 // 138 // Control::Continuous c5("test5"); 139 // c5.setVerboseLevel(DEBUG_LEVEL_VERBOSE); 140 // cont1.addElement(&c5); 141 // 142 // Control::Discrete d1("test_discr1"); 143 // d1.setVerboseLevel(DEBUG_LEVEL_VERBOSE); 144 // cont1.addElement(&d1); 145 // 146 // Control::Enum e1("test_enum"); 147 // e1.setVerboseLevel(DEBUG_LEVEL_VERBOSE); 148 // cont1.addElement(&e1); 149 // 150 // Control::AttributeEnum a1("test_attrenum"); 151 // a1.setVerboseLevel(DEBUG_LEVEL_VERBOSE); 152 // cont1.addElement(&a1); 153 // 154 // Control::Text t1("test_text"); 155 // t1.setVerboseLevel(DEBUG_LEVEL_VERBOSE); 156 // cont1.addElement(&t1); 157 157 158 158 // Note: create handlers AFTER all children are added