31 #include <sys/types.h> 39 #define REQUIRED_INTERFACE_VERSION_MAJOR 1 40 #define REQUIRED_INTERFACE_VERSION_MINOR 0 42 CAmControlSender* CAmControlSender::mInstance=NULL;
53 assert(sockethandler);
57 const char* conFile(controlPluginFile.c_str());
59 if (S_ISDIR(buf.st_mode))
61 std::string directoryName(controlPluginFile);
62 logInfo(
"Searching for ControlPlugin in", directoryName);
63 DIR *directory = opendir(directoryName.c_str());
67 logError(
"Error opening directory ", directoryName);
68 throw std::runtime_error(
"Controller directory could not be openend");
72 struct dirent *itemInDirectory = 0;
73 while ((itemInDirectory = readdir(directory)))
75 unsigned char entryType = itemInDirectory->d_type;
76 std::string entryName = itemInDirectory->d_name;
77 std::string fullName = directoryName +
"/" + entryName;
79 bool regularFile = (entryType == DT_REG || entryType == DT_LNK);
80 bool sharedLibExtension = (
"so" == entryName.substr(entryName.find_last_of(
".") + 1));
83 if (entryType == DT_UNKNOWN) {
86 if (stat(fullName.c_str(), &buf)) {
87 logInfo(__PRETTY_FUNCTION__,
"Failed to stat file: ", entryName, errno);
91 regularFile = S_ISREG(buf.st_mode);
94 if (regularFile && sharedLibExtension)
96 controlPluginFile=directoryName +
"/" + entryName;
97 logInfo(
"Found ControlPlugin:", controlPluginFile);
105 std::ifstream isfile(controlPluginFile.c_str());
108 logError(
"ControlSender::ControlSender: Controller plugin not found:", controlPluginFile);
109 throw std::runtime_error(
"Could not find controller plugin!");
111 else if (!controlPluginFile.empty())
115 createFunc = getCreateFunction<IAmControlSend*()>(controlPluginFile, mlibHandle);
116 assert(createFunc!=NULL);
117 mController = createFunc();
118 mControlPluginFile = controlPluginFile;
122 uint16_t minorVersion, majorVersion, cMinorVersion, cMajorVersion;
123 std::istringstream(version.substr(0, 1)) >> majorVersion;
124 std::istringstream(version.substr(2, 1)) >> minorVersion;
125 std::istringstream(cVersion.substr(0, 1)) >> cMajorVersion;
126 std::istringstream(cVersion.substr(2, 1)) >> cMinorVersion;
130 if (majorVersion < cMajorVersion || ((majorVersion == cMajorVersion) && (minorVersion < cMinorVersion)))
132 logError(
"ControlSender::ControlSender: Interface Version of Controller too old, required version:",
ControlVersion,
" Controller Version:",version,
"exiting now");
133 throw std::runtime_error(
"Interface Version of Controller too old");
138 logError(
"ControlSender::ControlSender: No controller loaded !");
142 if (pipe(mPipe) == -1)
144 logError(
"CAmControlSender could not create pipe!");
162 destroyFunc = getDestroyFunction<void(IAmControlSend*)>(mControlPluginFile, mlibHandle);
165 destroyFunc(mController);
169 logError(
"CAmControlSender Dtor: destroyFunc is invalid or not found");
401 logError(
"ControlSender::startupController: no Controller to startup!");
402 throw std::runtime_error(
"ControlSender::startupController: no Controller to startup! Exiting now ...");
435 logInfo(
"CAmControlSender::setControllerRundown received, signal=",signal);
442 return (mController->
getConnectionFormatChoice(sourceID, sinkID, listRoute, listPossibleConnectionFormats, listPrioConnectionFormats));
477 return (mController->
hookSystemUpdateSink(sinkID,sinkClassID,listSoundProperties,listConnectionFormats,listMainSoundProperties));
483 return (mController->
hookSystemUpdateSource(sourceID,sourceClassID,listSoundProperties,listConnectionFormats,listMainSoundProperties));
489 return (mController->
hookSystemUpdateGateway(gatewayID,listSourceConnectionFormats,listSinkConnectionFromats,convertionMatrix));
495 return (mController->
hookSystemUpdateConverter(converterID,listSourceConnectionFormats,listSinkConnectionFromats,convertionMatrix));
545 ssize_t result = read(pollfd.fd, &mSignal,
sizeof(mSignal));
573 logInfo(
"CAmControlSender was loaded in test mode!");
SPDX license identifier: MPL-2.0.
uint16_t am_connectionID_t
a connection ID
bool checkerCallback(const sh_pollHandle_t handle, void *userData)
bool dispatcherCallback(const sh_pollHandle_t handle, void *userData)
am_Error_e hookUserVolumeChange(const am_sinkID_t SinkID, const am_mainVolume_t newVolume)
void getInterfaceVersion(std::string &version) const
void hookSystemSourceAvailablityStateChange(const am_sourceID_t sourceID, const am_Availability_s &availability)
am_Error_e hookSystemUpdateGateway(const am_gatewayID_t gatewayID, const std::vector< am_CustomConnectionFormat_t > &listSourceConnectionFormats, const std::vector< am_CustomConnectionFormat_t > &listSinkConnectionFromats, const std::vector< bool > &convertionMatrix)
A Common-API wrapper class, which loads the common-api runtime and instantiates all necessary objects...
virtual am_Error_e hookUserVolumeChange(const am_sinkID_t SinkID, const am_mainVolume_t newVolume)=0
sets a user volume
the desired object is non existent
void cbAckSetSinkSoundProperties(const am_Handle_s handle, const am_Error_e error)
am_Error_e
the errors of the audiomanager.
am_Error_e hookUserSetMainSinkSoundProperty(const am_sinkID_t sinkID, const am_MainSoundProperty_s &soundProperty)
This struct holds information about the configuration for notifications.
am_Error_e hookSystemRegisterSink(const am_Sink_s &sinkData, am_sinkID_t &sinkID)
am_Error_e hookSystemDeregisterCrossfader(const am_crossfaderID_t crossfaderID)
void logInfo(T value, TArgs...args)
logs given values with infolevel with the default context
virtual void hookSystemDomainStateChange(const am_domainID_t domainID, const am_DomainState_e state)=0
id called when domainstate was changed
am_Error_e hookUserDisconnectionRequest(const am_mainConnectionID_t connectionID)
void hookSystemInterruptStateChange(const am_sourceID_t sourceID, const am_InterruptState_e interruptState)
void hookSystemDomainRegistrationComplete(const am_domainID_t domainID)
This struct describes the attribiutes of a sink.
This struct holds the payload of a notification.
virtual am_Error_e hookSystemDeregisterCrossfader(const am_crossfaderID_t crossfaderID)=0
is called when a routing adaptor deregisters a crossfader
void cbAckSetSinkNotificationConfiguration(const am_Handle_s handle, const am_Error_e error)
void confirmRoutingReady(const am_Error_e error)
virtual void setControllerReady()=0
this message is used tell the controller that it should get ready.
virtual am_Error_e hookSystemUpdateSource(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector< am_SoundProperty_s > &listSoundProperties, const std::vector< am_CustomConnectionFormat_t > &listConnectionFormats, const std::vector< am_MainSoundProperty_s > &listMainSoundProperties)=0
update from the source Data
void hookSinkNotificationDataChanged(const am_sinkID_t sinkID, const am_NotificationPayload_s &payload)
virtual am_Error_e getConnectionFormatChoice(const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_Route_s listRoute, const std::vector< am_CustomConnectionFormat_t > listPossibleConnectionFormats, std::vector< am_CustomConnectionFormat_t > &listPrioConnectionFormats)=0
This function is used by the routing algorithm to retrieve a priorized list of connectionFormats from...
am_Error_e hookSystemDeregisterSink(const am_sinkID_t sinkID)
This struct describes the attribiutes of a domain.
virtual void cbAckConnect(const am_Handle_s handle, const am_Error_e errorID)=0
ack for connect
am_Error_e startupController(IAmControlReceive *controlreceiveinterface)
virtual void cbAckSetSinkVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error)=0
ack for sink volume changes
am_Error_e hookSystemUpdateSink(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector< am_SoundProperty_s > &listSoundProperties, const std::vector< am_CustomConnectionFormat_t > &listConnectionFormats, const std::vector< am_MainSoundProperty_s > &listMainSoundProperties)
uint16_t am_crossfaderID_t
a crossfader ID
The am::CAmSocketHandler implements a mainloop for the AudioManager.
virtual void hookSinkNotificationDataChanged(const am_sinkID_t sinkID, const am_NotificationPayload_s &payload)=0
new sinkNotification data is there!
am_Error_e hookUserSetSystemProperty(const am_SystemProperty_s &property)
void confirmCommandReady(const am_Error_e error)
virtual void hookSystemSpeedChange(const am_speed_t speed)=0
this hook provides information about speed changes.
TAmShPollCheck< CAmControlSender > checkerCallbackT
void hookSystemSinkAvailablityStateChange(const am_sinkID_t sinkID, const am_Availability_s &availability)
int16_t am_timeSync_t
offset time that is introduced in milli seconds.
void hookSourceNotificationDataChanged(const am_sourceID_t sourceID, const am_NotificationPayload_s &payload)
virtual void hookSourceNotificationDataChanged(const am_sourceID_t sourceID, const am_NotificationPayload_s &payload)=0
new sourceNotification data is there!
am_Error_e hookSystemRegisterSource(const am_Source_s &sourceData, am_sourceID_t &sourceID)
uint16_t sh_pollHandle_t
this is a handle for a filedescriptor to be used with the SocketHandler
void receiverCallback(const pollfd pollfd, const sh_pollHandle_t handle, void *userData)
SPDX license identifier: MPL-2.0.
void hookSystemDomainStateChange(const am_domainID_t domainID, const am_DomainState_e state)
am_Error_e hookSystemRegisterConverter(const am_Converter_s &converterData, am_converterID_t &converterID)
virtual am_Error_e hookUserVolumeStep(const am_sinkID_t SinkID, const int16_t increment)=0
sets a user volume as increment
am_Error_e getConnectionFormatChoice(const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_Route_s listRoute, const std::vector< am_CustomConnectionFormat_t > listPossibleConnectionFormats, std::vector< am_CustomConnectionFormat_t > &listPrioConnectionFormats)
virtual am_Error_e hookSystemRegisterConverter(const am_Converter_s &converterData, am_converterID_t &converterID)=0
is called when a routing adaptor registers a converter
void setControllerRundown(const int16_t signal)
virtual am_Error_e hookUserSetSystemProperty(const am_SystemProperty_s &property)=0
sets a user SystemProperty
void cbAckCrossFade(const am_Handle_s handle, const am_HotSink_e hostsink, const am_Error_e error)
void cbAckSetSinkVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error)
virtual void cbAckSetSinkSoundProperties(const am_Handle_s handle, const am_Error_e error)=0
ack for setting of sinksoundproperties
virtual void cbAckSetSourceNotificationConfiguration(const am_Handle_s handle, const am_Error_e error)=0
The acknowledge of the source notification configuration.
virtual am_Error_e hookUserSetMainSinkSoundProperty(const am_sinkID_t sinkID, const am_MainSoundProperty_s &soundProperty)=0
sets a user MainSinkSoundProperty
void cbAckDisconnect(const am_Handle_s handle, const am_Error_e errorID)
void cbAckSetSourceNotificationConfiguration(const am_Handle_s handle, const am_Error_e error)
virtual am_Error_e hookUserSetMainSourceNotificationConfiguration(const am_sourceID_t sourceID, const am_NotificationConfiguration_s ¬ificationConfiguration)=0
sets a user MainSourceNotificationConfiguration
am_Error_e hookSystemUpdateConverter(const am_converterID_t converterID, const std::vector< am_CustomConnectionFormat_t > &listSourceConnectionFormats, const std::vector< am_CustomConnectionFormat_t > &listSinkConnectionFromats, const std::vector< bool > &convertionMatrix)
CAmControlSender()
for testing only contructor - do not use !
struct describing system properties
void hookSystemSinkVolumeTick(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume)
uint16_t am_converterID_t
a converter ID
virtual void cbAckSetSinkNotificationConfiguration(const am_Handle_s handle, const am_Error_e error)=0
The acknowledge of the sink notification configuration.
virtual void confirmRoutingReady(const am_Error_e error)=0
confirms the setRoutingReady call
virtual am_Error_e hookSystemRegisterSource(const am_Source_s &sourceData, am_sourceID_t &sourceID)=0
is called when a routing adaptor registers a source
struct describung mainsound property
am_Error_e hookUserSetMainSourceNotificationConfiguration(const am_sourceID_t sourceID, const am_NotificationConfiguration_s ¬ificationConfiguration)
TAmShPollFired< CAmControlSender > receiverCallbackT
virtual void hookSystemInterruptStateChange(const am_sourceID_t sourceID, const am_InterruptState_e interruptState)=0
is called when an low level interrupt changed its state
virtual void cbAckSetSourceState(const am_Handle_s handle, const am_Error_e error)=0
ack for setting of source states
virtual am_Error_e hookUserSetSinkMuteState(const am_sinkID_t sinkID, const am_MuteState_e muteState)=0
sets the mute state of a sink
am_Error_e hookUserSetMainSinkNotificationConfiguration(const am_sinkID_t sinkID, const am_NotificationConfiguration_s ¬ificationConfiguration)
void cbAckConnect(const am_Handle_s handle, const am_Error_e errorID)
void cbAckSetSinkSoundProperty(const am_Handle_s handle, const am_Error_e error)
virtual am_Error_e hookSystemDeregisterSink(const am_sinkID_t sinkID)=0
is called when a routing adaptor deregisters a sink
virtual void cbAckSetVolumes(const am_Handle_s handle, const std::vector< am_Volumes_s > &listVolumes, const am_Error_e error)=0
ack for mulitple volume changes
a handle is used for asynchronous operations and is uniquely assigned for each of this operations ...
virtual void confirmCommandRundown(const am_Error_e error)=0
confirms the setCommandRundown call
void hookSystemTimingInformationChanged(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time)
am_Error_e hookSystemRegisterCrossfader(const am_Crossfader_s &crossfaderData, am_crossfaderID_t &crossfaderID)
virtual void hookSystemReceiveEarlyData(const std::vector< am_EarlyData_s > &data)=0
when early data was received
void setControllerReady()
uint16_t am_sourceID_t
a source ID
am_Error_e hookSystemRegisterGateway(const am_Gateway_s &gatewayData, am_gatewayID_t &gatewayID)
virtual void hookSystemSourceVolumeTick(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume)=0
volumeticks.
virtual void hookSystemTimingInformationChanged(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time)=0
this hook is fired whenever the timing information of a mainconnection has changed.
virtual am_Error_e hookSystemDeregisterGateway(const am_gatewayID_t gatewayID)=0
is called when a routing adaptor deregisters a gateway
void cbAckSetSourceState(const am_Handle_s handle, const am_Error_e error)
am_Error_e hookUserSetSinkMuteState(const am_sinkID_t sinkID, const am_MuteState_e muteState)
sends data to the commandInterface, takes the file of the library that needs to be loaded ...
am_Error_e hookUserConnectionRequest(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t &mainConnectionID)
virtual void setControllerRundown(const int16_t signal)=0
This message tells the controller that he should prepare everything for the power to be switched off...
virtual void hookSystemDomainRegistrationComplete(const am_domainID_t domainID)=0
is called when a domain registered all the elements
void cbAckSetSourceSoundProperty(const am_Handle_s handle, const am_Error_e error)
virtual void cbAckSetSourceSoundProperties(const am_Handle_s handle, const am_Error_e error)=0
ack for setting of sourcesoundproperties
am_Error_e hookSystemDeregisterDomain(const am_domainID_t domainID)
This struct describes the attributes of a converter.
virtual am_Error_e hookSystemUpdateGateway(const am_gatewayID_t gatewayID, const std::vector< am_CustomConnectionFormat_t > &listSourceConnectionFormats, const std::vector< am_CustomConnectionFormat_t > &listSinkConnectionFormats, const std::vector< bool > &convertionMatrix)=0
updates the Gateway Data
This interface is presented by the AudioManager controller.
a list of routing elements that lead from source to sink
virtual void cbAckDisconnect(const am_Handle_s handle, const am_Error_e errorID)=0
ack for disconnect
am_Error_e hookUserSetMainSourceSoundProperty(const am_sourceID_t sourceID, const am_MainSoundProperty_s &soundProperty)
am_HotSink_e
describes the active sink of a crossfader.
int16_t am_volume_t
The unit is 0.1 db steps,The smallest value -3000 (=AM_MUTE).
This struct describes the attribiutes of a crossfader.
virtual void confirmCommandReady(const am_Error_e error)=0
confirms the setCommandReady call
am_Error_e hookSystemUpdateSource(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector< am_SoundProperty_s > &listSoundProperties, const std::vector< am_CustomConnectionFormat_t > &listConnectionFormats, const std::vector< am_MainSoundProperty_s > &listMainSoundProperties)
void hookSystemSpeedChange(const am_speed_t speed)
virtual am_Error_e hookUserDisconnectionRequest(const am_mainConnectionID_t connectionID)=0
is called when a disconnection request comes in via the command interface
virtual void hookSystemSinkAvailablityStateChange(const am_sinkID_t sinkID, const am_Availability_s &availability)=0
id called when a sink changed its availability
void confirmCommandRundown(const am_Error_e error)
virtual am_Error_e hookSystemUpdateConverter(const am_converterID_t converterID, const std::vector< am_CustomConnectionFormat_t > &listSourceConnectionFormats, const std::vector< am_CustomConnectionFormat_t > &listSinkConnectionFormats, const std::vector< bool > &convertionMatrix)=0
updates the Converter Data
am_Error_e addFDPoll(const int fd, const short event, std::function< void(const sh_pollHandle_t handle, void *userData)> prepare, std::function< void(const pollfd pollfd, const sh_pollHandle_t handle, void *userData)> fired, std::function< bool(const sh_pollHandle_t handle, void *userData)> check, std::function< bool(const sh_pollHandle_t handle, void *userData)> dispatch, void *userData, sh_pollHandle_t &handle)
Adds a filedescriptor to the polling loop.
uint16_t am_sourceClass_t
virtual void confirmRoutingRundown(const am_Error_e error)=0
confirms the setRoutingRundown command
void cbAckSetVolume(const am_Handle_s handle, const std::vector< am_Volumes_s > &listVolumes, const am_Error_e error)
virtual void cbAckCrossFade(const am_Handle_s handle, const am_HotSink_e hostsink, const am_Error_e error)=0
ack for crossfading
void hookSystemSingleTimingInformationChanged(const am_connectionID_t connectionID, const am_timeSync_t time)
this describes the availability of a sink or a source together with the latest change ...
This struct describes the attributes of a gateway.
This interface gives access to all important functions of the audiomanager that are used by the Audio...
virtual am_Error_e hookSystemDeregisterDomain(const am_domainID_t domainID)=0
is called when a routing adaptor wants to derigister a domain
void logError(T value, TArgs...args)
logs given values with errorlevel with the default context
virtual am_Error_e hookSystemDeregisterConverter(const am_converterID_t converterID)=0
is called when a routing adaptor deregisters a converter
virtual am_Error_e hookSystemUpdateSink(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector< am_SoundProperty_s > &listSoundProperties, const std::vector< am_CustomConnectionFormat_t > &listConnectionFormats, const std::vector< am_MainSoundProperty_s > &listMainSoundProperties)=0
update form the SinkData
virtual am_Error_e hookSystemRegisterCrossfader(const am_Crossfader_s &crossfaderData, am_crossfaderID_t &crossfaderID)=0
is called when a routing adaptor registers a crossfader
virtual am_Error_e hookUserConnectionRequest(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t &mainConnectionID)=0
is called when a connection request comes in via the command interface
virtual void cbAckSetSourceVolumeChange(const am_Handle_s handle, const am_volume_t voulme, const am_Error_e error)=0
ack for source volume changes
am_Error_e hookSystemDeregisterConverter(const am_converterID_t converterID)
virtual am_Error_e startupController(IAmControlReceive *controlreceiveinterface)=0
Starts up the controller.
TAmShPollDispatch< CAmControlSender > dispatcherCallbackT
virtual void cbAckSetSinkSoundProperty(const am_Handle_s handle, const am_Error_e error)=0
ack for setting of sinksoundproperties
am_Error_e hookSystemDeregisterGateway(const am_gatewayID_t gatewayID)
uint16_t am_domainID_t
a domain ID
void hookSystemSourceVolumeTick(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume)
int16_t am_mainVolume_t
This is the volume presented on the command interface.
void cbAckSetSourceSoundProperties(const am_Handle_s handle, const am_Error_e error)
am_Error_e hookSystemDeregisterSource(const am_sourceID_t sourceID)
SPDX license identifier: MPL-2.0.
virtual am_Error_e hookUserSetMainSinkNotificationConfiguration(const am_sinkID_t sinkID, const am_NotificationConfiguration_s ¬ificationConfiguration)=0
sets a user MainSinkNotificationConfiguration
virtual void cbAckSetSourceSoundProperty(const am_Handle_s handle, const am_Error_e error)=0
ack for setting of sourcesoundproperties
void confirmRoutingRundown(const am_Error_e error)
virtual am_Error_e hookSystemDeregisterSource(const am_sourceID_t sourceID)=0
is called when a routing adaptor deregisters a source
uint16_t am_gatewayID_t
a gateway ID
This struct describes the attribiutes of a source.
virtual void hookSystemSourceAvailablityStateChange(const am_sourceID_t sourceID, const am_Availability_s &availability)=0
id called when a source changed its availability
uint16_t am_sinkID_t
a sink ID
uint16_t am_mainConnectionID_t
a mainConnection ID
void cbAckSetSourceVolumeChange(const am_Handle_s handle, const am_volume_t voulme, const am_Error_e error)
virtual am_Error_e hookSystemRegisterDomain(const am_Domain_s &domainData, am_domainID_t &domainID)=0
is called when a routing adaptor registers its domain
virtual void hookSystemSingleTimingInformationChanged(const am_connectionID_t connectionID, const am_timeSync_t time)=0
This hook is fired whenever the timing information of a connection has changed.
am_Error_e hookSystemRegisterDomain(const am_Domain_s &domainData, am_domainID_t &domainID)
virtual am_Error_e hookSystemRegisterSink(const am_Sink_s &sinkData, am_sinkID_t &sinkID)=0
is called when a routing adaptor registers a sink
virtual void hookSystemSinkVolumeTick(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume)=0
volumeticks.
am_Error_e hookUserVolumeStep(const am_sinkID_t SinkID, const int16_t increment)
virtual am_Error_e hookSystemRegisterGateway(const am_Gateway_s &gatewayData, am_gatewayID_t &gatewayID)=0
is called when a routing adaptor registers a gateway
void hookSystemReceiveEarlyData(const std::vector< am_EarlyData_s > &data)
virtual void getInterfaceVersion(std::string &version) const =0
This function returns the version of the interface returns E_OK, E_UNKOWN if version is unknown...
virtual am_Error_e hookUserSetMainSourceSoundProperty(const am_sourceID_t sourceID, const am_MainSoundProperty_s &soundProperty)=0
sets a user MainSourceSoundProperty