Changeset 24

Show
Ignore:
Timestamp:
11/27/04 08:21:40 (19 years ago)
Author:
pieterpalmers
Message:

- bugfix: descriptor was not read correctly in AvDescriptor?
- several other small bugfixes/cleanups
- fix compiler warnings
- added some extra debug statements to follow parser flow

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/freebob/src/avdescriptor.cpp

    r22 r24  
    168168        aContents=new unsigned char[iLength]; 
    169169         
     170        /* there is a gap in the read data, because of the two bytes  
     171         * that are before the third quadlet (why did 1394TA do that?) 
     172         *  
     173         * proposed solution: 
     174         * 1) the first read is OK, because the length of the descriptor is in these two bytes, 
     175         *    so execute a read from address 0 with length=iLength 
     176         * 2) process the bytes starting from response[3] 
     177         * 3) the next reads should start from the end of the previous read minus 2. this way we  
     178         *    can discard these two problem bytes, because they are already read in the previous  
     179         *    run. 
     180         */ 
     181         
     182        // first read 
     183        if(bytes_read<iLength) { 
     184                fprintf(stderr,".");     
     185                // apparently the lib modifies the request, so redefine it completely 
     186                request[0] = AVC1394_CTYPE_CONTROL | qTarget 
     187                                                | AVC1394_COMMAND_READ_DESCRIPTOR | (iType & 0xFF); 
     188                // the amount of bytes we want to read is: 
     189                //  total descriptor length + 2 bytes of the descriptor length field (i.e. the overlap bytes for this read) 
     190                request[1] = 0xFFFF0000 | (iLength)&0xFFFF; 
     191                request[2] = ((0) << 16) |0x0000FFFF; 
     192                 
     193                response =  cParent->avcExecuteTransaction(request, 3, 3); 
     194                data_length_read=(response[1]&0xFFFF); 
     195                read_result_status=((response[1]>>24)&0xFF); 
     196                 
     197                databuffer=(unsigned char *)(response+3); 
     198                 
     199                // the buffer starting at databuffer is two bytes smaller that the amount of bytes read 
     200                for (i=0;(i<data_length_read-2) && (bytes_read < iLength);i++) { 
     201                        *(aContents+bytes_read)=*(databuffer+i); 
     202                        bytes_read++; 
     203                } 
     204                 
     205        } 
     206         
     207        // now do the remaining reads 
    170208        while(bytes_read<iLength) { 
    171209                fprintf(stderr,".");     
     
    173211                request[0] = AVC1394_CTYPE_CONTROL | qTarget 
    174212                                                | AVC1394_COMMAND_READ_DESCRIPTOR | (iType & 0xFF); 
    175                 request[1] = 0xFFFF0000 | (iLength-bytes_read)&0xFFFF; 
     213                // the amount of bytes we want to read is: 
     214                //  (total descriptor length - number of bytes already read) + 2 overlap with previous read 
     215                request[1] = 0xFFFF0000 | (iLength-bytes_read+2)&0xFFFF; 
    176216                request[2] = (((bytes_read)&0xFFFF) << 16) |0x0000FFFF; 
     217                 
    177218                response =  cParent->avcExecuteTransaction(request, 3, 3); 
    178219                data_length_read=(response[1]&0xFFFF); 
    179220                read_result_status=((response[1]>>24)&0xFF); 
     221                 
    180222                databuffer=(unsigned char *)(response+3); 
    181223                 
    182                 for (i=0;(i<data_length_read) && (bytes_read < iLength);i++) { 
     224                for (i=0;(i<data_length_read-2) && (bytes_read < iLength);i++) { 
    183225                        *(aContents+bytes_read)=*(databuffer+i); 
    184226                        bytes_read++; 
    185227                } 
     228                 
    186229        } 
    187230        fprintf(stderr,"\n");    
     
    256299        } 
    257300} 
    258     
  • trunk/freebob/src/avmusicstatusdescriptor.cpp

    r21 r24  
    5858        // PP: calculate the offset to accomodate for the presence of root lists [not implemented] 
    5959         
    60         int offset=2; // update offset when beginning at a new table in the specs for easy reading 
     60        //int offset=2; // update offset when beginning at a new table in the specs for easy reading 
    6161         
    6262        // start parsing the optional capability stuff 
  • trunk/freebob/src/avnameinfoblock.cpp

    r22 r24  
    5050        // PP: Can't find this in the specs I have... going to look around a bit for the spec this is in. 
    5151        //     (AV/C Information Block Types Specification Version 1.0) 
    52         unsigned int namelen; 
    5352        unsigned int readlen=0; 
    5453        if (isValid()) { 
     
    5756                // PP: for my device apparently one block is sufficient. 
    5857                // PP: one strange thing remains, that is that there are some NULL characters in the buffer. 
    59                 unsigned int length_of_textblock_1=readWord(0x0A); 
    60                 unsigned int type_of_textblock_1=readWord(0x0C); // = 0x000A ? 
     58                // unsigned int length_of_textblock_1=readWord(0x0A); 
     59                // unsigned int type_of_textblock_1=readWord(0x0C); // = 0x000A ? 
    6160                unsigned int primary_field_length_textblock_1=readWord(0x0E); // ?? I guess ?? 
    6261                 
  • trunk/freebob/src/avoutputplugstatusinfoblock.cpp

    r23 r24  
    4242 
    4343        debugPrint(DEBUG_LEVEL_INFO,"AvOutputPlugStatusInfoBlock: Creating... length=0x%04X\n",getLength()); 
     44        debugPrint(DEBUG_LEVEL_INFO,"AvOutputPlugStatusInfoBlock:   Number of source plugs=%d\n",nb_sourceplugs); 
    4445                 
    4546        if (nb_sourceplugs>0) { 
    4647                for (unsigned int i=0;i<nb_sourceplugs;i++) { 
     48                        debugPrint(DEBUG_LEVEL_INFO,"AvOutputPlugStatusInfoBlock: source plug=%d\n",i); 
    4749                        tmpAvSourcePlugInfoBlock=new AvSourcePlugInfoBlock(parent, next_block_position); 
    4850                         
    4951                        if (tmpAvSourcePlugInfoBlock && (tmpAvSourcePlugInfoBlock->isValid())) { 
     52                                //debugPrint(DEBUG_LEVEL_INFO,"AvOutputPlugStatusInfoBlock: source plug type=0x%04X\n",tmpAvSourcePlugInfoBlock->getType()); 
    5053                                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; 
    5154                                 
    5255                                // add to child list 
    5356                                cSourcePlugs.push_back(tmpAvSourcePlugInfoBlock); 
     57                                 
     58                                tmpAvSourcePlugInfoBlock->printContents(); 
     59                                 
    5460                        } else { 
    5561                                debugPrint(DEBUG_LEVEL_INFO,"AvOutputPlugStatusInfoBlock: Invalid block... parse error!\n"); 
  • trunk/freebob/src/avsourcepluginfoblock.cpp

    r23 r24  
    4848 
    4949        // parse the child info blocks 
    50         while ((next_block_position<getLength())) { 
     50        while ((next_block_position<address+getLength())) { 
    5151                debugPrint(DEBUG_LEVEL_INFO,"AvSourcePlugInfoBlock: Creating tmpInfoBlock\n"); 
    5252 
     
    132132        } 
    133133} 
     134 
     135void AvSourcePlugInfoBlock::printContents() { 
     136        if(cAudioInfoBlock) { 
     137                debugPrint(DEBUG_LEVEL_INFO,"AvSourcePlugInfoBlock: AudioInfoBlock: %s\n",cAudioInfoBlock->getName()); 
     138        } 
     139        if(cMidiInfoBlock) { 
     140                debugPrint(DEBUG_LEVEL_INFO,"AvSourcePlugInfoBlock: MidiInfoBlock %d streams\n",cMidiInfoBlock->getNbStreams()); 
     141                for (unsigned int i=0;i<cMidiInfoBlock->getNbStreams();i++) { 
     142                        debugPrint(DEBUG_LEVEL_INFO,"AvSourcePlugInfoBlock: MidiInfoBlock stream %d: %s\n",i,cMidiInfoBlock->getName(i)); 
     143                } 
     144        } 
     145        if(cAudioSyncInfoBlock) { 
     146                debugPrint(DEBUG_LEVEL_INFO,"AvSourcePlugInfoBlock: AudioSyncInfoBlock can sync to: Bus? %s / External? %s\n", 
     147                        cAudioSyncInfoBlock->canSyncBus()?"yes":"no", 
     148                        cAudioSyncInfoBlock->canSyncExternal()?"yes":"no" 
     149                        ); 
     150        } 
     151} 
  • trunk/freebob/src/avsourcepluginfoblock.h

    r23 r24  
    4545        unsigned int getPlugNumber(); 
    4646 
     47        void printContents(); // to debug the parse process 
     48         
    4749protected: 
    4850        //vector<AvNameInfoBlock*> cNameInfoBlocks; 
  • trunk/freebob/src/ieee1394service.cpp

    r23 r24  
    272272                        debugPrint (DEBUG_LEVEL_INFO, "    Trying to create an AvMidiInfoBlock...\n"); 
    273273 
    274                         AvMidiInfoBlock *testblock5=new AvMidiInfoBlock(testdesc_mid2,0x097); 
     274                        AvMidiInfoBlock *testblock5=new AvMidiInfoBlock(testdesc_mid2,0x099); 
    275275                        debugPrint (DEBUG_LEVEL_INFO, "     isValid? %s\n",(testblock5->isValid()?"yes":"no")); 
    276276                        debugPrint (DEBUG_LEVEL_INFO, "      Length? 0x%04X (%d)\n",testblock5->getLength(),testblock5->getLength()); 
     
    282282                         
    283283                        debugPrint (DEBUG_LEVEL_INFO, "    Trying to create an AvAudioSyncInfoBlock...\n"); 
    284                         AvAudioSyncInfoBlock *testblock6=new AvAudioSyncInfoBlock(testdesc_mid2,0x0260); 
     284                        AvAudioSyncInfoBlock *testblock6=new AvAudioSyncInfoBlock(testdesc_mid2,0x0262); 
    285285                        debugPrint (DEBUG_LEVEL_INFO, "     isValid? %s\n",(testblock6->isValid()?"yes":"no")); 
    286286                        debugPrint (DEBUG_LEVEL_INFO, "      canSyncBus? %s\n",(testblock6->canSyncBus()?"yes":"no"));