Changeset 1288
- Timestamp:
- 07/10/08 11:08:36 (13 years ago)
- Files:
-
- branches/libffado-2.0/src/bebob/bebob_avdevice.cpp (modified) (2 diffs)
- branches/libffado-2.0/src/bebob/bebob_avdevice.h (modified) (1 diff)
- branches/libffado-2.0/src/ffadodevice.h (modified) (1 diff)
- branches/libffado-2.0/src/fireworks/fireworks_device.cpp (modified) (1 diff)
- branches/libffado-2.0/src/fireworks/fireworks_device.h (modified) (1 diff)
- branches/libffado-2.0/src/genericavc/avc_avdevice.cpp (modified) (1 diff)
- branches/libffado-2.0/src/genericavc/avc_avdevice.h (modified) (2 diffs)
- branches/libffado-2.0/src/libavc/general/avc_plug.cpp (modified) (1 diff)
- branches/libffado-2.0/src/libavc/general/avc_plug.h (modified) (1 diff)
- branches/libffado-2.0/src/libcontrol/ClockSelect.cpp (modified) (2 diffs)
- branches/libffado-2.0/src/libcontrol/ClockSelect.h (modified) (2 diffs)
- branches/libffado-2.0/src/motu/motu_avdevice.cpp (modified) (1 diff)
- branches/libffado-2.0/src/motu/motu_avdevice.h (modified) (1 diff)
- branches/libffado-2.0/support/mixer/ffadomixer.in (modified) (2 diffs)
- branches/libffado-2.0/support/mixer/mixer_global.py (modified) (2 diffs)
- branches/libffado-2.0/support/mixer/mixer_global.ui (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/libffado-2.0/src/bebob/bebob_avdevice.cpp
r1244 r1288 174 174 } 175 175 176 #define BEBOB_CHECK_AND_ADD_SR(v, x) \ 177 { if(supportsSamplingFrequency(x)) \ 178 v.push_back(x); } 176 179 bool 177 180 AvDevice::discover() … … 434 437 } 435 438 436 437 439 uint8_t 438 440 AvDevice::getConfigurationIdSampleRate() branches/libffado-2.0/src/bebob/bebob_avdevice.h
r1244 r1288 108 108 virtual uint16_t getConfigurationIdSyncMode(); 109 109 110 std::vector<int> m_supported_frequencies; 110 111 protected: 111 112 Mixer* m_Mixer; branches/libffado-2.0/src/ffadodevice.h
r1263 r1288 138 138 */ 139 139 virtual int getSamplingFrequency( ) = 0; 140 141 /** 142 * @brief get the supported sampling frequencies 143 * @return a vector containing the supported sampling frequencies 144 */ 145 virtual std::vector<int> getSupportedSamplingFrequencies( ) = 0; 140 146 141 147 /** branches/libffado-2.0/src/fireworks/fireworks_device.cpp
r1284 r1288 427 427 } 428 428 429 #define ECHO_CHECK_AND_ADD_SR(v, x) \ 430 { if(x >= m_HwInfo.m_min_sample_rate && x <= m_HwInfo.m_max_sample_rate) \ 431 v.push_back(x); } 432 std::vector<int> 433 Device::getSupportedSamplingFrequencies() 434 { 435 std::vector<int> frequencies; 436 ECHO_CHECK_AND_ADD_SR(frequencies, 22050); 437 ECHO_CHECK_AND_ADD_SR(frequencies, 24000); 438 ECHO_CHECK_AND_ADD_SR(frequencies, 32000); 439 ECHO_CHECK_AND_ADD_SR(frequencies, 44100); 440 ECHO_CHECK_AND_ADD_SR(frequencies, 48000); 441 ECHO_CHECK_AND_ADD_SR(frequencies, 88200); 442 ECHO_CHECK_AND_ADD_SR(frequencies, 96000); 443 ECHO_CHECK_AND_ADD_SR(frequencies, 176400); 444 ECHO_CHECK_AND_ADD_SR(frequencies, 192000); 445 return frequencies; 446 } 447 429 448 FFADODevice::ClockSourceVector 430 449 Device::getSupportedClockSources() { branches/libffado-2.0/src/fireworks/fireworks_device.h
r1284 r1288 60 60 virtual bool buildMixer(); 61 61 virtual bool destroyMixer(); 62 63 virtual std::vector<int> getSupportedSamplingFrequencies(); 62 64 63 65 virtual ClockSourceVector getSupportedClockSources(); branches/libffado-2.0/src/genericavc/avc_avdevice.cpp
r1229 r1288 240 240 return false; 241 241 242 } 243 244 bool 245 AvDevice::supportsSamplingFrequency( int s ) 246 { 247 Util::MutexLockHelper lock(m_DeviceMutex); 248 249 AVC::Plug* plug = getPlugById( m_pcrPlugs, Plug::eAPD_Input, 0 ); 250 if ( !plug ) { 251 debugError( "Could not retrieve iso input plug 0\n" ); 252 return false; 253 } 254 255 if ( !plug->supportsSampleRate( s ) ) 256 { 257 debugError( "sample rate not supported by input plug\n" ); 258 return false; 259 } 260 261 plug = getPlugById( m_pcrPlugs, Plug::eAPD_Output, 0 ); 262 if ( !plug ) { 263 debugError( "Could not retrieve iso output plug 0\n" ); 264 return false; 265 } 266 267 if ( !plug->supportsSampleRate( s ) ) 268 { 269 debugError( "sample rate not supported by output plug\n" ); 270 return false; 271 } 272 return true; 273 } 274 275 #define GENERICAVC_CHECK_AND_ADD_SR(v, x) \ 276 { if(supportsSamplingFrequency(x)) \ 277 v.push_back(x); } 278 279 std::vector<int> 280 AvDevice::getSupportedSamplingFrequencies() 281 { 282 if (m_supported_frequencies_cache.size() == 0) { 283 GENERICAVC_CHECK_AND_ADD_SR(m_supported_frequencies_cache, 22050); 284 GENERICAVC_CHECK_AND_ADD_SR(m_supported_frequencies_cache, 24000); 285 GENERICAVC_CHECK_AND_ADD_SR(m_supported_frequencies_cache, 32000); 286 GENERICAVC_CHECK_AND_ADD_SR(m_supported_frequencies_cache, 44100); 287 GENERICAVC_CHECK_AND_ADD_SR(m_supported_frequencies_cache, 48000); 288 GENERICAVC_CHECK_AND_ADD_SR(m_supported_frequencies_cache, 88200); 289 GENERICAVC_CHECK_AND_ADD_SR(m_supported_frequencies_cache, 96000); 290 GENERICAVC_CHECK_AND_ADD_SR(m_supported_frequencies_cache, 176400); 291 GENERICAVC_CHECK_AND_ADD_SR(m_supported_frequencies_cache, 192000); 292 } 293 return m_supported_frequencies_cache; 242 294 } 243 295 branches/libffado-2.0/src/genericavc/avc_avdevice.h
r1229 r1288 62 62 63 63 virtual bool setSamplingFrequency( int ); 64 virtual bool supportsSamplingFrequency( int s ); 64 65 virtual int getSamplingFrequency( ); 66 virtual std::vector<int> getSupportedSamplingFrequencies(); 65 67 66 68 virtual ClockSourceVector getSupportedClockSources(); … … 103 105 private: 104 106 ClockSource syncInfoToClockSource(const SyncInfo& si); 107 std::vector<int> m_supported_frequencies_cache; 105 108 }; 106 109 branches/libffado-2.0/src/libavc/general/avc_plug.cpp
r1238 r1288 1015 1015 1016 1016 bool 1017 Plug::supportsSampleRate( int rate ) 1018 { 1019 // fallback: BeBoB style 1020 ESamplingFrequency samplingFrequency = parseSampleRate(rate); 1021 1022 ExtendedStreamFormatCmd extStreamFormatCmd( 1023 m_unit->get1394Service(), 1024 ExtendedStreamFormatCmd::eSF_ExtendedStreamFormatInformationCommandList ); 1025 UnitPlugAddress unitPlugAddress( UnitPlugAddress::ePT_PCR, 1026 getPlugId() ); 1027 1028 extStreamFormatCmd.setPlugAddress( 1029 PlugAddress( 1030 Plug::convertPlugDirection(getPlugDirection() ), 1031 PlugAddress::ePAM_Unit, 1032 unitPlugAddress ) ); 1033 1034 extStreamFormatCmd.setNodeId( m_unit->getConfigRom().getNodeId() ); 1035 extStreamFormatCmd.setCommandType( AVCCommand::eCT_Status ); 1036 1037 int i = 0; 1038 bool cmdSuccess = false; 1039 bool correctFormatFound = false; 1040 1041 do { 1042 extStreamFormatCmd.setIndexInStreamFormat( i ); 1043 extStreamFormatCmd.setCommandType( AVCCommand::eCT_Status ); 1044 extStreamFormatCmd.setVerbose( getDebugLevel() ); 1045 1046 cmdSuccess = extStreamFormatCmd.fire(); 1047 1048 if ( cmdSuccess 1049 && ( extStreamFormatCmd.getResponse() == 1050 AVCCommand::eR_Implemented ) ) 1051 { 1052 ESamplingFrequency foundFreq = eSF_DontCare; 1053 1054 FormatInformation* formatInfo = 1055 extStreamFormatCmd.getFormatInformation(); 1056 FormatInformationStreamsCompound* compoundStream 1057 = dynamic_cast< FormatInformationStreamsCompound* > ( 1058 formatInfo->m_streams ); 1059 if ( compoundStream ) { 1060 foundFreq = 1061 static_cast< ESamplingFrequency >( 1062 compoundStream->m_samplingFrequency ); 1063 } 1064 1065 FormatInformationStreamsSync* syncStream 1066 = dynamic_cast< FormatInformationStreamsSync* > ( 1067 formatInfo->m_streams ); 1068 if ( syncStream ) { 1069 foundFreq = 1070 static_cast< ESamplingFrequency >( 1071 syncStream->m_samplingFrequency ); 1072 } 1073 1074 if ( foundFreq == samplingFrequency ) 1075 { 1076 correctFormatFound = true; 1077 break; 1078 } 1079 } 1080 1081 ++i; 1082 } while ( cmdSuccess 1083 && ( extStreamFormatCmd.getResponse() == 1084 ExtendedStreamFormatCmd::eR_Implemented ) ); 1085 1086 if ( !cmdSuccess ) { 1087 debugError( "setSampleRatePlug: Failed to retrieve format info\n" ); 1088 return false; 1089 } 1090 1091 if ( !correctFormatFound ) { 1092 debugOutput(DEBUG_LEVEL_VERBOSE, 1093 "setSampleRatePlug: %s plug %d does not support sample rate %d\n", 1094 getName(), 1095 getPlugId(), 1096 convertESamplingFrequency( samplingFrequency ) ); 1097 return false; 1098 } 1099 return true; 1100 } 1101 1102 bool 1017 1103 Plug::discoverConnectionsFromSpecificData( 1018 1104 EPlugDirection discoverDirection, branches/libffado-2.0/src/libavc/general/avc_plug.h
r1238 r1288 129 129 int getSampleRate() const; // 22050, 24000, 32000, ... 130 130 bool setSampleRate( int rate ); 131 bool supportsSampleRate( int rate ); 131 132 132 133 int getNrOfChannels() const; branches/libffado-2.0/src/libcontrol/ClockSelect.cpp
r1214 r1288 173 173 174 174 SamplerateSelect::SamplerateSelect(FFADODevice &d) 175 : Discrete(&d)175 : Enum(&d) 176 176 , m_Device( d ) 177 177 { … … 182 182 183 183 bool 184 SamplerateSelect::setValue(int v) 185 { 186 return m_Device.setSamplingFrequency(v); 187 } 188 189 int 190 SamplerateSelect::getValue() 191 { 192 return m_Device.getSamplingFrequency(); 193 } 194 195 bool 196 SamplerateSelect::setValue(int idx, int v) 197 { 198 return m_Device.setSamplingFrequency(v); 199 } 200 201 int 202 SamplerateSelect::getValue(int idx) 203 { 204 return m_Device.getSamplingFrequency(); 205 } 206 207 int 208 SamplerateSelect::getMinimum() 209 { 210 return 32000; 211 } 212 213 int 214 SamplerateSelect::getMaximum() 215 { 216 return 192000; 217 } 184 SamplerateSelect::select(int idx) 185 { 186 std::vector<int> freqs = m_Device.getSupportedSamplingFrequencies(); 187 if (idx < (int)freqs.size()) { 188 if(!m_Device.setSamplingFrequency(freqs.at(idx))) { 189 debugWarning("Could not select samplerate\n"); 190 return false; 191 } 192 return true; 193 } else { 194 debugWarning("bad index specified\n"); 195 return false; 196 } 197 } 198 199 int 200 SamplerateSelect::selected() 201 { 202 std::vector<int> freqs = m_Device.getSupportedSamplingFrequencies(); 203 int samplerate = m_Device.getSamplingFrequency(); 204 for (int i = 0; i < (int)freqs.size(); i++) { 205 if (samplerate == freqs.at(i)) { 206 return i; 207 } 208 } 209 debugError("could not find the selected samplerate\n"); 210 return -1; 211 } 212 213 int 214 SamplerateSelect::count() 215 { 216 return m_Device.getSupportedSamplingFrequencies().size(); 217 } 218 219 std::string 220 SamplerateSelect::getEnumLabel(int idx) 221 { 222 char tmp[16]; 223 std::string retval = "bad attr index"; 224 std::vector<int> freqs = m_Device.getSupportedSamplingFrequencies(); 225 if (idx < (int)freqs.size()) { 226 snprintf(tmp, 16, "%u", freqs.at(idx)); 227 retval = tmp; 228 } else { 229 debugWarning("bad index specified\n"); 230 } 231 return retval; 232 } 233 234 void 235 SamplerateSelect::show() 236 { 237 debugOutput( DEBUG_LEVEL_NORMAL, "SamplerateSelect Element %s, current: %d\n", 238 getName().c_str(), m_Device.getSamplingFrequency()); 239 240 } 241 218 242 219 243 } // namespace Control branches/libffado-2.0/src/libcontrol/ClockSelect.h
r1214 r1288 69 69 */ 70 70 class SamplerateSelect 71 : public Discrete71 : public Enum 72 72 { 73 73 public: … … 75 75 virtual ~SamplerateSelect() {}; 76 76 77 virtual bool se tValue(int v);78 virtual int getValue();79 virtual bool setValue(int idx, int v);80 virtual int getValue(int idx);77 virtual bool select(int idx); 78 virtual int selected(); 79 virtual int count(); 80 virtual std::string getEnumLabel(int idx); 81 81 82 virtual int getMinimum();83 virtual int getMaximum(); 82 virtual void show(); 83 84 84 protected: 85 85 FFADODevice &m_Device; branches/libffado-2.0/src/motu/motu_avdevice.cpp
r1235 r1288 825 825 } 826 826 827 std::vector<int> 828 MotuDevice::getSupportedSamplingFrequencies() 829 { 830 std::vector<int> frequencies; 831 frequencies.push_back(44100); 832 frequencies.push_back(48000); 833 frequencies.push_back(88200); 834 frequencies.push_back(96000); 835 frequencies.push_back(176400); 836 frequencies.push_back(192000); 837 return frequencies; 838 } 839 827 840 FFADODevice::ClockSource 828 841 MotuDevice::clockIdToClockSource(unsigned int id) { branches/libffado-2.0/src/motu/motu_avdevice.h
r1229 r1288 161 161 virtual bool setSamplingFrequency( int samplingFrequency ); 162 162 virtual int getSamplingFrequency( ); 163 virtual std::vector<int> getSupportedSamplingFrequencies(); 163 164 164 165 FFADODevice::ClockSource clockIdToClockSource(unsigned int id); branches/libffado-2.0/support/mixer/ffadomixer.in
r1284 r1288 273 273 def getAttributeName(self, idx): 274 274 return self.iface.getAttributeName(idx) 275 276 class SamplerateSelectInterface: 277 def __init__(self, servername, devicepath): 278 self.basepath=devicepath + '/Generic/SamplerateSelect' 279 self.servername=servername 280 self.bus=dbus.SessionBus() 281 self.dev = self.bus.get_object(self.servername, self.basepath) 282 self.iface = dbus.Interface(self.dev, dbus_interface='org.ffado.Control.Element.Enum') 283 def count(self): 284 return self.iface.count() 285 def select(self, idx): 286 return self.iface.select(idx) 287 def selected(self): 288 return self.iface.selected() 289 def getEnumLabel(self, idx): 290 return self.iface.getEnumLabel(idx) 275 291 276 292 class TextInterface: … … 396 412 tmp = GlobalMixer( w ) 397 413 tmp.clockselect = ClockSelectInterface( server, basepath+"/DeviceManager/"+path ) 414 tmp.samplerateselect = SamplerateSelectInterface( server, basepath+"/DeviceManager/"+path ) 398 415 tmp.nickname = TextInterface( server, basepath+"/DeviceManager/"+path+"/Generic/Nickname" ) 399 416 tmp.hw = hw branches/libffado-2.0/support/mixer/mixer_global.py
r1108 r1288 41 41 self.clocksource.setCurrentItem( selected ) 42 42 43 def samplerateChanged( self, sr ): 44 print "samplerateChanged( " + str(sr) + " )" 45 self.samplerateselect.select( sr ) 46 selected = self.samplerateselect.selected() 47 48 if selected != sr: 49 srname = self.samplerateselect.getEnumLabel( sr ) 50 msg = QMessageBox() 51 msg.question( msg, "Failed to select sample rate", \ 52 "<qt>Could not select %s as samplerate.</qt>" % srname, \ 53 QMessageBox.Ok ) 54 self.samplerate.setCurrentItem( selected ) 55 43 56 def nicknameChanged( self, name ): 44 57 #print "nicknameChanged( %s )" % name … … 50 63 self.clocksource.insertItem( self.clockselect.getEnumLabel( i ) ) 51 64 self.clocksource.setCurrentItem( self.clockselect.selected() ) 65 66 for i in range( self.samplerateselect.count() ): 67 self.samplerate.insertItem( self.samplerateselect.getEnumLabel( i ) ) 68 self.samplerate.setCurrentItem( self.samplerateselect.selected() ) 69 52 70 self.txtNickname.setText( self.nickname.text() ) 53 71 branches/libffado-2.0/support/mixer/mixer_global.ui
r1105 r1288 26 26 <x>0</x> 27 27 <y>0</y> 28 <width> 600</width>28 <width>721</width> 29 29 <height>191</height> 30 30 </rect> … … 41 41 <string>Global Mixer Options</string> 42 42 </property> 43 < grid>43 <hbox> 44 44 <property name="name"> 45 45 <cstring>unnamed</cstring> 46 46 </property> 47 <widget class="QLa bel" row="0" column="0">47 <widget class="QLayoutWidget"> 48 48 <property name="name"> 49 <cstring> textLabel1</cstring>49 <cstring>layout5</cstring> 50 50 </property> 51 <property name="text"> 52 <string>Device Nickname:</string> 53 </property> 54 <property name="buddy" stdset="0"> 55 <cstring>nickname</cstring> 56 </property> 51 <vbox> 52 <property name="name"> 53 <cstring>unnamed</cstring> 54 </property> 55 <widget class="QLayoutWidget"> 56 <property name="name"> 57 <cstring>layout2</cstring> 58 </property> 59 <hbox> 60 <property name="name"> 61 <cstring>unnamed</cstring> 62 </property> 63 <widget class="QLabel"> 64 <property name="name"> 65 <cstring>textLabel1</cstring> 66 </property> 67 <property name="text"> 68 <string>Device Nickname:</string> 69 </property> 70 <property name="buddy" stdset="0"> 71 <cstring>nickname</cstring> 72 </property> 73 </widget> 74 <widget class="QLineEdit"> 75 <property name="name"> 76 <cstring>txtNickname</cstring> 77 </property> 78 <property name="minimumSize"> 79 <size> 80 <width>100</width> 81 <height>0</height> 82 </size> 83 </property> 84 </widget> 85 </hbox> 86 </widget> 87 <widget class="QLayoutWidget"> 88 <property name="name"> 89 <cstring>layout4</cstring> 90 </property> 91 <hbox> 92 <property name="name"> 93 <cstring>unnamed</cstring> 94 </property> 95 <widget class="QLabel"> 96 <property name="name"> 97 <cstring>textLabel2</cstring> 98 </property> 99 <property name="text"> 100 <string>Clock Source:</string> 101 </property> 102 <property name="buddy" stdset="0"> 103 <cstring>clocksource</cstring> 104 </property> 105 </widget> 106 <widget class="QComboBox"> 107 <property name="name"> 108 <cstring>clocksource</cstring> 109 </property> 110 </widget> 111 <spacer> 112 <property name="name"> 113 <cstring>spacer2</cstring> 114 </property> 115 <property name="orientation"> 116 <enum>Horizontal</enum> 117 </property> 118 <property name="sizeType"> 119 <enum>Expanding</enum> 120 </property> 121 <property name="sizeHint"> 122 <size> 123 <width>31</width> 124 <height>21</height> 125 </size> 126 </property> 127 </spacer> 128 <widget class="QLabel"> 129 <property name="name"> 130 <cstring>textLabel2_2</cstring> 131 </property> 132 <property name="text"> 133 <string>Sample Rate:</string> 134 </property> 135 <property name="buddy" stdset="0"> 136 <cstring>clocksource</cstring> 137 </property> 138 </widget> 139 <widget class="QComboBox"> 140 <property name="name"> 141 <cstring>samplerate</cstring> 142 </property> 143 <property name="enabled"> 144 <bool>false</bool> 145 </property> 146 </widget> 147 </hbox> 148 </widget> 149 </vbox> 57 150 </widget> 58 <widget class="QLineEdit" row="0" column="1"> 59 <property name="name"> 60 <cstring>txtNickname</cstring> 61 </property> 62 <property name="minimumSize"> 63 <size> 64 <width>100</width> 65 <height>0</height> 66 </size> 67 </property> 68 </widget> 69 <widget class="QLabel" row="1" column="0"> 70 <property name="name"> 71 <cstring>textLabel2</cstring> 72 </property> 73 <property name="text"> 74 <string>Clock Source:</string> 75 </property> 76 <property name="buddy" stdset="0"> 77 <cstring>clocksource</cstring> 78 </property> 79 </widget> 80 <widget class="QComboBox" row="1" column="1"> 81 <property name="name"> 82 <cstring>clocksource</cstring> 83 </property> 84 </widget> 85 <spacer row="0" column="2" rowspan="2" colspan="1"> 151 <spacer> 86 152 <property name="name"> 87 153 <cstring>spacer1</cstring> … … 95 161 <property name="sizeHint"> 96 162 <size> 97 <width> 111</width>163 <width>330</width> 98 164 <height>71</height> 99 165 </size> 100 166 </property> 101 167 </spacer> 102 </ grid>168 </hbox> 103 169 </widget> 104 170 <connections> … … 115 181 <slot>nicknameChanged(const QString&)</slot> 116 182 </connection> 183 <connection> 184 <sender>samplerate</sender> 185 <signal>activated(int)</signal> 186 <receiver>GlobalMixerUi</receiver> 187 <slot>samplerateChanged(int)</slot> 188 </connection> 117 189 </connections> 118 190 <slots> 119 191 <slot>clockChanged( int )</slot> 120 192 <slot>nicknameChanged( const QString& )</slot> 193 <slot>samplerateChanged(int)</slot> 121 194 </slots> 122 195 <layoutdefaults spacing="6" margin="11"/>