Changeset 25

Show
Ignore:
Timestamp:
11/27/04 08:55:32 (18 years ago)
Author:
pieterpalmers
Message:

- updated the AvMusicStatusDescriptor? to automatically parse itself upon creation

Files:

Legend:

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

    r24 r25  
    4242        bOpen=false; 
    4343        iAccessType=0; 
     44        bValid=false; // don't know yet what I'm going to do with this in the generic descriptor 
    4445} 
    4546 
     
    248249        if (((response[0] & 0xFF000000)==AVC1394_RESPONSE_NOT_IMPLEMENTED) || ((response[1] & 0xFF000000)==0x04)) {  
    249250                fprintf(stderr,"Descriptor not present.\n"); 
     251                bValid=false; 
    250252                return false; 
    251253        }  
     
    263265        return bLoaded; 
    264266} 
     267 
     268bool AvDescriptor::isValid() { 
     269        return bValid; 
     270} 
     271 
    265272 
    266273unsigned int AvDescriptor::getLength() { 
  • trunk/freebob/src/avdescriptor.h

    r21 r25  
    4141    bool isOpen(); 
    4242    bool canWrite(); 
     43    bool isValid(); 
    4344     
    4445 protected: 
     
    4849    bool bLoaded; 
    4950    bool bOpen; 
     51    bool bValid; 
    5052    unsigned int iAccessType; 
    5153    unsigned int iLength; 
  • trunk/freebob/src/avmusicstatusdescriptor.cpp

    r24 r25  
    2121#include "avdevice.h" 
    2222#include "avdescriptor.h" 
     23#include "avmusicidentifierdescriptor.h" 
    2324#include "avmusicstatusdescriptor.h" 
     25#include "avinfoblock.h" 
     26#include "avgeneralmusicstatusinfoblock.h" 
     27#include "avnameinfoblock.h" 
     28#include "avaudioinfoblock.h" 
     29#include "avmidiinfoblock.h" 
     30#include "avaudiosyncinfoblock.h" 
     31#include "avsourcepluginfoblock.h" 
     32#include "avoutputplugstatusinfoblock.h" 
    2433 
    2534AvMusicStatusDescriptor::AvMusicStatusDescriptor(AvDevice *parent) : AvDescriptor(parent, AVC1394_SUBUNIT_TYPE_MUSIC | AVC1394_SUBUNIT_ID_0,0x80) { 
     
    3847         
    3948        if (!(this->AvDescriptor::isOpen())) { 
    40                 fprintf(stderr,"AvMusicStatusDescriptor: Opening descriptor...\n"); 
     49                debugPrint (DEBUG_LEVEL_INFO, "AvMusicStatusDescriptor: Opening descriptor...\n"); 
    4150                this->AvDescriptor::OpenReadOnly(); 
    4251                if (!(this->AvDescriptor::isOpen()) ) { 
    4352                        fprintf(stderr,"AvMusicStatusDescriptor:   Failed!\n"); 
     53                        bValid=false; 
    4454                        return; 
    4555                } 
     
    4757         
    4858        if (!(this->AvDescriptor::isLoaded())) { 
    49                 fprintf(stderr,"AvMusicStatusDescriptor: Loading descriptor...\n"); 
     59                debugPrint (DEBUG_LEVEL_INFO, "AvMusicStatusDescriptor: Loading descriptor...\n"); 
    5060                this->AvDescriptor::Load(); 
    5161                if (!(this->AvDescriptor::isLoaded())) { 
    5262                        fprintf(stderr,"AvMusicStatusDescriptor:   Failed!\n"); 
     63                        bValid=false; 
    5364                        return; 
    5465                } 
    5566        } 
    5667         
    57         fprintf(stderr,"AvMusicStatusDescriptor: \n"); 
    58         // PP: calculate the offset to accomodate for the presence of root lists [not implemented] 
     68        unsigned int offset=0; // update offset when beginning at a new table in the specs for easy reading 
     69        cGeneralMusicInfoBlock=NULL; 
     70        cOutputPlugStatusInfoBlock=NULL; 
    5971         
    60         //int offset=2; // update offset when beginning at a new table in the specs for easy reading 
     72        debugPrint (DEBUG_LEVEL_INFO, "AvMusicStatusDescriptor: Creating AvGeneralMusicStatusInfoBlock... (offset=0x%04X)\n",offset); 
     73        cGeneralMusicInfoBlock=new AvGeneralMusicInfoBlock(this,offset); 
     74        if (!(cGeneralMusicInfoBlock) || !(cGeneralMusicInfoBlock->isValid())) { 
     75                debugPrint (DEBUG_LEVEL_INFO, "AvMusicStatusDescriptor:  AvGeneralMusicStatusInfoBlock not found!\n"); 
     76                bValid=false; 
     77                return; 
     78        } 
     79        debugPrint (DEBUG_LEVEL_INFO, "AvMusicStatusDescriptor:  AvGeneralMusicStatusInfoBlock found: length=0x%04X\n",cGeneralMusicInfoBlock->getLength()); 
    6180         
    62         // start parsing the optional capability stuff 
     81        offset += cGeneralMusicInfoBlock->getLength()+2; 
     82         
     83         
     84        debugPrint (DEBUG_LEVEL_INFO, "AvMusicStatusDescriptor: Creating AvOutputPlugStatusInfoBlock... (offset=0x%04X)\n",offset); 
     85        cOutputPlugStatusInfoBlock=new AvOutputPlugStatusInfoBlock(this,offset); 
     86        if (!(cOutputPlugStatusInfoBlock) || !(cOutputPlugStatusInfoBlock->isValid())) { 
     87                debugPrint (DEBUG_LEVEL_INFO, "AvMusicStatusDescriptor:  AvOutputPlugStatusInfoBlock not found!\n"); 
     88                bValid=false; 
     89                return; 
     90        } 
     91        debugPrint (DEBUG_LEVEL_INFO, "AvMusicStatusDescriptor:  AvOutputPlugStatusInfoBlock found: length=0x%04X\n",cOutputPlugStatusInfoBlock->getLength()); 
     92         
     93        offset += cOutputPlugStatusInfoBlock->getLength()+2; 
     94         
     95        // start parsing the optional infoblock(s) 
     96        AvInfoBlock *tmpInfoBlock = NULL; 
     97        debugPrint (DEBUG_LEVEL_INFO, "AvMusicStatusDescriptor: Parsing optional infoblocks...\n"); 
     98         
     99        while (offset < getLength()) { 
     100                debugPrint (DEBUG_LEVEL_INFO, "AvMusicStatusDescriptor:  Optional block found...\n"); 
     101                tmpInfoBlock = new AvInfoBlock(this,offset); 
     102                if (tmpInfoBlock && tmpInfoBlock->isValid()) { 
     103                        debugPrint (DEBUG_LEVEL_INFO, "AvMusicStatusDescriptor:  Optional block of type 0x%04X with length 0x%04X found\n",tmpInfoBlock->getType(), tmpInfoBlock->getLength()); 
     104                         
     105                        offset += tmpInfoBlock->getLength()+2; 
     106                } else { 
     107                        debugPrint (DEBUG_LEVEL_INFO, "AvMusicStatusDescriptor:  error parsing optional infoblock\n"); 
     108                        bValid=false; 
     109                        return; 
     110                } 
     111                 
     112        } 
     113         
    63114         
    64115} 
  • trunk/freebob/src/avmusicstatusdescriptor.h

    r21 r25  
    3131 
    3232 
     33class AvGeneralMusicInfoBlock; 
     34class AvOutputPlugStatusInfoBlock; 
     35 
    3336class AvMusicStatusDescriptor : public AvDescriptor { 
    3437 public: 
     
    3942 
    4043 protected: 
     44       AvGeneralMusicInfoBlock      *cGeneralMusicInfoBlock; 
     45       AvOutputPlugStatusInfoBlock  *cOutputPlugStatusInfoBlock; 
    4146        
    4247 private: 
  • trunk/freebob/src/ieee1394service.cpp

    r24 r25  
    223223                        debugPrint (DEBUG_LEVEL_INFO, "    Created...\n"); 
    224224                        testdesc_mid2->printCapabilities(); 
    225                        
     225#if 0                  
    226226                        // test the AvInfoBlock 
    227227                        debugPrint (DEBUG_LEVEL_INFO, "    Trying to create an AvInfoBlock...\n"); 
     
    312312                         
    313313                        delete testblock8; 
    314                        
     314#endif                         
    315315                        debugPrint (DEBUG_LEVEL_INFO, "    Deleting AvMusicStatusDescriptor...\n"); 
    316316                        delete testdesc_mid2;