Changeset 508
- Timestamp:
- 07/29/07 04:12:47 (16 years ago)
- Files:
-
- branches/echoaudio/src/bebob/bebob_avdevice_subunit.h (modified) (1 diff)
- branches/echoaudio/src/libavc/audiosubunit/avc_audiosubunit.cpp (copied) (copied from branches/echoaudio/src/libavc/general/avc_subunit.cpp) (3 diffs)
- branches/echoaudio/src/libavc/audiosubunit/avc_audiosubunit.h (copied) (copied from branches/echoaudio/src/libavc/general/avc_subunit.h) (4 diffs)
- branches/echoaudio/src/libavc/general/avc_subunit.cpp (modified) (4 diffs)
- branches/echoaudio/src/libavc/general/avc_subunit.h (modified) (6 diffs)
- branches/echoaudio/src/libavc/general/avc_unit.h (modified) (1 diff)
- branches/echoaudio/src/libavc/musicsubunit/avc_musicsubunit.cpp (copied) (copied from branches/echoaudio/src/libavc/general/avc_subunit.cpp) (3 diffs)
- branches/echoaudio/src/libavc/musicsubunit/avc_musicsubunit.h (copied) (copied from branches/echoaudio/src/libavc/general/avc_subunit.h) (3 diffs)
- branches/echoaudio/src/Makefile.am (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/echoaudio/src/bebob/bebob_avdevice_subunit.h
r507 r508 36 36 37 37 #include "libavc/general/avc_subunit.h" 38 #include "libavc/musicsubunit/avc_musicsubunit.h" 39 #include "libavc/audiosubunit/avc_audiosubunit.h" 38 40 #include "libavc/general/avc_plug.h" 39 41 branches/echoaudio/src/libavc/audiosubunit/avc_audiosubunit.cpp
r507 r508 1 1 /* 2 * Copyright (C) 2007 by Pieter Palmers 2 3 * Copyright (C) 2005-2007 by Daniel Wagner 3 4 * … … 22 23 */ 23 24 24 25 #include "avc_subunit.h" 26 #include "avc_unit.h" 27 #include "bebob/bebob_avplug.h" 28 #include "libieee1394/configrom.h" 29 30 #include "../general/avc_plug_info.h" 31 #include "../streamformat/avc_extended_stream_format.h" 32 #include "../util/avc_serialize.h" 25 #include "avc_audiosubunit.h" 26 #include "../general/avc_subunit.h" 27 28 #warning merge with bebob functionblock 29 #include "bebob/bebob_functionblock.h" 30 #include "../audiosubunit/avc_function_block.h" 31 33 32 34 33 #include <sstream> 35 34 36 35 namespace AVC { 37 38 IMPL_DEBUG_MODULE( Subunit, Subunit, DEBUG_LEVEL_VERBOSE );39 40 ////////////////////////////////////////////41 42 Subunit::Subunit( Unit& unit,43 ESubunitType type,44 subunit_t id )45 : m_unit( &unit )46 , m_sbType( type )47 , m_sbId( id )48 {49 50 }51 52 Subunit::Subunit()53 {54 }55 56 Subunit::~Subunit()57 {58 for ( PlugVector::iterator it = m_plugs.begin();59 it != m_plugs.end();60 ++it )61 {62 delete *it;63 }64 }65 66 bool67 Subunit::discover()68 {69 // There is nothing we can discover for a generic subunit70 // Maybe its plugs, but there are multiple ways of doing that.71 return true;72 }73 74 bool75 Subunit::addPlug( Plug& plug )76 {77 m_plugs.push_back( &plug );78 return true;79 }80 81 82 Plug*83 Subunit::getPlug(Plug::EPlugDirection direction, plug_id_t plugId)84 {85 for ( PlugVector::iterator it = m_plugs.begin();86 it != m_plugs.end();87 ++it )88 {89 Plug* plug = *it;90 if ( ( plug->getPlugId() == plugId )91 && ( plug->getDirection() == direction ) )92 {93 return plug;94 }95 }96 return 0;97 }98 99 bool100 Subunit::serialize( Glib::ustring basePath,101 Util::IOSerialize& ser ) const102 {103 bool result;104 105 result = ser.write( basePath + "m_sbType", m_sbType );106 result &= ser.write( basePath + "m_sbId", m_sbId );107 result &= ser.write( basePath + "m_verboseLevel", getDebugLevel() );108 result &= serializeChild( basePath, ser );109 110 return result;111 }112 113 Subunit*114 Subunit::deserialize( Glib::ustring basePath,115 Util::IODeserialize& deser,116 Unit& unit )117 {118 bool result;119 ESubunitType sbType;120 result = deser.read( basePath + "m_sbType", sbType );121 122 Subunit* pSubunit = 0;123 switch( sbType ) {124 case eST_Audio:125 pSubunit = new SubunitAudio;126 break;127 case eST_Music:128 pSubunit = new SubunitMusic;129 break;130 default:131 pSubunit = 0;132 }133 134 if ( !pSubunit ) {135 return 0;136 }137 138 pSubunit->m_unit = &unit;139 pSubunit->m_sbType = sbType;140 result &= deser.read( basePath + "m_sbId", pSubunit->m_sbId );141 int verboseLevel;142 result &= deser.read( basePath + "m_verboseLevel", verboseLevel );143 setDebugLevel(verboseLevel);144 result &= pSubunit->deserializeChild( basePath, deser, unit );145 146 if ( !result ) {147 delete pSubunit;148 return 0;149 }150 151 return pSubunit;152 }153 36 154 37 //////////////////////////////////////////// … … 480 363 } 481 364 482 //////////////////////////////////////////// 483 484 SubunitMusic::SubunitMusic( Unit& unit, subunit_t id ) 485 : Subunit( unit, eST_Music, id ) 486 { 487 } 488 489 SubunitMusic::SubunitMusic() 490 : Subunit() 491 { 492 } 493 494 SubunitMusic::~SubunitMusic() 495 { 496 } 497 498 const char* 499 SubunitMusic::getName() 500 { 501 return "MusicSubunit"; 502 } 503 504 bool 505 SubunitMusic::serializeChild( Glib::ustring basePath, 506 Util::IOSerialize& ser ) const 507 { 508 return true; 509 } 510 511 bool 512 SubunitMusic::deserializeChild( Glib::ustring basePath, 513 Util::IODeserialize& deser, 514 Unit& unit ) 515 { 516 return true; 517 } 518 519 } 365 } branches/echoaudio/src/libavc/audiosubunit/avc_audiosubunit.h
r507 r508 1 1 /* 2 * Copyright (C) 2007 by Pieter Palmers 2 3 * Copyright (C) 2005-2007 by Daniel Wagner 3 4 * … … 22 23 */ 23 24 24 #ifndef AVC_SUBUNIT_H 25 #define AVC_SUBUNIT_H 26 27 #include "avc_plug.h" 25 #ifndef AVC_AUDIOSUBUNIT_H 26 #define AVC_AUDIOSUBUNIT_H 28 27 29 28 #include "debugmodule/debugmodule.h" 30 #include "../general/avc_extended_subunit_info.h" 31 #include "../avc_definitions.h" 32 #include "../general/avc_generic.h" 33 #include "../audiosubunit/avc_function_block.h" 29 30 #include "../general/avc_subunit.h" 34 31 35 32 #include <vector> … … 37 34 #warning merge with bebob functionblock 38 35 #include "bebob/bebob_functionblock.h" 36 #include "../audiosubunit/avc_function_block.h" 39 37 40 38 namespace AVC { 41 39 42 40 class Unit; 43 44 45 46 class Subunit {47 public:48 Subunit( Unit& avDevice,49 ESubunitType type,50 subunit_t id );51 virtual ~Subunit();52 53 virtual bool discover();54 virtual bool discoverConnections()55 {//FIXME:56 #warning FIXME57 };58 59 virtual const char* getName() = 0;60 61 subunit_t getSubunitId()62 { return m_sbId; }63 ESubunitType getSubunitType()64 { return m_sbType; }65 66 bool addPlug( Plug& plug );67 68 PlugVector& getPlugs()69 { return m_plugs; }70 Plug* getPlug(Plug::EPlugDirection direction, plug_id_t plugId);71 72 73 Unit& getUnit() const74 { return *m_unit; }75 76 77 bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const;78 static Subunit* deserialize( Glib::ustring basePath,79 Util::IODeserialize& deser,80 Unit& avDevice );81 protected:82 Subunit();83 84 // bool discoverPlugs();85 // bool discoverPlugs(Plug::EPlugDirection plugDirection,86 // plug_id_t plugMaxId );87 //88 virtual bool serializeChild( Glib::ustring basePath,89 Util::IOSerialize& ser ) const = 0;90 virtual bool deserializeChild( Glib::ustring basePath,91 Util::IODeserialize& deser,92 Unit& avDevice ) = 0;93 94 protected:95 Unit* m_unit;96 ESubunitType m_sbType;97 subunit_t m_sbId;98 99 PlugVector m_plugs;100 101 DECLARE_DEBUG_MODULE;102 };103 104 typedef std::vector<Subunit*> SubunitVector;105 106 41 // ///////////////////////////// 107 42 … … 141 76 }; 142 77 143 // /////////////////////////////144 145 class SubunitMusic: public Subunit {146 public:147 SubunitMusic( Unit& avDevice,148 subunit_t id );149 SubunitMusic();150 virtual ~SubunitMusic();151 152 virtual const char* getName();153 154 protected:155 virtual bool serializeChild( Glib::ustring basePath,156 Util::IOSerialize& ser ) const;157 virtual bool deserializeChild( Glib::ustring basePath,158 Util::IODeserialize& deser,159 Unit& avDevice );160 };161 162 78 } 163 79 branches/echoaudio/src/libavc/general/avc_subunit.cpp
r507 r508 1 1 /* 2 * Copyright (C) 2007 by Pieter Palmers 2 3 * Copyright (C) 2005-2007 by Daniel Wagner 3 4 * … … 24 25 25 26 #include "avc_subunit.h" 26 #include "avc_unit.h" 27 #include "bebob/bebob_avplug.h" 27 #include "../general/avc_unit.h" 28 #include "../general/avc_plug.h" 29 28 30 #include "libieee1394/configrom.h" 29 31 … … 33 35 34 36 #include <sstream> 37 38 #warning do we need this? 39 #include "bebob/bebob_avplug.h" 35 40 36 41 namespace AVC { … … 152 157 } 153 158 154 ////////////////////////////////////////////155 156 SubunitAudio::SubunitAudio( Unit& unit, subunit_t id )157 : Subunit( unit, eST_Audio, id )158 {159 159 } 160 161 SubunitAudio::SubunitAudio()162 : Subunit()163 {164 }165 166 SubunitAudio::~SubunitAudio()167 {168 for ( BeBoB::FunctionBlockVector::iterator it = m_functions.begin();169 it != m_functions.end();170 ++it )171 {172 delete *it;173 }174 }175 176 bool177 SubunitAudio::discover()178 {179 debugOutput(DEBUG_LEVEL_NORMAL, "Discovering Audio Subunit...\n");180 181 if ( !Subunit::discover() ) {182 return false;183 }184 185 // if ( !discoverBeBoB::FunctionBlocks() ) {186 // debugError( "function block discovering failed\n" );187 // return false;188 // }189 190 return true;191 }192 193 194 const char*195 SubunitAudio::getName()196 {197 return "AudioSubunit";198 }199 200 // bool201 // SubunitAudio::discoverConnections()202 // {203 // debugOutput(DEBUG_LEVEL_NORMAL, "Discovering connections...\n");204 // if ( !Subunit::discoverConnections() ) {205 // return false;206 // }207 //208 // for ( BeBoB::FunctionBlockVector::iterator it = m_functions.begin();209 // it != m_functions.end();210 // ++it )211 // {212 // BeBoB::FunctionBlock* function = *it;213 // if ( !function->discoverConnections() ) {214 // debugError( "functionblock connection discovering failed ('%s')\n",215 // function->getName() );216 // return false;217 // }218 // }219 //220 // return true;221 // }222 // bool223 // SubunitAudio::discoverBeBoB::FunctionBlocks()224 // {225 // debugOutput( DEBUG_LEVEL_NORMAL,226 // "Discovering function blocks...\n");227 //228 // if ( !discoverBeBoB::FunctionBlocksDo(229 // ExtendedSubunitInfoCmd::eFBT_AudioSubunitSelector) )230 // {231 // debugError( "Could not discover function block selector\n" );232 // return false;233 // }234 // if ( !discoverBeBoB::FunctionBlocksDo(235 // ExtendedSubunitInfoCmd::eFBT_AudioSubunitFeature) )236 // {237 // debugError( "Could not discover function block feature\n" );238 // return false;239 // }240 // if ( !discoverBeBoB::FunctionBlocksDo(241 // ExtendedSubunitInfoCmd::eFBT_AudioSubunitProcessing) )242 // {243 // debugError( "Could not discover function block processing\n" );244 // return false;245 // }246 // if ( !discoverBeBoB::FunctionBlocksDo(247 // ExtendedSubunitInfoCmd::eFBT_AudioSubunitCodec) )248 // {249 // debugError( "Could not discover function block codec\n" );250 // return false;251 // }252 //253 // // print a function block list254 // #ifdef DEBUG255 // if (getDebugLevel() >= DEBUG_LEVEL_NORMAL) {256 //257 // for ( BeBoB::FunctionBlockVector::iterator it = m_functions.begin();258 // it != m_functions.end();259 // ++it )260 // {261 // debugOutput(DEBUG_LEVEL_NORMAL, "%20s FB, type 0x%X, id=%d\n",262 // (*it)->getName(),263 // (*it)->getType(),264 // (*it)->getId());265 // }266 // }267 // #endif268 //269 // return true;270 // }271 //272 // bool273 // SubunitAudio::discoverBeBoB::FunctionBlocksDo(274 // ExtendedSubunitInfoCmd::EBeBoB::FunctionBlockType fbType )275 // {276 // int page = 0;277 // bool cmdSuccess = false;278 // bool finished = false;279 //280 // do {281 // ExtendedSubunitInfoCmd282 // extSubunitInfoCmd( m_unit->get1394Service() );283 // extSubunitInfoCmd.setNodeId( m_unit->getConfigRom().getNodeId() );284 // extSubunitInfoCmd.setCommandType( AVCCommand::eCT_Status );285 // extSubunitInfoCmd.setSubunitId( getSubunitId() );286 // extSubunitInfoCmd.setSubunitType( getSubunitType() );287 // extSubunitInfoCmd.setVerbose( m_verboseLevel );288 //289 // extSubunitInfoCmd.m_fbType = fbType;290 // extSubunitInfoCmd.m_page = page;291 //292 // cmdSuccess = extSubunitInfoCmd.fire();293 // if ( cmdSuccess294 // && ( extSubunitInfoCmd.getResponse()295 // == AVCCommand::eR_Implemented ) )296 // {297 // for ( ExtendedSubunitInfoPageDataVector::iterator it =298 // extSubunitInfoCmd.m_infoPageDatas.begin();299 // cmdSuccess300 // && ( it != extSubunitInfoCmd.m_infoPageDatas.end() );301 // ++it )302 // {303 // cmdSuccess = createBeBoB::FunctionBlock( fbType, **it );304 // }305 // if ( ( extSubunitInfoCmd.m_infoPageDatas.size() != 0 )306 // && ( extSubunitInfoCmd.m_infoPageDatas.size() == 5 ) )307 // {308 // page++;309 // } else {310 // finished = true;311 // }312 // } else {313 // finished = true;314 // }315 // } while ( cmdSuccess && !finished );316 //317 // return cmdSuccess;318 // }319 //320 // bool321 // SubunitAudio::createBeBoB::FunctionBlock(322 // ExtendedSubunitInfoCmd::EBeBoB::FunctionBlockType fbType,323 // ExtendedSubunitInfoPageData& data )324 // {325 // BeBoB::FunctionBlock::ESpecialPurpose purpose326 // = convertSpecialPurpose( data.m_functionBlockSpecialPupose );327 //328 // BeBoB::FunctionBlock* fb = 0;329 //330 // switch ( fbType ) {331 // case ExtendedSubunitInfoCmd::eFBT_AudioSubunitSelector:332 // {333 // fb = new BeBoB::FunctionBlockSelector( *this,334 // data.m_functionBlockId,335 // purpose,336 // data.m_noOfInputPlugs,337 // data.m_noOfOutputPlugs,338 // m_verboseLevel );339 // }340 // break;341 // case ExtendedSubunitInfoCmd::eFBT_AudioSubunitFeature:342 // {343 // fb = new BeBoB::FunctionBlockFeature( *this,344 // data.m_functionBlockId,345 // purpose,346 // data.m_noOfInputPlugs,347 // data.m_noOfOutputPlugs,348 // m_verboseLevel );349 // }350 // break;351 // case ExtendedSubunitInfoCmd::eFBT_AudioSubunitProcessing:352 // {353 // switch ( data.m_functionBlockType ) {354 // case ExtendedSubunitInfoCmd::ePT_EnhancedMixer:355 // {356 // fb = new BeBoB::FunctionBlockEnhancedMixer( *this,357 // data.m_functionBlockId,358 // purpose,359 // data.m_noOfInputPlugs,360 // data.m_noOfOutputPlugs,361 // m_verboseLevel );362 // }363 // break;364 // case ExtendedSubunitInfoCmd::ePT_Mixer:365 // case ExtendedSubunitInfoCmd::ePT_Generic:366 // case ExtendedSubunitInfoCmd::ePT_UpDown:367 // case ExtendedSubunitInfoCmd::ePT_DolbyProLogic:368 // case ExtendedSubunitInfoCmd::ePT_3DStereoExtender:369 // case ExtendedSubunitInfoCmd::ePT_Reverberation:370 // case ExtendedSubunitInfoCmd::ePT_Chorus:371 // case ExtendedSubunitInfoCmd::ePT_DynamicRangeCompression:372 // default:373 // fb = new BeBoB::FunctionBlockProcessing( *this,374 // data.m_functionBlockId,375 // purpose,376 // data.m_noOfInputPlugs,377 // data.m_noOfOutputPlugs,378 // m_verboseLevel );379 // debugWarning( "Dummy function block processing created. "380 // "Implementation is missing\n" );381 // }382 // }383 // break;384 // case ExtendedSubunitInfoCmd::eFBT_AudioSubunitCodec:385 // {386 // fb = new BeBoB::FunctionBlockCodec( *this,387 // data.m_functionBlockId,388 // purpose,389 // data.m_noOfInputPlugs,390 // data.m_noOfOutputPlugs,391 // m_verboseLevel );392 // debugWarning( "Dummy function block codec created. "393 // "Implementation is missing\n" );394 // }395 // break;396 // default:397 // debugError( "Unhandled function block type found\n" );398 // return false;399 // }400 //401 // if ( !fb ) {402 // debugError( "Could create function block\n" );403 // return false;404 // }405 // if ( !fb->discover() ) {406 // debugError( "Could not discover function block %s\n",407 // fb->getName() );408 // delete fb;409 // return false;410 // }411 // m_functions.push_back( fb );412 //413 // return true;414 // }415 //416 // BeBoB::FunctionBlock::ESpecialPurpose417 // SubunitAudio::convertSpecialPurpose(418 // function_block_special_purpose_t specialPurpose )419 // {420 // BeBoB::FunctionBlock::ESpecialPurpose p;421 // switch ( specialPurpose ) {422 // case ExtendedSubunitInfoPageData::eSP_InputGain:423 // p = BeBoB::FunctionBlock::eSP_InputGain;424 // break;425 // case ExtendedSubunitInfoPageData::eSP_OutputVolume:426 // p = BeBoB::FunctionBlock::eSP_OutputVolume;427 // break;428 // default:429 // p = BeBoB::FunctionBlock::eSP_NoSpecialPurpose;430 // }431 // return p;432 // }433 //434 bool435 SubunitAudio::serializeChild( Glib::ustring basePath,436 Util::IOSerialize& ser ) const437 {438 bool result = true;439 int i = 0;440 441 for ( BeBoB::FunctionBlockVector::const_iterator it = m_functions.begin();442 it != m_functions.end();443 ++it )444 {445 BeBoB::FunctionBlock* pFB = *it;446 std::ostringstream strstrm;447 strstrm << basePath << "BeBoB::FunctionBlock" << i << "/";448 449 result &= pFB->serialize( strstrm.str() , ser );450 451 i++;452 }453 454 return result;455 }456 457 bool458 SubunitAudio::deserializeChild( Glib::ustring basePath,459 Util::IODeserialize& deser,460 Unit& unit )461 {462 int i = 0;463 bool bFinished = false;464 do {465 std::ostringstream strstrm;466 strstrm << basePath << "BeBoB::FunctionBlock" << i << "/";467 BeBoB::FunctionBlock* pFB = BeBoB::FunctionBlock::deserialize( strstrm.str(),468 deser,469 unit,470 *this );471 if ( pFB ) {472 m_functions.push_back( pFB );473 i++;474 } else {475 bFinished = true;476 }477 } while ( !bFinished );478 479 return true;480 }481 482 ////////////////////////////////////////////483 484 SubunitMusic::SubunitMusic( Unit& unit, subunit_t id )485 : Subunit( unit, eST_Music, id )486 {487 }488 489 SubunitMusic::SubunitMusic()490 : Subunit()491 {492 }493 494 SubunitMusic::~SubunitMusic()495 {496 }497 498 const char*499 SubunitMusic::getName()500 {501 return "MusicSubunit";502 }503 504 bool505 SubunitMusic::serializeChild( Glib::ustring basePath,506 Util::IOSerialize& ser ) const507 {508 return true;509 }510 511 bool512 SubunitMusic::deserializeChild( Glib::ustring basePath,513 Util::IODeserialize& deser,514 Unit& unit )515 {516 return true;517 }518 519 }branches/echoaudio/src/libavc/general/avc_subunit.h
r507 r508 1 1 /* 2 * Copyright (C) 2007 by Pieter Palmers 2 3 * Copyright (C) 2005-2007 by Daniel Wagner 3 4 * … … 25 26 #define AVC_SUBUNIT_H 26 27 27 #include " avc_plug.h"28 #include "debugmodule/debugmodule.h" 28 29 29 #include "debugmodule/debugmodule.h" 30 #include "../avc_definitions.h" 31 #include "../general/avc_plug.h" 30 32 #include "../general/avc_extended_subunit_info.h" 31 #include "../avc_definitions.h"32 33 #include "../general/avc_generic.h" 33 34 #include "../audiosubunit/avc_function_block.h" … … 41 42 42 43 class Unit; 43 44 45 44 46 45 class Subunit { … … 56 55 #warning FIXME 57 56 }; 58 57 59 58 virtual const char* getName() = 0; 60 59 … … 63 62 ESubunitType getSubunitType() 64 63 { return m_sbType; } 65 64 66 65 bool addPlug( Plug& plug ); 67 66 … … 104 103 typedef std::vector<Subunit*> SubunitVector; 105 104 106 // /////////////////////////////107 108 class SubunitAudio: public Subunit {109 public:110 SubunitAudio( Unit& avDevice,111 subunit_t id );112 SubunitAudio();113 virtual ~SubunitAudio();114 115 virtual bool discover();116 // virtual bool discoverConnections();117 //118 virtual const char* getName();119 //120 BeBoB::FunctionBlockVector getFunctionBlocks() { return m_functions; };121 //122 // protected:123 // bool discoverFunctionBlocks();124 // bool discoverFunctionBlocksDo(125 // ExtendedSubunitInfoCmd::EFunctionBlockType fbType );126 // bool createFunctionBlock(127 // ExtendedSubunitInfoCmd::EFunctionBlockType fbType,128 // ExtendedSubunitInfoPageData& data );129 //130 // FunctionBlock::ESpecialPurpose convertSpecialPurpose(131 // function_block_special_purpose_t specialPurpose );132 133 virtual bool serializeChild( Glib::ustring basePath,134 Util::IOSerialize& ser ) const;135 virtual bool deserializeChild( Glib::ustring basePath,136 Util::IODeserialize& deser,137 Unit& avDevice );138 139 protected:140 BeBoB::FunctionBlockVector m_functions;141 };142 143 // /////////////////////////////144 145 class SubunitMusic: public Subunit {146 public:147 SubunitMusic( Unit& avDevice,148 subunit_t id );149 SubunitMusic();150 virtual ~SubunitMusic();151 152 virtual const char* getName();153 154 protected:155 virtual bool serializeChild( Glib::ustring basePath,156 Util::IOSerialize& ser ) const;157 virtual bool deserializeChild( Glib::ustring basePath,158 Util::IODeserialize& deser,159 Unit& avDevice );160 };161 162 105 } 163 106 branches/echoaudio/src/libavc/general/avc_unit.h
r507 r508 32 32 #include "../avc_definitions.h" 33 33 #include "../general/avc_extended_cmd_generic.h" 34 #include "avc_subunit.h" 35 #include "avc_plug.h" 34 #include "../general/avc_subunit.h" 35 #include "../general/avc_plug.h" 36 #include "../musicsubunit/avc_musicsubunit.h" 37 #include "../audiosubunit/avc_audiosubunit.h" 36 38 37 39 #include "libutil/serialize.h" branches/echoaudio/src/libavc/musicsubunit/avc_musicsubunit.cpp
r507 r508 1 1 /* 2 * Copyright (C) 2007 by Pieter Palmers 2 3 * Copyright (C) 2005-2007 by Daniel Wagner 3 4 * … … 22 23 */ 23 24 24 25 #include "avc_subunit.h" 26 #include "avc_unit.h" 25 #warning this header should go 27 26 #include "bebob/bebob_avplug.h" 28 27 #include "libieee1394/configrom.h" 28 29 #include "../general/avc_subunit.h" 30 #include "../general/avc_unit.h" 29 31 30 32 #include "../general/avc_plug_info.h" … … 35 37 36 38 namespace AVC { 37 38 IMPL_DEBUG_MODULE( Subunit, Subunit, DEBUG_LEVEL_VERBOSE );39 40 ////////////////////////////////////////////41 42 Subunit::Subunit( Unit& unit,43 ESubunitType type,44 subunit_t id )45 : m_unit( &unit )46 , m_sbType( type )47 , m_sbId( id )48 {49 50 }51 52 Subunit::Subunit()53 {54 }55 56 Subunit::~Subunit()57 {58 for ( PlugVector::iterator it = m_plugs.begin();59 it != m_plugs.end();60 ++it )61 {62 delete *it;63 }64 }65 66 bool67 Subunit::discover()68 {69 // There is nothing we can discover for a generic subunit70 // Maybe its plugs, but there are multiple ways of doing that.71 return true;72 }73 74 bool75 Subunit::addPlug( Plug& plug )76 {77 m_plugs.push_back( &plug );78 return true;79 }80 81 82 Plug*83 Subunit::getPlug(Plug::EPlugDirection direction, plug_id_t plugId)84 {85 for ( PlugVector::iterator it = m_plugs.begin();86 it != m_plugs.end();87 ++it )88 {89 Plug* plug = *it;90 if ( ( plug->getPlugId() == plugId )91 && ( plug->getDirection() == direction ) )92 {93 return plug;94 }95 }96 return 0;97 }98 99 bool100 Subunit::serialize( Glib::ustring basePath,101 Util::IOSerialize& ser ) const102 {103 bool result;104 105 result = ser.write( basePath + "m_sbType", m_sbType );106 result &= ser.write( basePath + "m_sbId", m_sbId );107 result &= ser.write( basePath + "m_verboseLevel", getDebugLevel() );108 result &= serializeChild( basePath, ser );109 110 return result;111 }112 113 Subunit*114 Subunit::deserialize( Glib::ustring basePath,115 Util::IODeserialize& deser,116 Unit& unit )117 {118 bool result;119 ESubunitType sbType;120 result = deser.read( basePath + "m_sbType", sbType );121 122 Subunit* pSubunit = 0;123 switch( sbType ) {124 case eST_Audio:125 pSubunit = new SubunitAudio;126 break;127 case eST_Music:128 pSubunit = new SubunitMusic;129 break;130 default:131 pSubunit = 0;132 }133 134 if ( !pSubunit ) {135 return 0;136 }137 138 pSubunit->m_unit = &unit;139 pSubunit->m_sbType = sbType;140 result &= deser.read( basePath + "m_sbId", pSubunit->m_sbId );141 int verboseLevel;142 result &= deser.read( basePath + "m_verboseLevel", verboseLevel );143 setDebugLevel(verboseLevel);144 result &= pSubunit->deserializeChild( basePath, deser, unit );145 146 if ( !result ) {147 delete pSubunit;148 return 0;149 }150 151 return pSubunit;152 }153 154 ////////////////////////////////////////////155 156 SubunitAudio::SubunitAudio( Unit& unit, subunit_t id )157 : Subunit( unit, eST_Audio, id )158 {159 }160 161 SubunitAudio::SubunitAudio()162 : Subunit()163 {164 }165 166 SubunitAudio::~SubunitAudio()167 {168 for ( BeBoB::FunctionBlockVector::iterator it = m_functions.begin();169 it != m_functions.end();170 ++it )171 {172 delete *it;173 }174 }175 176 bool177 SubunitAudio::discover()178 {179 debugOutput(DEBUG_LEVEL_NORMAL, "Discovering Audio Subunit...\n");180 181 if ( !Subunit::discover() ) {182 return false;183 }184 185 // if ( !discoverBeBoB::FunctionBlocks() ) {186 // debugError( "function block discovering failed\n" );187 // return false;188 // }189 190 return true;191 }192 193 194 const char*195 SubunitAudio::getName()196 {197 return "AudioSubunit";198 }199 200 // bool201 // SubunitAudio::discoverConnections()202 // {203 // debugOutput(DEBUG_LEVEL_NORMAL, "Discovering connections...\n");204 // if ( !Subunit::discoverConnections() ) {205 // return false;206 // }207 //208 // for ( BeBoB::FunctionBlockVector::iterator it = m_functions.begin();209 // it != m_functions.end();210 // ++it )211 // {212 // BeBoB::FunctionBlock* function = *it;213 // if ( !function->discoverConnections() ) {214 // debugError( "functionblock connection discovering failed ('%s')\n",215 // function->getName() );216 // return false;217 // }218 // }219 //220 // return true;221 // }222 // bool223 // SubunitAudio::discoverBeBoB::FunctionBlocks()224 // {225 // debugOutput( DEBUG_LEVEL_NORMAL,226 // "Discovering function blocks...\n");227 //228 // if ( !discoverBeBoB::FunctionBlocksDo(229 // ExtendedSubunitInfoCmd::eFBT_AudioSubunitSelector) )230 // {231 // debugError( "Could not discover function block selector\n" );232 // return false;233 // }234 // if ( !discoverBeBoB::FunctionBlocksDo(235 // ExtendedSubunitInfoCmd::eFBT_AudioSubunitFeature) )236 // {237 // debugError( "Could not discover function block feature\n" );238 // return false;239 // }240 // if ( !discoverBeBoB::FunctionBlocksDo(241 // ExtendedSubunitInfoCmd::eFBT_AudioSubunitProcessing) )242 // {243 // debugError( "Could not discover function block processing\n" );244 // return false;245 // }246 // if ( !discoverBeBoB::FunctionBlocksDo(247 // ExtendedSubunitInfoCmd::eFBT_AudioSubunitCodec) )248 // {249 // debugError( "Could not discover function block codec\n" );250 // return false;251 // }252 //253 // // print a function block list254 // #ifdef DEBUG255 // if (getDebugLevel() >= DEBUG_LEVEL_NORMAL) {256 //257 // for ( BeBoB::FunctionBlockVector::iterator it = m_functions.begin();258 // it != m_functions.end();259 // ++it )260 // {261 // debugOutput(DEBUG_LEVEL_NORMAL, "%20s FB, type 0x%X, id=%d\n",262 // (*it)->getName(),263 // (*it)->getType(),264 // (*it)->getId());265 // }266 // }267 // #endif268 //269 // return true;270 // }271 //272 // bool273 // SubunitAudio::discoverBeBoB::FunctionBlocksDo(274 // ExtendedSubunitInfoCmd::EBeBoB::FunctionBlockType fbType )275 // {276 // int page = 0;277 // bool cmdSuccess = false;278 // bool finished = false;279 //280 // do {281 // ExtendedSubunitInfoCmd282 // extSubunitInfoCmd( m_unit->get1394Service() );283 // extSubunitInfoCmd.setNodeId( m_unit->getConfigRom().getNodeId() );284 // extSubunitInfoCmd.setCommandType( AVCCommand::eCT_Status );285 // extSubunitInfoCmd.setSubunitId( getSubunitId() );286 // extSubunitInfoCmd.setSubunitType( getSubunitType() );287 // extSubunitInfoCmd.setVerbose( m_verboseLevel );288 //289 // extSubunitInfoCmd.m_fbType = fbType;290 // extSubunitInfoCmd.m_page = page;291 //292 // cmdSuccess = extSubunitInfoCmd.fire();293 // if ( cmdSuccess294 // && ( extSubunitInfoCmd.getResponse()295 // == AVCCommand::eR_Implemented ) )296 // {297 // for ( ExtendedSubunitInfoPageDataVector::iterator it =298 // extSubunitInfoCmd.m_infoPageDatas.begin();299 // cmdSuccess300 // && ( it != extSubunitInfoCmd.m_infoPageDatas.end() );301 // ++it )302 // {303 // cmdSuccess = createBeBoB::FunctionBlock( fbType, **it );304 // }305 // if ( ( extSubunitInfoCmd.m_infoPageDatas.size() != 0 )306 // && ( extSubunitInfoCmd.m_infoPageDatas.size() == 5 ) )307 // {308 // page++;309 // } else {310 // finished = true;311 // }312 // } else {313 // finished = true;314 // }315 // } while ( cmdSuccess && !finished );316 //317 // return cmdSuccess;318 // }319 //320 // bool321 // SubunitAudio::createBeBoB::FunctionBlock(322 // ExtendedSubunitInfoCmd::EBeBoB::FunctionBlockType fbType,323 // ExtendedSubunitInfoPageData& data )324 // {325 // BeBoB::FunctionBlock::ESpecialPurpose purpose326 // = convertSpecialPurpose( data.m_functionBlockSpecialPupose );327 //328 // BeBoB::FunctionBlock* fb = 0;329 //330 // switch ( fbType ) {331 // case ExtendedSubunitInfoCmd::eFBT_AudioSubunitSelector:332 // {333 // fb = new BeBoB::FunctionBlockSelector( *this,334 // data.m_functionBlockId,335 // purpose,336 // data.m_noOfInputPlugs,337 // data.m_noOfOutputPlugs,338 // m_verboseLevel );339 // }340 // break;341 // case ExtendedSubunitInfoCmd::eFBT_AudioSubunitFeature:342 // {343 // fb = new BeBoB::FunctionBlockFeature( *this,344 // data.m_functionBlockId,345 // purpose,346 // data.m_noOfInputPlugs,347 // data.m_noOfOutputPlugs,348 // m_verboseLevel );349 // }350 // break;351 // case ExtendedSubunitInfoCmd::eFBT_AudioSubunitProcessing:352 // {353 // switch ( data.m_functionBlockType ) {354 // case ExtendedSubunitInfoCmd::ePT_EnhancedMixer:355 // {356 // fb = new BeBoB::FunctionBlockEnhancedMixer( *this,357 // data.m_functionBlockId,358 // purpose,359 // data.m_noOfInputPlugs,360 // data.m_noOfOutputPlugs,361 // m_verboseLevel );362 // }363 // break;364 // case ExtendedSubunitInfoCmd::ePT_Mixer:365 // case ExtendedSubunitInfoCmd::ePT_Generic:366 // case ExtendedSubunitInfoCmd::ePT_UpDown:367 // case ExtendedSubunitInfoCmd::ePT_DolbyProLogic:368 // case ExtendedSubunitInfoCmd::ePT_3DStereoExtender:369 // case ExtendedSubunitInfoCmd::ePT_Reverberation:370 // case ExtendedSubunitInfoCmd::ePT_Chorus:371 // case ExtendedSubunitInfoCmd::ePT_DynamicRangeCompression:372 // default:373 // fb = new BeBoB::FunctionBlockProcessing( *this,374 // data.m_functionBlockId,375 // purpose,376 // data.m_noOfInputPlugs,377 // data.m_noOfOutputPlugs,378 // m_verboseLevel );379 // debugWarning( "Dummy function block processing created. "380 // "Implementation is missing\n" );381 // }382 // }383 // break;384 // case ExtendedSubunitInfoCmd::eFBT_AudioSubunitCodec:385 // {386 // fb = new BeBoB::FunctionBlockCodec( *this,387 // data.m_functionBlockId,388 // purpose,389 // data.m_noOfInputPlugs,390 // data.m_noOfOutputPlugs,391 // m_verboseLevel );392 // debugWarning( "Dummy function block codec created. "393 // "Implementation is missing\n" );394 // }395 // break;396 // default:397 // debugError( "Unhandled function block type found\n" );398 // return false;399 // }400 //401 // if ( !fb ) {402 // debugError( "Could create function block\n" );403 // return false;404 // }405 // if ( !fb->discover() ) {406 // debugError( "Could not discover function block %s\n",407 // fb->getName() );408 // delete fb;409 // return false;410 // }411 // m_functions.push_back( fb );412 //413 // return true;414 // }415 //416 // BeBoB::FunctionBlock::ESpecialPurpose417 // SubunitAudio::convertSpecialPurpose(418 // function_block_special_purpose_t specialPurpose )419 // {420 // BeBoB::FunctionBlock::ESpecialPurpose p;421 // switch ( specialPurpose ) {422 // case ExtendedSubunitInfoPageData::eSP_InputGain:423 // p = BeBoB::FunctionBlock::eSP_InputGain;424 // break;425 // case ExtendedSubunitInfoPageData::eSP_OutputVolume:426 // p = BeBoB::FunctionBlock::eSP_OutputVolume;427 // break;428 // default:429 // p = BeBoB::FunctionBlock::eSP_NoSpecialPurpose;430 // }431 // return p;432 // }433 //434 bool435 SubunitAudio::serializeChild( Glib::ustring basePath,436 Util::IOSerialize& ser ) const437 {438 bool result = true;439 int i = 0;440 441 for ( BeBoB::FunctionBlockVector::const_iterator it = m_functions.begin();442 it != m_functions.end();443 ++it )444 {445 BeBoB::FunctionBlock* pFB = *it;446 std::ostringstream strstrm;447 strstrm << basePath << "BeBoB::FunctionBlock" << i << "/";448 449 result &= pFB->serialize( strstrm.str() , ser );450 451 i++;452 }453 454 return result;455 }456 457 bool458 SubunitAudio::deserializeChild( Glib::ustring basePath,459 Util::IODeserialize& deser,460 Unit& unit )461 {462 int i = 0;463 bool bFinished = false;464 do {465 std::ostringstream strstrm;466 strstrm << basePath << "BeBoB::FunctionBlock" << i << "/";467 BeBoB::FunctionBlock* pFB = BeBoB::FunctionBlock::deserialize( strstrm.str(),468 deser,469 unit,470 *this );471 if ( pFB ) {472 m_functions.push_back( pFB );473 i++;474 } else {475 bFinished = true;476 }477 } while ( !bFinished );478 479 return true;480 }481 39 482 40 //////////////////////////////////////////// branches/echoaudio/src/libavc/musicsubunit/avc_musicsubunit.h
r507 r508 1 1 /* 2 * Copyright (C) 2007 by Pieter Palmers 2 3 * Copyright (C) 2005-2007 by Daniel Wagner 3 4 * … … 22 23 */ 23 24 24 #ifndef AVC_SUBUNIT_H 25 #define AVC_SUBUNIT_H 26 27 #include "avc_plug.h" 28 29 #include "debugmodule/debugmodule.h" 30 #include "../general/avc_extended_subunit_info.h" 31 #include "../avc_definitions.h" 32 #include "../general/avc_generic.h" 33 #include "../audiosubunit/avc_function_block.h" 25 #ifndef AVC_MUSICSUBUNIT_H 26 #define AVC_MUSICSUBUNIT_H 34 27 35 28 #include <vector> 36 37 #warning merge with bebob functionblock 38 #include "bebob/bebob_functionblock.h" 29 #include "libutil/serialize.h" 39 30 40 31 namespace AVC { 41 32 42 33 class Unit; 43 44 45 46 class Subunit {47 public:48 Subunit( Unit& avDevice,49 ESubunitType type,50 subunit_t id );51 virtual ~Subunit();52 53 virtual bool discover();54 virtual bool discoverConnections()55 {//FIXME:56 #warning FIXME57 };58 59 virtual const char* getName() = 0;60 61 subunit_t getSubunitId()62 { return m_sbId; }63 ESubunitType getSubunitType()64 { return m_sbType; }65 66 bool addPlug( Plug& plug );67 68 PlugVector& getPlugs()69 { return m_plugs; }70 Plug* getPlug(Plug::EPlugDirection direction, plug_id_t plugId);71 72 73 Unit& getUnit() const74 { return *m_unit; }75 76 77 bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const;78 static Subunit* deserialize( Glib::ustring basePath,79 Util::IODeserialize& deser,80 Unit& avDevice );81 protected:82 Subunit();83 84 // bool discoverPlugs();85 // bool discoverPlugs(Plug::EPlugDirection plugDirection,86 // plug_id_t plugMaxId );87 //88 virtual bool serializeChild( Glib::ustring basePath,89 Util::IOSerialize& ser ) const = 0;90 virtual bool deserializeChild( Glib::ustring basePath,91 Util::IODeserialize& deser,92 Unit& avDevice ) = 0;93 94 protected:95 Unit* m_unit;96 ESubunitType m_sbType;97 subunit_t m_sbId;98 99 PlugVector m_plugs;100 101 DECLARE_DEBUG_MODULE;102 };103 104 typedef std::vector<Subunit*> SubunitVector;105 106 // /////////////////////////////107 108 class SubunitAudio: public Subunit {109 public:110 SubunitAudio( Unit& avDevice,111 subunit_t id );112 SubunitAudio();113 virtual ~SubunitAudio();114 115 virtual bool discover();116 // virtual bool discoverConnections();117 //118 virtual const char* getName();119 //120 BeBoB::FunctionBlockVector getFunctionBlocks() { return m_functions; };121 //122 // protected:123 // bool discoverFunctionBlocks();124 // bool discoverFunctionBlocksDo(125 // ExtendedSubunitInfoCmd::EFunctionBlockType fbType );126 // bool createFunctionBlock(127 // ExtendedSubunitInfoCmd::EFunctionBlockType fbType,128 // ExtendedSubunitInfoPageData& data );129 //130 // FunctionBlock::ESpecialPurpose convertSpecialPurpose(131 // function_block_special_purpose_t specialPurpose );132 133 virtual bool serializeChild( Glib::ustring basePath,134 Util::IOSerialize& ser ) const;135 virtual bool deserializeChild( Glib::ustring basePath,136 Util::IODeserialize& deser,137 Unit& avDevice );138 139 protected:140 BeBoB::FunctionBlockVector m_functions;141 };142 34 143 35 // ///////////////////////////// … … 146 38 public: 147 39 SubunitMusic( Unit& avDevice, 148 subunit_t id );40 subunit_t id ); 149 41 SubunitMusic(); 150 42 virtual ~SubunitMusic(); branches/echoaudio/src/Makefile.am
r507 r508 59 59 libavc/util/avc_serialize.h \ 60 60 libavc/musicsubunit/avc_descriptor_music.h \ 61 libavc/musicsubunit/avc_musicsubunit.h \ 62 libavc/audiosubunit/avc_audiosubunit.h \ 63 libavc/audiosubunit/avc_function_block.h \ 61 64 libavc/descriptors/avc_descriptor_cmd.h \ 62 65 libavc/descriptors/avc_descriptor.h \ … … 96 99 ffadodevice.cpp \ 97 100 debugmodule/debugmodule.cpp \ 98 libavc/audiosubunit/avc_function_block.cpp \99 101 libavc/streamformat/avc_extended_stream_format.cpp \ 100 102 libavc/util/avc_serialize.cpp \ 101 103 libavc/musicsubunit/avc_descriptor_music.cpp \ 104 libavc/musicsubunit/avc_musicsubunit.cpp \ 105 libavc/audiosubunit/avc_audiosubunit.cpp \ 106 libavc/audiosubunit/avc_function_block.cpp \ 102 107 libavc/descriptors/avc_descriptor_cmd.cpp \ 103 108 libavc/descriptors/avc_descriptor.cpp \