Changeset 43

Show
Ignore:
Timestamp:
01/09/05 14:57:49 (18 years ago)
Author:
wagi
Message:

Debug module overhaul.
Compile warnings removed.
Creating and destroying of AvDevices? now done as described in mail.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/freebob/configure.ac

    r16 r43  
    7575AC_C_CONST 
    7676AC_C_VOLATILE 
    77 CFLAGS="$CFLAGS -Wall" 
    78 CXXFLAGS="$CXXFLAGS -Wall" 
     77CFLAGS="$CFLAGS -Wall -DDEBUG"       # XXX DEBUG should not always be set 
     78CXXFLAGS="$CXXFLAGS -Wall -DDEBUG"   # XXX DEBUG should not always be set 
    7979 
    8080AC_SUBST([CFLAGS]) 
  • trunk/freebob/src/avaudioinfoblock.cpp

    r26 r43  
    11/* avaudioinfoblock.cpp 
    2  * Copyright (C) 2004 by Pieter Palmers 
     2 * Copyright (C) 2004,05 by Pieter Palmers 
    33 * 
    44 * This file is part of FreeBob. 
     
    1919 */ 
    2020 
    21  
    2221#include <string.h> 
    2322#include <errno.h> 
    2423#include <libavc1394/avc1394.h> 
    2524#include <libavc1394/avc1394_vcr.h> 
    26 #include "debugmodule.h" 
    2725 
    2826#include "avdescriptor.h" 
     
    3230 
    3331AvAudioInfoBlock::AvAudioInfoBlock(AvDescriptor *parent, int address) : AvInfoBlock(parent,address) { 
     32    setDebugLevel( DEBUG_LEVEL_ALL ); 
    3433        // do some more valid checks 
    3534        if (getType() != 0x8103) { 
    3635                bValid=false; 
    37         }       
     36        } 
    3837        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvAudioInfoBlock: Creating... length=0x%04X\n",getLength()); 
    39          
     38 
    4039        // PP: I assume that there is only an audio block, no optional blocks. 
    4140        cNameInfoBlock=new AvNameInfoBlock(parent, address+7); 
    4241        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvAudioInfoBlock: Created\n"); 
    43          
     42 
    4443} 
    4544 
  • trunk/freebob/src/avaudioinfoblock.h

    r31 r43  
    11/* avaudioinfoblock.h 
    2  * Copyright (C) 2004 by Pieter Palmers 
     2 * Copyright (C) 2004,05 by Pieter Palmers 
    33 * 
    44 * This file is part of FreeBob. 
     
    4242protected: 
    4343        AvNameInfoBlock *cNameInfoBlock; 
    44 private: 
    4544 
     45        DECLARE_DEBUG_MODULE; 
    4646}; 
    4747 
  • trunk/freebob/src/avaudiosyncinfoblock.cpp

    r26 r43  
    11/* avaudiosyncinfoblock.cpp 
    2  * Copyright (C) 2004 by Pieter Palmers 
     2 * Copyright (C) 2004,05 by Pieter Palmers 
    33 * 
    44 * This file is part of FreeBob. 
     
    2424#include <libavc1394/avc1394.h> 
    2525#include <libavc1394/avc1394_vcr.h> 
    26 #include "debugmodule.h" 
    2726 
    2827#include "avdescriptor.h" 
     
    3130 
    3231AvAudioSyncInfoBlock::AvAudioSyncInfoBlock(AvDescriptor *parent, int address) : AvInfoBlock(parent,address) { 
     32    setDebugLevel( DEBUG_LEVEL_ALL ); 
    3333        // do some more valid checks 
    3434        if (getType() != 0x8107) { 
     
    5757                unsigned char capability=readByte(6); 
    5858                return (capability & AVC1394_SUBUNIT_MUSIC_CAPABILITY_AUDIOSYNC_EXTERNAL); 
    59          
     59 
    6060        } else { 
    6161                return false; 
  • trunk/freebob/src/avaudiosyncinfoblock.h

    r31 r43  
    11/* avaudiosyncinfoblock.h 
    2  * Copyright (C) 2004 by Pieter Palmers 
     2 * Copyright (C) 2004,05 by Pieter Palmers 
    33 * 
    44 * This file is part of FreeBob. 
     
    4040 
    4141protected: 
    42  
    43 private: 
     42        DECLARE_DEBUG_MODULE; 
    4443 
    4544}; 
  • trunk/freebob/src/avclusterinfoblock.cpp

    r40 r43  
    11/* avclusterinfoblock.cpp 
    2  * Copyright (C) 2004 by Pieter Palmers 
     2 * Copyright (C) 2004,05 by Pieter Palmers 
    33 * 
    44 * This file is part of FreeBob. 
     
    2424#include <libavc1394/avc1394.h> 
    2525#include <libavc1394/avc1394_vcr.h> 
    26 #include "debugmodule.h" 
    2726 
    2827#include "avdescriptor.h" 
     
    3231 
    3332AvClusterInfoBlock::AvClusterInfoBlock(AvDescriptor *parent, int address) : AvInfoBlock(parent,address) { 
     33    setDebugLevel( DEBUG_LEVEL_ALL ); 
    3434        // do some more valid checks 
    3535        if (getType() != 0x810A) { 
    3636                bValid=false; 
    3737        } 
    38          
     38 
    3939        unsigned int next_block_position=address+0x06+readWord(0x04); 
    40          
     40 
    4141        unsigned int stream_format=readByte(0x06); 
    4242        unsigned int port_type=readByte(0x07); 
     
    5252                unsigned char stream_location=readByte(0x09+i*4+3); 
    5353                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 
    5555        } 
    56          
     56 
    5757        if(next_block_position<address+getLength()) { 
    5858                // parse the optional name block 
     
    6060                if (tmpNameInfoBlock && (tmpNameInfoBlock->isValid())) { 
    6161                        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvClusterInfoBlock:   Name info=%s\n",tmpNameInfoBlock->getName()); 
    62                  
     62 
    6363                } else { 
    6464                        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvClusterInfoBlock:   invalid extra name block present\n"); 
     
    7070        } 
    7171 
    72          
     72 
    7373        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvClusterInfoBlock: Created\n"); 
    74          
     74 
    7575} 
    7676 
     
    8181 
    8282void AvClusterInfoBlock::printSignalInfo(unsigned char idx) { 
    83         if (idx<getNbSignals() && (0x09+idx*4<getLength())) { 
     83        if ( ( idx < getNbSignals() ) && ( ( unsigned int )( 0x09+idx*4 ) < getLength() ) ) { 
    8484                unsigned int plug_info=readWord(0x09+idx*4); 
    8585                unsigned char stream_position=readByte(0x09+idx*4+2); 
     
    8888        } else { 
    8989                debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvClusterInfoBlock:   Signal %d not present!\n",idx); 
    90          
     90 
    9191        } 
    9292} 
     
    9494void AvClusterInfoBlock::printName() { 
    9595        unsigned int next_block_position=iBaseAddress+0x06+readWord(0x04); 
    96          
     96 
    9797        if(next_block_position<iBaseAddress+getLength()) { 
    9898                // parse the optional name block 
     
    100100                if (tmpNameInfoBlock && (tmpNameInfoBlock->isValid())) { 
    101101                        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvClusterInfoBlock:   Name: %s\n",tmpNameInfoBlock->getName()); 
    102                  
     102 
    103103                } else { 
    104104                        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvClusterInfoBlock:   no name block present\n"); 
  • trunk/freebob/src/avclusterinfoblock.h

    r40 r43  
    11/* avclusterinfoblock.h 
    2  * Copyright (C) 2004 by Pieter Palmers 
     2 * Copyright (C) 2004,05 by Pieter Palmers 
    33 * 
    44 * This file is part of FreeBob. 
     
    5252         
    5353protected: 
    54          
    55 private:         
     54        DECLARE_DEBUG_MODULE; 
    5655         
    5756}; 
  • trunk/freebob/src/avdescriptor.cpp

    r40 r43  
    11/* avdescriptor.cpp 
    2  * Copyright (C) 2004 by Pieter Palmers 
     2 * Copyright (C) 2004,05 by Pieter Palmers 
    33 * 
    44 * This file is part of FreeBob. 
     
    2424#include <libavc1394/avc1394.h> 
    2525#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, 
    2928   a descriptor is attached to an AVC device anyway. 
    30     
     29 
    3130   a descriptor also always has a type 
    3231*/ 
    3332 
    3433AvDescriptor::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 ) 
    3543{ 
    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 ); 
    4545} 
    4646 
     
    5858void AvDescriptor::OpenReadOnly() { 
    5959        quadlet_t *response; 
    60         quadlet_t request[3];   
    61          
     60        quadlet_t request[3]; 
     61 
    6262        if (!cParent) { 
    6363                return; 
    6464        } 
    65          
     65 
    6666        if(isOpen()) { 
    6767                Close(); 
    6868        } 
    69          
     69 
    7070        request[0] = AVC1394_CTYPE_CONTROL | qTarget 
    7171                                        | AVC1394_COMMAND_OPEN_DESCRIPTOR | (iType & 0xFF); 
    7272        request[1] = 0x01FFFFFF; 
    7373        //fprintf(stderr, "Opening descriptor\n"); 
    74          
     74 
    7575        response =  cParent->avcExecuteTransaction(request, 2, 2); 
    76          
     76 
    7777        if ((response[0]&0xFF000000)==AVC1394_RESPONSE_ACCEPTED) { 
    7878                bOpen=true; 
     
    8686void AvDescriptor::OpenReadWrite() { 
    8787        quadlet_t *response; 
    88         quadlet_t request[3];   
    89          
     88        quadlet_t request[3]; 
     89 
    9090        if (!cParent) { 
    9191                return; 
    9292        } 
    93          
     93 
    9494        if(isOpen()) { 
    9595                Close(); 
    9696        } 
    97                  
     97 
    9898        request[0] = AVC1394_CTYPE_CONTROL | qTarget 
    9999                                        | AVC1394_COMMAND_OPEN_DESCRIPTOR | (iType & 0xFF); 
    100100        request[1] = 0x03FFFFFF; 
    101101        //fprintf(stderr, "Opening descriptor\n"); 
    102          
     102 
    103103        response =  cParent->avcExecuteTransaction(request, 2, 2); 
    104          
     104 
    105105        if ((response[0]&0xFF000000)==AVC1394_RESPONSE_ACCEPTED) { 
    106106                bOpen=true; 
     
    122122void AvDescriptor::Close() { 
    123123        quadlet_t *response; 
    124         quadlet_t request[3];   
     124        quadlet_t request[3]; 
    125125        if (!cParent) { 
    126126                return; 
    127         }       
     127        } 
    128128        request[0] = AVC1394_CTYPE_CONTROL | qTarget 
    129129                                        | AVC1394_COMMAND_OPEN_DESCRIPTOR | (iType & 0xFF); 
    130130        request[1] = 0x00FFFFFF; 
    131131        //fprintf(stderr, "Opening descriptor\n"); 
    132          
     132 
    133133        response =  cParent->avcExecuteTransaction(request, 2, 2); 
    134          
     134 
    135135        if ((response[0]&0xFF000000)==AVC1394_RESPONSE_ACCEPTED) { // should always be accepted according to spec 
    136136                bOpen=false; 
     
    144144void AvDescriptor::Load() { 
    145145        quadlet_t *response; 
    146         quadlet_t request[3];   
     146        quadlet_t request[3]; 
    147147        unsigned int i=0; 
    148148        unsigned int bytes_read=0; 
     
    150150        unsigned char read_result_status; 
    151151        unsigned int data_length_read; 
    152          
     152 
    153153        if (!cParent) { 
    154154                return; 
    155155        } 
    156          
     156 
    157157        /* First determine the descriptor length */ 
    158158        request[0] = AVC1394_CTYPE_CONTROL | qTarget 
     
    163163 
    164164        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); 
    167167 
    168168        // now get the rest of the descriptor 
    169169        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 
    172172         * that are before the third quadlet (why did 1394TA do that?) 
    173          *  
     173         * 
    174174         * proposed solution: 
    175175         * 1) the first read is OK, because the length of the descriptor is in these two bytes, 
    176176         *    so execute a read from address 0 with length=iLength 
    177177         * 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 
    180180         *    run. 
    181181         */ 
    182          
     182 
    183183        // first read 
    184184        if(bytes_read<iLength) { 
    185                 debugPrintShort(DEBUG_LEVEL_DESCRIPTOR,".");    
     185                debugPrintShort(DEBUG_LEVEL_DESCRIPTOR,"."); 
    186186                // apparently the lib modifies the request, so redefine it completely 
    187187                request[0] = AVC1394_CTYPE_CONTROL | qTarget 
     
    191191                request[1] = 0xFFFF0000 | (iLength)&0xFFFF; 
    192192                request[2] = ((0) << 16) |0x0000FFFF; 
    193                  
     193 
    194194                response =  cParent->avcExecuteTransaction(request, 3, 3); 
    195195                data_length_read=(response[1]&0xFFFF); 
    196196                read_result_status=((response[1]>>24)&0xFF); 
    197                  
     197 
    198198                databuffer=(unsigned char *)(response+3); 
    199                  
     199 
    200200                // the buffer starting at databuffer is two bytes smaller that the amount of bytes read 
    201201                for (i=0;(i<data_length_read-2) && (bytes_read < iLength);i++) { 
     
    203203                        bytes_read++; 
    204204                } 
    205                  
    206         } 
    207          
     205 
     206        } 
     207 
    208208        // now do the remaining reads 
    209209        while(bytes_read<iLength) { 
    210                 debugPrintShort(DEBUG_LEVEL_DESCRIPTOR,".");    
     210                debugPrintShort(DEBUG_LEVEL_DESCRIPTOR,"."); 
    211211                // apparently the lib modifies the request, so redefine it completely 
    212212                request[0] = AVC1394_CTYPE_CONTROL | qTarget 
     
    216216                request[1] = 0xFFFF0000 | (iLength-bytes_read+2)&0xFFFF; 
    217217                request[2] = (((bytes_read)&0xFFFF) << 16) |0x0000FFFF; 
    218                  
     218 
    219219                response =  cParent->avcExecuteTransaction(request, 3, 3); 
    220220                data_length_read=(response[1]&0xFFFF); 
    221221                read_result_status=((response[1]>>24)&0xFF); 
    222                  
     222 
    223223                databuffer=(unsigned char *)(response+3); 
    224                  
     224 
    225225                for (i=0;(i<data_length_read-2) && (bytes_read < iLength);i++) { 
    226226                        *(aContents+bytes_read)=*(databuffer+i); 
    227227                        bytes_read++; 
    228228                } 
    229                  
    230         } 
    231         debugPrintShort(DEBUG_LEVEL_DESCRIPTOR,"\n");   
    232          
    233          
     229 
     230        } 
     231        debugPrintShort(DEBUG_LEVEL_DESCRIPTOR,"\n"); 
     232 
     233 
    234234        bLoaded=true; 
    235235} 
     
    237237bool AvDescriptor::isPresent() { 
    238238        quadlet_t *response; 
    239         quadlet_t request[2];   
    240          
     239        quadlet_t request[2]; 
     240 
    241241        if (!cParent) { 
    242242                return false; 
    243243        } 
    244          
     244 
    245245        request[0] = AVC1394_CTYPE_STATUS | qTarget | AVC1394_COMMAND_OPEN_DESCRIPTOR | (iType & 0xFF); 
    246246        request[1] = 0xFFFFFFFF; 
    247247        response =  cParent->avcExecuteTransaction(request, 2, 2); 
    248248 
    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)) { 
    250250                debugPrint(DEBUG_LEVEL_DESCRIPTOR,"Descriptor not present.\n"); 
    251251                bValid=false; 
    252252                return false; 
    253         }  
     253        } 
    254254        return true; 
    255255} 
     
    285285unsigned int AvDescriptor::readWord(unsigned int address) { 
    286286        unsigned int word; 
    287          
     287 
    288288        if(cParent && bLoaded && aContents) { 
    289289                word=(*(aContents+address)<<8)+*(aContents+address+1); 
     
    301301                memcpy((void*)buffer, (void*)(aContents+address), length); 
    302302                return length; 
    303                  
     303 
    304304        } else { 
    305305                return 0; 
  • trunk/freebob/src/avdescriptor.h

    r31 r43  
    11/* avdescriptor.h 
    2  * Copyright (C) 2004 by Pieter Palmers 
     2 * Copyright (C) 2004,05 by Pieter Palmers 
    33 * 
    44 * This file is part of FreeBob. 
     
    2323 
    2424#include "avdevice.h" 
     25#include "debugmodule.h" 
    2526 
    2627class AvDescriptor { 
     
    5354    unsigned int iLength; 
    5455    quadlet_t qTarget; 
     56 
     57    DECLARE_DEBUG_MODULE; 
    5558}; 
    5659 
  • trunk/freebob/src/avdevice.cpp

    r42 r43  
    2121#include <libavc1394/avc1394.h> 
    2222#include <libavc1394/avc1394_vcr.h> 
    23 #include "debugmodule.h" 
    2423#include "avdevice.h" 
    2524#include "avdevicesubunit.h" 
     
    2827 
    2928AvDevice::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 ); 
    3244} 
    3345 
    3446FBReturnCodes 
    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; 
     47AvDevice::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 
     67bool AvDevice::isInitialised() 
     68
     69    return m_bInitialised; 
    17670} 
    17771 
    17872AvDevice::~AvDevice() 
    17973{ 
    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    } 
    18578 
    18679    if ( m_handle ) { 
     
    19083} 
    19184 
    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. 
     85FBReturnCodes 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 
     109FBReturnCodes 
     110AvDevice::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. 
    194289 */ 
    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  
     290quadlet_t* 
     291AvDevice::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; 
    255377} 
    256378 
     
    266388 
    267389        } 
    268         return eFBRC_Success; 
     390       return eFBRC_Success; 
    269391} 
    270392 
     
    281403                *fdf=response[1]& 0x00FFFFFF; 
    282404        } 
    283         return eFBRC_Success; 
     405       return eFBRC_Success; 
    284406} 
    285407 
     
    295417 
    296418        } 
    297         return eFBRC_Success; 
     419       return eFBRC_Success; 
    298420} 
    299421 
     
    310432                *fdf=response[1]& 0x00FFFFFF; 
    311433        } 
    312         return eFBRC_Success; 
     434       return eFBRC_Success; 
    313435} 
    314436 
     
    321443        } 
    322444        return NULL; 
    323  
    324445} 
    325446 
     
    327448 
    328449void 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  
    2323 
    2424#include "ieee1394service.h" 
     25#include "debugmodule.h" 
    2526 
    2627#include <vector> 
     
    2930class AvDeviceSubunit; 
    3031 
     32 
    3133class AvDevice { 
    3234 public: 
     35    enum { 
     36        eScanAndCreate = 0, 
     37        eDestroy       = 1 
     38    } EStates; 
     39 
    3340    AvDevice( octlet_t oGuid ); 
    3441    virtual ~AvDevice(); 
     
    4047    void setPort( int iPort ) 
    4148        { m_iPort = iPort; } 
    42     void setGeneration( unsigned int iGeneration ) 
    43         { m_iGeneration = iGeneration; } 
    44     unsigned int getGeneration() 
    45         { return m_iGeneration; } 
    4649    octlet_t getGuid() 
    4750        { return m_oGuid; } 
     
    5457    bool isInitialised(); 
    5558 
    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 );   
    6071     
    61 //    getSourcePlugConnection(); 
    62        void printConnections(); 
     72    //        getSourcePlugConnection(); 
     73    void printConnections(); 
    6374             
    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; } 
    7087 
    7188 protected: 
    7289        AvDeviceSubunit *getSubunit(unsigned char type, unsigned char id); 
     90 
     91        FBReturnCodes create1394RawHandle(); 
     92        FBReturnCodes enumerateSubUnits(); 
    7393  
    7494 private: 
     
    81101    vector< AvDeviceSubunit * > cSubUnits; 
    82102     
    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; 
    89111}; 
    90112 
  • trunk/freebob/src/avdevicemusicsubunit.cpp

    r40 r43  
    11/* avdevicemusicsubunit.cpp 
    2  * Copyright (C) 2004 by Pieter Palmers 
     2 * Copyright (C) 2004,05 by Pieter Palmers 
    33 * 
    44 * This file is part of FreeBob. 
     
    2121#include <libavc1394/avc1394.h> 
    2222#include <libavc1394/avc1394_vcr.h> 
    23 #include "debugmodule.h" 
    2423#include "avdevice.h" 
    2524#include "avdevicesubunit.h" 
     
    3332 
    3433void AvDeviceMusicSubunit::test() { 
    35       unsigned char byte; 
     34//    unsigned char byte; 
    3635        quadlet_t request[6]; 
    3736        quadlet_t *response; 
    38          
     37 
    3938        unsigned char ipcr=0; 
    4039 
    4140        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++) { 
    4342                request[0] = AVC1394_CTYPE_STATUS | ((iTarget & 0x1F) << 19) | ((iId & 0x07) << 16) 
    4443                                                | (0x1B << 8) | 0xFF; 
     
    4746                request[2]= (ipcr<<24)| 0xFFFEFF; 
    4847                response = cParent->avcExecuteTransaction(request, 3, 4); 
    49                  
     48 
    5049                if ((response != NULL) && ((response[0]&0xFF000000)==0x0C000000)) { 
    5150                        unsigned char output_status=(response[1]&0xF0000000) >> 28; 
    5251                        unsigned char output_plug=(response[1]&0xFF); 
    5352                        unsigned char input_plug=((response[2]>>24)&0xFF); 
    54                          
     53 
    5554                        unsigned int node_id=((response[1]>>8)&0xFFFF); 
    5655                        unsigned int signal_destination=((response[2]>>8)&0xFFFF); 
     
    6261 
    6362void AvDeviceMusicSubunit::printMusicPlugConfigurations() { 
    64       unsigned char byte; 
     63//    unsigned char byte; 
    6564        quadlet_t request[6]; 
    6665        quadlet_t *response; 
    67          
     66 
    6867        unsigned int subunit_plug_id; 
    69          
     68 
    7069        debugPrint(DEBUG_LEVEL_SUBUNIT,"AvDeviceMusicSubunit: Source Plug configurations:\n"); 
    71                  
     70 
    7271        for (subunit_plug_id=0;subunit_plug_id < getNbSourcePlugs() ;subunit_plug_id++) { 
    7372                // get source plug configure status 
     
    7978                response = cParent->avcExecuteTransaction(request, 1, 4); 
    8079                if (response != NULL) { 
    81                          
     80 
    8281                        unsigned int start_of_music_plug_ID=CORRECT_INTEGER_ENDIANNESS(response[1]); 
    8382                        unsigned int end_of_music_plug_ID=CORRECT_INTEGER_ENDIANNESS(response[1]>>16); 
    84                          
     83 
    8584                        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 
    8786                        unsigned char *table_pointer=((unsigned char *)response)+8; 
    88                          
     87 
    8988                        for(unsigned int i=0;i<(end_of_music_plug_ID-start_of_music_plug_ID)+1;i++) { 
    9089                                unsigned char music_plug_type=(*(table_pointer)) & 0xFF; 
    9190                                unsigned int music_plug_ID=((*(table_pointer+1))<<8)+((*(table_pointer+2))); 
    9291                                unsigned int stream_position=((*(table_pointer+3))<<8)+((*(table_pointer+4))); 
    93                                  
     92 
    9493                                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 
    9695                                table_pointer+=5; 
    9796                        } 
    9897                } 
    9998        } 
    100          
     99 
    101100        debugPrint(DEBUG_LEVEL_SUBUNIT,"AvDeviceMusicSubunit: Destination Plug configurations:\n"); 
    102101        for (subunit_plug_id=0;subunit_plug_id < getNbDestinationPlugs() ;subunit_plug_id++) { 
     
    109108                response = cParent->avcExecuteTransaction(request, 1, 4); 
    110109                if (response != NULL) { 
    111                          
     110 
    112111                        unsigned int start_of_music_plug_ID=CORRECT_INTEGER_ENDIANNESS(response[1]); 
    113112                        unsigned int end_of_music_plug_ID=CORRECT_INTEGER_ENDIANNESS(response[1]>>16); 
    114                          
     113 
    115114                        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 
    117116                        unsigned char *table_pointer=((unsigned char *)response)+8; 
    118                          
     117 
    119118                        for(unsigned int i=0;i<(end_of_music_plug_ID-start_of_music_plug_ID)+1;i++) { 
    120119                                unsigned char music_plug_type=(*(table_pointer)) & 0xFF; 
    121120                                unsigned int music_plug_ID=((*(table_pointer+1))<<8)+((*(table_pointer+2))); 
    122121                                unsigned int stream_position=((*(table_pointer+3))<<8)+((*(table_pointer+4))); 
    123                                  
     122 
    124123                                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 
    126125                                table_pointer+=5; 
    127126                        } 
    128127                } 
    129         }       
     128        } 
    130129 
    131130} 
    132131 
    133132void AvDeviceMusicSubunit::printMusicPlugInfo() { 
    134       unsigned char byte; 
     133//    unsigned char byte; 
    135134        quadlet_t request[6]; 
    136135        quadlet_t *response; 
    137          
     136 
    138137        debugPrint(DEBUG_LEVEL_SUBUNIT,"AvDeviceMusicSubunit: Plug Information\n"); 
    139                  
     138 
    140139        // get music plug info (verified & working) 
    141140        request[0] = AVC1394_CTYPE_STATUS | ((iTarget & 0x1F) << 19) | ((iId & 0x07) << 16) 
    142141                                        | (0xC0 << 8) | 0xFF; 
    143142        response = cParent->avcExecuteTransaction(request, 1, 4); 
    144          
     143 
    145144        if (response != NULL) { 
    146145                unsigned char *buffer=(unsigned char *) response; 
     
    151150                        unsigned int nb_output_plugs=CORRECT_INTEGER_ENDIANNESS(*((unsigned int *)(buffer + 3))); 
    152151                        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); 
    154153                        buffer +=5; 
    155154                } 
     
    161160        if(cStatusDescriptor) { 
    162161                AvPlugInfoBlock *plugInfo=cStatusDescriptor->getSourcePlugInfoBlock(plug); 
    163                  
     162 
    164163                if(plugInfo) { 
    165164                        plugInfo->printConnections(); 
     
    167166                        debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceMusicSubunit: could not find source plug 0x%02X in the descriptor.\n",plug); 
    168167                } 
    169                  
    170                          
     168 
     169 
    171170        } else { 
    172171                debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceMusicSubunit: no Status Descriptor present!\n"); 
    173172        } 
    174          
     173 
    175174} 
    176175 
     
    179178AvDeviceMusicSubunit::AvDeviceMusicSubunit(AvDevice *parent, unsigned char  id) : AvDeviceSubunit(parent,0x0C,id) 
    180179{ 
     180    setDebugLevel( DEBUG_LEVEL_ALL ); 
     181 
    181182        debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceMusicSubunit: id=%02X constructor\n",id); 
    182183        bValid=false; 
    183          
     184 
    184185        // parse descriptors 
    185186        cStatusDescriptor=NULL; 
    186187        cIdentifierDescriptor=NULL; 
    187          
     188 
    188189        cStatusDescriptor = new AvMusicStatusDescriptor(parent,id); 
    189          
     190 
    190191        if(cStatusDescriptor) { 
    191192                cStatusDescriptor->printCapabilities(); 
     
    193194                debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceMusicSubunit: could not create AvMusicStatusDescriptor object\n"); 
    194195        } 
    195          
     196 
    196197        cIdentifierDescriptor = new AvMusicIdentifierDescriptor(parent,id); 
    197198        if(cIdentifierDescriptor) { 
    198199                cIdentifierDescriptor->printCapabilities(); 
    199                  
     200 
    200201        } else { 
    201202                debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceMusicSubunit: could not create AvMusicIdentifierDescriptor object\n"); 
    202203        } 
    203          
    204         bValid=true;    
    205          
     204 
     205        bValid=true; 
     206 
    206207} 
    207208 
  • trunk/freebob/src/avdevicemusicsubunit.h

    r40 r43  
    11/* avdevicemusicsubunit.h 
    2  * Copyright (C) 2004 by Pieter Palmers 
     2 * Copyright (C) 2004,05 by Pieter Palmers 
    33 * 
    44 * This file is part of FreeBob. 
     
    2222#include "avdevice.h" 
    2323#include "avdevicesubunit.h" 
     24#include "debugmodule.h" 
    2425 
    2526#ifndef AVDEVICEMUSICSUBUNIT_H 
     
    4445         
    4546 protected: 
    46          
    4747     
    4848 private: 
    4949        AvMusicStatusDescriptor         *cStatusDescriptor; 
    5050        AvMusicIdentifierDescriptor     *cIdentifierDescriptor; 
     51 
     52        DECLARE_DEBUG_MODULE; 
    5153}; 
    5254 
  • trunk/freebob/src/avdevicepool.cpp

    r42 r43  
    8787    return pAvDevice; 
    8888} 
    89  
    90 FBReturnCodes 
    91 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  
    2626 
    2727 
    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         } 
     28void AvDeviceSubunit::test() 
     29
     30
     31 
     32void 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    } 
    7374 
    7475} 
    7576 
    7677void AvDeviceSubunit::printSourcePlugConnections(unsigned char plug) { 
    77                        debugPrint(DEBUG_LEVEL_SUBUNIT," No internal connection information available.\n"); 
    78          
     78    debugPrint(DEBUG_LEVEL_SUBUNIT," No internal connection information available.\n"); 
     79 
    7980} 
    8081 
     
    8283AvDeviceSubunit::AvDeviceSubunit(AvDevice *parent, unsigned char target, unsigned char  id) 
    8384{ 
    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); 
    115118 
    116119 
     
    124127bool AvDeviceSubunit::isValid() 
    125128{ 
    126        return bValid; 
     129    return bValid; 
    127130} 
    128131 
    129132unsigned char AvDeviceSubunit::getNbDestinationPlugs() { 
    130        return iNbDestinationPlugs; 
     133    return iNbDestinationPlugs; 
    131134} 
    132135 
    133136unsigned char AvDeviceSubunit::getNbSourcePlugs() { 
    134        return iNbSourcePlugs; 
     137    return iNbSourcePlugs; 
    135138} 
    136139 
    137140int AvDeviceSubunit::reserve(unsigned char priority) { 
    138       unsigned char byte; 
    139        quadlet_t request[6]; 
    140        quadlet_t *response; 
    141  
    142        if (!cParent) { 
    143                debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: parent == NULL!\n"); 
    144                bValid=false; 
    145                return -1; 
    146        
    147  
    148        request[0] = AVC1394_CTYPE_CONTROL | ((iTarget & 0x1F) << 19) | ((iId & 0x07) << 16) 
    149                                        | AVC1394_COMMAND_RESERVE | priority; 
    150        request[1] = 0xFFFFFFFF; 
    151        request[2] = 0xFFFFFFFF; 
    152        request[3] = 0xFFFFFFFF; 
    153        response = cParent->avcExecuteTransaction(request, 4, 4); 
    154        if (response != NULL) { 
    155                if((AVC1394_MASK_RESPONSE(response[0]) == AVC1394_RESPONSE_ACCEPTED) || (AVC1394_MASK_RESPONSE(response[0]) == AVC1394_RESPONSE_IMPLEMENTED))  { 
    156                        debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: subunit reserve successfull.\n"); 
    157                        return priority; 
    158                } else { 
    159                        debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: subunit reserve not successfull.\n"); 
    160                        return -1; 
    161                
    162        
    163  
    164 } 
    165   
     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 
    166169int 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 
     199int 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  
    11/* avdevicesubunit.h 
    2  * Copyright (C) 2004 by Pieter Palmers 
     2 * Copyright (C) 2004,05 by Pieter Palmers 
    33 * 
    44 * This file is part of FreeBob. 
     
    2121#include "ieee1394service.h" 
    2222#include "avdevice.h" 
     23#include "debugmodule.h" 
    2324 
    2425#ifndef AVDEVICESUBUNIT_H 
     
    5455    AvDevice *cParent; 
    5556    
    56  private: 
    57  
     57    DECLARE_DEBUG_MODULE; 
    5858}; 
    5959 
  • trunk/freebob/src/avmidiinfoblock.cpp

    r26 r43  
    11/* avmidiinfoblock.cpp 
    2  * Copyright (C) 2004 by Pieter Palmers 
     2 * Copyright (C) 2004,05 by Pieter Palmers 
    33 * 
    44 * This file is part of FreeBob. 
     
    2424#include <libavc1394/avc1394.h> 
    2525#include <libavc1394/avc1394_vcr.h> 
    26 #include "debugmodule.h" 
    2726 
    2827#include "avdescriptor.h" 
     
    3231 
    3332AvMidiInfoBlock::AvMidiInfoBlock(AvDescriptor *parent, int address) : AvInfoBlock(parent,address) { 
     33    setDebugLevel( DEBUG_LEVEL_ALL ); 
    3434        // do some more valid checks 
    3535        if (getType() != 0x8104) { 
    3636                bValid=false; 
    3737        } 
    38          
     38 
    3939        unsigned int nb_streams=readByte(6); 
    4040        unsigned int position=0; 
    4141        AvNameInfoBlock *tmpNameBlock; 
    42          
     42 
    4343        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvMidiInfoBlock: Creating... length=0x%04X\n",getLength()); 
    44          
     44 
    4545        if (nb_streams>0) { 
    4646                position=address+7; 
    4747                for (unsigned int i=0;i<nb_streams;i++) { 
    48                          
     48 
    4949                        tmpNameBlock=new AvNameInfoBlock(parent, position); 
    50                          
     50 
    5151                        if (tmpNameBlock && (tmpNameBlock->isValid())) { 
    5252                                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 
    5454                                // add to child list 
    5555                                cNameInfoBlocks.push_back(tmpNameBlock); 
     
    6060                        } 
    6161                } 
    62                  
     62 
    6363        } 
    6464        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvMidiInfoBlock: Created\n"); 
    65          
     65 
    6666        // no optional info blocks please... 
    67          
     67 
    6868} 
    6969 
    7070AvMidiInfoBlock::~AvMidiInfoBlock() { 
    71          
     71 
    7272        vector<AvNameInfoBlock *>::iterator it; 
    7373        for( it = cNameInfoBlocks.begin(); it != cNameInfoBlocks.end(); it++ ) { 
     
    8787unsigned char *AvMidiInfoBlock::getName(unsigned int streamIdx) { 
    8888        AvNameInfoBlock *tmpNameBlock; 
    89          
     89 
    9090        if ((streamIdx<getNbStreams()) && (streamIdx<cNameInfoBlocks.size())) { 
    9191                tmpNameBlock =cNameInfoBlocks.at(streamIdx); 
  • trunk/freebob/src/avmidiinfoblock.h

    r22 r43  
    11/* avmidiinfoblock.h 
    2  * Copyright (C) 2004 by Pieter Palmers 
     2 * Copyright (C) 2004,05 by Pieter Palmers 
    33 * 
    44 * This file is part of FreeBob. 
     
    2424#include <libavc1394/avc1394_vcr.h> 
    2525#include <vector> 
     26 
    2627using std::vector; 
    2728 
     
    4546protected: 
    4647        vector<AvNameInfoBlock*> cNameInfoBlocks; 
    47 private:         
     48         
     49        DECLARE_DEBUG_MODULE; 
    4850         
    4951}; 
  • trunk/freebob/src/avmusicpluginfoblock.cpp

    r40 r43  
    11/* avmusicpluginfoblock.cpp 
    2  * Copyright (C) 2004 by Pieter Palmers 
     2 * Copyright (C) 2004,05 by Pieter Palmers 
    33 * 
    44 * This file is part of FreeBob. 
     
    2424#include <libavc1394/avc1394.h> 
    2525#include <libavc1394/avc1394_vcr.h> 
    26 #include "debugmodule.h" 
    2726 
    2827#include "avdescriptor.h" 
     
    3231 
    3332AvMusicPlugInfoBlock::AvMusicPlugInfoBlock(AvDescriptor *parent, int address) : AvInfoBlock(parent,address) { 
     33    setDebugLevel( DEBUG_LEVEL_ALL ); 
    3434        // do some more valid checks 
    3535        if (getType() != 0x810B) { 
    3636                bValid=false; 
    3737        } 
    38          
     38 
    3939        unsigned int next_block_position=address+0x06+readWord(0x04); 
    4040        unsigned int plug_type=readByte(0x06); 
    4141        unsigned int plug_id=readWord(0x07); 
    4242        unsigned int routing_support=readByte(0x09); 
    43          
     43 
    4444        unsigned int source_plug_function_type=readByte(0x0A); 
    4545        unsigned int source_plug_id=readByte(0x0B); 
     
    6262                        destination_plug_id,destination_plug_function_block_ID,destination_stream_position,destination_stream_location); 
    6363 
    64          
     64 
    6565        if(next_block_position<address+getLength()) { 
    6666                // parse the optional name block 
     
    6868                if (tmpNameInfoBlock && (tmpNameInfoBlock->isValid())) { 
    6969                        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvMusicPlugInfoBlock:   Name info=%s\n",tmpNameInfoBlock->getName()); 
    70                  
     70 
    7171                } else { 
    7272                        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvMusicPlugInfoBlock:   invalid extra name block present\n"); 
     
    7777                } 
    7878        } 
    79          
    80          
     79 
     80 
    8181        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvMusicPlugInfoBlock: Created\n"); 
    82          
     82 
    8383} 
    8484 
  • trunk/freebob/src/avmusicpluginfoblock.h

    r38 r43  
    11/* avmusicpluginfoblock.h 
    2  * Copyright (C) 2004 by Pieter Palmers 
     2 * Copyright (C) 2004,05 by Pieter Palmers 
    33 * 
    44 * This file is part of FreeBob. 
     
    4747         
    4848protected: 
    49          
    50 private:         
     49        DECLARE_DEBUG_MODULE; 
    5150         
    5251}; 
  • trunk/freebob/src/avnameinfoblock.cpp

    r26 r43  
    11/* avnameinfoblock.cpp 
    2  * Copyright (C) 2004 by Pieter Palmers 
     2 * Copyright (C) 2004,05 by Pieter Palmers 
    33 * 
    44 * This file is part of FreeBob. 
     
    2424#include <libavc1394/avc1394.h> 
    2525#include <libavc1394/avc1394_vcr.h> 
    26 #include "debugmodule.h" 
    2726 
    2827#include "avdescriptor.h" 
     
    3130 
    3231AvNameInfoBlock::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 
    3435        if (getType() != 0x000B) { 
    3536                bValid=false; 
    36         }       
     37        } 
    3738        nameBuffer=NULL; 
    3839 
     
    5354        if (isValid()) { 
    5455                // 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. 
    5657                // PP: for my device apparently one block is sufficient. 
    5758                // PP: one strange thing remains, that is that there are some NULL characters in the buffer. 
     
    5960                // unsigned int type_of_textblock_1=readWord(0x0C); // = 0x000A ? 
    6061                unsigned int primary_field_length_textblock_1=readWord(0x0E); // ?? I guess ?? 
    61                  
     62 
    6263                if (nameBuffer) { 
    6364                        delete nameBuffer; 
    6465                } 
    6566                nameBuffer=new unsigned char[primary_field_length_textblock_1]; 
    66                  
     67 
    6768                if((readlen=readBuffer(0x10,primary_field_length_textblock_1,nameBuffer))<primary_field_length_textblock_1) { 
    6869                        debugPrint (DEBUG_LEVEL_INFOBLOCK, "      truncated????\n"); 
    69                          
     70 
    7071                        nameBuffer[primary_field_length_textblock_1-1]=0; // make sure the string converter doesn't read past the buffer 
    7172                } 
    72                  
     73 
    7374                return nameBuffer; 
    7475        } else { 
  • trunk/freebob/src/avnameinfoblock.h

    r22 r43  
    11/* avnameinfoblock.h 
    2  * Copyright (C) 2004 by Pieter Palmers 
     2 * Copyright (C) 2004,05 by Pieter Palmers 
    33 * 
    44 * This file is part of FreeBob. 
     
    4040protected: 
    4141        unsigned char *nameBuffer; 
    42 private:         
     42        DECLARE_DEBUG_MODULE; 
    4343         
    4444}; 
  • trunk/freebob/src/avoutputplugstatusinfoblock.cpp

    r26 r43  
    11/* avoutputplugstatusinfoblock.cpp 
    2  * Copyright (C) 2004 by Pieter Palmers 
     2 * Copyright (C) 2004,05 by Pieter Palmers 
    33 * 
    44 * This file is part of FreeBob. 
     
    2424#include <libavc1394/avc1394.h> 
    2525#include <libavc1394/avc1394_vcr.h> 
    26 #include "debugmodule.h" 
    2726 
    2827#include "avdescriptor.h" 
     
    3231 
    3332AvOutputPlugStatusInfoBlock::AvOutputPlugStatusInfoBlock(AvDescriptor *parent, int address) : AvInfoBlock(parent,address) { 
     33    setDebugLevel( DEBUG_LEVEL_ALL ); 
    3434        // do some more valid checks 
    3535        if (getType() != 0x8101) { 
    3636                bValid=false; 
    3737        } 
    38          
     38 
    3939        unsigned int next_block_position=address+7; 
    4040        unsigned int nb_sourceplugs=readByte(6); 
     
    4343        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvOutputPlugStatusInfoBlock: Creating... length=0x%04X\n",getLength()); 
    4444        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvOutputPlugStatusInfoBlock:   Number of source plugs=%d\n",nb_sourceplugs); 
    45                  
     45 
    4646        if (nb_sourceplugs>0) { 
    4747                for (unsigned int i=0;i<nb_sourceplugs;i++) { 
    4848                        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvOutputPlugStatusInfoBlock: source plug=%d\n",i); 
    4949                        tmpAvSourcePlugInfoBlock=new AvSourcePlugInfoBlock(parent, next_block_position); 
    50                          
     50 
    5151                        if (tmpAvSourcePlugInfoBlock && (tmpAvSourcePlugInfoBlock->isValid())) { 
    5252                                //debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvOutputPlugStatusInfoBlock: source plug type=0x%04X\n",tmpAvSourcePlugInfoBlock->getType()); 
    5353                                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 
    5555                                // add to child list 
    5656                                cSourcePlugs.push_back(tmpAvSourcePlugInfoBlock); 
    57                                  
     57 
    5858                                tmpAvSourcePlugInfoBlock->printContents(); 
    59                                  
     59 
    6060                        } else { 
    6161                                debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvOutputPlugStatusInfoBlock: Invalid block... parse error!\n"); 
     
    6363                                break; // what to do now? 
    6464                        } 
    65                          
     65 
    6666                } 
    6767        } 
    68          
     68 
    6969        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvOutputPlugStatusInfoBlock: Created\n"); 
    70          
     70 
    7171} 
    7272 
  • trunk/freebob/src/avoutputplugstatusinfoblock.h

    r23 r43  
    11/* avoutputplugstatusinfoblock.h 
    2  * Copyright (C) 2004 by Pieter Palmers 
     2 * Copyright (C) 2004,05 by Pieter Palmers 
    33 * 
    44 * This file is part of FreeBob. 
     
    5050        vector<AvSourcePlugInfoBlock *> cSourcePlugs; 
    5151         
    52 private:         
    53          
     52        DECLARE_DEBUG_MODULE; 
    5453}; 
    5554 
  • trunk/freebob/src/avpluginfoblock.cpp

    r40 r43  
    11/* avpluginfoblock.cpp 
    2  * Copyright (C) 2004 by Pieter Palmers 
     2 * Copyright (C) 2004,05 by Pieter Palmers 
    33 * 
    44 * This file is part of FreeBob. 
     
    2424#include <libavc1394/avc1394.h> 
    2525#include <libavc1394/avc1394_vcr.h> 
    26 #include "debugmodule.h" 
    2726 
    2827#include "avdescriptor.h" 
     
    3332 
    3433AvPlugInfoBlock::AvPlugInfoBlock(AvDescriptor *parent, int address) : AvInfoBlock(parent,address) { 
     34    setDebugLevel( DEBUG_LEVEL_ALL ); 
    3535        // do some more valid checks 
    3636        if (getType() != 0x8109) { 
    3737                bValid=false; 
    3838        } 
    39          
     39 
    4040 
    4141 
     
    4646        unsigned int nb_clusters=readWord(0x0A); 
    4747        unsigned int nb_channels=readWord(0x0C); 
    48          
     48 
    4949        AvClusterInfoBlock *tmpAvClusterInfoBlock=NULL; 
    5050        AvInfoBlock *tmpInfoBlock=NULL; 
    51          
     51 
    5252        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvPlugInfoBlock: Creating... length=0x%04X\n",getLength()); 
    5353        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvPlugInfoBlock:   Subunit plug id=0x%02X\n",subunit_plug_id); 
     
    5757        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvPlugInfoBlock:   Number of channels=%d\n",nb_channels); 
    5858 
    59                  
     59 
    6060        if (nb_clusters>0) { 
    6161                for (unsigned int i=0;i<nb_clusters;i++) { 
    6262                        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvPlugInfoBlock: cluster=%d\n",i); 
    6363                        tmpAvClusterInfoBlock=new AvClusterInfoBlock(parent, next_block_position); 
    64                          
     64 
    6565                        if (tmpAvClusterInfoBlock && (tmpAvClusterInfoBlock->isValid())) { 
    6666 
    6767                                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 
    6969                                // add to child list 
    7070                                cClusterInfoBlocks.push_back(tmpAvClusterInfoBlock); 
    71                                  
     71 
    7272                                //tmpAvPlugInfoBlock->printContents(); 
    73                                  
     73 
    7474                        } else { 
    7575                                debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvPlugInfoBlock: Invalid block... parse error!\n"); 
     
    8181                                break; // what to do now? 
    8282                        } 
    83                          
     83 
    8484                } 
    8585        } 
    86          
     86 
    8787        if(next_block_position<address+getLength()) { 
    8888                // parse the optional name block 
     
    9090                if (tmpInfoBlock && (tmpInfoBlock->isValid())) { 
    9191                        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvPlugInfoBlock:   extra block of type=0x%04X present\n",tmpInfoBlock->getType()); 
    92                  
     92 
    9393                } else { 
    9494                        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvPlugInfoBlock:   invalid extra block present\n"); 
     
    9898                        tmpInfoBlock=NULL; 
    9999                } 
    100          
     100 
    101101        } 
    102          
     102 
    103103        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvPlugInfoBlock: Created\n"); 
    104          
     104 
    105105} 
    106106 
     
    113113 
    114114} 
    115          
     115 
    116116AvClusterInfoBlock *AvPlugInfoBlock::getCluster(unsigned int idx) { 
    117117        if ((idx < getNbClusters()) && (idx < cClusterInfoBlocks.size())) { 
  • trunk/freebob/src/avpluginfoblock.h

    r40 r43  
    11/* avpluginfoblock.h 
    2  * Copyright (C) 2004 by Pieter Palmers 
     2 * Copyright (C) 2004,05 by Pieter Palmers 
    33 * 
    44 * This file is part of FreeBob. 
     
    5959protected: 
    6060        vector<AvClusterInfoBlock *> cClusterInfoBlocks; 
    61 private:         
    62          
     61 
     62        DECLARE_DEBUG_MODULE;   
    6363}; 
    6464 
  • trunk/freebob/src/avroutingstatusinfoblock.cpp

    r40 r43  
    11/* avroutingstatusinfoblock.cpp 
    2  * Copyright (C) 2004 by Pieter Palmers 
     2 * Copyright (C) 2004,05 by Pieter Palmers 
    33 * 
    44 * This file is part of FreeBob. 
     
    2424#include <libavc1394/avc1394.h> 
    2525#include <libavc1394/avc1394_vcr.h> 
    26 #include "debugmodule.h" 
    2726 
    2827#include "avdescriptor.h" 
     
    3433 
    3534AvRoutingStatusInfoBlock::AvRoutingStatusInfoBlock(AvDescriptor *parent, int address) : AvInfoBlock(parent,address) { 
     35    setDebugLevel( DEBUG_LEVEL_ALL ); 
    3636        // do some more valid checks 
    3737        if (getType() != 0x8108) { 
     
    5555                        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvRoutingStatusInfoBlock: destination plug=%d\n",i); 
    5656                        tmpAvPlugInfoBlock=new AvPlugInfoBlock(parent, next_block_position); 
    57                          
     57 
    5858                        if (tmpAvPlugInfoBlock && (tmpAvPlugInfoBlock->isValid())) { 
    5959                                //debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvOutputPlugStatusInfoBlock: source plug type=0x%04X\n",tmpAvSourcePlugInfoBlock->getType()); 
    6060                                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 
    6262                                // add to child list 
    6363                                cDestinationPlugInfoBlocks.push_back(tmpAvPlugInfoBlock); 
    64                                  
     64 
    6565                                //tmpAvPlugInfoBlock->printContents(); 
    66                                  
     66 
    6767                        } else { 
    6868                                debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvRoutingStatusInfoBlock: Invalid block... parse error!\n"); 
     
    7474                                break; // what to do now? 
    7575                        } 
    76                          
     76 
    7777                } 
    7878        } 
    79          
     79 
    8080        if (nb_source_plugs>0) { 
    8181                for (unsigned int i=0;i<nb_source_plugs;i++) { 
    8282                        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvRoutingStatusInfoBlock: source plug=%d\n",i); 
    8383                        tmpAvPlugInfoBlock=new AvPlugInfoBlock(parent, next_block_position); 
    84                          
     84 
    8585                        if (tmpAvPlugInfoBlock && (tmpAvPlugInfoBlock->isValid())) { 
    8686                                //debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvOutputPlugStatusInfoBlock: source plug type=0x%04X\n",tmpAvSourcePlugInfoBlock->getType()); 
    8787                                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 
    8989                                // add to child list 
    9090                                cSourcePlugInfoBlocks.push_back(tmpAvPlugInfoBlock); 
    91                                  
     91 
    9292                                //tmpAvPlugInfoBlock->printContents(); 
    93                                  
     93 
    9494                        } else { 
    9595                                debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvRoutingStatusInfoBlock: Invalid block... parse error!\n"); 
     
    101101                                break; // what to do now? 
    102102                        } 
    103                          
     103 
    104104                } 
    105105        } 
    106          
     106 
    107107        if (nb_music_plugs>0) { 
    108108                for (unsigned int i=0;i<nb_music_plugs;i++) { 
    109109                        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvRoutingStatusInfoBlock: music plug=%d\n",i); 
    110110                        tmpAvMusicPlugInfoBlock=new AvMusicPlugInfoBlock(parent, next_block_position); 
    111                          
     111 
    112112                        if (tmpAvMusicPlugInfoBlock && (tmpAvMusicPlugInfoBlock->isValid())) { 
    113113                                //debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvOutputPlugStatusInfoBlock: source plug type=0x%04X\n",tmpAvSourcePlugInfoBlock->getType()); 
    114114                                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 
    116116                                // add to child list 
    117117                                cMusicPlugInfoBlocks.push_back(tmpAvMusicPlugInfoBlock); 
    118                                  
     118 
    119119                                //tmpAvPlugInfoBlock->printContents(); 
    120                                  
     120 
    121121                        } else { 
    122122                                debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvRoutingStatusInfoBlock: Invalid block... parse error!\n"); 
     
    128128                                break; // what to do now? 
    129129                        } 
    130                          
     130 
    131131                } 
    132         }                       
     132        } 
    133133 
    134          
     134 
    135135        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvRoutingStatusInfoBlock: Created\n"); 
    136          
     136 
    137137} 
    138138 
  • trunk/freebob/src/avroutingstatusinfoblock.h

    r40 r43  
    11/* avroutingstatusinfoblock.h 
    2  * Copyright (C) 2004 by Pieter Palmers 
     2 * Copyright (C) 2004,05 by Pieter Palmers 
    33 * 
    44 * This file is part of FreeBob. 
     
    5555        vector<AvMusicPlugInfoBlock *> cMusicPlugInfoBlocks; 
    5656         
    57 private:         
     57        DECLARE_DEBUG_MODULE; 
    5858         
    5959}; 
  • trunk/freebob/src/avsourcepluginfoblock.cpp

    r38 r43  
    11/* avsourcepluginfoblock.cpp 
    2  * Copyright (C) 2004 by Pieter Palmers 
     2 * Copyright (C) 2004,05 by Pieter Palmers 
    33 * 
    44 * This file is part of FreeBob. 
     
    2424#include <libavc1394/avc1394.h> 
    2525#include <libavc1394/avc1394_vcr.h> 
    26 #include "debugmodule.h" 
    2726 
    2827#include "avdescriptor.h" 
     
    3231 
    3332AvSourcePlugInfoBlock::AvSourcePlugInfoBlock(AvDescriptor *parent, int address) : AvInfoBlock(parent,address) { 
     33    setDebugLevel( DEBUG_LEVEL_ALL ); 
    3434        // do some more valid checks 
    3535        if (getType() != 0x8102) { 
    3636                bValid=false; 
    3737        } 
    38          
     38 
    3939        unsigned int next_block_position=address+7; 
    40          
     40 
    4141        AvInfoBlock *tmpInfoBlock=NULL; 
    42          
     42 
    4343        cAudioInfoBlock=NULL; 
    4444        cMidiInfoBlock=NULL; 
    4545        cAudioSyncInfoBlock=NULL; 
    46          
     46 
    4747        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvSourcePlugInfoBlock: Creating... length=0x%04X\n",getLength()); 
    4848 
     
    5252 
    5353                tmpInfoBlock=new AvInfoBlock(parent,next_block_position); 
    54                  
     54 
    5555                debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvSourcePlugInfoBlock: testing tmpInfoBlock\n"); 
    5656                if (tmpInfoBlock && tmpInfoBlock->isValid()) { 
     
    9292                                        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvSourcePlugInfoBlock: Skipping unknown block type 0x%04X\n",tmpInfoBlock->getType()); 
    9393                                break; 
    94                                  
     94 
    9595                        } 
    9696                        // update the block position pointer 
    9797                        next_block_position+=tmpInfoBlock->getLength()+2; 
    9898                        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvSourcePlugInfoBlock: Advancing to position=0x%04X\n",next_block_position); 
    99                          
     99 
    100100                } else { 
    101101                        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvSourcePlugInfoBlock: Parse error!\n"); 
     
    103103                        break; 
    104104                } 
    105                  
     105 
    106106                if (tmpInfoBlock) { 
    107107                        delete tmpInfoBlock; 
     
    109109                } 
    110110        } 
    111          
     111 
    112112        if (tmpInfoBlock) { 
    113113                delete tmpInfoBlock; 
    114114                tmpInfoBlock=NULL; 
    115115        } 
    116          
     116 
    117117        debugPrint(DEBUG_LEVEL_INFOBLOCK,"AvSourcePlugInfoBlock: Created\n"); 
    118          
     118 
    119119} 
    120120 
  • trunk/freebob/src/avsourcepluginfoblock.h

    r24 r43  
    11/* avsourcepluginfoblock.h 
    2  * Copyright (C) 2004 by Pieter Palmers 
     2 * Copyright (C) 2004,05 by Pieter Palmers 
    33 * 
    44 * This file is part of FreeBob. 
     
    5454        AvAudioSyncInfoBlock * cAudioSyncInfoBlock; 
    5555         
    56 private:         
    57          
     56        DECLARE_DEBUG_MODULE; 
    5857}; 
    5958 
  • trunk/freebob/src/cmhandler.cpp

    r15 r43  
    2121#include "cmhandler.h" 
    2222#include "ieee1394service.h" 
    23 #include "debugmodule.h" 
    2423 
    2524CMHandler* CMHandler::m_pInstance = 0; 
     
    2827    : m_bInitialised( false ) 
    2928{ 
     29    setDebugLevel( DEBUG_LEVEL_ALL ); 
    3030} 
    3131 
  • trunk/freebob/src/cmhandler.h

    r32 r43  
    2323 
    2424#include "freebob.h" 
     25#include "debugmodule.h" 
    2526 
    2627class Ieee1394Service; 
     
    4041    Ieee1394Service* m_pIeee1394Service; 
    4142    bool m_bInitialised; 
     43 
     44    DECLARE_DEBUG_MODULE; 
    4245}; 
    4346 
  • trunk/freebob/src/debugmodule.cpp

    r18 r43  
    1 /* debugmodule.h 
    2  * Copyright (C) 2004 by Pieter Palmers 
     1/* debugmodule.cpp 
     2 * Copyright (C) 2004,05 by Pieter Palmers, Daniel Wagner 
    33 * 
    44 * This file is part of FreeBob. 
     
    1818 * MA 02111-1307 USA. 
    1919 */ 
     20#include <stdarg.h> 
    2021#include "debugmodule.h" 
    2122 
    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//////////////////////////////////////////////////////////////// 
     29DebugBase::DebugBase() 
     30  : m_level( 0 ) 
     31{} 
     32 
     33DebugBase::~DebugBase() 
     34{} 
     35 
     36//////////////////////////////////////////////////////////////// 
     37DebugStandard::DebugStandard() 
     38    : DebugBase() 
     39{} 
     40 
     41DebugStandard::~DebugStandard() 
     42{} 
     43 
     44void 
     45DebugStandard::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 
     58void 
     59DebugStandard::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 
     75void 
     76DebugStandard::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//////////////////////////////////////////////////////////////// 
     89DebugAnsiColor::DebugAnsiColor() 
     90    : DebugBase() 
     91{} 
     92 
     93DebugAnsiColor::~DebugAnsiColor() 
     94{} 
     95 
     96void 
     97DebugAnsiColor::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 
     112void 
     113DebugAnsiColor::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 
     131void 
     132DebugAnsiColor::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 
     146const char* 
     147DebugAnsiColor::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//////////////////////////////////////////////////////////////// 
     177DebugHtml::DebugHtml() 
     178    : DebugBase() 
     179{} 
     180 
     181DebugHtml::~DebugHtml() 
     182{} 
     183 
     184void 
     185DebugHtml::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 
     200void 
     201DebugHtml::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 
     219void 
     220DebugHtml::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 
     233const char* 
     234DebugHtml::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 
     264unsigned char 
     265toAscii( 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 
    32275 * not implemented optimally, but clear 
    33276 */ 
    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 
     277void 
     278quadlet2char( 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 
     286void 
     287hexDump( 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  
    11/* debugmodule.h 
    2  * Copyright (C) 2004 by Daniel Wagner 
     2 * Copyright (C) 2004,05 by Daniel Wagner, Pieter Palmers 
    33 * 
    44 * This file is part of FreeBob. 
     
    2323 
    2424#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> 
    2926 
    3027// debug print control flags 
     
    4239#define DEBUG_LEVEL_HIGH     (DEBUG_LEVEL_MODERATE | DEBUG_LEVEL_DESCRIPTOR | DEBUG_LEVEL_INFOBLOCK) 
    4340 
    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 
     41unsigned char toAscii( unsigned char c ); 
     42void quadlet2char( quadlet_t quadlet, unsigned char* buff ); 
     43void hexDump( unsigned char *data_start, unsigned int length ); 
     44 
     45class 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 
     69class 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 
     87class 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 
     108class 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}; 
    50128 
    51129#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_ANSICOLORED 
    57130 
    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 ) 
    62135 
    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 
    89139 
    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 */ 
    136141 
    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 */ 
    140151 
    141152#endif 
  • trunk/freebob/src/freebob.h

    r16 r43  
    3333  eFBRC_InitializeCMHandlerFailed    =  -5, 
    3434  eFBRC_AvDeviceNotFound             =  -6, 
     35  eFBRC_CreatingAvDeviceFailed       =  -7, 
    3536} FBReturnCodes; 
    3637 
  • trunk/freebob/src/ieee1394service.cpp

    r42 r43  
    2626#include "ieee1394service.h" 
    2727#include "threads.h" 
    28 #include "debugmodule.h" 
    2928#include "avdevicepool.h" 
    3029 
     
    5049    , m_iGenerationCount( 0 ) 
    5150{ 
     51    setDebugLevel( DEBUG_LEVEL_ALL ); 
    5252    pthread_mutex_init( &m_mutex, NULL ); 
    5353} 
     
    140140        switch (rom1394_get_node_type( &romDir )) { 
    141141        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 ); 
    144144            break; 
    145145        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 ); 
    148148            break; 
    149149        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 ); 
    152152            printAvcUnitInfo( iNodeId ); 
    153153 
    154154            if ( avc1394_check_subunit_type( m_handle, iNodeId, 
    155155                                             AVC1394_SUBUNIT_TYPE_AUDIO ) ) { 
    156  
    157156                octlet_t oGuid = rom1394_get_guid( m_handle, iNodeId ); 
    158                 AvDevice* pAvDevice 
    159                     = AvDevicePool::instance()->getAvDevice( oGuid ); 
     157 
     158                AvDevice* pAvDevice = new AvDevice( oGuid ); 
    160159                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; 
    162166                } 
    163167                pAvDevice->setNodeId( iNodeId ); 
    164168                pAvDevice->setPort( m_iPort ); 
    165169 
    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; 
    177179                } 
    178180 
    179181                // XXX Pieter's test code. 
    180                 avDeviceTests( oGuid, m_iPort, iNodeId ); 
     182//                avDeviceTests( oGuid, m_iPort, iNodeId ); 
    181183            } 
    182184            break; 
     
    194196        } 
    195197    } 
    196  
    197     AvDevicePool::instance()->removeObsoleteDevices( iGeneration ); 
     198    // XXX dw: removed: AvDevicePool::instance()->removeObsoleteDevices() 
     199    // check if this is still code here is still correct. 
    198200    return eFBRC_Success; 
    199201} 
     
    337339                               unsigned int iGeneration ) 
    338340{ 
    339     debugPrint( DEBUG_LEVEL_INFO, 
    340                 "Bus reset has occurred (generation = %d).\n", iGeneration ); 
    341341    raw1394_update_generation (handle, iGeneration); 
    342342    Ieee1394Service* pInstance 
     
    344344    pInstance->setGenerationCount( iGeneration ); 
    345345 
    346     // dw: let's rescan the bus.  this might not the correct order 
    347     // of commands. 
    348346    asyncCall( pInstance, &Ieee1394Service::discoveryDevices, iGeneration ); 
    349347    return 0; 
  • trunk/freebob/src/ieee1394service.h

    r42 r43  
    2626 
    2727#include "freebob.h" 
     28#include "debugmodule.h" 
    2829 
    2930/* 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) 
    5231 
    5332class Ieee1394Service { 
     
    8766    bool m_bRHThreadRunning; 
    8867    unsigned int m_iGenerationCount; 
     68 
     69    DECLARE_DEBUG_MODULE; 
    8970}; 
    9071 
  • trunk/freebob/src/streamprocess.cpp

    r30 r43  
    2222 
    2323#include "streamprocess.h" 
    24 #include "debugmodule.h" 
    2524 
    2625StreamProcess::StreamProcess() 
    2726    : m_pCMHandler( 0 ) 
    2827{ 
     28    setDebugLevel( DEBUG_LEVEL_ALL ); 
    2929} 
    3030 
  • trunk/freebob/src/streamprocess.h

    r14 r43  
    2323 
    2424#include "cmhandler.h" 
     25#include "debugmodule.h" 
    2526 
    2627/** StreamProcess 
     
    3536 private: 
    3637    CMHandler* m_pCMHandler; 
     38     
     39    DECLARE_DEBUG_MODULE; 
    3740}; 
    3841 
  • trunk/freebob/src/workerthread.cpp

    r37 r43  
    11/* workerthread.cpp 
    2  * Copyright (C) 2004 by Daniel Wagner 
     2 * Copyright (C) 2004,05 by Daniel Wagner 
    33 * 
    44 * This file is part of FreeBob. 
     
    2121#include "threads.h" 
    2222#include "workerthread.h" 
    23 #include "debugmodule.h" 
    2423 
    2524WorkerThread* WorkerThread::m_pInstance = 0; 
     
    2726WorkerThread::WorkerThread() 
    2827{ 
     28    setDebugLevel( DEBUG_LEVEL_ALL ); 
     29 
    2930    pthread_create( &m_thread, NULL, workerThread, this ); 
    3031    pthread_mutex_init( &m_mutex, NULL ); 
     
    5152    // because the hole driver is single threaded... 
    5253    if ( !m_pInstance ) { 
    53         debugPrint( DEBUG_LEVEL_INFO,  "WorkerThread instance created.\n" ); 
    5454        m_pInstance = new WorkerThread(); 
    5555    } 
     
    9494WorkerThread::workerThread( void* arg ) 
    9595{ 
    96     debugPrint( DEBUG_LEVEL_INFO, "Starting WorkerThread main loop.\n" ); 
    9796    WorkerThread* pWorkerThread = ( WorkerThread* ) arg; 
    9897    pWorkerThread->run(); 
    99     debugPrint( DEBUG_LEVEL_INFO, "WorkerThread main loop exited.\n" ); 
    10098    return NULL; 
    10199} 
  • trunk/freebob/src/workerthread.h

    r34 r43  
    11/* workerthread.h 
    2  * Copyright (C) 2004 by Daniel Wagner 
     2 * Copyright (C) 2004,05 by Daniel Wagner 
    33 * 
    44 * This file is part of FreeBob. 
     
    2222 
    2323#include <queue> 
    24  
    2524#include <pthread.h> 
     25#include "debugmodule.h" 
    2626 
    2727class Functor; 
     
    4747    pthread_cond_t m_cond; 
    4848    std::queue< Functor* > m_queue; 
     49 
     50    DECLARE_DEBUG_MODULE; 
    4951}; 
    5052 
  • 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 
    121#include <libavc1394/rom1394.h> 
    222#include <libavc1394/avc1394.h>