Changeset 439
- Timestamp:
- 03/13/07 15:17:03 (17 years ago)
- Files:
-
- branches/streaming-rework/src/bebob/bebob_avplug.cpp (modified) (1 diff)
- branches/streaming-rework/src/bebob/bebob_avplug.h (modified) (2 diffs)
- branches/streaming-rework/src/debugmodule/debugmodule.cpp (modified) (1 diff)
- branches/streaming-rework/src/libavc/avc_definitions.h (modified) (1 diff)
- branches/streaming-rework/src/libavc/avc_function_block.cpp (modified) (5 diffs)
- branches/streaming-rework/src/libavc/avc_function_block.h (modified) (2 diffs)
- branches/streaming-rework/src/libavc/avc_generic.cpp (modified) (1 diff)
- branches/streaming-rework/src/libavc/avc_generic.h (modified) (1 diff)
- branches/streaming-rework/src/libavc/avc_serialize.cpp (modified) (2 diffs)
- branches/streaming-rework/src/libavc/avc_serialize.h (modified) (2 diffs)
- branches/streaming-rework/src/libieee1394/ieee1394service.cpp (modified) (2 diffs)
- branches/streaming-rework/tests/test-mixer.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/streaming-rework/src/bebob/bebob_avplug.cpp
r438 r439 1961 1961 AvPlug* plug = *it; 1962 1962 if ( plug->getFunctionBlockType() != 0xff ) { 1963 std::ostringstream strstrm; 1964 switch(plug->getFunctionBlockType()) { 1965 case 0x80: 1966 strstrm << "Selector FB"; 1967 break; 1968 case 0x81: 1969 strstrm << "Feature FB"; 1970 break; 1971 case 0x82: 1972 strstrm << "Processing FB"; 1973 break; 1974 case 0x83: 1975 strstrm << "CODEC FB"; 1976 break; 1977 default: 1978 strstrm << plug->getFunctionBlockType(); 1979 } 1980 1963 1981 if ( plug->getPlugDirection() == AvPlug::eAPD_Input ) { 1964 debugOutputShort( DEBUG_LEVEL_NORMAL, "\t\"(%d) %s\" -> \"( 0x%02x,%d)\"\n",1982 debugOutputShort( DEBUG_LEVEL_NORMAL, "\t\"(%d) %s\" -> \"(%s, ID %d)\"\n", 1965 1983 plug->getGlobalId(), 1966 1984 plug->getName(), 1967 plug->getFunctionBlockType(),1985 strstrm.str().c_str(), 1968 1986 plug->getFunctionBlockId() ); 1969 1987 } else { 1970 debugOutputShort( DEBUG_LEVEL_NORMAL, "\t\"( 0x%02x,%d)\" -> \t\"(%d) %s\"\n",1971 plug->getFunctionBlockType(),1988 debugOutputShort( DEBUG_LEVEL_NORMAL, "\t\"(%s, ID %d)\" -> \t\"(%d) %s\"\n", 1989 strstrm.str().c_str(), 1972 1990 plug->getFunctionBlockId(), 1973 1991 plug->getGlobalId(), branches/streaming-rework/src/bebob/bebob_avplug.h
r438 r439 96 96 97 97 int getGlobalId() const 98 98 { return m_globalId; } 99 99 plug_id_t getPlugId() const 100 100 { return m_id; } 101 101 AVCCommand::ESubunitType getSubunitType() const 102 102 { return m_subunitType; } 103 103 subunit_id_t getSubunitId() const 104 104 { return m_subunitId; } 105 105 const char* getName() const 106 106 { return m_name.c_str(); } 107 107 EAvPlugDirection getPlugDirection() const 108 108 { return m_direction; } 109 109 sampling_frequency_t getSamplingFrequency() const 110 110 { return m_samplingFrequency; } 111 111 int getSampleRate() const; // 22050, 24000, 32000, ... 112 112 int getNrOfChannels() const; … … 118 118 { return m_addressType; } 119 119 EAvPlugType getPlugType() const 120 120 { return m_infoPlugType; } 121 121 122 122 function_block_type_t getFunctionBlockType() const 123 123 { return m_functionBlockType; } 124 124 function_block_id_t getFunctionBlockId() const 125 125 { return m_functionBlockId; } branches/streaming-rework/src/debugmodule/debugmodule.cpp
r406 r439 54 54 DebugModule::~DebugModule() 55 55 { 56 if ( m_level >= eDL_VeryVerbose ) {57 cout << "Unregistering "58 << this->getName()59 << " at DebugModuleManager"60 << endl;61 }56 // if ( m_level >= eDL_VeryVerbose ) { 57 // cout << "Unregistering " 58 // << this->getName() 59 // << " at DebugModuleManager" 60 // << endl; 61 // } 62 62 if ( !DebugModuleManager::instance()->unregisterModule( *this ) ) { 63 63 cerr << "Could not unregister DebugModule at DebugModuleManager" branches/streaming-rework/src/libavc/avc_definitions.h
r438 r439 71 71 typedef byte_t control_selector_t; 72 72 typedef byte_t control_data_length_t; 73 typedef uint16_t control_data_ext_length_t; 74 typedef uint16_t mixer_level_t; 75 typedef byte_t mixer_programmable_state_t; 73 76 typedef byte_t input_fb_plug_number_t; 74 77 typedef byte_t input_audio_channel_number_t; branches/streaming-rework/src/libavc/avc_function_block.cpp
r413 r439 144 144 FunctionBlockProcessingEnhancedMixer::serialize( IOSSerialize& se ) 145 145 { 146 bool bStatus; 146 int todo,done; 147 bool bStatus; 148 byte_t data_length_hi, data_length_lo; 149 147 150 bStatus = se.write( m_controlSelector, "FunctionBlockProcessingEnhancedMixer controlSelector" ); 148 151 bStatus &= se.write( m_statusSelector, "FunctionBlockProcessingEnhancedMixer statusSelector" ); 149 152 153 switch (m_statusSelector) { 154 case eSS_ProgramableState: 155 m_controlDataLength=m_LevelData.size(); 156 data_length_hi=(m_controlDataLength >> 8); 157 data_length_lo=(m_controlDataLength & 0xFF); 158 bStatus &= se.write( data_length_hi, "FunctionBlockProcessingEnhancedMixer controlDataLengthHi" ); 159 bStatus &= se.write( data_length_lo, "FunctionBlockProcessingEnhancedMixer controlDataLengthLo" ); 160 161 for (int i=0;i<m_controlDataLength/8;i++) { 162 byte_t value=0; 163 164 for (int j=0;j<8;j++) { 165 control_data_ext_length_t bit_value=m_ProgramableStateData.at(i*8+j); 166 value |= bit_value << (7-j); 167 } 168 169 bStatus &= se.write( value, "FunctionBlockProcessingEnhancedMixer data" ); 170 } 171 172 todo=m_controlDataLength%8; 173 done=m_controlDataLength-todo; 174 if (todo) { 175 byte_t value=0; 176 for (int j=0;j<todo;j++) { 177 control_data_ext_length_t bit_value=m_ProgramableStateData.at(done*8+j); 178 value |= bit_value << (7-j); 179 } 180 bStatus &= se.write( value, "FunctionBlockProcessingEnhancedMixer data" ); 181 } 182 break; 183 case eSS_Level: 184 m_controlDataLength=m_LevelData.size()/2; 185 data_length_hi=(m_controlDataLength >> 8); 186 data_length_lo=(m_controlDataLength & 0xFF); 187 bStatus &= se.write( data_length_hi, "FunctionBlockProcessingEnhancedMixer controlDataLengthHi" ); 188 bStatus &= se.write( data_length_lo, "FunctionBlockProcessingEnhancedMixer controlDataLengthLo" ); 189 190 for (int i=0;i<m_controlDataLength/2;i++) { 191 mixer_level_t value=m_LevelData.at(i); 192 byte_t value_hi=value >> 8; 193 byte_t value_lo=value & 0xFF; 194 195 bStatus &= se.write( value_hi, "FunctionBlockProcessingEnhancedMixer data" ); 196 bStatus &= se.write( value_lo, "FunctionBlockProcessingEnhancedMixer data" ); 197 } 198 break; 199 } 150 200 return bStatus; 151 201 } … … 154 204 FunctionBlockProcessingEnhancedMixer::deserialize( IISDeserialize& de ) 155 205 { 156 bool bStatus; 206 int todo; 207 bool bStatus=true; 157 208 bStatus = de.read( &m_controlSelector ); 209 210 // NOTE: the returned value is currently bogus, so overwrite it 211 m_controlSelector=FunctionBlockProcessing::eCSE_Processing_EnhancedMixer; 212 158 213 bStatus &= de.read( &m_statusSelector ); 214 215 byte_t data_length_hi; 216 byte_t data_length_lo; 217 bStatus &= de.read( &data_length_hi ); 218 bStatus &= de.read( &data_length_lo ); 219 220 m_controlDataLength = (data_length_hi << 8) + data_length_lo; 221 switch (m_statusSelector) { 222 case eSS_ProgramableState: 223 m_ProgramableStateData.clear(); 224 for (int i=0;i<m_controlDataLength/8;i++) { 225 byte_t value; 226 bStatus &= de.read( &value); 227 228 for (int j=7;j>=0;j--) { 229 byte_t bit_value; 230 bit_value=(((1<<j) & value) ? 1 : 0); 231 m_ProgramableStateData.push_back(bit_value); 232 } 233 } 234 235 todo=m_controlDataLength%8; 236 if (todo) { 237 byte_t value; 238 bStatus &= de.read( &value); 239 240 for (int j=7;j>7-todo;j--) { 241 byte_t bit_value; 242 bit_value=(((1<<j) & value) ? 1 : 0); 243 m_ProgramableStateData.push_back(bit_value); 244 } 245 } 246 break; 247 case eSS_Level: 248 m_LevelData.clear(); 249 for (int i=0;i<m_controlDataLength/2;i++) { 250 byte_t mixer_value_hi=0, mixer_value_lo=0; 251 bStatus &= de.read( &mixer_value_hi); 252 bStatus &= de.read( &mixer_value_lo); 253 mixer_level_t value = (mixer_value_hi << 8) + mixer_value_lo; 254 m_LevelData.push_back(value); 255 } 256 break; 257 } 159 258 160 259 return bStatus; … … 358 457 FunctionBlockProcessing::deserialize( IISDeserialize& de ) 359 458 { 459 // NOTE: apparently the fbCmd of the STATUS type, 460 // with EnhancedMixer controlSelector returns with this 461 // controlSelector type changed to Mixer, making it 462 // impossible to choose the correct response handler 463 // based upon the response only. 464 465 // HACK: we assume that it is the same as the sent one 466 // we also look at our data structure to figure out what we sent 467 byte_t controlSelector=eCSE_Processing_Unknown; 468 if(m_pMixer) { 469 controlSelector=eCSE_Processing_Mixer; 470 } else if(m_pEnhancedMixer) { 471 controlSelector=eCSE_Processing_EnhancedMixer; 472 } 473 360 474 bool bStatus; 361 475 bStatus = de.read( &m_selectorLength ); … … 364 478 bStatus &= de.read( &m_outputAudioChannelNumber ); 365 479 366 byte_t controlSelector; 367 bStatus &= de.peek( &controlSelector ); 480 byte_t controlSelector_response; 481 bStatus &= de.peek( &controlSelector_response ); 482 /* debugOutput(DEBUG_LEVEL_VERBOSE,"ctrlsel: orig = %02X, resp = %02X\n", 483 controlSelector, controlSelector_response);*/ 484 368 485 switch( controlSelector ) { 369 486 case eCSE_Processing_Mixer: … … 385 502 } 386 503 504 byte_t tmp; 505 if (de.peek(&tmp)) { 506 debugOutput(DEBUG_LEVEL_VERBOSE,"Unprocessed bytes:\n"); 507 while (de.read(&tmp)) { 508 debugOutput(DEBUG_LEVEL_VERBOSE," %02X\n",tmp); 509 } 510 } 511 387 512 return bStatus; 388 513 } branches/streaming-rework/src/libavc/avc_function_block.h
r379 r439 26 26 27 27 #include <libavc1394/avc1394.h> 28 #include <vector> 29 using namespace std; 28 30 29 31 class FunctionBlockFeatureVolume: public IBusData … … 78 80 virtual FunctionBlockProcessingEnhancedMixer* clone() const; 79 81 80 control_selector_t m_controlSelector; 81 status_selector_t m_statusSelector; 82 control_selector_t m_controlSelector; 83 status_selector_t m_statusSelector; 84 control_data_ext_length_t m_controlDataLength; 85 vector<mixer_programmable_state_t> m_ProgramableStateData; 86 vector<mixer_level_t> m_LevelData; 82 87 }; 83 88 branches/streaming-rework/src/libavc/avc_generic.cpp
r413 r439 30 30 31 31 IMPL_DEBUG_MODULE( AVCCommand, AVCCommand, DEBUG_LEVEL_NORMAL ); 32 IMPL_DEBUG_MODULE( IBusData, IBusData, DEBUG_LEVEL_VERBOSE ); 32 33 33 34 int AVCCommand::m_time = 0; branches/streaming-rework/src/libavc/avc_generic.h
r375 r439 45 45 46 46 virtual IBusData* clone() const = 0; 47 48 protected: 49 DECLARE_DEBUG_MODULE; 47 50 }; 48 51 branches/streaming-rework/src/libavc/avc_serialize.cpp
r365 r439 26 26 #include <netinet/in.h> 27 27 28 IMPL_DEBUG_MODULE( CoutSerializer, CoutSerializer, DEBUG_LEVEL_NORMAL ); 29 28 30 bool 29 31 CoutSerializer::write( byte_t d, const char* name ) 30 32 { 31 printf(" %3d:\t0x%02x\t%s\n", m_cnt, d, name );33 debugOutput( DEBUG_LEVEL_NORMAL, " %3d:\t0x%02x\t%s\n", m_cnt, d, name ); 32 34 m_cnt += sizeof( byte_t ); 33 35 … … 38 40 CoutSerializer::write( quadlet_t d, const char* name ) 39 41 { 40 printf(" %3d:\t0x%08x\t%s\n", m_cnt, d, name );42 debugOutput( DEBUG_LEVEL_NORMAL, " %3d:\t0x%08x\t%s\n", m_cnt, d, name ); 41 43 m_cnt += sizeof( quadlet_t ); 42 44 return true; branches/streaming-rework/src/libavc/avc_serialize.h
r365 r439 21 21 #ifndef Serialize_h 22 22 #define Serialize_h 23 24 #include "debugmodule/debugmodule.h" 23 25 24 26 #include <libraw1394/raw1394.h> // byte_t and quadlet_t declaration … … 62 64 private: 63 65 unsigned int m_cnt; 66 DECLARE_DEBUG_MODULE; 64 67 65 68 }; branches/streaming-rework/src/libieee1394/ieee1394service.cpp
r436 r439 287 287 } 288 288 289 #ifdef DEBUG290 debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, " pre avc1394_transaction_block2\n" );291 printBuffer( DEBUG_LEVEL_VERY_VERBOSE, len, buf );292 #endif293 294 289 fb_quadlet_t* result = 295 290 avc1394_transaction_block2( m_handle, … … 299 294 resp_len, 300 295 10 ); 301 302 #ifdef DEBUG303 debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, " post avc1394_transaction_block2\n" );304 printBuffer( DEBUG_LEVEL_VERY_VERBOSE, *resp_len, result );305 #endif306 296 307 297 for ( unsigned int i = 0; i < *resp_len; ++i ) { branches/streaming-rework/tests/test-mixer.cpp
r437 r439 21 21 #include "libavc/avc_function_block.h" 22 22 #include "libavc/avc_serialize.h" 23 #include "debugmodule/debugmodule.h" 23 24 24 25 #include "libieee1394/ieee1394service.h" 26 #include <string.h> 27 28 DECLARE_GLOBAL_DEBUG_MODULE; 25 29 26 30 const bool bVerbose = true; … … 38 42 fbCmd.m_pFBProcessing->m_pEnhancedMixer = new FunctionBlockProcessingEnhancedMixer; 39 43 40 fbCmd.m_pFBProcessing->m_fbInputPlugNumber = 0x01; 44 debugOutput(DEBUG_LEVEL_NORMAL, "Requesting mixer programmable state...\n"); 45 46 fbCmd.m_pFBProcessing->m_fbInputPlugNumber = 0x00; 41 47 fbCmd.m_pFBProcessing->m_inputAudioChannelNumber = 0xff; 42 48 fbCmd.m_pFBProcessing->m_outputAudioChannelNumber = 0xff; 43 49 fbCmd.m_pFBProcessing->m_pEnhancedMixer->m_statusSelector 44 50 = FunctionBlockProcessingEnhancedMixer::eSS_ProgramableState; 45 // fbCmd.m_pFBProcessing->m_pEnhancedMixer->m_statusSelector46 // = FunctionBlockProcessingEnhancedMixer::eSS_Level;47 51 48 52 fbCmd.setVerbose( bVerbose ); … … 52 56 53 57 if ( !fbCmd.fire() ) { 54 printf( "cmd failed\n" ); 58 debugError( "cmd failed\n" ); 59 } 60 61 if ( bVerbose ) { 62 CoutSerializer se; 63 fbCmd.serialize( se ); 64 } 65 66 debugOutput(DEBUG_LEVEL_NORMAL, "Requesting mixer level state...\n"); 67 68 fbCmd.m_pFBProcessing->m_fbInputPlugNumber = 0x00; 69 fbCmd.m_pFBProcessing->m_inputAudioChannelNumber = 0x00; 70 fbCmd.m_pFBProcessing->m_outputAudioChannelNumber = 0x00; 71 fbCmd.m_pFBProcessing->m_pEnhancedMixer->m_statusSelector 72 = FunctionBlockProcessingEnhancedMixer::eSS_Level; 73 74 if ( !fbCmd.fire() ) { 75 debugError( "cmd failed\n" ); 76 } 77 78 if ( bVerbose ) { 79 CoutSerializer se; 80 fbCmd.serialize( se ); 81 } 82 83 return true; 84 } 85 86 bool 87 doApp2( Ieee1394Service& ieee1394service, int node_id, int fb_id ) 88 { 89 FunctionBlockCmd fbCmd( ieee1394service, 90 FunctionBlockCmd::eFBT_Selector, 91 fb_id, 92 FunctionBlockCmd::eCA_Current ); 93 fbCmd.setNodeId( node_id ); 94 fbCmd.setSubunitId( 0x00 ); 95 fbCmd.setCommandType( AVCCommand::eCT_Status ); 96 fbCmd.m_pFBSelector->m_inputFbPlugNumber=0; 97 98 debugOutput(DEBUG_LEVEL_NORMAL, "Requesting selector state...\n"); 99 100 fbCmd.setVerbose( bVerbose ); 101 if (bVerbose) { 102 ieee1394service.setVerboseLevel( DEBUG_LEVEL_VERY_VERBOSE ); 103 } 104 105 if ( !fbCmd.fire() ) { 106 debugError( "cmd failed\n" ); 107 } 108 109 if ( bVerbose ) { 110 CoutSerializer se; 111 fbCmd.serialize( se ); 112 } 113 114 return true; 115 } 116 117 bool 118 doApp3( Ieee1394Service& ieee1394service, int node_id, int fb_id , int val ) 119 { 120 FunctionBlockCmd fbCmd( ieee1394service, 121 FunctionBlockCmd::eFBT_Selector, 122 fb_id, 123 FunctionBlockCmd::eCA_Current ); 124 fbCmd.setNodeId( node_id ); 125 fbCmd.setSubunitId( 0x00 ); 126 fbCmd.setCommandType( AVCCommand::eCT_Control ); 127 fbCmd.m_pFBSelector->m_inputFbPlugNumber=val; 128 129 debugOutput(DEBUG_LEVEL_NORMAL, "Setting selector state to %d...\n", val); 130 131 fbCmd.setVerbose( bVerbose ); 132 if (bVerbose) { 133 ieee1394service.setVerboseLevel( DEBUG_LEVEL_VERY_VERBOSE ); 134 } 135 136 if ( !fbCmd.fire() ) { 137 debugError( "cmd failed\n" ); 55 138 } 56 139 … … 71 154 72 155 if (argc < 3) { 73 printf("usage: PORT NODE_ID FB_ID\n");156 debugError("usage: PORT NODE_ID FB_ID\n"); 74 157 exit(0); 75 158 } … … 82 165 83 166 if (errno) { 84 perror("argument parsing failed:");167 debugError("argument parsing failed: %s", strerror(errno)); 85 168 return -1; 86 169 } 87 170 Ieee1394Service ieee1394service; 88 171 if ( !ieee1394service.initialize( port ) ) { 89 fprintf( stderr,"could not set port on ieee1394service\n" );172 debugError( "could not set port on ieee1394service\n" ); 90 173 return -1; 91 174 } 92 175 93 176 doApp( ieee1394service, node_id, fb_id ); 177 doApp2( ieee1394service, node_id, fb_id ); 178 // doApp3( ieee1394service, node_id, fb_id , 0 ); 179 // sleep(1); 180 // doApp3( ieee1394service, node_id, fb_id , 1 ); 181 // sleep(1); 182 // doApp3( ieee1394service, node_id, fb_id , 0 ); 94 183 95 184 return 0;