Changeset 40 for trunk/freebob
- Timestamp:
- 12/05/04 07:09:21 (19 years ago)
- Files:
-
- trunk/freebob/src/avclusterinfoblock.cpp (modified) (2 diffs)
- trunk/freebob/src/avclusterinfoblock.h (modified) (1 diff)
- trunk/freebob/src/avdescriptor.cpp (modified) (4 diffs)
- trunk/freebob/src/avdevice.cpp (modified) (5 diffs)
- trunk/freebob/src/avdevice.h (modified) (1 diff)
- trunk/freebob/src/avdevicemusicsubunit.cpp (modified) (2 diffs)
- trunk/freebob/src/avdevicemusicsubunit.h (modified) (1 diff)
- trunk/freebob/src/avdevicesubunit.cpp (modified) (2 diffs)
- trunk/freebob/src/avdevicesubunit.h (modified) (1 diff)
- trunk/freebob/src/avmusicidentifierdescriptor.cpp (modified) (1 diff)
- trunk/freebob/src/avmusicpluginfoblock.cpp (modified) (1 diff)
- trunk/freebob/src/avmusicstatusdescriptor.cpp (modified) (2 diffs)
- trunk/freebob/src/avmusicstatusdescriptor.h (modified) (2 diffs)
- trunk/freebob/src/avpluginfoblock.cpp (modified) (1 diff)
- trunk/freebob/src/avpluginfoblock.h (modified) (1 diff)
- trunk/freebob/src/avroutingstatusinfoblock.cpp (modified) (6 diffs)
- trunk/freebob/src/avroutingstatusinfoblock.h (modified) (1 diff)
- trunk/freebob/src/debugmodule.h (modified) (1 diff)
- trunk/freebob/src/ieee1394service.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/freebob/src/avclusterinfoblock.cpp
r38 r40 48 48 49 49 for(unsigned int i=0;i<nb_signals;i++) { 50 unsigned int plug_info=readWord(0x0 A+i*4);51 unsigned char stream_position=readByte(0x0 A+i*4+2);52 unsigned char stream_location=readByte(0x0 A+i*4+3);50 unsigned int plug_info=readWord(0x09+i*4); 51 unsigned char stream_position=readByte(0x09+i*4+2); 52 unsigned char stream_location=readByte(0x09+i*4+3); 53 53 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvClusterInfoBlock: Signal %d: plug_info=0x%04X, stream_position=0x%02X, stream_location=0x%02X\n",i,plug_info,stream_position,stream_location); 54 54 … … 80 80 } 81 81 82 void AvClusterInfoBlock::printSignalInfo(unsigned char idx) { 83 if (idx<getNbSignals() && (0x09+idx*4<getLength())) { 84 unsigned int plug_info=readWord(0x09+idx*4); 85 unsigned char stream_position=readByte(0x09+idx*4+2); 86 unsigned char stream_location=readByte(0x09+idx*4+3); 87 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvClusterInfoBlock: Signal %d: plug_info=0x%04X, stream_position=0x%02X, stream_location=0x%02X\n",idx,plug_info,stream_position,stream_location); 88 } else { 89 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvClusterInfoBlock: Signal %d not present!\n",idx); 90 91 } 92 } 93 94 void AvClusterInfoBlock::printName() { 95 unsigned int next_block_position=iBaseAddress+0x06+readWord(0x04); 96 97 if(next_block_position<iBaseAddress+getLength()) { 98 // parse the optional name block 99 AvNameInfoBlock *tmpNameInfoBlock=new AvNameInfoBlock(cParent,next_block_position); 100 if (tmpNameInfoBlock && (tmpNameInfoBlock->isValid())) { 101 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvClusterInfoBlock: Name: %s\n",tmpNameInfoBlock->getName()); 102 103 } else { 104 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvClusterInfoBlock: no name block present\n"); 105 } 106 if(tmpNameInfoBlock) { 107 delete tmpNameInfoBlock; 108 tmpNameInfoBlock=NULL; 109 } 110 } 111 112 } trunk/freebob/src/avclusterinfoblock.h
r38 r40 44 44 AvClusterInfoBlock(AvDescriptor *parent, int address); // read an infoblock from a parent starting from a specific position 45 45 virtual ~AvClusterInfoBlock(); 46 unsigned char getStreamFormat() {return readByte(0x06);}; 47 unsigned char getPortType() {return readByte(0x07);}; 48 unsigned char getNbSignals() {return readByte(0x08);}; 46 49 50 void printSignalInfo(unsigned char idx); 51 void printName(); 47 52 48 53 protected: trunk/freebob/src/avdescriptor.cpp
r26 r40 164 164 iLength=response[2] & 0xFFFF; 165 165 166 debugPrint(DEBUG_LEVEL_DESCRIPTOR,"Descriptor length=0x%04X %d \n",iLength,iLength);166 debugPrint(DEBUG_LEVEL_DESCRIPTOR,"Descriptor length=0x%04X %d ",iLength,iLength); 167 167 168 168 // now get the rest of the descriptor … … 183 183 // first read 184 184 if(bytes_read<iLength) { 185 debugPrint (DEBUG_LEVEL_DESCRIPTOR,".");185 debugPrintShort(DEBUG_LEVEL_DESCRIPTOR,"."); 186 186 // apparently the lib modifies the request, so redefine it completely 187 187 request[0] = AVC1394_CTYPE_CONTROL | qTarget … … 208 208 // now do the remaining reads 209 209 while(bytes_read<iLength) { 210 debugPrint (DEBUG_LEVEL_DESCRIPTOR,".");210 debugPrintShort(DEBUG_LEVEL_DESCRIPTOR,"."); 211 211 // apparently the lib modifies the request, so redefine it completely 212 212 request[0] = AVC1394_CTYPE_CONTROL | qTarget … … 229 229 230 230 } 231 debugPrint (DEBUG_LEVEL_DESCRIPTOR,"\n");231 debugPrintShort(DEBUG_LEVEL_DESCRIPTOR,"\n"); 232 232 233 233 trunk/freebob/src/avdevice.cpp
r38 r40 43 43 FBReturnCodes 44 44 AvDevice::Initialize() { 45 if (!m_bInitialised) { 45 46 if (!m_bInitialised) { 46 47 47 48 m_handle = raw1394_new_handle(); … … 154 155 if(tmpAvDeviceSubunit && tmpAvDeviceSubunit->isValid()) { 155 156 cSubUnits.push_back(tmpAvDeviceSubunit); 156 157 //setDebugLevel(DEBUG_LEVEL_ALL); 158 debugPrint (DEBUG_LEVEL_DEVICE, "Trying to reserve the subunit...\n"); 159 tmpAvDeviceSubunit->reserve(0x01); 160 debugPrint (DEBUG_LEVEL_DEVICE, " isReserved?: %d\n",tmpAvDeviceSubunit->isReserved()); 161 tmpAvDeviceSubunit->unReserve(); 162 //setDebugLevel(DEBUG_LEVEL_MODERATE); 163 157 164 158 165 } else { … … 203 210 response = avc1394_transaction_block(m_handle, iNodeId, request, request_len, 2); 204 211 if (request != NULL) { 205 debugPrint (DEBUG_LEVEL_TRANSFERS, " \n------- TRANSACTION START -------\n");212 debugPrint (DEBUG_LEVEL_TRANSFERS, "------- TRANSACTION START -------\n"); 206 213 debugPrint (DEBUG_LEVEL_TRANSFERS," REQUEST: "); 207 214 /* request is in machine byte order. this function is for intel architecure */ 208 215 for (i=0;i<request_len;i++) { 209 216 request_pos=(unsigned char *)(request+i); 210 debugPrint (DEBUG_LEVEL_TRANSFERS, "0x%02X%02X%02X%02X ", *(request_pos),*(request_pos+1),*(request_pos+2),*(request_pos+3));211 } 212 debugPrint (DEBUG_LEVEL_TRANSFERS,"\n");217 debugPrintShort (DEBUG_LEVEL_TRANSFERS, "0x%02X%02X%02X%02X ", *(request_pos),*(request_pos+1),*(request_pos+2),*(request_pos+3)); 218 } 219 debugPrintShort (DEBUG_LEVEL_TRANSFERS,"\n"); 213 220 debugPrint (DEBUG_LEVEL_TRANSFERS," => "); 214 debugPrint (DEBUG_LEVEL_TRANSFERS," ");221 debugPrintShort (DEBUG_LEVEL_TRANSFERS," "); 215 222 request_pos=(unsigned char *)(request); 216 debugPrint (DEBUG_LEVEL_TRANSFERS, "subunit_type=%02X subunit_id=%02X opcode=%02X",((*(request_pos+1))>>3)&0x1F,(*(request_pos+1))&0x07,(*(request_pos+2))&0xFF);217 debugPrint (DEBUG_LEVEL_TRANSFERS,"\n");223 debugPrintShort (DEBUG_LEVEL_TRANSFERS, "subunit_type=%02X subunit_id=%02X opcode=%02X",((*(request_pos+1))>>3)&0x1F,(*(request_pos+1))&0x07,(*(request_pos+2))&0xFF); 224 debugPrintShort (DEBUG_LEVEL_TRANSFERS,"\n"); 218 225 } 219 226 if (response != NULL) { … … 221 228 debugPrint (DEBUG_LEVEL_TRANSFERS," -> RESPONSE: "); 222 229 for (i=0;i<response_len;i++) { 223 debugPrint (DEBUG_LEVEL_TRANSFERS, "0x%08X ", response[i]);224 } 225 debugPrint (DEBUG_LEVEL_TRANSFERS,"\n");230 debugPrintShort (DEBUG_LEVEL_TRANSFERS, "0x%08X ", response[i]); 231 } 232 debugPrintShort (DEBUG_LEVEL_TRANSFERS,"\n"); 226 233 debugPrint (DEBUG_LEVEL_TRANSFERS," => "); 227 234 switch (response[0]&0xFF000000) { 228 235 case AVC1394_RESPONSE_NOT_IMPLEMENTED: 229 debugPrint (DEBUG_LEVEL_TRANSFERS,"Not Implemented ");236 debugPrintShort (DEBUG_LEVEL_TRANSFERS,"Not Implemented "); 230 237 break; 231 238 case AVC1394_RESPONSE_ACCEPTED: 232 debugPrint (DEBUG_LEVEL_TRANSFERS,"Accepted ");239 debugPrintShort (DEBUG_LEVEL_TRANSFERS,"Accepted "); 233 240 break; 234 241 case AVC1394_RESPONSE_REJECTED: 235 debugPrint (DEBUG_LEVEL_TRANSFERS,"Rejected ");242 debugPrintShort (DEBUG_LEVEL_TRANSFERS,"Rejected "); 236 243 break; 237 244 case AVC1394_RESPONSE_IN_TRANSITION: 238 debugPrint (DEBUG_LEVEL_TRANSFERS,"In Transition ");245 debugPrintShort (DEBUG_LEVEL_TRANSFERS,"In Transition "); 239 246 break; 240 247 case AVC1394_RESPONSE_IMPLEMENTED: 241 debugPrint (DEBUG_LEVEL_TRANSFERS,"Implemented / Stable ");248 debugPrintShort (DEBUG_LEVEL_TRANSFERS,"Implemented / Stable "); 242 249 break; 243 250 case AVC1394_RESPONSE_CHANGED: 244 debugPrint (DEBUG_LEVEL_TRANSFERS,"Changed ");251 debugPrintShort (DEBUG_LEVEL_TRANSFERS,"Changed "); 245 252 break; 246 253 case AVC1394_RESPONSE_INTERIM: 247 debugPrint (DEBUG_LEVEL_TRANSFERS,"Interim ");254 debugPrintShort (DEBUG_LEVEL_TRANSFERS,"Interim "); 248 255 break; 249 256 default: 250 debugPrint (DEBUG_LEVEL_TRANSFERS,"Unknown response ");251 break; 252 } 253 debugPrint (DEBUG_LEVEL_TRANSFERS, "subunit_type=%02X subunit_id=%02X opcode=%02X",(response[0]>>19)&0x1F,(response[0]>>16)&0x07,(response[0]>>8)&0xFF);254 debugPrint (DEBUG_LEVEL_TRANSFERS,"\n");257 debugPrintShort (DEBUG_LEVEL_TRANSFERS,"Unknown response "); 258 break; 259 } 260 debugPrintShort (DEBUG_LEVEL_TRANSFERS, "subunit_type=%02X subunit_id=%02X opcode=%02X",(response[0]>>19)&0x1F,(response[0]>>16)&0x07,(response[0]>>8)&0xFF); 261 debugPrintShort (DEBUG_LEVEL_TRANSFERS,"\n"); 255 262 } 256 263 debugPrint (DEBUG_LEVEL_TRANSFERS, "------- TRANSACTION END -------\n"); … … 258 265 259 266 } 267 268 FBReturnCodes AvDevice::setInputPlugSignalFormat(unsigned char plug, unsigned char fmt, quadlet_t fdf) { 269 quadlet_t request[6]; 270 quadlet_t *response; 271 272 request[0] = AVC1394_CTYPE_CONTROL | AVC1394_SUBUNIT_TYPE_UNIT | AVC1394_SUBUNIT_ID_IGNORE 273 | AVC1394_COMMAND_INPUT_PLUG_SIGNAL_FORMAT | plug; 274 request[1] = (0x80000000) | ((fmt & 0x3F)<<24) | (fdf & 0x00FFFFFF); 275 response = avcExecuteTransaction(request, 2, 2); 276 if (response != NULL) { 277 278 } 279 280 } 281 282 FBReturnCodes AvDevice::getInputPlugSignalFormat(unsigned char plug, unsigned char *fmt, quadlet_t *fdf) { 283 quadlet_t request[6]; 284 quadlet_t *response; 285 286 request[0] = AVC1394_CTYPE_STATUS | AVC1394_SUBUNIT_TYPE_UNIT | AVC1394_SUBUNIT_ID_IGNORE 287 | AVC1394_COMMAND_INPUT_PLUG_SIGNAL_FORMAT | plug; 288 request[1] = 0xFFFFFFFF; 289 response = avcExecuteTransaction(request, 2, 2); 290 if (response != NULL) { 291 *fmt=((response[1] >> 24) & 0x3F); 292 *fdf=response[1]& 0x00FFFFFF; 293 } 294 295 } 296 FBReturnCodes AvDevice::setOutputPlugSignalFormat(unsigned char plug, unsigned char fmt, quadlet_t fdf) { 297 quadlet_t request[6]; 298 quadlet_t *response; 299 300 request[0] = AVC1394_CTYPE_CONTROL | AVC1394_SUBUNIT_TYPE_UNIT | AVC1394_SUBUNIT_ID_IGNORE 301 | AVC1394_COMMAND_OUTPUT_PLUG_SIGNAL_FORMAT | plug; 302 request[1] = (0x80000000) | ((fmt & 0x3F)<<24) | (fdf & 0x00FFFFFF); 303 response = avcExecuteTransaction(request, 2, 2); 304 if (response != NULL) { 305 306 } 307 308 } 309 310 FBReturnCodes AvDevice::getOutputPlugSignalFormat(unsigned char plug, unsigned char *fmt, quadlet_t *fdf) { 311 quadlet_t request[6]; 312 quadlet_t *response; 313 314 request[0] = AVC1394_CTYPE_STATUS | AVC1394_SUBUNIT_TYPE_UNIT | AVC1394_SUBUNIT_ID_IGNORE 315 | AVC1394_COMMAND_OUTPUT_PLUG_SIGNAL_FORMAT | plug; 316 request[1] = 0xFFFFFFFF; 317 response = avcExecuteTransaction(request, 2, 2); 318 if (response != NULL) { 319 *fmt=((response[1] >> 24) & 0x3F); 320 *fdf=response[1]& 0x00FFFFFF; 321 } 322 323 } 324 325 AvDeviceSubunit *AvDevice::getSubunit(unsigned char type, unsigned char id) { 326 vector<AvDeviceSubunit *>::iterator it; 327 for( it = cSubUnits.begin(); it != cSubUnits.end(); it++ ) { 328 if ((*it) && ((*it)->getType()==type) && ((*it)->getId()==id)) { 329 return *it; 330 } 331 } 332 return NULL; 333 334 } 335 336 #define AVC1394_COMMAND_SIGNAL_SOURCE 0x00001A00 337 338 void AvDevice::printConnections() { 339 quadlet_t request[6]; 340 quadlet_t *response; 341 //setDebugLevel(DEBUG_LEVEL_ALL); 342 343 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: ISO source connections:\n"); 344 345 for (unsigned int i=0;i<getNbIsoSourcePlugs();i++) { 346 request[0] = AVC1394_CTYPE_STATUS | AVC1394_SUBUNIT_TYPE_UNIT | AVC1394_SUBUNIT_ID_IGNORE 347 | AVC1394_COMMAND_SIGNAL_SOURCE | 0xFF; 348 request[1]=0xFFFEFF00 | ((i & 0xFF)); 349 350 response = avcExecuteTransaction(request, 2, 2); 351 352 if (response != NULL) { 353 unsigned char output_status=(response[0]&0xE0) >> 5; 354 unsigned char conv=(response[0]&0x10) >> 4; 355 unsigned char signal_status=(response[0]&0x0F); 356 357 unsigned int signal_source=((response[1]>>16)&0xFFFF); 358 359 unsigned char source_subunit_type=(signal_source>>11)&0x1F; 360 unsigned char source_subunit_id=(signal_source>>8)&0x07; 361 unsigned char source_plug=signal_source&0xFF; 362 363 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: OPCR 0x%02X <- subunit: 0x%02X/0x%02X, plug: 0x%02X (0x%02X / %d / 0x%02X)\n",i, source_subunit_type,source_subunit_id,source_plug,output_status,conv,signal_status); 364 // find the subunit this plug is connected to 365 AvDeviceSubunit *tmpSubunit=getSubunit(source_subunit_type,source_subunit_id); 366 if(tmpSubunit) { 367 tmpSubunit->printSourcePlugConnections(source_plug); 368 } 369 370 } 371 } 372 373 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: External source connections:\n"); 374 375 for (unsigned int i=0;i<getNbExtSourcePlugs();i++) { 376 request[0] = AVC1394_CTYPE_STATUS | AVC1394_SUBUNIT_TYPE_UNIT | AVC1394_SUBUNIT_ID_IGNORE 377 | AVC1394_COMMAND_SIGNAL_SOURCE | 0xFF; 378 request[1]=0xFFFEFF00 | ((i & 0xFF)|0x80); 379 380 response = avcExecuteTransaction(request, 2, 2); 381 382 if (response != NULL) { 383 unsigned char output_status=(response[0]&0xE0) >> 5; 384 unsigned char conv=(response[0]&0x10) >> 4; 385 unsigned char signal_status=(response[0]&0x0F); 386 387 unsigned int signal_source=((response[1]>>16)&0xFFFF); 388 389 unsigned char source_subunit_type=(signal_source>>11)&0x1F; 390 unsigned char source_subunit_id=(signal_source>>8)&0x07; 391 unsigned char source_plug=signal_source&0xFF; 392 393 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: EXTOUT 0x%02X <- subunit: 0x%02X/0x%02X, plug: 0x%02X (0x%02X / %d / 0x%02X)\n",i, source_subunit_type,source_subunit_id,source_plug,output_status,conv,signal_status); 394 395 // find the subunit this plug is connected to 396 AvDeviceSubunit *tmpSubunit=getSubunit(source_subunit_type,source_subunit_id); 397 if(tmpSubunit) { 398 tmpSubunit->printSourcePlugConnections(source_plug); 399 } 400 } 401 } 402 403 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: ISO sink connections:\n"); 404 405 for (unsigned int i=0;i<getNbIsoDestinationPlugs();i++) { 406 request[0] = AVC1394_CTYPE_STATUS | AVC1394_SUBUNIT_TYPE_UNIT | AVC1394_SUBUNIT_ID_IGNORE 407 | AVC1394_COMMAND_SIGNAL_SOURCE | 0xFF; 408 request[1]=0xFFFEFF00 | ((i & 0xFF)); 409 410 response = avcExecuteTransaction(request, 2, 2); 411 412 if (response != NULL) { 413 unsigned char output_status=(response[0]&0xE0) >> 5; 414 unsigned char conv=(response[0]&0x10) >> 4; 415 unsigned char signal_status=(response[0]&0x0F); 416 417 unsigned int signal_source=((response[1]>>16)&0xFFFF); 418 419 unsigned char source_subunit_type=(signal_source>>11)&0x1F; 420 unsigned char source_subunit_id=(signal_source>>8)&0x07; 421 unsigned char source_plug=signal_source&0xFF; 422 423 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: OPCR 0x%02X <- subunit: 0x%02X/0x%02X, plug: 0x%02X (0x%02X / %d / 0x%02X)\n",i, source_subunit_type,source_subunit_id,source_plug,output_status,conv,signal_status); 424 // find the subunit this plug is connected to 425 AvDeviceSubunit *tmpSubunit=getSubunit(source_subunit_type,source_subunit_id); 426 if(tmpSubunit) { 427 //tmpSubunit->printDestinationPlugConnections(source_plug); 428 } 429 430 } 431 } 432 433 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: External sink connections:\n"); 434 435 for (unsigned int i=0;i<getNbExtDestinationPlugs();i++) { 436 request[0] = AVC1394_CTYPE_STATUS | AVC1394_SUBUNIT_TYPE_UNIT | AVC1394_SUBUNIT_ID_IGNORE 437 | AVC1394_COMMAND_SIGNAL_SOURCE | 0xFF; 438 request[1]=0xFFFEFF00 | ((i & 0xFF)|0x80); 439 440 response = avcExecuteTransaction(request, 2, 2); 441 442 if (response != NULL) { 443 unsigned char output_status=(response[0]&0xE0) >> 5; 444 unsigned char conv=(response[0]&0x10) >> 4; 445 unsigned char signal_status=(response[0]&0x0F); 446 447 unsigned int signal_source=((response[1]>>16)&0xFFFF); 448 449 unsigned char source_subunit_type=(signal_source>>11)&0x1F; 450 unsigned char source_subunit_id=(signal_source>>8)&0x07; 451 unsigned char source_plug=signal_source&0xFF; 452 453 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: EXTOUT 0x%02X <- subunit: 0x%02X/0x%02X, plug: 0x%02X (0x%02X / %d / 0x%02X)\n",i, source_subunit_type,source_subunit_id,source_plug,output_status,conv,signal_status); 454 455 // find the subunit this plug is connected to 456 AvDeviceSubunit *tmpSubunit=getSubunit(source_subunit_type,source_subunit_id); 457 if(tmpSubunit) { 458 //tmpSubunit->printDestinationPlugConnections(source_plug); 459 } 460 } 461 } 462 463 } trunk/freebob/src/avdevice.h
r31 r40 38 38 quadlet_t * avcExecuteTransaction(quadlet_t *request, unsigned int request_len, unsigned int response_len); 39 39 40 FBReturnCodes AvDevice::Initialize();40 FBReturnCodes Initialize(); 41 41 42 bool AvDevice::isInitialised();42 bool isInitialised(); 43 43 44 FBReturnCodes setInputPlugSignalFormat(unsigned char plug, unsigned char fmt, quadlet_t fdf); 45 FBReturnCodes getInputPlugSignalFormat(unsigned char plug, unsigned char *fmt, quadlet_t *fdf); 46 FBReturnCodes setOutputPlugSignalFormat(unsigned char plug, unsigned char fmt, quadlet_t fdf); 47 FBReturnCodes getOutputPlugSignalFormat(unsigned char plug, unsigned char *fmt, quadlet_t *fdf); 48 49 // getSourcePlugConnection(); 50 void printConnections(); 51 52 unsigned char getNbAsyncSourcePlugs() { return iNbAsyncSourcePlugs; } ; 53 unsigned char getNbAsyncDestinationPlugs() { return iNbAsyncDestinationPlugs; } ; 54 unsigned char getNbIsoSourcePlugs() { return iNbIsoSourcePlugs; } ; // oPCR 55 unsigned char getNbIsoDestinationPlugs() { return iNbIsoDestinationPlugs; } ; // iPCR 56 unsigned char getNbExtSourcePlugs() { return iNbExtSourcePlugs; } ; 57 unsigned char getNbExtDestinationPlugs() { return iNbExtDestinationPlugs; } ; 58 59 int getNodeId() { return iNodeId; } ; 60 61 protected: 62 AvDeviceSubunit *getSubunit(unsigned char type, unsigned char id); 63 44 64 private: 45 65 int iNodeId; trunk/freebob/src/avdevicemusicsubunit.cpp
r35 r40 27 27 #include "avmusicstatusdescriptor.h" 28 28 #include "avmusicidentifierdescriptor.h" 29 #include "avpluginfoblock.h" 30 #include "avclusterinfoblock.h" 29 31 30 32 #define CORRECT_INTEGER_ENDIANNESS(value) (((((value)>>8) & 0xFF)) | ((((value)) & 0xFF)<<8)) … … 156 158 } 157 159 160 void AvDeviceMusicSubunit::printSourcePlugConnections(unsigned char plug) { 161 if(cStatusDescriptor) { 162 AvPlugInfoBlock *plugInfo=cStatusDescriptor->getSourcePlugInfoBlock(plug); 163 164 if(plugInfo) { 165 plugInfo->printConnections(); 166 } else { 167 debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceMusicSubunit: could not find source plug 0x%02X in the descriptor.\n",plug); 168 } 169 170 171 } else { 172 debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceMusicSubunit: no Status Descriptor present!\n"); 173 } 174 175 } 176 177 158 178 159 179 AvDeviceMusicSubunit::AvDeviceMusicSubunit(AvDevice *parent, unsigned char id) : AvDeviceSubunit(parent,0x0C,id) trunk/freebob/src/avdevicemusicsubunit.h
r31 r40 40 40 void printMusicPlugInfo(); 41 41 void printMusicPlugConfigurations(); 42 43 virtual void printSourcePlugConnections(unsigned char plug); 44 45 protected: 46 42 47 43 48 private: trunk/freebob/src/avdevicesubunit.cpp
r35 r40 74 74 } 75 75 76 void AvDeviceSubunit::printSourcePlugConnections(unsigned char plug) { 77 debugPrint(DEBUG_LEVEL_SUBUNIT," No internal connection information available.\n"); 78 79 } 80 81 76 82 AvDeviceSubunit::AvDeviceSubunit(AvDevice *parent, unsigned char target, unsigned char id) 77 83 { … … 128 134 return iNbSourcePlugs; 129 135 } 136 137 int AvDeviceSubunit::reserve(unsigned char priority) { 138 unsigned char byte; 139 quadlet_t request[6]; 140 quadlet_t *response; 141 142 if (!cParent) { 143 debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: parent == NULL!\n"); 144 bValid=false; 145 return -1; 146 } 147 148 request[0] = AVC1394_CTYPE_CONTROL | ((iTarget & 0x1F) << 19) | ((iId & 0x07) << 16) 149 | AVC1394_COMMAND_RESERVE | priority; 150 request[1] = 0xFFFFFFFF; 151 request[2] = 0xFFFFFFFF; 152 request[3] = 0xFFFFFFFF; 153 response = cParent->avcExecuteTransaction(request, 4, 4); 154 if (response != NULL) { 155 if((AVC1394_MASK_RESPONSE(response[0]) == AVC1394_RESPONSE_ACCEPTED) || (AVC1394_MASK_RESPONSE(response[0]) == AVC1394_RESPONSE_IMPLEMENTED)) { 156 debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: subunit reserve successfull.\n"); 157 return priority; 158 } else { 159 debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: subunit reserve not successfull.\n"); 160 return -1; 161 } 162 } 163 164 } 165 166 int AvDeviceSubunit::isReserved() { 167 unsigned char byte; 168 quadlet_t request[6]; 169 quadlet_t *response; 170 171 if (!cParent) { 172 debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: parent == NULL!\n"); 173 bValid=false; 174 return -1; // the device isn't usable, not due to reservation, but anyway... 175 } 176 177 request[0] = AVC1394_CTYPE_STATUS | ((iTarget & 0x1F) << 19) | ((iId & 0x07) << 16) 178 | AVC1394_COMMAND_RESERVE | 0xFF; 179 request[1] = 0xFFFFFFFF; 180 request[2] = 0xFFFFFFFF; 181 request[3] = 0xFFFFFFFF; 182 response = cParent->avcExecuteTransaction(request, 4, 4); 183 if (response != NULL) { 184 if((AVC1394_MASK_RESPONSE(response[0]) == AVC1394_RESPONSE_ACCEPTED) || (AVC1394_MASK_RESPONSE(response[0]) == AVC1394_RESPONSE_IMPLEMENTED)) { 185 debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: subunit reserve check successfull.\n"); 186 return (response[0]&0x000000FF); 187 } else { 188 debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: subunit reserve check not successfull.\n"); 189 190 return -1; 191 } 192 } 193 194 } 195 196 int AvDeviceSubunit::unReserve() { 197 unsigned char byte; 198 quadlet_t request[6]; 199 quadlet_t *response; 200 201 if (!cParent) { 202 debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: parent == NULL!\n"); 203 bValid=false; 204 return -1; 205 } 206 207 request[0] = AVC1394_CTYPE_CONTROL | ((iTarget & 0x1F) << 19) | ((iId & 0x07) << 16) 208 | AVC1394_COMMAND_RESERVE | 0x00; 209 request[1] = 0xFFFFFFFF; 210 request[2] = 0xFFFFFFFF; 211 request[3] = 0xFFFFFFFF; 212 response = cParent->avcExecuteTransaction(request, 4, 4); 213 if (response != NULL) { 214 if((AVC1394_MASK_RESPONSE(response[0]) == AVC1394_RESPONSE_ACCEPTED) || (AVC1394_MASK_RESPONSE(response[0]) == AVC1394_RESPONSE_IMPLEMENTED)) { 215 debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: subunit unreserve successfull.\n"); 216 return 0; 217 } else { 218 debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: subunit unreserve not successfull.\n"); 219 return -1; 220 } 221 } 222 223 } 224 225 226 trunk/freebob/src/avdevicesubunit.h
r35 r40 33 33 unsigned char getNbSourcePlugs(); 34 34 35 int reserve(unsigned char priority); 36 int unReserve(); 37 int isReserved(); 38 39 unsigned char getType() {return iTarget;} ; 40 unsigned char getId() {return iId;} ; 41 35 42 virtual void test(); 36 v oid printOutputPlugConnections();43 virtual void printOutputPlugConnections(); 37 44 45 virtual void printSourcePlugConnections(unsigned char plug); 46 38 47 protected: 39 48 bool bValid; trunk/freebob/src/avmusicidentifierdescriptor.cpp
r26 r40 75 75 debugPrint(DEBUG_LEVEL_DESCRIPTOR,"\t -> capabilities: "); 76 76 if ((capability_attributes & AVC1394_SUBUNIT_MUSIC_CAPABILITY_GENERAL)) { 77 debugPrint (DEBUG_LEVEL_DESCRIPTOR," general ");77 debugPrintShort(DEBUG_LEVEL_DESCRIPTOR," general "); 78 78 } 79 79 if ((capability_attributes & AVC1394_SUBUNIT_MUSIC_CAPABILITY_AUDIO)) { 80 debugPrint (DEBUG_LEVEL_DESCRIPTOR," audio ");80 debugPrintShort(DEBUG_LEVEL_DESCRIPTOR," audio "); 81 81 } 82 82 if ((capability_attributes & AVC1394_SUBUNIT_MUSIC_CAPABILITY_MIDI)) { 83 debugPrint (DEBUG_LEVEL_DESCRIPTOR," midi ");83 debugPrintShort(DEBUG_LEVEL_DESCRIPTOR," midi "); 84 84 } 85 85 if ((capability_attributes & AVC1394_SUBUNIT_MUSIC_CAPABILITY_SMPTE)) { 86 debugPrint (DEBUG_LEVEL_DESCRIPTOR," smtpe ");86 debugPrintShort(DEBUG_LEVEL_DESCRIPTOR," smtpe "); 87 87 } 88 88 if ((capability_attributes & AVC1394_SUBUNIT_MUSIC_CAPABILITY_SAMPLECOUNT)) { 89 debugPrint (DEBUG_LEVEL_DESCRIPTOR," samplecount ");89 debugPrintShort(DEBUG_LEVEL_DESCRIPTOR," samplecount "); 90 90 } 91 91 if ((capability_attributes & AVC1394_SUBUNIT_MUSIC_CAPABILITY_AUDIOSYNC)) { 92 debugPrint (DEBUG_LEVEL_DESCRIPTOR," audiosync ");92 debugPrintShort(DEBUG_LEVEL_DESCRIPTOR," audiosync "); 93 93 } 94 debugPrint (DEBUG_LEVEL_DESCRIPTOR,"\n");94 debugPrintShort(DEBUG_LEVEL_DESCRIPTOR,"\n"); 95 95 96 96 // start parsing the optional capability stuff trunk/freebob/src/avmusicpluginfoblock.cpp
r39 r40 54 54 55 55 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvMusicPlugInfoBlock: Creating... length=0x%04X\n",getLength()); 56 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvMusicPlugInfoBlock: Music plug id=0x%0 2X\n",plug_id);56 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvMusicPlugInfoBlock: Music plug id=0x%04X\n",plug_id); 57 57 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvMusicPlugInfoBlock: Plug type=0x%02X\n",plug_type); 58 58 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvMusicPlugInfoBlock: routing support=0x%02X\n",routing_support); trunk/freebob/src/avmusicstatusdescriptor.cpp
r38 r40 32 32 #include "avoutputplugstatusinfoblock.h" 33 33 #include "avroutingstatusinfoblock.h" 34 #include "avpluginfoblock.h" 34 35 35 36 AvMusicStatusDescriptor::AvMusicStatusDescriptor(AvDevice *parent, unsigned char id) : AvDescriptor(parent, AVC1394_SUBUNIT_TYPE_MUSIC | (id << 16),0x80) { … … 121 122 122 123 } 124 125 AvPlugInfoBlock *AvMusicStatusDescriptor::getSourcePlugInfoBlock(unsigned char plug) { 126 if (cRoutingStatusInfoBlock) { 127 return cRoutingStatusInfoBlock->getSourcePlugInfoBlock(plug); 128 } else return NULL; 129 } 130 131 AvPlugInfoBlock *AvMusicStatusDescriptor::getDestinationPlugInfoBlock(unsigned char plug) { 132 if (cRoutingStatusInfoBlock) { 133 return cRoutingStatusInfoBlock->getDestinationPlugInfoBlock(plug); 134 } else return NULL; 135 136 } 123 137 124 138 AvMusicStatusDescriptor::~AvMusicStatusDescriptor() { trunk/freebob/src/avmusicstatusdescriptor.h
r38 r40 34 34 class AvOutputPlugStatusInfoBlock; 35 35 class AvRoutingStatusInfoBlock; 36 class AvPlugInfoBlock; 36 37 37 38 class AvMusicStatusDescriptor : public AvDescriptor { … … 42 43 void printCapabilities(); 43 44 45 AvPlugInfoBlock *getSourcePlugInfoBlock(unsigned char plug); 46 AvPlugInfoBlock *getDestinationPlugInfoBlock(unsigned char plug); 47 44 48 protected: 45 49 AvGeneralMusicInfoBlock *cGeneralMusicInfoBlock; trunk/freebob/src/avpluginfoblock.cpp
r38 r40 113 113 114 114 } 115 116 AvClusterInfoBlock *AvPlugInfoBlock::getCluster(unsigned int idx) { 117 if ((idx < getNbClusters()) && (idx < cClusterInfoBlocks.size())) { 118 return cClusterInfoBlocks.at(idx); 119 } else return NULL; 120 } 115 121 122 void AvPlugInfoBlock::printConnections() { 123 for (unsigned int i=0; i<getNbClusters();i++) { 124 AvClusterInfoBlock *tmpCluster=getCluster(i); 125 if (tmpCluster) { 126 tmpCluster->printName(); 127 } 128 } 129 } trunk/freebob/src/avpluginfoblock.h
r38 r40 47 47 virtual ~AvPlugInfoBlock(); 48 48 49 unsigned char getPlugId() { return readByte(0x06); }; 50 unsigned int getSignalFormat() { return readWord(0x07); }; 51 unsigned char getPlugType() { return readByte(0x09); }; 52 unsigned int getNbClusters() { return readWord(0x0A); }; 53 unsigned int getNbChannels() { return readWord(0x0C); }; 54 55 AvClusterInfoBlock *getCluster(unsigned int idx); 56 57 void printConnections(); 49 58 50 59 protected: trunk/freebob/src/avroutingstatusinfoblock.cpp
r38 r40 40 40 41 41 unsigned int next_block_position=address+0x0A; 42 unsigned int nb_ source_plugs=readByte(6);43 unsigned int nb_ dest_plugs=readByte(7);44 unsigned int nb_music_plugs=readWord( 8);42 unsigned int nb_dest_plugs=readByte(0x06); 43 unsigned int nb_source_plugs=readByte(0x07); 44 unsigned int nb_music_plugs=readWord(0x08); 45 45 AvPlugInfoBlock *tmpAvPlugInfoBlock=NULL; 46 46 AvMusicPlugInfoBlock *tmpAvMusicPlugInfoBlock=NULL; … … 51 51 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvRoutingStatusInfoBlock: Number of music plugs=%d\n",nb_music_plugs); 52 52 53 54 if (nb_source_plugs>0) { 55 for (unsigned int i=0;i<nb_source_plugs;i++) { 56 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvRoutingStatusInfoBlock: source plug=%d\n",i); 53 if (nb_dest_plugs>0) { 54 for (unsigned int i=0;i<nb_dest_plugs;i++) { 55 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvRoutingStatusInfoBlock: destination plug=%d\n",i); 57 56 tmpAvPlugInfoBlock=new AvPlugInfoBlock(parent, next_block_position); 58 57 … … 62 61 63 62 // add to child list 64 c SourcePlugInfoBlocks.push_back(tmpAvPlugInfoBlock);63 cDestinationPlugInfoBlocks.push_back(tmpAvPlugInfoBlock); 65 64 66 65 //tmpAvPlugInfoBlock->printContents(); … … 78 77 } 79 78 } 80 81 if (nb_ dest_plugs>0) {82 for (unsigned int i=0;i<nb_ dest_plugs;i++) {83 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvRoutingStatusInfoBlock: destinationplug=%d\n",i);79 80 if (nb_source_plugs>0) { 81 for (unsigned int i=0;i<nb_source_plugs;i++) { 82 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvRoutingStatusInfoBlock: source plug=%d\n",i); 84 83 tmpAvPlugInfoBlock=new AvPlugInfoBlock(parent, next_block_position); 85 84 … … 89 88 90 89 // add to child list 91 c DestinationPlugInfoBlocks.push_back(tmpAvPlugInfoBlock);90 cSourcePlugInfoBlocks.push_back(tmpAvPlugInfoBlock); 92 91 93 92 //tmpAvPlugInfoBlock->printContents(); … … 153 152 } 154 153 154 AvPlugInfoBlock * AvRoutingStatusInfoBlock::getSourcePlugInfoBlock(unsigned char plug) { 155 vector<AvPlugInfoBlock *>::iterator it; 156 for( it = cSourcePlugInfoBlocks.begin(); it != cSourcePlugInfoBlocks.end(); it++ ) { 157 if((*it) && ((*it)->getPlugId() == plug)) { 158 return *it; 159 } 160 } 161 return NULL; 162 163 } 164 165 AvPlugInfoBlock * AvRoutingStatusInfoBlock::getDestinationPlugInfoBlock(unsigned char plug) { 166 vector<AvPlugInfoBlock *>::iterator it; 167 for( it = cDestinationPlugInfoBlocks.begin(); it != cDestinationPlugInfoBlocks.end(); it++ ) { 168 if((*it) && ((*it)->getPlugId() == plug)) { 169 return *it; 170 } 171 } 172 return NULL; 173 174 } trunk/freebob/src/avroutingstatusinfoblock.h
r38 r40 43 43 virtual ~AvRoutingStatusInfoBlock(); 44 44 45 unsigned char getNbDestinationPlugs() {return readByte(0x06);}; 46 unsigned char getNbSourcePlugs() {return readByte(0x07);}; 47 unsigned int getNbMusicPlugs() {return readWord(0x08);}; 48 49 AvPlugInfoBlock *getSourcePlugInfoBlock(unsigned char plug); 50 AvPlugInfoBlock *getDestinationPlugInfoBlock(unsigned char plug); 45 51 46 52 protected: trunk/freebob/src/debugmodule.h
r38 r40 25 25 #include "ieee1394service.h" 26 26 27 #define DEBUG_LEVEL_INFO (1<<0) 28 #define DEBUG_LEVEL_DEVICE (1<<1) 29 #define DEBUG_LEVEL_SUBUNIT (1<<2) 30 #define DEBUG_LEVEL_DESCRIPTOR (1<<3) 31 #define DEBUG_LEVEL_INFOBLOCK (1<<4) 27 // global debug control. undefine to disable debug output 28 #define DEBUG 32 29 33 #define DEBUG_LEVEL_TRANSFERS (1<<5) 30 // debug print control flags 31 #define DEBUG_LEVEL_INFO (1<<0) 32 #define DEBUG_LEVEL_DEVICE (1<<1) 33 #define DEBUG_LEVEL_SUBUNIT (1<<2) 34 #define DEBUG_LEVEL_DESCRIPTOR (1<<3) 35 #define DEBUG_LEVEL_INFOBLOCK (1<<4) 36 #define DEBUG_LEVEL_TRANSFERS (1<<5) 34 37 35 #define DEBUG_LEVEL_ALL (DEBUG_LEVEL_INFO | DEBUG_LEVEL_DEVICE | DEBUG_LEVEL_SUBUNIT | DEBUG_LEVEL_DESCRIPTOR | DEBUG_LEVEL_INFOBLOCK | DEBUG_LEVEL_TRANSFERS ) 36 38 // convenience defines 39 #define DEBUG_LEVEL_ALL (DEBUG_LEVEL_INFO | DEBUG_LEVEL_DEVICE | DEBUG_LEVEL_SUBUNIT | DEBUG_LEVEL_DESCRIPTOR | DEBUG_LEVEL_INFOBLOCK | DEBUG_LEVEL_TRANSFERS ) 40 #define DEBUG_LEVEL_LOW (DEBUG_LEVEL_INFO | DEBUG_LEVEL_DEVICE) 37 41 #define DEBUG_LEVEL_MODERATE (DEBUG_LEVEL_INFO | DEBUG_LEVEL_DEVICE | DEBUG_LEVEL_SUBUNIT) 38 42 #define DEBUG_LEVEL_HIGH (DEBUG_LEVEL_MODERATE | DEBUG_LEVEL_DESCRIPTOR | DEBUG_LEVEL_INFOBLOCK) 39 43 40 #define DEBUG_LEVEL DEBUG_LEVEL_HIGH 41 42 #define DEBUG 44 // control the type of output to be generated by the debug macro's 45 // make sure that only one of them is defined. comment out the others. 46 // note: the HTML option is only usefull if you enclose the output in <pre>....</pre> tags 47 #define DEBUG_OUTPUT_ANSICOLORED 48 //#define DEBUG_OUTPUT_STANDARD 49 //#define DEBUG_OUTPUT_HTML 43 50 44 51 #ifdef DEBUG 45 #define debugError(format, args...) fprintf( stderr, "%s %s %d: " format, __FILE__, __FUNCTION__, __LINE__, ##args ) 46 // #define debugPrint(Level, format, args...) if(DEBUG_LEVEL & Level) { int idebug=Level; while(idebug) {printf(" "); idebug=idebug>>1;} printf( format, ##args ); } 47 #define debugPrint(Level, format, args...) if(DEBUG_LEVEL & Level) printf("DEBUG %s %s %d :" format, __FILE__, __FUNCTION__, __LINE__, ##args ); 52 // this allows for debug level control inside the code (e.g. enable transfer logging for some specific code block) 53 static int DEBUG_LEVEL=DEBUG_LEVEL_HIGH; 54 #define setDebugLevel(x) (DEBUG_LEVEL=x) 55 56 #ifdef DEBUG_OUTPUT_ANSICOLORED 48 57 58 #define debugError(format, args...) fprintf( stderr, "\033[37m\033[41m" "ERROR: %s %s %d: " format "\033[0m\033[49m ", __FILE__, __FUNCTION__, __LINE__, ##args ) 59 60 #define debugPrint(Level, format, args...) if(DEBUG_LEVEL & Level) printf("\033[37m" "DEBUG %s %s %d:" "%s " format "\033[0m", __FILE__, __FUNCTION__, __LINE__, getLevelColor(Level), ##args ); 61 #define debugPrintShort(Level, format, args...) if(DEBUG_LEVEL & Level) printf("%s" format "\033[0m",getLevelColor(Level), ##args ); 62 63 inline char *getLevelColor(unsigned int Level) { 64 switch(Level) { 65 case DEBUG_LEVEL_INFO: 66 return "\033[31m"; 67 break; 68 case DEBUG_LEVEL_DEVICE: 69 return "\033[32m"; 70 break; 71 case DEBUG_LEVEL_SUBUNIT: 72 return "\033[33m"; 73 break; 74 case DEBUG_LEVEL_DESCRIPTOR: 75 return "\033[34m"; // blue 76 break; 77 case DEBUG_LEVEL_INFOBLOCK: // purple 78 return "\033[35m"; 79 break; 80 case DEBUG_LEVEL_TRANSFERS: 81 return "\033[36m"; 82 break; 83 default: 84 return "\033[0m"; 85 break; 86 87 } 88 } 89 90 #endif 91 92 #ifdef DEBUG_OUTPUT_HTML 93 #define debugError(format, args...) fprintf( stdout, "<P style='background: red;'><FONT color='white'>" "ERROR: %s %s %d: " format "</FONT></P>", __FILE__, __FUNCTION__, __LINE__, ##args ) 94 #define debugPrint(Level, format, args...) if(DEBUG_LEVEL & Level) printf("<FONT color='darkGray'>" "DEBUG %s %s %d:" "%s " format "</FONT></FONT>", __FILE__, __FUNCTION__, __LINE__, getLevelColor(Level), ##args ); 95 #define debugPrintShort(Level, format, args...) if(DEBUG_LEVEL & Level) printf("%s" format "</FONT>",getLevelColor(Level), ##args ); 96 inline char *getLevelColor(unsigned int Level) { 97 switch(Level) { 98 case DEBUG_LEVEL_INFO: 99 return "<FONT color='darkRed'>"; 100 break; 101 case DEBUG_LEVEL_DEVICE: 102 return "<FONT color='darkGreen'>"; 103 break; 104 case DEBUG_LEVEL_SUBUNIT: 105 return "<FONT color='darkYellow'>"; 106 break; 107 case DEBUG_LEVEL_DESCRIPTOR: 108 return "<FONT color='darkBlue'>"; // blue 109 break; 110 case DEBUG_LEVEL_INFOBLOCK: // purple 111 return "<FONT color='darkMagenta'>"; 112 break; 113 case DEBUG_LEVEL_TRANSFERS: 114 return "<FONT color='darkCyan'>"; 115 break; 116 default: 117 return "<FONT color='black'>"; 118 break; 119 120 } 121 } 122 #endif 123 124 #ifdef DEBUG_OUTPUT_STANDARD 125 #define debugError(format, args...) fprintf( stderr, "ERROR: %s %s %d: " format, __FILE__, __FUNCTION__, __LINE__, ##args ) 126 #define debugPrint(Level, format, args...) if(DEBUG_LEVEL & Level) printf("DEBUG %s %s %d :" format, __FILE__, __FUNCTION__, __LINE__, ##args ); 127 #define debugPrintShort(Level, format, args...) if(DEBUG_LEVEL & Level) printf(format, ##args ); 128 #endif 129 49 130 #else 131 #define DEBUG_LEVEL 132 #define setDebugLevel(x) 50 133 #define debugError(format, args...) 51 134 #define debugPrint(Level, format, args...) trunk/freebob/src/ieee1394service.cpp
r38 r40 22 22 #include <libavc1394/avc1394.h> 23 23 #include <libavc1394/avc1394_vcr.h> 24 #include <libiec61883/iec61883.h> 25 26 24 27 #include "ieee1394service.h" 25 28 #include "debugmodule.h" … … 161 164 test->Initialize(); 162 165 if (test->isInitialised()) { 163 #if 0 // the commented out code enables some tests of the several decriptor/infoblock classes 164 debugPrint (DEBUG_LEVEL_INFO, " Init successfull...\n"); 165 debugPrint (DEBUG_LEVEL_INFO, " Trying to create an AvDescriptor...\n"); 166 AvDescriptor *testdesc=new AvDescriptor(test,AVC1394_SUBUNIT_TYPE_MUSIC | AVC1394_SUBUNIT_ID_0,0x00); 167 debugPrint (DEBUG_LEVEL_INFO, " Created...\n"); 168 debugPrint (DEBUG_LEVEL_INFO, " Opening...\n"); 169 testdesc->OpenReadOnly(); 170 171 debugPrint (DEBUG_LEVEL_INFO, " Loading...\n"); 172 173 testdesc->Load(); 174 175 debugPrint (DEBUG_LEVEL_INFO, " Trying to create another AvDescriptor...\n"); 176 AvDescriptor *testdesc2=new AvDescriptor(test,AVC1394_SUBUNIT_TYPE_MUSIC | AVC1394_SUBUNIT_ID_0,0x80); 177 debugPrint (DEBUG_LEVEL_INFO, " Created...\n"); 178 debugPrint (DEBUG_LEVEL_INFO, " Opening...\n"); 179 testdesc2->OpenReadOnly(); 180 181 debugPrint (DEBUG_LEVEL_INFO, " Loading...\n"); 182 183 testdesc2->Load(); 184 185 unsigned char *buff=new unsigned char[testdesc->getLength()]; 186 187 testdesc->readBuffer(0,testdesc->getLength(),buff); 188 debugPrint (DEBUG_LEVEL_INFO, " AvDescriptor 1 Contents:\n"); 189 190 hexDump(buff,testdesc->getLength()); 191 192 delete buff; 193 194 buff=new unsigned char[testdesc2->getLength()]; 195 196 testdesc2->readBuffer(0,testdesc2->getLength(),buff); 197 198 debugPrint (DEBUG_LEVEL_INFO, " AvDescriptor 2 Contents:\n"); 199 hexDump(buff,testdesc2->getLength()); 200 delete buff; 201 202 203 debugPrint (DEBUG_LEVEL_INFO, " Closing AvDescriptors...\n"); 204 205 testdesc->Close(); 206 testdesc2->Close(); 207 208 debugPrint (DEBUG_LEVEL_INFO, " Deleting AvDescriptors...\n"); 209 210 delete testdesc; 211 delete testdesc2; 212 213 // test the AvMusicIdentifierDescriptor 214 debugPrint (DEBUG_LEVEL_INFO, " Trying to create an AvMusicIdentifierDescriptor...\n"); 215 AvMusicIdentifierDescriptor *testdesc_mid=new AvMusicIdentifierDescriptor(test,0x00); 216 debugPrint (DEBUG_LEVEL_INFO, " Created...\n"); 217 testdesc_mid->printCapabilities(); 218 debugPrint (DEBUG_LEVEL_INFO, " Deleting AvMusicIdentifierDescriptor...\n"); 219 delete testdesc_mid; 220 #endif 221 222 // test the AvMusicStatusDescriptor 223 debugPrint (DEBUG_LEVEL_INFO, " Trying to create an AvMusicStatusDescriptor...\n"); 224 AvMusicStatusDescriptor *testdesc_mid2=new AvMusicStatusDescriptor(test,0x00); 225 debugPrint (DEBUG_LEVEL_INFO, " Created...\n"); 226 testdesc_mid2->printCapabilities(); 227 #if 0 228 // test the AvInfoBlock 229 debugPrint (DEBUG_LEVEL_INFO, " Trying to create an AvInfoBlock...\n"); 230 231 AvInfoBlock *testblock1=new AvInfoBlock(testdesc_mid2,0); 232 debugPrint (DEBUG_LEVEL_INFO, " Length: 0x%04X (%d) Type: 0x%04X\n",testblock1->getLength(),testblock1->getLength(),testblock1->getType()); 233 234 debugPrint (DEBUG_LEVEL_INFO, " Trying to fetch next block...\n"); 235 // PP: might be better to have something like AvInfoBlock::moveToNextBlock(); 236 AvInfoBlock *testblock2=new AvInfoBlock(testdesc_mid2,2+testblock1->getLength()); 237 238 debugPrint (DEBUG_LEVEL_INFO, " Length: 0x%04X (%d) Type: 0x%04X\n",testblock2->getLength(),testblock2->getLength(),testblock2->getType()); 166 unsigned char fmt; 167 quadlet_t fdf; 168 test->getInputPlugSignalFormat(0,&fmt,&fdf); 169 debugPrint (DEBUG_LEVEL_INFO, " fmt=%02X fdf=%08X\n",fmt,fdf); 170 test->getInputPlugSignalFormat(1,&fmt,&fdf); 171 debugPrint (DEBUG_LEVEL_INFO, " fmt=%02X fdf=%08X\n",fmt,fdf); 172 test->getOutputPlugSignalFormat(0,&fmt,&fdf); 173 debugPrint (DEBUG_LEVEL_INFO, " fmt=%02X fdf=%08X\n",fmt,fdf); 174 test->getOutputPlugSignalFormat(1,&fmt,&fdf); 175 debugPrint (DEBUG_LEVEL_INFO, " fmt=%02X fdf=%08X\n",fmt,fdf); 176 test->printConnections(); 177 } 239 178 240 // test the general status info block 241 debugPrint (DEBUG_LEVEL_INFO, " Trying to create an AvGeneralMusicStatusInfoBlock...\n"); 242 AvGeneralMusicInfoBlock *testblock3=new AvGeneralMusicInfoBlock(testdesc_mid2,0); 243 244 // PP: the next tests could fail because of the difference in hardware. 245 // these classes are intended to be used in the parser. I use hardcoded addresses in the test code, 246 // instead of derived addresses based on the parent descriptors. 247 // this is only intended to debug the base classes before using them in the parser. 248 249 250 // this one should be valid (on my config) 251 debugPrint (DEBUG_LEVEL_INFO, " isValid? %s\n",(testblock3->isValid()?"yes":"no")); 252 debugPrint (DEBUG_LEVEL_INFO, " canTransmitBlocking? %s\n",(testblock3->canTransmitBlocking()?"yes":"no")); 253 debugPrint (DEBUG_LEVEL_INFO, " canTransmitNonblocking? %s\n",(testblock3->canTransmitNonblocking()?"yes":"no")); 254 debugPrint (DEBUG_LEVEL_INFO, " canReceiveBlocking? %s\n",(testblock3->canReceiveBlocking()?"yes":"no")); 255 debugPrint (DEBUG_LEVEL_INFO, " canReceiveNonblocking? %s\n",(testblock3->canReceiveNonblocking()?"yes":"no")); 256 257 delete testblock3; 258 // this one shouldn't be valid 259 testblock3=new AvGeneralMusicInfoBlock(testdesc_mid2,2+testblock1->getLength()); 260 debugPrint (DEBUG_LEVEL_INFO, " isValid? %s\n",(testblock3->isValid()?"yes":"no")); 261 debugPrint (DEBUG_LEVEL_INFO, " canTransmitBlocking? %s\n",(testblock3->canTransmitBlocking()?"yes":"no")); 262 debugPrint (DEBUG_LEVEL_INFO, " canTransmitNonblocking? %s\n",(testblock3->canTransmitNonblocking()?"yes":"no")); 263 debugPrint (DEBUG_LEVEL_INFO, " canReceiveBlocking? %s\n",(testblock3->canReceiveBlocking()?"yes":"no")); 264 debugPrint (DEBUG_LEVEL_INFO, " canReceiveNonblocking? %s\n",(testblock3->canReceiveNonblocking()?"yes":"no")); 265 266 debugPrint (DEBUG_LEVEL_INFO, " Trying to create an AvAudioInfoBlock...\n"); 267 268 AvAudioInfoBlock *testblock4=new AvAudioInfoBlock(testdesc_mid2,0x01A); 269 debugPrint (DEBUG_LEVEL_INFO, " isValid? %s\n",(testblock4->isValid()?"yes":"no")); 270 debugPrint (DEBUG_LEVEL_INFO, " Length? 0x%04X (%d)\n",testblock4->getLength(),testblock4->getLength()); 271 debugPrint (DEBUG_LEVEL_INFO, " streams: %d\n",testblock4->getNbStreams()); 272 debugPrint (DEBUG_LEVEL_INFO, " Name: %s\n",testblock4->getName()); 273 274 debugPrint (DEBUG_LEVEL_INFO, " Trying to create an AvMidiInfoBlock...\n"); 275 276 AvMidiInfoBlock *testblock5=new AvMidiInfoBlock(testdesc_mid2,0x099); 277 debugPrint (DEBUG_LEVEL_INFO, " isValid? %s\n",(testblock5->isValid()?"yes":"no")); 278 debugPrint (DEBUG_LEVEL_INFO, " Length? 0x%04X (%d)\n",testblock5->getLength(),testblock5->getLength()); 279 unsigned int nb_midi_streams=testblock5->getNbStreams(); 280 debugPrint (DEBUG_LEVEL_INFO, " streams: %d\n",nb_midi_streams); 281 for (unsigned int i=0;i<nb_midi_streams;i++) { 282 debugPrint (DEBUG_LEVEL_INFO, " stream %d name: %s\n",i,testblock5->getName(i)); 283 } 284 285 debugPrint (DEBUG_LEVEL_INFO, " Trying to create an AvAudioSyncInfoBlock...\n"); 286 AvAudioSyncInfoBlock *testblock6=new AvAudioSyncInfoBlock(testdesc_mid2,0x0262); 287 debugPrint (DEBUG_LEVEL_INFO, " isValid? %s\n",(testblock6->isValid()?"yes":"no")); 288 debugPrint (DEBUG_LEVEL_INFO, " canSyncBus? %s\n",(testblock6->canSyncBus()?"yes":"no")); 289 debugPrint (DEBUG_LEVEL_INFO, " canSyncExternal? %s\n",(testblock6->canSyncExternal()?"yes":"no")); 290 291 292 debugPrint (DEBUG_LEVEL_INFO, " Deleting AvInfoBlocks...\n"); 293 294 delete testblock1; 295 delete testblock2; 296 delete testblock3; 297 delete testblock4; 298 delete testblock5; 299 delete testblock6; 300 301 // now try to parse a full source plug entry 302 debugPrint (DEBUG_LEVEL_INFO, " Trying to create an AvSourcePlugInfoBlock...\n"); 303 AvSourcePlugInfoBlock *testblock7=new AvSourcePlugInfoBlock(testdesc_mid2,0x13); 304 305 debugPrint (DEBUG_LEVEL_INFO, " Deleting AvSourcePlugInfoBlock...\n"); 306 307 delete testblock7; 308 309 // now try to parse the full music output plug status infoblock 310 debugPrint (DEBUG_LEVEL_INFO, " Trying to create an AvOutputPlugStatusInfoBlock...\n"); 311 AvOutputPlugStatusInfoBlock *testblock8=new AvOutputPlugStatusInfoBlock(testdesc_mid2,0x0C); 312 313 debugPrint (DEBUG_LEVEL_INFO, " Deleting AvOutputPlugStatusInfoBlock...\n"); 314 315 delete testblock8; 316 debugPrint (DEBUG_LEVEL_INFO, " Deleting AvMusicStatusDescriptor...\n"); 317 #endif 318 delete testdesc_mid2; 319 } 320 debugPrint (DEBUG_LEVEL_INFO, " Deleting AvDevice...\n"); 179 debugPrint (DEBUG_LEVEL_INFO, " Deleting AvDevice...\n"); 321 180 delete test; 322 181