diff options
-rw-r--r-- | AudioManagerUtilities/include/CAmDltWrapper.h | 134 | ||||
-rw-r--r-- | AudioManagerUtilities/src/CAmDltWrapper.cpp | 102 | ||||
-rwxr-xr-x | include/audiomanagertypes.h | 68 |
3 files changed, 167 insertions, 137 deletions
diff --git a/AudioManagerUtilities/include/CAmDltWrapper.h b/AudioManagerUtilities/include/CAmDltWrapper.h index 4a00f6f..90ce903 100644 --- a/AudioManagerUtilities/include/CAmDltWrapper.h +++ b/AudioManagerUtilities/include/CAmDltWrapper.h @@ -194,194 +194,122 @@ public: #endif //WITH_DLT } + +private: + static const std::vector<const char*> mStr_error; + static const std::vector<const char*> mStr_sourceState; + static const std::vector<const char*> mStr_MuteState; + static const std::vector<const char*> mStr_DomainState; + static const std::vector<const char*> mStr_ConnectionState; + static const std::vector<const char*> mStr_Availability; + static const std::vector<const char*> mStr_Interrupt; + static const std::vector<const char*> mStr_Handle; + static const std::vector<const char*> mStr_NotificationStatus; + +public: // specialization for const am_Error_e template<typename T = const am_Error_e> void append(const am_Error_e value) { - const std::vector<const char*> str_error = { - "E_OK", - "E_UNKNOWN", - "E_OUT_OF_RANGE", - "E_NOT_USED", - "E_DATABASE_ERROR", - "E_ALREADY_EXISTS", - "E_NO_CHANGE", - "E_NOT_POSSIBLE", - "E_NON_EXISTENT", - "E_ABORTED", - "E_WRONG_FORMAT", - "E_COMMUNICATION", - "E_MAX" - }; - if ((int)value >=str_error.size()) + if ((int)value >=mStr_error.size()) { append("value for am_Error_e out of bounds!"); append(value); return; } - append(str_error[value]); + append(mStr_error[value]); } // specialization for const am_Error_e template<typename T = const am_SourceState_e> void append(const am_SourceState_e value) { - const std::vector<const char*> str_sourceState = { - "SS_UNKNNOWN", - "SS_ON", - "SS_OFF", - "SS_PAUSED", - "SS_MAX" - }; - if ((int)value >=(str_sourceState.size())) + if ((int)value >=(mStr_sourceState.size())) { append("value for am_SourceState_e out of bounds!"); append(value); return; } - append(str_sourceState[value]); + append(mStr_sourceState[value]); } template<typename T = const am_MuteState_e> void append(const am_MuteState_e value) { - const std::vector<const char*> str_MuteState= { - "MS_UNKNOWN" , - "MS_MUTED" , - "MS_UNMUTED" , - "MS_MAX" - }; - if ((int)value >=str_MuteState.size()) + if ((int)value >=mStr_MuteState.size()) { append("value for am_MuteState_e out of bounds!"); append(value); return; } - append(str_MuteState[value]); + append(mStr_MuteState[value]); } template<typename T = const am_DomainState_e> void append(const am_DomainState_e value) { - const std::vector<const char*> str_DomainState = { - "DS_UNKNOWN", - "DS_CONTROLLED", - "DS_INDEPENDENT_STARTUP", - "DS_INDEPENDENT_RUNDOWN", - "DS_MAX" - }; - if ((int)value >= str_DomainState.size()) + if ((int)value >= mStr_DomainState.size()) { append("value for am_DomainState_e out of bounds!"); append(value); return; } - append(str_DomainState[value]); + append(mStr_DomainState[value]); } template<typename T = const am_ConnectionState_e> void append(const am_ConnectionState_e value) { - const std::vector<const char*> str_ConnectionState = { - "CS_UNKNOWN", - "CS_CONNECTING", - "CS_CONNECTED", - "CS_DISCONNECTING", - "CS_DISCONNECTED", - "CS_SUSPENDED", - "CS_MAX" - }; - if ((int)value >=str_ConnectionState.size()) + if ((int)value >=mStr_ConnectionState.size()) { append("value for am_ConnectionState_e out of bounds!"); append(value); return; } - append(str_ConnectionState[value]); + append(mStr_ConnectionState[value]); } template<typename T = const am_Availability_e> void append(const am_Availability_e value) { - const std::vector<const char*> str_Availability = { - "A_UNKNOWN", - "A_AVAILABLE", - "A_UNAVAILABLE", - "A_MAX" - }; - if ((int)value >= str_Availability.size()) + if ((int)value >= mStr_Availability.size()) { append("value for am_Availability_e out of bounds!"); append(value); return; } - append(str_Availability[value]); + append(mStr_Availability[value]); } template<typename T = const am_InterruptState_e> void append(const am_InterruptState_e value) { - const std::vector<const char*> str_Interrupt = { - "IS_UNKNOWN", - "IS_OFF", - "IS_INTERRUPTED", - "IS_MAX" - }; - if ((int)value >=str_Interrupt.size()) + if ((int)value >=mStr_Interrupt.size()) { append("value for am_InterruptState_e out of bounds!"); append(value); return; } - append(str_Interrupt[value]); + append(mStr_Interrupt[value]); } template<typename T = const am_Handle_e> void append(const am_Handle_e value) { - const std::vector<const char*> str_Handle = { - "H_UNKNOWN", - "H_CONNECT", - "H_DISCONNECT", - "H_SETSOURCESTATE", - "H_SETSINKVOLUME", - "H_SETSOURCEVOLUME", - "H_SETSINKSOUNDPROPERTY", - "H_SETSOURCESOUNDPROPERTY", - "H_SETSINKSOUNDPROPERTIES", - "H_SETSOURCESOUNDPROPERTIES", - "H_CROSSFADE", - "H_SETVOLUMES", - "H_SETSINKNOTIFICATION", - "H_SETSOURCENOTIFICATION", - "H_MAX" - }; - if ((int)value >=str_Handle.size()) + if ((int)value >=mStr_Handle.size()) { append("value for am_Handle_e out of bounds!"); append(value); return; } - append(str_Handle[value]); + append(mStr_Handle[value]); } template<typename T = const am_NotificationStatus_e> void append(const am_NotificationStatus_e value) { - const std::vector<const char*> str_NotificationStatus = { - "NS_UNKNOWN", - "NS_OFF", - "NS_PERIODIC", - "NS_MINIMUM", - "NS_MAXIMUM", - "NS_CHANGE", - "NS_MAX" - }; - if ((int)value >=str_NotificationStatus.size()) + if ((int)value >=mStr_NotificationStatus.size()) { append("value for am_NotificationStatus_e out of bounds!"); append(value); return; } - append(str_NotificationStatus[value]); + append(mStr_NotificationStatus[value]); } - - - // Template to print unknown pointer types with their address template<typename T> void append(T* value) { diff --git a/AudioManagerUtilities/src/CAmDltWrapper.cpp b/AudioManagerUtilities/src/CAmDltWrapper.cpp index b116e53..4b82e33 100644 --- a/AudioManagerUtilities/src/CAmDltWrapper.cpp +++ b/AudioManagerUtilities/src/CAmDltWrapper.cpp @@ -35,6 +35,108 @@ namespace am CAmDltWrapper* CAmDltWrapper::mpDLTWrapper = NULL; pthread_mutex_t CAmDltWrapper::mMutex = PTHREAD_MUTEX_INITIALIZER; +const std::vector<const char*> CAmDltWrapper::mStr_error = +{ + "E_OK", + "E_UNKNOWN", + "E_OUT_OF_RANGE", + "E_NOT_USED", + "E_DATABASE_ERROR", + "E_ALREADY_EXISTS", + "E_NO_CHANGE", + "E_NOT_POSSIBLE", + "E_NON_EXISTENT", + "E_ABORTED", + "E_WRONG_FORMAT", + "E_COMMUNICATION", + "E_MAX" +}; + +const std::vector<const char*> CAmDltWrapper::mStr_sourceState = +{ + "SS_UNKNNOWN", + "SS_ON", + "SS_OFF", + "SS_PAUSED", + "SS_MAX" +}; + +const std::vector<const char*> CAmDltWrapper::mStr_MuteState = +{ + "MS_UNKNOWN" , + "MS_MUTED" , + "MS_UNMUTED" , + "MS_MAX" +}; + +const std::vector<const char*> CAmDltWrapper::mStr_DomainState = +{ + "DS_UNKNOWN", + "DS_CONTROLLED", + "DS_INDEPENDENT_STARTUP", + "DS_INDEPENDENT_RUNDOWN", + "DS_MAX" +}; + +const std::vector<const char*> CAmDltWrapper::mStr_ConnectionState = +{ + "CS_UNKNOWN", + "CS_CONNECTING", + "CS_CONNECTED", + "CS_DISCONNECTING", + "CS_DISCONNECTED", + "CS_SUSPENDED", + "CS_MAX" +}; + +const std::vector<const char*> CAmDltWrapper::mStr_Availability = +{ + "A_UNKNOWN", + "A_AVAILABLE", + "A_UNAVAILABLE", + "A_MAX" +}; + +const std::vector<const char*> CAmDltWrapper::mStr_Interrupt = +{ + "IS_UNKNOWN", + "IS_OFF", + "IS_INTERRUPTED", + "IS_MAX" +}; + +const std::vector<const char*> CAmDltWrapper::mStr_Handle = +{ + "H_UNKNOWN", + "H_CONNECT", + "H_DISCONNECT", + "H_SETSOURCESTATE", + "H_SETSINKVOLUME", + "H_SETSOURCEVOLUME", + "H_SETSINKSOUNDPROPERTY", + "H_SETSOURCESOUNDPROPERTY", + "H_SETSINKSOUNDPROPERTIES", + "H_SETSOURCESOUNDPROPERTIES", + "H_CROSSFADE", + "H_SETVOLUMES", + "H_SETSINKNOTIFICATION", + "H_SETSOURCENOTIFICATION", + "H_MAX" +}; + +const std::vector<const char*> CAmDltWrapper::mStr_NotificationStatus = +{ + "NS_UNKNOWN", + "NS_OFF", + "NS_PERIODIC", + "NS_MINIMUM", + "NS_MAXIMUM", + "NS_CHANGE", + "NS_MAX" +}; + + + std::string CAmDltWrapper::now() { std::time_t t(std::chrono::system_clock::to_time_t(std::chrono::system_clock::now())); diff --git a/include/audiomanagertypes.h b/include/audiomanagertypes.h index be3365c..d015737 100755 --- a/include/audiomanagertypes.h +++ b/include/audiomanagertypes.h @@ -31,9 +31,9 @@ //so we need the macro here
#if defined __cplusplus
-#define CONST const
+#define A_CONST const
#else
-#define CONST static const
+#define A_CONST static const
#endif
@@ -89,7 +89,7 @@ typedef uint16_t am_speed_t; * maximum can be limited by actual project.
*/
typedef int16_t am_volume_t;
-CONST am_volume_t AM_MUTE = -3000;
+A_CONST am_volume_t AM_MUTE = -3000;
/**
* This is the volume presented on the command interface. It is in the duty of the
@@ -117,28 +117,28 @@ typedef int16_t am_timeSync_t; * This type gives the information about reason for reason for Source/Sink change
*/
typedef uint16_t am_CustomAvailabilityReason_t;
-CONST am_CustomAvailabilityReason_t AR_UNKNOWN = 0;
+A_CONST am_CustomAvailabilityReason_t AR_UNKNOWN = 0;
/** new media was entered */
-CONST am_CustomAvailabilityReason_t AR_GENIVI_NEWMEDIA = 1;
+A_CONST am_CustomAvailabilityReason_t AR_GENIVI_NEWMEDIA = 1;
/** same media was entered */
-CONST am_CustomAvailabilityReason_t AR_GENIVI_SAMEMEDIA = 2;
+A_CONST am_CustomAvailabilityReason_t AR_GENIVI_SAMEMEDIA = 2;
/** there is no media or media is removed */
-CONST am_CustomAvailabilityReason_t AR_GENIVI_NOMEDIA = 3;
+A_CONST am_CustomAvailabilityReason_t AR_GENIVI_NOMEDIA = 3;
/** there was a temperature event */
-CONST am_CustomAvailabilityReason_t AR_GENIVI_TEMPERATURE = 4;
+A_CONST am_CustomAvailabilityReason_t AR_GENIVI_TEMPERATURE = 4;
/** there was a voltage event */
-CONST am_CustomAvailabilityReason_t AR_GENIVI_VOLTAGE = 5;
+A_CONST am_CustomAvailabilityReason_t AR_GENIVI_VOLTAGE = 5;
/** fatal errors on reading or accessing media */
-CONST am_CustomAvailabilityReason_t AR_GENIVI_ERRORMEDIA = 6;
+A_CONST am_CustomAvailabilityReason_t AR_GENIVI_ERRORMEDIA = 6;
/**
* This is a custom specific identifier of property. It can be used to
* differentiate between interrupt source/sink, main source/sink, etc.
*/
typedef uint16_t am_CustomClassProperty_t;
-CONST am_CustomClassProperty_t CP_UNKNOWN = 0;
-CONST am_CustomClassProperty_t CP_GENIVI_SOURCE_TYPE = 1;
-CONST am_CustomClassProperty_t CP_GENIVI_SINK_TYPE = 2;
+A_CONST am_CustomClassProperty_t CP_UNKNOWN = 0;
+A_CONST am_CustomClassProperty_t CP_GENIVI_SOURCE_TYPE = 1;
+A_CONST am_CustomClassProperty_t CP_GENIVI_SINK_TYPE = 2;
/**
* This type classifies the format in which data is exchanged within a connection.
@@ -146,27 +146,27 @@ CONST am_CustomClassProperty_t CP_GENIVI_SINK_TYPE = 2; * defined.
*/
typedef uint16_t am_CustomConnectionFormat_t;
-CONST am_CustomConnectionFormat_t CF_UNKNOWN = 0;
-CONST am_CustomConnectionFormat_t CF_GENIVI_MONO = 1;
-CONST am_CustomConnectionFormat_t CF_GENIVI_STEREO = 2;
-CONST am_CustomConnectionFormat_t CF_GENIVI_ANALOG = 3;
-CONST am_CustomConnectionFormat_t CF_GENIVI_AUTO = 4;
+A_CONST am_CustomConnectionFormat_t CF_UNKNOWN = 0;
+A_CONST am_CustomConnectionFormat_t CF_GENIVI_MONO = 1;
+A_CONST am_CustomConnectionFormat_t CF_GENIVI_STEREO = 2;
+A_CONST am_CustomConnectionFormat_t CF_GENIVI_ANALOG = 3;
+A_CONST am_CustomConnectionFormat_t CF_GENIVI_AUTO = 4;
/**
* Here are all SoundProperties that can be set via the CommandInterface.
* This type is product specific and can be changed or extended.
*/
typedef uint16_t am_CustomMainSoundPropertyType_t;
-CONST am_CustomMainSoundPropertyType_t MSP_UNKNOWN = 0;
-CONST am_CustomMainSoundPropertyType_t MSP_GENIVI_TREBLE = 1;
-CONST am_CustomMainSoundPropertyType_t MSP_GENIVI_MID = 2;
-CONST am_CustomMainSoundPropertyType_t MSP_GENIVI_BASS = 3;
+A_CONST am_CustomMainSoundPropertyType_t MSP_UNKNOWN = 0;
+A_CONST am_CustomMainSoundPropertyType_t MSP_GENIVI_TREBLE = 1;
+A_CONST am_CustomMainSoundPropertyType_t MSP_GENIVI_MID = 2;
+A_CONST am_CustomMainSoundPropertyType_t MSP_GENIVI_BASS = 3;
/**
* The notification types are project specific.
*/
typedef uint16_t am_CustomNotificationType_t;
-CONST am_CustomNotificationType_t NT_UNKNOWN = 0;
+A_CONST am_CustomNotificationType_t NT_UNKNOWN = 0;
/**
* The given ramp types here are just examples. For products, different ramp types
@@ -174,33 +174,33 @@ CONST am_CustomNotificationType_t NT_UNKNOWN = 0; * that the routing plugins are aware of the ramp types used.
*/
typedef uint16_t am_CustomRampType_t;
-CONST am_CustomRampType_t RAMP_UNKNOWN = 0;
+A_CONST am_CustomRampType_t RAMP_UNKNOWN = 0;
/** sets directly the value without a ramp */
-CONST am_CustomRampType_t RAMP_GENIVI_DIRECT = 1;
+A_CONST am_CustomRampType_t RAMP_GENIVI_DIRECT = 1;
/** Sets the volume as fast as possible */
-CONST am_CustomRampType_t RAMP_GENIVI_NO_PLOP = 2;
+A_CONST am_CustomRampType_t RAMP_GENIVI_NO_PLOP = 2;
/** inverted exponential update, high gradient at the start - soft end */
-CONST am_CustomRampType_t RAMP_GENIVI_EXP_INV = 3;
+A_CONST am_CustomRampType_t RAMP_GENIVI_EXP_INV = 3;
/** continues update of volume */
-CONST am_CustomRampType_t RAMP_GENIVI_LINEAR = 4;
+A_CONST am_CustomRampType_t RAMP_GENIVI_LINEAR = 4;
/** exponential update, soft start - high gradient at the end */
-CONST am_CustomRampType_t RAMP_GENIVI_EXP = 5;
+A_CONST am_CustomRampType_t RAMP_GENIVI_EXP = 5;
/**
* Within genivi only the some example properties are defined.
* For products these should be changed or extended.
*/
typedef uint16_t am_CustomSoundPropertyType_t;
-CONST am_CustomSoundPropertyType_t SP_UNKNOWN = 0;
-CONST am_CustomSoundPropertyType_t SP_GENIVI_TREBLE = 1;
-CONST am_CustomSoundPropertyType_t SP_GENIVI_MID = 2;
-CONST am_CustomSoundPropertyType_t SP_GENIVI_BASS = 3;
+A_CONST am_CustomSoundPropertyType_t SP_UNKNOWN = 0;
+A_CONST am_CustomSoundPropertyType_t SP_GENIVI_TREBLE = 1;
+A_CONST am_CustomSoundPropertyType_t SP_GENIVI_MID = 2;
+A_CONST am_CustomSoundPropertyType_t SP_GENIVI_BASS = 3;
/**
* Describes the different system properties which are project specific.
*/
typedef uint16_t am_CustomSystemPropertyType_t;
-CONST am_CustomSystemPropertyType_t SYP_UNKNOWN = 0;
+A_CONST am_CustomSystemPropertyType_t SYP_UNKNOWN = 0;
/**
* describes the active sink of a crossfader.
|