Changeset 43
- Timestamp:
- 01/09/05 14:57:49 (18 years ago)
- Files:
-
- trunk/freebob/configure.ac (modified) (1 diff)
- trunk/freebob/src/avaudioinfoblock.cpp (modified) (3 diffs)
- trunk/freebob/src/avaudioinfoblock.h (modified) (2 diffs)
- trunk/freebob/src/avaudiosyncinfoblock.cpp (modified) (4 diffs)
- trunk/freebob/src/avaudiosyncinfoblock.h (modified) (2 diffs)
- trunk/freebob/src/avclusterinfoblock.cpp (modified) (10 diffs)
- trunk/freebob/src/avclusterinfoblock.h (modified) (2 diffs)
- trunk/freebob/src/avdescriptor.cpp (modified) (14 diffs)
- trunk/freebob/src/avdescriptor.h (modified) (3 diffs)
- trunk/freebob/src/avdevice.cpp (modified) (9 diffs)
- trunk/freebob/src/avdevice.h (modified) (5 diffs)
- trunk/freebob/src/avdevicemusicsubunit.cpp (modified) (12 diffs)
- trunk/freebob/src/avdevicemusicsubunit.h (modified) (3 diffs)
- trunk/freebob/src/avdevicepool.cpp (modified) (1 diff)
- trunk/freebob/src/avdevicesubunit.cpp (modified) (3 diffs)
- trunk/freebob/src/avdevicesubunit.h (modified) (3 diffs)
- trunk/freebob/src/avmidiinfoblock.cpp (modified) (5 diffs)
- trunk/freebob/src/avmidiinfoblock.h (modified) (3 diffs)
- trunk/freebob/src/avmusicpluginfoblock.cpp (modified) (6 diffs)
- trunk/freebob/src/avmusicpluginfoblock.h (modified) (2 diffs)
- trunk/freebob/src/avnameinfoblock.cpp (modified) (5 diffs)
- trunk/freebob/src/avnameinfoblock.h (modified) (2 diffs)
- trunk/freebob/src/avoutputplugstatusinfoblock.cpp (modified) (5 diffs)
- trunk/freebob/src/avoutputplugstatusinfoblock.h (modified) (2 diffs)
- trunk/freebob/src/avpluginfoblock.cpp (modified) (9 diffs)
- trunk/freebob/src/avpluginfoblock.h (modified) (2 diffs)
- trunk/freebob/src/avroutingstatusinfoblock.cpp (modified) (7 diffs)
- trunk/freebob/src/avroutingstatusinfoblock.h (modified) (2 diffs)
- trunk/freebob/src/avsourcepluginfoblock.cpp (modified) (7 diffs)
- trunk/freebob/src/avsourcepluginfoblock.h (modified) (2 diffs)
- trunk/freebob/src/cmhandler.cpp (modified) (2 diffs)
- trunk/freebob/src/cmhandler.h (modified) (2 diffs)
- trunk/freebob/src/debugmodule.cpp (modified) (2 diffs)
- trunk/freebob/src/debugmodule.h (modified) (3 diffs)
- trunk/freebob/src/freebob.h (modified) (1 diff)
- trunk/freebob/src/ieee1394service.cpp (modified) (6 diffs)
- trunk/freebob/src/ieee1394service.h (modified) (2 diffs)
- trunk/freebob/src/streamprocess.cpp (modified) (1 diff)
- trunk/freebob/src/streamprocess.h (modified) (2 diffs)
- trunk/freebob/src/workerthread.cpp (modified) (5 diffs)
- trunk/freebob/src/workerthread.h (modified) (3 diffs)
- trunk/freebob/tests/byte_order.c (added)
- trunk/freebob/tests/detect_avc_unit.c (modified) (1 diff)
- trunk/freebob/tests/test_debug_module.cpp (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/freebob/configure.ac
r16 r43 75 75 AC_C_CONST 76 76 AC_C_VOLATILE 77 CFLAGS="$CFLAGS -Wall "78 CXXFLAGS="$CXXFLAGS -Wall "77 CFLAGS="$CFLAGS -Wall -DDEBUG" # XXX DEBUG should not always be set 78 CXXFLAGS="$CXXFLAGS -Wall -DDEBUG" # XXX DEBUG should not always be set 79 79 80 80 AC_SUBST([CFLAGS]) trunk/freebob/src/avaudioinfoblock.cpp
r26 r43 1 1 /* avaudioinfoblock.cpp 2 * Copyright (C) 2004 by Pieter Palmers2 * Copyright (C) 2004,05 by Pieter Palmers 3 3 * 4 4 * This file is part of FreeBob. … … 19 19 */ 20 20 21 22 21 #include <string.h> 23 22 #include <errno.h> 24 23 #include <libavc1394/avc1394.h> 25 24 #include <libavc1394/avc1394_vcr.h> 26 #include "debugmodule.h"27 25 28 26 #include "avdescriptor.h" … … 32 30 33 31 AvAudioInfoBlock::AvAudioInfoBlock(AvDescriptor *parent, int address) : AvInfoBlock(parent,address) { 32 setDebugLevel( DEBUG_LEVEL_ALL ); 34 33 // do some more valid checks 35 34 if (getType() != 0x8103) { 36 35 bValid=false; 37 } 36 } 38 37 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvAudioInfoBlock: Creating... length=0x%04X\n",getLength()); 39 38 40 39 // PP: I assume that there is only an audio block, no optional blocks. 41 40 cNameInfoBlock=new AvNameInfoBlock(parent, address+7); 42 41 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvAudioInfoBlock: Created\n"); 43 42 44 43 } 45 44 trunk/freebob/src/avaudioinfoblock.h
r31 r43 1 1 /* avaudioinfoblock.h 2 * Copyright (C) 2004 by Pieter Palmers2 * Copyright (C) 2004,05 by Pieter Palmers 3 3 * 4 4 * This file is part of FreeBob. … … 42 42 protected: 43 43 AvNameInfoBlock *cNameInfoBlock; 44 private:45 44 45 DECLARE_DEBUG_MODULE; 46 46 }; 47 47 trunk/freebob/src/avaudiosyncinfoblock.cpp
r26 r43 1 1 /* avaudiosyncinfoblock.cpp 2 * Copyright (C) 2004 by Pieter Palmers2 * Copyright (C) 2004,05 by Pieter Palmers 3 3 * 4 4 * This file is part of FreeBob. … … 24 24 #include <libavc1394/avc1394.h> 25 25 #include <libavc1394/avc1394_vcr.h> 26 #include "debugmodule.h"27 26 28 27 #include "avdescriptor.h" … … 31 30 32 31 AvAudioSyncInfoBlock::AvAudioSyncInfoBlock(AvDescriptor *parent, int address) : AvInfoBlock(parent,address) { 32 setDebugLevel( DEBUG_LEVEL_ALL ); 33 33 // do some more valid checks 34 34 if (getType() != 0x8107) { … … 57 57 unsigned char capability=readByte(6); 58 58 return (capability & AVC1394_SUBUNIT_MUSIC_CAPABILITY_AUDIOSYNC_EXTERNAL); 59 59 60 60 } else { 61 61 return false; trunk/freebob/src/avaudiosyncinfoblock.h
r31 r43 1 1 /* avaudiosyncinfoblock.h 2 * Copyright (C) 2004 by Pieter Palmers2 * Copyright (C) 2004,05 by Pieter Palmers 3 3 * 4 4 * This file is part of FreeBob. … … 40 40 41 41 protected: 42 43 private: 42 DECLARE_DEBUG_MODULE; 44 43 45 44 }; trunk/freebob/src/avclusterinfoblock.cpp
r40 r43 1 1 /* avclusterinfoblock.cpp 2 * Copyright (C) 2004 by Pieter Palmers2 * Copyright (C) 2004,05 by Pieter Palmers 3 3 * 4 4 * This file is part of FreeBob. … … 24 24 #include <libavc1394/avc1394.h> 25 25 #include <libavc1394/avc1394_vcr.h> 26 #include "debugmodule.h"27 26 28 27 #include "avdescriptor.h" … … 32 31 33 32 AvClusterInfoBlock::AvClusterInfoBlock(AvDescriptor *parent, int address) : AvInfoBlock(parent,address) { 33 setDebugLevel( DEBUG_LEVEL_ALL ); 34 34 // do some more valid checks 35 35 if (getType() != 0x810A) { 36 36 bValid=false; 37 37 } 38 38 39 39 unsigned int next_block_position=address+0x06+readWord(0x04); 40 40 41 41 unsigned int stream_format=readByte(0x06); 42 42 unsigned int port_type=readByte(0x07); … … 52 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 55 55 } 56 56 57 57 if(next_block_position<address+getLength()) { 58 58 // parse the optional name block … … 60 60 if (tmpNameInfoBlock && (tmpNameInfoBlock->isValid())) { 61 61 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvClusterInfoBlock: Name info=%s\n",tmpNameInfoBlock->getName()); 62 62 63 63 } else { 64 64 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvClusterInfoBlock: invalid extra name block present\n"); … … 70 70 } 71 71 72 72 73 73 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvClusterInfoBlock: Created\n"); 74 74 75 75 } 76 76 … … 81 81 82 82 void AvClusterInfoBlock::printSignalInfo(unsigned char idx) { 83 if ( idx<getNbSignals() && (0x09+idx*4<getLength())) {83 if ( ( idx < getNbSignals() ) && ( ( unsigned int )( 0x09+idx*4 ) < getLength() ) ) { 84 84 unsigned int plug_info=readWord(0x09+idx*4); 85 85 unsigned char stream_position=readByte(0x09+idx*4+2); … … 88 88 } else { 89 89 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvClusterInfoBlock: Signal %d not present!\n",idx); 90 90 91 91 } 92 92 } … … 94 94 void AvClusterInfoBlock::printName() { 95 95 unsigned int next_block_position=iBaseAddress+0x06+readWord(0x04); 96 96 97 97 if(next_block_position<iBaseAddress+getLength()) { 98 98 // parse the optional name block … … 100 100 if (tmpNameInfoBlock && (tmpNameInfoBlock->isValid())) { 101 101 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvClusterInfoBlock: Name: %s\n",tmpNameInfoBlock->getName()); 102 102 103 103 } else { 104 104 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvClusterInfoBlock: no name block present\n"); trunk/freebob/src/avclusterinfoblock.h
r40 r43 1 1 /* avclusterinfoblock.h 2 * Copyright (C) 2004 by Pieter Palmers2 * Copyright (C) 2004,05 by Pieter Palmers 3 3 * 4 4 * This file is part of FreeBob. … … 52 52 53 53 protected: 54 55 private: 54 DECLARE_DEBUG_MODULE; 56 55 57 56 }; trunk/freebob/src/avdescriptor.cpp
r40 r43 1 1 /* avdescriptor.cpp 2 * Copyright (C) 2004 by Pieter Palmers2 * Copyright (C) 2004,05 by Pieter Palmers 3 3 * 4 4 * This file is part of FreeBob. … … 24 24 #include <libavc1394/avc1394.h> 25 25 #include <libavc1394/avc1394_vcr.h> 26 #include "debugmodule.h" 27 28 /* should probably be attached to an AVC device, 26 27 /* should probably be attached to an AVC device, 29 28 a descriptor is attached to an AVC device anyway. 30 29 31 30 a descriptor also always has a type 32 31 */ 33 32 34 33 AvDescriptor::AvDescriptor(AvDevice *parent, quadlet_t target, unsigned int type) 34 : cParent( parent ) 35 , iType( type ) 36 , aContents( 0 ) 37 , bLoaded( false ) 38 , bOpen( false ) 39 , bValid( false ) // don't know yet what I'm going to do with this in the generic descriptor 40 , iAccessType( 0 ) 41 , iLength( 0 ) 42 , qTarget( target ) 35 43 { 36 cParent=parent; 37 iType=type; 38 qTarget=target; 39 aContents=NULL; 40 bLoaded=false; 41 iLength=0; 42 bOpen=false; 43 iAccessType=0; 44 bValid=false; // don't know yet what I'm going to do with this in the generic descriptor 44 setDebugLevel( DEBUG_LEVEL_ALL ); 45 45 } 46 46 … … 58 58 void AvDescriptor::OpenReadOnly() { 59 59 quadlet_t *response; 60 quadlet_t request[3]; 61 60 quadlet_t request[3]; 61 62 62 if (!cParent) { 63 63 return; 64 64 } 65 65 66 66 if(isOpen()) { 67 67 Close(); 68 68 } 69 69 70 70 request[0] = AVC1394_CTYPE_CONTROL | qTarget 71 71 | AVC1394_COMMAND_OPEN_DESCRIPTOR | (iType & 0xFF); 72 72 request[1] = 0x01FFFFFF; 73 73 //fprintf(stderr, "Opening descriptor\n"); 74 74 75 75 response = cParent->avcExecuteTransaction(request, 2, 2); 76 76 77 77 if ((response[0]&0xFF000000)==AVC1394_RESPONSE_ACCEPTED) { 78 78 bOpen=true; … … 86 86 void AvDescriptor::OpenReadWrite() { 87 87 quadlet_t *response; 88 quadlet_t request[3]; 89 88 quadlet_t request[3]; 89 90 90 if (!cParent) { 91 91 return; 92 92 } 93 93 94 94 if(isOpen()) { 95 95 Close(); 96 96 } 97 97 98 98 request[0] = AVC1394_CTYPE_CONTROL | qTarget 99 99 | AVC1394_COMMAND_OPEN_DESCRIPTOR | (iType & 0xFF); 100 100 request[1] = 0x03FFFFFF; 101 101 //fprintf(stderr, "Opening descriptor\n"); 102 102 103 103 response = cParent->avcExecuteTransaction(request, 2, 2); 104 104 105 105 if ((response[0]&0xFF000000)==AVC1394_RESPONSE_ACCEPTED) { 106 106 bOpen=true; … … 122 122 void AvDescriptor::Close() { 123 123 quadlet_t *response; 124 quadlet_t request[3]; 124 quadlet_t request[3]; 125 125 if (!cParent) { 126 126 return; 127 } 127 } 128 128 request[0] = AVC1394_CTYPE_CONTROL | qTarget 129 129 | AVC1394_COMMAND_OPEN_DESCRIPTOR | (iType & 0xFF); 130 130 request[1] = 0x00FFFFFF; 131 131 //fprintf(stderr, "Opening descriptor\n"); 132 132 133 133 response = cParent->avcExecuteTransaction(request, 2, 2); 134 134 135 135 if ((response[0]&0xFF000000)==AVC1394_RESPONSE_ACCEPTED) { // should always be accepted according to spec 136 136 bOpen=false; … … 144 144 void AvDescriptor::Load() { 145 145 quadlet_t *response; 146 quadlet_t request[3]; 146 quadlet_t request[3]; 147 147 unsigned int i=0; 148 148 unsigned int bytes_read=0; … … 150 150 unsigned char read_result_status; 151 151 unsigned int data_length_read; 152 152 153 153 if (!cParent) { 154 154 return; 155 155 } 156 156 157 157 /* First determine the descriptor length */ 158 158 request[0] = AVC1394_CTYPE_CONTROL | qTarget … … 163 163 164 164 iLength=response[2] & 0xFFFF; 165 166 debugPrint(DEBUG_LEVEL_DESCRIPTOR,"Descriptor length=0x%04X %d ",iLength,iLength); 165 166 debugPrint(DEBUG_LEVEL_DESCRIPTOR,"Descriptor length=0x%04X %d ",iLength,iLength); 167 167 168 168 // now get the rest of the descriptor 169 169 aContents=new unsigned char[iLength]; 170 171 /* there is a gap in the read data, because of the two bytes 170 171 /* there is a gap in the read data, because of the two bytes 172 172 * that are before the third quadlet (why did 1394TA do that?) 173 * 173 * 174 174 * proposed solution: 175 175 * 1) the first read is OK, because the length of the descriptor is in these two bytes, 176 176 * so execute a read from address 0 with length=iLength 177 177 * 2) process the bytes starting from response[3] 178 * 3) the next reads should start from the end of the previous read minus 2. this way we 179 * can discard these two problem bytes, because they are already read in the previous 178 * 3) the next reads should start from the end of the previous read minus 2. this way we 179 * can discard these two problem bytes, because they are already read in the previous 180 180 * run. 181 181 */ 182 182 183 183 // first read 184 184 if(bytes_read<iLength) { 185 debugPrintShort(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 … … 191 191 request[1] = 0xFFFF0000 | (iLength)&0xFFFF; 192 192 request[2] = ((0) << 16) |0x0000FFFF; 193 193 194 194 response = cParent->avcExecuteTransaction(request, 3, 3); 195 195 data_length_read=(response[1]&0xFFFF); 196 196 read_result_status=((response[1]>>24)&0xFF); 197 197 198 198 databuffer=(unsigned char *)(response+3); 199 199 200 200 // the buffer starting at databuffer is two bytes smaller that the amount of bytes read 201 201 for (i=0;(i<data_length_read-2) && (bytes_read < iLength);i++) { … … 203 203 bytes_read++; 204 204 } 205 206 } 207 205 206 } 207 208 208 // now do the remaining reads 209 209 while(bytes_read<iLength) { 210 debugPrintShort(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 … … 216 216 request[1] = 0xFFFF0000 | (iLength-bytes_read+2)&0xFFFF; 217 217 request[2] = (((bytes_read)&0xFFFF) << 16) |0x0000FFFF; 218 218 219 219 response = cParent->avcExecuteTransaction(request, 3, 3); 220 220 data_length_read=(response[1]&0xFFFF); 221 221 read_result_status=((response[1]>>24)&0xFF); 222 222 223 223 databuffer=(unsigned char *)(response+3); 224 224 225 225 for (i=0;(i<data_length_read-2) && (bytes_read < iLength);i++) { 226 226 *(aContents+bytes_read)=*(databuffer+i); 227 227 bytes_read++; 228 228 } 229 230 } 231 debugPrintShort(DEBUG_LEVEL_DESCRIPTOR,"\n"); 232 233 229 230 } 231 debugPrintShort(DEBUG_LEVEL_DESCRIPTOR,"\n"); 232 233 234 234 bLoaded=true; 235 235 } … … 237 237 bool AvDescriptor::isPresent() { 238 238 quadlet_t *response; 239 quadlet_t request[2]; 240 239 quadlet_t request[2]; 240 241 241 if (!cParent) { 242 242 return false; 243 243 } 244 244 245 245 request[0] = AVC1394_CTYPE_STATUS | qTarget | AVC1394_COMMAND_OPEN_DESCRIPTOR | (iType & 0xFF); 246 246 request[1] = 0xFFFFFFFF; 247 247 response = cParent->avcExecuteTransaction(request, 2, 2); 248 248 249 if (((response[0] & 0xFF000000)==AVC1394_RESPONSE_NOT_IMPLEMENTED) || ((response[1] & 0xFF000000)==0x04)) { 249 if (((response[0] & 0xFF000000)==AVC1394_RESPONSE_NOT_IMPLEMENTED) || ((response[1] & 0xFF000000)==0x04)) { 250 250 debugPrint(DEBUG_LEVEL_DESCRIPTOR,"Descriptor not present.\n"); 251 251 bValid=false; 252 252 return false; 253 } 253 } 254 254 return true; 255 255 } … … 285 285 unsigned int AvDescriptor::readWord(unsigned int address) { 286 286 unsigned int word; 287 287 288 288 if(cParent && bLoaded && aContents) { 289 289 word=(*(aContents+address)<<8)+*(aContents+address+1); … … 301 301 memcpy((void*)buffer, (void*)(aContents+address), length); 302 302 return length; 303 303 304 304 } else { 305 305 return 0; trunk/freebob/src/avdescriptor.h
r31 r43 1 1 /* avdescriptor.h 2 * Copyright (C) 2004 by Pieter Palmers2 * Copyright (C) 2004,05 by Pieter Palmers 3 3 * 4 4 * This file is part of FreeBob. … … 23 23 24 24 #include "avdevice.h" 25 #include "debugmodule.h" 25 26 26 27 class AvDescriptor { … … 53 54 unsigned int iLength; 54 55 quadlet_t qTarget; 56 57 DECLARE_DEBUG_MODULE; 55 58 }; 56 59 trunk/freebob/src/avdevice.cpp
r42 r43 21 21 #include <libavc1394/avc1394.h> 22 22 #include <libavc1394/avc1394_vcr.h> 23 #include "debugmodule.h"24 23 #include "avdevice.h" 25 24 #include "avdevicesubunit.h" … … 28 27 29 28 AvDevice::AvDevice(octlet_t oGuid) 30 { 31 m_oGuid = oGuid; 29 : m_iNodeId( -1 ) 30 , m_handle( 0 ) 31 , m_iPort( -1 ) 32 , m_bInitialised( false ) 33 , m_oGuid( oGuid ) 34 , m_iGeneration( 0 ) 35 , cSubUnits( 0 ) 36 , m_iNbAsyncDestinationPlugs( 0 ) 37 , m_iNbAsyncSourcePlugs( 0 ) 38 , m_iNbIsoDestinationPlugs( 0 ) 39 , m_iNbIsoSourcePlugs( 0 ) 40 , m_iNbExtDestinationPlugs( 0 ) 41 , m_iNbExtSourcePlugs( 0 ) 42 { 43 setDebugLevel( DEBUG_LEVEL_ALL ); 32 44 } 33 45 34 46 FBReturnCodes 35 AvDevice::initialize() { 36 if (!m_bInitialised) { 37 m_handle = raw1394_new_handle(); 38 if ( !m_handle ) { 39 if ( !errno ) { 40 debugPrint(DEBUG_LEVEL_DEVICE, "libraw1394 not compatible.\n" ); 41 } else { 42 perror ("Could not get 1394 handle"); 43 debugPrint(DEBUG_LEVEL_DEVICE, "Is ieee1394 and raw1394 driver loaded?\n"); 44 } 45 return eFBRC_Creating1394HandleFailed; 46 } 47 48 raw1394_set_userdata( m_handle, this ); 49 50 if ( raw1394_set_port( m_handle, m_iPort ) < 0 ) { 51 perror( "Could not set port" ); 52 return eFBRC_Setting1394PortFailed; 53 } 54 } 55 56 // enumerate the subunits present in this device, create an AvDeviceSubunit for them, and add this object to the cSubUnits vector 57 unsigned char table_entry; 58 unsigned char subunit_maxid; 59 unsigned char subunit_type; 60 quadlet_t table_entries; // buffer these table entries, because the memory content pointed to by 61 // the response pointer can change due to other libraw operations on this handle 62 63 quadlet_t request[6]; 64 quadlet_t *response; 65 AvDeviceSubunit *tmpAvDeviceSubunit=NULL; 66 67 // check the number of I/O plugs 68 69 request[0] = AVC1394_CTYPE_STATUS | AVC1394_SUBUNIT_TYPE_UNIT | AVC1394_SUBUNIT_ID_IGNORE 70 | AVC1394_COMMAND_PLUG_INFO | 0x00; 71 request[1] = 0xFFFFFFFF; 72 response = avcExecuteTransaction(request, 2, 2); 73 if (response != NULL) { 74 iNbIsoDestinationPlugs= (unsigned char) ((response[1]>>24) & 0xff); 75 iNbIsoSourcePlugs= (unsigned char) ((response[1]>>16) & 0xff); 76 iNbExtDestinationPlugs= (unsigned char) ((response[1]>>8) & 0xff); 77 iNbExtSourcePlugs= (unsigned char) ((response[1]>>0) & 0xff); 78 } 79 request[0] = AVC1394_CTYPE_STATUS | AVC1394_SUBUNIT_TYPE_UNIT | AVC1394_SUBUNIT_ID_IGNORE 80 | AVC1394_COMMAND_PLUG_INFO | 0x01; 81 request[1] = 0xFFFFFFFF; 82 response = avcExecuteTransaction(request, 2, 2); 83 if (response != NULL) { 84 iNbAsyncDestinationPlugs= (unsigned char) ((response[1]>>24) & 0xff); 85 iNbAsyncSourcePlugs= (unsigned char) ((response[1]>>16) & 0xff); 86 } 87 88 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: %d Isochronous source plugs, %d Isochronous destination plugs\n",iNbIsoSourcePlugs,iNbIsoDestinationPlugs); 89 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: %d External source plugs, %d External destination plugs\n",iNbExtSourcePlugs,iNbExtDestinationPlugs); 90 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: %d Asynchronous source plugs, %d Asynchronous destination plugs\n",iNbAsyncSourcePlugs,iNbAsyncDestinationPlugs); 91 92 // create the subunits 93 for (unsigned int i=0;i<8;i++) { // cycle through the 8 pages (max 32 subunits; 4 subunits/page) 94 request[0] = AVC1394_CTYPE_STATUS | AVC1394_SUBUNIT_TYPE_UNIT | AVC1394_SUBUNIT_ID_IGNORE 95 | AVC1394_COMMAND_SUBUNIT_INFO | ((i<<4) & 0xF0) | 0x07; 96 request[1] = 0xFFFFFFFF; 97 response = avcExecuteTransaction(request, 6, 2); 98 99 table_entries=response[1]; 100 101 if (response != NULL) { 102 // this way of processing the table entries assumes that the subunit type is not "extended" 103 104 // stop processing when a "not implemented" is received (according to spec) 105 if((response[0]&0xFF000000) == AVC1394_RESPONSE_NOT_IMPLEMENTED) break; 106 107 // warning: don't do unsigned int j! comparison >= 0 is always true for uint 108 for (int j=3;j>=0;j--) { // cycle through the 8 pages (max 32 subunits; 4 subunits/page) 109 table_entry=(table_entries >> (j*8)) & 0xFF; 110 subunit_maxid=table_entry& 0x07; 111 subunit_type=(table_entry >> 3) & 0x1F; 112 //debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: Page %d, item %d: Table entry=0x%02X, subunit_maxid=0x%02X, subunit_type=0x%02X\n",i,j,table_entry,subunit_maxid,subunit_type); 113 114 // according to spec we could stop processing 115 // at the first 0xFF entry, but doing it this way 116 // is a little more robust 117 if (table_entry != 0xFF) { 118 for (unsigned char subunit_id=0;subunit_id<subunit_maxid+1;subunit_id++) { 119 120 // only two types of specific subunits are supported: audio and music 121 switch (subunit_type) { 122 case 0x01: // audio subunit 123 tmpAvDeviceSubunit=new AvDeviceAudioSubunit(this,subunit_id); 124 if (tmpAvDeviceSubunit) { // test code 125 //tmpAvDeviceSubunit->printOutputPlugConnections(); 126 } 127 break; 128 case 0x0C: // music subunit 129 tmpAvDeviceSubunit=new AvDeviceMusicSubunit(this,subunit_id); 130 /*{ // just a test 131 AvDeviceMusicSubunit tmpAvDeviceSubunit2(this,subunit_id); 132 tmpAvDeviceSubunit2.printMusicPlugInfo(); 133 tmpAvDeviceSubunit2.printMusicPlugConfigurations(); 134 tmpAvDeviceSubunit2.printOutputPlugConnections(); 135 tmpAvDeviceSubunit2.test(); 136 }*/ 137 break; 138 139 default: // generic 140 tmpAvDeviceSubunit=new AvDeviceSubunit(this,subunit_type,subunit_id); 141 break; 142 } 143 144 if(tmpAvDeviceSubunit && tmpAvDeviceSubunit->isValid()) { 145 cSubUnits.push_back(tmpAvDeviceSubunit); 146 //setDebugLevel(DEBUG_LEVEL_ALL); 147 debugPrint (DEBUG_LEVEL_DEVICE, "Trying to reserve the subunit...\n"); 148 tmpAvDeviceSubunit->reserve(0x01); 149 debugPrint (DEBUG_LEVEL_DEVICE, " isReserved?: %d\n",tmpAvDeviceSubunit->isReserved()); 150 tmpAvDeviceSubunit->unReserve(); 151 //setDebugLevel(DEBUG_LEVEL_MODERATE); 152 153 154 } else { 155 if (tmpAvDeviceSubunit) { 156 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: Unsupported AvDeviceSubunit encountered. Page %d, item %d: Table entry=0x%02X, subunit_maxid=0x%02X, subunit_type=0x%02X, subunit_id=%0x02X\n",i,j,table_entry,subunit_maxid,subunit_type,subunit_id); 157 158 delete tmpAvDeviceSubunit; 159 } else { 160 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: Could not create AvDeviceSubunit object.\n"); 161 } 162 } 163 } 164 } 165 } 166 } 167 } 168 169 m_bInitialised = true; 170 return eFBRC_Success; 171 172 } 173 174 bool AvDevice::isInitialised() { 175 return m_bInitialised; 47 AvDevice::initialize() 48 { 49 if ( !m_bInitialised ) { 50 FBReturnCodes eStatus = create1394RawHandle(); 51 if ( eStatus != eFBRC_Success ) { 52 debugError( "Could not create 1394 raw handle\n" ); 53 return eStatus; 54 } 55 56 eStatus = enumerateSubUnits(); 57 if ( eStatus != eFBRC_Success ) { 58 debugError( "Could not enumrate SubUnits\n" ); 59 return eStatus; 60 } 61 62 m_bInitialised = true; 63 } 64 return eFBRC_Success; 65 } 66 67 bool AvDevice::isInitialised() 68 { 69 return m_bInitialised; 176 70 } 177 71 178 72 AvDevice::~AvDevice() 179 73 { 180 181 vector<AvDeviceSubunit *>::iterator it; 182 for( it = cSubUnits.begin(); it != cSubUnits.end(); it++ ) { 183 delete *it; 184 } 74 vector<AvDeviceSubunit *>::iterator it; 75 for( it = cSubUnits.begin(); it != cSubUnits.end(); it++ ) { 76 delete *it; 77 } 185 78 186 79 if ( m_handle ) { … … 190 83 } 191 84 192 /* Function to execute an AVC transaction, i.e. send command/status and get response 193 * main purpose is wrapping the avc1394 function call to output some debugging comments. 85 FBReturnCodes AvDevice::create1394RawHandle() 86 { 87 m_handle = raw1394_new_handle(); 88 if ( !m_handle ) { 89 if ( !errno ) { 90 debugPrint( DEBUG_LEVEL_DEVICE, 91 "libraw1394 not compatible.\n" ); 92 } else { 93 perror( "Could not get 1394 handle" ); 94 debugPrint(DEBUG_LEVEL_DEVICE, 95 "Is ieee1394 and raw1394 driver loaded?\n"); 96 } 97 return eFBRC_Creating1394HandleFailed; 98 } 99 100 raw1394_set_userdata( m_handle, this ); 101 102 if ( raw1394_set_port( m_handle, m_iPort ) < 0 ) { 103 perror( "Could not set port" ); 104 return eFBRC_Setting1394PortFailed; 105 } 106 return eFBRC_Success; 107 } 108 109 FBReturnCodes 110 AvDevice::enumerateSubUnits() 111 { 112 // enumerate the subunits present in this device, create an 113 // AvDeviceSubunit for them, and add this object to the cSubUnits 114 // vector 115 unsigned char table_entry; 116 unsigned char subunit_maxid; 117 unsigned char subunit_type; 118 // buffer these table entries, because the memory content pointed 119 // to by the response pointer can change due to other libraw 120 // operations on this handle 121 quadlet_t table_entries; 122 quadlet_t request[6]; 123 quadlet_t *response; 124 AvDeviceSubunit *tmpAvDeviceSubunit=NULL; 125 126 // check the number of I/O plugs 127 request[0] = AVC1394_CTYPE_STATUS 128 | AVC1394_SUBUNIT_TYPE_UNIT 129 | AVC1394_SUBUNIT_ID_IGNORE 130 | AVC1394_COMMAND_PLUG_INFO 131 | 0x0000; 132 request[1] = 0xFFFFFFFF; 133 response = avcExecuteTransaction( request, 2, 2 ); 134 request[1] = 0x02020606; 135 response = request; 136 if ( response ) { 137 138 m_iNbIsoDestinationPlugs 139 = AVC1394_GET_RESPONSE_OPERAND( response[1], 0 ); 140 m_iNbIsoSourcePlugs 141 = AVC1394_GET_RESPONSE_OPERAND( response[1], 1 ); 142 m_iNbExtDestinationPlugs 143 = AVC1394_GET_RESPONSE_OPERAND( response[1], 2 ); 144 m_iNbExtSourcePlugs 145 = AVC1394_GET_RESPONSE_OPERAND( response[1], 3 ); 146 147 /* 148 m_iNbIsoDestinationPlugs = (unsigned char) ((response[1]>>24) & 0xff); 149 m_iNbIsoSourcePlugs = (unsigned char) ((response[1]>>16) & 0xff); 150 m_iNbExtDestinationPlugs = (unsigned char) ((response[1]>>8) & 0xff); 151 m_iNbExtSourcePlugs = (unsigned char) ((response[1]>>0) & 0xff); 152 */ 153 } 154 155 request[0] = AVC1394_CTYPE_STATUS 156 | AVC1394_SUBUNIT_TYPE_UNIT 157 | AVC1394_SUBUNIT_ID_IGNORE 158 | AVC1394_COMMAND_PLUG_INFO 159 | 0x01; 160 request[1] = 0xFFFFFFFF; 161 response = avcExecuteTransaction(request, 2, 2); 162 if (response != NULL) { 163 m_iNbAsyncDestinationPlugs= (unsigned char) ((response[1]>>24) & 0xff); 164 m_iNbAsyncSourcePlugs= (unsigned char) ((response[1]>>16) & 0xff); 165 } 166 167 debugPrint( DEBUG_LEVEL_DEVICE, 168 "AvDevice: %d Isochronous source plugs, " 169 "%d Isochronous destination plugs\n", 170 m_iNbIsoSourcePlugs, m_iNbIsoDestinationPlugs); 171 debugPrint( DEBUG_LEVEL_DEVICE, 172 "AvDevice: %d External source plugs, " 173 "%d External destination plugs\n", 174 m_iNbExtSourcePlugs, m_iNbExtDestinationPlugs); 175 debugPrint( DEBUG_LEVEL_DEVICE, 176 "AvDevice: %d Asynchronous source plugs, " 177 "%d Asynchronous destination plugs\n", 178 m_iNbAsyncSourcePlugs, m_iNbAsyncDestinationPlugs); 179 180 // create the subunits 181 for (unsigned int i = 0; i < 8; i++ ) { 182 // cycle through the 8 pages (max 32 subunits; 4 183 // subunits/page) 184 185 186 request[0] = AVC1394_CTYPE_STATUS 187 | AVC1394_SUBUNIT_TYPE_UNIT 188 | AVC1394_SUBUNIT_ID_IGNORE 189 | AVC1394_COMMAND_SUBUNIT_INFO 190 | ((i<<4) & 0xF0) | 0x07; 191 request[1] = 0xFFFFFFFF; 192 response = avcExecuteTransaction( request, 6, 2 ); 193 194 table_entries=response[1]; /// XXX buggy code! response could be 0! 195 196 if ( response != NULL ) { 197 // this way of processing the table entries assumes that 198 // the subunit type is not "extended" 199 200 // stop processing when a "not implemented" is received 201 // (according to spec) 202 if ( (response[0]&0xFF000000) == AVC1394_RESPONSE_NOT_IMPLEMENTED) { 203 break; 204 } 205 206 // warning: don't do unsigned int j! 207 // comparison >= 0 is always true for uint 208 for ( int j = 3; j >= 0; j-- ) { 209 // cycle through the 8 pages (max 32 210 // subunits; 4 subunits/page) 211 table_entry = (table_entries >> (j*8)) & 0xFF; 212 subunit_maxid = table_entry & 0x07; 213 subunit_type = (table_entry >> 3) & 0x1F; 214 215 //debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: Page %d, item %d: Table entry=0x%02X, subunit_maxid=0x%02X, subunit_type=0x%02X\n",i,j,table_entry,subunit_maxid,subunit_type); 216 217 // according to spec we could stop processing at the 218 // first 0xFF entry, but doing it this way is a little 219 // more robust 220 221 if ( table_entry != 0xFF ) { 222 for ( unsigned char subunit_id = 0; 223 subunit_id < subunit_maxid+1; 224 subunit_id++ ) 225 { 226 227 // only two types of specific subunits are 228 // supported: audio and music 229 switch ( subunit_type ) { 230 case 0x01: // audio subunit 231 tmpAvDeviceSubunit 232 = new AvDeviceAudioSubunit( this, subunit_id); 233 if ( tmpAvDeviceSubunit ) { 234 // test code 235 //tmpAvDeviceSubunit->printOutputPlugConnections(); 236 } 237 break; 238 case 0x0C: // music subunit 239 tmpAvDeviceSubunit=new AvDeviceMusicSubunit(this,subunit_id); 240 /*{ // just a test 241 AvDeviceMusicSubunit tmpAvDeviceSubunit2(this,subunit_id); 242 tmpAvDeviceSubunit2.printMusicPlugInfo(); 243 tmpAvDeviceSubunit2.printMusicPlugConfigurations(); 244 tmpAvDeviceSubunit2.printOutputPlugConnections(); 245 tmpAvDeviceSubunit2.test(); 246 }*/ 247 break; 248 249 default: // generic 250 tmpAvDeviceSubunit=new AvDeviceSubunit(this,subunit_type,subunit_id); 251 break; 252 } 253 254 if ( tmpAvDeviceSubunit 255 && tmpAvDeviceSubunit->isValid() ) 256 { 257 cSubUnits.push_back(tmpAvDeviceSubunit); 258 //setDebugLevel(DEBUG_LEVEL_ALL); 259 debugPrint( DEBUG_LEVEL_DEVICE, 260 "Trying to reserve the " 261 "subunit...\n" ); 262 tmpAvDeviceSubunit->reserve( 0x01 ); 263 debugPrint( DEBUG_LEVEL_DEVICE, 264 " isReserved?: %d\n", 265 tmpAvDeviceSubunit->isReserved()); 266 tmpAvDeviceSubunit->unReserve(); 267 //setDebugLevel(DEBUG_LEVEL_MODERATE); 268 } else { 269 if ( tmpAvDeviceSubunit ) { 270 debugPrint( DEBUG_LEVEL_DEVICE, "AvDevice: Unsupported AvDeviceSubunit encountered. Page %d, item %d: Table entry=0x%02X, subunit_maxid=0x%02X, subunit_type=0x%02X, subunit_id=%0x02X\n",i,j,table_entry,subunit_maxid,subunit_type,subunit_id); 271 272 delete tmpAvDeviceSubunit; 273 } else { 274 debugPrint( DEBUG_LEVEL_DEVICE, 275 "AvDevice: Could not create AvDeviceSubunit object.\n"); 276 } 277 } 278 } 279 } 280 } 281 } 282 } 283 return eFBRC_Success; 284 } 285 286 /* Function to execute an AVC transaction, i.e. send command/status 287 * and get response main purpose is wrapping the avc1394 function call 288 * to output some debugging comments. 194 289 */ 195 quadlet_t * AvDevice::avcExecuteTransaction(quadlet_t *request, unsigned int request_len, unsigned int response_len) { 196 quadlet_t *response; 197 unsigned char *request_pos; 198 unsigned int i; 199 response = avc1394_transaction_block(m_handle, m_iNodeId, request, request_len, 2); 200 if (request != NULL) { 201 debugPrint (DEBUG_LEVEL_TRANSFERS, "------- TRANSACTION START -------\n"); 202 debugPrint (DEBUG_LEVEL_TRANSFERS," REQUEST: "); 203 /* request is in machine byte order. this function is for intel architecure */ 204 for (i=0;i<request_len;i++) { 205 request_pos=(unsigned char *)(request+i); 206 debugPrintShort (DEBUG_LEVEL_TRANSFERS, "0x%02X%02X%02X%02X ", *(request_pos),*(request_pos+1),*(request_pos+2),*(request_pos+3)); 207 } 208 debugPrintShort (DEBUG_LEVEL_TRANSFERS,"\n"); 209 debugPrint (DEBUG_LEVEL_TRANSFERS," => "); 210 debugPrintShort (DEBUG_LEVEL_TRANSFERS," "); 211 request_pos=(unsigned char *)(request); 212 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); 213 debugPrintShort (DEBUG_LEVEL_TRANSFERS,"\n"); 214 } 215 if (response != NULL) { 216 /* response is in order of receiving, i.e. msb first */ 217 debugPrint (DEBUG_LEVEL_TRANSFERS," -> RESPONSE: "); 218 for (i=0;i<response_len;i++) { 219 debugPrintShort (DEBUG_LEVEL_TRANSFERS, "0x%08X ", response[i]); 220 } 221 debugPrintShort (DEBUG_LEVEL_TRANSFERS,"\n"); 222 debugPrint (DEBUG_LEVEL_TRANSFERS," => "); 223 switch (response[0]&0xFF000000) { 224 case AVC1394_RESPONSE_NOT_IMPLEMENTED: 225 debugPrintShort (DEBUG_LEVEL_TRANSFERS,"Not Implemented "); 226 break; 227 case AVC1394_RESPONSE_ACCEPTED: 228 debugPrintShort (DEBUG_LEVEL_TRANSFERS,"Accepted "); 229 break; 230 case AVC1394_RESPONSE_REJECTED: 231 debugPrintShort (DEBUG_LEVEL_TRANSFERS,"Rejected "); 232 break; 233 case AVC1394_RESPONSE_IN_TRANSITION: 234 debugPrintShort (DEBUG_LEVEL_TRANSFERS,"In Transition "); 235 break; 236 case AVC1394_RESPONSE_IMPLEMENTED: 237 debugPrintShort (DEBUG_LEVEL_TRANSFERS,"Implemented / Stable "); 238 break; 239 case AVC1394_RESPONSE_CHANGED: 240 debugPrintShort (DEBUG_LEVEL_TRANSFERS,"Changed "); 241 break; 242 case AVC1394_RESPONSE_INTERIM: 243 debugPrintShort (DEBUG_LEVEL_TRANSFERS,"Interim "); 244 break; 245 default: 246 debugPrintShort (DEBUG_LEVEL_TRANSFERS,"Unknown response "); 247 break; 248 } 249 debugPrintShort (DEBUG_LEVEL_TRANSFERS, "subunit_type=%02X subunit_id=%02X opcode=%02X",(response[0]>>19)&0x1F,(response[0]>>16)&0x07,(response[0]>>8)&0xFF); 250 debugPrintShort (DEBUG_LEVEL_TRANSFERS,"\n"); 251 } 252 debugPrint (DEBUG_LEVEL_TRANSFERS, "------- TRANSACTION END -------\n"); 253 return response; 254 290 quadlet_t* 291 AvDevice::avcExecuteTransaction( quadlet_t* request, 292 unsigned int request_len, 293 unsigned int response_len ) 294 { 295 quadlet_t* response; 296 unsigned char* request_pos; 297 unsigned int i; 298 299 response = avc1394_transaction_block( m_handle, 300 m_iNodeId, 301 request, 302 request_len, 303 2 ); 304 if ( request ) { 305 debugPrint( DEBUG_LEVEL_TRANSFERS, 306 "------- TRANSACTION START -------\n" ); 307 debugPrint( DEBUG_LEVEL_TRANSFERS," REQUEST: " ); 308 /* request is in machine byte order. this function is for 309 * intel architecure */ 310 for ( i = 0; i < request_len; i++ ) { 311 request_pos = (unsigned char *)(request+i); 312 debugPrintShort( DEBUG_LEVEL_TRANSFERS, 313 "0x%02X%02X%02X%02X ", 314 *(request_pos), 315 *(request_pos+1), 316 *(request_pos+2), 317 *(request_pos+3)); 318 } 319 debugPrintShort( DEBUG_LEVEL_TRANSFERS, "\n" ); 320 debugPrint( DEBUG_LEVEL_TRANSFERS, " => " ); 321 debugPrintShort( DEBUG_LEVEL_TRANSFERS, " " ); 322 323 request_pos = (unsigned char *)(request); 324 325 debugPrintShort( DEBUG_LEVEL_TRANSFERS, 326 "subunit_type=%02X subunit_id=%02X opcode=%02X", 327 ((*(request_pos+1))>>3)&0x1F, 328 (*(request_pos+1))&0x07, 329 (*(request_pos+2))&0xFF ); 330 debugPrintShort (DEBUG_LEVEL_TRANSFERS,"\n"); 331 } 332 333 if ( response ) { 334 /* response is in order of receiving, i.e. msb first */ 335 debugPrint(DEBUG_LEVEL_TRANSFERS, " -> RESPONSE: " ); 336 for ( i = 0; i < response_len; i++ ) { 337 debugPrintShort( DEBUG_LEVEL_TRANSFERS, "0x%08X ", response[i] ); 338 } 339 340 debugPrintShort( DEBUG_LEVEL_TRANSFERS,"\n" ); 341 debugPrint( DEBUG_LEVEL_TRANSFERS," => " ); 342 switch (response[0]&0xFF000000) { 343 case AVC1394_RESPONSE_NOT_IMPLEMENTED: 344 debugPrintShort( DEBUG_LEVEL_TRANSFERS, "Not Implemented " ); 345 break; 346 case AVC1394_RESPONSE_ACCEPTED: 347 debugPrintShort( DEBUG_LEVEL_TRANSFERS, "Accepted " ); 348 break; 349 case AVC1394_RESPONSE_REJECTED: 350 debugPrintShort( DEBUG_LEVEL_TRANSFERS, "Rejected " ); 351 break; 352 case AVC1394_RESPONSE_IN_TRANSITION: 353 debugPrintShort( DEBUG_LEVEL_TRANSFERS, "In Transition " ); 354 break; 355 case AVC1394_RESPONSE_IMPLEMENTED: 356 debugPrintShort( DEBUG_LEVEL_TRANSFERS, "Implemented / Stable " ); 357 break; 358 case AVC1394_RESPONSE_CHANGED: 359 debugPrintShort( DEBUG_LEVEL_TRANSFERS, "Changed " ); 360 break; 361 case AVC1394_RESPONSE_INTERIM: 362 debugPrintShort( DEBUG_LEVEL_TRANSFERS, "Interim " ); 363 break; 364 default: 365 debugPrintShort( DEBUG_LEVEL_TRANSFERS, "Unknown response " ); 366 break; 367 } 368 debugPrintShort( DEBUG_LEVEL_TRANSFERS, 369 "subunit_type=%02X subunit_id=%02X opcode=%02X", 370 (response[0]>>19)&0x1F, 371 (response[0]>>16)&0x07, 372 (response[0]>>8)&0xFF ); 373 debugPrintShort( DEBUG_LEVEL_TRANSFERS, "\n" ); 374 } 375 debugPrint( DEBUG_LEVEL_TRANSFERS, "------- TRANSACTION END -------\n" ); 376 return response; 255 377 } 256 378 … … 266 388 267 389 } 268 390 return eFBRC_Success; 269 391 } 270 392 … … 281 403 *fdf=response[1]& 0x00FFFFFF; 282 404 } 283 405 return eFBRC_Success; 284 406 } 285 407 … … 295 417 296 418 } 297 419 return eFBRC_Success; 298 420 } 299 421 … … 310 432 *fdf=response[1]& 0x00FFFFFF; 311 433 } 312 434 return eFBRC_Success; 313 435 } 314 436 … … 321 443 } 322 444 return NULL; 323 324 445 } 325 446 … … 327 448 328 449 void AvDevice::printConnections() { 329 quadlet_t request[6]; 330 quadlet_t *response; 331 //setDebugLevel(DEBUG_LEVEL_ALL); 332 333 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: ISO source connections:\n"); 334 335 for (unsigned int i=0;i<getNbIsoSourcePlugs();i++) { 336 request[0] = AVC1394_CTYPE_STATUS | AVC1394_SUBUNIT_TYPE_UNIT | AVC1394_SUBUNIT_ID_IGNORE 337 | AVC1394_COMMAND_SIGNAL_SOURCE | 0xFF; 338 request[1]=0xFFFEFF00 | ((i & 0xFF)); 339 340 response = avcExecuteTransaction(request, 2, 2); 341 342 if (response != NULL) { 343 unsigned char output_status=(response[0]&0xE0) >> 5; 344 unsigned char conv=(response[0]&0x10) >> 4; 345 unsigned char signal_status=(response[0]&0x0F); 346 347 unsigned int signal_source=((response[1]>>16)&0xFFFF); 348 349 unsigned char source_subunit_type=(signal_source>>11)&0x1F; 350 unsigned char source_subunit_id=(signal_source>>8)&0x07; 351 unsigned char source_plug=signal_source&0xFF; 352 353 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); 354 // find the subunit this plug is connected to 355 AvDeviceSubunit *tmpSubunit=getSubunit(source_subunit_type,source_subunit_id); 356 if(tmpSubunit) { 357 tmpSubunit->printSourcePlugConnections(source_plug); 358 } 359 360 } 361 } 362 363 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: External source connections:\n"); 364 365 for (unsigned int i=0;i<getNbExtSourcePlugs();i++) { 366 request[0] = AVC1394_CTYPE_STATUS | AVC1394_SUBUNIT_TYPE_UNIT | AVC1394_SUBUNIT_ID_IGNORE 367 | AVC1394_COMMAND_SIGNAL_SOURCE | 0xFF; 368 request[1]=0xFFFEFF00 | ((i & 0xFF)|0x80); 369 370 response = avcExecuteTransaction(request, 2, 2); 371 372 if (response != NULL) { 373 unsigned char output_status=(response[0]&0xE0) >> 5; 374 unsigned char conv=(response[0]&0x10) >> 4; 375 unsigned char signal_status=(response[0]&0x0F); 376 377 unsigned int signal_source=((response[1]>>16)&0xFFFF); 378 379 unsigned char source_subunit_type=(signal_source>>11)&0x1F; 380 unsigned char source_subunit_id=(signal_source>>8)&0x07; 381 unsigned char source_plug=signal_source&0xFF; 382 383 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); 384 385 // find the subunit this plug is connected to 386 AvDeviceSubunit *tmpSubunit=getSubunit(source_subunit_type,source_subunit_id); 387 if(tmpSubunit) { 388 tmpSubunit->printSourcePlugConnections(source_plug); 389 } 390 } 391 } 392 393 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: ISO sink connections:\n"); 394 395 for (unsigned int i=0;i<getNbIsoDestinationPlugs();i++) { 396 request[0] = AVC1394_CTYPE_STATUS | AVC1394_SUBUNIT_TYPE_UNIT | AVC1394_SUBUNIT_ID_IGNORE 397 | AVC1394_COMMAND_SIGNAL_SOURCE | 0xFF; 398 request[1]=0xFFFEFF00 | ((i & 0xFF)); 399 400 response = avcExecuteTransaction(request, 2, 2); 401 402 if (response != NULL) { 403 unsigned char output_status=(response[0]&0xE0) >> 5; 404 unsigned char conv=(response[0]&0x10) >> 4; 405 unsigned char signal_status=(response[0]&0x0F); 406 407 unsigned int signal_source=((response[1]>>16)&0xFFFF); 408 409 unsigned char source_subunit_type=(signal_source>>11)&0x1F; 410 unsigned char source_subunit_id=(signal_source>>8)&0x07; 411 unsigned char source_plug=signal_source&0xFF; 412 413 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); 414 // find the subunit this plug is connected to 415 AvDeviceSubunit *tmpSubunit=getSubunit(source_subunit_type,source_subunit_id); 416 if(tmpSubunit) { 417 //tmpSubunit->printDestinationPlugConnections(source_plug); 418 } 419 420 } 421 } 422 423 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: External sink connections:\n"); 424 425 for (unsigned int i=0;i<getNbExtDestinationPlugs();i++) { 426 request[0] = AVC1394_CTYPE_STATUS | AVC1394_SUBUNIT_TYPE_UNIT | AVC1394_SUBUNIT_ID_IGNORE 427 | AVC1394_COMMAND_SIGNAL_SOURCE | 0xFF; 428 request[1]=0xFFFEFF00 | ((i & 0xFF)|0x80); 429 430 response = avcExecuteTransaction(request, 2, 2); 431 432 if (response != NULL) { 433 unsigned char output_status=(response[0]&0xE0) >> 5; 434 unsigned char conv=(response[0]&0x10) >> 4; 435 unsigned char signal_status=(response[0]&0x0F); 436 437 unsigned int signal_source=((response[1]>>16)&0xFFFF); 438 439 unsigned char source_subunit_type=(signal_source>>11)&0x1F; 440 unsigned char source_subunit_id=(signal_source>>8)&0x07; 441 unsigned char source_plug=signal_source&0xFF; 442 443 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); 444 445 // find the subunit this plug is connected to 446 AvDeviceSubunit *tmpSubunit=getSubunit(source_subunit_type,source_subunit_id); 447 if(tmpSubunit) { 448 //tmpSubunit->printDestinationPlugConnections(source_plug); 449 } 450 } 451 } 452 453 } 450 quadlet_t request[6]; 451 quadlet_t *response; 452 //setDebugLevel(DEBUG_LEVEL_ALL); 453 454 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: ISO source connections:\n"); 455 456 for (unsigned int i=0;i<getNbIsoSourcePlugs();i++) { 457 request[0] = AVC1394_CTYPE_STATUS 458 | AVC1394_SUBUNIT_TYPE_UNIT 459 | AVC1394_SUBUNIT_ID_IGNORE 460 | AVC1394_COMMAND_SIGNAL_SOURCE 461 | 0x00FF; 462 request[1]=0xFFFEFF00 | ((i & 0xFF)); 463 464 response = avcExecuteTransaction(request, 2, 2); 465 466 if ( response ) { 467 unsigned char output_status=(response[0]&0xE0) >> 5; 468 unsigned char conv=(response[0]&0x10) >> 4; 469 unsigned char signal_status=(response[0]&0x0F); 470 471 unsigned int signal_source=((response[1]>>16)&0xFFFF); 472 473 unsigned char source_subunit_type=(signal_source>>11)&0x1F; 474 unsigned char source_subunit_id=(signal_source>>8)&0x07; 475 unsigned char source_plug=signal_source&0xFF; 476 477 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); 478 // find the subunit this plug is connected to 479 AvDeviceSubunit *tmpSubunit=getSubunit(source_subunit_type,source_subunit_id); 480 if ( tmpSubunit ) { 481 tmpSubunit->printSourcePlugConnections(source_plug); 482 } 483 484 } 485 } 486 487 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: External source connections:\n"); 488 489 for (unsigned int i=0;i<getNbExtSourcePlugs();i++) { 490 request[0] = AVC1394_CTYPE_STATUS 491 | AVC1394_SUBUNIT_TYPE_UNIT 492 | AVC1394_SUBUNIT_ID_IGNORE 493 | AVC1394_COMMAND_SIGNAL_SOURCE 494 | 0x00FF; 495 request[1]=0xFFFEFF00 | ((i & 0xFF)|0x80); 496 497 response = avcExecuteTransaction(request, 2, 2); 498 499 if ( response ) { 500 unsigned char output_status=(response[0]&0xE0) >> 5; 501 unsigned char conv=(response[0]&0x10) >> 4; 502 unsigned char signal_status=(response[0]&0x0F); 503 504 unsigned int signal_source=((response[1]>>16)&0xFFFF); 505 506 unsigned char source_subunit_type=(signal_source>>11)&0x1F; 507 unsigned char source_subunit_id=(signal_source>>8)&0x07; 508 unsigned char source_plug=signal_source&0xFF; 509 510 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); 511 512 // find the subunit this plug is connected to 513 AvDeviceSubunit *tmpSubunit=getSubunit(source_subunit_type,source_subunit_id); 514 if ( tmpSubunit ) { 515 tmpSubunit->printSourcePlugConnections(source_plug); 516 } 517 } 518 } 519 520 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: ISO sink connections:\n"); 521 522 for (unsigned int i=0;i<getNbIsoDestinationPlugs();i++) { 523 request[0] = AVC1394_CTYPE_STATUS 524 | AVC1394_SUBUNIT_TYPE_UNIT 525 | AVC1394_SUBUNIT_ID_IGNORE 526 | AVC1394_COMMAND_SIGNAL_SOURCE 527 | 0x00FF; 528 request[1] = 0xFFFEFF00 | ((i & 0xFF)); 529 530 response = avcExecuteTransaction(request, 2, 2); 531 532 if ( response ) { 533 unsigned char output_status=(response[0]&0xE0) >> 5; 534 unsigned char conv=(response[0]&0x10) >> 4; 535 unsigned char signal_status=(response[0]&0x0F); 536 537 unsigned int signal_source=((response[1]>>16)&0xFFFF); 538 539 unsigned char source_subunit_type=(signal_source>>11)&0x1F; 540 unsigned char source_subunit_id=(signal_source>>8)&0x07; 541 unsigned char source_plug=signal_source&0xFF; 542 543 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); 544 // find the subunit this plug is connected to 545 AvDeviceSubunit *tmpSubunit 546 = getSubunit(source_subunit_type,source_subunit_id); 547 if ( tmpSubunit ) { 548 //tmpSubunit->printDestinationPlugConnections(source_plug); 549 } 550 551 } 552 } 553 554 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: External sink connections:\n"); 555 556 for (unsigned int i=0;i<getNbExtDestinationPlugs();i++) { 557 request[0] = AVC1394_CTYPE_STATUS 558 | AVC1394_SUBUNIT_TYPE_UNIT 559 | AVC1394_SUBUNIT_ID_IGNORE 560 | AVC1394_COMMAND_SIGNAL_SOURCE 561 | 0x00FF; 562 request[1]=0xFFFEFF00 | ((i & 0xFF)|0x80); 563 564 response = avcExecuteTransaction(request, 2, 2); 565 566 if ( response ) { 567 unsigned char output_status=(response[0]&0xE0) >> 5; 568 unsigned char conv=(response[0]&0x10) >> 4; 569 unsigned char signal_status=(response[0]&0x0F); 570 571 unsigned int signal_source=((response[1]>>16)&0xFFFF); 572 573 unsigned char source_subunit_type=(signal_source>>11)&0x1F; 574 unsigned char source_subunit_id=(signal_source>>8)&0x07; 575 unsigned char source_plug=signal_source&0xFF; 576 577 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); 578 579 // find the subunit this plug is connected to 580 AvDeviceSubunit *tmpSubunit 581 = getSubunit(source_subunit_type,source_subunit_id); 582 if ( tmpSubunit ) { 583 //tmpSubunit->printDestinationPlugConnections(source_plug); 584 } 585 } 586 } 587 } trunk/freebob/src/avdevice.h
r42 r43 23 23 24 24 #include "ieee1394service.h" 25 #include "debugmodule.h" 25 26 26 27 #include <vector> … … 29 30 class AvDeviceSubunit; 30 31 32 31 33 class AvDevice { 32 34 public: 35 enum { 36 eScanAndCreate = 0, 37 eDestroy = 1 38 } EStates; 39 33 40 AvDevice( octlet_t oGuid ); 34 41 virtual ~AvDevice(); … … 40 47 void setPort( int iPort ) 41 48 { m_iPort = iPort; } 42 void setGeneration( unsigned int iGeneration )43 { m_iGeneration = iGeneration; }44 unsigned int getGeneration()45 { return m_iGeneration; }46 49 octlet_t getGuid() 47 50 { return m_oGuid; } … … 54 57 bool isInitialised(); 55 58 56 FBReturnCodes setInputPlugSignalFormat(unsigned char plug, unsigned char fmt, quadlet_t fdf); 57 FBReturnCodes getInputPlugSignalFormat(unsigned char plug, unsigned char *fmt, quadlet_t *fdf); 58 FBReturnCodes setOutputPlugSignalFormat(unsigned char plug, unsigned char fmt, quadlet_t fdf); 59 FBReturnCodes getOutputPlugSignalFormat(unsigned char plug, unsigned char *fmt, quadlet_t *fdf); 59 FBReturnCodes setInputPlugSignalFormat( unsigned char plug, 60 unsigned char fmt, 61 quadlet_t fdf ); 62 FBReturnCodes getInputPlugSignalFormat( unsigned char plug, 63 unsigned char *fmt, 64 quadlet_t *fdf ); 65 FBReturnCodes setOutputPlugSignalFormat( unsigned char plug, 66 unsigned char fmt, 67 quadlet_t fdf ); 68 FBReturnCodes getOutputPlugSignalFormat( unsigned char plug, 69 unsigned char *fmt, 70 quadlet_t *fdf ); 60 71 61 // getSourcePlugConnection();62 72 // getSourcePlugConnection(); 73 void printConnections(); 63 74 64 unsigned char getNbAsyncSourcePlugs() { return iNbAsyncSourcePlugs; } ; 65 unsigned char getNbAsyncDestinationPlugs() { return iNbAsyncDestinationPlugs; } ; 66 unsigned char getNbIsoSourcePlugs() { return iNbIsoSourcePlugs; } ; // oPCR 67 unsigned char getNbIsoDestinationPlugs() { return iNbIsoDestinationPlugs; } ; // iPCR 68 unsigned char getNbExtSourcePlugs() { return iNbExtSourcePlugs; } ; 69 unsigned char getNbExtDestinationPlugs() { return iNbExtDestinationPlugs; } ; 75 unsigned char getNbAsyncSourcePlugs() 76 { return m_iNbAsyncSourcePlugs; } 77 unsigned char getNbAsyncDestinationPlugs() 78 { return m_iNbAsyncDestinationPlugs; } 79 unsigned char getNbIsoSourcePlugs() 80 { return m_iNbIsoSourcePlugs; } 81 unsigned char getNbIsoDestinationPlugs() 82 { return m_iNbIsoDestinationPlugs; } 83 unsigned char getNbExtSourcePlugs() 84 { return m_iNbExtSourcePlugs; } 85 unsigned char getNbExtDestinationPlugs() 86 { return m_iNbExtDestinationPlugs; } 70 87 71 88 protected: 72 89 AvDeviceSubunit *getSubunit(unsigned char type, unsigned char id); 90 91 FBReturnCodes create1394RawHandle(); 92 FBReturnCodes enumerateSubUnits(); 73 93 74 94 private: … … 81 101 vector< AvDeviceSubunit * > cSubUnits; 82 102 83 unsigned char iNbAsyncDestinationPlugs; 84 unsigned char iNbAsyncSourcePlugs; 85 unsigned char iNbIsoDestinationPlugs; 86 unsigned char iNbIsoSourcePlugs; 87 unsigned char iNbExtDestinationPlugs; 88 unsigned char iNbExtSourcePlugs; 103 unsigned char m_iNbAsyncDestinationPlugs; 104 unsigned char m_iNbAsyncSourcePlugs; 105 unsigned char m_iNbIsoDestinationPlugs; // iPCR 106 unsigned char m_iNbIsoSourcePlugs; // oPCR 107 unsigned char m_iNbExtDestinationPlugs; 108 unsigned char m_iNbExtSourcePlugs; 109 110 DECLARE_DEBUG_MODULE; 89 111 }; 90 112 trunk/freebob/src/avdevicemusicsubunit.cpp
r40 r43 1 1 /* avdevicemusicsubunit.cpp 2 * Copyright (C) 2004 by Pieter Palmers2 * Copyright (C) 2004,05 by Pieter Palmers 3 3 * 4 4 * This file is part of FreeBob. … … 21 21 #include <libavc1394/avc1394.h> 22 22 #include <libavc1394/avc1394_vcr.h> 23 #include "debugmodule.h"24 23 #include "avdevice.h" 25 24 #include "avdevicesubunit.h" … … 33 32 34 33 void AvDeviceMusicSubunit::test() { 35 unsigned char byte;34 // unsigned char byte; 36 35 quadlet_t request[6]; 37 36 quadlet_t *response; 38 37 39 38 unsigned char ipcr=0; 40 39 41 40 debugPrint(DEBUG_LEVEL_SUBUNIT,"AvDeviceMusicSubunit: Input Select status (iso channels):\n"); 42 for(ipcr=0;ipcr<0x1E;ipcr++) { 41 for(ipcr=0;ipcr<0x1E;ipcr++) { 43 42 request[0] = AVC1394_CTYPE_STATUS | ((iTarget & 0x1F) << 19) | ((iId & 0x07) << 16) 44 43 | (0x1B << 8) | 0xFF; … … 47 46 request[2]= (ipcr<<24)| 0xFFFEFF; 48 47 response = cParent->avcExecuteTransaction(request, 3, 4); 49 48 50 49 if ((response != NULL) && ((response[0]&0xFF000000)==0x0C000000)) { 51 50 unsigned char output_status=(response[1]&0xF0000000) >> 28; 52 51 unsigned char output_plug=(response[1]&0xFF); 53 52 unsigned char input_plug=((response[2]>>24)&0xFF); 54 53 55 54 unsigned int node_id=((response[1]>>8)&0xFFFF); 56 55 unsigned int signal_destination=((response[2]>>8)&0xFFFF); … … 62 61 63 62 void AvDeviceMusicSubunit::printMusicPlugConfigurations() { 64 unsigned char byte;63 // unsigned char byte; 65 64 quadlet_t request[6]; 66 65 quadlet_t *response; 67 66 68 67 unsigned int subunit_plug_id; 69 68 70 69 debugPrint(DEBUG_LEVEL_SUBUNIT,"AvDeviceMusicSubunit: Source Plug configurations:\n"); 71 70 72 71 for (subunit_plug_id=0;subunit_plug_id < getNbSourcePlugs() ;subunit_plug_id++) { 73 72 // get source plug configure status … … 79 78 response = cParent->avcExecuteTransaction(request, 1, 4); 80 79 if (response != NULL) { 81 80 82 81 unsigned int start_of_music_plug_ID=CORRECT_INTEGER_ENDIANNESS(response[1]); 83 82 unsigned int end_of_music_plug_ID=CORRECT_INTEGER_ENDIANNESS(response[1]>>16); 84 83 85 84 debugPrint(DEBUG_LEVEL_SUBUNIT," Subunit source plug %d: start_of_music_plug_ID=%d, end_of_music_plug_ID=%d\n",subunit_plug_id,start_of_music_plug_ID,end_of_music_plug_ID); 86 85 87 86 unsigned char *table_pointer=((unsigned char *)response)+8; 88 87 89 88 for(unsigned int i=0;i<(end_of_music_plug_ID-start_of_music_plug_ID)+1;i++) { 90 89 unsigned char music_plug_type=(*(table_pointer)) & 0xFF; 91 90 unsigned int music_plug_ID=((*(table_pointer+1))<<8)+((*(table_pointer+2))); 92 91 unsigned int stream_position=((*(table_pointer+3))<<8)+((*(table_pointer+4))); 93 92 94 93 debugPrint(DEBUG_LEVEL_SUBUNIT," %02d: Type=0x%02X, ID=%02d, Position=0x%04X\n",i+start_of_music_plug_ID,music_plug_type,music_plug_ID,stream_position); 95 94 96 95 table_pointer+=5; 97 96 } 98 97 } 99 98 } 100 99 101 100 debugPrint(DEBUG_LEVEL_SUBUNIT,"AvDeviceMusicSubunit: Destination Plug configurations:\n"); 102 101 for (subunit_plug_id=0;subunit_plug_id < getNbDestinationPlugs() ;subunit_plug_id++) { … … 109 108 response = cParent->avcExecuteTransaction(request, 1, 4); 110 109 if (response != NULL) { 111 110 112 111 unsigned int start_of_music_plug_ID=CORRECT_INTEGER_ENDIANNESS(response[1]); 113 112 unsigned int end_of_music_plug_ID=CORRECT_INTEGER_ENDIANNESS(response[1]>>16); 114 113 115 114 debugPrint(DEBUG_LEVEL_SUBUNIT," Subunit destination plug %d: start_of_music_plug_ID=%d, end_of_music_plug_ID=%d\n",subunit_plug_id,start_of_music_plug_ID,end_of_music_plug_ID); 116 115 117 116 unsigned char *table_pointer=((unsigned char *)response)+8; 118 117 119 118 for(unsigned int i=0;i<(end_of_music_plug_ID-start_of_music_plug_ID)+1;i++) { 120 119 unsigned char music_plug_type=(*(table_pointer)) & 0xFF; 121 120 unsigned int music_plug_ID=((*(table_pointer+1))<<8)+((*(table_pointer+2))); 122 121 unsigned int stream_position=((*(table_pointer+3))<<8)+((*(table_pointer+4))); 123 122 124 123 debugPrint(DEBUG_LEVEL_SUBUNIT," %02d: Type=0x%02X, ID=%02d, Position=0x%04X\n",i+start_of_music_plug_ID,music_plug_type,music_plug_ID,stream_position); 125 124 126 125 table_pointer+=5; 127 126 } 128 127 } 129 } 128 } 130 129 131 130 } 132 131 133 132 void AvDeviceMusicSubunit::printMusicPlugInfo() { 134 unsigned char byte;133 // unsigned char byte; 135 134 quadlet_t request[6]; 136 135 quadlet_t *response; 137 136 138 137 debugPrint(DEBUG_LEVEL_SUBUNIT,"AvDeviceMusicSubunit: Plug Information\n"); 139 138 140 139 // get music plug info (verified & working) 141 140 request[0] = AVC1394_CTYPE_STATUS | ((iTarget & 0x1F) << 19) | ((iId & 0x07) << 16) 142 141 | (0xC0 << 8) | 0xFF; 143 142 response = cParent->avcExecuteTransaction(request, 1, 4); 144 143 145 144 if (response != NULL) { 146 145 unsigned char *buffer=(unsigned char *) response; … … 151 150 unsigned int nb_output_plugs=CORRECT_INTEGER_ENDIANNESS(*((unsigned int *)(buffer + 3))); 152 151 unsigned int nb_input_plugs=CORRECT_INTEGER_ENDIANNESS(*((unsigned int *)(buffer + 1))); 153 debugPrint(DEBUG_LEVEL_SUBUNIT," Music plug type 0x%02X: %d input plugs / %d output plugs\n",*buffer,nb_input_plugs,nb_output_plugs) 152 debugPrint(DEBUG_LEVEL_SUBUNIT," Music plug type 0x%02X: %d input plugs / %d output plugs\n",*buffer,nb_input_plugs,nb_output_plugs); 154 153 buffer +=5; 155 154 } … … 161 160 if(cStatusDescriptor) { 162 161 AvPlugInfoBlock *plugInfo=cStatusDescriptor->getSourcePlugInfoBlock(plug); 163 162 164 163 if(plugInfo) { 165 164 plugInfo->printConnections(); … … 167 166 debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceMusicSubunit: could not find source plug 0x%02X in the descriptor.\n",plug); 168 167 } 169 170 168 169 171 170 } else { 172 171 debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceMusicSubunit: no Status Descriptor present!\n"); 173 172 } 174 173 175 174 } 176 175 … … 179 178 AvDeviceMusicSubunit::AvDeviceMusicSubunit(AvDevice *parent, unsigned char id) : AvDeviceSubunit(parent,0x0C,id) 180 179 { 180 setDebugLevel( DEBUG_LEVEL_ALL ); 181 181 182 debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceMusicSubunit: id=%02X constructor\n",id); 182 183 bValid=false; 183 184 184 185 // parse descriptors 185 186 cStatusDescriptor=NULL; 186 187 cIdentifierDescriptor=NULL; 187 188 188 189 cStatusDescriptor = new AvMusicStatusDescriptor(parent,id); 189 190 190 191 if(cStatusDescriptor) { 191 192 cStatusDescriptor->printCapabilities(); … … 193 194 debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceMusicSubunit: could not create AvMusicStatusDescriptor object\n"); 194 195 } 195 196 196 197 cIdentifierDescriptor = new AvMusicIdentifierDescriptor(parent,id); 197 198 if(cIdentifierDescriptor) { 198 199 cIdentifierDescriptor->printCapabilities(); 199 200 200 201 } else { 201 202 debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceMusicSubunit: could not create AvMusicIdentifierDescriptor object\n"); 202 203 } 203 204 bValid=true; 205 204 205 bValid=true; 206 206 207 } 207 208 trunk/freebob/src/avdevicemusicsubunit.h
r40 r43 1 1 /* avdevicemusicsubunit.h 2 * Copyright (C) 2004 by Pieter Palmers2 * Copyright (C) 2004,05 by Pieter Palmers 3 3 * 4 4 * This file is part of FreeBob. … … 22 22 #include "avdevice.h" 23 23 #include "avdevicesubunit.h" 24 #include "debugmodule.h" 24 25 25 26 #ifndef AVDEVICEMUSICSUBUNIT_H … … 44 45 45 46 protected: 46 47 47 48 48 private: 49 49 AvMusicStatusDescriptor *cStatusDescriptor; 50 50 AvMusicIdentifierDescriptor *cIdentifierDescriptor; 51 52 DECLARE_DEBUG_MODULE; 51 53 }; 52 54 trunk/freebob/src/avdevicepool.cpp
r42 r43 87 87 return pAvDevice; 88 88 } 89 90 FBReturnCodes91 AvDevicePool::removeObsoleteDevices( unsigned int iGeneration )92 {93 // XXX dw: removing elements can be done more elegant.94 std::queue< AvDevice* > deleteQueue;95 96 for ( AvDeviceVector::iterator iter = m_avDevices.begin();97 iter != m_avDevices.end();98 ++iter )99 {100 if ( ( *iter )->getGeneration() < iGeneration ) {101 deleteQueue.push( *iter );102 }103 }104 105 while ( !deleteQueue.empty() ) {106 AvDevice* pAvDevice = deleteQueue.front();107 deleteQueue.pop();108 delete pAvDevice;109 }110 111 return eFBRC_Success;112 }trunk/freebob/src/avdevicesubunit.cpp
r40 r43 26 26 27 27 28 void AvDeviceSubunit::test() { 29 30 } 31 32 void AvDeviceSubunit::printOutputPlugConnections() { 33 unsigned char byte; 34 quadlet_t request[6]; 35 quadlet_t *response; 36 37 unsigned char opcr=0; 38 39 debugPrint(DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: Serial bus iso output plug connections:\n"); 40 for(opcr=0;opcr<0x1E;opcr++) { 41 request[0] = AVC1394_CTYPE_STATUS | ((iTarget & 0x1F) << 19) | ((iId & 0x07) << 16) 42 | (0x1A << 8) | 0xFF; 43 //request[1] = ((iTarget & 0x1F) << 27) | ((iId & 0x07) << 24) | 0x00FF7F; 44 request[1]=0xFFFEFF00 | opcr; 45 response = cParent->avcExecuteTransaction(request, 2, 4); 46 if ((response != NULL) && ((response[0]&0xFF000000)==0x0C000000)) { 47 unsigned char output_status=(response[0]&0xE0) >> 5; 48 unsigned char conv=(response[0]&0x10) >> 4; 49 unsigned char signal_status=(response[0]&0x0F); 50 51 unsigned int signal_source=((response[1]>>16)&0xFFFF); 52 unsigned int signal_destination=((response[1])&0xFFFF); 53 debugPrint(DEBUG_LEVEL_SUBUNIT," oPCR %d: output_status=%d,conv=%d,signal_status=%d,signal_source=0x%04X,signal_destination=0x%04X\n",opcr,output_status,conv,signal_status,signal_source,signal_destination); 54 } 55 } 56 debugPrint(DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: Serial bus external output plug connections:\n"); 57 for(opcr=0x80;opcr<0x9E;opcr++) { 58 request[0] = AVC1394_CTYPE_STATUS | ((iTarget & 0x1F) << 19) | ((iId & 0x07) << 16) 59 | (0x1A << 8) | 0xFF; 60 //request[1] = ((iTarget & 0x1F) << 27) | ((iId & 0x07) << 24) | 0x00FF7F; 61 request[1]=0xFFFEFF00 | opcr; 62 response = cParent->avcExecuteTransaction(request, 2, 4); 63 if ((response != NULL) && ((response[0]&0xFF000000)==0x0C000000)) { 64 unsigned char output_status=(response[0]&0xE0) >> 5; 65 unsigned char conv=(response[0]&0x10) >> 4; 66 unsigned char signal_status=(response[0]&0x0F); 67 68 unsigned int signal_source=((response[1]>>16)&0xFFFF); 69 unsigned int signal_destination=((response[1])&0xFFFF); 70 debugPrint(DEBUG_LEVEL_SUBUNIT," oPCR %02X: output_status=%d,conv=%d,signal_status=%d,signal_source=0x%04X,signal_destination=0x%04X\n",opcr,output_status,conv,signal_status,signal_source,signal_destination); 71 } 72 } 28 void AvDeviceSubunit::test() 29 { 30 } 31 32 void AvDeviceSubunit::printOutputPlugConnections() 33 { 34 // unsigned char byte; 35 quadlet_t request[6]; 36 quadlet_t *response; 37 38 unsigned char opcr=0; 39 40 debugPrint(DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: Serial bus iso output plug connections:\n"); 41 for(opcr=0;opcr<0x1E;opcr++) { 42 request[0] = AVC1394_CTYPE_STATUS | ((iTarget & 0x1F) << 19) | ((iId & 0x07) << 16) 43 | (0x1A << 8) | 0xFF; 44 //request[1] = ((iTarget & 0x1F) << 27) | ((iId & 0x07) << 24) | 0x00FF7F; 45 request[1]=0xFFFEFF00 | opcr; 46 response = cParent->avcExecuteTransaction(request, 2, 4); 47 if ((response != NULL) && ((response[0]&0xFF000000)==0x0C000000)) { 48 unsigned char output_status=(response[0]&0xE0) >> 5; 49 unsigned char conv=(response[0]&0x10) >> 4; 50 unsigned char signal_status=(response[0]&0x0F); 51 52 unsigned int signal_source=((response[1]>>16)&0xFFFF); 53 unsigned int signal_destination=((response[1])&0xFFFF); 54 debugPrint(DEBUG_LEVEL_SUBUNIT," oPCR %d: output_status=%d,conv=%d,signal_status=%d,signal_source=0x%04X,signal_destination=0x%04X\n",opcr,output_status,conv,signal_status,signal_source,signal_destination); 55 } 56 } 57 debugPrint(DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: Serial bus external output plug connections:\n"); 58 for(opcr=0x80;opcr<0x9E;opcr++) { 59 request[0] = AVC1394_CTYPE_STATUS | ((iTarget & 0x1F) << 19) | ((iId & 0x07) << 16) 60 | (0x1A << 8) | 0xFF; 61 //request[1] = ((iTarget & 0x1F) << 27) | ((iId & 0x07) << 24) | 0x00FF7F; 62 request[1]=0xFFFEFF00 | opcr; 63 response = cParent->avcExecuteTransaction(request, 2, 4); 64 if ((response != NULL) && ((response[0]&0xFF000000)==0x0C000000)) { 65 unsigned char output_status=(response[0]&0xE0) >> 5; 66 unsigned char conv=(response[0]&0x10) >> 4; 67 unsigned char signal_status=(response[0]&0x0F); 68 69 unsigned int signal_source=((response[1]>>16)&0xFFFF); 70 unsigned int signal_destination=((response[1])&0xFFFF); 71 debugPrint(DEBUG_LEVEL_SUBUNIT," oPCR %02X: output_status=%d,conv=%d,signal_status=%d,signal_source=0x%04X,signal_destination=0x%04X\n",opcr,output_status,conv,signal_status,signal_source,signal_destination); 72 } 73 } 73 74 74 75 } 75 76 76 77 void AvDeviceSubunit::printSourcePlugConnections(unsigned char plug) { 77 78 78 debugPrint(DEBUG_LEVEL_SUBUNIT," No internal connection information available.\n"); 79 79 80 } 80 81 … … 82 83 AvDeviceSubunit::AvDeviceSubunit(AvDevice *parent, unsigned char target, unsigned char id) 83 84 { 84 unsigned char byte; 85 quadlet_t request[6]; 86 quadlet_t *response; 87 88 cParent=parent; 89 iTarget=target; 90 iId=id; 91 iNbDestinationPlugs=0; 92 iNbSourcePlugs=0; 93 94 debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit target=%02X id=%02X created\n",target,id); 95 96 if (!cParent) { 97 debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: parent == NULL!\n"); 98 bValid=false; 99 return; 100 } 101 102 bValid=true; 103 104 // check the number of I/O plugs 105 106 request[0] = AVC1394_CTYPE_STATUS | ((iTarget & 0x1F) << 19) | ((iId & 0x07) << 16) 107 | AVC1394_COMMAND_PLUG_INFO | 0x00; 108 request[1] = 0xFFFFFFFF; 109 response = cParent->avcExecuteTransaction(request, 2, 2); 110 if (response != NULL) { 111 iNbDestinationPlugs= (unsigned char) ((response[1]>>24) & 0xff); 112 iNbSourcePlugs= (unsigned char) ((response[1]>>16) & 0xff); 113 } 114 debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: %d source plugs, %d destination plugs\n",iNbSourcePlugs,iNbDestinationPlugs); 85 // unsigned char byte; 86 quadlet_t request[6]; 87 quadlet_t *response; 88 89 cParent=parent; 90 iTarget=target; 91 iId=id; 92 iNbDestinationPlugs=0; 93 iNbSourcePlugs=0; 94 95 setDebugLevel( DEBUG_LEVEL_ALL ); 96 97 debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit target=%02X id=%02X created\n",target,id); 98 99 if (!cParent) { 100 debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: parent == NULL!\n"); 101 bValid=false; 102 return; 103 } 104 105 bValid=true; 106 107 // check the number of I/O plugs 108 109 request[0] = AVC1394_CTYPE_STATUS | ((iTarget & 0x1F) << 19) | ((iId & 0x07) << 16) 110 | AVC1394_COMMAND_PLUG_INFO | 0x00; 111 request[1] = 0xFFFFFFFF; 112 response = cParent->avcExecuteTransaction(request, 2, 2); 113 if (response != NULL) { 114 iNbDestinationPlugs= (unsigned char) ((response[1]>>24) & 0xff); 115 iNbSourcePlugs= (unsigned char) ((response[1]>>16) & 0xff); 116 } 117 debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: %d source plugs, %d destination plugs\n",iNbSourcePlugs,iNbDestinationPlugs); 115 118 116 119 … … 124 127 bool AvDeviceSubunit::isValid() 125 128 { 126 129 return bValid; 127 130 } 128 131 129 132 unsigned char AvDeviceSubunit::getNbDestinationPlugs() { 130 133 return iNbDestinationPlugs; 131 134 } 132 135 133 136 unsigned char AvDeviceSubunit::getNbSourcePlugs() { 134 137 return iNbSourcePlugs; 135 138 } 136 139 137 140 int AvDeviceSubunit::reserve(unsigned char priority) { 138 unsigned char byte;139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 } 165 141 // unsigned char byte; 142 quadlet_t request[6]; 143 quadlet_t *response; 144 145 if (!cParent) { 146 debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: parent == NULL!\n"); 147 bValid=false; 148 return -1; 149 } 150 151 request[0] = AVC1394_CTYPE_CONTROL | ((iTarget & 0x1F) << 19) | ((iId & 0x07) << 16) 152 | AVC1394_COMMAND_RESERVE | priority; 153 request[1] = 0xFFFFFFFF; 154 request[2] = 0xFFFFFFFF; 155 request[3] = 0xFFFFFFFF; 156 response = cParent->avcExecuteTransaction(request, 4, 4); 157 if (response != NULL) { 158 if((AVC1394_MASK_RESPONSE(response[0]) == AVC1394_RESPONSE_ACCEPTED) || (AVC1394_MASK_RESPONSE(response[0]) == AVC1394_RESPONSE_IMPLEMENTED)) { 159 debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: subunit reserve successfull.\n"); 160 return priority; 161 } else { 162 debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: subunit reserve not successfull.\n"); 163 return -1; 164 } 165 } 166 return 0; 167 } 168 166 169 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 170 // unsigned char byte; 171 quadlet_t request[6]; 172 quadlet_t *response; 173 174 if (!cParent) { 175 debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: parent == NULL!\n"); 176 bValid=false; 177 return -1; // the device isn't usable, not due to reservation, but anyway... 178 } 179 180 request[0] = AVC1394_CTYPE_STATUS | ((iTarget & 0x1F) << 19) | ((iId & 0x07) << 16) 181 | AVC1394_COMMAND_RESERVE | 0xFF; 182 request[1] = 0xFFFFFFFF; 183 request[2] = 0xFFFFFFFF; 184 request[3] = 0xFFFFFFFF; 185 response = cParent->avcExecuteTransaction(request, 4, 4); 186 if (response != NULL) { 187 if((AVC1394_MASK_RESPONSE(response[0]) == AVC1394_RESPONSE_ACCEPTED) || (AVC1394_MASK_RESPONSE(response[0]) == AVC1394_RESPONSE_IMPLEMENTED)) { 188 debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: subunit reserve check successfull.\n"); 189 return (response[0]&0x000000FF); 190 } else { 191 debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: subunit reserve check not successfull.\n"); 192 193 return -1; 194 } 195 } 196 return 0; // XXX dw: is this correct? 197 } 198 199 int AvDeviceSubunit::unReserve() 200 { 201 // unsigned char byte; 202 quadlet_t request[6]; 203 quadlet_t *response; 204 205 if (!cParent) { 206 debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: parent == NULL!\n"); 207 bValid=false; 208 return -1; 209 } 210 211 request[0] = AVC1394_CTYPE_CONTROL | ((iTarget & 0x1F) << 19) | ((iId & 0x07) << 16) 212 | AVC1394_COMMAND_RESERVE | 0x00; 213 request[1] = 0xFFFFFFFF; 214 request[2] = 0xFFFFFFFF; 215 request[3] = 0xFFFFFFFF; 216 response = cParent->avcExecuteTransaction(request, 4, 4); 217 if (response != NULL) { 218 if((AVC1394_MASK_RESPONSE(response[0]) == AVC1394_RESPONSE_ACCEPTED) || (AVC1394_MASK_RESPONSE(response[0]) == AVC1394_RESPONSE_IMPLEMENTED)) { 219 debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: subunit unreserve successfull.\n"); 220 return 0; 221 } else { 222 debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: subunit unreserve not successfull.\n"); 223 return -1; 224 } 225 } 226 return 0; // XXX dw: is this correct? 227 } 228 229 230 trunk/freebob/src/avdevicesubunit.h
r40 r43 1 1 /* avdevicesubunit.h 2 * Copyright (C) 2004 by Pieter Palmers2 * Copyright (C) 2004,05 by Pieter Palmers 3 3 * 4 4 * This file is part of FreeBob. … … 21 21 #include "ieee1394service.h" 22 22 #include "avdevice.h" 23 #include "debugmodule.h" 23 24 24 25 #ifndef AVDEVICESUBUNIT_H … … 54 55 AvDevice *cParent; 55 56 56 private: 57 57 DECLARE_DEBUG_MODULE; 58 58 }; 59 59 trunk/freebob/src/avmidiinfoblock.cpp
r26 r43 1 1 /* avmidiinfoblock.cpp 2 * Copyright (C) 2004 by Pieter Palmers2 * Copyright (C) 2004,05 by Pieter Palmers 3 3 * 4 4 * This file is part of FreeBob. … … 24 24 #include <libavc1394/avc1394.h> 25 25 #include <libavc1394/avc1394_vcr.h> 26 #include "debugmodule.h"27 26 28 27 #include "avdescriptor.h" … … 32 31 33 32 AvMidiInfoBlock::AvMidiInfoBlock(AvDescriptor *parent, int address) : AvInfoBlock(parent,address) { 33 setDebugLevel( DEBUG_LEVEL_ALL ); 34 34 // do some more valid checks 35 35 if (getType() != 0x8104) { 36 36 bValid=false; 37 37 } 38 38 39 39 unsigned int nb_streams=readByte(6); 40 40 unsigned int position=0; 41 41 AvNameInfoBlock *tmpNameBlock; 42 42 43 43 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvMidiInfoBlock: Creating... length=0x%04X\n",getLength()); 44 44 45 45 if (nb_streams>0) { 46 46 position=address+7; 47 47 for (unsigned int i=0;i<nb_streams;i++) { 48 48 49 49 tmpNameBlock=new AvNameInfoBlock(parent, position); 50 50 51 51 if (tmpNameBlock && (tmpNameBlock->isValid())) { 52 52 position+=tmpNameBlock->getLength()+2; // the 2 is due to the fact that the length of the length field of the infoblock isn't accounted for; 53 53 54 54 // add to child list 55 55 cNameInfoBlocks.push_back(tmpNameBlock); … … 60 60 } 61 61 } 62 62 63 63 } 64 64 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvMidiInfoBlock: Created\n"); 65 65 66 66 // no optional info blocks please... 67 67 68 68 } 69 69 70 70 AvMidiInfoBlock::~AvMidiInfoBlock() { 71 71 72 72 vector<AvNameInfoBlock *>::iterator it; 73 73 for( it = cNameInfoBlocks.begin(); it != cNameInfoBlocks.end(); it++ ) { … … 87 87 unsigned char *AvMidiInfoBlock::getName(unsigned int streamIdx) { 88 88 AvNameInfoBlock *tmpNameBlock; 89 89 90 90 if ((streamIdx<getNbStreams()) && (streamIdx<cNameInfoBlocks.size())) { 91 91 tmpNameBlock =cNameInfoBlocks.at(streamIdx); trunk/freebob/src/avmidiinfoblock.h
r22 r43 1 1 /* avmidiinfoblock.h 2 * Copyright (C) 2004 by Pieter Palmers2 * Copyright (C) 2004,05 by Pieter Palmers 3 3 * 4 4 * This file is part of FreeBob. … … 24 24 #include <libavc1394/avc1394_vcr.h> 25 25 #include <vector> 26 26 27 using std::vector; 27 28 … … 45 46 protected: 46 47 vector<AvNameInfoBlock*> cNameInfoBlocks; 47 private: 48 49 DECLARE_DEBUG_MODULE; 48 50 49 51 }; trunk/freebob/src/avmusicpluginfoblock.cpp
r40 r43 1 1 /* avmusicpluginfoblock.cpp 2 * Copyright (C) 2004 by Pieter Palmers2 * Copyright (C) 2004,05 by Pieter Palmers 3 3 * 4 4 * This file is part of FreeBob. … … 24 24 #include <libavc1394/avc1394.h> 25 25 #include <libavc1394/avc1394_vcr.h> 26 #include "debugmodule.h"27 26 28 27 #include "avdescriptor.h" … … 32 31 33 32 AvMusicPlugInfoBlock::AvMusicPlugInfoBlock(AvDescriptor *parent, int address) : AvInfoBlock(parent,address) { 33 setDebugLevel( DEBUG_LEVEL_ALL ); 34 34 // do some more valid checks 35 35 if (getType() != 0x810B) { 36 36 bValid=false; 37 37 } 38 38 39 39 unsigned int next_block_position=address+0x06+readWord(0x04); 40 40 unsigned int plug_type=readByte(0x06); 41 41 unsigned int plug_id=readWord(0x07); 42 42 unsigned int routing_support=readByte(0x09); 43 43 44 44 unsigned int source_plug_function_type=readByte(0x0A); 45 45 unsigned int source_plug_id=readByte(0x0B); … … 62 62 destination_plug_id,destination_plug_function_block_ID,destination_stream_position,destination_stream_location); 63 63 64 64 65 65 if(next_block_position<address+getLength()) { 66 66 // parse the optional name block … … 68 68 if (tmpNameInfoBlock && (tmpNameInfoBlock->isValid())) { 69 69 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvMusicPlugInfoBlock: Name info=%s\n",tmpNameInfoBlock->getName()); 70 70 71 71 } else { 72 72 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvMusicPlugInfoBlock: invalid extra name block present\n"); … … 77 77 } 78 78 } 79 80 79 80 81 81 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvMusicPlugInfoBlock: Created\n"); 82 82 83 83 } 84 84 trunk/freebob/src/avmusicpluginfoblock.h
r38 r43 1 1 /* avmusicpluginfoblock.h 2 * Copyright (C) 2004 by Pieter Palmers2 * Copyright (C) 2004,05 by Pieter Palmers 3 3 * 4 4 * This file is part of FreeBob. … … 47 47 48 48 protected: 49 50 private: 49 DECLARE_DEBUG_MODULE; 51 50 52 51 }; trunk/freebob/src/avnameinfoblock.cpp
r26 r43 1 1 /* avnameinfoblock.cpp 2 * Copyright (C) 2004 by Pieter Palmers2 * Copyright (C) 2004,05 by Pieter Palmers 3 3 * 4 4 * This file is part of FreeBob. … … 24 24 #include <libavc1394/avc1394.h> 25 25 #include <libavc1394/avc1394_vcr.h> 26 #include "debugmodule.h"27 26 28 27 #include "avdescriptor.h" … … 31 30 32 31 AvNameInfoBlock::AvNameInfoBlock(AvDescriptor *parent, int address) : AvInfoBlock(parent,address) { 33 // do some more valid checks 32 33 setDebugLevel( DEBUG_LEVEL_ALL ); 34 // do some more valid checks 34 35 if (getType() != 0x000B) { 35 36 bValid=false; 36 } 37 } 37 38 nameBuffer=NULL; 38 39 … … 53 54 if (isValid()) { 54 55 // PP: we should parse some raw_text_info_blocks here, but the music spec indicates that there are maximum 3 of these 55 // so I do it manually here. 56 // so I do it manually here. 56 57 // PP: for my device apparently one block is sufficient. 57 58 // PP: one strange thing remains, that is that there are some NULL characters in the buffer. … … 59 60 // unsigned int type_of_textblock_1=readWord(0x0C); // = 0x000A ? 60 61 unsigned int primary_field_length_textblock_1=readWord(0x0E); // ?? I guess ?? 61 62 62 63 if (nameBuffer) { 63 64 delete nameBuffer; 64 65 } 65 66 nameBuffer=new unsigned char[primary_field_length_textblock_1]; 66 67 67 68 if((readlen=readBuffer(0x10,primary_field_length_textblock_1,nameBuffer))<primary_field_length_textblock_1) { 68 69 debugPrint (DEBUG_LEVEL_INFOBLOCK, " truncated????\n"); 69 70 70 71 nameBuffer[primary_field_length_textblock_1-1]=0; // make sure the string converter doesn't read past the buffer 71 72 } 72 73 73 74 return nameBuffer; 74 75 } else { trunk/freebob/src/avnameinfoblock.h
r22 r43 1 1 /* avnameinfoblock.h 2 * Copyright (C) 2004 by Pieter Palmers2 * Copyright (C) 2004,05 by Pieter Palmers 3 3 * 4 4 * This file is part of FreeBob. … … 40 40 protected: 41 41 unsigned char *nameBuffer; 42 private: 42 DECLARE_DEBUG_MODULE; 43 43 44 44 }; trunk/freebob/src/avoutputplugstatusinfoblock.cpp
r26 r43 1 1 /* avoutputplugstatusinfoblock.cpp 2 * Copyright (C) 2004 by Pieter Palmers2 * Copyright (C) 2004,05 by Pieter Palmers 3 3 * 4 4 * This file is part of FreeBob. … … 24 24 #include <libavc1394/avc1394.h> 25 25 #include <libavc1394/avc1394_vcr.h> 26 #include "debugmodule.h"27 26 28 27 #include "avdescriptor.h" … … 32 31 33 32 AvOutputPlugStatusInfoBlock::AvOutputPlugStatusInfoBlock(AvDescriptor *parent, int address) : AvInfoBlock(parent,address) { 33 setDebugLevel( DEBUG_LEVEL_ALL ); 34 34 // do some more valid checks 35 35 if (getType() != 0x8101) { 36 36 bValid=false; 37 37 } 38 38 39 39 unsigned int next_block_position=address+7; 40 40 unsigned int nb_sourceplugs=readByte(6); … … 43 43 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvOutputPlugStatusInfoBlock: Creating... length=0x%04X\n",getLength()); 44 44 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvOutputPlugStatusInfoBlock: Number of source plugs=%d\n",nb_sourceplugs); 45 45 46 46 if (nb_sourceplugs>0) { 47 47 for (unsigned int i=0;i<nb_sourceplugs;i++) { 48 48 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvOutputPlugStatusInfoBlock: source plug=%d\n",i); 49 49 tmpAvSourcePlugInfoBlock=new AvSourcePlugInfoBlock(parent, next_block_position); 50 50 51 51 if (tmpAvSourcePlugInfoBlock && (tmpAvSourcePlugInfoBlock->isValid())) { 52 52 //debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvOutputPlugStatusInfoBlock: source plug type=0x%04X\n",tmpAvSourcePlugInfoBlock->getType()); 53 53 next_block_position+=tmpAvSourcePlugInfoBlock->getLength()+2; // the 2 is due to the fact that the length of the length field of the infoblock isn't accounted for; 54 54 55 55 // add to child list 56 56 cSourcePlugs.push_back(tmpAvSourcePlugInfoBlock); 57 57 58 58 tmpAvSourcePlugInfoBlock->printContents(); 59 59 60 60 } else { 61 61 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvOutputPlugStatusInfoBlock: Invalid block... parse error!\n"); … … 63 63 break; // what to do now? 64 64 } 65 65 66 66 } 67 67 } 68 68 69 69 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvOutputPlugStatusInfoBlock: Created\n"); 70 70 71 71 } 72 72 trunk/freebob/src/avoutputplugstatusinfoblock.h
r23 r43 1 1 /* avoutputplugstatusinfoblock.h 2 * Copyright (C) 2004 by Pieter Palmers2 * Copyright (C) 2004,05 by Pieter Palmers 3 3 * 4 4 * This file is part of FreeBob. … … 50 50 vector<AvSourcePlugInfoBlock *> cSourcePlugs; 51 51 52 private: 53 52 DECLARE_DEBUG_MODULE; 54 53 }; 55 54 trunk/freebob/src/avpluginfoblock.cpp
r40 r43 1 1 /* avpluginfoblock.cpp 2 * Copyright (C) 2004 by Pieter Palmers2 * Copyright (C) 2004,05 by Pieter Palmers 3 3 * 4 4 * This file is part of FreeBob. … … 24 24 #include <libavc1394/avc1394.h> 25 25 #include <libavc1394/avc1394_vcr.h> 26 #include "debugmodule.h"27 26 28 27 #include "avdescriptor.h" … … 33 32 34 33 AvPlugInfoBlock::AvPlugInfoBlock(AvDescriptor *parent, int address) : AvInfoBlock(parent,address) { 34 setDebugLevel( DEBUG_LEVEL_ALL ); 35 35 // do some more valid checks 36 36 if (getType() != 0x8109) { 37 37 bValid=false; 38 38 } 39 39 40 40 41 41 … … 46 46 unsigned int nb_clusters=readWord(0x0A); 47 47 unsigned int nb_channels=readWord(0x0C); 48 48 49 49 AvClusterInfoBlock *tmpAvClusterInfoBlock=NULL; 50 50 AvInfoBlock *tmpInfoBlock=NULL; 51 51 52 52 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvPlugInfoBlock: Creating... length=0x%04X\n",getLength()); 53 53 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvPlugInfoBlock: Subunit plug id=0x%02X\n",subunit_plug_id); … … 57 57 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvPlugInfoBlock: Number of channels=%d\n",nb_channels); 58 58 59 59 60 60 if (nb_clusters>0) { 61 61 for (unsigned int i=0;i<nb_clusters;i++) { 62 62 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvPlugInfoBlock: cluster=%d\n",i); 63 63 tmpAvClusterInfoBlock=new AvClusterInfoBlock(parent, next_block_position); 64 64 65 65 if (tmpAvClusterInfoBlock && (tmpAvClusterInfoBlock->isValid())) { 66 66 67 67 next_block_position+=tmpAvClusterInfoBlock->getLength()+2; // the 2 is due to the fact that the length of the length field of the infoblock isn't accounted for; 68 68 69 69 // add to child list 70 70 cClusterInfoBlocks.push_back(tmpAvClusterInfoBlock); 71 71 72 72 //tmpAvPlugInfoBlock->printContents(); 73 73 74 74 } else { 75 75 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvPlugInfoBlock: Invalid block... parse error!\n"); … … 81 81 break; // what to do now? 82 82 } 83 83 84 84 } 85 85 } 86 86 87 87 if(next_block_position<address+getLength()) { 88 88 // parse the optional name block … … 90 90 if (tmpInfoBlock && (tmpInfoBlock->isValid())) { 91 91 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvPlugInfoBlock: extra block of type=0x%04X present\n",tmpInfoBlock->getType()); 92 92 93 93 } else { 94 94 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvPlugInfoBlock: invalid extra block present\n"); … … 98 98 tmpInfoBlock=NULL; 99 99 } 100 100 101 101 } 102 102 103 103 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvPlugInfoBlock: Created\n"); 104 104 105 105 } 106 106 … … 113 113 114 114 } 115 115 116 116 AvClusterInfoBlock *AvPlugInfoBlock::getCluster(unsigned int idx) { 117 117 if ((idx < getNbClusters()) && (idx < cClusterInfoBlocks.size())) { trunk/freebob/src/avpluginfoblock.h
r40 r43 1 1 /* avpluginfoblock.h 2 * Copyright (C) 2004 by Pieter Palmers2 * Copyright (C) 2004,05 by Pieter Palmers 3 3 * 4 4 * This file is part of FreeBob. … … 59 59 protected: 60 60 vector<AvClusterInfoBlock *> cClusterInfoBlocks; 61 private: 62 61 62 DECLARE_DEBUG_MODULE; 63 63 }; 64 64 trunk/freebob/src/avroutingstatusinfoblock.cpp
r40 r43 1 1 /* avroutingstatusinfoblock.cpp 2 * Copyright (C) 2004 by Pieter Palmers2 * Copyright (C) 2004,05 by Pieter Palmers 3 3 * 4 4 * This file is part of FreeBob. … … 24 24 #include <libavc1394/avc1394.h> 25 25 #include <libavc1394/avc1394_vcr.h> 26 #include "debugmodule.h"27 26 28 27 #include "avdescriptor.h" … … 34 33 35 34 AvRoutingStatusInfoBlock::AvRoutingStatusInfoBlock(AvDescriptor *parent, int address) : AvInfoBlock(parent,address) { 35 setDebugLevel( DEBUG_LEVEL_ALL ); 36 36 // do some more valid checks 37 37 if (getType() != 0x8108) { … … 55 55 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvRoutingStatusInfoBlock: destination plug=%d\n",i); 56 56 tmpAvPlugInfoBlock=new AvPlugInfoBlock(parent, next_block_position); 57 57 58 58 if (tmpAvPlugInfoBlock && (tmpAvPlugInfoBlock->isValid())) { 59 59 //debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvOutputPlugStatusInfoBlock: source plug type=0x%04X\n",tmpAvSourcePlugInfoBlock->getType()); 60 60 next_block_position+=tmpAvPlugInfoBlock->getLength()+2; // the 2 is due to the fact that the length of the length field of the infoblock isn't accounted for; 61 61 62 62 // add to child list 63 63 cDestinationPlugInfoBlocks.push_back(tmpAvPlugInfoBlock); 64 64 65 65 //tmpAvPlugInfoBlock->printContents(); 66 66 67 67 } else { 68 68 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvRoutingStatusInfoBlock: Invalid block... parse error!\n"); … … 74 74 break; // what to do now? 75 75 } 76 76 77 77 } 78 78 } 79 79 80 80 if (nb_source_plugs>0) { 81 81 for (unsigned int i=0;i<nb_source_plugs;i++) { 82 82 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvRoutingStatusInfoBlock: source plug=%d\n",i); 83 83 tmpAvPlugInfoBlock=new AvPlugInfoBlock(parent, next_block_position); 84 84 85 85 if (tmpAvPlugInfoBlock && (tmpAvPlugInfoBlock->isValid())) { 86 86 //debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvOutputPlugStatusInfoBlock: source plug type=0x%04X\n",tmpAvSourcePlugInfoBlock->getType()); 87 87 next_block_position+=tmpAvPlugInfoBlock->getLength()+2; // the 2 is due to the fact that the length of the length field of the infoblock isn't accounted for; 88 88 89 89 // add to child list 90 90 cSourcePlugInfoBlocks.push_back(tmpAvPlugInfoBlock); 91 91 92 92 //tmpAvPlugInfoBlock->printContents(); 93 93 94 94 } else { 95 95 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvRoutingStatusInfoBlock: Invalid block... parse error!\n"); … … 101 101 break; // what to do now? 102 102 } 103 103 104 104 } 105 105 } 106 106 107 107 if (nb_music_plugs>0) { 108 108 for (unsigned int i=0;i<nb_music_plugs;i++) { 109 109 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvRoutingStatusInfoBlock: music plug=%d\n",i); 110 110 tmpAvMusicPlugInfoBlock=new AvMusicPlugInfoBlock(parent, next_block_position); 111 111 112 112 if (tmpAvMusicPlugInfoBlock && (tmpAvMusicPlugInfoBlock->isValid())) { 113 113 //debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvOutputPlugStatusInfoBlock: source plug type=0x%04X\n",tmpAvSourcePlugInfoBlock->getType()); 114 114 next_block_position+=tmpAvMusicPlugInfoBlock->getLength()+2; // the 2 is due to the fact that the length of the length field of the infoblock isn't accounted for; 115 115 116 116 // add to child list 117 117 cMusicPlugInfoBlocks.push_back(tmpAvMusicPlugInfoBlock); 118 118 119 119 //tmpAvPlugInfoBlock->printContents(); 120 120 121 121 } else { 122 122 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvRoutingStatusInfoBlock: Invalid block... parse error!\n"); … … 128 128 break; // what to do now? 129 129 } 130 130 131 131 } 132 } 132 } 133 133 134 134 135 135 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvRoutingStatusInfoBlock: Created\n"); 136 136 137 137 } 138 138 trunk/freebob/src/avroutingstatusinfoblock.h
r40 r43 1 1 /* avroutingstatusinfoblock.h 2 * Copyright (C) 2004 by Pieter Palmers2 * Copyright (C) 2004,05 by Pieter Palmers 3 3 * 4 4 * This file is part of FreeBob. … … 55 55 vector<AvMusicPlugInfoBlock *> cMusicPlugInfoBlocks; 56 56 57 private: 57 DECLARE_DEBUG_MODULE; 58 58 59 59 }; trunk/freebob/src/avsourcepluginfoblock.cpp
r38 r43 1 1 /* avsourcepluginfoblock.cpp 2 * Copyright (C) 2004 by Pieter Palmers2 * Copyright (C) 2004,05 by Pieter Palmers 3 3 * 4 4 * This file is part of FreeBob. … … 24 24 #include <libavc1394/avc1394.h> 25 25 #include <libavc1394/avc1394_vcr.h> 26 #include "debugmodule.h"27 26 28 27 #include "avdescriptor.h" … … 32 31 33 32 AvSourcePlugInfoBlock::AvSourcePlugInfoBlock(AvDescriptor *parent, int address) : AvInfoBlock(parent,address) { 33 setDebugLevel( DEBUG_LEVEL_ALL ); 34 34 // do some more valid checks 35 35 if (getType() != 0x8102) { 36 36 bValid=false; 37 37 } 38 38 39 39 unsigned int next_block_position=address+7; 40 40 41 41 AvInfoBlock *tmpInfoBlock=NULL; 42 42 43 43 cAudioInfoBlock=NULL; 44 44 cMidiInfoBlock=NULL; 45 45 cAudioSyncInfoBlock=NULL; 46 46 47 47 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvSourcePlugInfoBlock: Creating... length=0x%04X\n",getLength()); 48 48 … … 52 52 53 53 tmpInfoBlock=new AvInfoBlock(parent,next_block_position); 54 54 55 55 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvSourcePlugInfoBlock: testing tmpInfoBlock\n"); 56 56 if (tmpInfoBlock && tmpInfoBlock->isValid()) { … … 92 92 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvSourcePlugInfoBlock: Skipping unknown block type 0x%04X\n",tmpInfoBlock->getType()); 93 93 break; 94 94 95 95 } 96 96 // update the block position pointer 97 97 next_block_position+=tmpInfoBlock->getLength()+2; 98 98 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvSourcePlugInfoBlock: Advancing to position=0x%04X\n",next_block_position); 99 99 100 100 } else { 101 101 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvSourcePlugInfoBlock: Parse error!\n"); … … 103 103 break; 104 104 } 105 105 106 106 if (tmpInfoBlock) { 107 107 delete tmpInfoBlock; … … 109 109 } 110 110 } 111 111 112 112 if (tmpInfoBlock) { 113 113 delete tmpInfoBlock; 114 114 tmpInfoBlock=NULL; 115 115 } 116 116 117 117 debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvSourcePlugInfoBlock: Created\n"); 118 118 119 119 } 120 120 trunk/freebob/src/avsourcepluginfoblock.h
r24 r43 1 1 /* avsourcepluginfoblock.h 2 * Copyright (C) 2004 by Pieter Palmers2 * Copyright (C) 2004,05 by Pieter Palmers 3 3 * 4 4 * This file is part of FreeBob. … … 54 54 AvAudioSyncInfoBlock * cAudioSyncInfoBlock; 55 55 56 private: 57 56 DECLARE_DEBUG_MODULE; 58 57 }; 59 58 trunk/freebob/src/cmhandler.cpp
r15 r43 21 21 #include "cmhandler.h" 22 22 #include "ieee1394service.h" 23 #include "debugmodule.h"24 23 25 24 CMHandler* CMHandler::m_pInstance = 0; … … 28 27 : m_bInitialised( false ) 29 28 { 29 setDebugLevel( DEBUG_LEVEL_ALL ); 30 30 } 31 31 trunk/freebob/src/cmhandler.h
r32 r43 23 23 24 24 #include "freebob.h" 25 #include "debugmodule.h" 25 26 26 27 class Ieee1394Service; … … 40 41 Ieee1394Service* m_pIeee1394Service; 41 42 bool m_bInitialised; 43 44 DECLARE_DEBUG_MODULE; 42 45 }; 43 46 trunk/freebob/src/debugmodule.cpp
r18 r43 1 /* debugmodule. h2 * Copyright (C) 2004 by Pieter Palmers1 /* debugmodule.cpp 2 * Copyright (C) 2004,05 by Pieter Palmers, Daniel Wagner 3 3 * 4 4 * This file is part of FreeBob. … … 18 18 * MA 02111-1307 USA. 19 19 */ 20 #include <stdarg.h> 20 21 #include "debugmodule.h" 21 22 22 unsigned char toAscii(unsigned char c) { 23 if (c>31 && c<126) { 24 return c; 25 } else { 26 return '.'; 27 } 28 29 } 30 31 /* converts a quadlet to a uchar * buffer 23 #undef setDebugLevel 24 #undef debugError 25 #undef debugPrint 26 #undef debugPrintShort 27 28 //////////////////////////////////////////////////////////////// 29 DebugBase::DebugBase() 30 : m_level( 0 ) 31 {} 32 33 DebugBase::~DebugBase() 34 {} 35 36 //////////////////////////////////////////////////////////////// 37 DebugStandard::DebugStandard() 38 : DebugBase() 39 {} 40 41 DebugStandard::~DebugStandard() 42 {} 43 44 void 45 DebugStandard::debugError( const char* file, 46 const char* function, 47 unsigned int line, 48 const char* format, ... ) const 49 { 50 va_list arg; 51 52 va_start( arg, format ); 53 fprintf( stderr, "ERROR: %s %s %d: ", file, function, line ); 54 vfprintf( stderr, format, arg ); 55 va_end( arg ); 56 } 57 58 void 59 DebugStandard::debugPrint( int level, 60 const char* file, 61 const char* function, 62 unsigned int line, 63 const char* format, ... ) const 64 { 65 if (level & m_level) { 66 va_list arg; 67 68 va_start( arg, format ); 69 printf( "DEBUG %s %s %d : ", file, function, line ); 70 vprintf( format, arg ); 71 va_end( arg ); 72 } 73 } 74 75 void 76 DebugStandard::debugPrintShort( int level, 77 const char* format, ... ) const 78 { 79 if (level & m_level) { 80 va_list arg; 81 82 va_start( arg, format ); 83 vprintf ( format, arg ); 84 va_end( arg ); 85 } 86 } 87 88 //////////////////////////////////////////////////////////////// 89 DebugAnsiColor::DebugAnsiColor() 90 : DebugBase() 91 {} 92 93 DebugAnsiColor::~DebugAnsiColor() 94 {} 95 96 void 97 DebugAnsiColor::debugError( const char* file, 98 const char* function, 99 unsigned int line, 100 const char* format, ... ) const 101 { 102 va_list arg; 103 104 va_start( arg, format ); 105 fprintf( stderr, "\033[37m\033[41mERROR: %s %s %d: ", 106 file, function, line ); 107 vfprintf( stderr, format, arg ); 108 fprintf( stderr, "\033[0m\033[49m" ); 109 va_end( arg ); 110 } 111 112 void 113 DebugAnsiColor::debugPrint( int level, 114 const char* file, 115 const char* function, 116 unsigned int line, 117 const char* format, ... ) const 118 { 119 if (level & m_level) { 120 va_list arg; 121 122 va_start( arg, format ); 123 printf( "\033[37mDEBUG %s %s %d: %s" , 124 file, function, line, getLevelColor( level ) ); 125 vprintf( format, arg ); 126 printf( "\033[0m" ); 127 va_end( arg ); 128 } 129 } 130 131 void 132 DebugAnsiColor::debugPrintShort( int level, 133 const char* format, ... ) const 134 { 135 if (level & m_level) { 136 va_list arg; 137 138 va_start( arg, format ); 139 printf( "%s", getLevelColor( level ) ); 140 vprintf( format, arg ); 141 printf( "\033[0m" ); 142 va_end( arg ); 143 } 144 } 145 146 const char* 147 DebugAnsiColor::getLevelColor( int level ) const 148 { 149 switch(level) { 150 case DEBUG_LEVEL_INFO: 151 return "\033[31m"; 152 break; 153 case DEBUG_LEVEL_DEVICE: 154 return "\033[32m"; 155 break; 156 case DEBUG_LEVEL_SUBUNIT: 157 return "\033[33m"; 158 break; 159 case DEBUG_LEVEL_DESCRIPTOR: 160 return "\033[34m"; // blue 161 break; 162 case DEBUG_LEVEL_INFOBLOCK: // purple 163 return "\033[35m"; 164 break; 165 case DEBUG_LEVEL_TRANSFERS: 166 return "\033[36m"; 167 break; 168 default: 169 return "\033[0m"; 170 break; 171 172 } 173 return ""; 174 } 175 176 //////////////////////////////////////////////////////////////// 177 DebugHtml::DebugHtml() 178 : DebugBase() 179 {} 180 181 DebugHtml::~DebugHtml() 182 {} 183 184 void 185 DebugHtml::debugError( const char* file, 186 const char* function, 187 unsigned int line, 188 const char* format, ... ) const 189 { 190 va_list arg; 191 192 va_start( arg, format ); 193 fprintf( stdout, "<P style='background: red;'><FONT color='white'>" 194 "ERROR: %s %s %d: ", file, function, line ); 195 vfprintf( stdout, format, arg ); 196 fprintf( stdout, "</FONT></P>" ); 197 va_end( arg ); 198 } 199 200 void 201 DebugHtml::debugPrint( int level, 202 const char* file, 203 const char* function, 204 unsigned int line, 205 const char* format, ... ) const 206 { 207 if (level & m_level) { 208 va_list arg; 209 210 va_start( arg, format ); 211 printf( "<FONT color='darkGray'>" "DEBUG %s %s %d: %s", 212 file, function, line, getLevelColor( level ) ); 213 vprintf( format, arg ); 214 printf( "</FONT></FONT>" ); 215 va_end( arg ); 216 } 217 } 218 219 void 220 DebugHtml::debugPrintShort( int level, const char* format, ... ) const 221 { 222 if (level & m_level) { 223 va_list( arg ); 224 225 va_start( arg, format ); 226 printf ( "%s", getLevelColor( level ) ); 227 vprintf( format, arg ); 228 printf( "</FONT>" ); 229 va_end( arg ); 230 } 231 } 232 233 const char* 234 DebugHtml::getLevelColor( int level ) const 235 { 236 switch( level ) { 237 case DEBUG_LEVEL_INFO: 238 return "<FONT color='darkRed'>"; 239 break; 240 case DEBUG_LEVEL_DEVICE: 241 return "<FONT color='darkGreen'>"; 242 break; 243 case DEBUG_LEVEL_SUBUNIT: 244 return "<FONT color='darkYellow'>"; 245 break; 246 case DEBUG_LEVEL_DESCRIPTOR: 247 return "<FONT color='darkBlue'>"; // blue 248 break; 249 case DEBUG_LEVEL_INFOBLOCK: // purple 250 return "<FONT color='darkMagenta'>"; 251 break; 252 case DEBUG_LEVEL_TRANSFERS: 253 return "<FONT color='darkCyan'>"; 254 break; 255 default: 256 return "<FONT color='black'>"; 257 break; 258 } 259 } 260 261 //////////////////////////////////////////////////////////////// 262 //////////////////////////////////////////////////////////////// 263 264 unsigned char 265 toAscii( unsigned char c ) 266 { 267 if ( ( c > 31 ) && ( c < 126) ) { 268 return c; 269 } else { 270 return '.'; 271 } 272 } 273 274 /* converts a quadlet to a uchar * buffer 32 275 * not implemented optimally, but clear 33 276 */ 34 void quadlet2char(quadlet_t quadlet,unsigned char* buff) { 35 *(buff)=(quadlet>>24)&0xFF; 36 *(buff+1)=(quadlet>>16)&0xFF; 37 *(buff+2)=(quadlet>>8)&0xFF; 38 *(buff+3)=(quadlet)&0xFF; 39 } 40 41 void hexDump(unsigned char *data_start, unsigned int length) { 42 unsigned int i=0; 43 unsigned int byte_pos; 44 unsigned int bytes_left; 45 //printf("hexdump: %p %d\n",data_start,length); 46 47 if(length<=0) return; 48 if(length>=7) { 49 for(i=0;i<(length-7);i+=8) { 50 printf("%04X: %02X %02X %02X %02X %02X %02X %02X %02X - [%c%c%c%c%c%c%c%c]\n",i, 51 *(data_start+i+0),*(data_start+i+1),*(data_start+i+2),*(data_start+i+3),*(data_start+i+4),*(data_start+i+5),*(data_start+i+6),*(data_start+i+7), 52 toAscii(*(data_start+i+0)),toAscii(*(data_start+i+1)),toAscii(*(data_start+i+2)),toAscii(*(data_start+i+3)),toAscii(*(data_start+i+4)),toAscii(*(data_start+i+5)),toAscii(*(data_start+i+6)),toAscii(*(data_start+i+7)) 53 ); 54 } 55 } 56 byte_pos=i; 57 bytes_left=length-byte_pos; 58 59 printf("%04X:",i); 60 for (i=byte_pos;i<length;i+=1) { 61 printf(" %02X",*(data_start+i)); 62 } 63 for (i=0;i<8-bytes_left;i+=1) { 64 printf(" "); 65 } 66 67 printf(" - ["); 68 for (i=byte_pos;i<length;i+=1) { 69 printf("%c",toAscii(*(data_start+i))); 70 } 71 for (i=0;i<8-bytes_left;i+=1) { 72 printf(" "); 73 } 74 75 printf("]"); 76 printf("\n"); 77 78 } 277 void 278 quadlet2char( quadlet_t quadlet, unsigned char* buff ) 279 { 280 *(buff) = (quadlet>>24)&0xFF; 281 *(buff+1) = (quadlet>>16)&0xFF; 282 *(buff+2) = (quadlet>> 8)&0xFF; 283 *(buff+3) = (quadlet) &0xFF; 284 } 285 286 void 287 hexDump( unsigned char *data_start, unsigned int length ) 288 { 289 unsigned int i=0; 290 unsigned int byte_pos; 291 unsigned int bytes_left; 292 //printf("hexdump: %p %d\n",data_start,length); 293 294 if ( length <= 0 ) { 295 return; 296 } 297 if ( length >= 7 ) { 298 for ( i = 0; i < (length-7); i += 8 ) { 299 printf( "%04X: %02X %02X %02X %02X %02X %02X %02X %02X " 300 "- [%c%c%c%c%c%c%c%c]\n", 301 302 i, 303 304 *(data_start+i+0), 305 *(data_start+i+1), 306 *(data_start+i+2), 307 *(data_start+i+3), 308 *(data_start+i+4), 309 *(data_start+i+5), 310 *(data_start+i+6), 311 *(data_start+i+7), 312 313 toAscii( *(data_start+i+0) ), 314 toAscii( *(data_start+i+1) ), 315 toAscii( *(data_start+i+2) ), 316 toAscii( *(data_start+i+3) ), 317 toAscii( *(data_start+i+4) ), 318 toAscii( *(data_start+i+5) ), 319 toAscii( *(data_start+i+6) ), 320 toAscii( *(data_start+i+7) ) 321 ); 322 } 323 } 324 byte_pos = i; 325 bytes_left = length - byte_pos; 326 327 printf( "%04X:" ,i ); 328 for ( i = byte_pos; i < length; i += 1 ) { 329 printf( " %02X", *(data_start+i) ); 330 } 331 for ( i=0; i < 8-bytes_left; i+=1 ) { 332 printf( " " ); 333 } 334 335 printf( " - [" ); 336 for ( i = byte_pos; i < length; i += 1) { 337 printf( "%c", toAscii(*(data_start+i))); 338 } 339 for ( i = 0; i < 8-bytes_left; i += 1) { 340 printf( " " ); 341 } 342 343 printf( "]" ); 344 printf( "\n" ); 345 } trunk/freebob/src/debugmodule.h
r40 r43 1 1 /* debugmodule.h 2 * Copyright (C) 2004 by Daniel Wagner2 * Copyright (C) 2004,05 by Daniel Wagner, Pieter Palmers 3 3 * 4 4 * This file is part of FreeBob. … … 23 23 24 24 #include <stdio.h> 25 #include "ieee1394service.h" 26 27 // global debug control. undefine to disable debug output 28 #define DEBUG 25 #include <libraw1394/raw1394.h> 29 26 30 27 // debug print control flags … … 42 39 #define DEBUG_LEVEL_HIGH (DEBUG_LEVEL_MODERATE | DEBUG_LEVEL_DESCRIPTOR | DEBUG_LEVEL_INFOBLOCK) 43 40 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 41 unsigned char toAscii( unsigned char c ); 42 void quadlet2char( quadlet_t quadlet, unsigned char* buff ); 43 void hexDump( unsigned char *data_start, unsigned int length ); 44 45 class DebugBase { 46 public: 47 DebugBase(); 48 virtual ~DebugBase(); 49 50 void setDebugLevel( int level ) 51 { m_level = level; } 52 53 virtual void debugError( const char* file, 54 const char* function, 55 unsigned int line, 56 const char* format, ... ) const = 0; 57 virtual void debugPrint( int level, 58 const char* file, 59 const char* function, 60 unsigned int line, 61 const char* format, ... ) const = 0; 62 virtual void debugPrintShort( int level, 63 const char* format, ... ) const = 0; 64 65 protected: 66 int m_level; 67 }; 68 69 class DebugStandard : public DebugBase { 70 public: 71 DebugStandard(); 72 virtual ~DebugStandard(); 73 74 virtual void debugError( const char* file, 75 const char* function, 76 unsigned int line, 77 const char* format, ... ) const; 78 virtual void debugPrint( int level, 79 const char* file, 80 const char* function, 81 unsigned int line, 82 const char* format, ... ) const; 83 virtual void debugPrintShort( int level, 84 const char* format, ... ) const; 85 }; 86 87 class DebugAnsiColor : public DebugBase { 88 public: 89 DebugAnsiColor(); 90 virtual ~DebugAnsiColor(); 91 92 virtual void debugError( const char* file, 93 const char* function, 94 unsigned int line, 95 const char* format, ... ) const; 96 virtual void debugPrint( int level, 97 const char* file, 98 const char* function, 99 unsigned int line, 100 const char* format, ... ) const; 101 virtual void debugPrintShort( int level, 102 const char* format, ... ) const; 103 104 protected: 105 const char* getLevelColor( int level ) const; 106 }; 107 108 class DebugHtml : public DebugBase { 109 public: 110 DebugHtml(); 111 virtual ~DebugHtml(); 112 113 void debugError( const char* file, 114 const char* function, 115 unsigned int line, 116 const char* format, ... ) const; 117 void debugPrint( int level, 118 const char* file, 119 const char* function, 120 unsigned int line, 121 const char* format, ... ) const; 122 void debugPrintShort( int level, 123 const char* format, ... ) const; 124 125 protected: 126 const char* getLevelColor( int level ) const; 127 }; 50 128 51 129 #ifdef DEBUG 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_ANSICOLORED57 130 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 ); 131 #define setDebugLevel(x) m_debug.setDebugLevel( x ) 132 #define debugError(format, args...) m_debug.debugError( __FILE__, __FUNCTION__, __LINE__, format, ##args ) 133 #define debugPrint(level, format, args...) m_debug.debugPrint( level, __FILE__, __FUNCTION__, __LINE__, format, ##args ) 134 #define debugPrintShort(level, format, args...) m_debug.debugPrintShort( level, format, ##args ) 62 135 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 } 136 // XXX To change the debug module the header has to be edited 137 // which sucks big time 138 #define DECLARE_DEBUG_MODULE DebugAnsiColor m_debug 89 139 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 130 #else 131 #define DEBUG_LEVEL 132 #define setDebugLevel(x) 133 #define debugError(format, args...) 134 #define debugPrint(Level, format, args...) 135 #endif 140 #else /* !DEBUG */ 136 141 137 unsigned char toAscii(unsigned char c); 138 void quadlet2char(quadlet_t quadlet,unsigned char* buff); 139 void hexDump(unsigned char *data_start, unsigned int length); 142 #define setDebugLevel(x) 143 #define debugError(format, args...) 144 #define debugPrint(level, format, args...) 145 #define debugPrint(level, format, args...) 146 #define debugPrintShort(level, format, args...) 147 148 #define DECLARE_DEBUG_MODULE 149 150 #endif /* DEBUG */ 140 151 141 152 #endif trunk/freebob/src/freebob.h
r16 r43 33 33 eFBRC_InitializeCMHandlerFailed = -5, 34 34 eFBRC_AvDeviceNotFound = -6, 35 eFBRC_CreatingAvDeviceFailed = -7, 35 36 } FBReturnCodes; 36 37 trunk/freebob/src/ieee1394service.cpp
r42 r43 26 26 #include "ieee1394service.h" 27 27 #include "threads.h" 28 #include "debugmodule.h"29 28 #include "avdevicepool.h" 30 29 … … 50 49 , m_iGenerationCount( 0 ) 51 50 { 51 setDebugLevel( DEBUG_LEVEL_ALL ); 52 52 pthread_mutex_init( &m_mutex, NULL ); 53 53 } … … 140 140 switch (rom1394_get_node_type( &romDir )) { 141 141 case ROM1394_NODE_TYPE_UNKNOWN: 142 debugPrint (DEBUG_LEVEL_INFO,143 "Node %d has node type UNKNOWN\n", iNodeId );142 debugPrint( DEBUG_LEVEL_INFO, 143 "Node %d has node type UNKNOWN\n", iNodeId ); 144 144 break; 145 145 case ROM1394_NODE_TYPE_DC: 146 debugPrint (DEBUG_LEVEL_INFO,147 "Node %d has node type DC\n", iNodeId );146 debugPrint( DEBUG_LEVEL_INFO, 147 "Node %d has node type DC\n", iNodeId ); 148 148 break; 149 149 case ROM1394_NODE_TYPE_AVC: 150 debugPrint (DEBUG_LEVEL_INFO,151 "Node %d has node type AVC\n", iNodeId );150 debugPrint( DEBUG_LEVEL_INFO, 151 "Node %d has node type AVC\n", iNodeId ); 152 152 printAvcUnitInfo( iNodeId ); 153 153 154 154 if ( avc1394_check_subunit_type( m_handle, iNodeId, 155 155 AVC1394_SUBUNIT_TYPE_AUDIO ) ) { 156 157 156 octlet_t oGuid = rom1394_get_guid( m_handle, iNodeId ); 158 AvDevice* pAvDevice 159 = AvDevicePool::instance()->getAvDevice( oGuid );157 158 AvDevice* pAvDevice = new AvDevice( oGuid ); 160 159 if ( !pAvDevice ) { 161 pAvDevice = new AvDevice( oGuid ); 160 debugError( "Could not create AvDevice instance for " 161 "device with GUID 0x%08x%08x\n", 162 (quadlet_t) (oGuid>>32), 163 (quadlet_t) (oGuid & 0xffffffff) ); 164 165 return eFBRC_CreatingAvDeviceFailed; 162 166 } 163 167 pAvDevice->setNodeId( iNodeId ); 164 168 pAvDevice->setPort( m_iPort ); 165 169 166 if ( !pAvDevice->isInitialised() ) { 167 FBReturnCodes eStatus = pAvDevice->initialize(); 168 if ( eStatus != eFBRC_Success ) { 169 debugError( "AvDevice with GUID 0x%08x%08x could " 170 "not be initialized\n", 171 (quadlet_t) (oGuid>>32), 172 (quadlet_t) (oGuid & 0xffffffff) ); 173 174 delete pAvDevice; 175 return eStatus; 176 } 170 FBReturnCodes eStatus = pAvDevice->initialize(); 171 if ( eStatus != eFBRC_Success ) { 172 debugError( "AvDevice with GUID 0x%08x%08x could " 173 "not be initialized\n", 174 (quadlet_t) (oGuid>>32), 175 (quadlet_t) (oGuid & 0xffffffff) ); 176 177 delete pAvDevice; 178 return eStatus; 177 179 } 178 180 179 181 // XXX Pieter's test code. 180 avDeviceTests( oGuid, m_iPort, iNodeId );182 // avDeviceTests( oGuid, m_iPort, iNodeId ); 181 183 } 182 184 break; … … 194 196 } 195 197 } 196 197 AvDevicePool::instance()->removeObsoleteDevices( iGeneration );198 // XXX dw: removed: AvDevicePool::instance()->removeObsoleteDevices() 199 // check if this is still code here is still correct. 198 200 return eFBRC_Success; 199 201 } … … 337 339 unsigned int iGeneration ) 338 340 { 339 debugPrint( DEBUG_LEVEL_INFO,340 "Bus reset has occurred (generation = %d).\n", iGeneration );341 341 raw1394_update_generation (handle, iGeneration); 342 342 Ieee1394Service* pInstance … … 344 344 pInstance->setGenerationCount( iGeneration ); 345 345 346 // dw: let's rescan the bus. this might not the correct order347 // of commands.348 346 asyncCall( pInstance, &Ieee1394Service::discoveryDevices, iGeneration ); 349 347 return 0; trunk/freebob/src/ieee1394service.h
r42 r43 26 26 27 27 #include "freebob.h" 28 #include "debugmodule.h" 28 29 29 30 /* XXX: add those to avc1394.h */ 30 #define AVC1394_SUBUNIT_TYPE_AUDIO (1 <<19)31 #define AVC1394_SUBUNIT_TYPE_PRINTER (2 <<19)32 #define AVC1394_SUBUNIT_TYPE_CA (6 <<19)33 #define AVC1394_SUBUNIT_TYPE_PANEL (9 <<19)34 #define AVC1394_SUBUNIT_TYPE_BULLETIN_BOARD (0xA <<19)35 #define AVC1394_SUBUNIT_TYPE_CAMERA_STORAGE (0xB <<19)36 #define AVC1394_SUBUNIT_TYPE_MUSIC (0xC <<19)37 38 #define AVC1394_SUBUNIT_MUSIC_CAPABILITY_GENERAL (1<<0)39 #define AVC1394_SUBUNIT_MUSIC_CAPABILITY_AUDIO (1<<1)40 #define AVC1394_SUBUNIT_MUSIC_CAPABILITY_MIDI (1<<2)41 #define AVC1394_SUBUNIT_MUSIC_CAPABILITY_SMPTE (1<<3)42 #define AVC1394_SUBUNIT_MUSIC_CAPABILITY_SAMPLECOUNT (1<<4)43 #define AVC1394_SUBUNIT_MUSIC_CAPABILITY_AUDIOSYNC (1<<5)44 #define AVC1394_SUBUNIT_MUSIC_CAPABILITY_RESERVED (1<<6)45 #define AVC1394_SUBUNIT_MUSIC_CAPABILITY_MORE (1<<7)46 47 #define AVC1394_SUBUNIT_MUSIC_CAPABILITY_NONBLOCKING (1<<0)48 #define AVC1394_SUBUNIT_MUSIC_CAPABILITY_BLOCKING (1<<1)49 50 #define AVC1394_SUBUNIT_MUSIC_CAPABILITY_AUDIOSYNC_BUS (1<<0)51 #define AVC1394_SUBUNIT_MUSIC_CAPABILITY_AUDIOSYNC_EXTERNAL (1<<0)52 31 53 32 class Ieee1394Service { … … 87 66 bool m_bRHThreadRunning; 88 67 unsigned int m_iGenerationCount; 68 69 DECLARE_DEBUG_MODULE; 89 70 }; 90 71 trunk/freebob/src/streamprocess.cpp
r30 r43 22 22 23 23 #include "streamprocess.h" 24 #include "debugmodule.h"25 24 26 25 StreamProcess::StreamProcess() 27 26 : m_pCMHandler( 0 ) 28 27 { 28 setDebugLevel( DEBUG_LEVEL_ALL ); 29 29 } 30 30 trunk/freebob/src/streamprocess.h
r14 r43 23 23 24 24 #include "cmhandler.h" 25 #include "debugmodule.h" 25 26 26 27 /** StreamProcess … … 35 36 private: 36 37 CMHandler* m_pCMHandler; 38 39 DECLARE_DEBUG_MODULE; 37 40 }; 38 41 trunk/freebob/src/workerthread.cpp
r37 r43 1 1 /* workerthread.cpp 2 * Copyright (C) 2004 by Daniel Wagner2 * Copyright (C) 2004,05 by Daniel Wagner 3 3 * 4 4 * This file is part of FreeBob. … … 21 21 #include "threads.h" 22 22 #include "workerthread.h" 23 #include "debugmodule.h"24 23 25 24 WorkerThread* WorkerThread::m_pInstance = 0; … … 27 26 WorkerThread::WorkerThread() 28 27 { 28 setDebugLevel( DEBUG_LEVEL_ALL ); 29 29 30 pthread_create( &m_thread, NULL, workerThread, this ); 30 31 pthread_mutex_init( &m_mutex, NULL ); … … 51 52 // because the hole driver is single threaded... 52 53 if ( !m_pInstance ) { 53 debugPrint( DEBUG_LEVEL_INFO, "WorkerThread instance created.\n" );54 54 m_pInstance = new WorkerThread(); 55 55 } … … 94 94 WorkerThread::workerThread( void* arg ) 95 95 { 96 debugPrint( DEBUG_LEVEL_INFO, "Starting WorkerThread main loop.\n" );97 96 WorkerThread* pWorkerThread = ( WorkerThread* ) arg; 98 97 pWorkerThread->run(); 99 debugPrint( DEBUG_LEVEL_INFO, "WorkerThread main loop exited.\n" );100 98 return NULL; 101 99 } trunk/freebob/src/workerthread.h
r34 r43 1 1 /* workerthread.h 2 * Copyright (C) 2004 by Daniel Wagner2 * Copyright (C) 2004,05 by Daniel Wagner 3 3 * 4 4 * This file is part of FreeBob. … … 22 22 23 23 #include <queue> 24 25 24 #include <pthread.h> 25 #include "debugmodule.h" 26 26 27 27 class Functor; … … 47 47 pthread_cond_t m_cond; 48 48 std::queue< Functor* > m_queue; 49 50 DECLARE_DEBUG_MODULE; 49 51 }; 50 52 trunk/freebob/tests/detect_avc_unit.c
r10 r43 1 /* detect_avc_unit.c 2 * Copyright (C) 2004,05 by Daniel Wagner 3 * 4 * This file is part of FreeBob. 5 * 6 * FreeBob is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBob is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with FreeBob; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 18 * MA 02111-1307 USA. 19 */ 20 1 21 #include <libavc1394/rom1394.h> 2 22 #include <libavc1394/avc1394.h>