Index: /branches/echoaudio/src/libavc/musicsubunit/avc_musicsubunit.cpp =================================================================== --- /branches/echoaudio/src/libavc/musicsubunit/avc_musicsubunit.cpp (revision 524) +++ /branches/echoaudio/src/libavc/musicsubunit/avc_musicsubunit.cpp (revision 548) @@ -124,6 +124,4 @@ // number of channels result &= plug.setNrOfChannels(info->m_nb_channels); - - int idx=1; @@ -165,4 +163,38 @@ } + if (plug.getDirection() == Plug::eAPD_Input) { + // it's an input plug to the subunit + // so we have to check the source field of the music plug + if(s.stream_position != mplug->m_source_stream_position) { + debugWarning("s.stream_position (= 0x%02X) != mplug->m_source_stream_position (= 0x%02X)\n", + s.stream_position, mplug->m_source_stream_position); + // use the one from the music plug + sinfo.m_streamPosition= mplug->m_source_stream_position; + } + if(s.stream_location != mplug->m_source_stream_location) { + debugWarning("s.stream_location (= 0x%02X) != mplug->m_source_stream_location (= 0x%02X)\n", + s.stream_location, mplug->m_source_stream_location); + // use the one from the music plug + sinfo.m_location=mplug->m_source_stream_location; + } + } else if (plug.getDirection() == Plug::eAPD_Output) { + // it's an output plug from the subunit + // so we have to check the destination field of the music plug + if(s.stream_position != mplug->m_dest_stream_position) { + debugWarning("s.stream_position (= 0x%02X) != mplug->m_dest_stream_position (= 0x%02X)\n", + s.stream_position, mplug->m_dest_stream_position); + // use the one from the music plug + sinfo.m_streamPosition=mplug->m_dest_stream_position; + } + if(s.stream_location != mplug->m_dest_stream_location) { + debugWarning("s.stream_location (= 0x%02X) != mplug->m_dest_stream_location (= 0x%02X)\n", + s.stream_location, mplug->m_dest_stream_location); + // use the one from the music plug + sinfo.m_location=mplug->m_dest_stream_location; + } + } else { + debugWarning("Invalid plug direction.\n"); + } + debugOutput(DEBUG_LEVEL_VERBOSE, "Adding signal pos=%2d loc=%2d name=%s\n", sinfo.m_streamPosition, sinfo.m_location, mplug->getName().c_str()); Index: /branches/echoaudio/src/libavc/general/avc_plug.cpp =================================================================== --- /branches/echoaudio/src/libavc/general/avc_plug.cpp (revision 524) +++ /branches/echoaudio/src/libavc/general/avc_plug.cpp (revision 548) @@ -520,23 +520,4 @@ Plug::discoverConnectionsOutput() { - debugOutput( DEBUG_LEVEL_VERBOSE, "Discovering outgoing connections...\n"); - -// int i=0; -// int nbPlugs=m_unit->getPlugManager().getPlugCount(); -// debugOutput( DEBUG_LEVEL_VERBOSE, "checking %d plugs\n", nbPlugs); -// -// for (i=0;igetPlugManager().getPlug(i); -// -// if(p==NULL) { -// debugError("could not get plug 0x%02X\n",i); -// continue; -// } -// -// if(p->getGlobalId()==getGlobalId()) continue; // skip yourself -// -// -// } - return true; } @@ -1098,45 +1079,4 @@ debugError( "Unknown subunit type\n" ); } -} - - -bool -Plug::copyClusterInfo(ExtendedPlugInfoPlugChannelPositionSpecificData& - channelPositionData ) -{ - int index = 1; - for ( ExtendedPlugInfoPlugChannelPositionSpecificData::ClusterInfoVector::const_iterator it - = channelPositionData.m_clusterInfos.begin(); - it != channelPositionData.m_clusterInfos.end(); - ++it ) - { - const ExtendedPlugInfoPlugChannelPositionSpecificData::ClusterInfo* - extPlugSpClusterInfo = &( *it ); - - ClusterInfo clusterInfo; - clusterInfo.m_nrOfChannels = extPlugSpClusterInfo->m_nrOfChannels; - clusterInfo.m_index = index; - index++; - - for ( ExtendedPlugInfoPlugChannelPositionSpecificData::ChannelInfoVector::const_iterator cit - = extPlugSpClusterInfo->m_channelInfos.begin(); - cit != extPlugSpClusterInfo->m_channelInfos.end(); - ++cit ) - { - const ExtendedPlugInfoPlugChannelPositionSpecificData::ChannelInfo* - extPlugSpChannelInfo = &( *cit ); - - ChannelInfo channelInfo; - channelInfo.m_streamPosition = - extPlugSpChannelInfo->m_streamPosition; - channelInfo.m_location = - extPlugSpChannelInfo->m_location; - - clusterInfo.m_channelInfos.push_back( channelInfo ); - } - m_clusterInfos.push_back( clusterInfo ); - } - - return true; } @@ -2308,12 +2248,14 @@ } -ExtendedPlugInfoCmd -Plug::setPlugAddrToPlugInfoCmd() -{ - ExtendedPlugInfoCmd extPlugInfoCmd( m_unit->get1394Service() ); - +ExtendedStreamFormatCmd +Plug::setPlugAddrToStreamFormatCmd( + ExtendedStreamFormatCmd::ESubFunction subFunction) +{ + ExtendedStreamFormatCmd extStreamFormatInfoCmd( + m_unit->get1394Service(), + subFunction ); switch( getSubunitType() ) { case eST_Unit: - { + { UnitPlugAddress::EPlugType ePlugType = UnitPlugAddress::ePT_Unknown; @@ -2331,81 +2273,4 @@ ePlugType = UnitPlugAddress::ePT_Unknown; } - UnitPlugAddress unitPlugAddress( ePlugType, - m_id ); - extPlugInfoCmd.setPlugAddress( - PlugAddress( convertPlugDirection( getPlugDirection() ), - PlugAddress::ePAM_Unit, - unitPlugAddress ) ); - } - break; - case eST_Music: - case eST_Audio: - { - switch( m_addressType ) { - case eAPA_SubunitPlug: - { - SubunitPlugAddress subunitPlugAddress( m_id ); - extPlugInfoCmd.setPlugAddress( - PlugAddress( - convertPlugDirection( getPlugDirection() ), - PlugAddress::ePAM_Subunit, - subunitPlugAddress ) ); - } - break; - case eAPA_FunctionBlockPlug: - { - FunctionBlockPlugAddress functionBlockPlugAddress( - m_functionBlockType, - m_functionBlockId, - m_id ); - extPlugInfoCmd.setPlugAddress( - PlugAddress( - convertPlugDirection( getPlugDirection() ), - PlugAddress::ePAM_FunctionBlock, - functionBlockPlugAddress ) ); - } - break; - default: - extPlugInfoCmd.setPlugAddress(PlugAddress()); - } - } - break; - default: - debugError( "Unknown subunit type\n" ); - } - - extPlugInfoCmd.setNodeId( m_unit->getConfigRom().getNodeId() ); - extPlugInfoCmd.setCommandType( AVCCommand::eCT_Status ); - extPlugInfoCmd.setSubunitId( getSubunitId() ); - extPlugInfoCmd.setSubunitType( getSubunitType() ); - - return extPlugInfoCmd; -} - -ExtendedStreamFormatCmd -Plug::setPlugAddrToStreamFormatCmd( - ExtendedStreamFormatCmd::ESubFunction subFunction) -{ - ExtendedStreamFormatCmd extStreamFormatInfoCmd( - m_unit->get1394Service(), - subFunction ); - switch( getSubunitType() ) { - case eST_Unit: - { - UnitPlugAddress::EPlugType ePlugType = - UnitPlugAddress::ePT_Unknown; - switch ( m_addressType ) { - case eAPA_PCR: - ePlugType = UnitPlugAddress::ePT_PCR; - break; - case eAPA_ExternalPlug: - ePlugType = UnitPlugAddress::ePT_ExternalPlug; - break; - case eAPA_AsynchronousPlug: - ePlugType = UnitPlugAddress::ePT_AsynchronousPlug; - break; - default: - ePlugType = UnitPlugAddress::ePT_Unknown; - } UnitPlugAddress unitPlugAddress( ePlugType, m_id ); Index: /branches/echoaudio/src/libavc/general/avc_plug.h =================================================================== --- /branches/echoaudio/src/libavc/general/avc_plug.h (revision 524) +++ /branches/echoaudio/src/libavc/general/avc_plug.h (revision 548) @@ -28,6 +28,4 @@ #include "../ccm/avc_signal_source.h" #include "../streamformat/avc_extended_stream_format.h" -#include "avc_extended_plug_info.h" -#include "avc_extended_cmd_generic.h" #include "../avc_definitions.h" #include "avc_generic.h" @@ -214,6 +212,4 @@ bool propagateFromPlug( Plug *p ); - ExtendedPlugInfoCmd setPlugAddrToPlugInfoCmd(); - ExtendedStreamFormatCmd setPlugAddrToStreamFormatCmd( ExtendedStreamFormatCmd::ESubFunction subFunction); @@ -228,7 +224,4 @@ void debugOutputClusterInfos( int debugLevel ); - - bool copyClusterInfo(ExtendedPlugInfoPlugChannelPositionSpecificData& - channelPositionData ); bool addPlugConnection( PlugVector& connections, Plug& plug ); Index: /branches/echoaudio/src/libavc/general/avc_unit.cpp =================================================================== --- /branches/echoaudio/src/libavc/general/avc_unit.cpp (revision 524) +++ /branches/echoaudio/src/libavc/general/avc_unit.cpp (revision 548) @@ -156,6 +156,6 @@ } - if ( !propagateClusterInfos() ) { - debugError( "Failed to propagate cluster info's\n" ); + if ( !propagatePlugInfo() ) { + debugError( "Failed to propagate plug info\n" ); return false; } @@ -458,5 +458,5 @@ bool -Unit::propagateClusterInfos() +Unit::propagatePlugInfo() { debugOutput( DEBUG_LEVEL_NORMAL, "Propagating info to PCR plugs...\n"); Index: /branches/echoaudio/src/libavc/general/avc_unit.h =================================================================== --- /branches/echoaudio/src/libavc/general/avc_unit.h (revision 524) +++ /branches/echoaudio/src/libavc/general/avc_unit.h (revision 548) @@ -127,5 +127,5 @@ virtual bool discoverPlugsExternal( AVC::Plug::EPlugDirection plugDirection, AVC::plug_id_t plugMaxId ); - virtual bool propagateClusterInfos(); + virtual bool propagatePlugInfo(); virtual bool discoverSyncModes(); virtual bool checkSyncConnectionsAndAddToList( AVC::PlugVector& plhs, Index: /branches/echoaudio/src/genericavc/avc_avdevice.cpp =================================================================== --- /branches/echoaudio/src/genericavc/avc_avdevice.cpp (revision 541) +++ /branches/echoaudio/src/genericavc/avc_avdevice.cpp (revision 548) @@ -65,4 +65,5 @@ debugOutput( DEBUG_LEVEL_VERBOSE, "Created GenericAVC::AvDevice (NodeID %d)\n", nodeId ); + addOption(Util::OptionContainer::Option("snoopMode",false)); } @@ -134,4 +135,13 @@ } +void +AvDevice::setVerboseLevel(int l) +{ + m_pPlugManager->setVerboseLevel(l); + + FFADODevice::setVerboseLevel(l); + AVC::Unit::setVerboseLevel(l); +} + int AvDevice::getSamplingFrequency( ) { @@ -159,5 +169,4 @@ AvDevice::setSamplingFrequency( int s ) { - ESamplingFrequency samplingFrequency=parseSampleRate( s ); bool snoopMode=false; if(!getOption("snoopMode", snoopMode)) { @@ -167,5 +176,5 @@ if(snoopMode) { int current_sr=getSamplingFrequency(); - if (current_sr != convertESamplingFrequency( samplingFrequency ) ) { + if (current_sr != s ) { debugError("In snoop mode it is impossible to set the sample rate.\n"); debugError("Please start the client with the correct setting.\n"); @@ -180,5 +189,5 @@ } - if ( !plug->setSampleRate( convertESamplingFrequency( samplingFrequency ) ) ) + if ( !plug->setSampleRate( s ) ) { debugError( "setSampleRate: Setting sample rate failed\n" ); @@ -192,5 +201,5 @@ } - if ( !plug->setSampleRate( convertESamplingFrequency( samplingFrequency ) ) ) + if ( !plug->setSampleRate( s ) ) { debugError( "setSampleRate: Setting sample rate failed\n" ); @@ -200,5 +209,5 @@ debugOutput( DEBUG_LEVEL_VERBOSE, "setSampleRate: Set sample rate to %d\n", - convertESamplingFrequency( samplingFrequency ) ); + s ); return true; } @@ -348,6 +357,4 @@ Streaming::StreamProcessor *processor, Streaming::AmdtpAudioPort::E_Direction direction) { - - debugOutput(DEBUG_LEVEL_VERBOSE, " Adding plug %s to processor\n", plug.getName()); std::string id=std::string("dev?"); @@ -362,6 +369,4 @@ { const Plug::ClusterInfo* clusterInfo = &( *it ); - - debugOutput(DEBUG_LEVEL_VERBOSE, " Adding cluster %s\n", clusterInfo->m_name.c_str()); Plug::ChannelInfoVector channelInfos = clusterInfo->m_channelInfos; @@ -370,7 +375,5 @@ ++it ) { - const Plug::ChannelInfo* channelInfo = &( *it ); - std::ostringstream portname; @@ -396,13 +399,10 @@ case ExtendedPlugInfoClusterInfoSpecificData::ePT_MIDI: - // HACK: for audiofire2 only !!! debugOutput(DEBUG_LEVEL_VERBOSE, " Adding MIDI channel %s (pos=0x%02X, loc=0x%02X)\n", - channelInfo->m_name.c_str(), (direction==Streaming::Port::E_Capture?4:6), - processor->getPortCount(Streaming::Port::E_Midi)); + channelInfo->m_name.c_str(), channelInfo->m_streamPosition, processor->getPortCount(Streaming::Port::E_Midi)); p=new Streaming::AmdtpMidiPort( portname.str(), direction, - (direction==Streaming::Port::E_Capture?4:6), -// channelInfo->m_streamPosition, + channelInfo->m_streamPosition, // Workaround for out-of-spec hardware // should be: @@ -420,4 +420,15 @@ case ExtendedPlugInfoClusterInfoSpecificData::ePT_MADI: case ExtendedPlugInfoClusterInfoSpecificData::ePT_Digital: + debugOutput(DEBUG_LEVEL_VERBOSE, " Adding digital audio channel %s (pos=0x%02X, loc=0x%02X)\n", + channelInfo->m_name.c_str(), channelInfo->m_streamPosition, channelInfo->m_location); + p=new Streaming::AmdtpAudioPort( + portname.str(), + direction, + channelInfo->m_streamPosition, + channelInfo->m_location, + Streaming::AmdtpPortInfo::E_MBLA + ); + break; + case ExtendedPlugInfoClusterInfoSpecificData::ePT_NoType: default: Index: /branches/echoaudio/src/genericavc/avc_avdevice.h =================================================================== --- /branches/echoaudio/src/genericavc/avc_avdevice.h (revision 542) +++ /branches/echoaudio/src/genericavc/avc_avdevice.h (revision 548) @@ -60,25 +60,26 @@ static bool probe( ConfigRom& configRom ); - bool discover(); + virtual bool discover(); + + virtual void setVerboseLevel(int l); + virtual void showDevice(); - void showDevice(); + virtual bool setSamplingFrequency( int ); + virtual int getSamplingFrequency( ); - bool setSamplingFrequency( int ); - int getSamplingFrequency( ); + virtual int getStreamCount(); + virtual Streaming::StreamProcessor *getStreamProcessorByIndex(int i); - int getStreamCount(); - Streaming::StreamProcessor *getStreamProcessorByIndex(int i); + virtual bool prepare(); + virtual bool lock(); + virtual bool unlock(); - bool prepare(); - bool lock(); - bool unlock(); - - bool startStreamByIndex(int i); - bool stopStreamByIndex(int i); + virtual bool startStreamByIndex(int i); + virtual bool stopStreamByIndex(int i); // redefinition to resolve ambiguity - Ieee1394Service& get1394Service() + virtual Ieee1394Service& get1394Service() { return FFADODevice::get1394Service(); }; - ConfigRom& getConfigRom() const + virtual ConfigRom& getConfigRom() const { return FFADODevice::getConfigRom(); }; @@ -86,7 +87,7 @@ virtual bool addPlugToProcessor( AVC::Plug& plug, Streaming::StreamProcessor *processor, Streaming::AmdtpAudioPort::E_Direction direction); - bool setSamplingFrequencyPlug( AVC::Plug& plug, +/* bool setSamplingFrequencyPlug( AVC::Plug& plug, AVC::Plug::EPlugDirection direction, - AVC::ESamplingFrequency samplingFrequency ); + AVC::ESamplingFrequency samplingFrequency );*/ struct VendorModelEntry *m_model; Index: /branches/echoaudio/src/bebob/bebob_avdevice.cpp =================================================================== --- /branches/echoaudio/src/bebob/bebob_avdevice.cpp (revision 543) +++ /branches/echoaudio/src/bebob/bebob_avdevice.cpp (revision 548) @@ -45,7 +45,5 @@ namespace BeBoB { -IMPL_DEBUG_MODULE( AvDevice, AvDevice, DEBUG_LEVEL_VERBOSE ); - -static VendorModelEntry supportedDeviceList[] = +static GenericAVC::VendorModelEntry supportedDeviceList[] = { {0x00000f, 0x00010065, "Mackie", "Onyx Firewire"}, @@ -74,12 +72,9 @@ Ieee1394Service& ieee1394service, int nodeId ) - : FFADODevice( configRom, ieee1394service, nodeId ) - , AVC::Unit( ) - , m_model ( NULL ) + : GenericAVC::AvDevice( configRom, ieee1394service, nodeId ) , m_Mixer ( NULL ) { debugOutput( DEBUG_LEVEL_VERBOSE, "Created BeBoB::AvDevice (NodeID %d)\n", nodeId ); - addOption(Util::OptionContainer::Option("snoopMode",false)); } @@ -95,5 +90,5 @@ AVC::Subunit* -BeBoB::AvDevice::createSubunit(AVC::Unit& unit, +AvDevice::createSubunit(AVC::Unit& unit, AVC::ESubunitType type, AVC::subunit_t id ) @@ -110,5 +105,5 @@ AVC::Plug * -BeBoB::AvDevice::createPlug( AVC::Unit* unit, +AvDevice::createPlug( AVC::Unit* unit, AVC::Subunit* subunit, AVC::function_block_type_t functionBlockType, @@ -128,13 +123,4 @@ } -void -AvDevice::setVerboseLevel(int l) -{ - m_pPlugManager->setVerboseLevel(l); - - FFADODevice::setVerboseLevel(l); - AVC::Unit::setVerboseLevel(l); -} - bool AvDevice::probe( ConfigRom& configRom ) @@ -144,5 +130,5 @@ for ( unsigned int i = 0; - i < ( sizeof( supportedDeviceList )/sizeof( VendorModelEntry ) ); + i < ( sizeof( supportedDeviceList )/sizeof( GenericAVC::VendorModelEntry ) ); ++i ) { @@ -163,5 +149,5 @@ for ( unsigned int i = 0; - i < ( sizeof( supportedDeviceList )/sizeof( VendorModelEntry ) ); + i < ( sizeof( supportedDeviceList )/sizeof( GenericAVC::VendorModelEntry ) ); ++i ) { @@ -223,554 +209,9 @@ bool -AvDevice::setSamplingFrequency( int s ) -{ - ESamplingFrequency samplingFrequency=parseSampleRate( s ); - bool snoopMode=false; - if(!getOption("snoopMode", snoopMode)) { - debugWarning("Could not retrieve snoopMode parameter, defauling to false\n"); - } - - if(snoopMode) { - int current_sr=getSamplingFrequency(); - if (current_sr != convertESamplingFrequency( samplingFrequency ) ) { - debugError("In snoop mode it is impossible to set the sample rate.\n"); - debugError("Please start the client with the correct setting.\n"); - return false; - } - return true; - } else { - AVC::Plug* plug = getPlugById( m_pcrPlugs, Plug::eAPD_Input, 0 ); - if ( !plug ) { - debugError( "setSampleRate: Could not retrieve iso input plug 0\n" ); - return false; - } - - if ( !setSamplingFrequencyPlug( *plug, - Plug::eAPD_Input, - samplingFrequency ) ) - { - debugError( "setSampleRate: Setting sample rate failed\n" ); - return false; - } - - plug = getPlugById( m_pcrPlugs, Plug::eAPD_Output, 0 ); - if ( !plug ) { - debugError( "setSampleRate: Could not retrieve iso output plug 0\n" ); - return false; - } - - if ( !setSamplingFrequencyPlug( *plug, - Plug::eAPD_Output, - samplingFrequency ) ) - { - debugError( "setSampleRate: Setting sample rate failed\n" ); - return false; - } - - debugOutput( DEBUG_LEVEL_VERBOSE, - "setSampleRate: Set sample rate to %d\n", - convertESamplingFrequency( samplingFrequency ) ); - return true; - } - // not executable - return false; -} - -int -AvDevice::getSamplingFrequency( ) { - AVC::Plug* inputPlug = getPlugById( m_pcrPlugs, Plug::eAPD_Input, 0 ); - if ( !inputPlug ) { - debugError( "setSampleRate: Could not retrieve iso input plug 0\n" ); - return false; - } - AVC::Plug* outputPlug = getPlugById( m_pcrPlugs, Plug::eAPD_Output, 0 ); - if ( !outputPlug ) { - debugError( "setSampleRate: Could not retrieve iso output plug 0\n" ); - return false; - } - - int samplerate_playback=inputPlug->getSampleRate(); - int samplerate_capture=outputPlug->getSampleRate(); - - if (samplerate_playback != samplerate_capture) { - debugWarning("Samplerates for capture and playback differ!\n"); - } - return samplerate_capture; -} - - -bool -AvDevice::setSamplingFrequencyPlug( AVC::Plug& plug, - Plug::EPlugDirection direction, - ESamplingFrequency samplingFrequency ) -{ - - ExtendedStreamFormatCmd extStreamFormatCmd( - *m_p1394Service, - ExtendedStreamFormatCmd::eSF_ExtendedStreamFormatInformationCommandList ); - UnitPlugAddress unitPlugAddress( UnitPlugAddress::ePT_PCR, - plug.getPlugId() ); - - extStreamFormatCmd.setPlugAddress( - PlugAddress( - Plug::convertPlugDirection(direction ), - PlugAddress::ePAM_Unit, - unitPlugAddress ) ); - - extStreamFormatCmd.setNodeId( m_pConfigRom->getNodeId() ); - extStreamFormatCmd.setCommandType( AVCCommand::eCT_Status ); - - int i = 0; - bool cmdSuccess = false; - bool correctFormatFound = false; - - do { - extStreamFormatCmd.setIndexInStreamFormat( i ); - extStreamFormatCmd.setCommandType( AVCCommand::eCT_Status ); - extStreamFormatCmd.setVerbose( m_verboseLevel ); - - cmdSuccess = extStreamFormatCmd.fire(); - - if ( cmdSuccess - && ( extStreamFormatCmd.getResponse() == - AVCCommand::eR_Implemented ) ) - { - ESamplingFrequency foundFreq = eSF_DontCare; - - FormatInformation* formatInfo = - extStreamFormatCmd.getFormatInformation(); - FormatInformationStreamsCompound* compoundStream - = dynamic_cast< FormatInformationStreamsCompound* > ( - formatInfo->m_streams ); - if ( compoundStream ) { - foundFreq = - static_cast< ESamplingFrequency >( - compoundStream->m_samplingFrequency ); - } - - FormatInformationStreamsSync* syncStream - = dynamic_cast< FormatInformationStreamsSync* > ( - formatInfo->m_streams ); - if ( syncStream ) { - foundFreq = - static_cast< ESamplingFrequency >( - syncStream->m_samplingFrequency ); - } - - if ( foundFreq == samplingFrequency ) - { - correctFormatFound = true; - break; - } - } - - ++i; - } while ( cmdSuccess - && ( extStreamFormatCmd.getResponse() == - ExtendedStreamFormatCmd::eR_Implemented ) ); - - if ( !cmdSuccess ) { - debugError( "setSampleRatePlug: Failed to retrieve format info\n" ); - return false; - } - - if ( !correctFormatFound ) { - debugError( "setSampleRatePlug: %s plug %d does not support " - "sample rate %d\n", - plug.getName(), - plug.getPlugId(), - convertESamplingFrequency( samplingFrequency ) ); - return false; - } - - extStreamFormatCmd.setSubFunction( - ExtendedStreamFormatCmd::eSF_ExtendedStreamFormatInformationCommand ); - extStreamFormatCmd.setCommandType( AVCCommand::eCT_Control ); - extStreamFormatCmd.setVerbose( m_verboseLevel ); - - if ( !extStreamFormatCmd.fire() ) { - debugError( "setSampleRate: Could not set sample rate %d " - "to %s plug %d\n", - convertESamplingFrequency( samplingFrequency ), - plug.getName(), - plug.getPlugId() ); - return false; - } - +AvDevice::propagatePlugInfo() { + // we don't have to propagate since we discover things + // another way + debugOutput(DEBUG_LEVEL_VERBOSE, "Skip plug info propagation\n"); return true; -} - -void -AvDevice::showDevice() -{ - debugOutput(DEBUG_LEVEL_VERBOSE, - "%s %s at node %d\n", m_model->vendor_name, m_model->model_name, - m_nodeId); - - m_pPlugManager->showPlugs(); - flushDebugOutput(); -} - - -bool -AvDevice::lock() { - bool snoopMode=false; - if(!getOption("snoopMode", snoopMode)) { - debugWarning("Could not retrieve snoopMode parameter, defauling to false\n"); - } - - if (snoopMode) { - // don't lock - } else { -// return Unit::reserve(4); - } - - return true; -} - -bool -AvDevice::unlock() { - bool snoopMode=false; - if(!getOption("snoopMode", snoopMode)) { - debugWarning("Could not retrieve snoopMode parameter, defauling to false\n"); - } - - if (snoopMode) { - // don't unlock - } else { -// return Unit::reserve(0); - } - return true; -} - -bool -AvDevice::prepare() { - bool snoopMode=false; - if(!getOption("snoopMode", snoopMode)) { - debugWarning("Could not retrieve snoopMode parameter, defauling to false\n"); - } - - /////////// - // get plugs - - AVC::Plug* inputPlug = getPlugById( m_pcrPlugs, Plug::eAPD_Input, 0 ); - if ( !inputPlug ) { - debugError( "setSampleRate: Could not retrieve iso input plug 0\n" ); - return false; - } - AVC::Plug* outputPlug = getPlugById( m_pcrPlugs, Plug::eAPD_Output, 0 ); - if ( !outputPlug ) { - debugError( "setSampleRate: Could not retrieve iso output plug 0\n" ); - return false; - } - - int samplerate=outputPlug->getSampleRate(); - - debugOutput( DEBUG_LEVEL_VERBOSE, "Initializing receive processor...\n"); - // create & add streamprocessors - Streaming::StreamProcessor *p; - - p=new Streaming::AmdtpReceiveStreamProcessor( - m_p1394Service->getPort(), - samplerate, - outputPlug->getNrOfChannels()); - - if(!p->init()) { - debugFatal("Could not initialize receive processor!\n"); - delete p; - return false; - } - - if (!addPlugToProcessor(*outputPlug,p, - Streaming::Port::E_Capture)) { - debugFatal("Could not add plug to processor!\n"); - delete p; - return false; - } - - m_receiveProcessors.push_back(p); - - // do the transmit processor - debugOutput( DEBUG_LEVEL_VERBOSE, "Initializing transmit processor%s...\n", - (snoopMode?" in snoop mode":"")); - if (snoopMode) { - // we are snooping, so this is receive too. - p=new Streaming::AmdtpReceiveStreamProcessor( - m_p1394Service->getPort(), - samplerate, - inputPlug->getNrOfChannels()); - } else { - p=new Streaming::AmdtpTransmitStreamProcessor( - m_p1394Service->getPort(), - samplerate, - inputPlug->getNrOfChannels()); - } - - if(!p->init()) { - debugFatal("Could not initialize transmit processor %s!\n", - (snoopMode?" in snoop mode":"")); - delete p; - return false; - } - - if (snoopMode) { - if (!addPlugToProcessor(*inputPlug,p, - Streaming::Port::E_Capture)) { - debugFatal("Could not add plug to processor!\n"); - return false; - } - } else { - if (!addPlugToProcessor(*inputPlug,p, - Streaming::Port::E_Playback)) { - debugFatal("Could not add plug to processor!\n"); - return false; - } - } - - // we put this SP into the transmit SP vector, - // no matter if we are in snoop mode or not - // this allows us to find out what direction - // a certain stream should have. - m_transmitProcessors.push_back(p); - - return true; -} - -bool -AvDevice::addPlugToProcessor( - AVC::Plug& plug, - Streaming::StreamProcessor *processor, - Streaming::AmdtpAudioPort::E_Direction direction) { - - std::string id=std::string("dev?"); - if(!getOption("id", id)) { - debugWarning("Could not retrieve id parameter, defauling to 'dev?'\n"); - } - - Plug::ClusterInfoVector& clusterInfos = plug.getClusterInfos(); - for ( Plug::ClusterInfoVector::const_iterator it = clusterInfos.begin(); - it != clusterInfos.end(); - ++it ) - { - const Plug::ClusterInfo* clusterInfo = &( *it ); - - Plug::ChannelInfoVector channelInfos = clusterInfo->m_channelInfos; - for ( Plug::ChannelInfoVector::const_iterator it = channelInfos.begin(); - it != channelInfos.end(); - ++it ) - { - const Plug::ChannelInfo* channelInfo = &( *it ); - std::ostringstream portname; - - portname << id << "_" << channelInfo->m_name; - - Streaming::Port *p=NULL; - switch(clusterInfo->m_portType) { - case ExtendedPlugInfoClusterInfoSpecificData::ePT_Speaker: - case ExtendedPlugInfoClusterInfoSpecificData::ePT_Headphone: - case ExtendedPlugInfoClusterInfoSpecificData::ePT_Microphone: - case ExtendedPlugInfoClusterInfoSpecificData::ePT_Line: - case ExtendedPlugInfoClusterInfoSpecificData::ePT_Analog: - debugOutput(DEBUG_LEVEL_VERBOSE, " Adding audio channel %s (pos=0x%02X, loc=0x%02X)\n", - channelInfo->m_name.c_str(), channelInfo->m_streamPosition-1, channelInfo->m_location-1); - p=new Streaming::AmdtpAudioPort( - portname.str(), - direction, - // \todo: streaming backend expects indexing starting from 0 - // but bebob reports it starting from 1. Decide where - // and how to handle this (pp: here) - // note that the descriptor mechanism specifies indexing from 0 - channelInfo->m_streamPosition-1, - channelInfo->m_location - 1, - Streaming::AmdtpPortInfo::E_MBLA - ); - break; - - case ExtendedPlugInfoClusterInfoSpecificData::ePT_MIDI: - debugOutput(DEBUG_LEVEL_VERBOSE, " Adding MIDI channel %s (pos=0x%02X, loc=0x%02X)\n", - channelInfo->m_name.c_str(), channelInfo->m_streamPosition-1, processor->getPortCount(Streaming::Port::E_Midi)); - p=new Streaming::AmdtpMidiPort( - portname.str(), - direction, - channelInfo->m_streamPosition-1, - // Workaround for out-of-spec hardware - // should be: - // channelInfo->m_location-1, - // but now we renumber the midi channels' location as they - // are discovered - processor->getPortCount(Streaming::Port::E_Midi), - Streaming::AmdtpPortInfo::E_Midi - ); - - break; - case ExtendedPlugInfoClusterInfoSpecificData::ePT_SPDIF: - case ExtendedPlugInfoClusterInfoSpecificData::ePT_ADAT: - case ExtendedPlugInfoClusterInfoSpecificData::ePT_TDIF: - case ExtendedPlugInfoClusterInfoSpecificData::ePT_MADI: - case ExtendedPlugInfoClusterInfoSpecificData::ePT_Digital: - case ExtendedPlugInfoClusterInfoSpecificData::ePT_NoType: - default: - // unsupported - break; - } - - if (!p) { - debugOutput(DEBUG_LEVEL_VERBOSE, "Skipped port %s\n",channelInfo->m_name.c_str()); - } else { - - if (!processor->addPort(p)) { - debugWarning("Could not register port with stream processor\n"); - return false; - } - } - } - } - return true; -} - -int -AvDevice::getStreamCount() { - return m_receiveProcessors.size() + m_transmitProcessors.size(); -} - -Streaming::StreamProcessor * -AvDevice::getStreamProcessorByIndex(int i) { - - if (i<(int)m_receiveProcessors.size()) { - return m_receiveProcessors.at(i); - } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) { - return m_transmitProcessors.at(i-m_receiveProcessors.size()); - } - - return NULL; -} - -bool -AvDevice::startStreamByIndex(int i) { - int iso_channel=-1; - bool snoopMode=false; - if(!getOption("snoopMode", snoopMode)) { - debugWarning("Could not retrieve snoopMode parameter, defauling to false\n"); - } - - if (i<(int)m_receiveProcessors.size()) { - int n=i; - Streaming::StreamProcessor *p=m_receiveProcessors.at(n); - - if(snoopMode) { // a stream from the device to another host - // FIXME: put this into a decent framework! - // we should check the oPCR[n] on the device - struct iec61883_oPCR opcr; - if (iec61883_get_oPCRX( - m_p1394Service->getHandle(), - m_pConfigRom->getNodeId() | 0xffc0, - (quadlet_t *)&opcr, - n)) { - - debugWarning("Error getting the channel for SP %d\n",i); - return false; - } - - iso_channel=opcr.channel; - } else { - iso_channel=m_p1394Service->allocateIsoChannelCMP( - m_pConfigRom->getNodeId() | 0xffc0, n, - m_p1394Service->getLocalNodeId()| 0xffc0, -1); - } - if (iso_channel<0) { - debugError("Could not allocate ISO channel for SP %d\n",i); - return false; - } - - debugOutput(DEBUG_LEVEL_VERBOSE, "Started SP %d on channel %d\n",i,iso_channel); - - p->setChannel(iso_channel); - return true; - - } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) { - int n=i-m_receiveProcessors.size(); - Streaming::StreamProcessor *p=m_transmitProcessors.at(n); - - if(snoopMode) { // a stream from another host to the device - // FIXME: put this into a decent framework! - // we should check the iPCR[n] on the device - struct iec61883_iPCR ipcr; - if (iec61883_get_iPCRX( - m_p1394Service->getHandle(), - m_pConfigRom->getNodeId() | 0xffc0, - (quadlet_t *)&ipcr, - n)) { - - debugWarning("Error getting the channel for SP %d\n",i); - return false; - } - - iso_channel=ipcr.channel; - - } else { - iso_channel=m_p1394Service->allocateIsoChannelCMP( - m_p1394Service->getLocalNodeId()| 0xffc0, -1, - m_pConfigRom->getNodeId() | 0xffc0, n); - } - - if (iso_channel<0) { - debugError("Could not allocate ISO channel for SP %d\n",i); - return false; - } - - debugOutput(DEBUG_LEVEL_VERBOSE, "Started SP %d on channel %d\n",i,iso_channel); - - p->setChannel(iso_channel); - return true; - } - - debugError("SP index %d out of range!\n",i); - return false; -} - -bool -AvDevice::stopStreamByIndex(int i) { - bool snoopMode=false; - if(!getOption("snoopMode", snoopMode)) { - debugWarning("Could not retrieve snoopMode parameter, defauling to false\n"); - } - - if (i<(int)m_receiveProcessors.size()) { - int n=i; - Streaming::StreamProcessor *p=m_receiveProcessors.at(n); - - if(snoopMode) { - - } else { - // deallocate ISO channel - if(!m_p1394Service->freeIsoChannel(p->getChannel())) { - debugError("Could not deallocate iso channel for SP %d\n",i); - return false; - } - } - p->setChannel(-1); - - return true; - - } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) { - int n=i-m_receiveProcessors.size(); - Streaming::StreamProcessor *p=m_transmitProcessors.at(n); - - if(snoopMode) { - - } else { - // deallocate ISO channel - if(!m_p1394Service->freeIsoChannel(p->getChannel())) { - debugError("Could not deallocate iso channel for SP %d\n",i); - return false; - } - } - p->setChannel(-1); - - return true; - } - - debugError("SP index %d out of range!\n",i); - return false; } Index: /branches/echoaudio/src/bebob/bebob_avdevice.h =================================================================== --- /branches/echoaudio/src/bebob/bebob_avdevice.h (revision 543) +++ /branches/echoaudio/src/bebob/bebob_avdevice.h (revision 548) @@ -44,4 +44,6 @@ #include "libutil/serialize.h" +#include "genericavc/avc_avdevice.h" + #include "ffadodevice.h" @@ -54,12 +56,5 @@ namespace BeBoB { -struct VendorModelEntry { - unsigned int vendor_id; - unsigned int model_id; - char *vendor_name; - char *model_name; -}; - -class AvDevice : public FFADODevice, public AVC::Unit { +class AvDevice : public GenericAVC::AvDevice { public: AvDevice( std::auto_ptr( configRom ), @@ -68,35 +63,7 @@ virtual ~AvDevice(); - void setVerboseLevel(int l); - static bool probe( ConfigRom& configRom ); virtual bool discover(); - virtual bool setSamplingFrequency( int ); - virtual int getSamplingFrequency( ); - - virtual int getStreamCount(); - virtual Streaming::StreamProcessor *getStreamProcessorByIndex(int i); - - virtual bool prepare(); - bool lock(); - bool unlock(); - - bool startStreamByIndex(int i); - bool stopStreamByIndex(int i); - - virtual void showDevice(); - - bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; - static AvDevice* deserialize( Glib::ustring basePath, - Util::IODeserialize& deser, - Ieee1394Service& ieee1394Service ); - - // redefinition to resolve ambiguity - Ieee1394Service& get1394Service() - { return FFADODevice::get1394Service(); }; - ConfigRom& getConfigRom() const - { return FFADODevice::getConfigRom(); }; - virtual AVC::Subunit* createSubunit(AVC::Unit& unit, AVC::ESubunitType type, @@ -109,25 +76,17 @@ AVC::Plug::EPlugDirection plugDirection, AVC::plug_id_t plugId ); -protected: - - virtual bool addPlugToProcessor( AVC::Plug& plug, Streaming::StreamProcessor *processor, - Streaming::AmdtpAudioPort::E_Direction direction); - - bool setSamplingFrequencyPlug( AVC::Plug& plug, - AVC::Plug::EPlugDirection direction, - AVC::ESamplingFrequency samplingFrequency ); - - virtual bool propagateClusterInfos() {return true;}; protected: - struct VendorModelEntry* m_model; + virtual bool propagatePlugInfo(); + +public: + bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; + static AvDevice* deserialize( Glib::ustring basePath, + Util::IODeserialize& deser, + Ieee1394Service& ieee1394Service ); + +protected: GenericMixer* m_Mixer; - // streaming stuff - typedef std::vector< Streaming::StreamProcessor * > StreamProcessorVector; - StreamProcessorVector m_receiveProcessors; - StreamProcessorVector m_transmitProcessors; - - DECLARE_DEBUG_MODULE; }; Index: /branches/echoaudio/src/bebob/bebob_avplug.cpp =================================================================== --- /branches/echoaudio/src/bebob/bebob_avplug.cpp (revision 543) +++ /branches/echoaudio/src/bebob/bebob_avplug.cpp (revision 548) @@ -312,4 +312,49 @@ bool +Plug::copyClusterInfo(ExtendedPlugInfoPlugChannelPositionSpecificData& + channelPositionData ) +{ + int index = 1; + for ( ExtendedPlugInfoPlugChannelPositionSpecificData::ClusterInfoVector::const_iterator it + = channelPositionData.m_clusterInfos.begin(); + it != channelPositionData.m_clusterInfos.end(); + ++it ) + { + const ExtendedPlugInfoPlugChannelPositionSpecificData::ClusterInfo* + extPlugSpClusterInfo = &( *it ); + + ClusterInfo clusterInfo; + clusterInfo.m_nrOfChannels = extPlugSpClusterInfo->m_nrOfChannels; + clusterInfo.m_index = index; + index++; + + for ( ExtendedPlugInfoPlugChannelPositionSpecificData::ChannelInfoVector::const_iterator cit + = extPlugSpClusterInfo->m_channelInfos.begin(); + cit != extPlugSpClusterInfo->m_channelInfos.end(); + ++cit ) + { + const ExtendedPlugInfoPlugChannelPositionSpecificData::ChannelInfo* + extPlugSpChannelInfo = &( *cit ); + + ChannelInfo channelInfo; + channelInfo.m_streamPosition = + extPlugSpChannelInfo->m_streamPosition-1; + // FIXME: this can only become a mess with the two meanings + // of the location parameter. the audio style meaning + // starts from 1, the midi style meaning from 0 + // lucky for us we recalculate this for the midi channels + // and don't use this value. + channelInfo.m_location = + extPlugSpChannelInfo->m_location; + + clusterInfo.m_channelInfos.push_back( channelInfo ); + } + m_clusterInfos.push_back( clusterInfo ); + } + + return true; +} + +bool Plug::discoverChannelName() { @@ -539,3 +584,78 @@ } -} +ExtendedPlugInfoCmd +Plug::setPlugAddrToPlugInfoCmd() +{ + ExtendedPlugInfoCmd extPlugInfoCmd( m_unit->get1394Service() ); + + switch( getSubunitType() ) { + case eST_Unit: + { + UnitPlugAddress::EPlugType ePlugType = + UnitPlugAddress::ePT_Unknown; + switch ( m_addressType ) { + case eAPA_PCR: + ePlugType = UnitPlugAddress::ePT_PCR; + break; + case eAPA_ExternalPlug: + ePlugType = UnitPlugAddress::ePT_ExternalPlug; + break; + case eAPA_AsynchronousPlug: + ePlugType = UnitPlugAddress::ePT_AsynchronousPlug; + break; + default: + ePlugType = UnitPlugAddress::ePT_Unknown; + } + UnitPlugAddress unitPlugAddress( ePlugType, + m_id ); + extPlugInfoCmd.setPlugAddress( + PlugAddress( convertPlugDirection( getPlugDirection() ), + PlugAddress::ePAM_Unit, + unitPlugAddress ) ); + } + break; + case eST_Music: + case eST_Audio: + { + switch( m_addressType ) { + case eAPA_SubunitPlug: + { + SubunitPlugAddress subunitPlugAddress( m_id ); + extPlugInfoCmd.setPlugAddress( + PlugAddress( + convertPlugDirection( getPlugDirection() ), + PlugAddress::ePAM_Subunit, + subunitPlugAddress ) ); + } + break; + case eAPA_FunctionBlockPlug: + { + FunctionBlockPlugAddress functionBlockPlugAddress( + m_functionBlockType, + m_functionBlockId, + m_id ); + extPlugInfoCmd.setPlugAddress( + PlugAddress( + convertPlugDirection( getPlugDirection() ), + PlugAddress::ePAM_FunctionBlock, + functionBlockPlugAddress ) ); + } + break; + default: + extPlugInfoCmd.setPlugAddress(PlugAddress()); + } + } + break; + default: + debugError( "Unknown subunit type\n" ); + } + + extPlugInfoCmd.setNodeId( m_unit->getConfigRom().getNodeId() ); + extPlugInfoCmd.setCommandType( AVCCommand::eCT_Status ); + extPlugInfoCmd.setSubunitId( getSubunitId() ); + extPlugInfoCmd.setSubunitType( getSubunitType() ); + + return extPlugInfoCmd; +} + +} Index: /branches/echoaudio/src/bebob/bebob_avplug.h =================================================================== --- /branches/echoaudio/src/bebob/bebob_avplug.h (revision 524) +++ /branches/echoaudio/src/bebob/bebob_avplug.h (revision 548) @@ -78,4 +78,8 @@ private: + bool copyClusterInfo(AVC::ExtendedPlugInfoPlugChannelPositionSpecificData& + channelPositionData ); + AVC::ExtendedPlugInfoCmd setPlugAddrToPlugInfoCmd(); + };