summaryrefslogtreecommitdiff
path: root/AudioManagerDaemon
diff options
context:
space:
mode:
authorChristian Mueller <christian@lmuc329619u.(none)>2011-12-12 21:43:47 +0100
committerChristian Mueller <christian@lmuc329619u.(none)>2011-12-12 21:43:47 +0100
commit205595e3d3e6a1d55be3c462ef02c9f828a77feb (patch)
tree9c1202619c7b9a66ed874ca1a0c81530ae06e426 /AudioManagerDaemon
parentd85e69bbf6d8ec6e087c7af579686923c76079cd (diff)
downloadaudiomanager-205595e3d3e6a1d55be3c462ef02c9f828a77feb.tar.gz
some updates, new tests
Diffstat (limited to 'AudioManagerDaemon')
-rw-r--r--AudioManagerDaemon/CMakeLists.txt9
-rw-r--r--AudioManagerDaemon/Doxyfile.in1661
-rw-r--r--AudioManagerDaemon/include/CommandReceiver.h29
-rw-r--r--AudioManagerDaemon/include/CommandSender.h10
-rw-r--r--AudioManagerDaemon/include/ControlReceiver.h4
-rw-r--r--AudioManagerDaemon/include/ControlSender.h62
-rw-r--r--AudioManagerDaemon/include/DatabaseHandler.h92
-rw-r--r--AudioManagerDaemon/include/Observer.h45
-rw-r--r--AudioManagerDaemon/include/RoutingReceiver.h13
-rw-r--r--AudioManagerDaemon/include/RoutingSender.h62
-rw-r--r--AudioManagerDaemon/include/pluginTemplate.h7
-rw-r--r--AudioManagerDaemon/src/CommandReceiver.cpp31
-rw-r--r--AudioManagerDaemon/src/CommandSender.cpp22
-rw-r--r--AudioManagerDaemon/src/ControlReceiver.cpp82
-rw-r--r--AudioManagerDaemon/src/ControlSender.cpp287
-rw-r--r--AudioManagerDaemon/src/DBusWrapper.cpp2
-rw-r--r--AudioManagerDaemon/src/DatabaseHandler.cpp1020
-rw-r--r--AudioManagerDaemon/src/Observer.cpp188
-rw-r--r--AudioManagerDaemon/src/RoutingReceiver.cpp62
-rw-r--r--AudioManagerDaemon/src/RoutingSender.cpp133
-rw-r--r--AudioManagerDaemon/src/main.cpp14
-rw-r--r--AudioManagerDaemon/test/CMakeLists.txt50
-rw-r--r--AudioManagerDaemon/test/CommandInterfaceBackdoor.h27
-rw-r--r--AudioManagerDaemon/test/CommonFunctions.cpp368
-rw-r--r--AudioManagerDaemon/test/CommonFunctions.h74
-rw-r--r--AudioManagerDaemon/test/ControlInterfaceBackdoor.h25
-rw-r--r--AudioManagerDaemon/test/RoutingInterfaceBackdoor.h27
-rw-r--r--AudioManagerDaemon/test/controlInterface/CMakeLists.txt79
-rw-r--r--AudioManagerDaemon/test/controlInterface/MockControlInterface.h103
-rw-r--r--AudioManagerDaemon/test/controlInterface/controlInterfaceTest.cpp82
-rw-r--r--AudioManagerDaemon/test/controlInterface/controlInterfaceTest.h53
-rw-r--r--AudioManagerDaemon/test/database/CMakeLists.txt73
-rw-r--r--AudioManagerDaemon/test/database/databaseTest.cpp (renamed from AudioManagerDaemon/test/databasetest.cpp)727
-rw-r--r--AudioManagerDaemon/test/database/databaseTest.h37
-rw-r--r--AudioManagerDaemon/test/databasetest.h109
-rw-r--r--AudioManagerDaemon/test/routingInterface/CMakeLists.txt77
-rw-r--r--AudioManagerDaemon/test/routingInterface/MockRoutingInterface.h52
-rw-r--r--AudioManagerDaemon/test/routingInterface/routingInterfaceTest.cpp415
-rw-r--r--AudioManagerDaemon/test/routingInterface/routingInterfaceTest.h49
39 files changed, 5420 insertions, 842 deletions
diff --git a/AudioManagerDaemon/CMakeLists.txt b/AudioManagerDaemon/CMakeLists.txt
index aab505c..d591de6 100644
--- a/AudioManagerDaemon/CMakeLists.txt
+++ b/AudioManagerDaemon/CMakeLists.txt
@@ -13,9 +13,10 @@ cmake_minimum_required(VERSION 2.6)
PROJECT(AudioManagerDeamon)
-set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xlinker -export-dynamic")
-set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic")
-set(CMAKE_CXX_FLAGS "-g -pipe -g -Wall -W -D_REENTRANT")
+set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -rdynamic")
+#set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic")
+set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
+
##todo only when dbus needed!
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}")
@@ -39,7 +40,6 @@ pkg_check_modules(DLT REQUIRED automotive-dlt)
##todo: only when dbus is reuqired !
find_package (Threads)
FIND_PACKAGE(DBUS REQUIRED)
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR} ${STD_INCLUDE_DIRS})
file(GLOB AUDIOMAN_SRCS_CXX "src/*.cpp")
@@ -55,7 +55,6 @@ INCLUDE_DIRECTORIES(
${DBUS_INCLUDES_FOLDER}
)
-
ADD_EXECUTABLE(AudioManager ${AUDIOMAN_SRCS_CXX})
##todo only when dbus is required
diff --git a/AudioManagerDaemon/Doxyfile.in b/AudioManagerDaemon/Doxyfile.in
new file mode 100644
index 0000000..bb1ef58
--- /dev/null
+++ b/AudioManagerDaemon/Doxyfile.in
@@ -0,0 +1,1661 @@
+# Doxyfile 1.7.1
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project
+#
+# All text after a hash (#) is considered a comment and will be ignored
+# The format is:
+# TAG = value [value, ...]
+# For lists items can also be appended using:
+# TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ")
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# This tag specifies the encoding used for all characters in the config file
+# that follow. The default is UTF-8 which is also the encoding used for all
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the
+# iconv built into libc) for the transcoding. See
+# http://www.gnu.org/software/libiconv for the list of possible encodings.
+
+DOXYFILE_ENCODING = UTF-8
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
+# by quotes) that should identify the project.
+
+PROJECT_NAME = AudioManager
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number.
+# This could be handy for archiving the generated documentation or
+# if some version control system is used.
+
+PROJECT_NUMBER = 0.1
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
+# base path where the generated documentation will be put.
+# If a relative path is entered, it will be relative to the location
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY =
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
+# 4096 sub-directories (in 2 levels) under the output directory of each output
+# format and will distribute the generated files over these directories.
+# Enabling this option can be useful when feeding doxygen a huge amount of
+# source files, where putting all generated files in the same directory would
+# otherwise cause performance problems for the file system.
+
+CREATE_SUBDIRS = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# The default language is English, other supported languages are:
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
+# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German,
+# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English
+# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian,
+# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak,
+# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
+
+OUTPUT_LANGUAGE = English
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
+# include brief member descriptions after the members that are listed in
+# the file and class documentation (similar to JavaDoc).
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
+# the brief description of a member or function before the detailed description.
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator
+# that is used to form the text in various listings. Each string
+# in this list, if found as the leading text of the brief description, will be
+# stripped from the text and the result after processing the whole list, is
+# used as the annotated text. Otherwise, the brief description is used as-is.
+# If left blank, the following values are used ("$name" is automatically
+# replaced with the name of the entity): "The $name class" "The $name widget"
+# "The $name file" "is" "provides" "specifies" "contains"
+# "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF = "The $name class" \
+ "The $name widget" \
+ "The $name file" \
+ is \
+ provides \
+ specifies \
+ contains \
+ represents \
+ a \
+ an \
+ the
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# Doxygen will generate a detailed section even if there is only a brief
+# description.
+
+ALWAYS_DETAILED_SEC = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
+# inherited members of a class in the documentation of that class as if those
+# members were ordinary class members. Constructors, destructors and assignment
+# operators of the base classes will not be shown.
+
+INLINE_INHERITED_MEMB = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
+# path before files name in the file list and in the header files. If set
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES = YES
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
+# can be used to strip a user-defined part of the path. Stripping is
+# only done if one of the specified strings matches the left-hand part of
+# the path. The tag can be used to show relative paths in the file list.
+# If left blank the directory from which doxygen is run is used as the
+# path to strip.
+
+STRIP_FROM_PATH =
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
+# the path mentioned in the documentation of a class, which tells
+# the reader which header file to include in order to use a class.
+# If left blank only the name of the header file containing the class
+# definition is used. Otherwise one should specify the include paths that
+# are normally passed to the compiler using the -I flag.
+
+STRIP_FROM_INC_PATH =
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
+# (but less readable) file names. This can be useful is your file systems
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
+# will interpret the first line (until the first dot) of a JavaDoc-style
+# comment as the brief description. If set to NO, the JavaDoc
+# comments will behave just like regular Qt-style comments
+# (thus requiring an explicit @brief command for a brief description.)
+
+JAVADOC_AUTOBRIEF = YES
+
+# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
+# interpret the first line (until the first dot) of a Qt-style
+# comment as the brief description. If set to NO, the comments
+# will behave just like regular Qt-style comments (thus requiring
+# an explicit \brief command for a brief description.)
+
+QT_AUTOBRIEF = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
+# treat a multi-line C++ special comment block (i.e. a block of //! or ///
+# comments) as a brief description. This used to be the default behaviour.
+# The new default is to treat a multi-line C++ comment block as a detailed
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
+# member inherits the documentation from any documented member that it
+# re-implements.
+
+INHERIT_DOCS = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
+# a new page for each member. If set to NO, the documentation of a member will
+# be part of the file/class/namespace that contains it.
+
+SEPARATE_MEMBER_PAGES = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab.
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE = 8
+
+# This tag can be used to specify a number of aliases that acts
+# as commands in the documentation. An alias has the form "name=value".
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to
+# put the command \sideeffect (or @sideeffect) in the documentation, which
+# will result in a user-defined paragraph with heading "Side Effects:".
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES =
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
+# sources only. Doxygen will then generate output that is more tailored for C.
+# For instance, some of the names that are used will be different. The list
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C = NO
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
+# sources only. Doxygen will then generate output that is more tailored for
+# Java. For instance, namespaces will be presented as packages, qualified
+# scopes will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA = NO
+
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
+# sources only. Doxygen will then generate output that is more tailored for
+# Fortran.
+
+OPTIMIZE_FOR_FORTRAN = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
+# sources. Doxygen will then generate output that is tailored for
+# VHDL.
+
+OPTIMIZE_OUTPUT_VHDL = NO
+
+# Doxygen selects the parser to use depending on the extension of the files it
+# parses. With this tag you can assign which parser to use for a given extension.
+# Doxygen has a built-in mapping, but you can override or extend it using this
+# tag. The format is ext=language, where ext is a file extension, and language
+# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C,
+# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make
+# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C
+# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions
+# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen.
+
+EXTENSION_MAPPING =
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
+# to include (a tag file for) the STL sources as input, then you should
+# set this tag to YES in order to let doxygen match functions declarations and
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
+# func(std::string) {}). This also make the inheritance and collaboration
+# diagrams that involve STL classes more complete and accurate.
+
+BUILTIN_STL_SUPPORT = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to
+# enable parsing support.
+
+CPP_CLI_SUPPORT = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
+# Doxygen will parse them like normal C++ but will assume all classes use public
+# instead of private inheritance when no explicit protection keyword is present.
+
+SIP_SUPPORT = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate getter
+# and setter methods for a property. Setting this option to YES (the default)
+# will make doxygen to replace the get and set methods by a property in the
+# documentation. This will only work if the methods are indeed getting or
+# setting a simple type. If this is not the case, or you want to show the
+# methods anyway, you should set this option to NO.
+
+IDL_PROPERTY_SUPPORT = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES, then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
+# the same type (for instance a group of public functions) to be put as a
+# subgroup of that type (e.g. under the Public Functions section). Set it to
+# NO to prevent subgrouping. Alternatively, this can be done per class using
+# the \nosubgrouping command.
+
+SUBGROUPING = YES
+
+# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
+# is documented as struct, union, or enum with the name of the typedef. So
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
+# with name TypeT. When disabled the typedef will appear as a member of a file,
+# namespace, or class. And the struct will be named TypeS. This can typically
+# be useful for C code in case the coding convention dictates that all compound
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+
+TYPEDEF_HIDES_STRUCT = YES
+
+# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to
+# determine which symbols to keep in memory and which to flush to disk.
+# When the cache is full, less often used symbols will be written to disk.
+# For small to medium size projects (<1000 input files) the default value is
+# probably good enough. For larger projects a too small cache size can cause
+# doxygen to be busy swapping symbols to and from disk most of the time
+# causing a significant performance penality.
+# If the system has enough physical memory increasing the cache will improve the
+# performance by keeping more symbols in memory. Note that the value works on
+# a logarithmic scale so increasing the size by one will rougly double the
+# memory usage. The cache size is given by this formula:
+# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
+# corresponding to a cache size of 2^16 = 65536 symbols
+
+SYMBOL_CACHE_SIZE = 0
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
+# documentation are documented, even if no documentation was available.
+# Private class members and static file members will be hidden unless
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL = YES
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
+# will be included in the documentation.
+
+EXTRACT_PRIVATE = YES
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file
+# will be included in the documentation.
+
+EXTRACT_STATIC = YES
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
+# defined locally in source files will be included in the documentation.
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES = YES
+
+# This flag is only useful for Objective-C code. When set to YES local
+# methods, which are defined in the implementation section but not in
+# the interface are included in the documentation.
+# If set to NO (the default) only methods in the interface are included.
+
+EXTRACT_LOCAL_METHODS = YES
+
+# If this flag is set to YES, the members of anonymous namespaces will be
+# extracted and appear in the documentation as a namespace called
+# 'anonymous_namespace{file}', where file will be replaced with the base
+# name of the file that contains the anonymous namespace. By default
+# anonymous namespace are hidden.
+
+EXTRACT_ANON_NSPACES = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
+# undocumented members of documented classes, files or namespaces.
+# If set to NO (the default) these members will be included in the
+# various overviews, but no documentation section is generated.
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy.
+# If set to NO (the default) these classes will be included in the various
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
+# friend (class|struct|union) declarations.
+# If set to NO (the default) these declarations will be included in the
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
+# documentation blocks found inside the body of a function.
+# If set to NO (the default) these blocks will be appended to the
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS = NO
+
+# The INTERNAL_DOCS tag determines if documentation
+# that is typed after a \internal command is included. If the tag is set
+# to NO (the default) then the documentation will be excluded.
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
+# file names in lower-case letters. If set to YES upper-case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
+# and Mac users are advised to set this option to NO.
+
+CASE_SENSE_NAMES = NO
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
+# will show members with their full class and namespace scopes in the
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES = NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
+# will put a list of the files that are included by a file in the documentation
+# of that file.
+
+SHOW_INCLUDE_FILES = YES
+
+# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen
+# will list include files with double quotes in the documentation
+# rather than with sharp brackets.
+
+FORCE_LOCAL_INCLUDES = NO
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
+# is inserted in the documentation for inline members.
+
+INLINE_INFO = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
+# will sort the (detailed) documentation of file and class members
+# alphabetically by member name. If set to NO the members will appear in
+# declaration order.
+
+SORT_MEMBER_DOCS = YES
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
+# brief documentation of file, namespace and class members alphabetically
+# by member name. If set to NO (the default) the members will appear in
+# declaration order.
+
+SORT_BRIEF_DOCS = YES
+
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen
+# will sort the (brief and detailed) documentation of class members so that
+# constructors and destructors are listed first. If set to NO (the default)
+# the constructors will appear in the respective orders defined by
+# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS.
+# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO
+# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
+
+SORT_MEMBERS_CTORS_1ST = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
+# hierarchy of group names into alphabetical order. If set to NO (the default)
+# the group names will appear in their defined order.
+
+SORT_GROUP_NAMES = YES
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
+# sorted by fully-qualified names, including namespaces. If set to
+# NO (the default), the class list will be sorted only by class name,
+# not including the namespace part.
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the
+# alphabetical list.
+
+SORT_BY_SCOPE_NAME = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or
+# disable (NO) the todo list. This list is created by putting \todo
+# commands in the documentation.
+
+GENERATE_TODOLIST = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or
+# disable (NO) the test list. This list is created by putting \test
+# commands in the documentation.
+
+GENERATE_TESTLIST = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or
+# disable (NO) the bug list. This list is created by putting \bug
+# commands in the documentation.
+
+GENERATE_BUGLIST = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
+# disable (NO) the deprecated list. This list is created by putting
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS =
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
+# the initial value of a variable or define consists of for it to appear in
+# the documentation. If the initializer consists of more lines than specified
+# here it will be hidden. Use a value of 0 to hide initializers completely.
+# The appearance of the initializer of individual variables and defines in the
+# documentation can be controlled using \showinitializer or \hideinitializer
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
+# at the bottom of the documentation of classes and structs. If set to YES the
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES = YES
+
+# If the sources in your project are distributed over multiple directories
+# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
+# in the documentation. The default is NO.
+
+SHOW_DIRECTORIES = NO
+
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
+# This will remove the Files entry from the Quick Index and from the
+# Folder Tree View (if specified). The default is YES.
+
+SHOW_FILES = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the
+# Namespaces page. This will remove the Namespaces entry from the Quick Index
+# and from the Folder Tree View (if specified). The default is YES.
+
+SHOW_NAMESPACES = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
+# doxygen should invoke to get the current version for each file (typically from
+# the version control system). Doxygen will invoke the program by executing (via
+# popen()) the command <command> <input-file>, where <command> is the value of
+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
+# provided by doxygen. Whatever the program writes to standard output
+# is used as the file version. See the manual for examples.
+
+FILE_VERSION_FILTER =
+
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed
+# by doxygen. The layout file controls the global structure of the generated
+# output files in an output format independent way. The create the layout file
+# that represents doxygen's defaults, run doxygen with the -l option.
+# You can optionally specify a file name after the option, if omitted
+# DoxygenLayout.xml will be used as the name of the layout file.
+
+LAYOUT_FILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated by doxygen. Possible values are YES and NO. If left blank
+# NO is used.
+
+WARNINGS = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED = YES
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some
+# parameters in a documented function, or documenting parameters that
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR = YES
+
+# This WARN_NO_PARAMDOC option can be abled to get warnings for
+# functions that are documented, but have no documentation for their parameters
+# or return value. If set to NO (the default) doxygen will only warn about
+# wrong or incomplete parameter documentation, but not about the absence of
+# documentation.
+
+WARN_NO_PARAMDOC = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that
+# doxygen can produce. The string should contain the $file, $line, and $text
+# tags, which will be replaced by the file and line number from which the
+# warning originated and the warning text. Optionally the format may contain
+# $version, which will be replaced by the version of the file (if it could
+# be obtained via FILE_VERSION_FILTER)
+
+WARN_FORMAT = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning
+# and error messages should be written. If left blank the output is written
+# to stderr.
+
+WARN_LOGFILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain
+# documented source files. You may enter file names like "myfile.cpp" or
+# directories like "/usr/src/myproject". Separate the files or directories
+# with spaces.
+
+INPUT = @CMAKE_CURRENT_SOURCE_DIR@
+
+# This tag can be used to specify the character encoding of the source files
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
+# also the default input encoding. Doxygen uses libiconv (or the iconv built
+# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
+# the list of possible encodings.
+
+INPUT_ENCODING = UTF-8
+
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank the following patterns are tested:
+# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
+# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
+
+FILE_PATTERNS = *.c \
+ *.cc \
+ *.cxx \
+ *.cpp \
+ *.c++ \
+ *.d \
+ *.java \
+ *.ii \
+ *.ixx \
+ *.ipp \
+ *.i++ \
+ *.inl \
+ *.h \
+ *.hh \
+ *.hxx \
+ *.hpp \
+ *.h++ \
+ *.idl \
+ *.odl \
+ *.cs \
+ *.php \
+ *.php3 \
+ *.inc \
+ *.m \
+ *.mm \
+ *.dox \
+ *.py \
+ *.f90 \
+ *.f \
+ *.vhd \
+ *.vhdl
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories
+# should be searched for input files as well. Possible values are YES and NO.
+# If left blank NO is used.
+
+RECURSIVE = YES
+
+# The EXCLUDE tag can be used to specify files and/or directories that should
+# excluded from the INPUT source files. This way you can easily exclude a
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+
+EXCLUDE =
+
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
+# directories that are symbolic links (a Unix filesystem feature) are excluded
+# from the input.
+
+EXCLUDE_SYMLINKS = NO
+
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories. Note that the wildcards are matched
+# against the file with absolute path, so to exclude all test directories
+# for example use the pattern */test/*
+
+EXCLUDE_PATTERNS =
+
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
+# (namespaces, classes, functions, etc.) that should be excluded from the
+# output. The symbol name can be a fully qualified name, a word, or if the
+# wildcard * is used, a substring. Examples: ANamespace, AClass,
+# AClass::ANamespace, ANamespace::*Test
+
+EXCLUDE_SYMBOLS =
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or
+# directories that contain example code fragments that are included (see
+# the \include command).
+
+EXAMPLE_PATH =
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank all files are included.
+
+EXAMPLE_PATTERNS = *
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
+# searched for input files to be used with the \include or \dontinclude
+# commands irrespective of the value of the RECURSIVE tag.
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or
+# directories that contain image that are included in the documentation (see
+# the \image command).
+
+IMAGE_PATH = ../../AudioManGUI
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should
+# invoke to filter for each input file. Doxygen will invoke the filter program
+# by executing (via popen()) the command <filter> <input-file>, where <filter>
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
+# input file. Doxygen will then use the output that the filter program writes
+# to standard output. If FILTER_PATTERNS is specified, this tag will be
+# ignored.
+
+INPUT_FILTER =
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
+# basis. Doxygen will compare the file name with each pattern and apply the
+# filter if there is a match. The filters are a list of the form:
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
+# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
+# is applied to all files.
+
+FILTER_PATTERNS =
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
+# INPUT_FILTER) will be used to filter the input files when producing source
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will
+# be generated. Documented entities will be cross-referenced with these sources.
+# Note: To get rid of all source code in the generated output, make sure also
+# VERBATIM_HEADERS is set to NO.
+
+SOURCE_BROWSER = YES
+
+# Setting the INLINE_SOURCES tag to YES will include the body
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
+# doxygen to hide any special comment blocks from generated source code
+# fragments. Normal C and C++ comments will always remain visible.
+
+STRIP_CODE_COMMENTS = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES
+# then for each documented function all documented
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = NO
+
+# If the REFERENCES_RELATION tag is set to YES
+# then for each documented function all documented entities
+# called/used by that function will be listed.
+
+REFERENCES_RELATION = NO
+
+# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
+# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
+# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
+# link to the source code. Otherwise they will link to the documentation.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code
+# will point to the HTML generated by the htags(1) tool instead of doxygen
+# built-in source browser. The htags tool is part of GNU's global source
+# tagging system (see http://www.gnu.org/software/global/global.html). You
+# will need version 4.8.6 or higher.
+
+USE_HTAGS = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
+# will generate a verbatim copy of the header file for each class for
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
+# of all compounds will be generated. Enable this if the project
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX = YES
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX = 5
+
+# In case all classes in a project start with a common prefix, all
+# classes will be put under the same header in the alphabetical index.
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX =
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
+# generate HTML output.
+
+GENERATE_HTML = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard header.
+
+HTML_HEADER =
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard footer.
+
+HTML_FOOTER =
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
+# style sheet that is used by each HTML page. It can be used to
+# fine-tune the look of the HTML output. If the tag is left blank doxygen
+# will generate a default style sheet. Note that doxygen will try to copy
+# the style sheet file to the HTML output directory, so don't put your own
+# stylesheet in the HTML output directory as well, or it will be erased!
+
+HTML_STYLESHEET =
+
+# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output.
+# Doxygen will adjust the colors in the stylesheet and background images
+# according to this color. Hue is specified as an angle on a colorwheel,
+# see http://en.wikipedia.org/wiki/Hue for more information.
+# For instance the value 0 represents red, 60 is yellow, 120 is green,
+# 180 is cyan, 240 is blue, 300 purple, and 360 is red again.
+# The allowed range is 0 to 359.
+
+HTML_COLORSTYLE_HUE = 220
+
+# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of
+# the colors in the HTML output. For a value of 0 the output will use
+# grayscales only. A value of 255 will produce the most vivid colors.
+
+HTML_COLORSTYLE_SAT = 100
+
+# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to
+# the luminance component of the colors in the HTML output. Values below
+# 100 gradually make the output lighter, whereas values above 100 make
+# the output darker. The value divided by 100 is the actual gamma applied,
+# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2,
+# and 100 does not change the gamma.
+
+HTML_COLORSTYLE_GAMMA = 80
+
+# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
+# page will contain the date and time when the page was generated. Setting
+# this to NO can help when comparing the output of multiple runs.
+
+HTML_TIMESTAMP = YES
+
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
+# files or namespaces will be aligned in HTML using tables. If set to
+# NO a bullet list will be used.
+
+HTML_ALIGN_MEMBERS = YES
+
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
+# documentation will contain sections that can be hidden and shown after the
+# page has loaded. For this to work a browser that supports
+# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox
+# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
+
+HTML_DYNAMIC_SECTIONS = YES
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files
+# will be generated that can be used as input for Apple's Xcode 3
+# integrated development environment, introduced with OSX 10.5 (Leopard).
+# To create a documentation set, doxygen will generate a Makefile in the
+# HTML output directory. Running make will produce the docset in that
+# directory and running "make install" will install the docset in
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
+# it at startup.
+# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html
+# for more information.
+
+GENERATE_DOCSET = NO
+
+# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
+# feed. A documentation feed provides an umbrella under which multiple
+# documentation sets from a single provider (such as a company or product suite)
+# can be grouped.
+
+DOCSET_FEEDNAME = "Doxygen generated docs"
+
+# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
+# should uniquely identify the documentation set bundle. This should be a
+# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
+# will append .docset to the name.
+
+DOCSET_BUNDLE_ID = org.doxygen.Project
+
+# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify
+# the documentation publisher. This should be a reverse domain-name style
+# string, e.g. com.mycompany.MyDocSet.documentation.
+
+DOCSET_PUBLISHER_ID = org.doxygen.Publisher
+
+# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher.
+
+DOCSET_PUBLISHER_NAME = Publisher
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files
+# will be generated that can be used as input for tools like the
+# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
+# be used to specify the file name of the resulting .chm file. You
+# can add a path in front of the file if the result should not be
+# written to the html output directory.
+
+CHM_FILE =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
+# be used to specify the location (absolute path including file name) of
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
+# the HTML help compiler on the generated index.hhp.
+
+HHC_LOCATION =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
+# controls if a separate .chi index file is generated (YES) or that
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
+# is used to encode HtmlHelp index (hhk), content (hhc) and project file
+# content.
+
+CHM_INDEX_ENCODING =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
+# controls whether a binary table of contents is generated (YES) or a
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members
+# to the contents of the HTML help documentation and to the tree view.
+
+TOC_EXPAND = NO
+
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and
+# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated
+# that can be used as input for Qt's qhelpgenerator to generate a
+# Qt Compressed Help (.qch) of the generated HTML documentation.
+
+GENERATE_QHP = NO
+
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can
+# be used to specify the file name of the resulting .qch file.
+# The path specified is relative to the HTML output folder.
+
+QCH_FILE =
+
+# The QHP_NAMESPACE tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#namespace
+
+QHP_NAMESPACE = org.doxygen.Project
+
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#virtual-folders
+
+QHP_VIRTUAL_FOLDER = doc
+
+# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to
+# add. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#custom-filters
+
+QHP_CUST_FILTER_NAME =
+
+# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the
+# custom filter to add. For more information please see
+# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">
+# Qt Help Project / Custom Filters</a>.
+
+QHP_CUST_FILTER_ATTRS =
+
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
+# project's
+# filter section matches.
+# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">
+# Qt Help Project / Filter Attributes</a>.
+
+QHP_SECT_FILTER_ATTRS =
+
+# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can
+# be used to specify the location of Qt's qhelpgenerator.
+# If non-empty doxygen will try to run qhelpgenerator on the generated
+# .qhp file.
+
+QHG_LOCATION =
+
+# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files
+# will be generated, which together with the HTML files, form an Eclipse help
+# plugin. To install this plugin and make it available under the help contents
+# menu in Eclipse, the contents of the directory containing the HTML and XML
+# files needs to be copied into the plugins directory of eclipse. The name of
+# the directory within the plugins directory should be the same as
+# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before
+# the help appears.
+
+GENERATE_ECLIPSEHELP = YES
+
+# A unique identifier for the eclipse help plugin. When installing the plugin
+# the directory name containing the HTML and XML files should also have
+# this name.
+
+ECLIPSE_DOC_ID = org.doxygen.Project
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
+# top of each HTML page. The value NO (the default) enables the index and
+# the value YES disables it.
+
+DISABLE_INDEX = NO
+
+# This tag can be used to set the number of enum values (range [1..20])
+# that doxygen will group on one line in the generated HTML documentation.
+
+ENUM_VALUES_PER_LINE = 4
+
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
+# structure should be generated to display hierarchical information.
+# If the tag value is set to YES, a side panel will be generated
+# containing a tree-like index structure (just like the one that
+# is generated for HTML Help). For this to work a browser that supports
+# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser).
+# Windows users are probably better off using the HTML help feature.
+
+GENERATE_TREEVIEW = YES
+
+# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories,
+# and Class Hierarchy pages using a tree view instead of an ordered list.
+
+USE_INLINE_TREES = YES
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
+# used to set the initial width (in pixels) of the frame in which the tree
+# is shown.
+
+TREEVIEW_WIDTH = 250
+
+# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open
+# links to external symbols imported via tag files in a separate window.
+
+EXT_LINKS_IN_WINDOW = NO
+
+# Use this tag to change the font size of Latex formulas included
+# as images in the HTML documentation. The default is 10. Note that
+# when you change the font size after a successful doxygen run you need
+# to manually remove any form_*.png images from the HTML output directory
+# to force them to be regenerated.
+
+FORMULA_FONTSIZE = 10
+
+# Use the FORMULA_TRANPARENT tag to determine whether or not the images
+# generated for formulas are transparent PNGs. Transparent PNGs are
+# not supported properly for IE 6.0, but are supported on all modern browsers.
+# Note that when changing this option you need to delete any form_*.png files
+# in the HTML output before the changes have effect.
+
+FORMULA_TRANSPARENT = YES
+
+# When the SEARCHENGINE tag is enabled doxygen will generate a search box
+# for the HTML output. The underlying search engine uses javascript
+# and DHTML and should work on any modern browser. Note that when using
+# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets
+# (GENERATE_DOCSET) there is already a search function so this one should
+# typically be disabled. For large projects the javascript based search engine
+# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution.
+
+SEARCHENGINE = YES
+
+# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
+# implemented using a PHP enabled web server instead of at the web client
+# using Javascript. Doxygen will generate the search PHP script and index
+# file to put on the web server. The advantage of the server
+# based approach is that it scales better to large projects and allows
+# full text search. The disadvances is that it is more difficult to setup
+# and does not have live searching capabilities.
+
+SERVER_BASED_SEARCH = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
+# generate Latex output.
+
+GENERATE_LATEX = NO
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
+# invoked. If left blank `latex' will be used as the default command name.
+# Note that when enabling USE_PDFLATEX this option is only used for
+# generating bitmaps for formulas in the HTML output, but not in the
+# Makefile that is written to the output directory.
+
+LATEX_CMD_NAME = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
+# generate index for LaTeX. If left blank `makeindex' will be used as the
+# default command name.
+
+MAKEINDEX_CMD_NAME = makeindex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
+# LaTeX documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_LATEX = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used
+# by the printer. Possible values are: a4, a4wide, letter, legal and
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE = a4wide
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES =
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
+# the generated latex document. The header should contain everything until
+# the first chapter. If it is left blank doxygen will generate a
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER =
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will
+# contain links (just like the HTML output) instead of page references
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS = YES
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
+# plain latex in the generated Makefile. Set this option to YES to get a
+# higher quality PDF documentation.
+
+USE_PDFLATEX = YES
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
+# command to the generated LaTeX files. This will instruct LaTeX to keep
+# running if errors occur, instead of asking the user for help.
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE = NO
+
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not
+# include the index chapters (such as File Index, Compound Index, etc.)
+# in the output.
+
+LATEX_HIDE_INDICES = NO
+
+# If LATEX_SOURCE_CODE is set to YES then doxygen will include
+# source code with syntax highlighting in the LaTeX output.
+# Note that which sources are shown also depends on other settings
+# such as SOURCE_BROWSER.
+
+LATEX_SOURCE_CODE = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
+# The RTF output is optimized for Word 97 and may not look very pretty with
+# other RTF readers or editors.
+
+GENERATE_RTF = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
+# RTF documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_RTF = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
+# will contain hyperlink fields. The RTF file will
+# contain links (just like the HTML output) instead of page references.
+# This makes the output suitable for online browsing using WORD or other
+# programs which support those fields.
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's
+# config file, i.e. a series of assignments. You only have to provide
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE =
+
+# Set optional variables used in the generation of an rtf document.
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
+# generate man pages
+
+GENERATE_MAN = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT = man
+
+# The MAN_EXTENSION tag determines the extension that is added to
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
+# then it will generate one additional man file for each entity
+# documented in the real man page(s). These additional files
+# only source the real man page, but without them the man command
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will
+# generate an XML file that captures the structure of
+# the code including all documentation.
+
+GENERATE_XML = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `xml' will be used as the default path.
+
+XML_OUTPUT = xml
+
+# The XML_SCHEMA tag can be used to specify an XML schema,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_SCHEMA =
+
+# The XML_DTD tag can be used to specify an XML DTD,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_DTD =
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
+# dump the program listings (including syntax highlighting
+# and cross-referencing information) to the XML output. Note that
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING = YES
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
+# generate an AutoGen Definitions (see autogen.sf.net) file
+# that captures the structure of the code including all
+# documentation. Note that this feature is still experimental
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will
+# generate a Perl module file that captures the structure of
+# the code including all documentation. Note that this
+# feature is still experimental and incomplete at the
+# moment.
+
+GENERATE_PERLMOD = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
+# nicely formatted so it can be parsed by a human reader. This is useful
+# if you want to understand what is going on. On the other hand, if this
+# tag is set to NO the size of the Perl module output will be much smaller
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY = YES
+
+# The names of the make variables in the generated doxyrules.make file
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
+# This is useful so different doxyrules.make files included by the same
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
+# evaluate all C-preprocessor directives found in the sources and include
+# files.
+
+ENABLE_PREPROCESSING = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
+# names in the source code. If set to NO (the default) only conditional
+# compilation will be performed. Macro expansion can be done in a controlled
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
+# then the macro expansion is limited to the macros specified with the
+# PREDEFINED and EXPAND_AS_DEFINED tags.
+
+EXPAND_ONLY_PREDEF = NO
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
+# in the INCLUDE_PATH (see below) will be search if a #include is found.
+
+SEARCH_INCLUDES = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by
+# the preprocessor.
+
+INCLUDE_PATH =
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will
+# be used.
+
+INCLUDE_FILE_PATTERNS =
+
+# The PREDEFINED tag can be used to specify one or more macro names that
+# are defined before the preprocessor is started (similar to the -D option of
+# gcc). The argument of the tag is a list of macros of the form: name
+# or name=definition (no spaces). If the definition and the = are
+# omitted =1 is assumed. To prevent a macro definition from being
+# undefined via #undef or recursively expanded use the := operator
+# instead of the = operator.
+
+PREDEFINED =
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
+# this tag can be used to specify a list of macro names that should be expanded.
+# The macro definition that is found in the sources will be used.
+# Use the PREDEFINED tag if you want to use a different macro definition.
+
+EXPAND_AS_DEFINED =
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
+# doxygen's preprocessor will remove all function-like macros that are alone
+# on a line, have an all uppercase name, and do not end with a semicolon. Such
+# function macros are typically used for boiler-plate code, and will confuse
+# the parser if not removed.
+
+SKIP_FUNCTION_MACROS = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+
+# The TAGFILES option can be used to specify one or more tagfiles.
+# Optionally an initial location of the external documentation
+# can be added for each tagfile. The format of a tag file without
+# this location is as follows:
+# TAGFILES = file1 file2 ...
+# Adding location for the tag files is done as follows:
+# TAGFILES = file1=loc1 "file2 = loc2" ...
+# where "loc1" and "loc2" can be relative or absolute paths or
+# URLs. If a location is present for each tag, the installdox tool
+# does not have to be run to correct the links.
+# Note that each tag file must have a unique name
+# (where the name does NOT include the path)
+# If a tag file is not located in the directory in which doxygen
+# is run, you must also specify the path to the tagfile here.
+
+TAGFILES =
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE =
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed
+# in the class index. If set to NO only the inherited external classes
+# will be listed.
+
+ALLEXTERNALS = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
+# in the modules index. If set to NO, only the current project's groups will
+# be listed.
+
+EXTERNAL_GROUPS = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
+# or super classes. Setting the tag to NO turns the diagrams off. Note that
+# this option is superseded by the HAVE_DOT option below. This is only a
+# fallback. It is recommended to install and use dot, since it yields more
+# powerful graphs.
+
+CLASS_DIAGRAMS = NO
+
+# You can define message sequence charts within doxygen comments using the \msc
+# command. Doxygen will then run the mscgen tool (see
+# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where
+# the mscgen tool resides. If left empty the tool is assumed to be found in the
+# default search path.
+
+MSCGEN_PATH =
+
+# If set to YES, the inheritance and collaboration graphs will hide
+# inheritance and usage relations if the target is undocumented
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
+# available from the path. This tool is part of Graphviz, a graph visualization
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT = YES
+
+# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is
+# allowed to run in parallel. When set to 0 (the default) doxygen will
+# base this on the number of processors available in the system. You can set it
+# explicitly to a value larger than 0 to get control over the balance
+# between CPU load and processing speed.
+
+DOT_NUM_THREADS = 0
+
+# By default doxygen will write a font called FreeSans.ttf to the output
+# directory and reference it in all dot files that doxygen generates. This
+# font does not include all possible unicode characters however, so when you need
+# these (or just want a differently looking font) you can specify the font name
+# using DOT_FONTNAME. You need need to make sure dot is able to find the font,
+# which can be done by putting it in a standard location or by setting the
+# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory
+# containing the font.
+
+DOT_FONTNAME = FreeSans.ttf
+
+# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
+# The default size is 10pt.
+
+DOT_FONTSIZE = 10
+
+# By default doxygen will tell dot to use the output directory to look for the
+# FreeSans.ttf font (which doxygen will put there itself). If you specify a
+# different font using DOT_FONTNAME you can set the path where dot
+# can find it using this tag.
+
+DOT_FONTPATH =
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect inheritance relations. Setting this tag to YES will force the
+# the CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect implementation dependencies (inheritance, containment, and
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH = YES
+
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for groups, showing the direct groups dependencies
+
+GROUP_GRAPHS = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
+# collaboration diagrams in a style similar to the OMG's Unified Modeling
+# Language.
+
+UML_LOOK = NO
+
+# If set to YES, the inheritance and collaboration graphs will show the
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS = NO
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
+# tags are set to YES then doxygen will generate a graph for each documented
+# file showing the direct and indirect include dependencies of the file with
+# other documented files.
+
+INCLUDE_GRAPH = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
+# documented header file showing the documented files that directly or
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH = YES
+
+# If the CALL_GRAPH and HAVE_DOT options are set to YES then
+# doxygen will generate a call dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable call graphs
+# for selected functions only using the \callgraph command.
+
+CALL_GRAPH = YES
+
+# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
+# doxygen will generate a caller dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable caller
+# graphs for selected functions only using the \callergraph command.
+
+CALLER_GRAPH = YES
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
+# will graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY = YES
+
+# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
+# then doxygen will show the dependencies a directory has on other directories
+# in a graphical way. The dependency relations are determined by the #include
+# relations between the files in the directories.
+
+DIRECTORY_GRAPH = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
+# generated by dot. Possible values are png, jpg, or gif
+# If left blank png will be used.
+
+DOT_IMAGE_FORMAT = png
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be
+# found. If left blank, it is assumed the dot tool can be found in the path.
+
+DOT_PATH =
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that
+# contain dot files that are included in the documentation (see the
+# \dotfile command).
+
+DOTFILE_DIRS =
+
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
+# nodes that will be shown in the graph. If the number of nodes in a graph
+# becomes larger than this value, doxygen will truncate the graph, which is
+# visualized by representing a node as a red box. Note that doxygen if the
+# number of direct children of the root node in a graph is already larger than
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
+# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+
+DOT_GRAPH_MAX_NODES = 50
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
+# graphs generated by dot. A depth value of 3 means that only nodes reachable
+# from the root by following a path via at most 3 edges will be shown. Nodes
+# that lay further from the root node will be omitted. Note that setting this
+# option to 1 or 2 may greatly reduce the computation time needed for large
+# code bases. Also note that the size of a graph can be further restricted by
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
+
+MAX_DOT_GRAPH_DEPTH = 0
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
+# background. This is disabled by default, because dot on Windows does not
+# seem to support this out of the box. Warning: Depending on the platform used,
+# enabling this option may lead to badly anti-aliased labels on the edges of
+# a graph (i.e. they become hard to read).
+
+DOT_TRANSPARENT = NO
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
+# files in one run (i.e. multiple -o and -T options on the command line). This
+# makes dot run faster, but since only newer versions of dot (>1.8.10)
+# support this, this feature is disabled by default.
+
+DOT_MULTI_TARGETS = NO
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
+# generate a legend page explaining the meaning of the various boxes and
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND = YES
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
+# remove the intermediate dot files that are used to generate
+# the various graphs.
+
+DOT_CLEANUP = YES
diff --git a/AudioManagerDaemon/include/CommandReceiver.h b/AudioManagerDaemon/include/CommandReceiver.h
index 3f4138a..a49c03d 100644
--- a/AudioManagerDaemon/include/CommandReceiver.h
+++ b/AudioManagerDaemon/include/CommandReceiver.h
@@ -8,16 +8,40 @@
#ifndef COMMANDRECEIVER_H_
#define COMMANDRECEIVER_H_
-
+/**
+* Copyright (C) 2011, BMW AG
+*
+* GeniviAudioMananger AudioManagerDaemon
+*
+* \file DBusWrapper.cpp
+*
+* \date 20-Oct-2011 3:42:04 PM
+* \author Christian Mueller (christian.ei.mueller@bmw.de)
+*
+* \section License
+* GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+* Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+*
+* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+* You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+*
+* THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
+*/
#include <command/CommandReceiveInterface.h>
#include "DatabaseHandler.h"
#include "DBusWrapper.h"
+#include "ControlSender.h"
using namespace am;
class CommandReceiver: public CommandReceiveInterface {
public:
- CommandReceiver(DatabaseHandler* iDatabaseHandler, DBusWrapper* iDBusWrapper);
+ CommandReceiver(DatabaseHandler* iDatabaseHandler, DBusWrapper* iDBusWrapper, ControlSender* iControlSender);
virtual ~CommandReceiver();
am_Error_e connect(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t& mainConnectionID) ;
am_Error_e disconnect(const am_mainConnectionID_t mainConnectionID) ;
@@ -41,6 +65,7 @@ public:
private:
DatabaseHandler* mDatabaseHandler;
DBusWrapper* mDBusWrapper;
+ ControlSender* mControlSender;
};
#endif /* COMMANDRECEIVER_H_ */
diff --git a/AudioManagerDaemon/include/CommandSender.h b/AudioManagerDaemon/include/CommandSender.h
index 8e604c6..2cd5025 100644
--- a/AudioManagerDaemon/include/CommandSender.h
+++ b/AudioManagerDaemon/include/CommandSender.h
@@ -8,9 +8,12 @@
#ifndef COMMANDSENDER_H_
#define COMMANDSENDER_H_
-#include "pluginTemplate.h"
#include "command/CommandSendInterface.h"
+#ifdef UNIT_TEST
+#include "../test/CommandInterfaceBackdoor.h"
+#endif
+
using namespace am;
class CommandSender {
@@ -35,8 +38,13 @@ public:
void cbSinkMuteStateChanged(const am_sinkID_t sinkID, const am_MuteState_e muteState) ;
void cbSystemPropertyChanged(const am_SystemProperty_s& SystemProperty) ;
void cbTimingInformationChanged(const am_mainConnectionID_t mainConnection, const am_timeSync_t time) ;
+#ifdef UNIT_TEST
+ friend class CommandInterfaceBackdoor;
+#endif
private:
+ void unloadLibraries(void);
std::vector<CommandSendInterface*> mListInterfaces;
+ std::vector<void*> mListLibraryHandles;
};
#endif /* COMMANDSENDER_H_ */
diff --git a/AudioManagerDaemon/include/ControlReceiver.h b/AudioManagerDaemon/include/ControlReceiver.h
index 722bde1..1b5c072 100644
--- a/AudioManagerDaemon/include/ControlReceiver.h
+++ b/AudioManagerDaemon/include/ControlReceiver.h
@@ -10,12 +10,13 @@
#include <control/ControlReceiveInterface.h>
#include "DatabaseHandler.h"
+#include "RoutingSender.h"
using namespace am;
class ControlReceiver: public ControlReceiveInterface {
public:
- ControlReceiver(DatabaseHandler* iDatabaseHandler);
+ ControlReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender);
virtual ~ControlReceiver();
am_Error_e getRoute(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector<am_Route_s>& returnList) ;
am_Error_e connect(am_Handle_s& handle, am_connectionID_t& connectionID, const am_ConnectionFormat_e format, const am_sourceID_t sourceID, const am_sinkID_t sinkID) ;
@@ -81,6 +82,7 @@ public:
private:
DatabaseHandler* mDatabaseHandler;
+ RoutingSender* mRoutingSender;
};
#endif /* CONTRONLRECEIVER_H_ */
diff --git a/AudioManagerDaemon/include/ControlSender.h b/AudioManagerDaemon/include/ControlSender.h
index fde029c..0a490d4 100644
--- a/AudioManagerDaemon/include/ControlSender.h
+++ b/AudioManagerDaemon/include/ControlSender.h
@@ -1,21 +1,71 @@
/*
- * ControlLoader.h
+ * ControlSender.h
*
- * Created on: Oct 25, 2011
+ * Created on: Dec 9, 2011
* Author: christian
*/
-#ifndef CONTROLLOADER_H_
-#define CONTROLLOADER_H_
+#ifndef CONTROLSENDER_H_
+#define CONTROLSENDER_H_
#include "control/ControlSendInterface.h"
+#ifdef UNIT_TEST
+#include "../test/ControlInterfaceBackdoor.h"
+#endif
+
using namespace am;
-class ControlSender : private ControlSendInterface {
+class ControlSender {
public:
ControlSender();
virtual ~ControlSender();
+ am_Error_e startupController(ControlReceiveInterface* controlreceiveinterface) ;
+ am_Error_e stopController() ;
+ void hookAllPluginsLoaded() ;
+ am_Error_e hookUserConnectionRequest(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t& mainConnectionID) ;
+ am_Error_e hookUserDisconnectionRequest(const am_mainConnectionID_t connectionID) ;
+ am_Error_e hookUserSetMainSinkSoundProperty(const am_sinkID_t sinkID, const am_MainSoundProperty_s& soundProperty) ;
+ am_Error_e hookUserSetMainSourceSoundProperty(const am_sourceID_t sourceID, const am_MainSoundProperty_s& soundProperty) ;
+ am_Error_e hookUserSetSystemProperty(const am_SystemProperty_s& property) ;
+ am_Error_e hookUserVolumeChange(const am_sinkID_t SinkID, const am_mainVolume_t newVolume) ;
+ am_Error_e hookUserVolumeStep(const am_sinkID_t SinkID, const int16_t increment) ;
+ am_Error_e hookUserSetSinkMuteState(const am_sinkID_t sinkID, const am_MuteState_e muteState) ;
+ am_Error_e hookSystemRegisterDomain(const am_Domain_s& domainData, am_domainID_t& domainID) ;
+ am_Error_e hookSystemDeregisterDomain(const am_domainID_t domainID) ;
+ am_Error_e hookSystemRegisterSink(const am_Sink_s& sinkData, am_sinkID_t& sinkID) ;
+ am_Error_e hookSystemDeregisterSink(const am_sinkID_t sinkID) ;
+ am_Error_e hookSystemRegisterSource(const am_Source_s& sourceData, am_sourceID_t& sourceID) ;
+ am_Error_e hookSystemDeregisterSource(const am_sourceID_t sourceID) ;
+ am_Error_e hookSystemRegisterGateway(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID) ;
+ am_Error_e hookSystemDeregisterGateway(const am_gatewayID_t gatewayID) ;
+ am_Error_e hookSystemRegisterCrossfader(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID) ;
+ am_Error_e hookSystemDeregisterCrossfader(const am_crossfaderID_t crossfaderID) ;
+ void hookSystemDomainRegistrationComplete(const am_domainID_t domainID) ;
+ void hookSystemSinkVolumeTick(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume) ;
+ void hookSystemSourceVolumeTick(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume) ;
+ void hookSystemInterruptStateChange(const am_sourceID_t sourceID, const am_InterruptState_e interruptState) ;
+ void hookSystemSinkAvailablityStateChange(const am_sinkID_t sinkID, const am_Availability_s& availability) ;
+ void hookSystemSourceAvailablityStateChange(const am_sourceID_t sourceID, const am_Availability_s& availability) ;
+ void hookSystemDomainStateChange(const am_domainID_t domainID, const am_DomainState_e state) ;
+ void hookSystemReceiveEarlyData(const std::vector<am_EarlyData_s>& data) ;
+ void hookSystemSpeedChange(const am_speed_t speed) ;
+ void hookSystemTimingInformationChanged(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time) ;
+ void cbAckConnect(const am_Handle_s handle, const am_Error_e errorID) ;
+ void cbAckDisconnect(const am_Handle_s handle, const am_Error_e errorID) ;
+ 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) ;
+ void cbAckSetSourceVolumeChange(const am_Handle_s handle, const am_volume_t voulme, const am_Error_e error) ;
+ void cbAckSetSourceState(const am_Handle_s handle, const am_Error_e error) ;
+ void cbAckSetSourceSoundProperty(const am_Handle_s handle, const am_Error_e error) ;
+ void cbAckSetSinkSoundProperty(const am_Handle_s handle, const am_Error_e error) ;
+
+#ifdef UNIT_TEST
+ friend class ControlInterfaceBackdoor;
+#endif
+private:
+ ControlSendInterface* mController;
+ void* mlibHandle;
};
-#endif /* CONTROLLOADER_H_ */
+#endif /* CONTROLSENDER_H_ */
diff --git a/AudioManagerDaemon/include/DatabaseHandler.h b/AudioManagerDaemon/include/DatabaseHandler.h
index 5c99719..38c20dd 100644
--- a/AudioManagerDaemon/include/DatabaseHandler.h
+++ b/AudioManagerDaemon/include/DatabaseHandler.h
@@ -8,9 +8,13 @@
#ifndef DATABASEHANDLER_H_
#define DATABASEHANDLER_H_
+#include "Observer.h"
#include "audiomanagertypes.h"
#include <map>
#include <string>
+#include <stdint.h>
+#include <fstream>
+#include <sstream>
#include <vector>
#include <sqlite3.h>
@@ -23,6 +27,9 @@ using namespace am;
//todo: change asserts for dynamic boundary checks into failure answers.#
//todo: check autoincrement boundary and set to 16bit limits
//todo: If the sink is part of a gateway, the listconnectionFormats is copied to the gatewayInformation. Check this statement for sinks & sources
+//todo: exchange last_insert_row id to be more safe
+//todo: create test to ensure uniqueness of names throughout the database
+//todo: enforce the uniqueness of names
class DatabaseHandler {
public:
@@ -52,6 +59,8 @@ public:
am_Error_e changeSinkClassInfoDB(const am_SinkClass_s& sinkClass) ;
am_Error_e changeSourceClassInfoDB(const am_SourceClass_s& sourceClass) ;
am_Error_e changeConnectionTimingInformation(const am_connectionID_t connectionID, const am_timeSync_t delay) ;
+ am_Error_e changeConnectionFinal(const am_connectionID_t connectionID) ;
+ am_Error_e changeSourceState(const am_sourceID_t sourceID, const am_SourceState_e sourceState);
am_Error_e removeMainConnectionDB(const am_mainConnectionID_t mainConnectionID) ;
am_Error_e removeSinkDB(const am_sinkID_t sinkID) ;
am_Error_e removeSourceDB(const am_sourceID_t sourceID) ;
@@ -60,10 +69,15 @@ public:
am_Error_e removeDomainDB(const am_domainID_t domainID) ;
am_Error_e removeSinkClassDB(const am_sinkClass_t sinkClassID) ;
am_Error_e removeSourceClassDB(const am_sourceClass_t sourceClassID) ;
+ am_Error_e removeConnection(const am_connectionID_t connectionID) ;
am_Error_e getSourceClassInfoDB(const am_sourceID_t sourceID, am_SourceClass_s& classInfo) const ;
am_Error_e getSinkClassInfoDB(const am_sinkID_t sinkID, am_SinkClass_s& sinkClass) const ;
am_Error_e getGatewayInfoDB(const am_gatewayID_t gatewayID, am_Gateway_s& gatewayData) const ;
am_Error_e getCrossfaderInfoDB(const am_crossfaderID_t crossfaderID, am_Crossfader_s& crossfaderData) const ;
+ am_Error_e getSinkVolume(const am_sinkID_t sinkID, am_volume_t& volume) const;
+ am_Error_e getSourceVolume(const am_sourceID_t sourceID, am_volume_t& volume) const;
+ am_Error_e getSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_SoundPropertyType_e propertyType, uint16_t& value) const ;
+ am_Error_e getSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_SoundPropertyType_e propertyType, uint16_t& value) const ;
am_Error_e getListSinksOfDomain(const am_domainID_t domainID, std::vector<am_sinkID_t>& listSinkID) const ;
am_Error_e getListSourcesOfDomain(const am_domainID_t domainID, std::vector<am_sourceID_t>& listSourceID) const ;
am_Error_e getListCrossfadersOfDomain(const am_domainID_t domainID, std::vector<am_crossfaderID_t>& listGatewaysID) const ;
@@ -85,8 +99,11 @@ public:
am_Error_e getListSystemProperties(std::vector<am_SystemProperty_s>& listSystemProperties) const ;
am_Error_e getTimingInformation(const am_mainConnectionID_t mainConnectionID, am_timeSync_t& delay) const ;
am_Error_e getDomainOfSource(const am_sourceID_t sourceID, am_domainID_t& domainID) const;
-
-
+ am_Error_e getSoureState(const am_sourceID_t sourceID, am_SourceState_e& sourceState) const;
+ am_Error_e getDomainState(const am_domainID_t domainID, am_DomainState_e state) const;
+ am_Error_e peekDomain(const std::string& name, am_domainID_t& domainID);
+ am_Error_e peekSink(const std::string& name, am_sinkID_t& sinkID);
+ am_Error_e peekSource(const std::string& name, am_sourceID_t& sourceID);
/**
* checks for a certain mainConnection
* @param mainConnectionID to be checked for
@@ -95,6 +112,27 @@ public:
bool existMainConnection(const am_mainConnectionID_t mainConnectionID) const;
/**
+ * checks if a CrossFader exists
+ * @param crossFaderID the ID of the crossfader to be checked
+ * @return true if exists
+ */
+ bool existcrossFader(const am_crossfaderID_t crossfaderID) const;
+
+ /**
+ * checks if a connection already exists.
+ * Only takes sink, source and format information for search!
+ * @param connection the connection to be checked
+ * @return true if connections exists
+ */
+ bool existConnection(const am_Connection_s connection);
+
+ /**
+ * checks if a connection with the given ID exists
+ * @param connectionID
+ * @return true if connection exits
+ */
+ bool existConnectionID(const am_connectionID_t connectionID);
+ /**
* checks for a certain Source
* @param sourceID to be checked for
* @return true if it exists
@@ -102,6 +140,20 @@ public:
bool existSource(const am_sourceID_t sourceID) const;
/**
+ * checks if a source name or ID exists
+ * @param sourceID the sourceID
+ * @param name the name
+ * @return true if it exits
+ */
+ bool existSourceNameOrID(const am_sourceID_t sourceID, const std::string& name) const;
+
+ /**
+ * checks if a name exits
+ * @param name the name
+ * @return true if it exits
+ */
+ bool existSourceName(const std::string& name) const;
+ /**
* checks for a certain Sink
* @param sinkID to be checked for
* @return true if it exists
@@ -109,6 +161,21 @@ public:
bool existSink(const am_sinkID_t sinkID) const;
/**
+ * checks if a sink with the ID or the name exists
+ * @param sinkID the ID
+ * @param name the name
+ * @return true if it exists.
+ */
+ bool existSinkNameOrID(const am_sinkID_t sinkID, const std::string& name) const;
+
+ /**
+ * checks if a sink with the name exists
+ * @param name the name
+ * @return true if it exists
+ */
+ bool existSinkName(const std::string& name) const;
+
+ /**
* checks for a certain domain
* @param domainID to be checked for
* @return true if it exists
@@ -136,6 +203,26 @@ public:
*/
bool existSourceClass(const am_sourceClass_t sourceClassID) const;
+ /**
+ * registers the Observer at the Database
+ * @param iObserver pointer to the observer
+ */
+ void registerObserver(Observer *iObserver);
+
+ /**
+ * gives information about the visibility of a source
+ * @param sourceID the sourceID
+ * @return true if source is visible
+ */
+ bool sourceVisible(const am_sourceID_t sourceID) const;
+
+ /**
+ * gives information about the visibility of a sink
+ * @param sinkID the sinkID
+ * @return true if source is visible
+ */
+ bool sinkVisible(const am_sinkID_t sinkID) const;
+
private:
am_timeSync_t calculateMainConnectionDelay(const am_mainConnectionID_t mainConnectionID) const;
bool connectionPartofMainConnection(const am_connectionID_t connectionID,const am_mainConnectionID_t mainConnectionID) const;
@@ -144,6 +231,7 @@ private:
void createTables();
sqlite3 *mDatabase;
std::string mPath;
+ Observer *mObserver;
bool mFirstStaticSink;
bool mFirstStaticSource;
bool mFirstStaticGateway;
diff --git a/AudioManagerDaemon/include/Observer.h b/AudioManagerDaemon/include/Observer.h
new file mode 100644
index 0000000..f616722
--- /dev/null
+++ b/AudioManagerDaemon/include/Observer.h
@@ -0,0 +1,45 @@
+/*
+ * Observer.h
+ *
+ * Created on: Dec 10, 2011
+ * Author: christian
+ */
+
+#ifndef OBSERVER_H_
+#define OBSERVER_H_
+
+#include "CommandSender.h"
+#include "RoutingSender.h"
+
+class Observer {
+public:
+ Observer(CommandSender *iCommandSender, RoutingSender *iRoutingSender);
+ virtual ~Observer();
+ void numberOfMainConnectionsChanged() ;
+ void numberOfSinkClassesChanged() ;
+ void numberOfSourceClassesChanged() ;
+ void newSink(am_Sink_s sink);
+ void newSource(am_Source_s source);
+ void newDomain(am_Domain_s domain);
+ void newGateway(am_Gateway_s gateway);
+ void newCrossfader(am_Crossfader_s crossfader);
+ void removedSink(am_sinkID_t sinkID);
+ void removedSource(am_sourceID_t sourceID);
+ void removeDomain(am_domainID_t domainID);
+ void removeGateway(am_gatewayID_t gatewayID);
+ void removeCrossfader(am_crossfaderID_t crossfaderID);
+ void mainConnectionStateChanged(const am_mainConnectionID_t connectionID, const am_ConnectionState_e connectionState) ;
+ void mainSinkSoundPropertyChanged(const am_sinkID_t sinkID, const am_MainSoundProperty_s SoundProperty) ;
+ void mainSourceSoundPropertyChanged(const am_sourceID_t sourceID, const am_MainSoundProperty_s& SoundProperty) ;
+ void sinkAvailabilityChanged(const am_sinkID_t sinkID, const am_Availability_s& availability) ;
+ void sourceAvailabilityChanged(const am_sourceID_t sourceID, const am_Availability_s& availability) ;
+ void volumeChanged(const am_sinkID_t sinkID, const am_mainVolume_t volume) ;
+ void sinkMuteStateChanged(const am_sinkID_t sinkID, const am_MuteState_e muteState) ;
+ void systemPropertyChanged(const am_SystemProperty_s& SystemProperty) ;
+ void timingInformationChanged(const am_mainConnectionID_t mainConnection, const am_timeSync_t time) ;
+private:
+ CommandSender *mCommandSender;
+ RoutingSender* mRoutingSender;
+};
+
+#endif /* OBSERVER_H_ */
diff --git a/AudioManagerDaemon/include/RoutingReceiver.h b/AudioManagerDaemon/include/RoutingReceiver.h
index 903786a..f2dc405 100644
--- a/AudioManagerDaemon/include/RoutingReceiver.h
+++ b/AudioManagerDaemon/include/RoutingReceiver.h
@@ -9,12 +9,15 @@
#define ROUTINGRECEIVER_H_
#include "routing/RoutingReceiveInterface.h"
+#include "ControlSender.h"
+#include "RoutingSender.h"
+#include "DatabaseHandler.h"
using namespace am;
class RoutingReceiver : public RoutingReceiveInterface {
public:
- RoutingReceiver();
+ RoutingReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, ControlSender *iControlSender);
virtual ~RoutingReceiver();
void ackConnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error) ;
void ackDisconnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error) ;
@@ -39,6 +42,8 @@ public:
am_Error_e deregisterSource(const am_sourceID_t sourceID) ;
am_Error_e registerCrossfader(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID) ;
am_Error_e deregisterCrossfader(const am_crossfaderID_t crossfaderID) ;
+ am_Error_e peekSinkClassID(const std::string& name, am_sourceClass_t& sourceClassID) ;
+ am_Error_e peekSourceClassID(const std::string& name, am_sinkClass_t& sinkClassID) ;
void hookInterruptStatusChange(const am_sourceID_t sourceID, const am_InterruptState_e interruptState) ;
void hookDomainRegistrationComplete(const am_domainID_t domainID) ;
void hookSinkAvailablityStatusChange(const am_sinkID_t sinkID, const am_Availability_s& availability) ;
@@ -47,7 +52,11 @@ public:
void hookTimingInformationChanged(const am_connectionID_t connectionID, const am_timeSync_t delay) ;
am_Error_e sendChangedData(const std::vector<am_EarlyData_s>& earlyData) ;
am_Error_e getDBusConnectionWrapper(DBusWrapper* dbusConnectionWrapper) const ;
- am_Error_e registerDbusNode(const std::string& nodeName) ;
+private:
+ DatabaseHandler *mDatabaseHandler;
+ RoutingSender *mRoutingSender;
+ ControlSender *mControlSender;
+
};
#endif /* ROUTINGRECEIVER_H_ */
diff --git a/AudioManagerDaemon/include/RoutingSender.h b/AudioManagerDaemon/include/RoutingSender.h
index 2aac7be..bb3cc53 100644
--- a/AudioManagerDaemon/include/RoutingSender.h
+++ b/AudioManagerDaemon/include/RoutingSender.h
@@ -8,9 +8,14 @@
#ifndef ROUTINGSENDER_H_
#define ROUTINGSENDER_H_
-#include "pluginTemplate.h"
#include "routing/RoutingSendInterface.h"
+
+#ifdef UNIT_TEST //this is needed to test RoutingSender
+#include "../test/RoutingInterfaceBackdoor.h"
+#endif
+
#include <map>
+#include <set>
using namespace am;
@@ -18,6 +23,14 @@ class RoutingSender {
public:
RoutingSender();
virtual ~RoutingSender();
+
+ /**
+ * removes a handle from the list
+ * @param handle to be removed
+ * @return E_OK in case of success
+ */
+ am_Error_e removeHandle(const am_Handle_s& handle);
+
/**
* @author Christian
* this adds the domain to the lookup table of the Router. The data is used to have a quick lookup of the correct pluginInterface.
@@ -65,18 +78,17 @@ public:
void startupRoutingInterface(RoutingReceiveInterface* routingreceiveinterface) ;
void routingInterfacesReady() ;
void routingInterfacesRundown() ;
- am_Error_e asyncAbort(const am_Handle_s handle) ;
- am_Error_e asyncConnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_ConnectionFormat_e connectionFormat) ;
- am_Error_e asyncDisconnect(const am_Handle_s handle, const am_connectionID_t connectionID) ;
- am_Error_e asyncSetSinkVolume(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time) ;
- am_Error_e asyncSetSourceVolume(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time) ;
- am_Error_e asyncSetSourceState(const am_Handle_s handle, const am_sourceID_t sourceID, const am_SourceState_e state) ;
- am_Error_e asyncSetSinkSoundProperty(const am_Handle_s handle, const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty) ;
- am_Error_e asyncSetSourceSoundProperty(const am_Handle_s handle, const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty) ;
- am_Error_e asyncCrossFade(const am_Handle_s handle, const am_crossfaderID_t crossfaderID, const am_HotSink_e hotSink, const am_RampType_e rampType, const am_time_t time) ;
+ am_Error_e asyncAbort(const am_Handle_s& handle) ;
+ am_Error_e asyncConnect(am_Handle_s& handle, const am_connectionID_t connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_ConnectionFormat_e connectionFormat) ;
+ am_Error_e asyncDisconnect(am_Handle_s& handle, const am_connectionID_t connectionID) ;
+ am_Error_e asyncSetSinkVolume(am_Handle_s& handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time) ;
+ am_Error_e asyncSetSourceVolume(am_Handle_s& handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time) ;
+ am_Error_e asyncSetSourceState(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SourceState_e state) ;
+ am_Error_e asyncSetSinkSoundProperty(am_Handle_s& handle, const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty) ;
+ am_Error_e asyncSetSourceSoundProperty(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty) ;
+ am_Error_e asyncCrossFade(am_Handle_s& handle, const am_crossfaderID_t crossfaderID, const am_HotSink_e hotSink, const am_RampType_e rampType, const am_time_t time) ;
am_Error_e setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState) ;
- am_Error_e returnBusName(std::string& BusName) const ;
-private:
+ am_Error_e getListHandles(std::vector<am_Handle_s> & listHandles) const ;
struct InterfaceNamePairs
{
@@ -84,18 +96,40 @@ private:
std::string busName;
};
+#ifdef UNIT_TEST //this is needed to test RoutingSender
+ friend class RoutingInterfaceBackdoor;
+#endif
+private:
+ struct compareHandles
+ {
+ bool operator()(const am_Handle_s& a, const am_Handle_s& b) const
+ {
+ {
+ return (a.handle < b.handle);
+ }
+ }
+ };
+
+ am_Handle_s createHandle(const am_Handle_e handle);
+ void unloadLibraries(void);
+
typedef std::map<am_domainID_t, RoutingSendInterface*> DomainInterfaceMap;
typedef std::map<am_sinkID_t, RoutingSendInterface*> SinkInterfaceMap;
typedef std::map<am_sourceID_t, RoutingSendInterface*> SourceInterfaceMap;
typedef std::map<am_crossfaderID_t, RoutingSendInterface*> CrossfaderInterfaceMap;
typedef std::map<am_connectionID_t, RoutingSendInterface*> ConnectionInterfaceMap;
+ typedef std::map<uint16_t, RoutingSendInterface*> HandleInterfaceMap;
+ int16_t mHandleCount;
+ std::set<am_Handle_s,compareHandles> mlistActiveHandles;
std::vector<InterfaceNamePairs> mListInterfaces;
+ std::vector<void*> mListLibraryHandles;
+ ConnectionInterfaceMap mMapConnectionInterface;
+ CrossfaderInterfaceMap mMapCrossfaderInterface;
DomainInterfaceMap mMapDomainInterface;
SinkInterfaceMap mMapSinkInterface;
SourceInterfaceMap mMapSourceInterface;
- CrossfaderInterfaceMap mMapCrossfaderInterface;
- ConnectionInterfaceMap mMapConnectionInterface;
+ HandleInterfaceMap mMapHandleInterface;
};
#endif /* ROUTINGSENDER_H_ */
diff --git a/AudioManagerDaemon/include/pluginTemplate.h b/AudioManagerDaemon/include/pluginTemplate.h
index 1f6a06b..0054d92 100644
--- a/AudioManagerDaemon/include/pluginTemplate.h
+++ b/AudioManagerDaemon/include/pluginTemplate.h
@@ -35,14 +35,14 @@
#include <string>
#include <dlt/dlt.h>
-DLT_IMPORT_CONTEXT(AudioManager);
+DLT_IMPORT_CONTEXT(AudioManager)
/**
* This template tries to load a library and cast ot to a class
* @param libname the full path to the library to be loaded
* @return returns the pointer to the class to be loaded
*/
-template<class T>T* getCreateFunction(std::string libname) {
+template<class T>T* getCreateFunction(const std::string& libname, void*& libraryHandle) {
DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Trying to load libray with name: "),DLT_STRING(libname.c_str()));
@@ -54,9 +54,8 @@ template<class T>T* getCreateFunction(std::string libname) {
std::string createFunctionName = libFileName.substr(3, libFileName.length() - 6) + "Factory";
// open library
- void *libraryHandle;
dlerror(); // Clear any existing error
- libraryHandle = dlopen(libname.c_str(), RTLD_NOW /*LAZY*/);
+ libraryHandle = dlopen(libname.c_str(), RTLD_LAZY);
const char* dlopen_error = dlerror();
if (!libraryHandle || dlopen_error)
{
diff --git a/AudioManagerDaemon/src/CommandReceiver.cpp b/AudioManagerDaemon/src/CommandReceiver.cpp
index 604a659..a970f6b 100644
--- a/AudioManagerDaemon/src/CommandReceiver.cpp
+++ b/AudioManagerDaemon/src/CommandReceiver.cpp
@@ -6,10 +6,19 @@
*/
#include "CommandReceiver.h"
+#include <dlt/dlt.h>
+#include <assert.h>
-CommandReceiver::CommandReceiver(DatabaseHandler* iDatabaseHandler, DBusWrapper* iDBusWrapper)
-: mDatabaseHandler(iDatabaseHandler), mDBusWrapper(iDBusWrapper)
+DLT_IMPORT_CONTEXT(AudioManager)
+
+CommandReceiver::CommandReceiver (DatabaseHandler* iDatabaseHandler, DBusWrapper* iDBusWrapper, ControlSender* iControlSender)
+ : mDatabaseHandler(iDatabaseHandler),
+ mDBusWrapper(iDBusWrapper),
+ mControlSender(iControlSender)
{
+ assert(mDatabaseHandler!=NULL);
+ assert(mDBusWrapper!=NULL);
+ assert(mControlSender!=NULL);
}
CommandReceiver::~CommandReceiver()
@@ -18,50 +27,64 @@ CommandReceiver::~CommandReceiver()
am_Error_e CommandReceiver::connect(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t & mainConnectionID)
{
- mainConnectionID=4;
- return E_OK;
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("CommandReceiver::connect got called:"),DLT_STRING("sourceID"),DLT_INT(sourceID), DLT_STRING("sinkID"), DLT_INT(sinkID));
+ return mControlSender->hookUserConnectionRequest(sourceID,sinkID,mainConnectionID);
}
am_Error_e CommandReceiver::disconnect(const am_mainConnectionID_t mainConnectionID)
{
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("CommandReceiver::disconnect got called, mainConnectionID="),DLT_INT(mainConnectionID));
+ return mControlSender->hookUserDisconnectionRequest(mainConnectionID);
}
am_Error_e CommandReceiver::setVolume(const am_sinkID_t sinkID, const am_mainVolume_t volume)
{
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("CommandReceiver::setVolume got called, sinkID="),DLT_INT(sinkID),DLT_STRING("volume="),DLT_INT(volume));
+ return mControlSender->hookUserVolumeChange(sinkID,volume);
}
am_Error_e CommandReceiver::volumeStep(const am_sinkID_t sinkID, const int16_t volumeStep)
{
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("CommandReceiver::volumeStep got called, sinkID="),DLT_INT(sinkID),DLT_STRING("volumeStep="),DLT_INT(volumeStep));
+ return mControlSender->hookUserVolumeStep(sinkID,volumeStep);
}
am_Error_e CommandReceiver::setSinkMuteState(const am_sinkID_t sinkID, const am_MuteState_e muteState)
{
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("CommandReceiver::setSinkMuteState got called, sinkID="),DLT_INT(sinkID),DLT_STRING("muteState="),DLT_INT(muteState));
+ return mControlSender->hookUserSetSinkMuteState(sinkID,muteState);
}
am_Error_e CommandReceiver::setMainSinkSoundProperty(const am_MainSoundProperty_s & soundProperty, const am_sinkID_t sinkID)
{
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("CommandReceiver::setMainSinkSoundProperty got called, sinkID="),DLT_INT(sinkID),DLT_STRING("soundPropertyType="),DLT_INT(soundProperty.type),DLT_STRING("soundPropertyValue="),DLT_INT(soundProperty.value));
+ return mControlSender->hookUserSetMainSinkSoundProperty(sinkID,soundProperty);
}
am_Error_e CommandReceiver::setMainSourceSoundProperty(const am_MainSoundProperty_s & soundProperty, const am_sourceID_t sourceID)
{
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("CommandReceiver::setMainSourceSoundProperty got called, sourceID="),DLT_INT(sourceID),DLT_STRING("soundPropertyType="),DLT_INT(soundProperty.type),DLT_STRING("soundPropertyValue="),DLT_INT(soundProperty.value));
+ return mControlSender->hookUserSetMainSourceSoundProperty(sourceID,soundProperty);
}
am_Error_e CommandReceiver::setSystemProperty(const am_SystemProperty_s & property)
{
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("CommandReceiver::setSystemProperty got called"),DLT_STRING("type="),DLT_INT(property.type),DLT_STRING("soundPropertyValue="),DLT_INT(property.value));
+ return mControlSender->hookUserSetSystemProperty(property);
}
diff --git a/AudioManagerDaemon/src/CommandSender.cpp b/AudioManagerDaemon/src/CommandSender.cpp
index 113ea2b..841c520 100644
--- a/AudioManagerDaemon/src/CommandSender.cpp
+++ b/AudioManagerDaemon/src/CommandSender.cpp
@@ -8,12 +8,13 @@
#include "CommandSender.h"
#include "command/CommandSendInterface.h"
#include "pluginTemplate.h"
+
using namespace am;
#define CALL_ALL_INTERFACES(...) \
std::vector<CommandSendInterface*>::iterator iter = mListInterfaces.begin(); \
std::vector<CommandSendInterface*>::iterator iterEnd = mListInterfaces.end(); \
- for (; iter<iterEnd;++iter) \
+ for (; iter<iterEnd;++iter) \
{ \
(*iter)->__VA_ARGS__; \
}
@@ -23,6 +24,8 @@ const char* commandPluginDirectories[] = { "/home/christian/workspace/gitserver/
uint16_t commandPluginDirectoriesCount = sizeof(commandPluginDirectories) / sizeof(commandPluginDirectories[0]);
CommandSender::CommandSender()
+ :mListInterfaces(),
+ mListLibraryHandles()
{
std::vector<std::string> sharedLibraryNameList;
@@ -71,7 +74,8 @@ CommandSender::CommandSender()
{
//DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Loading Hook plugin"),DLT_STRING(iter->c_str()));
CommandSendInterface* (*createFunc)();
- createFunc = getCreateFunction<CommandSendInterface*()>(*iter);
+ void* tempLibHandle=NULL;
+ createFunc = getCreateFunction<CommandSendInterface*()>(*iter,tempLibHandle);
if (!createFunc)
{
@@ -88,11 +92,13 @@ CommandSender::CommandSender()
}
mListInterfaces.push_back(commander);
+ mListLibraryHandles.push_back(tempLibHandle);
}
}
CommandSender::~CommandSender()
{
+ unloadLibraries();
}
@@ -229,5 +235,17 @@ void CommandSender::cbTimingInformationChanged(const am_mainConnectionID_t mainC
CALL_ALL_INTERFACES(cbTimingInformationChanged(mainConnection,time))
}
+void CommandSender::unloadLibraries(void)
+{
+ std::vector<void*>::iterator iterator=mListLibraryHandles.begin();
+ for(;iterator<mListLibraryHandles.end();++iterator)
+ {
+ dlclose(*iterator);
+ }
+ mListLibraryHandles.clear();
+}
+
+
+
diff --git a/AudioManagerDaemon/src/ControlReceiver.cpp b/AudioManagerDaemon/src/ControlReceiver.cpp
index d841144..e3e888f 100644
--- a/AudioManagerDaemon/src/ControlReceiver.cpp
+++ b/AudioManagerDaemon/src/ControlReceiver.cpp
@@ -6,8 +6,13 @@
*/
#include "ControlReceiver.h"
+#include <dlt/dlt.h>
-ControlReceiver::ControlReceiver(DatabaseHandler* iDatabaseHandler) : mDatabaseHandler(iDatabaseHandler)
+DLT_IMPORT_CONTEXT(AudioManager)
+
+ControlReceiver::ControlReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender)
+ : mDatabaseHandler(iDatabaseHandler),
+ mRoutingSender(iRoutingSender)
{
}
@@ -17,66 +22,126 @@ ControlReceiver::~ControlReceiver()
am_Error_e ControlReceiver::getRoute(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector<am_Route_s> & returnList)
{
+ //todo: implement routing algorithm
}
am_Error_e ControlReceiver::connect(am_Handle_s & handle, am_connectionID_t & connectionID, const am_ConnectionFormat_e format, const am_sourceID_t sourceID, const am_sinkID_t sinkID)
{
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("ControlReceiver::connect got called, connectionFormat"),DLT_INT(format),DLT_STRING("sourceID"),DLT_INT(sourceID),DLT_STRING("sinkID"),DLT_INT(sinkID));
+
+ am_Connection_s tempConnection;
+ tempConnection.sinkID=sinkID;
+ tempConnection.sourceID=sourceID;
+ tempConnection.connectionFormat=format;
+ tempConnection.connectionID=0;
+
+ if (mDatabaseHandler->existConnection(tempConnection)) return E_ALREADY_EXISTS; //todo:enter the correct connectionID here?
+
+ mDatabaseHandler->enterConnectionDB(tempConnection,connectionID);
+ return mRoutingSender->asyncConnect(handle,connectionID,sourceID,sinkID,format);
}
am_Error_e ControlReceiver::disconnect(am_Handle_s & handle, const am_connectionID_t connectionID)
{
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("ControlReceiver::disconnect got called, connectionID="),DLT_INT(connectionID));
+
+ if (!mDatabaseHandler->existConnectionID(connectionID)) return E_NON_EXISTENT; //todo: check with EA model and correct
+ return mRoutingSender->asyncDisconnect(handle,connectionID);
}
am_Error_e ControlReceiver::crossfade(am_Handle_s & handle, const am_HotSink_e hotSource, const am_crossfaderID_t crossfaderID, const am_RampType_e rampType, const am_time_t rampTime)
{
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("ControlReceiver::crossfade got called, hotSource="),DLT_INT(hotSource),DLT_STRING("crossfaderID="),DLT_INT(crossfaderID),DLT_STRING("rampType="),DLT_INT(rampType),DLT_STRING("rampTime="),DLT_INT(rampTime));
+
+ if (!mDatabaseHandler->existcrossFader(crossfaderID)) return E_NON_EXISTENT;
+ return mRoutingSender->asyncCrossFade(handle,crossfaderID,hotSource,rampType,rampTime);
}
am_Error_e ControlReceiver::setSourceState(am_Handle_s & handle, const am_sourceID_t sourceID, const am_SourceState_e state)
{
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("ControlReceiver::setSourceState got called, sourceID="),DLT_INT(sourceID),DLT_STRING("state="),DLT_INT(state));
+
+ am_SourceState_e sourceState;
+ if(mDatabaseHandler->getSoureState(sourceID,sourceState)!=E_OK) return E_UNKNOWN;
+ if(sourceState==state) return E_NO_CHANGE;
+ return mRoutingSender->asyncSetSourceState(handle,sourceID,state);
}
am_Error_e ControlReceiver::setSinkVolume(am_Handle_s & handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time)
{
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("ControlReceiver::setSinkVolume got called, sinkID="),DLT_INT(sinkID),DLT_STRING("volume="),DLT_INT(volume),DLT_STRING("ramp="),DLT_INT(ramp),DLT_STRING("time="),DLT_INT(time));
+
+ am_volume_t tempVolume;
+ if(mDatabaseHandler->getSinkVolume(sinkID,tempVolume)!=E_OK) return E_UNKNOWN;
+ if(tempVolume==volume) return E_NO_CHANGE;
+ return mRoutingSender->asyncSetSinkVolume(handle,sinkID,volume,ramp,time);
}
am_Error_e ControlReceiver::setSourceVolume(am_Handle_s & handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_RampType_e rampType, const am_time_t time)
{
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("ControlReceiver::setSourceVolume got called, sourceID="),DLT_INT(sourceID),DLT_STRING("volume="),DLT_INT(volume),DLT_STRING("ramp="),DLT_INT(rampType),DLT_STRING("time="),DLT_INT(time));
+
+ am_volume_t tempVolume;
+ if(mDatabaseHandler->getSourceVolume(sourceID,tempVolume)!=E_OK) return E_UNKNOWN;
+ if(tempVolume==volume) return E_NO_CHANGE;
+ return mRoutingSender->asyncSetSourceVolume(handle,sourceID,volume,rampType,time);
}
am_Error_e ControlReceiver::setSinkSoundProperty(am_Handle_s & handle, const am_sinkID_t sinkID, const am_SoundProperty_s & soundProperty)
{
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("ControlReceiver::setSinkSoundProperty got called, sinkID="),DLT_INT(sinkID),DLT_STRING("soundProperty.Type="),DLT_INT(soundProperty.type),DLT_STRING("soundProperty.value="),DLT_INT(soundProperty.value));
+
+ uint16_t value;
+ if(mDatabaseHandler->getSinkSoundPropertyValue(sinkID,soundProperty.type,value)!=E_OK) return E_UNKNOWN;
+ if(value==soundProperty.value) return E_NO_CHANGE;
+ return mRoutingSender->asyncSetSinkSoundProperty(handle,sinkID,soundProperty);
}
am_Error_e ControlReceiver::setSourceSoundProperty(am_Handle_s & handle, const am_sourceID_t sourceID, const am_SoundProperty_s & soundProperty)
{
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("ControlReceiver::setSourceSoundProperty got called, sourceID="),DLT_INT(sourceID),DLT_STRING("soundProperty.Type="),DLT_INT(soundProperty.type),DLT_STRING("soundProperty.value="),DLT_INT(soundProperty.value));
+
+ uint16_t value;
+ if(mDatabaseHandler->getSourceSoundPropertyValue(sourceID,soundProperty.type,value)!=E_OK) return E_UNKNOWN;
+ if(value==soundProperty.value) return E_NO_CHANGE;
+ return mRoutingSender->asyncSetSourceSoundProperty(handle,sourceID,soundProperty);
}
am_Error_e ControlReceiver::setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState)
{
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("ControlReceiver::setDomainState got called, domainID="),DLT_INT(domainID),DLT_STRING("domainState="),DLT_INT(domainState));
+
+ am_DomainState_e tempState=DS_MIN;
+ if(mDatabaseHandler->getDomainState(domainID,tempState)!=E_OK) return E_UNKNOWN;
+ if(tempState==domainState) return E_NO_CHANGE;
+ return mRoutingSender->setDomainState(domainID,domainState);
}
am_Error_e ControlReceiver::abortAction(const am_Handle_s handle)
{
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("ControlReceiver::abortAction got called, handle.type="),DLT_INT(handle.handle),DLT_STRING("handle.handleType="),DLT_INT(handle.handleType));
+
+ return mRoutingSender->asyncAbort(handle);
}
@@ -349,7 +414,7 @@ am_Error_e ControlReceiver::getListSourceClasses(std::vector<am_SourceClass_s> &
am_Error_e ControlReceiver::getListHandles(std::vector<am_Handle_s> & listHandles) const
{
- //todo: implement getListHandles
+ return mRoutingSender->getListHandles(listHandles);
}
@@ -380,30 +445,33 @@ am_Error_e ControlReceiver::getListSystemProperties(std::vector<am_SystemPropert
}
-void ControlReceiver::setRoutingReady()
-{
-}
-
-
am_Error_e ControlReceiver::changeSinkClassInfoDB(const am_SinkClass_s & classInfo)
{
+ mDatabaseHandler->changeSinkClassInfoDB(classInfo);
}
am_Error_e ControlReceiver::changeSourceClassInfoDB(const am_SourceClass_s & classInfo)
{
+ mDatabaseHandler->changeSourceClassInfoDB(classInfo);
}
am_Error_e ControlReceiver::removeSinkClassDB(const am_sinkClass_t sinkClassID)
{
+ mDatabaseHandler->removeSinkClassDB(sinkClassID);
}
am_Error_e ControlReceiver::removeSourceClassDB(const am_sourceClass_t sourceClassID)
{
+ mDatabaseHandler->removeSourceClassDB(sourceClassID);
}
void ControlReceiver::setCommandReady()
{
}
+void ControlReceiver::setRoutingReady()
+{
+}
+
diff --git a/AudioManagerDaemon/src/ControlSender.cpp b/AudioManagerDaemon/src/ControlSender.cpp
index bd3787b..7f015e1 100644
--- a/AudioManagerDaemon/src/ControlSender.cpp
+++ b/AudioManagerDaemon/src/ControlSender.cpp
@@ -1,42 +1,299 @@
/*
- * ControlLoader.cpp
+ * ControlSender.cpp
*
- * Created on: Oct 25, 2011
+ * Created on: Dec 9, 2011
* Author: christian
*/
#include "ControlSender.h"
+#include "control/ControlSendInterface.h"
+#include "control/ControlReceiveInterface.h"
#include "pluginTemplate.h"
-#include <string>
+#include <assert.h>
+
+std::string controlPluginFile= "/home/christian/workspace/gitserver/build/plugins/control/libPluginControlInterface.so";
ControlSender::ControlSender()
{
ControlSendInterface* (*createFunc)();
- std::string libPath="/home/christian/workspace/gitserver/build/plugins/control/libPluginControlInterface.so";
- createFunc = getCreateFunction<ControlSendInterface*()>(libPath);
+ createFunc = getCreateFunction<ControlSendInterface*()>(controlPluginFile,mlibHandle);
+
+ assert(createFunc!=NULL);
+
+ mController = createFunc();
+}
+
+ControlSender::~ControlSender()
+{
+ dlclose(mlibHandle);
+}
- if (!createFunc) {
- //DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Entry point of Communicator not found"));
- }
+void ControlSender::hookAllPluginsLoaded()
+{
+ mController->hookAllPluginsLoaded();
+}
- //mControler = createFunc();
- if (!mControler) {
- //DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("RoutingPlugin initialization failed. Entry Function not callable"));
- }
+am_Error_e ControlSender::hookUserConnectionRequest(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t & mainConnectionID)
+{
+ return mController->hookUserConnectionRequest(sourceID,sinkID,mainConnectionID);
}
-ControlSender::~ControlSender()
+am_Error_e ControlSender::hookUserDisconnectionRequest(const am_mainConnectionID_t connectionID)
+{
+ return mController->hookUserDisconnectionRequest(connectionID);
+}
+
+
+
+am_Error_e ControlSender::hookUserSetMainSinkSoundProperty(const am_sinkID_t sinkID, const am_MainSoundProperty_s & soundProperty)
+{
+ return mController->hookUserSetMainSinkSoundProperty(sinkID,soundProperty);
+}
+
+
+
+am_Error_e ControlSender::hookUserSetMainSourceSoundProperty(const am_sourceID_t sourceID, const am_MainSoundProperty_s & soundProperty)
+{
+ return mController->hookUserSetMainSourceSoundProperty(sourceID,soundProperty);
+}
+
+
+
+am_Error_e ControlSender::hookUserSetSystemProperty(const am_SystemProperty_s & property)
+{
+ return mController->hookUserSetSystemProperty(property);
+}
+
+
+
+am_Error_e ControlSender::hookUserVolumeChange(const am_sinkID_t sinkID, const am_mainVolume_t newVolume)
+{
+ return mController->hookUserVolumeChange(sinkID,newVolume);
+}
+
+
+
+am_Error_e ControlSender::hookUserVolumeStep(const am_sinkID_t sinkID, const int16_t increment)
+{
+ return mController->hookUserVolumeStep(sinkID,increment);
+}
+
+
+
+am_Error_e ControlSender::hookUserSetSinkMuteState(const am_sinkID_t sinkID, const am_MuteState_e muteState)
+{
+ return mController->hookUserSetSinkMuteState(sinkID,muteState);
+}
+
+
+
+am_Error_e ControlSender::hookSystemRegisterDomain(const am_Domain_s & domainData, am_domainID_t & domainID)
{
+ return mController->hookSystemRegisterDomain(domainData,domainID);
}
-ControlSendInterface *ControlSender::returnControl()
+am_Error_e ControlSender::hookSystemDeregisterDomain(const am_domainID_t domainID)
{
- return mControler;
+ return mController->hookSystemDeregisterDomain(domainID);
}
+
+
+void ControlSender::hookSystemDomainRegistrationComplete(const am_domainID_t domainID)
+{
+ return mController->hookSystemDomainRegistrationComplete(domainID);
+}
+
+
+
+am_Error_e ControlSender::hookSystemRegisterSink(const am_Sink_s & sinkData, am_sinkID_t & sinkID)
+{
+ return mController->hookSystemRegisterSink(sinkData,sinkID);
+}
+
+
+
+am_Error_e ControlSender::hookSystemDeregisterSink(const am_sinkID_t sinkID)
+{
+ return mController->hookSystemDeregisterSink(sinkID);
+}
+
+
+
+am_Error_e ControlSender::hookSystemRegisterSource(const am_Source_s & sourceData, am_sourceID_t & sourceID)
+{
+ return mController->hookSystemRegisterSource(sourceData,sourceID);
+}
+
+
+
+am_Error_e ControlSender::hookSystemDeregisterSource(const am_sourceID_t sourceID)
+{
+ return mController->hookSystemDeregisterSource(sourceID);
+}
+
+
+
+am_Error_e ControlSender::hookSystemRegisterGateway(const am_Gateway_s & gatewayData, am_gatewayID_t & gatewayID)
+{
+ return mController->hookSystemRegisterGateway(gatewayData,gatewayID);
+}
+
+
+
+am_Error_e ControlSender::hookSystemDeregisterGateway(const am_gatewayID_t gatewayID)
+{
+ return mController->hookSystemDeregisterGateway(gatewayID);
+}
+
+
+
+am_Error_e ControlSender::hookSystemRegisterCrossfader(const am_Crossfader_s & crossfaderData, am_crossfaderID_t & crossfaderID)
+{
+ return mController->hookSystemRegisterCrossfader(crossfaderData,crossfaderID);
+}
+
+
+
+am_Error_e ControlSender::hookSystemDeregisterCrossfader(const am_crossfaderID_t crossfaderID)
+{
+ return mController->hookSystemDeregisterCrossfader(crossfaderID);
+}
+
+
+
+void ControlSender::hookSystemSinkVolumeTick(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume)
+{
+ return mController->hookSystemSinkVolumeTick(handle,sinkID,volume);
+}
+
+
+
+void ControlSender::hookSystemSourceVolumeTick(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume)
+{
+ return mController->hookSystemSourceVolumeTick(handle,sourceID,volume);
+}
+
+
+
+void ControlSender::hookSystemInterruptStateChange(const am_sourceID_t sourceID, const am_InterruptState_e interruptState)
+{
+ return mController->hookSystemInterruptStateChange(sourceID,interruptState);
+}
+
+
+
+void ControlSender::hookSystemSinkAvailablityStateChange(const am_sinkID_t sinkID, const am_Availability_s & availability)
+{
+ return mController->hookSystemSinkAvailablityStateChange(sinkID,availability);
+}
+
+
+
+void ControlSender::hookSystemSourceAvailablityStateChange(const am_sourceID_t sourceID, const am_Availability_s & availability)
+{
+ return mController->hookSystemSourceAvailablityStateChange(sourceID,availability);
+}
+
+
+
+void ControlSender::hookSystemDomainStateChange(const am_domainID_t domainID, const am_DomainState_e state)
+{
+ return mController->hookSystemDomainStateChange(domainID,state);
+}
+
+
+
+void ControlSender::hookSystemReceiveEarlyData(const std::vector<am_EarlyData_s> & data)
+{
+ return mController->hookSystemReceiveEarlyData(data);
+}
+
+
+
+void ControlSender::hookSystemSpeedChange(const am_speed_t speed)
+{
+ return mController->hookSystemSpeedChange(speed);
+}
+
+
+
+void ControlSender::hookSystemTimingInformationChanged(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time)
+{
+ return mController->hookSystemTimingInformationChanged(mainConnectionID,time);
+}
+
+
+
+void ControlSender::cbAckConnect(const am_Handle_s handle, const am_Error_e errorID)
+{
+ return mController->cbAckConnect(handle,errorID);
+}
+
+
+
+void ControlSender::cbAckDisconnect(const am_Handle_s handle, const am_Error_e errorID)
+{
+ return mController->cbAckDisconnect(handle,errorID);
+}
+
+
+
+void ControlSender::cbAckCrossFade(const am_Handle_s handle, const am_HotSink_e hostsink, const am_Error_e error)
+{
+ return mController->cbAckCrossFade(handle,hostsink,error);
+}
+
+
+
+void ControlSender::cbAckSetSinkVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error)
+{
+ return mController->cbAckSetSinkVolumeChange(handle,volume,error);
+}
+
+
+
+void ControlSender::cbAckSetSourceVolumeChange(const am_Handle_s handle, const am_volume_t voulme, const am_Error_e error)
+{
+ return mController->cbAckSetSourceVolumeChange(handle,voulme,error);
+}
+
+
+
+void ControlSender::cbAckSetSourceState(const am_Handle_s handle, const am_Error_e error)
+{
+ return mController->cbAckSetSourceState(handle,error);
+}
+
+
+
+void ControlSender::cbAckSetSourceSoundProperty(const am_Handle_s handle, const am_Error_e error)
+{
+ return mController->cbAckSetSourceSoundProperty(handle,error);
+}
+
+
+
+am_Error_e ControlSender::startupController(ControlReceiveInterface *controlreceiveinterface)
+{
+ return mController->startupController(controlreceiveinterface);
+}
+
+am_Error_e ControlSender::stopController()
+{
+ return mController->stopController();
+}
+
+void ControlSender::cbAckSetSinkSoundProperty(const am_Handle_s handle, const am_Error_e error)
+{
+ return mController->cbAckSetSinkSoundProperty(handle,error);
+}
+
+
+
diff --git a/AudioManagerDaemon/src/DBusWrapper.cpp b/AudioManagerDaemon/src/DBusWrapper.cpp
index f614aab..6f971df 100644
--- a/AudioManagerDaemon/src/DBusWrapper.cpp
+++ b/AudioManagerDaemon/src/DBusWrapper.cpp
@@ -29,7 +29,7 @@
#include <sstream>
#include <string>
-DLT_IMPORT_CONTEXT(AudioManager);
+DLT_IMPORT_CONTEXT(AudioManager)
#define ROOT_INTROSPECT_XML \
diff --git a/AudioManagerDaemon/src/DatabaseHandler.cpp b/AudioManagerDaemon/src/DatabaseHandler.cpp
index 2284717..5bfcd37 100644
--- a/AudioManagerDaemon/src/DatabaseHandler.cpp
+++ b/AudioManagerDaemon/src/DatabaseHandler.cpp
@@ -6,6 +6,7 @@
*/
#include "DatabaseHandler.h"
+#include "Observer.h"
#include <dlt/dlt.h>
#include <assert.h>
#include <stdint.h>
@@ -16,7 +17,7 @@
#include <malloc.h>
#include <string.h>
-DLT_IMPORT_CONTEXT(AudioManager);
+DLT_IMPORT_CONTEXT(AudioManager)
//#define DATABASE_PATH "/tmp/audiomanager.sqlite"
#define DATABASE_PATH ":memory:"
@@ -27,6 +28,7 @@ DLT_IMPORT_CONTEXT(AudioManager);
#define SOURCE_TABLE "Sources"
#define SINK_TABLE "Sinks"
#define GATEWAY_TABLE "Gateways"
+#define CROSSFADER_TABLE "Crossfaders"
#define CONNECTION_TABLE "Connections"
#define MAINCONNECTION_TABLE "MainConnections"
#define INTERRUPT_TABLE "Interrupts"
@@ -34,13 +36,14 @@ DLT_IMPORT_CONTEXT(AudioManager);
#define SYSTEM_TABLE "SystemProperties"
const std::string databaseTables[]={
- " Domains (domainID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name VARCHAR(50), busname VARCHAR(50), nodename VARCHAR(50), early BOOL, complete BOOL, state INTEGER);",
+ " Domains (domainID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name VARCHAR(50), busname VARCHAR(50), nodename VARCHAR(50), early BOOL, complete BOOL, state INTEGER, reserved BOOL);",
" SourceClasses (sourceClassID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name VARCHAR(50));",
" SinkClasses (sinkClassID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name VARCHAR(50));",
- " Sources (sourceID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, domainID INTEGER, name VARCHAR(50), sourceClassID INTEGER, sourceState INTEGER, volume INTEGER, visible BOOL, availability INTEGER, availabilityReason INTEGER, interruptState INTEGER);",
- " Sinks (sinkID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name VARCHAR(50), domainID INTEGER, sinkClassID INTEGER, volume INTEGER, visible BOOL, availability INTEGER, availabilityReason INTEGER, muteState INTEGER, mainVolume INTEGER);",
+ " Sources (sourceID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, domainID INTEGER, name VARCHAR(50), sourceClassID INTEGER, sourceState INTEGER, volume INTEGER, visible BOOL, availability INTEGER, availabilityReason INTEGER, interruptState INTEGER, reserved BOOL);",
+ " Sinks (sinkID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name VARCHAR(50), domainID INTEGER, sinkClassID INTEGER, volume INTEGER, visible BOOL, availability INTEGER, availabilityReason INTEGER, muteState INTEGER, mainVolume INTEGER, reserved BOOL);",
" Gateways (gatewayID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name VARCHAR(50), sinkID INTEGER, sourceID INTEGER, domainSinkID INTEGER, domainSourceID INTEGER, controlDomainID INTEGER);",
- " Connections (connectionID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, sourceID INTEGER, sinkID INTEGER, delay INTEGER, connectionFormat INTEGER );",
+ " Crossfaders (crossfaderID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name VARCHAR(50), sinkID_A INTEGER, sinkID_B INTEGER, sourceID INTEGER, hotSink INTEGER);",
+ " Connections (connectionID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, sourceID INTEGER, sinkID INTEGER, delay INTEGER, connectionFormat INTEGER, reserved BOOL);",
" MainConnections (mainConnectionID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, sourceID INTEGER, sinkID INTEGER, connectionState INTEGER, delay INTEGER);",
" SystemProperties (type INTEGER PRIMARY KEY, value INTEGER);"
};
@@ -50,17 +53,18 @@ const std::string databaseTables[]={
* @param i the value to be converted
* @return the string
*/
-
-std::string int2string(int i) {
- std::stringstream out;
- out << i;
- return out.str();
+template<typename T>
+inline std::string i2s(T const& x)
+{
+ std::ostringstream o;
+ o << x;
+ return o.str();
}
-
DatabaseHandler::DatabaseHandler()
: mDatabase(NULL),
mPath(DATABASE_PATH),
+ mObserver(NULL),
mFirstStaticSink(true),
mFirstStaticSource(true),
mFirstStaticGateway(true),
@@ -98,8 +102,6 @@ DatabaseHandler::~DatabaseHandler()
sqlite3_close(mDatabase);
}
-
-
am_Error_e DatabaseHandler::enterDomainDB(const am_Domain_s & domainData, am_domainID_t & domainID)
{
assert(domainData.domainID==0);
@@ -107,20 +109,22 @@ am_Error_e DatabaseHandler::enterDomainDB(const am_Domain_s & domainData, am_dom
assert(!domainData.busname.empty());
assert(domainData.state>=DS_CONTROLLED && domainData.state<=DS_INDEPENDENT_RUNDOWN);
-
- sqlite3_stmt* query=NULL;
+ //first check for a reserved domain
+ sqlite3_stmt* query=NULL, *queryFinal;
int eCode=0;
- std::string command= "INSERT INTO " + std::string(DOMAIN_TABLE) + "(name, busname, nodename, early, complete, state) VALUES (?,?,?,?,?,?)";
-
+ std::string command="SELECT domainID FROM "+ std::string(DOMAIN_TABLE) + " WHERE name=?";
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
sqlite3_bind_text(query,1, domainData.name.c_str(),domainData.name.size(),SQLITE_STATIC);
- sqlite3_bind_text(query,2, domainData.busname.c_str(),domainData.busname.size(),SQLITE_STATIC);
- sqlite3_bind_text(query,3, domainData.nodename.c_str(),domainData.nodename.size(),SQLITE_STATIC);
- sqlite3_bind_int(query,4, domainData.early);
- sqlite3_bind_int(query,5, domainData.complete);
- sqlite3_bind_int(query,6, domainData.state);
+ if ((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ command= "UPDATE " + std::string(DOMAIN_TABLE) + " SET name=?, busname=?, nodename=?, early=?, complete=?, state=?, reserved=? WHERE domainID=" +i2s(sqlite3_column_int(query,0));
+ }
+ else if (eCode==SQLITE_DONE)
+ {
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ command= "INSERT INTO " + std::string(DOMAIN_TABLE) + " (name, busname, nodename, early, complete, state, reserved) VALUES (?,?,?,?,?,?,?)";
+ }
+ else
{
DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterDomainDB SQLITE Step error code:"),DLT_INT(eCode));
return E_DATABASE_ERROR;
@@ -132,6 +136,27 @@ am_Error_e DatabaseHandler::enterDomainDB(const am_Domain_s & domainData, am_dom
return E_DATABASE_ERROR;
}
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&queryFinal,NULL);
+ sqlite3_bind_text(queryFinal,1, domainData.name.c_str(),domainData.name.size(),SQLITE_STATIC);
+ sqlite3_bind_text(queryFinal,2, domainData.busname.c_str(),domainData.busname.size(),SQLITE_STATIC);
+ sqlite3_bind_text(queryFinal,3, domainData.nodename.c_str(),domainData.nodename.size(),SQLITE_STATIC);
+ sqlite3_bind_int(queryFinal,4, domainData.early);
+ sqlite3_bind_int(queryFinal,5, domainData.complete);
+ sqlite3_bind_int(queryFinal,6, domainData.state);
+ sqlite3_bind_int(queryFinal,7, 0);
+
+ if((eCode=sqlite3_step(queryFinal))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterDomainDB SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(queryFinal))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterDomainDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
domainID=sqlite3_last_insert_rowid(mDatabase);
DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::enterDomainDB entered new domain with name"), DLT_STRING(domainData.name.c_str()),
DLT_STRING("busname:"),DLT_STRING(domainData.busname.c_str()),
@@ -140,6 +165,11 @@ am_Error_e DatabaseHandler::enterDomainDB(const am_Domain_s & domainData, am_dom
DLT_STRING("complete:"),DLT_BOOL(domainData.complete),
DLT_STRING("state:"),DLT_INT(domainData.state),
DLT_STRING("assigned ID:"),DLT_INT16(domainID));
+
+ am_Domain_s domain=domainData;
+ domain.domainID=domainID;
+ if(mObserver) mObserver->newDomain(domain);
+
return E_OK;
}
@@ -209,10 +239,10 @@ am_Error_e DatabaseHandler::enterMainConnectionDB(const am_MainConnection_s & ma
}
//now we create a table with references to the connections;
- command="CREATE TABLE MainConnectionRoute" + int2string(connectionID) + std::string("(connectionID INTEGER)");
+ command="CREATE TABLE MainConnectionRoute" + i2s(connectionID) + std::string("(connectionID INTEGER)");
assert(this->sqQuery(command));
- command= "INSERT INTO MainConnectionRoute" + int2string(connectionID) + "(connectionID) VALUES (?)";
+ command= "INSERT INTO MainConnectionRoute" + i2s(connectionID) + "(connectionID) VALUES (?)";
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
std::vector<uint16_t>::iterator listConnectionIterator=listOfConnections.begin();
for(;listConnectionIterator<listOfConnections.end();++listConnectionIterator)
@@ -237,6 +267,12 @@ am_Error_e DatabaseHandler::enterMainConnectionDB(const am_MainConnection_s & ma
DLT_STRING("delay:"),DLT_INT16(delay),
DLT_STRING("assigned ID:"),DLT_INT16(connectionID));
+ if (mObserver)
+ {
+ mObserver->numberOfMainConnectionsChanged();
+ mObserver->mainConnectionStateChanged(connectionID,mainConnectionData.connectionState);
+ }
+
//finally, we update the delay value for the maintable
if (delay==0) delay=-1;
return changeDelayMainConnection(delay,connectionID);
@@ -253,70 +289,113 @@ am_Error_e DatabaseHandler::enterSinkDB(const am_Sink_s & sinkData, am_sinkID_t
assert(!sinkData.listConnectionFormats.empty());
assert(sinkData.muteState>=MS_MUTED && sinkData.muteState<=MS_UNMUTED);
- sqlite3_stmt* query=NULL;
+ sqlite3_stmt *query=NULL, *queryFinal=NULL;
int eCode=0;
- std::string command;
+ std::string command="SELECT sinkID FROM "+ std::string(SINK_TABLE) + " WHERE name=? AND reserved=1";
- //if sinkID is zero and the first Static Sink was already entered, the ID is created
- if (sinkData.sinkID==0 && !mFirstStaticSink)
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_bind_text(query,1, sinkData.name.c_str(),sinkData.name.size(),SQLITE_STATIC);
+
+ if ((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ command= "UPDATE " + std::string(SINK_TABLE) + " SET name=?, domainID=?, sinkClassID=?, volume=?, visible=?, availability=?, availabilityReason=?, muteState=?, mainVolume=?, reserved=? WHERE sinkID=" +i2s(sqlite3_column_int(query,0));
+ }
+ else if (eCode==SQLITE_DONE)
{
- command= "INSERT INTO " + std::string(SINK_TABLE) + "(name, domainID, sinkClassID, volume, visible, availability, availabilityReason, muteState, mainVolume) VALUES (?,?,?,?,?,?,?,?,?)";
+ //if sinkID is zero and the first Static Sink was already entered, the ID is created
+ if (sinkData.sinkID==0 && !mFirstStaticSink && !existSinkName(sinkData.name))
+ {
+ command= "INSERT INTO " + std::string(SINK_TABLE) + "(name, domainID, sinkClassID, volume, visible, availability, availabilityReason, muteState, mainVolume, reserved) VALUES (?,?,?,?,?,?,?,?,?,?)";
+ }
+ else
+ {
+ //check if the ID already exists
+ if(existSinkNameOrID(sinkData.sinkID,sinkData.name))
+ {
+ sqlite3_finalize(query);
+ return E_ALREADY_EXISTS;
+ }
+ command= "INSERT INTO " + std::string(SINK_TABLE) + "(name, domainID, sinkClassID, volume, visible, availability, availabilityReason, muteState, mainVolume, reserved, sinkID) VALUES (?,?,?,?,?,?,?,?,?,?,?)";
+ }
}
else
{
- //check if the ID already exists
- if(existSink(sinkData.sinkID)) return E_ALREADY_EXISTS;
- command= "INSERT INTO " + std::string(SINK_TABLE) + "(name, domainID, sinkClassID, volume, visible, availability, availabilityReason, muteState, mainVolume, sinkID) VALUES (?,?,?,?,?,?,?,?,?,?)";
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkDB SQLITE Step error code:"),DLT_INT(eCode));
+ sqlite3_finalize(query);
+ return E_DATABASE_ERROR;
}
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_text(query,1, sinkData.name.c_str(),sinkData.name.size(),SQLITE_STATIC);
- sqlite3_bind_int(query,2, sinkData.domainID);
- sqlite3_bind_int(query,3, sinkData.sinkClassID);
- sqlite3_bind_int(query,4, sinkData.volume);
- sqlite3_bind_int(query,5, sinkData.visible);
- sqlite3_bind_int(query,6, sinkData.available.availability);
- sqlite3_bind_int(query,7, sinkData.available.availabilityReason);
- sqlite3_bind_int(query,8, sinkData.muteState);
- sqlite3_bind_int(query,9, sinkData.mainVolume);
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&queryFinal,NULL);
+ sqlite3_bind_text(queryFinal,1, sinkData.name.c_str(),sinkData.name.size(),SQLITE_STATIC);
+ sqlite3_bind_int(queryFinal,2, sinkData.domainID);
+ sqlite3_bind_int(queryFinal,3, sinkData.sinkClassID);
+ sqlite3_bind_int(queryFinal,4, sinkData.volume);
+ sqlite3_bind_int(queryFinal,5, sinkData.visible);
+ sqlite3_bind_int(queryFinal,6, sinkData.available.availability);
+ sqlite3_bind_int(queryFinal,7, sinkData.available.availabilityReason);
+ sqlite3_bind_int(queryFinal,8, sinkData.muteState);
+ sqlite3_bind_int(queryFinal,9, sinkData.mainVolume);
+ sqlite3_bind_int(queryFinal,10, 0);
//if the ID is not created, we add it to the query
if(sinkData.sinkID!=0)
{
- sqlite3_bind_int(query,10, sinkData.sinkID);
+ sqlite3_bind_int(queryFinal,11, sinkData.sinkID);
}
//if the first static sink is entered, we need to set it onto the boundary
else if(mFirstStaticSink)
{
- sqlite3_bind_int(query,10, DYNAMIC_ID_BOUNDARY);
+ sqlite3_bind_int(queryFinal,11, DYNAMIC_ID_BOUNDARY);
mFirstStaticSink=false;
}
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ if((eCode=sqlite3_step(queryFinal))!=SQLITE_DONE)
{
DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkDB SQLITE Step error code:"),DLT_INT(eCode));
+ sqlite3_finalize(queryFinal);
return E_DATABASE_ERROR;
}
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ if((eCode=sqlite3_finalize(queryFinal))!=SQLITE_OK)
{
DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkDB SQLITE Finalize error code:"),DLT_INT(eCode));
return E_DATABASE_ERROR;
}
- sinkID=sqlite3_last_insert_rowid(mDatabase); //todo:change last_insert implementations for mulithread usage...
+ //now read back the sinkID
+ command = "SELECT sinkID FROM " + std::string(SINK_TABLE) + " WHERE name=?";
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_bind_text(query,1,sinkData.name.c_str(),sinkData.name.size(),SQLITE_STATIC);
+ if ((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ sinkID=sqlite3_column_int(query,0);
+ }
+ else
+ {
+ sinkID=0;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existSink database error!:"), DLT_INT(eCode))
+ sqlite3_finalize(query);
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_finalize(query);
//now we need to create the additional tables:
- command="CREATE TABLE SinkConnectionFormat" + int2string(sinkID) + std::string("(soundFormat INTEGER)");
+ command="CREATE TABLE SinkConnectionFormat" + i2s(sinkID) + std::string("(soundFormat INTEGER)");
assert(this->sqQuery(command));
- command="CREATE TABLE SinkMainSoundProperty" + int2string(sinkID) + std::string("(soundPropertyType INTEGER, value INTEGER)");
+ command="CREATE TABLE SinkMainSoundProperty" + i2s(sinkID) + std::string("(soundPropertyType INTEGER, value INTEGER)");
assert(this->sqQuery(command));
- command="CREATE TABLE SinkSoundProperty" + int2string(sinkID) + std::string("(soundPropertyType INTEGER, value INTEGER)");
+ command="CREATE TABLE SinkSoundProperty" + i2s(sinkID) + std::string("(soundPropertyType INTEGER, value INTEGER)");
assert(this->sqQuery(command));
//fill ConnectionFormats
- command="INSERT INTO SinkConnectionFormat" + int2string(sinkID) + std::string("(soundFormat) VALUES (?)");
+ command="INSERT INTO SinkConnectionFormat" + i2s(sinkID) + std::string("(soundFormat) VALUES (?)");
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
std::vector<am_ConnectionFormat_e>::const_iterator connectionFormatIterator=sinkData.listConnectionFormats.begin();
for(;connectionFormatIterator<sinkData.listConnectionFormats.end();++connectionFormatIterator)
@@ -325,13 +404,14 @@ am_Error_e DatabaseHandler::enterSinkDB(const am_Sink_s & sinkData, am_sinkID_t
if((eCode=sqlite3_step(query))!=SQLITE_DONE)
{
DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkDB SQLITE Step error code:"),DLT_INT(eCode));
+ sqlite3_finalize(query);
return E_DATABASE_ERROR;
}
sqlite3_reset(query);
}
//Fill MainSinkSoundProperties
- command="INSERT INTO SinkMainSoundProperty" + int2string(sinkID) + std::string("(soundPropertyType,value) VALUES (?,?)");
+ command="INSERT INTO SinkMainSoundProperty" + i2s(sinkID) + std::string("(soundPropertyType,value) VALUES (?,?)");
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
std::vector<am_MainSoundProperty_s>::const_iterator mainSoundPropertyIterator=sinkData.listMainSoundProperties.begin();
for(;mainSoundPropertyIterator<sinkData.listMainSoundProperties.end();++mainSoundPropertyIterator)
@@ -341,13 +421,14 @@ am_Error_e DatabaseHandler::enterSinkDB(const am_Sink_s & sinkData, am_sinkID_t
if((eCode=sqlite3_step(query))!=SQLITE_DONE)
{
DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkDB SQLITE Step error code:"),DLT_INT(eCode));
+ sqlite3_finalize(query);
return E_DATABASE_ERROR;
}
sqlite3_reset(query);
}
//Fill SinkSoundProperties
- command="INSERT INTO SinkSoundProperty" + int2string(sinkID) + std::string("(soundPropertyType,value) VALUES (?,?)");
+ command="INSERT INTO SinkSoundProperty" + i2s(sinkID) + std::string("(soundPropertyType,value) VALUES (?,?)");
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
std::vector<am_SoundProperty_s>::const_iterator SoundPropertyIterator=sinkData.listSoundProperties.begin();
for(;SoundPropertyIterator<sinkData.listSoundProperties.end();++SoundPropertyIterator)
@@ -357,6 +438,7 @@ am_Error_e DatabaseHandler::enterSinkDB(const am_Sink_s & sinkData, am_sinkID_t
if((eCode=sqlite3_step(query))!=SQLITE_DONE)
{
DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkDB SQLITE Step error code:"),DLT_INT(eCode));
+ sqlite3_finalize(query);
return E_DATABASE_ERROR;
}
sqlite3_reset(query);
@@ -373,6 +455,10 @@ am_Error_e DatabaseHandler::enterSinkDB(const am_Sink_s & sinkData, am_sinkID_t
DLT_STRING("mainVolume:"),DLT_INT(sinkData.mainVolume),
DLT_STRING("assigned ID:"),DLT_INT16(sinkID));
+ am_Sink_s sink=sinkData;
+ sink.sinkID=sinkID;
+ if (mObserver!=NULL) mObserver->newSink(sink);
+
return E_OK;
}
@@ -455,13 +541,13 @@ am_Error_e DatabaseHandler::enterGatewayDB(const am_Gateway_s & gatewayData, am_
//now the convertion matrix todo: change the map implementation sometimes to blob in sqlite
mListConnectionFormat.insert(std::make_pair(gatewayID,gatewayData.convertionMatrix));
- command="CREATE TABLE GatewaySourceFormat" + int2string(gatewayID) + std::string("(soundFormat INTEGER)");
+ command="CREATE TABLE GatewaySourceFormat" + i2s(gatewayID) + std::string("(soundFormat INTEGER)");
assert(this->sqQuery(command));
- command="CREATE TABLE GatewaySinkFormat" + int2string(gatewayID) + std::string("(soundFormat INTEGER)");
+ command="CREATE TABLE GatewaySinkFormat" + i2s(gatewayID) + std::string("(soundFormat INTEGER)");
assert(this->sqQuery(command));
//fill ConnectionFormats
- command="INSERT INTO GatewaySourceFormat" + int2string(gatewayID) + std::string("(soundFormat) VALUES (?)");
+ command="INSERT INTO GatewaySourceFormat" + i2s(gatewayID) + std::string("(soundFormat) VALUES (?)");
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
std::vector<am_ConnectionFormat_e>::const_iterator connectionFormatIterator=gatewayData.listSourceFormats.begin();
for(;connectionFormatIterator<gatewayData.listSourceFormats.end();++connectionFormatIterator)
@@ -475,7 +561,7 @@ am_Error_e DatabaseHandler::enterGatewayDB(const am_Gateway_s & gatewayData, am_
sqlite3_reset(query);
}
- command="INSERT INTO GatewaySinkFormat" + int2string(gatewayID) + std::string("(soundFormat) VALUES (?)");
+ command="INSERT INTO GatewaySinkFormat" + i2s(gatewayID) + std::string("(soundFormat) VALUES (?)");
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
connectionFormatIterator=gatewayData.listSinkFormats.begin();
for(;connectionFormatIterator<gatewayData.listSinkFormats.end();++connectionFormatIterator)
@@ -498,6 +584,9 @@ am_Error_e DatabaseHandler::enterGatewayDB(const am_Gateway_s & gatewayData, am_
DLT_STRING("controlDomainID:"),DLT_INT(gatewayData.controlDomainID),
DLT_STRING("assigned ID:"),DLT_INT16(gatewayID));
+ am_Gateway_s gateway=gatewayData;
+ gateway.gatewayID=gatewayID;
+ if(mObserver) mObserver->newGateway(gateway);
return E_OK;
}
@@ -512,70 +601,114 @@ am_Error_e DatabaseHandler::enterSourceDB(const am_Source_s & sourceData, am_sou
assert(!sourceData.listConnectionFormats.empty());
assert(sourceData.sourceState>=SS_ON && sourceData.sourceState<=SS_PAUSED);
- sqlite3_stmt* query=NULL;
+ sqlite3_stmt* query=NULL, *queryFinal=NULL;;
int eCode=0;
- std::string command;
+ std::string command="SELECT sourceID FROM "+ std::string(SOURCE_TABLE) + " WHERE name=? AND reserved=1";
- //if sinkID is zero and the first Static Sink was already entered, the ID is created
- if (sourceData.sourceID==0 && !mFirstStaticSource)
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_bind_text(query,1, sourceData.name.c_str(),sourceData.name.size(),SQLITE_STATIC);
+
+ if ((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ command= "UPDATE " + std::string(SOURCE_TABLE) + " SET name=?, domainID=?, sourceClassID=?, sourceState=?, volume=?, visible=?, availability=?, availabilityReason=?, interruptState=?, reserved=? WHERE sourceID=" +i2s(sqlite3_column_int(query,0));
+ }
+ else if (eCode==SQLITE_DONE)
{
- command= "INSERT INTO " + std::string(SOURCE_TABLE) + "(name, domainID, sourceClassID, sourceState, volume, visible, availability, availabilityReason, interruptState) VALUES (?,?,?,?,?,?,?,?,?)";
+ //if sinkID is zero and the first Static Sink was already entered, the ID is created
+ if (sourceData.sourceID==0 && !mFirstStaticSource && !existSourceName(sourceData.name))
+ {
+ command= "INSERT INTO " + std::string(SOURCE_TABLE) + "(name, domainID, sourceClassID, sourceState, volume, visible, availability, availabilityReason, interruptState, reserved) VALUES (?,?,?,?,?,?,?,?,?,?)";
+ }
+ else
+ {
+ //check if the ID already exists
+ if (existSourceNameOrID(sourceData.sourceID,sourceData.name))
+ {
+ sqlite3_finalize(query);
+ return E_ALREADY_EXISTS;
+ }
+ command= "INSERT INTO " + std::string(SOURCE_TABLE) + "(name, domainID, sourceClassID, sourceState, volume, visible, availability, availabilityReason, interruptState, reserved, sourceID) VALUES (?,?,?,?,?,?,?,?,?,?,?)";
+ }
}
else
{
- //check if the ID already exists
- if (existSource(sourceData.sourceID)) return E_ALREADY_EXISTS;
- else command= "INSERT INTO " + std::string(SOURCE_TABLE) + "(name, domainID, sourceClassID, sourceState, volume, visible, availability, availabilityReason, interruptState, sourceID) VALUES (?,?,?,?,?,?,?,?,?,?)";
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSourceDB SQLITE Step error code:"),DLT_INT(eCode));
+ sqlite3_finalize(query);
+ return E_DATABASE_ERROR;
}
- sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
- sqlite3_bind_text(query,1, sourceData.name.c_str(),sourceData.name.size(),SQLITE_STATIC);
- sqlite3_bind_int(query,2, sourceData.domainID);
- sqlite3_bind_int(query,3, sourceData.sourceClassID);
- sqlite3_bind_int(query,4, sourceData.sourceState);
- sqlite3_bind_int(query,5, sourceData.volume);
- sqlite3_bind_int(query,6, sourceData.visible);
- sqlite3_bind_int(query,7, sourceData.available.availability);
- sqlite3_bind_int(query,8, sourceData.available.availabilityReason);
- sqlite3_bind_int(query,9, sourceData.interruptState);
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSourceDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&queryFinal,NULL);
+ sqlite3_bind_text(queryFinal,1, sourceData.name.c_str(),sourceData.name.size(),SQLITE_STATIC);
+ sqlite3_bind_int(queryFinal,2, sourceData.domainID);
+ sqlite3_bind_int(queryFinal,3, sourceData.sourceClassID);
+ sqlite3_bind_int(queryFinal,4, sourceData.sourceState);
+ sqlite3_bind_int(queryFinal,5, sourceData.volume);
+ sqlite3_bind_int(queryFinal,6, sourceData.visible);
+ sqlite3_bind_int(queryFinal,7, sourceData.available.availability);
+ sqlite3_bind_int(queryFinal,8, sourceData.available.availabilityReason);
+ sqlite3_bind_int(queryFinal,9, sourceData.interruptState);
+ sqlite3_bind_int(queryFinal,10, 0);
//if the ID is not created, we add it to the query
if(sourceData.sourceID!=0)
{
- sqlite3_bind_int(query,10, sourceData.sourceID);
+ sqlite3_bind_int(queryFinal,11, sourceData.sourceID);
}
//if the first static sink is entered, we need to set it onto the boundary
else if(mFirstStaticSource)
{
- sqlite3_bind_int(query,10, DYNAMIC_ID_BOUNDARY);
+ sqlite3_bind_int(queryFinal,11, DYNAMIC_ID_BOUNDARY);
mFirstStaticSource=false;
}
- if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ if((eCode=sqlite3_step(queryFinal))!=SQLITE_DONE)
{
DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSourceDB SQLITE Step error code:"),DLT_INT(eCode));
+ sqlite3_finalize(queryFinal);
return E_DATABASE_ERROR;
}
- if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ if((eCode=sqlite3_finalize(queryFinal))!=SQLITE_OK)
{
DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSourceDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ sqlite3_finalize(queryFinal);
+ return E_DATABASE_ERROR;
+ }
+
+ //now read back the sinkID
+ command = "SELECT sourceID FROM " + std::string(SOURCE_TABLE) + " WHERE name=?";
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_bind_text(query,1,sourceData.name.c_str(),sourceData.name.size(),SQLITE_STATIC);
+ if ((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ sourceID=sqlite3_column_int(query,0);
+ }
+ else
+ {
+ sourceID=0;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existSink database error!:"), DLT_INT(eCode))
+ sqlite3_finalize(query);
return E_DATABASE_ERROR;
}
+ sqlite3_finalize(query);
- sourceID=sqlite3_last_insert_rowid(mDatabase);
//now we need to create the additional tables:
- command="CREATE TABLE SourceConnectionFormat" + int2string(sourceID) + std::string("(soundFormat INTEGER)");
+ command="CREATE TABLE SourceConnectionFormat" + i2s(sourceID) + std::string("(soundFormat INTEGER)");
assert(this->sqQuery(command));
- command="CREATE TABLE SourceMainSoundProperty" + int2string(sourceID) + std::string("(soundPropertyType INTEGER, value INTEGER)");
+ command="CREATE TABLE SourceMainSoundProperty" + i2s(sourceID) + std::string("(soundPropertyType INTEGER, value INTEGER)");
assert(this->sqQuery(command));
- command="CREATE TABLE SourceSoundProperty" + int2string(sourceID) + std::string("(soundPropertyType INTEGER, value INTEGER)");
+ command="CREATE TABLE SourceSoundProperty" + i2s(sourceID) + std::string("(soundPropertyType INTEGER, value INTEGER)");
assert(this->sqQuery(command));
//fill ConnectionFormats
- command="INSERT INTO SourceConnectionFormat" + int2string(sourceID) + std::string("(soundFormat) VALUES (?)");
+ command="INSERT INTO SourceConnectionFormat" + i2s(sourceID) + std::string("(soundFormat) VALUES (?)");
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
std::vector<am_ConnectionFormat_e>::const_iterator connectionFormatIterator=sourceData.listConnectionFormats.begin();
for(;connectionFormatIterator<sourceData.listConnectionFormats.end();++connectionFormatIterator)
@@ -584,13 +717,14 @@ am_Error_e DatabaseHandler::enterSourceDB(const am_Source_s & sourceData, am_sou
if((eCode=sqlite3_step(query))!=SQLITE_DONE)
{
DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSourceDB SQLITE Step error code:"),DLT_INT(eCode));
+ sqlite3_finalize(query);
return E_DATABASE_ERROR;
}
sqlite3_reset(query);
}
//Fill MainSinkSoundProperties
- command="INSERT INTO SourceMainSoundProperty" + int2string(sourceID) + std::string("(soundPropertyType,value) VALUES (?,?)");
+ command="INSERT INTO SourceMainSoundProperty" + i2s(sourceID) + std::string("(soundPropertyType,value) VALUES (?,?)");
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
std::vector<am_MainSoundProperty_s>::const_iterator mainSoundPropertyIterator=sourceData.listMainSoundProperties.begin();
for(;mainSoundPropertyIterator<sourceData.listMainSoundProperties.end();++mainSoundPropertyIterator)
@@ -600,13 +734,14 @@ am_Error_e DatabaseHandler::enterSourceDB(const am_Source_s & sourceData, am_sou
if((eCode=sqlite3_step(query))!=SQLITE_DONE)
{
DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSourceDB SQLITE Step error code:"),DLT_INT(eCode));
+ sqlite3_finalize(query);
return E_DATABASE_ERROR;
}
sqlite3_reset(query);
}
//Fill SinkSoundProperties
- command="INSERT INTO SourceSoundProperty" + int2string(sourceID) + std::string("(soundPropertyType,value) VALUES (?,?)");
+ command="INSERT INTO SourceSoundProperty" + i2s(sourceID) + std::string("(soundPropertyType,value) VALUES (?,?)");
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
std::vector<am_SoundProperty_s>::const_iterator SoundPropertyIterator=sourceData.listSoundProperties.begin();
for(;SoundPropertyIterator<sourceData.listSoundProperties.end();++SoundPropertyIterator)
@@ -616,6 +751,7 @@ am_Error_e DatabaseHandler::enterSourceDB(const am_Source_s & sourceData, am_sou
if((eCode=sqlite3_step(query))!=SQLITE_DONE)
{
DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkDB SQLITE Step error code:"),DLT_INT(eCode));
+ sqlite3_finalize(query);
return E_DATABASE_ERROR;
}
sqlite3_reset(query);
@@ -631,6 +767,9 @@ am_Error_e DatabaseHandler::enterSourceDB(const am_Source_s & sourceData, am_sou
DLT_STRING("interruptState:"),DLT_INT(sourceData.interruptState),
DLT_STRING("assigned ID:"),DLT_INT16(sourceID));
+ am_Source_s source=sourceData;
+ source.sourceID=sourceID;
+ if(mObserver) mObserver->newSource(source);
return E_OK;
}
@@ -680,10 +819,10 @@ am_Error_e DatabaseHandler::changeMainConnectionRouteDB(const am_mainConnectionI
}
//now we delete the data in the table
- command="DELETE from MainConnectionRoute" + int2string(mainconnectionID);
+ command="DELETE from MainConnectionRoute" + i2s(mainconnectionID);
assert(this->sqQuery(command));
- command= "INSERT INTO MainConnectionRoute" + int2string(mainconnectionID) + "(connectionID) VALUES (?)";
+ command= "INSERT INTO MainConnectionRoute" + i2s(mainconnectionID) + "(connectionID) VALUES (?)";
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
std::vector<uint16_t>::iterator listConnectionIterator=listOfConnections.begin();
for(;listConnectionIterator<listOfConnections.end();++listConnectionIterator)
@@ -718,7 +857,7 @@ am_Error_e DatabaseHandler::changeMainConnectionStateDB(const am_mainConnectionI
{
return E_NON_EXISTENT;
}
- command = "UPDATE " + std::string(MAINCONNECTION_TABLE) + " SET connectionState=? WHERE mainConnectionID=" + int2string(mainconnectionID);
+ command = "UPDATE " + std::string(MAINCONNECTION_TABLE) + " SET connectionState=? WHERE mainConnectionID=" + i2s(mainconnectionID);
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
sqlite3_bind_int(query,1, connectionState);
if((eCode=sqlite3_step(query))!=SQLITE_DONE)
@@ -732,6 +871,8 @@ am_Error_e DatabaseHandler::changeMainConnectionStateDB(const am_mainConnectionI
return E_DATABASE_ERROR;
}
DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeMainConnectionStateDB changed mainConnectionState of MainConnection:"),DLT_INT(mainconnectionID),DLT_STRING("to:"),DLT_INT(connectionState));
+
+ if (mObserver) mObserver->mainConnectionStateChanged(mainconnectionID,connectionState);
return E_OK;
}
@@ -749,7 +890,7 @@ am_Error_e DatabaseHandler::changeSinkMainVolumeDB(const am_mainVolume_t mainVol
{
return E_NON_EXISTENT;
}
- command = "UPDATE " + std::string(SINK_TABLE) + " SET mainVolume=? WHERE sinkID=" + int2string(sinkID);
+ command = "UPDATE " + std::string(SINK_TABLE) + " SET mainVolume=? WHERE sinkID=" + i2s(sinkID);
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
sqlite3_bind_int(query,1, mainVolume);
if((eCode=sqlite3_step(query))!=SQLITE_DONE)
@@ -764,6 +905,9 @@ am_Error_e DatabaseHandler::changeSinkMainVolumeDB(const am_mainVolume_t mainVol
}
DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeSinkMainVolumeDB changed mainVolume of sink:"),DLT_INT(sinkID),DLT_STRING("to:"),DLT_INT(mainVolume));
+
+ if(mObserver) mObserver->volumeChanged(sinkID,mainVolume);
+
return E_OK;
}
@@ -781,7 +925,7 @@ am_Error_e DatabaseHandler::changeSinkAvailabilityDB(const am_Availability_s & a
{
return E_NON_EXISTENT;
}
- command = "UPDATE " + std::string(SINK_TABLE) + " SET availability=?, availabilityReason=? WHERE sinkID=" + int2string(sinkID);
+ command = "UPDATE " + std::string(SINK_TABLE) + " SET availability=?, availabilityReason=? WHERE sinkID=" + i2s(sinkID);
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
sqlite3_bind_int(query,1, availability.availability);
sqlite3_bind_int(query,2, availability.availabilityReason);
@@ -798,6 +942,8 @@ am_Error_e DatabaseHandler::changeSinkAvailabilityDB(const am_Availability_s & a
}
DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeSinkAvailabilityDB changed sinkAvailability of sink:"),DLT_INT(sinkID),DLT_STRING("to:"),DLT_INT(availability.availability), DLT_STRING("Reason:"),DLT_INT(availability.availabilityReason));
+
+ if (mObserver && sourceVisible(sinkID)) mObserver->sinkAvailabilityChanged(sinkID,availability);
return E_OK;
}
@@ -815,7 +961,7 @@ am_Error_e DatabaseHandler::changDomainStateDB(const am_DomainState_e domainStat
{
return E_NON_EXISTENT;
}
- command = "UPDATE " + std::string(DOMAIN_TABLE) + " SET state=? WHERE domainID=" + int2string(domainID);
+ command = "UPDATE " + std::string(DOMAIN_TABLE) + " SET state=? WHERE domainID=" + i2s(domainID);
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
sqlite3_bind_int(query,1, domainState);
if((eCode=sqlite3_step(query))!=SQLITE_DONE)
@@ -848,7 +994,7 @@ am_Error_e DatabaseHandler::changeSinkMuteStateDB(const am_MuteState_e muteState
{
return E_NON_EXISTENT;
}
- command = "UPDATE " + std::string(SINK_TABLE) + " SET muteState=? WHERE sinkID=" + int2string(sinkID);
+ command = "UPDATE " + std::string(SINK_TABLE) + " SET muteState=? WHERE sinkID=" + i2s(sinkID);
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
sqlite3_bind_int(query,1, muteState);
if((eCode=sqlite3_step(query))!=SQLITE_DONE)
@@ -864,6 +1010,9 @@ am_Error_e DatabaseHandler::changeSinkMuteStateDB(const am_MuteState_e muteState
}
DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeSinkMuteStateDB changed sinkMuteState of sink:"),DLT_INT(sinkID),DLT_STRING("to:"),DLT_INT(muteState));
+
+ if(mObserver) mObserver->sinkMuteStateChanged(sinkID,muteState);
+
return E_OK;
}
@@ -882,7 +1031,7 @@ am_Error_e DatabaseHandler::changeMainSinkSoundPropertyDB(const am_MainSoundProp
{
return E_NON_EXISTENT;
}
- command = "UPDATE SinkMainSoundProperty" + int2string(sinkID)+ " SET value=? WHERE soundPropertyType=" + int2string(soundProperty.type);
+ command = "UPDATE SinkMainSoundProperty" + i2s(sinkID)+ " SET value=? WHERE soundPropertyType=" + i2s(soundProperty.type);
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
sqlite3_bind_int(query,1, soundProperty.value);
if((eCode=sqlite3_step(query))!=SQLITE_DONE)
@@ -898,6 +1047,7 @@ am_Error_e DatabaseHandler::changeMainSinkSoundPropertyDB(const am_MainSoundProp
}
DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeMainSinkSoundPropertyDB changed MainSinkSoundProperty of sink:"),DLT_INT(sinkID),DLT_STRING("type:"),DLT_INT(soundProperty.type),DLT_STRING("to:"),DLT_INT(soundProperty.value));
+ if (mObserver) mObserver->mainSinkSoundPropertyChanged(sinkID,soundProperty);
return E_OK;
}
@@ -916,7 +1066,7 @@ am_Error_e DatabaseHandler::changeMainSourceSoundPropertyDB(const am_MainSoundPr
{
return E_NON_EXISTENT;
}
- command = "UPDATE SourceMainSoundProperty" + int2string(sourceID)+ " SET value=? WHERE soundPropertyType=" + int2string(soundProperty.type);
+ command = "UPDATE SourceMainSoundProperty" + i2s(sourceID)+ " SET value=? WHERE soundPropertyType=" + i2s(soundProperty.type);
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
sqlite3_bind_int(query,1, soundProperty.value);
if((eCode=sqlite3_step(query))!=SQLITE_DONE)
@@ -932,6 +1082,8 @@ am_Error_e DatabaseHandler::changeMainSourceSoundPropertyDB(const am_MainSoundPr
}
DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeMainSourceSoundPropertyDB changed MainSinkSoundProperty of source:"),DLT_INT(sourceID),DLT_STRING("type:"),DLT_INT(soundProperty.type),DLT_STRING("to:"),DLT_INT(soundProperty.value));
+
+ if(mObserver) mObserver->mainSourceSoundPropertyChanged(sourceID,soundProperty);
return E_OK;
}
@@ -949,7 +1101,7 @@ am_Error_e DatabaseHandler::changeSourceAvailabilityDB(const am_Availability_s &
{
return E_NON_EXISTENT;
}
- command = "UPDATE " + std::string(SOURCE_TABLE) + " SET availability=?, availabilityReason=? WHERE sourceID=" + int2string(sourceID);
+ command = "UPDATE " + std::string(SOURCE_TABLE) + " SET availability=?, availabilityReason=? WHERE sourceID=" + i2s(sourceID);
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
sqlite3_bind_int(query,1, availability.availability);
sqlite3_bind_int(query,2, availability.availabilityReason);
@@ -966,6 +1118,8 @@ am_Error_e DatabaseHandler::changeSourceAvailabilityDB(const am_Availability_s &
}
DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeSourceAvailabilityDB changed changeSourceAvailabilityDB of source:"),DLT_INT(sourceID),DLT_STRING("to:"),DLT_INT(availability.availability), DLT_STRING("Reason:"),DLT_INT(availability.availabilityReason));
+
+ if (mObserver && sourceVisible(sourceID)) mObserver->sourceAvailabilityChanged(sourceID,availability);
return E_OK;
}
@@ -995,6 +1149,9 @@ am_Error_e DatabaseHandler::changeSystemPropertyDB(const am_SystemProperty_s & p
}
DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeSystemPropertyDB changed system property"));
+
+ if(mObserver) mObserver->systemPropertyChanged(property);
+
return E_OK;
}
@@ -1008,11 +1165,12 @@ am_Error_e DatabaseHandler::removeMainConnectionDB(const am_mainConnectionID_t m
{
return E_NON_EXISTENT;
}
- std::string command = "DELETE from " + std::string(MAINCONNECTION_TABLE) + " WHERE mainConnectionID=" + int2string(mainConnectionID);
- std::string command1 = "DROP table MainConnectionRoute" + int2string(mainConnectionID);
+ std::string command = "DELETE from " + std::string(MAINCONNECTION_TABLE) + " WHERE mainConnectionID=" + i2s(mainConnectionID);
+ std::string command1 = "DROP table MainConnectionRoute" + i2s(mainConnectionID);
if(!sqQuery(command)) return E_DATABASE_ERROR;
if(!sqQuery(command1)) return E_DATABASE_ERROR;
DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::removeMainConnectionDB removed:"),DLT_INT(mainConnectionID));
+ if (mObserver) mObserver->numberOfMainConnectionsChanged();
return E_OK;
}
@@ -1026,15 +1184,18 @@ am_Error_e DatabaseHandler::removeSinkDB(const am_sinkID_t sinkID)
{
return E_NON_EXISTENT;
}
- std::string command = "DELETE from " + std::string(SINK_TABLE) + " WHERE sinkID=" + int2string(sinkID);
- std::string command1 = "DROP table SinkConnectionFormat" + int2string(sinkID);
- std::string command2 = "DROP table SinkMainSoundProperty" + int2string(sinkID);
- std::string command3 = "DROP table SinkSoundProperty" + int2string(sinkID);
+ std::string command = "DELETE from " + std::string(SINK_TABLE) + " WHERE sinkID=" + i2s(sinkID);
+ std::string command1 = "DROP table SinkConnectionFormat" + i2s(sinkID);
+ std::string command2 = "DROP table SinkMainSoundProperty" + i2s(sinkID);
+ std::string command3 = "DROP table SinkSoundProperty" + i2s(sinkID);
if(!sqQuery(command)) return E_DATABASE_ERROR;
if(!sqQuery(command1)) return E_DATABASE_ERROR;
if(!sqQuery(command2)) return E_DATABASE_ERROR;
if(!sqQuery(command3)) return E_DATABASE_ERROR;
DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::removeSinkDB removed:"),DLT_INT(sinkID));
+
+ if (mObserver!=NULL) mObserver->removedSink(sinkID);
+
return E_OK;
}
@@ -1048,15 +1209,16 @@ am_Error_e DatabaseHandler::removeSourceDB(const am_sourceID_t sourceID)
{
return E_NON_EXISTENT;
}
- std::string command = "DELETE from " + std::string(SOURCE_TABLE) + " WHERE sourceID=" + int2string(sourceID);
- std::string command1 = "DROP table SourceConnectionFormat" + int2string(sourceID);
- std::string command2 = "DROP table SourceMainSoundProperty" + int2string(sourceID);
- std::string command3 = "DROP table SourceSoundProperty" + int2string(sourceID);
+ std::string command = "DELETE from " + std::string(SOURCE_TABLE) + " WHERE sourceID=" + i2s(sourceID);
+ std::string command1 = "DROP table SourceConnectionFormat" + i2s(sourceID);
+ std::string command2 = "DROP table SourceMainSoundProperty" + i2s(sourceID);
+ std::string command3 = "DROP table SourceSoundProperty" + i2s(sourceID);
if(!sqQuery(command)) return E_DATABASE_ERROR;
if(!sqQuery(command1)) return E_DATABASE_ERROR;
if(!sqQuery(command2)) return E_DATABASE_ERROR;
if(!sqQuery(command3)) return E_DATABASE_ERROR;
DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::removeSourceDB removed:"),DLT_INT(sourceID));
+ if(mObserver) mObserver->removedSource(sourceID);
return E_OK;
}
@@ -1070,9 +1232,10 @@ am_Error_e DatabaseHandler::removeGatewayDB(const am_gatewayID_t gatewayID)
{
return E_NON_EXISTENT;
}
- std::string command = "DELETE from " + std::string(GATEWAY_TABLE) + " WHERE gatewayID=" + int2string(gatewayID);
+ std::string command = "DELETE from " + std::string(GATEWAY_TABLE) + " WHERE gatewayID=" + i2s(gatewayID);
if(!sqQuery(command)) return E_DATABASE_ERROR;
DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::removeGatewayDB removed:"),DLT_INT(gatewayID));
+ if(mObserver) mObserver->removeGateway(gatewayID);
return E_OK;
}
@@ -1095,10 +1258,10 @@ am_Error_e DatabaseHandler::removeDomainDB(const am_domainID_t domainID)
{
return E_NON_EXISTENT;
}
- std::string command = "DELETE from " + std::string(DOMAIN_TABLE) + " WHERE domainID=" + int2string(domainID);
+ std::string command = "DELETE from " + std::string(DOMAIN_TABLE) + " WHERE domainID=" + i2s(domainID);
if(!sqQuery(command)) return E_DATABASE_ERROR;
DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::removeDomainDB removed:"),DLT_INT(domainID));
-
+ if(mObserver) mObserver->removeDomain(domainID);
return E_OK;
}
@@ -1110,11 +1273,14 @@ am_Error_e DatabaseHandler::removeSinkClassDB(const am_sinkClass_t sinkClassID)
{
return E_NON_EXISTENT;
}
- std::string command = "DELETE from " + std::string(SINK_CLASS_TABLE) + " WHERE sinkClassID=" + int2string(sinkClassID);
- std::string command1 = "DROP table SinkClassProperties" + int2string(sinkClassID);
+ std::string command = "DELETE from " + std::string(SINK_CLASS_TABLE) + " WHERE sinkClassID=" + i2s(sinkClassID);
+ std::string command1 = "DROP table SinkClassProperties" + i2s(sinkClassID);
if(!sqQuery(command)) return E_DATABASE_ERROR;
if(!sqQuery(command1)) return E_DATABASE_ERROR;
+
DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::removeSinkClassDB removed:"),DLT_INT(sinkClassID));
+ if (mObserver) mObserver->numberOfSinkClassesChanged();
+
return E_OK;
}
@@ -1126,11 +1292,26 @@ am_Error_e DatabaseHandler::removeSourceClassDB(const am_sourceClass_t sourceCla
{
return E_NON_EXISTENT;
}
- std::string command = "DELETE from " + std::string(SOURCE_CLASS_TABLE) + " WHERE sourceClassID=" + int2string(sourceClassID);
- std::string command1 = "DROP table SourceClassProperties" + int2string(sourceClassID);
+ std::string command = "DELETE from " + std::string(SOURCE_CLASS_TABLE) + " WHERE sourceClassID=" + i2s(sourceClassID);
+ std::string command1 = "DROP table SourceClassProperties" + i2s(sourceClassID);
if(!sqQuery(command)) return E_DATABASE_ERROR;
if(!sqQuery(command1)) return E_DATABASE_ERROR;
DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::removeSourceClassDB removed:"),DLT_INT(sourceClassID));
+
+ if (mObserver) mObserver->numberOfSourceClassesChanged();
+ return E_OK;
+}
+
+am_Error_e DatabaseHandler::removeConnection(const am_connectionID_t connectionID)
+{
+ assert(connectionID!=0);
+
+ std::string command = "DELETE from " + std::string(CONNECTION_TABLE) + " WHERE connectionID=" + i2s(connectionID);
+ std::string command1 = "DROP table SourceClassProperties" + i2s(connectionID);
+ if(!sqQuery(command)) return E_DATABASE_ERROR;
+ if(!sqQuery(command1)) return E_DATABASE_ERROR;
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::removeConnection removed:"),DLT_INT(connectionID));
+
return E_OK;
}
@@ -1146,7 +1327,7 @@ am_Error_e DatabaseHandler::getSourceClassInfoDB(const am_sourceID_t sourceID, a
sqlite3_stmt* query=NULL;
int eCode=0;
am_ClassProperty_s propertyTemp;
- std::string command= "SELECT sourceClassID FROM " + std::string(SOURCE_TABLE)+ " WHERE sourceID=" + (int2string(sourceID));
+ std::string command= "SELECT sourceClassID FROM " + std::string(SOURCE_TABLE)+ " WHERE sourceID=" + (i2s(sourceID));
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
if((eCode=sqlite3_step(query))==SQLITE_ROW)
@@ -1166,7 +1347,7 @@ am_Error_e DatabaseHandler::getSourceClassInfoDB(const am_sourceID_t sourceID, a
return E_DATABASE_ERROR;
}
- command= "SELECT name FROM " + std::string(SOURCE_CLASS_TABLE)+ " WHERE sourceClassID=" + (int2string(classInfo.sourceClassID));
+ command= "SELECT name FROM " + std::string(SOURCE_CLASS_TABLE)+ " WHERE sourceClassID=" + (i2s(classInfo.sourceClassID));
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
if((eCode=sqlite3_step(query))==SQLITE_ROW)
@@ -1187,7 +1368,7 @@ am_Error_e DatabaseHandler::getSourceClassInfoDB(const am_sourceID_t sourceID, a
}
//read out Properties
- command= "SELECT classProperty, value FROM SourceClassProperties"+ int2string(classInfo.sourceClassID);
+ command= "SELECT classProperty, value FROM SourceClassProperties"+ i2s(classInfo.sourceClassID);
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
while((eCode=sqlite3_step(query))==SQLITE_ROW)
{
@@ -1225,7 +1406,7 @@ am_Error_e DatabaseHandler::changeSinkClassInfoDB(const am_SinkClass_s& sinkClas
if(!existSinkClass(sinkClass.sinkClassID)) return E_NON_EXISTENT;
//fill ConnectionFormats
- std::string command="UPDATE SinkClassProperties" + int2string(sinkClass.sinkClassID) + " set value=? WHERE classProperty=?;";
+ std::string command="UPDATE SinkClassProperties" + i2s(sinkClass.sinkClassID) + " set value=? WHERE classProperty=?;";
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
std::vector<am_ClassProperty_s>::const_iterator Iterator=sinkClass.listClassProperties.begin();
for(;Iterator<sinkClass.listClassProperties.end();++Iterator)
@@ -1265,7 +1446,7 @@ am_Error_e DatabaseHandler::changeSourceClassInfoDB(const am_SourceClass_s& sour
if(!existSourceClass(sourceClass.sourceClassID)) return E_NON_EXISTENT;
//fill ConnectionFormats
- std::string command="UPDATE SourceClassProperties" + int2string(sourceClass.sourceClassID) + " set value=? WHERE classProperty=?;";
+ std::string command="UPDATE SourceClassProperties" + i2s(sourceClass.sourceClassID) + " set value=? WHERE classProperty=?;";
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
std::vector<am_ClassProperty_s>::const_iterator Iterator=sourceClass.listClassProperties.begin();
for(;Iterator<sourceClass.listClassProperties.end();++Iterator)
@@ -1303,7 +1484,7 @@ am_Error_e DatabaseHandler::getSinkClassInfoDB(const am_sinkID_t sinkID, am_Sink
sqlite3_stmt* query=NULL;
int eCode=0;
am_ClassProperty_s propertyTemp;
- std::string command= "SELECT sinkClassID FROM " + std::string(SINK_TABLE)+ " WHERE sinkID=" + (int2string(sinkID));
+ std::string command= "SELECT sinkClassID FROM " + std::string(SINK_TABLE)+ " WHERE sinkID=" + (i2s(sinkID));
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
if((eCode=sqlite3_step(query))==SQLITE_ROW)
@@ -1323,7 +1504,7 @@ am_Error_e DatabaseHandler::getSinkClassInfoDB(const am_sinkID_t sinkID, am_Sink
return E_DATABASE_ERROR;
}
- command= "SELECT name FROM " + std::string(SINK_CLASS_TABLE)+ " WHERE sinkClassID=" + (int2string(sinkClass.sinkClassID));
+ command= "SELECT name FROM " + std::string(SINK_CLASS_TABLE)+ " WHERE sinkClassID=" + (i2s(sinkClass.sinkClassID));
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
if((eCode=sqlite3_step(query))==SQLITE_ROW)
@@ -1344,7 +1525,7 @@ am_Error_e DatabaseHandler::getSinkClassInfoDB(const am_sinkID_t sinkID, am_Sink
}
//read out Properties
- command= "SELECT classProperty, value FROM SinkClassProperties"+ int2string(sinkClass.sinkClassID);
+ command= "SELECT classProperty, value FROM SinkClassProperties"+ i2s(sinkClass.sinkClassID);
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
while((eCode=sqlite3_step(query))==SQLITE_ROW)
{
@@ -1379,7 +1560,7 @@ am_Error_e DatabaseHandler::getGatewayInfoDB(const am_gatewayID_t gatewayID, am_
sqlite3_stmt* query=NULL, *qSinkConnectionFormat=NULL, *qSourceConnectionFormat=NULL;
int eCode=0;
am_ConnectionFormat_e tempConnectionFormat;
- std::string command= "SELECT name, sinkID, sourceID, domainSinkID, domainSourceID, controlDomainID, gatewayID FROM " + std::string(GATEWAY_TABLE) + " WHERE gatewayID="+int2string(gatewayID);
+ std::string command= "SELECT name, sinkID, sourceID, domainSinkID, domainSourceID, controlDomainID, gatewayID FROM " + std::string(GATEWAY_TABLE) + " WHERE gatewayID="+i2s(gatewayID);
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
while((eCode=sqlite3_step(query))==SQLITE_ROW)
@@ -1403,7 +1584,7 @@ am_Error_e DatabaseHandler::getGatewayInfoDB(const am_gatewayID_t gatewayID, am_
gatewayData.convertionMatrix=iter->second;
//read out the connectionFormats
- std::string commandConnectionFormat= "SELECT soundFormat FROM GatewaySourceFormat" + int2string(gatewayData.gatewayID);
+ std::string commandConnectionFormat= "SELECT soundFormat FROM GatewaySourceFormat" + i2s(gatewayData.gatewayID);
sqlite3_prepare_v2(mDatabase,commandConnectionFormat.c_str(),-1,&qSourceConnectionFormat,NULL);
while((eCode=sqlite3_step(qSourceConnectionFormat))==SQLITE_ROW)
{
@@ -1418,7 +1599,7 @@ am_Error_e DatabaseHandler::getGatewayInfoDB(const am_gatewayID_t gatewayID, am_
}
//read out sound properties
- commandConnectionFormat= "SELECT soundFormat FROM GatewaySinkFormat" + int2string(gatewayData.gatewayID);
+ commandConnectionFormat= "SELECT soundFormat FROM GatewaySinkFormat" + i2s(gatewayData.gatewayID);
sqlite3_prepare_v2(mDatabase,commandConnectionFormat.c_str(),-1,&qSinkConnectionFormat,NULL);
while((eCode=sqlite3_step(qSinkConnectionFormat))==SQLITE_ROW)
{
@@ -1473,7 +1654,7 @@ am_Error_e DatabaseHandler::getListSinksOfDomain(const am_domainID_t domainID, s
sqlite3_stmt* query=NULL;
int eCode=0;
am_sinkID_t temp;
- std::string command= "SELECT sinkID FROM " + std::string(SINK_TABLE)+ " WHERE domainID=" + (int2string(domainID));
+ std::string command= "SELECT sinkID FROM " + std::string(SINK_TABLE)+ " WHERE reserved=0 AND domainID=" + (i2s(domainID));
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
while((eCode=sqlite3_step(query))==SQLITE_ROW)
@@ -1510,7 +1691,7 @@ am_Error_e DatabaseHandler::getListSourcesOfDomain(const am_domainID_t domainID,
sqlite3_stmt* query=NULL;
int eCode=0;
am_sourceID_t temp;
- std::string command= "SELECT sourceID FROM " + std::string(SOURCE_TABLE) + " WHERE domainID=" + int2string(domainID);
+ std::string command= "SELECT sourceID FROM " + std::string(SOURCE_TABLE) + " WHERE reserved=0 AND domainID=" + i2s(domainID);
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
@@ -1560,7 +1741,7 @@ am_Error_e DatabaseHandler::getListGatewaysOfDomain(const am_domainID_t domainID
int eCode=0;
am_gatewayID_t temp;
- std::string command= "SELECT gatewayID FROM " + std::string(GATEWAY_TABLE) + " WHERE controlDomainID=" +int2string(domainID);
+ std::string command= "SELECT gatewayID FROM " + std::string(GATEWAY_TABLE) + " WHERE controlDomainID=" +i2s(domainID);
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
while((eCode=sqlite3_step(query))==SQLITE_ROW)
@@ -1607,7 +1788,7 @@ am_Error_e DatabaseHandler::getListMainConnections(std::vector<am_MainConnection
temp.route.sinkID=sqlite3_column_int(query,2);
temp.connectionState=(am_ConnectionState_e)sqlite3_column_int(query,3);
temp.delay=sqlite3_column_int(query,4);
- std::string statement=command1 + int2string(temp.connectionID);
+ std::string statement=command1 + i2s(temp.connectionID);
sqlite3_prepare_v2(mDatabase,statement.c_str(),-1,&query1,NULL);
while((eCode1=sqlite3_step(query1))==SQLITE_ROW) //todo: check results of eCode1, eCode2
{
@@ -1649,7 +1830,7 @@ am_Error_e DatabaseHandler::getListDomains(std::vector<am_Domain_s> & listDomain
sqlite3_stmt* query=NULL;
int eCode=0;
am_Domain_s temp;
- std::string command= "SELECT domainID, name, busname, nodename, early, complete, state FROM " + std::string(DOMAIN_TABLE);
+ std::string command= "SELECT domainID, name, busname, nodename, early, complete, state FROM " + std::string(DOMAIN_TABLE) + " WHERE reserved=0";
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
while((eCode=sqlite3_step(query))==SQLITE_ROW)
@@ -1687,7 +1868,7 @@ am_Error_e DatabaseHandler::getListConnections(std::vector<am_Connection_s> & li
sqlite3_stmt* query=NULL;
int eCode=0;
am_Connection_s temp;
- std::string command= "SELECT connectionID, sourceID, sinkID, delay, connectionFormat FROM " + std::string(CONNECTION_TABLE);
+ std::string command= "SELECT connectionID, sourceID, sinkID, delay, connectionFormat FROM " + std::string(CONNECTION_TABLE)+" WHERE reserved=0";
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
while((eCode=sqlite3_step(query))==SQLITE_ROW)
@@ -1726,7 +1907,7 @@ am_Error_e DatabaseHandler::getListSinks(std::vector<am_Sink_s> & listSinks) con
am_ConnectionFormat_e tempConnectionFormat;
am_SoundProperty_s tempSoundProperty;
am_MainSoundProperty_s tempMainSoundProperty;
- std::string command= "SELECT name, domainID, sinkClassID, volume, visible, availability, availabilityReason, muteState, mainVolume, sinkID FROM " + std::string(SINK_TABLE);
+ std::string command= "SELECT name, domainID, sinkClassID, volume, visible, availability, availabilityReason, muteState, mainVolume, sinkID FROM " + std::string(SINK_TABLE)+ " WHERE reserved=0";
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
while((eCode=sqlite3_step(query))==SQLITE_ROW)
@@ -1743,7 +1924,7 @@ am_Error_e DatabaseHandler::getListSinks(std::vector<am_Sink_s> & listSinks) con
temp.sinkID=sqlite3_column_int(query,9);
//read out the connectionFormats
- std::string commandConnectionFormat= "SELECT soundFormat FROM SinkConnectionFormat"+ int2string(temp.sinkID);
+ std::string commandConnectionFormat= "SELECT soundFormat FROM SinkConnectionFormat"+ i2s(temp.sinkID);
sqlite3_prepare_v2(mDatabase,commandConnectionFormat.c_str(),-1,&qConnectionFormat,NULL);
while((eCode=sqlite3_step(qConnectionFormat))==SQLITE_ROW)
{
@@ -1758,7 +1939,7 @@ am_Error_e DatabaseHandler::getListSinks(std::vector<am_Sink_s> & listSinks) con
}
//read out sound properties
- std::string commandSoundProperty= "SELECT soundPropertyType, value FROM SinkSoundProperty" + int2string(temp.sinkID);
+ std::string commandSoundProperty= "SELECT soundPropertyType, value FROM SinkSoundProperty" + i2s(temp.sinkID);
sqlite3_prepare_v2(mDatabase,commandSoundProperty.c_str(),-1,&qSoundProperty,NULL);
while((eCode=sqlite3_step(qSoundProperty))==SQLITE_ROW)
{
@@ -1774,7 +1955,7 @@ am_Error_e DatabaseHandler::getListSinks(std::vector<am_Sink_s> & listSinks) con
}
//read out MainSoundProperties
- std::string commandMainSoundProperty= "SELECT soundPropertyType, value FROM SinkMainSoundProperty"+ int2string(temp.sinkID);
+ std::string commandMainSoundProperty= "SELECT soundPropertyType, value FROM SinkMainSoundProperty"+ i2s(temp.sinkID);
sqlite3_prepare_v2(mDatabase,commandMainSoundProperty.c_str(),-1,&qMAinSoundProperty,NULL);
while((eCode=sqlite3_step(qMAinSoundProperty))==SQLITE_ROW)
{
@@ -1820,7 +2001,7 @@ am_Error_e DatabaseHandler::getListSources(std::vector<am_Source_s> & listSource
am_ConnectionFormat_e tempConnectionFormat;
am_SoundProperty_s tempSoundProperty;
am_MainSoundProperty_s tempMainSoundProperty;
- std::string command= "SELECT name, domainID, sourceClassID, sourceState, volume, visible, availability, availabilityReason, interruptState, sourceID FROM " + std::string(SOURCE_TABLE);
+ std::string command= "SELECT name, domainID, sourceClassID, sourceState, volume, visible, availability, availabilityReason, interruptState, sourceID FROM " + std::string(SOURCE_TABLE) +" WHERE reserved=0";
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
while((eCode=sqlite3_step(query))==SQLITE_ROW)
@@ -1837,7 +2018,7 @@ am_Error_e DatabaseHandler::getListSources(std::vector<am_Source_s> & listSource
temp.sourceID=sqlite3_column_int(query,9);
//read out the connectionFormats
- std::string commandConnectionFormat= "SELECT soundFormat FROM SourceConnectionFormat"+ int2string(temp.sourceID);
+ std::string commandConnectionFormat= "SELECT soundFormat FROM SourceConnectionFormat"+ i2s(temp.sourceID);
sqlite3_prepare_v2(mDatabase,commandConnectionFormat.c_str(),-1,&qConnectionFormat,NULL);
while((eCode=sqlite3_step(qConnectionFormat))==SQLITE_ROW)
{
@@ -1852,7 +2033,7 @@ am_Error_e DatabaseHandler::getListSources(std::vector<am_Source_s> & listSource
}
//read out sound properties
- std::string commandSoundProperty= "SELECT soundPropertyType, value FROM SourceSoundProperty" + int2string(temp.sourceID);
+ std::string commandSoundProperty= "SELECT soundPropertyType, value FROM SourceSoundProperty" + i2s(temp.sourceID);
sqlite3_prepare_v2(mDatabase,commandSoundProperty.c_str(),-1,&qSoundProperty,NULL);
while((eCode=sqlite3_step(qSoundProperty))==SQLITE_ROW)
{
@@ -1868,7 +2049,7 @@ am_Error_e DatabaseHandler::getListSources(std::vector<am_Source_s> & listSource
}
//read out MainSoundProperties
- std::string commandMainSoundProperty= "SELECT soundPropertyType, value FROM SourceMainSoundProperty"+ int2string(temp.sourceID);
+ std::string commandMainSoundProperty= "SELECT soundPropertyType, value FROM SourceMainSoundProperty"+ i2s(temp.sourceID);
sqlite3_prepare_v2(mDatabase,commandMainSoundProperty.c_str(),-1,&qMAinSoundProperty,NULL);
while((eCode=sqlite3_step(qMAinSoundProperty))==SQLITE_ROW)
{
@@ -1924,7 +2105,7 @@ am_Error_e DatabaseHandler::getListSourceClasses(std::vector<am_SourceClass_s> &
classTemp.name=std::string((const char*)sqlite3_column_text(query,1));
//read out Properties
- command2="SELECT classProperty, value FROM SourceClassProperties"+ int2string(classTemp.sourceClassID);
+ command2="SELECT classProperty, value FROM SourceClassProperties"+ i2s(classTemp.sourceClassID);
sqlite3_prepare_v2(mDatabase,command2.c_str(),-1,&subQuery,NULL);
while((eCode1=sqlite3_step(subQuery))==SQLITE_ROW)
@@ -2006,7 +2187,7 @@ am_Error_e DatabaseHandler::getListGateways(std::vector<am_Gateway_s> & listGate
temp.convertionMatrix=iter->second;
//read out the connectionFormats
- std::string commandConnectionFormat= "SELECT soundFormat FROM GatewaySourceFormat" + int2string(temp.gatewayID);
+ std::string commandConnectionFormat= "SELECT soundFormat FROM GatewaySourceFormat" + i2s(temp.gatewayID);
sqlite3_prepare_v2(mDatabase,commandConnectionFormat.c_str(),-1,&qSourceConnectionFormat,NULL);
while((eCode=sqlite3_step(qSourceConnectionFormat))==SQLITE_ROW)
{
@@ -2021,7 +2202,7 @@ am_Error_e DatabaseHandler::getListGateways(std::vector<am_Gateway_s> & listGate
}
//read out sound properties
- commandConnectionFormat= "SELECT soundFormat FROM GatewaySinkFormat" + int2string(temp.gatewayID);
+ commandConnectionFormat= "SELECT soundFormat FROM GatewaySinkFormat" + i2s(temp.gatewayID);
sqlite3_prepare_v2(mDatabase,commandConnectionFormat.c_str(),-1,&qSinkConnectionFormat,NULL);
while((eCode=sqlite3_step(qSinkConnectionFormat))==SQLITE_ROW)
{
@@ -2076,7 +2257,7 @@ am_Error_e DatabaseHandler::getListSinkClasses(std::vector<am_SinkClass_s> & lis
classTemp.name=std::string((const char*)sqlite3_column_text(query,1));
//read out Properties
- command2="SELECT classProperty, value FROM SinkClassProperties"+ int2string(classTemp.sinkClassID);
+ command2="SELECT classProperty, value FROM SinkClassProperties"+ i2s(classTemp.sinkClassID);
sqlite3_prepare_v2(mDatabase,command2.c_str(),-1,&subQuery,NULL);
while((eCode=sqlite3_step(subQuery))==SQLITE_ROW)
@@ -2161,7 +2342,7 @@ am_Error_e DatabaseHandler::getListMainSinks(std::vector<am_SinkType_s> & listMa
int eCode=0;
am_SinkType_s temp;
- std::string command= "SELECT name, sinkID, availability, availabilityReason, muteState, mainVolume, sinkClassID FROM " + std::string(SINK_TABLE) + " WHERE visible=1";
+ std::string command= "SELECT name, sinkID, availability, availabilityReason, muteState, mainVolume, sinkClassID FROM " + std::string(SINK_TABLE) + " WHERE visible=1 AND reserved=0";
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
while((eCode=sqlite3_step(query))==SQLITE_ROW)
@@ -2239,7 +2420,7 @@ am_Error_e DatabaseHandler::getListMainSinkSoundProperties(const am_sinkID_t sin
sqlite3_stmt* query=NULL;
int eCode=0;
am_MainSoundProperty_s temp;
- std::string command= "SELECT soundPropertyType, value FROM SinkMainSoundProperty" + int2string(sinkID);
+ std::string command= "SELECT soundPropertyType, value FROM SinkMainSoundProperty" + i2s(sinkID);
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
while((eCode=sqlite3_step(query))==SQLITE_ROW)
@@ -2275,7 +2456,7 @@ am_Error_e DatabaseHandler::getListMainSourceSoundProperties(const am_sourceID_t
sqlite3_stmt* query=NULL;
int eCode=0;
am_MainSoundProperty_s temp;
- std::string command= "SELECT soundPropertyType, value FROM SourceMainSoundProperty" + int2string(sourceID);
+ std::string command= "SELECT soundPropertyType, value FROM SourceMainSoundProperty" + i2s(sourceID);
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
while((eCode=sqlite3_step(query))==SQLITE_ROW)
@@ -2343,7 +2524,7 @@ am_Error_e DatabaseHandler::getTimingInformation(const am_mainConnectionID_t mai
sqlite3_stmt *query=NULL;
int eCode=0;
- std::string command= "SELECT delay FROM " + std::string(MAINCONNECTION_TABLE) + " WHERE mainConnectionID=" + int2string(mainConnectionID);
+ std::string command= "SELECT delay FROM " + std::string(MAINCONNECTION_TABLE) + " WHERE mainConnectionID=" + i2s(mainConnectionID);
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
while((eCode=sqlite3_step(query))==SQLITE_ROW)
@@ -2413,6 +2594,9 @@ am_Error_e DatabaseHandler::changeDelayMainConnection(const am_timeSync_t & dela
DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeDelayMainConnection SQLITE Finalize error code:"),DLT_INT(eCode));
return E_DATABASE_ERROR;
}
+
+ if(mObserver) mObserver->timingInformationChanged(connectionID,delay);
+
return E_OK;
}
@@ -2425,13 +2609,14 @@ am_Error_e DatabaseHandler::enterConnectionDB(const am_Connection_s& connection,
sqlite3_stmt* query=NULL;
int eCode=0;
- std::string command= "INSERT INTO " + std::string(CONNECTION_TABLE) + "(sinkID, sourceID, delay, connectionFormat) VALUES (?,?,?,?)";
+ std::string command= "INSERT INTO " + std::string(CONNECTION_TABLE) + "(sinkID, sourceID, delay, connectionFormat, reserved) VALUES (?,?,?,?,?)";
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
sqlite3_bind_int(query,1, connection.sinkID);
sqlite3_bind_int(query,2, connection.sourceID);
sqlite3_bind_int(query,3, connection.delay);
sqlite3_bind_int(query,4, connection.connectionFormat);
+ sqlite3_bind_int(query,5, true);
if((eCode=sqlite3_step(query))!=SQLITE_DONE)
{
@@ -2509,11 +2694,11 @@ am_Error_e DatabaseHandler::enterSinkClassDB(const am_SinkClass_s & sinkClass, a
sinkClassID=sqlite3_last_insert_rowid(mDatabase); //todo:change last_insert implementations for mulithread usage...
//now we need to create the additional tables:
- command="CREATE TABLE SinkClassProperties" + int2string(sinkClassID) + std::string("(classProperty INTEGER, value INTEGER)");
+ command="CREATE TABLE SinkClassProperties" + i2s(sinkClassID) + std::string("(classProperty INTEGER, value INTEGER)");
assert(this->sqQuery(command));
//fill ConnectionFormats
- command="INSERT INTO SinkClassProperties" + int2string(sinkClassID) + std::string("(classProperty,value) VALUES (?,?)");
+ command="INSERT INTO SinkClassProperties" + i2s(sinkClassID) + std::string("(classProperty,value) VALUES (?,?)");
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
std::vector<am_ClassProperty_s>::const_iterator Iterator=sinkClass.listClassProperties.begin();
for(;Iterator<sinkClass.listClassProperties.end();++Iterator)
@@ -2535,6 +2720,7 @@ am_Error_e DatabaseHandler::enterSinkClassDB(const am_SinkClass_s & sinkClass, a
}
DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::enterSinkClassDB entered new sinkClass"));
+ if (mObserver) mObserver->numberOfSinkClassesChanged();
return E_OK;
}
@@ -2591,11 +2777,11 @@ am_Error_e DatabaseHandler::enterSourceClassDB(am_sourceClass_t & sourceClassID,
sourceClassID=sqlite3_last_insert_rowid(mDatabase); //todo:change last_insert implementations for mulithread usage...
//now we need to create the additional tables:
- command="CREATE TABLE SourceClassProperties" + int2string(sourceClassID) + std::string("(classProperty INTEGER, value INTEGER)");
+ command="CREATE TABLE SourceClassProperties" + i2s(sourceClassID) + std::string("(classProperty INTEGER, value INTEGER)");
assert(sqQuery(command));
//fill ConnectionFormats
- command="INSERT INTO SourceClassProperties" + int2string(sourceClassID) + std::string("(classProperty,value) VALUES (?,?)");
+ command="INSERT INTO SourceClassProperties" + i2s(sourceClassID) + std::string("(classProperty,value) VALUES (?,?)");
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
std::vector<am_ClassProperty_s>::const_iterator Iterator=sourceClass.listClassProperties.begin();
for(;Iterator<sourceClass.listClassProperties.end();++Iterator)
@@ -2617,6 +2803,8 @@ am_Error_e DatabaseHandler::enterSourceClassDB(am_sourceClass_t & sourceClassID,
}
DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::enterSourceClassDB entered new sourceClass"));
+
+ if (mObserver) mObserver->numberOfSourceClassesChanged();
return E_OK;
}
@@ -2658,7 +2846,7 @@ am_Error_e DatabaseHandler::enterSystemProperties(const std::vector<am_SystemPro
bool DatabaseHandler::existMainConnection(const am_mainConnectionID_t mainConnectionID) const
{
sqlite3_stmt* query=NULL;
- std::string command = "SELECT mainConnectionID FROM " + std::string(MAINCONNECTION_TABLE) + " WHERE mainConnectionID=" + int2string(mainConnectionID);
+ std::string command = "SELECT mainConnectionID FROM " + std::string(MAINCONNECTION_TABLE) + " WHERE mainConnectionID=" + i2s(mainConnectionID);
int eCode=0;
bool returnVal=true;
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
@@ -2675,10 +2863,47 @@ bool DatabaseHandler::existMainConnection(const am_mainConnectionID_t mainConnec
bool DatabaseHandler::existSource(const am_sourceID_t sourceID) const
{
sqlite3_stmt* query=NULL;
- std::string command = "SELECT sourceID FROM " + std::string(SOURCE_TABLE) + " WHERE sourceID=" + int2string(sourceID);
+ std::string command = "SELECT sourceID FROM " + std::string(SOURCE_TABLE) + " WHERE reserved=0 AND sourceID=" + i2s(sourceID);
+ int eCode=0;
+ bool returnVal=true;
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ if ((eCode=sqlite3_step(query))==SQLITE_DONE) returnVal=false;
+ else if (eCode!=SQLITE_ROW)
+ {
+ returnVal=false;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existSource database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return returnVal;
+}
+
+bool DatabaseHandler::existSourceNameOrID(const am_sourceID_t sourceID, const std::string & name) const
+{
+ sqlite3_stmt* query=NULL;
+ std::string command = "SELECT sourceID FROM " + std::string(SOURCE_TABLE) + " WHERE reserved=0 AND (name=? OR sourceID=?)";
int eCode=0;
bool returnVal=true;
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_bind_text(query,1,name.c_str(),name.size(),SQLITE_STATIC);
+ sqlite3_bind_int(query,2,sourceID);
+ if ((eCode=sqlite3_step(query))==SQLITE_DONE) returnVal=false;
+ else if (eCode!=SQLITE_ROW)
+ {
+ returnVal=false;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existSource database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return returnVal;
+}
+
+bool DatabaseHandler::existSourceName(const std::string & name) const
+{
+ sqlite3_stmt* query=NULL;
+ std::string command = "SELECT sourceID FROM " + std::string(SOURCE_TABLE) + " WHERE reserved=0 AND name=?";
+ int eCode=0;
+ bool returnVal=true;
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_bind_text(query,1,name.c_str(),name.size(),SQLITE_STATIC);
if ((eCode=sqlite3_step(query))==SQLITE_DONE) returnVal=false;
else if (eCode!=SQLITE_ROW)
{
@@ -2692,10 +2917,47 @@ bool DatabaseHandler::existSource(const am_sourceID_t sourceID) const
bool DatabaseHandler::existSink(const am_sinkID_t sinkID) const
{
sqlite3_stmt* query=NULL;
- std::string command = "SELECT sinkID FROM " + std::string(SINK_TABLE) + " WHERE sinkID=" + int2string(sinkID);
+ std::string command = "SELECT sinkID FROM " + std::string(SINK_TABLE) + " WHERE reserved=0 AND sinkID=" + i2s(sinkID);
+ int eCode=0;
+ bool returnVal=true;
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ if ((eCode=sqlite3_step(query))==SQLITE_DONE) returnVal=false;
+ else if (eCode!=SQLITE_ROW)
+ {
+ returnVal=false;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existSink database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return returnVal;
+}
+
+bool DatabaseHandler::existSinkNameOrID(const am_sinkID_t sinkID, const std::string & name) const
+{
+ sqlite3_stmt* query=NULL;
+ std::string command = "SELECT sinkID FROM " + std::string(SINK_TABLE) + " WHERE reserved=0 AND (name=? OR sinkID=?)";
+ int eCode=0;
+ bool returnVal=true;
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_bind_text(query,1,name.c_str(),name.size(),SQLITE_STATIC);
+ sqlite3_bind_int(query,2,sinkID);
+ if ((eCode=sqlite3_step(query))==SQLITE_DONE) returnVal=false;
+ else if (eCode!=SQLITE_ROW)
+ {
+ returnVal=false;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existSink database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return returnVal;
+}
+
+bool DatabaseHandler::existSinkName(const std::string & name) const
+{
+ sqlite3_stmt* query=NULL;
+ std::string command = "SELECT sinkID FROM " + std::string(SINK_TABLE) + " WHERE reserved=0 AND name=?";
int eCode=0;
bool returnVal=true;
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_bind_text(query,1,name.c_str(),name.size(),SQLITE_STATIC);
if ((eCode=sqlite3_step(query))==SQLITE_DONE) returnVal=false;
else if (eCode!=SQLITE_ROW)
{
@@ -2709,7 +2971,7 @@ bool DatabaseHandler::existSink(const am_sinkID_t sinkID) const
bool DatabaseHandler::existDomain(const am_domainID_t domainID) const
{
sqlite3_stmt* query=NULL;
- std::string command = "SELECT domainID FROM " + std::string(DOMAIN_TABLE) + " WHERE domainID=" + int2string(domainID);
+ std::string command = "SELECT domainID FROM " + std::string(DOMAIN_TABLE) + " WHERE reserved=0 AND domainID=" + i2s(domainID);
int eCode=0;
bool returnVal=true;
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
@@ -2726,7 +2988,7 @@ bool DatabaseHandler::existDomain(const am_domainID_t domainID) const
bool DatabaseHandler::existGateway(const am_gatewayID_t gatewayID) const
{
sqlite3_stmt* query=NULL;
- std::string command = "SELECT gatewayID FROM " + std::string(GATEWAY_TABLE) + " WHERE gatewayID=" + int2string(gatewayID);
+ std::string command = "SELECT gatewayID FROM " + std::string(GATEWAY_TABLE) + " WHERE gatewayID=" + i2s(gatewayID);
int eCode=0;
bool returnVal=true;
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
@@ -2745,7 +3007,7 @@ am_Error_e DatabaseHandler::getDomainOfSource(const am_sourceID_t sourceID, am_d
assert(sourceID!=0);
sqlite3_stmt* query=NULL;
- std::string command = "SELECT domainID FROM " + std::string(SOURCE_TABLE) + " WHERE sourceID=" + int2string(sourceID);
+ std::string command = "SELECT domainID FROM " + std::string(SOURCE_TABLE) + " WHERE sourceID=" + i2s(sourceID);
int eCode=0;
am_Error_e returnVal=E_DATABASE_ERROR;
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
@@ -2766,7 +3028,7 @@ am_Error_e DatabaseHandler::getDomainOfSource(const am_sourceID_t sourceID, am_d
bool DatabaseHandler::existSinkClass(const am_sinkClass_t sinkClassID) const
{
sqlite3_stmt* query=NULL;
- std::string command = "SELECT sinkClassID FROM " + std::string(SINK_CLASS_TABLE) + " WHERE sinkClassID=" + int2string(sinkClassID);
+ std::string command = "SELECT sinkClassID FROM " + std::string(SINK_CLASS_TABLE) + " WHERE sinkClassID=" + i2s(sinkClassID);
int eCode=0;
bool returnVal=true;
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
@@ -2783,7 +3045,7 @@ bool DatabaseHandler::existSinkClass(const am_sinkClass_t sinkClassID) const
bool DatabaseHandler::existSourceClass(const am_sourceClass_t sourceClassID) const
{
sqlite3_stmt* query=NULL;
- std::string command = "SELECT sourceClassID FROM " + std::string(SOURCE_CLASS_TABLE) + " WHERE sourceClassID=" + int2string(sourceClassID);
+ std::string command = "SELECT sourceClassID FROM " + std::string(SOURCE_CLASS_TABLE) + " WHERE sourceClassID=" + i2s(sourceClassID);
int eCode=0;
bool returnVal=true;
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
@@ -2856,10 +3118,35 @@ am_Error_e DatabaseHandler::changeConnectionTimingInformation(const am_connectio
return E_OK;
}
+am_Error_e DatabaseHandler::changeConnectionFinal(const am_connectionID_t connectionID)
+{
+ assert(connectionID!=0);
+
+ sqlite3_stmt *query=NULL;
+ int eCode=0;
+ std::string command= "UPDATE " + std::string(CONNECTION_TABLE) + " set reserved=0 WHERE connectionID=?";
+
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_bind_int(query,1, connectionID);
+
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeConnectionFinal SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeConnectionFinal SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ return E_OK;
+}
+
bool DatabaseHandler::connectionPartofMainConnection(const am_connectionID_t connectionID, const am_mainConnectionID_t mainConnectionID) const
{
sqlite3_stmt* query=NULL;
- std::string command = "SELECT connectionID FROM MainConnectionRoute"+ int2string(mainConnectionID)+ " WHERE connectionID=" + int2string(connectionID);
+ std::string command = "SELECT connectionID FROM MainConnectionRoute"+ i2s(mainConnectionID)+ " WHERE connectionID=" + i2s(connectionID);
int eCode=0;
bool returnVal=true;
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
@@ -2877,7 +3164,7 @@ am_timeSync_t DatabaseHandler::calculateMainConnectionDelay(const am_mainConnect
{
assert (mainConnectionID!=0);
sqlite3_stmt* query=NULL;
- std::string command = "SELECT delay FROM MainConnectionRoute"+ int2string(mainConnectionID);
+ std::string command = "SELECT delay FROM MainConnectionRoute"+ i2s(mainConnectionID);
int eCode=0;
am_timeSync_t delay=0;
sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
@@ -2903,6 +3190,415 @@ am_timeSync_t DatabaseHandler::calculateMainConnectionDelay(const am_mainConnect
return delay;
}
+void DatabaseHandler::registerObserver(Observer *iObserver)
+{
+ #ifndef UNIT_TEST //we need this here for unittest
+ assert(iObserver!=NULL);
+ #endif
+
+ mObserver=iObserver;
+}
+
+bool DatabaseHandler::sourceVisible(const am_sourceID_t sourceID) const
+{
+ assert(sourceID!=0);
+ sqlite3_stmt* query=NULL;
+ std::string command = "SELECT visible FROM "+ std::string(SOURCE_TABLE) +" WHERE sourceID="+ i2s(sourceID);
+ int eCode=0;
+ bool returnVal=false;
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ if ((eCode=sqlite3_step(query))==SQLITE_DONE)
+ {
+ returnVal=sqlite3_column_int(query,0);
+ }
+ else if (eCode!=SQLITE_ROW)
+ {
+ returnVal=false;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::sourceVisible database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return returnVal;
+}
+
+bool DatabaseHandler::sinkVisible(const am_sinkID_t sinkID) const
+{
+ sqlite3_stmt* query=NULL;
+ std::string command = "SELECT visible FROM "+ std::string(SINK_TABLE) +" WHERE reserved=0 AND sinkID="+ i2s(sinkID);
+ int eCode=0;
+ bool returnVal=false;
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ if ((eCode=sqlite3_step(query))==SQLITE_DONE)
+ {
+ returnVal=sqlite3_column_int(query,0);
+ }
+ else if (eCode!=SQLITE_ROW)
+ {
+ returnVal=false;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::sinkVisible database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return returnVal;
+}
+
+bool DatabaseHandler::existConnection(const am_Connection_s connection)
+{
+ sqlite3_stmt* query=NULL;
+ std::string command = "SELECT connectionID FROM " + std::string(CONNECTION_TABLE) + " WHERE sinkID=? AND sourceID=? AND connectionFormat=? AND reserved=0";
+ int eCode=0;
+ bool returnVal=true;
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_bind_int(query,1, connection.sinkID);
+ sqlite3_bind_int(query,2, connection.sourceID);
+ sqlite3_bind_int(query,3, connection.connectionFormat);
+ if ((eCode=sqlite3_step(query))==SQLITE_DONE) returnVal=false;
+ else if (eCode!=SQLITE_ROW)
+ {
+ returnVal=false;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existMainConnection database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return returnVal;
+}
+
+
+bool DatabaseHandler::existConnectionID(const am_connectionID_t connectionID)
+{
+ sqlite3_stmt* query=NULL;
+ std::string command = "SELECT connectionID FROM " + std::string(CONNECTION_TABLE) + " WHERE connectionID=? AND reserved=0";
+ int eCode=0;
+ bool returnVal=true;
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_bind_int(query,1, connectionID);
+ if ((eCode=sqlite3_step(query))==SQLITE_DONE) returnVal=false;
+ else if (eCode!=SQLITE_ROW)
+ {
+ returnVal=false;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existMainConnection database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return returnVal;
+}
+
+bool DatabaseHandler::existcrossFader(const am_crossfaderID_t crossfaderID) const
+{
+ sqlite3_stmt* query=NULL;
+ std::string command = "SELECT crossfaderID FROM " + std::string(CROSSFADER_TABLE) + " WHERE crossfaderID=?";
+ int eCode=0;
+ bool returnVal=true;
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_bind_int(query,1, crossfaderID);
+ if ((eCode=sqlite3_step(query))==SQLITE_DONE) returnVal=false;
+ else if (eCode!=SQLITE_ROW)
+ {
+ returnVal=false;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existMainConnection database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return returnVal;
+}
+
+am_Error_e DatabaseHandler::getSoureState(const am_sourceID_t sourceID, am_SourceState_e & sourceState) const
+{
+ assert(sourceID!=0);
+ sqlite3_stmt* query=NULL;
+ sourceState=SS_MIN;
+ std::string command = "SELECT sourceState FROM "+ std::string(SOURCE_TABLE) +" WHERE sourceID="+ i2s(sourceID);
+ int eCode=0;
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ if ((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ sourceState=(am_SourceState_e)sqlite3_column_int(query,0);
+ }
+ else if ((eCode=sqlite3_step(query))==SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSoureState database error!:"), DLT_INT(eCode))
+
+ }
+ sqlite3_finalize(query);
+ return E_OK;
+}
+
+am_Error_e DatabaseHandler::changeSourceState(const am_sourceID_t sourceID, const am_SourceState_e sourceState)
+{
+ assert(sourceID!=0);
+ sqlite3_stmt* query=NULL;
+ std::string command = "UPDATE " + std::string(SOURCE_TABLE) +" setsourceState=? WHERE sourceID="+ i2s(sourceID);
+ int eCode=0;
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_bind_int(query,1,sourceState);
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSourceState SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSourceState SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ return E_OK;
+}
+
+am_Error_e DatabaseHandler::getSinkVolume(const am_sinkID_t sinkID, am_volume_t & volume) const
+{
+ assert(sinkID!=0);
+ sqlite3_stmt* query=NULL;
+ volume=-1;
+ std::string command = "SELECT volume FROM "+ std::string(SINK_TABLE) +" WHERE sinkID="+ i2s(sinkID);
+ int eCode=0;
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ if ((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ volume=sqlite3_column_int(query,0);
+ }
+ else if ((eCode=sqlite3_step(query))==SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSinkVolume database error!:"), DLT_INT(eCode))
+
+ }
+ sqlite3_finalize(query);
+ return E_OK;
+}
+
+am_Error_e DatabaseHandler::getSourceVolume(const am_sourceID_t sourceID, am_volume_t & volume) const
+{
+ assert(sourceID!=0);
+ sqlite3_stmt* query=NULL;
+ volume=-1;
+ std::string command = "SELECT volume FROM "+ std::string(SOURCE_TABLE) +" WHERE sourceID="+ i2s(sourceID);
+ int eCode=0;
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ if ((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ volume=sqlite3_column_int(query,0);
+ }
+ else if ((eCode=sqlite3_step(query))==SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSourceVolume database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return E_OK;
+}
+
+
+am_Error_e DatabaseHandler::getSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_SoundPropertyType_e propertyType, uint16_t & value) const
+{
+ assert(sinkID!=0);
+ if (!existSink(sinkID)) return E_DATABASE_ERROR; // todo: here we could change to non existent, but not shown in sequences
+
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+ std::string command= "SELECT value FROM SinkSoundProperty" + i2s(sinkID) +" WHERE soundPropertyType=" +i2s(propertyType);
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+
+ while((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ value=sqlite3_column_int(query,0);
+ }
+
+ if(eCode!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSinkSoundPropertyValue SQLITE error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSinkSoundPropertyValue SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ return E_OK;
+}
+
+am_Error_e DatabaseHandler::getSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_SoundPropertyType_e propertyType, uint16_t & value) const
+{
+ assert(sourceID!=0);
+ if (!existSource(sourceID)) return E_DATABASE_ERROR; // todo: here we could change to non existent, but not shown in sequences
+
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+ std::string command= "SELECT value FROM SourceSoundProperty" + i2s(sourceID) +" WHERE soundPropertyType=" +i2s(propertyType);
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+
+ while((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ value=sqlite3_column_int(query,0);
+ }
+
+ if(eCode!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSinkSoundPropertyValue SQLITE error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSinkSoundPropertyValue SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ return E_OK;
+}
+
+am_Error_e DatabaseHandler::getDomainState(const am_domainID_t domainID, am_DomainState_e state) const
+{
+ assert(domainID!=0);
+ sqlite3_stmt* query=NULL;
+ state=DS_MIN;
+ std::string command = "SELECT domainState FROM "+ std::string(DOMAIN_TABLE) +" WHERE domainID="+ i2s(domainID);
+ int eCode=0;
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ if ((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ state=(am_DomainState_e)sqlite3_column_int(query,0);
+ }
+ else if ((eCode=sqlite3_step(query))==SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getDomainState database error!:"), DLT_INT(eCode))
+
+ }
+ sqlite3_finalize(query);
+ return E_OK;
+
+}
+
+am_Error_e DatabaseHandler::peekDomain(const std::string & name, am_domainID_t & domainID)
+{
+ sqlite3_stmt* query=NULL, *queryInsert=NULL;
+ std::string command = "SELECT domainID FROM " + std::string(DOMAIN_TABLE) + " WHERE name=?";
+ int eCode=0, eCode1=0;
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_bind_text(query,1,name.c_str(),name.size(),SQLITE_STATIC);
+ if ((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ domainID=sqlite3_column_int(query,0);
+ }
+ else if (eCode!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::peekDomain database error!:"), DLT_INT(eCode))
+ return E_DATABASE_ERROR;
+ }
+ else
+ {
+ command= "INSERT INTO " + std::string(DOMAIN_TABLE) + " (name,reserved) VALUES (?,?)";
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&queryInsert,NULL);
+ sqlite3_bind_text(queryInsert,1,name.c_str(),name.size(),SQLITE_STATIC);
+ sqlite3_bind_int(queryInsert,2,1); //reservation flag
+ if((eCode1=sqlite3_step(queryInsert))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::peekDomain SQLITE Step error code:"),DLT_INT(eCode1));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode1=sqlite3_finalize(queryInsert))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::peekDomain SQLITE Finalize error code:"),DLT_INT(eCode1));
+ return E_DATABASE_ERROR;
+ }
+ domainID=sqlite3_last_insert_rowid(mDatabase);
+ }
+ sqlite3_finalize(query);
+ return E_OK;
+}
+
+am_Error_e DatabaseHandler::peekSink(const std::string & name, am_sinkID_t & sinkID)
+{
+ sqlite3_stmt* query=NULL, *queryInsert=NULL;
+ std::string command = "SELECT sinkID FROM " + std::string(SINK_TABLE) + " WHERE name=?";
+ int eCode=0, eCode1=0;
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_bind_text(query,1,name.c_str(),name.size(),SQLITE_STATIC);
+ if ((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ sinkID=sqlite3_column_int(query,0);
+ }
+ else if (eCode!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::peekSink database error!:"), DLT_INT(eCode))
+ return E_DATABASE_ERROR;
+ }
+ else
+ {
+ if (mFirstStaticSink)
+ {
+ command= "INSERT INTO " + std::string(SINK_TABLE) + " (name,reserved,sinkID) VALUES (?,?," + i2s(DYNAMIC_ID_BOUNDARY) + ")";
+ mFirstStaticSink=false;
+ }
+ else
+ {
+ command= "INSERT INTO " + std::string(SINK_TABLE) + " (name,reserved) VALUES (?,?)";
+ }
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&queryInsert,NULL);
+ sqlite3_bind_text(queryInsert,1,name.c_str(),name.size(),SQLITE_STATIC);
+ sqlite3_bind_int(queryInsert,2,1); //reservation flag
+ if((eCode1=sqlite3_step(queryInsert))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::peekSink SQLITE Step error code:"),DLT_INT(eCode1));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode1=sqlite3_finalize(queryInsert))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::peekDomain SQLITE Finalize error code:"),DLT_INT(eCode1));
+ return E_DATABASE_ERROR;
+ }
+ sinkID=sqlite3_last_insert_rowid(mDatabase);
+ }
+ sqlite3_finalize(query);
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::peekSource(const std::string & name, am_sourceID_t & sourceID)
+{
+ sqlite3_stmt* query=NULL, *queryInsert=NULL;
+ std::string command = "SELECT sourceID FROM " + std::string(SOURCE_TABLE) + " WHERE name=?";
+ int eCode=0, eCode1=0;
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_bind_text(query,1,name.c_str(),name.size(),SQLITE_STATIC);
+ if ((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ sourceID=sqlite3_column_int(query,0);
+ }
+ else if (eCode!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::peekSink database error!:"), DLT_INT(eCode))
+ return E_DATABASE_ERROR;
+ }
+ else
+ {
+ if (mFirstStaticSource)
+ {
+ command= "INSERT INTO " + std::string(SOURCE_TABLE) + " (name,reserved,sourceID) VALUES (?,?," + i2s(DYNAMIC_ID_BOUNDARY) + ")";
+ mFirstStaticSource=false;
+ }
+ else
+ {
+ command= "INSERT INTO " + std::string(SOURCE_TABLE) + " (name,reserved) VALUES (?,?)";
+ }
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&queryInsert,NULL);
+ sqlite3_bind_text(queryInsert,1,name.c_str(),name.size(),SQLITE_STATIC);
+ sqlite3_bind_int(queryInsert,2,1); //reservation flag
+ if((eCode1=sqlite3_step(queryInsert))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::peekSink SQLITE Step error code:"),DLT_INT(eCode1));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode1=sqlite3_finalize(queryInsert))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::peekDomain SQLITE Finalize error code:"),DLT_INT(eCode1));
+ return E_DATABASE_ERROR;
+ }
+ sourceID=sqlite3_last_insert_rowid(mDatabase);
+ }
+ sqlite3_finalize(query);
+ return E_OK;
+}
+
void DatabaseHandler::createTables()
{
for(uint16_t i=0;i<sizeof(databaseTables)/sizeof(databaseTables[0]);i++)
diff --git a/AudioManagerDaemon/src/Observer.cpp b/AudioManagerDaemon/src/Observer.cpp
new file mode 100644
index 0000000..648c295
--- /dev/null
+++ b/AudioManagerDaemon/src/Observer.cpp
@@ -0,0 +1,188 @@
+/*
+ * Observer.cpp
+ *
+ * Created on: Dec 10, 2011
+ * Author: christian
+ */
+
+#include "Observer.h"
+#include "CommandSender.h"
+#include <assert.h>
+
+Observer::Observer(CommandSender *iCommandSender, RoutingSender *iRoutingSender)
+ :mCommandSender(iCommandSender),
+ mRoutingSender(iRoutingSender)
+{
+ assert(mCommandSender!=0);
+ assert(mRoutingSender!=0);
+ mCommandSender->cbCommunicationReady();
+}
+
+Observer::~Observer() {
+ // TODO Auto-generated destructor stub
+}
+
+void Observer::newSink(am_Sink_s sink)
+{
+ mRoutingSender->addSinkLookup(sink);
+ mCommandSender->cbNumberOfSinksChanged();
+}
+
+
+
+void Observer::newSource(am_Source_s source)
+{
+ mRoutingSender->addSourceLookup(source);
+ mCommandSender->cbNumberOfSourcesChanged();
+}
+
+
+
+void Observer::newDomain(am_Domain_s domain)
+{
+ mRoutingSender->addDomainLookup(domain);
+}
+
+
+
+void Observer::newGateway(am_Gateway_s gateway)
+{
+
+}
+
+
+
+void Observer::newCrossfader(am_Crossfader_s crossfader)
+{
+ mRoutingSender->addCrossfaderLookup(crossfader);
+}
+
+
+
+void Observer::removedSink(am_sinkID_t sinkID)
+{
+ mRoutingSender->removeSinkLookup(sinkID);
+ mCommandSender->cbNumberOfSinksChanged();
+}
+
+
+
+void Observer::removedSource(am_sourceID_t sourceID)
+{
+ mRoutingSender->removeSourceLookup(sourceID);
+ mCommandSender->cbNumberOfSourcesChanged();
+}
+
+
+
+void Observer::removeDomain(am_domainID_t domainID)
+{
+ mRoutingSender->removeDomainLookup(domainID);
+}
+
+
+
+void Observer::removeGateway(am_gatewayID_t gatewayID)
+{
+}
+
+
+
+void Observer::removeCrossfader(am_crossfaderID_t crossfaderID)
+{
+ mRoutingSender->removeCrossfaderLookup(crossfaderID);
+}
+
+
+void Observer::numberOfMainConnectionsChanged()
+{
+ mCommandSender->cbNumberOfMainConnectionsChanged();
+}
+
+void Observer::numberOfSinkClassesChanged()
+{
+ mCommandSender->cbNumberOfSinkClassesChanged();
+}
+
+
+
+void Observer::numberOfSourceClassesChanged()
+{
+ mCommandSender->cbNumberOfSourceClassesChanged();
+}
+
+
+
+void Observer::mainConnectionStateChanged(const am_mainConnectionID_t connectionID, const am_ConnectionState_e connectionState)
+{
+ mCommandSender->cbMainConnectionStateChanged(connectionID,connectionState);
+}
+
+
+
+void Observer::mainSinkSoundPropertyChanged(const am_sinkID_t sinkID, const am_MainSoundProperty_s SoundProperty)
+{
+ mCommandSender->cbMainSinkSoundPropertyChanged(sinkID,SoundProperty);
+}
+
+
+
+void Observer::mainSourceSoundPropertyChanged(const am_sourceID_t sourceID, const am_MainSoundProperty_s & SoundProperty)
+{
+ mCommandSender->cbMainSourceSoundPropertyChanged(sourceID,SoundProperty);
+}
+
+
+
+void Observer::sinkAvailabilityChanged(const am_sinkID_t sinkID, const am_Availability_s & availability)
+{
+ mCommandSender->cbSinkAvailabilityChanged(sinkID,availability);
+}
+
+
+
+void Observer::sourceAvailabilityChanged(const am_sourceID_t sourceID, const am_Availability_s & availability)
+{
+ mCommandSender->cbSourceAvailabilityChanged(sourceID,availability);
+}
+
+
+
+void Observer::volumeChanged(const am_sinkID_t sinkID, const am_mainVolume_t volume)
+{
+ mCommandSender->cbVolumeChanged(sinkID,volume);
+}
+
+
+
+void Observer::sinkMuteStateChanged(const am_sinkID_t sinkID, const am_MuteState_e muteState)
+{
+ mCommandSender->cbSinkMuteStateChanged(sinkID,muteState);
+}
+
+
+
+void Observer::systemPropertyChanged(const am_SystemProperty_s & SystemProperty)
+{
+ mCommandSender->cbSystemPropertyChanged(SystemProperty);
+}
+
+
+
+void Observer::timingInformationChanged(const am_mainConnectionID_t mainConnection, const am_timeSync_t time)
+{
+ mCommandSender->cbTimingInformationChanged(mainConnection,time);
+ //todo:inform the controller via controlsender
+}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/AudioManagerDaemon/src/RoutingReceiver.cpp b/AudioManagerDaemon/src/RoutingReceiver.cpp
index 00567e8..9940c6e 100644
--- a/AudioManagerDaemon/src/RoutingReceiver.cpp
+++ b/AudioManagerDaemon/src/RoutingReceiver.cpp
@@ -6,11 +6,18 @@
*/
#include "RoutingReceiver.h"
+#include <assert.h>
-RoutingReceiver::RoutingReceiver()
+RoutingReceiver::RoutingReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, ControlSender *iControlSender)
+ :mDatabaseHandler(iDatabaseHandler),
+ mRoutingSender(iRoutingSender),
+ mControlSender(iControlSender)
{
+ assert(mDatabaseHandler!=0);
+ assert(mRoutingSender!=0);
+ assert(mControlSender!=0);
}
@@ -23,18 +30,35 @@ RoutingReceiver::~RoutingReceiver()
void RoutingReceiver::ackConnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error)
{
+ mRoutingSender->removeHandle(handle);
+ if (error==E_OK)
+ {
+ mDatabaseHandler->changeConnectionFinal(connectionID);
+ }
+ else
+ {
+ mDatabaseHandler->removeConnection(connectionID);
+ }
+ return mControlSender->cbAckConnect(handle,error);
}
void RoutingReceiver::ackDisconnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error)
{
+ mRoutingSender->removeHandle(handle);
+ if (error==E_OK)
+ {
+ mDatabaseHandler->removeConnection(connectionID);
+ }
+ return mControlSender->cbAckConnect(handle,error);
}
void RoutingReceiver::ackSetSinkVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error)
{
+
}
@@ -83,131 +107,159 @@ void RoutingReceiver::ackSinkVolumeTick(const am_Handle_s handle, const am_sinkI
am_Error_e RoutingReceiver::peekDomain(const std::string & name, am_domainID_t & domainID)
{
-}
+ return mDatabaseHandler->peekDomain(name,domainID);
+}
am_Error_e RoutingReceiver::registerDomain(const am_Domain_s & domainData, am_domainID_t & domainID)
{
+ return mControlSender->hookSystemRegisterDomain(domainData,domainID);
}
am_Error_e RoutingReceiver::deregisterDomain(const am_domainID_t domainID)
{
+ return mControlSender->hookSystemDeregisterDomain(domainID);
}
am_Error_e RoutingReceiver::registerGateway(const am_Gateway_s & gatewayData, am_gatewayID_t & gatewayID)
{
+ return mControlSender->hookSystemRegisterGateway(gatewayData,gatewayID);
}
am_Error_e RoutingReceiver::deregisterGateway(const am_gatewayID_t gatewayID)
{
+ return mControlSender->hookSystemDeregisterGateway(gatewayID);
}
am_Error_e RoutingReceiver::peekSink(const std::string& name, am_sinkID_t & sinkID)
{
+ return mDatabaseHandler->peekSink(name,sinkID);
}
am_Error_e RoutingReceiver::registerSink(const am_Sink_s & sinkData, am_sinkID_t & sinkID)
{
+ return mControlSender->hookSystemRegisterSink(sinkData,sinkID);
}
am_Error_e RoutingReceiver::deregisterSink(const am_sinkID_t sinkID)
{
+ return mControlSender->hookSystemDeregisterSink(sinkID);
}
am_Error_e RoutingReceiver::peekSource(const std::string & name, am_sourceID_t & sourceID)
{
+ return mDatabaseHandler->peekSource(name,sourceID);
}
am_Error_e RoutingReceiver::registerSource(const am_Source_s & sourceData, am_sourceID_t & sourceID)
{
+ return mControlSender->hookSystemRegisterSource(sourceData,sourceID);
}
am_Error_e RoutingReceiver::deregisterSource(const am_sourceID_t sourceID)
{
+ return mControlSender->hookSystemDeregisterSource(sourceID);
}
am_Error_e RoutingReceiver::registerCrossfader(const am_Crossfader_s & crossfaderData, am_crossfaderID_t & crossfaderID)
{
+ return mControlSender->hookSystemRegisterCrossfader(crossfaderData,crossfaderID);
}
am_Error_e RoutingReceiver::deregisterCrossfader(const am_crossfaderID_t crossfaderID)
{
+ return mControlSender->hookSystemDeregisterCrossfader(crossfaderID);
}
void RoutingReceiver::hookInterruptStatusChange(const am_sourceID_t sourceID, const am_InterruptState_e interruptState)
{
+ return mControlSender->hookSystemInterruptStateChange(sourceID,interruptState);
}
void RoutingReceiver::hookDomainRegistrationComplete(const am_domainID_t domainID)
{
+ mControlSender->hookSystemDomainRegistrationComplete(domainID);
}
+
void RoutingReceiver::hookSinkAvailablityStatusChange(const am_sinkID_t sinkID, const am_Availability_s & availability)
{
+ mControlSender->hookSystemSinkAvailablityStateChange(sinkID,availability);
}
void RoutingReceiver::hookSourceAvailablityStatusChange(const am_sourceID_t sourceID, const am_Availability_s & availability)
{
+ mControlSender->hookSystemSourceAvailablityStateChange(sourceID,availability);
}
void RoutingReceiver::hookDomainStateChange(const am_domainID_t domainID, const am_DomainState_e domainState)
{
+ mControlSender->hookSystemDomainStateChange(domainID,domainState);
}
void RoutingReceiver::hookTimingInformationChanged(const am_connectionID_t connectionID, const am_timeSync_t delay)
{
+ mDatabaseHandler->changeConnectionTimingInformation(connectionID,delay);
}
am_Error_e RoutingReceiver::sendChangedData(const std::vector<am_EarlyData_s> & earlyData)
{
+ mControlSender->hookSystemReceiveEarlyData(earlyData);
+ return E_OK;
+ //todo: change return type to void in EA model
}
-am_Error_e RoutingReceiver::getDBusConnectionWrapper(DBusWrapper *dbusConnectionWrapper) const
+am_Error_e RoutingReceiver::peekSinkClassID(const std::string & name, am_sourceClass_t & sourceClassID)
{
+ //todo: implement
}
+am_Error_e RoutingReceiver::peekSourceClassID(const std::string & name, am_sinkClass_t & sinkClassID)
+{
+ //todo: implement
+}
-
-am_Error_e RoutingReceiver::registerDbusNode(const std::string & nodeName)
+am_Error_e RoutingReceiver::getDBusConnectionWrapper(DBusWrapper *dbusConnectionWrapper) const
{
+ //todo: return DbusWrapper
}
diff --git a/AudioManagerDaemon/src/RoutingSender.cpp b/AudioManagerDaemon/src/RoutingSender.cpp
index 945fefa..d54a986 100644
--- a/AudioManagerDaemon/src/RoutingSender.cpp
+++ b/AudioManagerDaemon/src/RoutingSender.cpp
@@ -6,7 +6,9 @@
*/
#include "RoutingSender.h"
+#include "pluginTemplate.h"
#include <utility>
+
using namespace am;
#define CALL_ALL_INTERFACES(...) \
@@ -20,10 +22,19 @@ using namespace am;
const char* routingPluginDirectories[] = { "/home/christian/workspace/gitserver/build/plugins/routing"};
uint16_t routingPluginDirectoriesCount = sizeof(routingPluginDirectories) / sizeof(routingPluginDirectories[0]);
+
RoutingSender::RoutingSender()
+ : mHandleCount(0),
+ mlistActiveHandles(),
+ mListInterfaces(),
+ mMapConnectionInterface(),
+ mMapCrossfaderInterface(),
+ mMapDomainInterface(),
+ mMapSinkInterface(),
+ mMapSourceInterface(),
+ mMapHandleInterface()
{
std::vector<std::string> sharedLibraryNameList;
-
// search communicator plugins in configured directories
for (uint16_t dirIndex = 0; dirIndex < routingPluginDirectoriesCount; dirIndex++)
{
@@ -70,7 +81,8 @@ RoutingSender::RoutingSender()
//DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Loading Hook plugin"),DLT_STRING(iter->c_str()));
RoutingSendInterface* (*createFunc)();
- createFunc = getCreateFunction<RoutingSendInterface*()>(*iter);
+ void* tempLibHandle=NULL;
+ createFunc = getCreateFunction<RoutingSendInterface*()>(*iter,tempLibHandle);
if (!createFunc)
{
@@ -90,11 +102,13 @@ RoutingSender::RoutingSender()
routerInterface.routingInterface = router;
router->returnBusName(routerInterface.busName);
mListInterfaces.push_back(routerInterface);
+ mListLibraryHandles.push_back(tempLibHandle);
}
}
RoutingSender::~RoutingSender()
{
+ unloadLibraries();
}
void RoutingSender::routingInterfacesReady()
@@ -112,22 +126,30 @@ void RoutingSender::startupRoutingInterface(RoutingReceiveInterface *routingrece
CALL_ALL_INTERFACES(startupRoutingInterface(routingreceiveinterface))
}
-am_Error_e RoutingSender::asyncAbort(const am_Handle_s handle)
+am_Error_e RoutingSender::asyncAbort(const am_Handle_s& handle)
{
- //Todo: map handle to RoutingInterface via Database.
- return E_UNKNOWN;
+ HandleInterfaceMap::iterator iter = mMapHandleInterface.begin();
+ iter=mMapHandleInterface.find(handle.handle);
+ if (iter != mMapHandleInterface.end())
+ {
+ return iter->second->asyncAbort(handle);
+ }
+
+ return E_NON_EXISTENT;
}
-am_Error_e RoutingSender::asyncConnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_ConnectionFormat_e connectionFormat)
+am_Error_e RoutingSender::asyncConnect(am_Handle_s& handle, const am_connectionID_t connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_ConnectionFormat_e connectionFormat)
{
SinkInterfaceMap::iterator iter = mMapSinkInterface.begin();
- mMapSinkInterface.find(sinkID);
+ iter=mMapSinkInterface.find(sinkID);
if (iter != mMapSinkInterface.end())
{
- return iter->second->asyncConnect(handle,connectionID,sourceID,sinkID,connectionFormat);
+ handle=createHandle(H_CONNECT);
mMapConnectionInterface.insert(std::make_pair(connectionID,iter->second));
+ mMapHandleInterface.insert(std::make_pair(handle.handle,iter->second));
+ return iter->second->asyncConnect(handle,connectionID,sourceID,sinkID,connectionFormat);
}
return E_NON_EXISTENT;
@@ -135,14 +157,17 @@ am_Error_e RoutingSender::asyncConnect(const am_Handle_s handle, const am_connec
-am_Error_e RoutingSender::asyncDisconnect(const am_Handle_s handle, const am_connectionID_t connectionID)
+am_Error_e RoutingSender::asyncDisconnect(am_Handle_s& handle, const am_connectionID_t connectionID)
{
ConnectionInterfaceMap::iterator iter = mMapConnectionInterface.begin();
mMapConnectionInterface.find(connectionID);
if (iter != mMapConnectionInterface.end())
{
- return iter->second->asyncDisconnect(handle,connectionID);
+ handle=createHandle(H_DISCONNECT);
+ mMapHandleInterface.insert(std::make_pair(handle.handle,iter->second));
+ am_Error_e returnVal=iter->second->asyncDisconnect(handle,connectionID);
mMapConnectionInterface.erase(iter);
+ return returnVal;
}
return E_NON_EXISTENT;
@@ -150,66 +175,78 @@ am_Error_e RoutingSender::asyncDisconnect(const am_Handle_s handle, const am_con
-am_Error_e RoutingSender::asyncSetSinkVolume(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time)
+am_Error_e RoutingSender::asyncSetSinkVolume(am_Handle_s& handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time)
{
SinkInterfaceMap::iterator iter = mMapSinkInterface.begin();
- mMapSinkInterface.find(sinkID);
+ iter=mMapSinkInterface.find(sinkID);
if (iter != mMapSinkInterface.end())
+ handle=createHandle(H_SETSINKVOLUME);
+ mMapHandleInterface.insert(std::make_pair(handle.handle,iter->second));
return iter->second->asyncSetSinkVolume(handle,sinkID,volume,ramp,time);
return E_NON_EXISTENT;
}
-am_Error_e RoutingSender::asyncSetSourceVolume(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time)
+am_Error_e RoutingSender::asyncSetSourceVolume(am_Handle_s& handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time)
{
SourceInterfaceMap::iterator iter = mMapSourceInterface.begin();
- mMapSourceInterface.find(sourceID);
+ iter=mMapSourceInterface.find(sourceID);
if (iter != mMapSourceInterface.end())
+ handle=createHandle(H_SETSOURCEVOLUME);
+ mMapHandleInterface.insert(std::make_pair(handle.handle,iter->second));
return iter->second->asyncSetSourceVolume(handle,sourceID,volume,ramp,time);
return E_NON_EXISTENT;
}
-am_Error_e RoutingSender::asyncSetSourceState(const am_Handle_s handle, const am_sourceID_t sourceID, const am_SourceState_e state)
+am_Error_e RoutingSender::asyncSetSourceState(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SourceState_e state)
{
SourceInterfaceMap::iterator iter = mMapSourceInterface.begin();
- mMapSourceInterface.find(sourceID);
+ iter=mMapSourceInterface.find(sourceID);
if (iter != mMapSourceInterface.end())
+ handle=createHandle(H_SETSOURCESTATE);
+ mMapHandleInterface.insert(std::make_pair(handle.handle,iter->second));
return iter->second->asyncSetSourceState(handle,sourceID,state);
return E_NON_EXISTENT;
}
-am_Error_e RoutingSender::asyncSetSinkSoundProperty(const am_Handle_s handle, const am_sinkID_t sinkID, const am_SoundProperty_s & soundProperty)
+am_Error_e RoutingSender::asyncSetSinkSoundProperty(am_Handle_s& handle, const am_sinkID_t sinkID, const am_SoundProperty_s & soundProperty)
{
SinkInterfaceMap::iterator iter = mMapSinkInterface.begin();
- mMapSinkInterface.find(sinkID);
+ iter=mMapSinkInterface.find(sinkID);
if (iter != mMapSinkInterface.end())
+ handle=createHandle(H_SETSINKSOUNDPROPERTY);
+ mMapHandleInterface.insert(std::make_pair(handle.handle,iter->second));
return iter->second->asyncSetSinkSoundProperty(handle,soundProperty,sinkID);
return E_NON_EXISTENT;
}
-am_Error_e RoutingSender::asyncSetSourceSoundProperty(const am_Handle_s handle, const am_sourceID_t sourceID, const am_SoundProperty_s & soundProperty)
+am_Error_e RoutingSender::asyncSetSourceSoundProperty(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SoundProperty_s & soundProperty)
{
SourceInterfaceMap::iterator iter = mMapSourceInterface.begin();
- mMapSourceInterface.find(sourceID);
+ iter=mMapSourceInterface.find(sourceID);
if (iter != mMapSourceInterface.end())
+ handle=createHandle(H_SETSOURCESOUNDPROPERTY);
+ mMapHandleInterface.insert(std::make_pair(handle.handle,iter->second));
return iter->second->asyncSetSourceSoundProperty(handle,soundProperty,sourceID);
return E_NON_EXISTENT;
}
-am_Error_e RoutingSender::asyncCrossFade(const am_Handle_s handle, const am_crossfaderID_t crossfaderID, const am_HotSink_e hotSink, const am_RampType_e rampType, const am_time_t time)
+am_Error_e RoutingSender::asyncCrossFade(am_Handle_s& handle, const am_crossfaderID_t crossfaderID, const am_HotSink_e hotSink, const am_RampType_e rampType, const am_time_t time)
{
CrossfaderInterfaceMap::iterator iter = mMapCrossfaderInterface.begin();
- mMapCrossfaderInterface.find(crossfaderID);
+ iter=mMapCrossfaderInterface.find(crossfaderID);
if (iter != mMapCrossfaderInterface.end())
+ handle=createHandle(H_CROSSFADE);
+ mMapHandleInterface.insert(std::make_pair(handle.handle,iter->second));
return iter->second->asyncCrossFade(handle,crossfaderID,hotSink,rampType,time);
return E_NON_EXISTENT;
}
@@ -219,7 +256,7 @@ am_Error_e RoutingSender::asyncCrossFade(const am_Handle_s handle, const am_cros
am_Error_e RoutingSender::setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState)
{
DomainInterfaceMap::iterator iter = mMapDomainInterface.begin();
- mMapDomainInterface.find(domainID);
+ iter=mMapDomainInterface.find(domainID);
if (iter != mMapDomainInterface.end())
return iter->second->setDomainState(domainID,domainState);
return E_NON_EXISTENT;
@@ -246,7 +283,7 @@ am_Error_e RoutingSender::addDomainLookup(const am_Domain_s& domainData)
am_Error_e RoutingSender::addSourceLookup(const am_Source_s& sourceData)
{
DomainInterfaceMap::iterator iter = mMapDomainInterface.begin();
- mMapDomainInterface.find(sourceData.domainID);
+ iter=mMapDomainInterface.find(sourceData.domainID);
if (iter != mMapDomainInterface.end())
{
mMapSourceInterface.insert(std::make_pair(sourceData.sourceID,iter->second));
@@ -261,7 +298,7 @@ am_Error_e RoutingSender::addSourceLookup(const am_Source_s& sourceData)
am_Error_e RoutingSender::addSinkLookup(const am_Sink_s& sinkData)
{
DomainInterfaceMap::iterator iter = mMapDomainInterface.begin();
- mMapDomainInterface.find(sinkData.domainID);
+ iter=mMapDomainInterface.find(sinkData.domainID);
if (iter != mMapDomainInterface.end())
{
mMapSinkInterface.insert(std::make_pair(sinkData.sinkID,iter->second));
@@ -276,7 +313,7 @@ am_Error_e RoutingSender::addSinkLookup(const am_Sink_s& sinkData)
am_Error_e RoutingSender::addCrossfaderLookup(const am_Crossfader_s& crossfaderData)
{
DomainInterfaceMap::iterator iter = mMapSourceInterface.begin();
- mMapSourceInterface.find(crossfaderData.sourceID);
+ iter=mMapSourceInterface.find(crossfaderData.sourceID);
if (iter != mMapSourceInterface.end())
{
mMapSourceInterface.insert(std::make_pair(crossfaderData.crossfaderID,iter->second));
@@ -289,7 +326,7 @@ am_Error_e RoutingSender::addCrossfaderLookup(const am_Crossfader_s& crossfaderD
am_Error_e RoutingSender::removeDomainLookup(const am_domainID_t domainID)
{
DomainInterfaceMap::iterator iter = mMapDomainInterface.begin();
- mMapDomainInterface.find(domainID);
+ iter=mMapDomainInterface.find(domainID);
if (iter != mMapDomainInterface.end())
{
mMapDomainInterface.erase(iter);
@@ -304,7 +341,7 @@ am_Error_e RoutingSender::removeDomainLookup(const am_domainID_t domainID)
am_Error_e RoutingSender::removeSourceLookup(const am_sourceID_t sourceID)
{
SourceInterfaceMap::iterator iter = mMapSourceInterface.begin();
- mMapSourceInterface.find(sourceID);
+ iter=mMapSourceInterface.find(sourceID);
if (iter != mMapSourceInterface.end())
{
mMapSourceInterface.erase(iter);
@@ -319,7 +356,7 @@ am_Error_e RoutingSender::removeSourceLookup(const am_sourceID_t sourceID)
am_Error_e RoutingSender::removeSinkLookup(const am_sinkID_t sinkID)
{
SinkInterfaceMap::iterator iter = mMapSinkInterface.begin();
- mMapSinkInterface.find(sinkID);
+ iter=mMapSinkInterface.find(sinkID);
if (iter != mMapSinkInterface.end())
{
mMapSinkInterface.erase(iter);
@@ -334,7 +371,7 @@ am_Error_e RoutingSender::removeSinkLookup(const am_sinkID_t sinkID)
am_Error_e RoutingSender::removeCrossfaderLookup(const am_crossfaderID_t crossfaderID)
{
CrossfaderInterfaceMap::iterator iter = mMapCrossfaderInterface.begin();
- mMapCrossfaderInterface.find(crossfaderID);
+ iter=mMapCrossfaderInterface.find(crossfaderID);
if (iter != mMapCrossfaderInterface.end())
{
mMapCrossfaderInterface.erase(iter);
@@ -345,6 +382,42 @@ am_Error_e RoutingSender::removeCrossfaderLookup(const am_crossfaderID_t crossfa
}
+am_Error_e RoutingSender::removeHandle(const am_Handle_s& handle)
+{
+ if(mlistActiveHandles.erase(handle)) return E_OK;
+ return E_UNKNOWN;
+}
+
+am_Error_e RoutingSender::getListHandles(std::vector<am_Handle_s> & listHandles) const
+{
+ std::copy(mlistActiveHandles.begin(),mlistActiveHandles.end(),std::back_inserter(listHandles));
+ return E_OK;
+}
+
+am_Handle_s RoutingSender::createHandle(const am_Handle_e handle)
+{
+ am_Handle_s newHandle;
+ newHandle.handle=++mHandleCount; //todo: handle overflows here...
+ newHandle.handleType=handle;
+ mlistActiveHandles.insert(newHandle);
+ return newHandle;
+}
+
+void RoutingSender::unloadLibraries(void)
+{
+ std::vector<void*>::iterator iterator=mListLibraryHandles.begin();
+ for(;iterator<mListLibraryHandles.end();++iterator)
+ {
+ dlclose(*iterator);
+ }
+ mListLibraryHandles.clear();
+}
+
+
+
+
+
+
diff --git a/AudioManagerDaemon/src/main.cpp b/AudioManagerDaemon/src/main.cpp
index 3aa5f8b..59682eb 100644
--- a/AudioManagerDaemon/src/main.cpp
+++ b/AudioManagerDaemon/src/main.cpp
@@ -8,6 +8,7 @@
//todo: add debug commandline option to allow to use other than memory database
//todo: make real daemon out of it- systemd conform
+#include "control/ControlReceiveInterface.h"
#include "RoutingReceiver.h"
#include "CommandReceiver.h"
#include "ControlReceiver.h"
@@ -19,7 +20,9 @@
#include <dbus/dbus.h>
#include <dlt/dlt.h>
-DLT_DECLARE_CONTEXT(AudioManager);
+DLT_DECLARE_CONTEXT(AudioManager)
+
+#define UNIT_TEST 1
using namespace am;
@@ -31,12 +34,13 @@ int main(int argc, char *argv[])
DatabaseHandler iDatabaseHandler;
DBusWrapper iDBusWrapper;
- CommandReceiver iCommandReceiver(&iDatabaseHandler,&iDBusWrapper);
- RoutingReceiver iRoutingReceiver;
- ControlReceiver iControlReceiver(&iDatabaseHandler);
RoutingSender iRoutingSender;
CommandSender iCommandSender;
-
+ ControlSender iControlSender;
+ Observer iObserver(&iCommandSender, &iRoutingSender);
+ CommandReceiver iCommandReceiver(&iDatabaseHandler,&iDBusWrapper,&iControlSender);
+ RoutingReceiver iRoutingReceiver(&iDatabaseHandler,&iRoutingSender,&iControlSender);
+ ControlReceiver iControlReceiver(&iDatabaseHandler, &iRoutingSender);
iCommandSender.startupInterface(&iCommandReceiver);
diff --git a/AudioManagerDaemon/test/CMakeLists.txt b/AudioManagerDaemon/test/CMakeLists.txt
index 1431ee5..3bcc777 100644
--- a/AudioManagerDaemon/test/CMakeLists.txt
+++ b/AudioManagerDaemon/test/CMakeLists.txt
@@ -11,51 +11,7 @@
cmake_minimum_required(VERSION 2.6)
-PROJECT(AudioManagerDeamon)
-
-set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xlinker -export-dynamic")
-set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic")
-set(CMAKE_CXX_FLAGS "-g -pipe -g -Wall -W -D_REENTRANT")
-
-##todo only when dbus needed!
-set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}")
-
-set(STD_INCLUDE_DIRS "/usr/include")
-set(DBUS_FOLDER ${CMAKE_SOURCE_DIR}/../../dbusInterfaces)
-set(AUDIO_INCLUDES_FOLDER ${CMAKE_SOURCE_DIR}/../../includes)
-set(DBUS_INCLUDES_FOLDER ${CMAKE_SOURCE_DIR}/../../dbusIncludes)
-set(INCLUDES_FOLDER ${CMAKE_SOURCE_DIR}/../include)
-set(EXECUTABLE_OUTPUT_PATH ../../../test/)
-
-file(MAKE_DIRECTORY ${DOC_OUTPUT_PATH})
-
-FIND_PACKAGE(PkgConfig)
-pkg_check_modules(SQLITE REQUIRED sqlite3)
-pkg_check_modules(DLT REQUIRED automotive-dlt)
-
-file(GLOB DATABASE_SRCS_CXX "../src/DatabaseHandler.cpp")
-
-INCLUDE_DIRECTORIES(
- ${CMAKE_SOURCE_DIR}
- ${STD_INCLUDE_DIRS}
- ${CMAKE_CURRENT_BINARY_DIR}
- ${DLT_INCLUDE_DIRS}
- ${DBUS_INCLUDE_DIR}
- ${AUDIO_INCLUDES_FOLDER}
- ${INCLUDES_FOLDER}
- ${DBUS_ARCH_INCLUDE_DIR}
- ${DBUS_INCLUDES_FOLDER}
-)
-
-ADD_EXECUTABLE(databasetest databasetest.cpp ${DATABASE_SRCS_CXX})
-
-TARGET_LINK_LIBRARIES(databasetest
- ${SQLITE_LIBRARIES}
- ${DLT_LIBRARIES}
- ${DBUS_LIBRARY}
- ${CMAKE_THREAD_LIBS_INIT}
- gtest
-)
-
-
+add_subdirectory (database)
+add_subdirectory (routingInterface)
+add_subdirectory (controlInterface)
diff --git a/AudioManagerDaemon/test/CommandInterfaceBackdoor.h b/AudioManagerDaemon/test/CommandInterfaceBackdoor.h
new file mode 100644
index 0000000..10bb135
--- /dev/null
+++ b/AudioManagerDaemon/test/CommandInterfaceBackdoor.h
@@ -0,0 +1,27 @@
+/*
+ * CommandInterfaceBackdoor.h
+ *
+ * Created on: Dec 10, 2011
+ * Author: christian
+ */
+
+#ifndef COMMANDINTERFACEBACKDOOR_H_
+#define COMMANDINTERFACEBACKDOOR_H_
+
+#include "CommandSender.h"
+
+using namespace am;
+
+class CommandSender;
+
+class CommandInterfaceBackdoor {
+public:
+ CommandInterfaceBackdoor();
+ virtual ~CommandInterfaceBackdoor();
+ bool unloadPlugins(CommandSender *CommandSender);
+ bool injectInterface(CommandSender* CommandSender, CommandSendInterface* CommandSendInterface);
+};
+
+//definitions are in CommonFunctions.cpp!
+
+#endif /* COMMANDINTERFACEBACKDOOR_H_ */
diff --git a/AudioManagerDaemon/test/CommonFunctions.cpp b/AudioManagerDaemon/test/CommonFunctions.cpp
new file mode 100644
index 0000000..734bbbc
--- /dev/null
+++ b/AudioManagerDaemon/test/CommonFunctions.cpp
@@ -0,0 +1,368 @@
+/*
+ * CommonFunctions.cpp
+ *
+ * Created on: Dec 10, 2011
+ * Author: christian
+ */
+
+#include "CommonFunctions.h"
+#include "CommandInterfaceBackdoor.h"
+#include "RoutingInterfaceBackdoor.h"
+#include "ControlInterfaceBackdoor.h"
+
+CommandInterfaceBackdoor::CommandInterfaceBackdoor() {
+}
+CommandInterfaceBackdoor::~CommandInterfaceBackdoor() {
+}
+
+bool CommandInterfaceBackdoor::unloadPlugins(CommandSender *CommandSender) {
+ assert(CommandSender != NULL);
+ CommandSender->unloadLibraries();
+ CommandSender->mListInterfaces.clear();
+ if (CommandSender->mListInterfaces.empty())
+ return true;
+ return false;
+}
+
+bool CommandInterfaceBackdoor::injectInterface(CommandSender *CommandSender,
+ CommandSendInterface *CommandSendInterface) {
+ assert(CommandSender != NULL);
+ assert(CommandSendInterface != NULL);
+ CommandSender->mListInterfaces.push_back(CommandSendInterface);
+ return true; //todo: check if it worked
+}
+
+RoutingInterfaceBackdoor::RoutingInterfaceBackdoor() {
+}
+RoutingInterfaceBackdoor::~RoutingInterfaceBackdoor() {
+}
+
+bool RoutingInterfaceBackdoor::unloadPlugins(RoutingSender *RoutingSender) {
+ assert(RoutingSender != NULL);
+ RoutingSender->unloadLibraries();
+ RoutingSender->mListInterfaces.clear();
+ if (RoutingSender->mListInterfaces.empty())
+ return true;
+ return false;
+}
+
+bool RoutingInterfaceBackdoor::injectInterface(RoutingSender *RoutingSender,
+ RoutingSendInterface *newInterface, const std::string& busname) {
+ assert(RoutingSender != NULL);
+ assert(newInterface != NULL);
+
+ RoutingSender::InterfaceNamePairs newInterfacePair;
+ newInterfacePair.routingInterface = newInterface;
+ newInterfacePair.busName = busname;
+ RoutingSender->mListInterfaces.push_back(newInterfacePair);
+ return true; //todo: check if it worked
+}
+
+ControlInterfaceBackdoor::ControlInterfaceBackdoor() {}
+
+ControlInterfaceBackdoor::~ControlInterfaceBackdoor() {}
+
+bool ControlInterfaceBackdoor::replaceController(ControlSender *controlSender, ControlSendInterface *newController)
+{
+ controlSender->mController=newController;
+ return true;
+}
+
+
+int GetRandomNumber(int nLow, int nHigh) {
+ return (rand() % (nHigh - nLow + 1)) + nLow;
+}
+
+bool equalSoundProperty(const am_SoundProperty_s a,
+ const am_SoundProperty_s b) {
+ return (a.type == b.type && a.value == b.value);
+}
+
+bool equalMainSoundProperty(const am_MainSoundProperty_s a,
+ const am_MainSoundProperty_s b) {
+ return (a.type == b.type && a.value == b.value);
+}
+
+bool equalRoutingElement(const am_RoutingElement_s a,
+ const am_RoutingElement_s b) {
+ return (a.connectionFormat == b.connectionFormat && a.domainID == b.domainID
+ && a.sinkID == b.sinkID && a.sourceID == b.sourceID);
+}
+
+bool equalClassProperties(const am_ClassProperty_s a,
+ const am_ClassProperty_s b) {
+ return (a.classProperty == b.classProperty && a.value == b.value);
+}
+
+std::string int2string(int i) {
+ std::stringstream out;
+ out << i;
+ return out.str();
+}
+
+bool CommonFunctions::compareSource(
+ std::vector<am_Source_s>::iterator listIterator,
+ const am_Source_s& sourceData) {
+ return (listIterator->available.availability
+ == sourceData.available.availability)
+ && (listIterator->available.availabilityReason
+ == sourceData.available.availabilityReason)
+ && (listIterator->sourceClassID == sourceData.sourceClassID)
+ && (listIterator->domainID == sourceData.domainID)
+ && (listIterator->interruptState == sourceData.interruptState)
+ && (listIterator->visible == sourceData.visible)
+ && (listIterator->name.compare(sourceData.name) == 0)
+ && (listIterator->volume == sourceData.volume)
+ && std::equal(listIterator->listConnectionFormats.begin(),
+ listIterator->listConnectionFormats.end(),
+ sourceData.listConnectionFormats.begin())
+ && std::equal(listIterator->listMainSoundProperties.begin(),
+ listIterator->listMainSoundProperties.end(),
+ sourceData.listMainSoundProperties.begin(),
+ equalMainSoundProperty)
+ && std::equal(listIterator->listSoundProperties.begin(),
+ listIterator->listSoundProperties.end(),
+ sourceData.listSoundProperties.begin(), equalSoundProperty);
+}
+
+bool CommonFunctions::compareSink(std::vector<am_Sink_s>::iterator listIterator,
+ const am_Sink_s& sinkData) {
+ return (listIterator->available.availability
+ == sinkData.available.availability)
+ && (listIterator->available.availabilityReason
+ == sinkData.available.availabilityReason)
+ && (listIterator->sinkClassID == sinkData.sinkClassID)
+ && (listIterator->domainID == sinkData.domainID)
+ && (listIterator->mainVolume == sinkData.mainVolume)
+ && (listIterator->muteState == sinkData.muteState)
+ && (listIterator->visible == sinkData.visible)
+ && (listIterator->name.compare(sinkData.name) == 0)
+ && (listIterator->volume == sinkData.volume)
+ && std::equal(listIterator->listConnectionFormats.begin(),
+ listIterator->listConnectionFormats.end(),
+ sinkData.listConnectionFormats.begin())
+ && std::equal(listIterator->listMainSoundProperties.begin(),
+ listIterator->listMainSoundProperties.end(),
+ sinkData.listMainSoundProperties.begin(),
+ equalMainSoundProperty)
+ && std::equal(listIterator->listSoundProperties.begin(),
+ listIterator->listSoundProperties.end(),
+ sinkData.listSoundProperties.begin(), equalSoundProperty);
+}
+
+bool CommonFunctions::compareGateway(
+ std::vector<am_Gateway_s>::iterator listIterator,
+ const am_Gateway_s& gatewayData) {
+ return (listIterator->name.compare(gatewayData.name) == 0)
+ && (listIterator->sinkID == gatewayData.sinkID)
+ && (listIterator->sourceID == gatewayData.sourceID)
+ && (listIterator->controlDomainID == gatewayData.controlDomainID)
+ && (listIterator->domainSinkID == gatewayData.domainSinkID)
+ && (listIterator->domainSourceID == gatewayData.domainSourceID)
+ && std::equal(listIterator->convertionMatrix.begin(),
+ listIterator->convertionMatrix.end(),
+ gatewayData.convertionMatrix.begin())
+ && std::equal(listIterator->listSourceFormats.begin(),
+ listIterator->listSourceFormats.end(),
+ gatewayData.listSourceFormats.begin())
+ && std::equal(listIterator->listSinkFormats.begin(),
+ listIterator->listSinkFormats.end(),
+ gatewayData.listSinkFormats.begin());
+}
+
+bool CommonFunctions::compareGateway1(const am_Gateway_s gateway1,
+ const am_Gateway_s gatewayData) {
+ return (gateway1.name.compare(gatewayData.name) == 0)
+ && (gateway1.sinkID == gatewayData.sinkID)
+ && (gateway1.sourceID == gatewayData.sourceID)
+ && (gateway1.controlDomainID == gatewayData.controlDomainID)
+ && (gateway1.domainSinkID == gatewayData.domainSinkID)
+ && (gateway1.domainSourceID == gatewayData.domainSourceID)
+ && std::equal(gateway1.convertionMatrix.begin(),
+ gateway1.convertionMatrix.end(),
+ gatewayData.convertionMatrix.begin())
+ && std::equal(gateway1.listSourceFormats.begin(),
+ gateway1.listSourceFormats.end(),
+ gatewayData.listSourceFormats.begin())
+ && std::equal(gateway1.listSinkFormats.begin(),
+ gateway1.listSinkFormats.end(),
+ gatewayData.listSinkFormats.begin());
+}
+
+bool CommonFunctions::compareSinkMainSink(
+ std::vector<am_SinkType_s>::iterator listIterator,
+ const std::vector<am_Sink_s>& sinkList) {
+ std::vector<am_Sink_s>::const_iterator sinkListIterator = sinkList.begin();
+ for (; sinkListIterator < sinkList.end(); ++sinkListIterator) {
+ if (listIterator->sinkID == sinkListIterator->sinkID) {
+ return (listIterator->name.compare(sinkListIterator->name) == 0)
+ && (listIterator->availability.availability
+ == sinkListIterator->available.availability)
+ && (listIterator->availability.availabilityReason
+ == sinkListIterator->available.availabilityReason)
+ && (listIterator->muteState == sinkListIterator->muteState)
+ && (listIterator->volume == sinkListIterator->mainVolume)
+ && (listIterator->sinkClassID
+ == sinkListIterator->sinkClassID);
+ }
+ }
+ return false;
+}
+
+bool CommonFunctions::compareSinkMainSource(
+ std::vector<am_SourceType_s>::iterator listIterator,
+ const std::vector<am_Source_s>& sourceList) {
+ std::vector<am_Source_s>::const_iterator sinkListIterator =
+ sourceList.begin();
+ for (; sinkListIterator < sourceList.end(); ++sinkListIterator) {
+ if (listIterator->sourceID == sinkListIterator->sourceID) {
+ return (listIterator->name.compare(sinkListIterator->name) == 0)
+ && (listIterator->availability.availability
+ == sinkListIterator->available.availability)
+ && (listIterator->availability.availabilityReason
+ == sinkListIterator->available.availabilityReason)
+ && (listIterator->sourceClassID
+ == sinkListIterator->sourceClassID);
+ }
+ }
+ return false;
+}
+
+std::vector<am_ConnectionFormat_e> CommonFunctions::getStandardConnectionFormatList() {
+ std::vector < am_ConnectionFormat_e > list;
+ list.push_back(CF_ANALOG);
+ list.push_back(CF_STEREO);
+ return list;
+}
+
+std::vector<am_SoundProperty_s> CommonFunctions::getStandardSoundPropertyList() {
+ std::vector < am_SoundProperty_s > soundPropertyList;
+ am_SoundProperty_s soundProperty;
+ soundProperty.type = SP_BASS;
+ soundProperty.value = 23;
+ soundPropertyList.push_back(soundProperty);
+ soundProperty.type = SP_MID;
+ soundProperty.value = 2;
+ soundPropertyList.push_back(soundProperty);
+ return soundPropertyList;
+}
+
+std::vector<am_MainSoundProperty_s> CommonFunctions::getStandardMainSoundPropertyList() {
+ std::vector < am_MainSoundProperty_s > mainSoundPropertyList;
+ am_MainSoundProperty_s mainSoundProperty;
+ mainSoundProperty.type = MSP_NAVIGATION_OFFSET;
+ mainSoundProperty.value = 23;
+ mainSoundPropertyList.push_back(mainSoundProperty);
+ mainSoundProperty.type = MSP_TEST;
+ mainSoundProperty.value = 3;
+ mainSoundPropertyList.push_back(mainSoundProperty);
+ return mainSoundPropertyList;
+}
+
+void CommonFunctions::createSink(am_Sink_s& sink) const {
+ sink.name = "AnySink";
+ sink.domainID = 4;
+ sink.available.availability = A_AVAILABLE;
+ sink.available.availabilityReason = AR_NEWMEDIA;
+ sink.sinkClassID = 1;
+ sink.listConnectionFormats = getStandardConnectionFormatList();
+ sink.listSoundProperties = getStandardSoundPropertyList();
+ sink.listMainSoundProperties = getStandardMainSoundPropertyList();
+ sink.mainVolume = 12;
+ sink.muteState = MS_UNMUTED;
+ sink.visible = true;
+ sink.volume = 23;
+ sink.sinkID = 0;
+}
+
+void CommonFunctions::createSource(am_Source_s& source) const {
+ source.name = "AnySource";
+ source.domainID = 4;
+ source.available.availability = A_AVAILABLE;
+ source.available.availabilityReason = AR_NEWMEDIA;
+ source.sourceClassID = 1;
+ source.listConnectionFormats = getStandardConnectionFormatList();
+ source.listSoundProperties = getStandardSoundPropertyList();
+ source.listMainSoundProperties = getStandardMainSoundPropertyList();
+ source.interruptState = IS_OFF;
+ source.visible = true;
+ source.volume = 23;
+ source.sourceID = 0;
+ source.sourceState = SS_ON;
+}
+
+void CommonFunctions::createDomain(am_Domain_s & domain) const {
+
+ domain.domainID = 0;
+ domain.name = "AnyDomain";
+ domain.nodename = "AnyNode";
+ domain.busname = "AnyBusname";
+ domain.complete = true;
+ domain.early = true;
+ domain.state = DS_CONTROLLED;
+}
+
+void CommonFunctions::createGateway(am_Gateway_s & gateway) {
+ gateway.name = "AnyGateway";
+ gateway.sinkID = 1;
+ gateway.sourceID = 2;
+ gateway.controlDomainID = 1;
+ gateway.domainSinkID = 3;
+ gateway.domainSourceID = 4;
+ gateway.convertionMatrix = getStandardConvertionMatrix();
+ gateway.listSourceFormats = getStandardConnectionFormatList();
+ gateway.listSinkFormats = getStandardConnectionFormatList();
+ gateway.gatewayID = 0;
+
+}
+
+void CommonFunctions::createConnection(am_Connection_s & connection) const {
+ connection.connectionID = 0;
+ connection.sinkID = 1;
+ connection.sourceID = 2;
+ connection.delay = -1;
+ connection.connectionFormat = CF_ANALOG;
+}
+
+void CommonFunctions::createMainConnection(am_MainConnection_s & mainConnection,
+ am_Route_s route) const {
+ mainConnection.connectionID = 0;
+ mainConnection.connectionState = CS_CONNECTED;
+ mainConnection.route = route;
+ mainConnection.delay = -1;
+}
+
+std::vector<bool> CommonFunctions::getStandardConvertionMatrix() {
+ std::vector<bool> convMatrix;
+ convMatrix.push_back(true);
+ convMatrix.push_back(false);
+ convMatrix.push_back(true);
+ convMatrix.push_back(false);
+ convMatrix.push_back(true);
+ convMatrix.push_back(true);
+ return convMatrix;
+}
+
+void CommonFunctions::connectionList2RoutingList(
+ std::vector<am_RoutingElement_s> & routingList,
+ const std::vector<am_Connection_s>& connectionList) {
+ am_RoutingElement_s routingElement;
+ std::vector<am_Connection_s>::const_iterator cIterator =
+ connectionList.begin();
+ for (; cIterator < connectionList.end(); ++cIterator) {
+ routingElement.sinkID = cIterator->sinkID;
+ routingElement.sourceID = cIterator->sourceID;
+ routingElement.connectionFormat = cIterator->connectionFormat;
+ routingElement.domainID = 4; //todo: make this test read out the real value
+ routingList.push_back(routingElement);
+ }
+}
+
+
+
+
+
+
+
+
+
diff --git a/AudioManagerDaemon/test/CommonFunctions.h b/AudioManagerDaemon/test/CommonFunctions.h
new file mode 100644
index 0000000..b7c3a40
--- /dev/null
+++ b/AudioManagerDaemon/test/CommonFunctions.h
@@ -0,0 +1,74 @@
+/*
+ * CommonHeaders.h
+ *
+ * Created on: Dec 10, 2011
+ * Author: christian
+ */
+
+#ifndef COMMONHEADERS_H_
+#define COMMONHEADERS_H_
+
+#include <gtest/gtest.h>
+#include "DatabaseHandler.h"
+
+using namespace am;
+
+class CommonFunctions
+{
+public:
+
+ static std::vector<am_ConnectionFormat_e> getStandardConnectionFormatList();
+ static std::vector<am_SoundProperty_s> getStandardSoundPropertyList();
+ static std::vector<am_MainSoundProperty_s> getStandardMainSoundPropertyList();
+ static std::vector<bool> getStandardConvertionMatrix();
+ bool compareSource(std::vector<am_Source_s>::iterator listIterator, const am_Source_s& sourceData);
+ bool compareSink(std::vector<am_Sink_s>::iterator listIterator, const am_Sink_s& sinkData);
+ bool compareGateway(std::vector<am_Gateway_s>::iterator listIterator, const am_Gateway_s& gatewayData);
+ bool compareGateway1(const am_Gateway_s gateway1, const am_Gateway_s gatewayData);
+ bool compareSinkMainSink(std::vector<am_SinkType_s>::iterator listIterator, const std::vector<am_Sink_s>& sinkList);
+ bool compareSinkMainSource(std::vector<am_SourceType_s>::iterator listIterator, const std::vector<am_Source_s>& sourceList);
+ void createSink(am_Sink_s& sink) const;
+ void createSource(am_Source_s& source) const ;
+ void createDomain(am_Domain_s& domain) const;
+ void createGateway(am_Gateway_s& gateway);
+ void createConnection(am_Connection_s& connection) const ;
+ void createMainConnection(am_MainConnection_s& mainConnection, am_Route_s route) const;
+ void connectionList2RoutingList(std::vector<am_RoutingElement_s>& routingList, const std::vector<am_Connection_s>& connectionList);
+
+ struct sortBySinkID
+ {
+ bool operator()(const am_RoutingElement_s & a, const am_RoutingElement_s & b) const
+ {
+ return (a.sinkID < b.sinkID);
+ }
+ };
+
+ struct sortByConnectionFormat
+ {
+ bool operator()(const am_ConnectionFormat_e & a, const am_ConnectionFormat_e & b) const
+ {
+ return (a < b);
+ }
+ };
+
+ struct sortByMainSoundProperty
+ {
+ bool operator()(const am_MainSoundProperty_s & a, const am_MainSoundProperty_s & b) const
+ {
+ return (a.type > b.type);
+ }
+ };
+
+ struct sortBySoundProperty
+ {
+ bool operator()(const am_SoundProperty_s & a, const am_SoundProperty_s & b) const
+ {
+ return (a.type < b.type);
+ }
+ };
+};
+
+
+
+
+#endif /* COMMONHEADERS_H_ */
diff --git a/AudioManagerDaemon/test/ControlInterfaceBackdoor.h b/AudioManagerDaemon/test/ControlInterfaceBackdoor.h
new file mode 100644
index 0000000..b6a5337
--- /dev/null
+++ b/AudioManagerDaemon/test/ControlInterfaceBackdoor.h
@@ -0,0 +1,25 @@
+/*
+ * ControlInterfaceBackdoor.h
+ *
+ * Created on: Dec 11, 2011
+ * Author: christian
+ */
+
+#ifndef CONTROLINTERFACEBACKDOOR_H_
+#define CONTROLINTERFACEBACKDOOR_H_
+
+#include "control/ControlSendInterface.h"
+#include "ControlSender.h"
+
+class ControlSender;
+
+using namespace am;
+
+class ControlInterfaceBackdoor {
+public:
+ ControlInterfaceBackdoor();
+ virtual ~ControlInterfaceBackdoor();
+ bool replaceController(ControlSender *controlSender, ControlSendInterface *newController);
+};
+
+#endif /* CONTROLINTERFACEBACKDOOR_H_ */
diff --git a/AudioManagerDaemon/test/RoutingInterfaceBackdoor.h b/AudioManagerDaemon/test/RoutingInterfaceBackdoor.h
new file mode 100644
index 0000000..bd4a5ca
--- /dev/null
+++ b/AudioManagerDaemon/test/RoutingInterfaceBackdoor.h
@@ -0,0 +1,27 @@
+/*
+ * RoutingInterfaceBackdoor.h
+ *
+ * Created on: Dec 10, 2011
+ * Author: christian
+ */
+
+#ifndef ROUTINGINTERFACEBACKDOOR_H_
+#define ROUTINGINTERFACEBACKDOOR_H_
+
+#include "RoutingSender.h"
+
+using namespace am;
+
+class RoutingSender;
+
+class RoutingInterfaceBackdoor {
+public:
+ RoutingInterfaceBackdoor();
+ virtual ~RoutingInterfaceBackdoor();
+ bool unloadPlugins(RoutingSender *RoutingSender);
+ bool injectInterface(RoutingSender *RoutingSender, RoutingSendInterface *newInterface, const std::string& busname);
+};
+
+//definitions are in CommonFunctions.cpp!
+
+#endif /* ROUTINGINTERFACEBACKDOOR_H_ */
diff --git a/AudioManagerDaemon/test/controlInterface/CMakeLists.txt b/AudioManagerDaemon/test/controlInterface/CMakeLists.txt
new file mode 100644
index 0000000..bd09acd
--- /dev/null
+++ b/AudioManagerDaemon/test/controlInterface/CMakeLists.txt
@@ -0,0 +1,79 @@
+#
+# Copyright (C) 2011, BMW AG
+#
+# GeniviAudioMananger ControlInterfaceTest
+#
+# \file CMakeLists.txt
+#
+# \date 20-Oct-2011 3:42:04 PM
+# \author Christian Mueller (christian.ei.mueller@bmw.de)
+#
+# \section License
+# GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+# Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+#
+# This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+# You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+# Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+# Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+# As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+# Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+#
+
+cmake_minimum_required(VERSION 2.6)
+
+PROJECT(controlInterfacetest)
+
+set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -rdynamic")
+#set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic")
+set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -DUNIT_TEST=1")
+
+set(STD_INCLUDE_DIRS "/usr/include")
+set(DBUS_FOLDER ${CMAKE_SOURCE_DIR}/../../../dbusInterfaces)
+set(AUDIO_INCLUDES_FOLDER ${CMAKE_SOURCE_DIR}/../../../includes)
+set(DBUS_INCLUDES_FOLDER ${CMAKE_SOURCE_DIR}/../../../../dbusIncludes)
+set(INCLUDES_FOLDER ${CMAKE_SOURCE_DIR}/../../include)
+set(EXECUTABLE_OUTPUT_PATH ../../../../test/)
+
+FIND_PACKAGE(PkgConfig)
+pkg_check_modules(SQLITE REQUIRED sqlite3)
+pkg_check_modules(DLT REQUIRED automotive-dlt)
+
+INCLUDE_DIRECTORIES(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${AUDIO_INCLUDES_FOLDER}
+ ${DBUS_ARCH_INCLUDE_DIR}
+ ${DBUS_INCLUDES_FOLDER}
+ ${CMAKE_SOURCE_DIR}
+ ${STD_INCLUDE_DIRS}
+ ${DLT_INCLUDE_DIRS}
+ ${DBUS_INCLUDE_DIR}
+ ${INCLUDES_FOLDER}
+)
+
+file(GLOB CONTROL_INTERFACE_SRCS_CXX
+ "../../src/DatabaseHandler.cpp"
+ "../../src/Observer.cpp"
+ "../../src/RoutingSender.cpp"
+ "../../src/RoutingReceiver.cpp"
+ "../../src/CommandSender.cpp"
+ "../../src/ControlReceiver.cpp"
+ "../../src/ControlSender.cpp"
+ "../CommonFunctions.cpp"
+ "*.cpp"
+)
+
+ADD_EXECUTABLE(controlInterfaceTest ${CONTROL_INTERFACE_SRCS_CXX})
+
+TARGET_LINK_LIBRARIES(controlInterfaceTest
+ ${SQLITE_LIBRARIES}
+ ${DLT_LIBRARIES}
+ ${DBUS_LIBRARY}
+ ${CMAKE_THREAD_LIBS_INIT}
+ gtest
+ gmock
+)
+
+
+
diff --git a/AudioManagerDaemon/test/controlInterface/MockControlInterface.h b/AudioManagerDaemon/test/controlInterface/MockControlInterface.h
new file mode 100644
index 0000000..28d26af
--- /dev/null
+++ b/AudioManagerDaemon/test/controlInterface/MockControlInterface.h
@@ -0,0 +1,103 @@
+/*
+ * MockRoutingInterface.h
+ *
+ * Created on: Dec 10, 2011
+ * Author: christian
+ */
+
+#ifndef MOCKROUTINGINTERFACE_H_
+#define MOCKROUTINGINTERFACE_H_
+
+#include <control/ControlSendInterface.h>
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+namespace am {
+
+class MockControlSendInterface : public ControlSendInterface {
+ public:
+ MOCK_METHOD1(startupController,
+ am_Error_e(ControlReceiveInterface* controlreceiveinterface));
+ MOCK_METHOD0(stopController,
+ am_Error_e());
+ MOCK_METHOD0(hookAllPluginsLoaded,
+ void());
+ MOCK_METHOD3(hookUserConnectionRequest,
+ am_Error_e(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t& mainConnectionID));
+ MOCK_METHOD1(hookUserDisconnectionRequest,
+ am_Error_e(const am_mainConnectionID_t connectionID));
+ MOCK_METHOD2(hookUserSetMainSinkSoundProperty,
+ am_Error_e(const am_sinkID_t sinkID, const am_MainSoundProperty_s& soundProperty));
+ MOCK_METHOD2(hookUserSetMainSourceSoundProperty,
+ am_Error_e(const am_sourceID_t sourceID, const am_MainSoundProperty_s& soundProperty));
+ MOCK_METHOD1(hookUserSetSystemProperty,
+ am_Error_e(const am_SystemProperty_s& property));
+ MOCK_METHOD2(hookUserVolumeChange,
+ am_Error_e(const am_sinkID_t SinkID, const am_mainVolume_t newVolume));
+ MOCK_METHOD2(hookUserVolumeStep,
+ am_Error_e(const am_sinkID_t SinkID, const int16_t increment));
+ MOCK_METHOD2(hookUserSetSinkMuteState,
+ am_Error_e(const am_sinkID_t sinkID, const am_MuteState_e muteState));
+ MOCK_METHOD2(hookSystemRegisterDomain,
+ am_Error_e(const am_Domain_s& domainData, am_domainID_t& domainID));
+ MOCK_METHOD1(hookSystemDeregisterDomain,
+ am_Error_e(const am_domainID_t domainID));
+ MOCK_METHOD1(hookSystemDomainRegistrationComplete,
+ void(const am_domainID_t domainID));
+ MOCK_METHOD2(hookSystemRegisterSink,
+ am_Error_e(const am_Sink_s& sinkData, am_sinkID_t& sinkID));
+ MOCK_METHOD1(hookSystemDeregisterSink,
+ am_Error_e(const am_sinkID_t sinkID));
+ MOCK_METHOD2(hookSystemRegisterSource,
+ am_Error_e(const am_Source_s& sourceData, am_sourceID_t& sourceID));
+ MOCK_METHOD1(hookSystemDeregisterSource,
+ am_Error_e(const am_sourceID_t sourceID));
+ MOCK_METHOD2(hookSystemRegisterGateway,
+ am_Error_e(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID));
+ MOCK_METHOD1(hookSystemDeregisterGateway,
+ am_Error_e(const am_gatewayID_t gatewayID));
+ MOCK_METHOD2(hookSystemRegisterCrossfader,
+ am_Error_e(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID));
+ MOCK_METHOD1(hookSystemDeregisterCrossfader,
+ am_Error_e(const am_crossfaderID_t crossfaderID));
+ MOCK_METHOD3(hookSystemSinkVolumeTick,
+ void(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume));
+ MOCK_METHOD3(hookSystemSourceVolumeTick,
+ void(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume));
+ MOCK_METHOD2(hookSystemInterruptStateChange,
+ void(const am_sourceID_t sourceID, const am_InterruptState_e interruptState));
+ MOCK_METHOD2(hookSystemSinkAvailablityStateChange,
+ void(const am_sinkID_t sinkID, const am_Availability_s& availability));
+ MOCK_METHOD2(hookSystemSourceAvailablityStateChange,
+ void(const am_sourceID_t sourceID, const am_Availability_s& availability));
+ MOCK_METHOD2(hookSystemDomainStateChange,
+ void(const am_domainID_t domainID, const am_DomainState_e state));
+ MOCK_METHOD1(hookSystemReceiveEarlyData,
+ void(const std::vector<am_EarlyData_s>& data));
+ MOCK_METHOD1(hookSystemSpeedChange,
+ void(const am_speed_t speed));
+ MOCK_METHOD2(hookSystemTimingInformationChanged,
+ void(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time));
+ MOCK_METHOD2(cbAckConnect,
+ void(const am_Handle_s handle, const am_Error_e errorID));
+ MOCK_METHOD2(cbAckDisconnect,
+ void(const am_Handle_s handle, const am_Error_e errorID));
+ MOCK_METHOD3(cbAckCrossFade,
+ void(const am_Handle_s handle, const am_HotSink_e hostsink, const am_Error_e error));
+ MOCK_METHOD3(cbAckSetSinkVolumeChange,
+ void(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error));
+ MOCK_METHOD3(cbAckSetSourceVolumeChange,
+ void(const am_Handle_s handle, const am_volume_t voulme, const am_Error_e error));
+ MOCK_METHOD2(cbAckSetSourceState,
+ void(const am_Handle_s handle, const am_Error_e error));
+ MOCK_METHOD2(cbAckSetSourceSoundProperty,
+ void(const am_Handle_s handle, const am_Error_e error));
+ MOCK_METHOD2(cbAckSetSinkSoundProperty,
+ void(const am_Handle_s handle, const am_Error_e error));
+};
+
+} // namespace am
+
+
+
+#endif /* MOCKROUTINGINTERFACE_H_ */
diff --git a/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.cpp b/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.cpp
new file mode 100644
index 0000000..1a8c48b
--- /dev/null
+++ b/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.cpp
@@ -0,0 +1,82 @@
+/*
+ * routingInterfaceTest.cpp
+ *
+ * Created on: Dec 10, 2011
+ * Author: christian
+ */
+
+#include "controlInterfaceTest.h"
+
+using namespace am;
+
+using ::testing::Field;
+using ::testing::Property;
+using ::testing::Matcher;
+using ::testing::Pointee;
+using ::testing::AllOf;
+using ::testing::SafeMatcherCast;
+using ::testing::MatcherCast;
+using ::testing::DefaultValue;
+using ::testing::Eq;
+using ::testing::An;
+using ::testing::ElementsAreArray;
+using ::testing::ElementsAre;
+using ::testing::NotNull;
+using ::testing::Assign;
+using ::testing::SetArgReferee;
+using ::testing::DoAll;
+
+controlInterfaceTest::controlInterfaceTest()
+ :pDatabaseHandler(),
+ pRoutingSender(),
+ pCommandSender(),
+ pMockInterface(),
+ pControlSender(),
+ pRoutingInterfaceBackdoor(),
+ pCommandInterfaceBackdoor(),
+ pControlInterfaceBackdoor(),
+ pObserver(&pCommandSender,&pRoutingSender),
+ pControlReceiver(&pDatabaseHandler,&pRoutingSender),
+ pRoutingReceiver(&pDatabaseHandler,&pRoutingSender,&pControlSender)
+{
+ pDatabaseHandler.registerObserver(&pObserver);
+ pRoutingInterfaceBackdoor.unloadPlugins(&pRoutingSender);
+ pCommandInterfaceBackdoor.unloadPlugins(&pCommandSender);
+ pControlInterfaceBackdoor.replaceController(&pControlSender,&pMockInterface);
+
+}
+
+controlInterfaceTest::~controlInterfaceTest()
+{
+}
+
+void controlInterfaceTest::SetUp()
+{
+ DLT_REGISTER_APP("Rtest","RoutingInterfacetest");
+ DLT_REGISTER_CONTEXT(AudioManager,"Main","Main Context");
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("RoutingSendInterface Test started "));
+
+}
+
+void controlInterfaceTest::TearDown()
+{
+ DLT_UNREGISTER_CONTEXT(AudioManager);
+}
+
+TEST_F(controlInterfaceTest,registerDomain)
+{
+
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ pCF.createDomain(domain);
+ EXPECT_CALL(pMockInterface,hookSystemRegisterDomain(_,_)).WillRepeatedly(DoAll(SetArgReferee<1>(2),Return(E_OK)));
+ ASSERT_EQ(E_OK,pRoutingReceiver.registerDomain(domain,domainID));
+}
+
+
+int main(int argc, char **argv)
+{
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
+
diff --git a/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.h b/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.h
new file mode 100644
index 0000000..2b73af6
--- /dev/null
+++ b/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.h
@@ -0,0 +1,53 @@
+/*
+ * routingInterfaceTest.h
+ *
+ * Created on: Dec 10, 2011
+ * Author: christian
+ */
+
+#ifndef ROUTINGINTERFACETEST_H_
+#define ROUTINGINTERFACETEST_H_
+
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+#include <dlt/dlt.h>
+#include <algorithm>
+#include <string>
+#include <vector>
+#include <set>
+#include "MockControlInterface.h"
+#include "DatabaseHandler.h"
+#include "ControlReceiver.h"
+#include "ControlSender.h"
+#include "Observer.h"
+#include "RoutingReceiver.h"
+#include "../RoutingInterfaceBackdoor.h"
+#include "../CommandInterfaceBackdoor.h"
+#include "../CommonFunctions.h"
+
+DLT_DECLARE_CONTEXT(AudioManager)
+
+using namespace testing;
+using namespace am;
+
+class controlInterfaceTest : public Test{
+public:
+ controlInterfaceTest();
+ virtual ~controlInterfaceTest();
+ DatabaseHandler pDatabaseHandler;
+ RoutingSender pRoutingSender;
+ CommandSender pCommandSender;
+ MockControlSendInterface pMockInterface;
+ ControlSender pControlSender;
+ RoutingInterfaceBackdoor pRoutingInterfaceBackdoor;
+ CommandInterfaceBackdoor pCommandInterfaceBackdoor;
+ ControlInterfaceBackdoor pControlInterfaceBackdoor;
+ Observer pObserver;
+ ControlReceiver pControlReceiver;
+ RoutingReceiver pRoutingReceiver;
+ CommonFunctions pCF;
+ void SetUp();
+ void TearDown();
+};
+
+#endif /* ROUTINGINTERFACETEST_H_ */
diff --git a/AudioManagerDaemon/test/database/CMakeLists.txt b/AudioManagerDaemon/test/database/CMakeLists.txt
new file mode 100644
index 0000000..33e6f87
--- /dev/null
+++ b/AudioManagerDaemon/test/database/CMakeLists.txt
@@ -0,0 +1,73 @@
+#
+# Copyright (C) 2011, BMW AG
+#
+# GeniviAudioMananger DatbaseTest
+#
+# \file CMakeLists.txt
+#
+# \date 20-Oct-2011 3:42:04 PM
+# \author Christian Mueller (christian.ei.mueller@bmw.de)
+#
+# \section License
+# GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+# Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+#
+# This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+# You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+# Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+# Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+# As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+# Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+#
+
+cmake_minimum_required(VERSION 2.6)
+
+PROJECT(datbaseTest)
+
+set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -rdynamic")
+#set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic")
+set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -DUNIT_TEST=1")
+
+set(STD_INCLUDE_DIRS "/usr/include")
+set(DBUS_FOLDER ${CMAKE_SOURCE_DIR}/../../../dbusInterfaces)
+set(AUDIO_INCLUDES_FOLDER ${CMAKE_SOURCE_DIR}/../../../includes)
+set(DBUS_INCLUDES_FOLDER ${CMAKE_SOURCE_DIR}/../../../../dbusIncludes)
+set(INCLUDES_FOLDER ${CMAKE_SOURCE_DIR}/../../include)
+set(EXECUTABLE_OUTPUT_PATH ../../../../test/)
+
+FIND_PACKAGE(PkgConfig)
+pkg_check_modules(SQLITE REQUIRED sqlite3)
+pkg_check_modules(DLT REQUIRED automotive-dlt)
+
+INCLUDE_DIRECTORIES(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${AUDIO_INCLUDES_FOLDER}
+ ${DBUS_ARCH_INCLUDE_DIR}
+ ${DBUS_INCLUDES_FOLDER}
+ ${CMAKE_SOURCE_DIR}
+ ${STD_INCLUDE_DIRS}
+ ${DLT_INCLUDE_DIRS}
+ ${DBUS_INCLUDE_DIR}
+ ${INCLUDES_FOLDER}
+)
+
+file(GLOB DATABASE_SRCS_CXX
+ "../../src/DatabaseHandler.cpp"
+ "../../src/Observer.cpp"
+ "../../src/CommandSender.cpp"
+ "../../src/RoutingSender.cpp"
+ "../CommonFunctions.cpp"
+ "*.cpp"
+ )
+
+ADD_EXECUTABLE( databasetest ${DATABASE_SRCS_CXX})
+
+TARGET_LINK_LIBRARIES( databasetest
+ ${SQLITE_LIBRARIES}
+ ${DLT_LIBRARIES}
+ ${DBUS_LIBRARY}
+ ${CMAKE_THREAD_LIBS_INIT}
+ gtest
+ gmock
+) \ No newline at end of file
diff --git a/AudioManagerDaemon/test/databasetest.cpp b/AudioManagerDaemon/test/database/databaseTest.cpp
index 29f8e98..75fb389 100644
--- a/AudioManagerDaemon/test/databasetest.cpp
+++ b/AudioManagerDaemon/test/database/databaseTest.cpp
@@ -23,341 +23,17 @@
* THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
*/
-#include "databasetest.h"
+#include "databaseTest.h"
+#include "Observer.h"
-int GetRandomNumber(int nLow, int nHigh)
-{
- return (rand() % (nHigh - nLow + 1)) + nLow;
-}
-
-bool equalSoundProperty (const am_SoundProperty_s a, const am_SoundProperty_s b)
-{
- return (a.type==b.type && a.value == b.value);
-}
-
-bool equalMainSoundProperty (const am_MainSoundProperty_s a, const am_MainSoundProperty_s b)
-{
- return (a.type==b.type && a.value == b.value);
-}
-
-bool equalRoutingElement (const am_RoutingElement_s a,const am_RoutingElement_s b)
-{
- return (a.connectionFormat==b.connectionFormat && a.domainID==b.domainID && a.sinkID==b.sinkID && a.sourceID==b.sourceID);
-}
-
-bool equalClassProperties (const am_ClassProperty_s a,const am_ClassProperty_s b)
-{
- return (a.classProperty==b.classProperty && a.value==b.value);
-}
+using namespace am;
-void databaseTest::SetUp()
-{
- DLT_REGISTER_APP("Dtest","AudioManagerDeamon");
- DLT_REGISTER_CONTEXT(AudioManager,"Main","Main Context");
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Database Test started "));
-}
-
-void databaseTest::TearDown()
-{
- DLT_UNREGISTER_CONTEXT(AudioManager);
-}
-
-bool databaseTest::compareSource(std::vector<am_Source_s>::iterator listIterator, const am_Source_s& sourceData)
-{
- return (listIterator->available.availability == sourceData.available.availability)
- && (listIterator->available.availabilityReason == sourceData.available.availabilityReason)
- && (listIterator->sourceClassID == sourceData.sourceClassID)
- && (listIterator->domainID == sourceData.domainID)
- && (listIterator->interruptState == sourceData.interruptState)
- && (listIterator->visible == sourceData.visible)
- && (listIterator->name.compare(sourceData.name)==0)
- && (listIterator->volume == sourceData.volume)
- && std::equal(listIterator->listConnectionFormats.begin(),listIterator->listConnectionFormats.end(),sourceData.listConnectionFormats.begin())
- && std::equal(listIterator->listMainSoundProperties.begin(),listIterator->listMainSoundProperties.end(),sourceData.listMainSoundProperties.begin(),equalMainSoundProperty)
- && std::equal(listIterator->listSoundProperties.begin(),listIterator->listSoundProperties.end(),sourceData.listSoundProperties.begin(),equalSoundProperty);
-}
-
-bool databaseTest::compareSink(std::vector<am_Sink_s>::iterator listIterator, const am_Sink_s& sinkData)
-{
- return (listIterator->available.availability == sinkData.available.availability)
- && (listIterator->available.availabilityReason == sinkData.available.availabilityReason)
- && (listIterator->sinkClassID == sinkData.sinkClassID)
- && (listIterator->domainID == sinkData.domainID)
- && (listIterator->mainVolume == sinkData.mainVolume)
- && (listIterator->muteState == sinkData.muteState)
- && (listIterator->visible == sinkData.visible)
- && (listIterator->name.compare(sinkData.name)==0)
- && (listIterator->volume == sinkData.volume)
- && std::equal(listIterator->listConnectionFormats.begin(),listIterator->listConnectionFormats.end(),sinkData.listConnectionFormats.begin())
- && std::equal(listIterator->listMainSoundProperties.begin(),listIterator->listMainSoundProperties.end(),sinkData.listMainSoundProperties.begin(),equalMainSoundProperty)
- && std::equal(listIterator->listSoundProperties.begin(),listIterator->listSoundProperties.end(),sinkData.listSoundProperties.begin(),equalSoundProperty);
-}
-
-bool databaseTest::compareGateway(std::vector<am_Gateway_s>::iterator listIterator, const am_Gateway_s& gatewayData)
-{
- return (listIterator->name.compare(gatewayData.name)==0)
- && (listIterator->sinkID == gatewayData.sinkID)
- && (listIterator->sourceID == gatewayData.sourceID)
- && (listIterator->controlDomainID == gatewayData.controlDomainID)
- && (listIterator->domainSinkID == gatewayData.domainSinkID)
- && (listIterator->domainSourceID == gatewayData.domainSourceID)
- && std::equal(listIterator->convertionMatrix.begin(),listIterator->convertionMatrix.end(),gatewayData.convertionMatrix.begin())
- && std::equal(listIterator->listSourceFormats.begin(),listIterator->listSourceFormats.end(),gatewayData.listSourceFormats.begin())
- && std::equal(listIterator->listSinkFormats.begin(),listIterator->listSinkFormats.end(),gatewayData.listSinkFormats.begin());
-}
-
-bool databaseTest::compareGateway1(const am_Gateway_s gateway1, const am_Gateway_s gatewayData)
-{
- return (gateway1.name.compare(gatewayData.name)==0)
- && (gateway1.sinkID == gatewayData.sinkID)
- && (gateway1.sourceID == gatewayData.sourceID)
- && (gateway1.controlDomainID == gatewayData.controlDomainID)
- && (gateway1.domainSinkID == gatewayData.domainSinkID)
- && (gateway1.domainSourceID == gatewayData.domainSourceID)
- && std::equal(gateway1.convertionMatrix.begin(),gateway1.convertionMatrix.end(),gatewayData.convertionMatrix.begin())
- && std::equal(gateway1.listSourceFormats.begin(),gateway1.listSourceFormats.end(),gatewayData.listSourceFormats.begin())
- && std::equal(gateway1.listSinkFormats.begin(),gateway1.listSinkFormats.end(),gatewayData.listSinkFormats.begin());
-}
-
-bool databaseTest::compareSinkMainSink(std::vector<am_SinkType_s>::iterator listIterator, const std::vector<am_Sink_s>& sinkList)
-{
- std::vector<am_Sink_s>::const_iterator sinkListIterator=sinkList.begin();
- for(;sinkListIterator<sinkList.end();++sinkListIterator)
- {
- if (listIterator->sinkID==sinkListIterator->sinkID)
- {
- return (listIterator->name.compare(sinkListIterator->name)==0)
- && (listIterator->availability.availability==sinkListIterator->available.availability)
- && (listIterator->availability.availabilityReason==sinkListIterator->available.availabilityReason)
- && (listIterator->muteState==sinkListIterator->muteState)
- && (listIterator->volume==sinkListIterator->mainVolume)
- && (listIterator->sinkClassID==sinkListIterator->sinkClassID);
- }
- }
- return false;
-}
-
-bool databaseTest::compareSinkMainSource(std::vector<am_SourceType_s>::iterator listIterator, const std::vector<am_Source_s>& sourceList)
-{
- std::vector<am_Source_s>::const_iterator sinkListIterator=sourceList.begin();
- for(;sinkListIterator<sourceList.end();++sinkListIterator)
- {
- if (listIterator->sourceID==sinkListIterator->sourceID)
- {
- return (listIterator->name.compare(sinkListIterator->name)==0)
- && (listIterator->availability.availability==sinkListIterator->available.availability)
- && (listIterator->availability.availabilityReason==sinkListIterator->available.availabilityReason)
- && (listIterator->sourceClassID==sinkListIterator->sourceClassID);
- }
- }
- return false;
-}
-
-std::vector<am_ConnectionFormat_e> databaseTest::getStandardConnectionFormatList()
-{
- std::vector<am_ConnectionFormat_e> list;
- list.push_back(CF_ANALOG);
- list.push_back(CF_STEREO);
- return list;
-}
-
-std::string databaseTest::int2string(int i)
-{
- std::stringstream out;
- out << i;
- return out.str();
-}
-
-std::vector<am_SoundProperty_s> databaseTest::getStandardSoundPropertyList()
-{
- std::vector<am_SoundProperty_s> soundPropertyList;
- am_SoundProperty_s soundProperty;
- soundProperty.type=SP_BASS;
- soundProperty.value=23;
- soundPropertyList.push_back(soundProperty);
- soundProperty.type=SP_MID;
- soundProperty.value=2;
- soundPropertyList.push_back(soundProperty);
- return soundPropertyList;
-}
-
-std::vector<am_MainSoundProperty_s> databaseTest::getStandardMainSoundPropertyList()
-{
- std::vector<am_MainSoundProperty_s> mainSoundPropertyList;
- am_MainSoundProperty_s mainSoundProperty;
- mainSoundProperty.type=MSP_NAVIGATION_OFFSET;
- mainSoundProperty.value=23;
- mainSoundPropertyList.push_back(mainSoundProperty);
- mainSoundProperty.type=MSP_TEST;
- mainSoundProperty.value=3;
- mainSoundPropertyList.push_back(mainSoundProperty);
- return mainSoundPropertyList;
-}
-
-void databaseTest::createSink(
- am_Sink_s& sink,
- am_sinkID_t sinkID=0,
- std::string name="AnySink",
- am_domainID_t domainID=4,
- am_Availablility_e availability=A_AVAILABLE,
- am_AvailabilityReason_e availabilityReason=AR_NEWMEDIA,
- am_sinkClass_t sinkClassID=1,
- std::vector<am_ConnectionFormat_e> connectionFormatList=getStandardConnectionFormatList(),
- std::vector<am_SoundProperty_s> soundPropertyList=getStandardSoundPropertyList(),
- std::vector<am_MainSoundProperty_s> mainSoundPropertyList=getStandardMainSoundPropertyList(),
- am_mainVolume_t mainVolume=12,
- am_MuteState_e muteState=MS_UNMUTED,
- bool visible=true,
- am_volume_t volume=23)
-{
- sink.name=name;
- sink.domainID=domainID;
- sink.available.availability=availability;
- sink.available.availabilityReason=availabilityReason;
- sink.sinkClassID=sinkClassID;
- sink.listConnectionFormats=connectionFormatList;
- sink.listSoundProperties=soundPropertyList;
- sink.listMainSoundProperties=mainSoundPropertyList;
- sink.mainVolume=mainVolume;
- sink.muteState=muteState;
- sink.visible=visible;
- sink.volume=volume;
- sink.sinkID=sinkID;
-}
-
-void databaseTest::createSource(
- am_Source_s& source,
- am_sourceID_t sourceID=0,
- std::string name="AnySource",
- am_domainID_t domainID=4,
- am_Availablility_e availability=A_AVAILABLE,
- am_AvailabilityReason_e availabilityReason=AR_NEWMEDIA,
- am_sourceClass_t sourceClassID=1,
- std::vector<am_ConnectionFormat_e> connectionFormatList=getStandardConnectionFormatList(),
- std::vector<am_SoundProperty_s> soundPropertyList=getStandardSoundPropertyList(),
- std::vector<am_MainSoundProperty_s> mainSoundPropertyList=getStandardMainSoundPropertyList(),
- am_InterruptState_e interruptState=IS_OFF,
- bool visible=true,
- am_volume_t volume=23,
- am_SourceState_e sourceState=SS_ON)
-{
- source.name=name;
- source.domainID=domainID;
- source.available.availability=availability;
- source.available.availabilityReason=availabilityReason;
- source.sourceClassID=sourceClassID;
- source.listConnectionFormats=connectionFormatList;
- source.listSoundProperties=soundPropertyList;
- source.listMainSoundProperties=mainSoundPropertyList;
- source.interruptState=interruptState;
- source.visible=visible;
- source.volume=volume;
- source.sourceID=sourceID;
- source.sourceState=sourceState;
-}
-
-void databaseTest::createDomain(
- am_Domain_s & domain,
- am_domainID_t domainID=0,
- std::string name = "AnyDomain",
- std::string nodename = "AnyNode",
- std::string busname = "AnyBusname",
- bool complete= true,
- bool early= true,
- am_DomainState_e state=DS_CONTROLLED)
-{
-
- domain.domainID=domainID;
- domain.name=name;
- domain.nodename=nodename;
- domain.busname=busname;
- domain.complete=complete;
- domain.early=early;
- domain.state=state;
-}
-
-
-void databaseTest::createGateway(
- am_Gateway_s & gateway,
- am_gatewayID_t gatewayID=0,
- std::string name="AnyGateway",
- am_sinkID_t sinkID=1,
- am_sourceID_t sourceID=2,
- am_domainID_t controlDomainID=1,
- am_domainID_t domainSinkID=3,
- am_domainID_t domainSourceID=4,
- std::vector<bool> convertionMatrix=getStandardConvertionMatrix(),
- std::vector<am_ConnectionFormat_e> listSourceFormats=getStandardConnectionFormatList(),
- std::vector<am_ConnectionFormat_e> listSinkFormats=getStandardConnectionFormatList())
-{
- gateway.name=name;
- gateway.sinkID= sinkID;
- gateway.sourceID= sourceID;
- gateway.controlDomainID= controlDomainID;
- gateway.domainSinkID= domainSinkID;
- gateway.domainSourceID= domainSourceID;
- gateway.convertionMatrix= convertionMatrix;
- gateway.listSourceFormats=listSourceFormats;
- gateway.listSinkFormats=listSinkFormats;
- gateway.gatewayID=gatewayID;
-
-}
-
-void databaseTest::createConnection(
- am_Connection_s & connection,
- am_connectionID_t connectionID=0,
- am_sinkID_t sinkID=1,
- am_sourceID_t sourceID=2,
- am_timeSync_t delay=-1,
- am_ConnectionFormat_e connectionFormat=CF_ANALOG)
-{
- connection.connectionID=connectionID;
- connection.sinkID=sinkID;
- connection.sourceID=sourceID;
- connection.delay=delay;
- connection.connectionFormat=connectionFormat;
-}
-
-void databaseTest::createMainConnection(
- am_MainConnection_s & mainConnection,
- am_Route_s route,
- am_timeSync_t delay=-1,
- am_mainConnectionID_t connectionID=0,
- am_ConnectionState_e state=CS_CONNECTED)
-{
- mainConnection.connectionID=connectionID;
- mainConnection.connectionState=state;
- mainConnection.route=route;
- mainConnection.delay=delay;
-}
-
-
-std::vector<bool> databaseTest::getStandardConvertionMatrix()
-{
- std::vector<bool> convMatrix;
- convMatrix.push_back(true);
- convMatrix.push_back(false);
- convMatrix.push_back(true);
- convMatrix.push_back(false);
- convMatrix.push_back(true);
- convMatrix.push_back(true);
- return convMatrix;
-}
-
-
-void databaseTest::connectionList2RoutingList(std::vector<am_RoutingElement_s> & routingList, const std::vector<am_Connection_s>& connectionList)
-{
- am_RoutingElement_s routingElement;
- std::vector<am_Connection_s>::const_iterator cIterator=connectionList.begin();
- for(;cIterator<connectionList.end();++cIterator)
- {
- routingElement.sinkID=cIterator->sinkID;
- routingElement.sourceID=cIterator->sourceID;
- routingElement.connectionFormat=cIterator->connectionFormat;
- routingElement.domainID=4; //todo: make this test read out the real value
- routingList.push_back(routingElement);
- }
-}
+//extern int GetRandomNumber(int nLow, int nHigh);
+//extern bool equalSoundProperty (const am_SoundProperty_s a, const am_SoundProperty_s b);
+extern bool equalMainSoundProperty (const am_MainSoundProperty_s a, const am_MainSoundProperty_s b);
+extern bool equalRoutingElement (const am_RoutingElement_s a,const am_RoutingElement_s b);
+extern bool equalClassProperties (const am_ClassProperty_s a,const am_ClassProperty_s b);
+extern std::string int2string(int i);
void databaseTest::createMainConnectionSetup()
{
@@ -373,20 +49,29 @@ void databaseTest::createMainConnectionSetup()
am_sourceID_t forgetSource;
am_connectionID_t forgetConnection;
- createConnection(connection,0,i,i);
+ pCF.createConnection(connection);
+ connection.sinkID=i;
+ connection.sourceID=i;
connectionList.push_back(connection);
- createSink(sink,i,"sink" + int2string(i),4);
- createSource(source,i,"source" + int2string(i),4);
+ pCF.createSink(sink);
+ sink.sinkID=i;
+ sink.name="sink" + int2string(i);
+ sink.domainID=4;
+ pCF.createSource(source);
+ source.sourceID=i;
+ source.name="source" + int2string(i);
+ source.domainID=4;
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,forgetSink))<< "ERROR: database error";
ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,forgetSource))<< "ERROR: database error";
ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection,forgetConnection))<< "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.changeConnectionFinal(forgetConnection));
}
//fill the route
std::vector<am_RoutingElement_s> routingList;
- connectionList2RoutingList(routingList,connectionList);
+ pCF.connectionList2RoutingList(routingList,connectionList);
//create the Route
am_Route_s route;
@@ -398,7 +83,7 @@ void databaseTest::createMainConnectionSetup()
am_MainConnection_s mainConnection;
am_mainConnectionID_t mainConnectionID;
std::vector<am_MainConnection_s> mainConnectionList;
- createMainConnection(mainConnection,route);
+ pCF.createMainConnection(mainConnection,route);
//enter mainconnection in database
ASSERT_EQ(E_OK,pDatabaseHandler.enterMainConnectionDB(mainConnection,mainConnectionID))<< "ERROR: database error";
@@ -421,13 +106,131 @@ void databaseTest::createMainConnectionSetup()
ASSERT_EQ(true,equal);
}
+void databaseTest::SetUp()
+{
+ DLT_REGISTER_APP("Dtest","AudioManagerDeamon");
+ DLT_REGISTER_CONTEXT(AudioManager,"Main","Main Context");
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Database Test started "));
+ Observer *observer=NULL;
+ pDatabaseHandler.registerObserver(observer);
+}
+
+void databaseTest::TearDown()
+{
+ DLT_UNREGISTER_CONTEXT(AudioManager);
+}
+
+TEST_F(databaseTest, peekSource)
+{
+ std::vector<am_Source_s> listSources;
+ am_sourceID_t sourceID;
+ am_sourceID_t source2ID;
+ am_Source_s source;
+ pCF.createSource(source);
+ ASSERT_EQ(E_OK,pDatabaseHandler.peekSource(std::string("newsource"),sourceID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
+ ASSERT_TRUE(listSources.empty());
+ ASSERT_EQ(sourceID,100);
+ source.name="newsource";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,source2ID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
+ ASSERT_EQ(sourceID,source2ID);
+ ASSERT_TRUE(listSources[0].sourceID==sourceID);
+}
+
+TEST_F(databaseTest, peekSourceDouble)
+{
+ std::vector<am_Source_s> listSources;
+ am_sourceID_t sourceID;
+ am_sourceID_t source2ID;
+ am_sourceID_t source3ID;
+ am_Source_s source;
+ pCF.createSource(source);
+ ASSERT_EQ(E_OK,pDatabaseHandler.peekSource(std::string("newsource"),sourceID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.peekSource(std::string("newsource2"),source2ID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
+ ASSERT_TRUE(listSources.empty());
+ ASSERT_EQ(sourceID,100);
+ source.name="newsource";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,source3ID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
+ ASSERT_EQ(sourceID,source3ID);
+ ASSERT_TRUE(listSources[0].sourceID==sourceID);
+}
+
+TEST_F(databaseTest, peekSourceExists)
+{
+ std::vector<am_Source_s> listSources;
+ am_sourceID_t sourceID;
+ am_sourceID_t source2ID;
+ am_Source_s source;
+ pCF.createSource(source);
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.peekSource(source.name,source2ID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
+ ASSERT_TRUE(listSources.size()==1);
+ ASSERT_EQ(sourceID,source2ID);
+}
+
+TEST_F(databaseTest, peekSink)
+{
+ std::vector<am_Sink_s> listSinks;
+ am_sinkID_t sinkID;
+ am_sinkID_t sink2ID;
+ am_Sink_s sink;
+ pCF.createSink(sink);
+ ASSERT_EQ(E_OK,pDatabaseHandler.peekSink(std::string("newsink"),sinkID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
+ ASSERT_TRUE(listSinks.empty());
+ ASSERT_EQ(sinkID,100);
+ sink.name="newsink";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sink2ID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
+ ASSERT_EQ(sinkID,sink2ID);
+ ASSERT_TRUE(listSinks[0].sinkID==sinkID);
+}
+
+TEST_F(databaseTest, peekSinkDouble)
+{
+ std::vector<am_Sink_s> listSinks;
+ am_sinkID_t sinkID;
+ am_sinkID_t sink2ID;
+ am_sinkID_t sink3ID;
+ am_Sink_s sink;
+ pCF.createSink(sink);
+ ASSERT_EQ(E_OK,pDatabaseHandler.peekSink(std::string("newsink"),sinkID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.peekSink(std::string("nextsink"),sink2ID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
+ ASSERT_TRUE(listSinks.empty());
+ ASSERT_EQ(sinkID,100);
+ sink.name="newsink";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sink3ID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
+ ASSERT_EQ(sinkID,sink3ID);
+ ASSERT_TRUE(listSinks[0].sinkID==sinkID);
+}
+
+TEST_F(databaseTest, peekSinkExists)
+{
+ std::vector<am_Sink_s> listSinks;
+ am_sinkID_t sinkID;
+ am_sinkID_t sink2ID;
+ am_Sink_s sink;
+ pCF.createSink(sink);
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.peekSink(sink.name,sink2ID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
+ ASSERT_TRUE(listSinks.size()==1);
+ ASSERT_EQ(sinkID,sink2ID);
+}
+
+
TEST_F(databaseTest,changeConnectionTimingInformationCheckMainConnection)
{
am_Connection_s connection;
- am_connectionID_t connectionID;
std::vector<am_Connection_s> connectionList;
std::vector<am_MainConnectionType_s> mainList;
- createConnection(connection);
+ pCF.createConnection(connection);
createMainConnectionSetup();
ASSERT_EQ(-E_OK,pDatabaseHandler.getListVisibleMainConnections(mainList));
ASSERT_EQ(mainList[0].delay,-1);
@@ -446,10 +249,11 @@ TEST_F(databaseTest,changeConnectionTimingInformation)
am_Connection_s connection;
am_connectionID_t connectionID;
std::vector<am_Connection_s> connectionList;
- createConnection(connection);
+ pCF.createConnection(connection);
ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection,connectionID));
ASSERT_EQ(E_OK,pDatabaseHandler.changeConnectionTimingInformation(connectionID,24));
+ ASSERT_EQ(E_OK,pDatabaseHandler.changeConnectionFinal(connectionID));
ASSERT_EQ(E_OK,pDatabaseHandler.getListConnections(connectionList));
ASSERT_TRUE(connectionList[0].delay==24);
}
@@ -472,7 +276,7 @@ TEST_F(databaseTest,getSinkClassOfSink)
sinkClass.name="test";
sinkClass.sinkClassID=4;
sinkClass.listClassProperties=classPropertyList;
- createSink(sink);
+ pCF.createSink(sink);
sink.sinkClassID=4;
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
@@ -506,7 +310,7 @@ TEST_F(databaseTest,getSourceClassOfSource)
sourceClass.name="test";
sourceClass.sourceClassID=1;
sourceClass.listClassProperties=classPropertyList;
- createSource(source);
+ pCF.createSource(source);
ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
@@ -776,17 +580,21 @@ TEST_F(databaseTest,enterSourcesCorrect)
am_sourceID_t staticSourceID,firstDynamicSourceID,secondDynamicSourceID;
std::vector<am_Source_s> sourceList;
- createSource(staticSource,4,"Static");
+ pCF.createSource(staticSource);
+ staticSource.sourceID=4;
+ staticSource.name="Static";
ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(staticSource,staticSourceID))<< "ERROR: database error";
ASSERT_EQ(staticSource.sourceID,staticSourceID)<< "ERROR: ID not the one given in staticSource";
- createSource(firstDynamicSource,0,"firstDynamicSource");
+ pCF.createSource(firstDynamicSource);
+ firstDynamicSource.name="firstDynamicSource";
ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(firstDynamicSource,firstDynamicSourceID))<< "ERROR: database error";
ASSERT_EQ(firstDynamicSourceID,DYNAMIC_ID_BOUNDARY)<< "ERROR: ID not the one given in firstDynamicSink";
- createSource(secondDynamicSource,0,"secondDynamicSource");
+ pCF.createSource(secondDynamicSource);
+ secondDynamicSource.name="secondDynamicSource";
ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(secondDynamicSource,secondDynamicSourceID))<< "ERROR: database error";
ASSERT_NEAR(secondDynamicSourceID,DYNAMIC_ID_BOUNDARY,10)<< "ERROR: ID not the one given in secondDynamicSink";
@@ -800,17 +608,17 @@ TEST_F(databaseTest,enterSourcesCorrect)
{
if(listIterator->sourceID==staticSourceID)
{
- equal = equal && compareSource(listIterator,staticSource);
+ equal = equal && pCF.compareSource(listIterator,staticSource);
}
if(listIterator->sourceID==firstDynamicSourceID)
{
- equal = equal && compareSource(listIterator,firstDynamicSource);
+ equal = equal && pCF.compareSource(listIterator,firstDynamicSource);
}
if(listIterator->sourceID==secondDynamicSourceID)
{
- equal = equal && compareSource(listIterator,secondDynamicSource);
+ equal = equal && pCF.compareSource(listIterator,secondDynamicSource);
}
}
@@ -823,7 +631,7 @@ TEST_F(databaseTest, changeSourceMainSoundProperty)
std::vector<am_Source_s> listSources;
am_Source_s source;
am_sourceID_t sourceID;
- createSource(source);
+ pCF.createSource(source);
am_MainSoundProperty_s property;
property.type=MSP_NAVIGATION_OFFSET;
property.value=33;
@@ -845,7 +653,7 @@ TEST_F(databaseTest, changeSinkMuteState)
std::vector<am_Sink_s> listSinks;
am_Sink_s sink;
am_sinkID_t sinkID;
- createSink(sink);
+ pCF.createSink(sink);
am_MuteState_e muteState=MS_MUTED;
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
ASSERT_EQ(E_OK,pDatabaseHandler.changeSinkMuteStateDB(muteState,sinkID));
@@ -858,7 +666,7 @@ TEST_F(databaseTest, changeSinkMainSoundProperty)
std::vector<am_Sink_s> listSinks;
am_Sink_s sink;
am_sinkID_t sinkID;
- createSink(sink);
+ pCF.createSink(sink);
am_MainSoundProperty_s property;
property.type=MSP_NAVIGATION_OFFSET;
property.value=33;
@@ -875,12 +683,45 @@ TEST_F(databaseTest, changeSinkMainSoundProperty)
}
}
+TEST_F(databaseTest, peekDomain)
+{
+ std::vector<am_Domain_s> listDomains;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_domainID_t domain2ID;
+ pCF.createDomain(domain);
+ ASSERT_EQ(E_OK,pDatabaseHandler.peekDomain(std::string("newdomain"),domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListDomains(listDomains));
+ ASSERT_TRUE(listDomains.empty());
+ ASSERT_EQ(domainID,1);
+ domain.name="newdomain";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domain2ID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListDomains(listDomains));
+ ASSERT_EQ(domainID,domain2ID);
+ ASSERT_TRUE(listDomains[0].domainID==domainID);
+}
+
+TEST_F(databaseTest, peekDomainFirstEntered)
+{
+ std::vector<am_Domain_s> listDomains;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_domainID_t domain2ID;
+ pCF.createDomain(domain);
+ domain.name="newdomain";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.peekDomain(std::string("newdomain"),domain2ID));
+ ASSERT_EQ(domainID,domain2ID);
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListDomains(listDomains));
+ ASSERT_TRUE(listDomains.size()==1);
+}
+
TEST_F(databaseTest, changeDomainState)
{
std::vector<am_Domain_s> listDomains;
am_Domain_s domain;
am_domainID_t domainID;
- createDomain(domain);
+ pCF.createDomain(domain);
am_DomainState_e newState=DS_INDEPENDENT_STARTUP;
ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
ASSERT_EQ(E_OK,pDatabaseHandler.changDomainStateDB(newState,domainID));
@@ -903,7 +744,7 @@ TEST_F(databaseTest, changeSinkAvailability)
std::vector<am_Sink_s> listSinks;
am_Sink_s sink;
am_sinkID_t sinkID;
- createSink(sink);
+ pCF.createSink(sink);
am_Availability_s availability;
availability.availability=A_UNKNOWN;
availability.availabilityReason=AR_TEMPERATURE;
@@ -919,7 +760,7 @@ TEST_F(databaseTest, changeSourceAvailability)
std::vector<am_Source_s> listSources;
am_Source_s source;
am_sourceID_t sourceID;
- createSource(source);
+ pCF.createSource(source);
am_Availability_s availability;
availability.availability=A_UNKNOWN;
availability.availabilityReason=AR_TEMPERATURE;
@@ -948,11 +789,20 @@ TEST_F(databaseTest,changeMainConnectionRoute)
am_sourceID_t forgetSource;
am_connectionID_t forgetConnection;
- createConnection(connection,0,i+20,i+20,-1,CF_ANALOG);
+ pCF.createConnection(connection);
+ connection.sinkID=i+20;
+ connection.sourceID=i+20;
+ connection.delay=-1;
connectionList.push_back(connection);
- createSink(sink,i+20,"sink" + int2string(i+20),4);
- createSource(source,i+20,"source" + int2string(i+30),4);
+ pCF.createSink(sink);
+ sink.sinkID=i+20;
+ sink.name="sink" + int2string(i+20);
+ sink.domainID=4;
+ pCF.createSource(source);
+ source.sourceID=i+20;
+ source.name="source" + int2string(i+30);
+ source.domainID=4;
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,forgetSink))<< "ERROR: database error";
ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,forgetSource))<< "ERROR: database error";
@@ -963,7 +813,7 @@ TEST_F(databaseTest,changeMainConnectionRoute)
//fill the route
std::vector<am_RoutingElement_s> routingList;
- connectionList2RoutingList(routingList,connectionList);
+ pCF.connectionList2RoutingList(routingList,connectionList);
//create the Route
am_Route_s route;
@@ -983,7 +833,7 @@ TEST_F(databaseTest,changeMainSinkVolume)
am_sinkID_t sinkID;
am_mainVolume_t newVol=20;
std::vector<am_Sink_s> listSinks;
- createSink(sink);
+ pCF.createSink(sink);
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
ASSERT_EQ(E_OK,pDatabaseHandler.changeSinkMainVolumeDB(newVol,sinkID));
ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
@@ -994,7 +844,7 @@ TEST_F(databaseTest,getMainSourceSoundProperties)
{
am_Source_s source;
am_sourceID_t sourceID;
- createSource(source);
+ pCF.createSource(source);
std::vector<am_MainSoundProperty_s> mainSoundProperties=source.listMainSoundProperties;
std::vector<am_MainSoundProperty_s> listMainSoundProperties;
ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
@@ -1006,7 +856,7 @@ TEST_F(databaseTest,getMainSinkSoundProperties)
{
am_Sink_s sink;
am_sinkID_t sinkID;
- createSink(sink);
+ pCF.createSink(sink);
std::vector<am_MainSoundProperty_s> mainSoundProperties=sink.listMainSoundProperties;
std::vector<am_MainSoundProperty_s> listMainSoundProperties;
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
@@ -1018,9 +868,11 @@ TEST_F(databaseTest,getMainSources)
{
am_Source_s source, source1,source2;
am_sourceID_t sourceID;
- createSource(source);
- createSource(source1);
- createSource(source2);
+ pCF.createSource(source);
+ pCF.createSource(source1);
+ pCF.createSource(source2);
+ source1.name="source1";
+ source2.name="source2";
bool equal=true;
source1.visible=false;
std::vector<am_SourceType_s> listMainSources;
@@ -1036,7 +888,7 @@ TEST_F(databaseTest,getMainSources)
std::vector<am_SourceType_s>::iterator listIterator=listMainSources.begin();
for(;listIterator<listMainSources.end();++listIterator)
{
- equal = equal && compareSinkMainSource(listIterator,listSources);
+ equal = equal && pCF.compareSinkMainSource(listIterator,listSources);
}
ASSERT_TRUE(equal);
}
@@ -1045,9 +897,11 @@ TEST_F(databaseTest,getMainSinks)
{
am_Sink_s sink, sink1,sink2;
am_sinkID_t sinkID;
- createSink(sink);
- createSink(sink1);
- createSink(sink2);
+ pCF.createSink(sink);
+ pCF.createSink(sink1);
+ pCF.createSink(sink2);
+ sink1.name="sink1";
+ sink2.name="sink2";
bool equal=true;
sink1.visible=false;
std::vector<am_SinkType_s> listMainSinks;
@@ -1063,7 +917,7 @@ TEST_F(databaseTest,getMainSinks)
std::vector<am_SinkType_s>::iterator listIterator=listMainSinks.begin();
for(;listIterator<listMainSinks.end();++listIterator)
{
- equal = equal && compareSinkMainSink(listIterator,listSinks);
+ equal = equal && pCF.compareSinkMainSink(listIterator,listSinks);
}
ASSERT_TRUE(equal);
}
@@ -1073,7 +927,7 @@ TEST_F(databaseTest,getVisibleMainConnections)
createMainConnectionSetup();
am_MainConnection_s mainConnection;
am_Route_s route;
- createMainConnection(mainConnection,route);
+ pCF.createMainConnection(mainConnection,route);
std::vector<am_MainConnectionType_s> visibleMainConnection;
ASSERT_EQ(E_OK,pDatabaseHandler.getListVisibleMainConnections(visibleMainConnection));
ASSERT_TRUE(1==visibleMainConnection[0].mainConnectionID);
@@ -1090,9 +944,15 @@ TEST_F(databaseTest,getListSourcesOfDomain)
am_domainID_t domainID;
am_sourceID_t sourceID;
std::vector<am_sourceID_t> sourceList,sourceCheckList;
- createSource(source,1,"testSink",1);
- createSource(source2,0,"testSink",5);
- createDomain(domain);
+ pCF.createSource(source);
+ source.sourceID=1;
+ source.name="testSource";
+ source.domainID=1;
+ pCF.createSource(source2);
+ source2.sourceID=0;
+ source2.name="testSource2";
+ source2.domainID=5;
+ pCF.createDomain(domain);
sourceCheckList.push_back(1);//sink.sinkID);
ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID))<< "ERROR: database error";
@@ -1110,9 +970,13 @@ TEST_F(databaseTest,getListSinksOfDomain)
am_domainID_t domainID;
am_sinkID_t sinkID;
std::vector<am_sinkID_t> sinkList,sinkCheckList;
- createSink(sink,1,"testSink",1);
- createSink(sink2,0,"testSink",5);
- createDomain(domain);
+ pCF.createSink(sink);
+ sink.sinkID=1;
+ sink.domainID=1;
+ pCF.createSink(sink2);
+ sink2.domainID=5;
+ sink2.name="sink2";
+ pCF.createDomain(domain);
sinkCheckList.push_back(1);//sink.sinkID);
ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID))<< "ERROR: database error";
@@ -1130,9 +994,23 @@ TEST_F(databaseTest,getListGatewaysOfDomain)
am_domainID_t domainID;
am_Domain_s domain;
std::vector<am_gatewayID_t> gatewayList,gatewayCheckList;
- createGateway(gateway,1,"testGateway",1,1,1);
- createGateway(gateway2,0,"testGateway2",1,1,4);
- createDomain(domain);
+ pCF.createGateway(gateway);
+ gateway.gatewayID=1;
+ gateway.name="testGateway";
+ gateway.controlDomainID=1;
+ gateway.sourceID=1;
+ gateway.sinkID=1;
+ gateway.domainSinkID=1;
+ gateway.domainSourceID=1;
+ pCF.createGateway(gateway2);
+ gateway2.gatewayID=2;
+ gateway2.name="testGateway2";
+ gateway2.controlDomainID=4;
+ gateway2.sourceID=1;
+ gateway2.sinkID=1;
+ gateway2.domainSinkID=1;
+ gateway2.domainSourceID=1;
+ pCF.createDomain(domain);
gatewayCheckList.push_back(gateway.gatewayID);
ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))<< "ERROR: database error";
@@ -1148,7 +1026,7 @@ TEST_F(databaseTest,removeDomain)
am_Domain_s domain;
am_domainID_t domainID;
std::vector<am_Domain_s> listDomains;
- createDomain(domain);
+ pCF.createDomain(domain);
ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID))<< "ERROR: database error";
ASSERT_EQ(E_OK,pDatabaseHandler.removeDomainDB(domainID))<< "ERROR: database error";
ASSERT_EQ(E_OK,pDatabaseHandler.getListDomains(listDomains))<< "ERROR: database error";
@@ -1160,7 +1038,7 @@ TEST_F(databaseTest,removeGateway)
am_Gateway_s gateway;
am_gatewayID_t gatewayID;
std::vector<am_Gateway_s> listGateways;
- createGateway(gateway);
+ pCF.createGateway(gateway);
ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))<< "ERROR: database error";
ASSERT_EQ(E_OK,pDatabaseHandler.removeGatewayDB(gatewayID))<< "ERROR: database error";
ASSERT_EQ(E_OK,pDatabaseHandler.getListGateways(listGateways))<< "ERROR: database error";
@@ -1172,7 +1050,7 @@ TEST_F(databaseTest,removeSink)
am_Sink_s sink;
am_sinkID_t sinkID;
std::vector<am_Sink_s> listSinks;
- createSink(sink);
+ pCF.createSink(sink);
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID))<< "ERROR: database error";
ASSERT_EQ(E_OK,pDatabaseHandler.removeSinkDB(sinkID))<< "ERROR: database error";
ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks))<< "ERROR: database error";
@@ -1185,7 +1063,7 @@ TEST_F(databaseTest,removeSource)
am_Source_s source;
am_sourceID_t sourceID;
std::vector<am_Source_s> listSources;
- createSource(source);
+ pCF.createSource(source);
ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID))<< "ERROR: database error";
ASSERT_EQ(E_OK,pDatabaseHandler.removeSourceDB(sourceID))<< "ERROR: database error";
@@ -1226,9 +1104,10 @@ TEST_F(databaseTest,registerGatewayCorrect)
am_Gateway_s gateway, gateway1, gateway2;
am_gatewayID_t gatewayID=0,gatewayID1=0,gatewayID2=0;
- createGateway(gateway,0,"Gateway1");
- createGateway(gateway1,20,"Gateway2");
- createGateway(gateway2,0,"Gateway3");
+ pCF.createGateway(gateway);
+ pCF.createGateway(gateway1);
+ gateway1.gatewayID=20;
+ pCF.createGateway(gateway2);
ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))<< "ERROR: database error";
ASSERT_EQ(100,gatewayID)<< "ERROR: domainID zero";
@@ -1248,17 +1127,17 @@ TEST_F(databaseTest,registerGatewayCorrect)
{
if(listIterator->gatewayID==gatewayID)
{
- equal= equal && compareGateway(listIterator,gateway);
+ equal= equal && pCF.compareGateway(listIterator,gateway);
}
if(listIterator->gatewayID==gatewayID1)
{
- equal= equal && compareGateway(listIterator,gateway1);
+ equal= equal && pCF.compareGateway(listIterator,gateway1);
}
if(listIterator->gatewayID==gatewayID2)
{
- equal= equal && compareGateway(listIterator,gateway2);
+ equal= equal && pCF.compareGateway(listIterator,gateway2);
}
}
@@ -1272,9 +1151,10 @@ TEST_F(databaseTest,getGatewayInfo)
am_Gateway_s gateway, gateway1, gateway2;
am_gatewayID_t gatewayID=0,gatewayID1=0,gatewayID2=0;
- createGateway(gateway,0,"Gateway1");
- createGateway(gateway1,20,"Gateway2");
- createGateway(gateway2,0,"Gateway3");
+ pCF.createGateway(gateway);
+ pCF.createGateway(gateway1);
+ gateway1.gatewayID=20;
+ pCF.createGateway(gateway2);
ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))<< "ERROR: database error";
ASSERT_EQ(100,gatewayID)<< "ERROR: domainID zero";
@@ -1294,17 +1174,17 @@ TEST_F(databaseTest,getGatewayInfo)
{
if(listIterator->gatewayID==gatewayID)
{
- equal= equal && compareGateway(listIterator,gateway);
+ equal= equal && pCF.compareGateway(listIterator,gateway);
}
if(listIterator->gatewayID==gatewayID1)
{
- equal= equal && compareGateway(listIterator,gateway1);
+ equal= equal && pCF.compareGateway(listIterator,gateway1);
}
if(listIterator->gatewayID==gatewayID2)
{
- equal= equal && compareGateway(listIterator,gateway2);
+ equal= equal && pCF.compareGateway(listIterator,gateway2);
}
}
@@ -1312,7 +1192,7 @@ TEST_F(databaseTest,getGatewayInfo)
am_Gateway_s gatewayInfo;
ASSERT_EQ(E_OK,pDatabaseHandler.getGatewayInfoDB(20,gatewayInfo));
- ASSERT_TRUE(compareGateway1(gateway1,gatewayInfo));
+ ASSERT_TRUE(pCF.compareGateway1(gateway1,gatewayInfo));
}
@@ -1322,12 +1202,16 @@ TEST_F(databaseTest,enterSinkThatAlreadyExistFail)
am_Sink_s staticSink,SecondSink;
am_sinkID_t staticSinkID,SecondSinkID;
- createSink(staticSink,43,"Static");
+ pCF.createSink(staticSink);
+ staticSink.sinkID=43;
+ staticSink.name="Static";
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(staticSink,staticSinkID))<< "ERROR: database error";
ASSERT_EQ(staticSink.sinkID,staticSinkID)<< "ERROR: ID not the one given in staticSink";
- createSink(SecondSink,43,"secondStatic");
+ pCF.createSink(SecondSink);
+ SecondSink.sinkID=43;
+ SecondSink.name="SecondSink";
ASSERT_EQ(E_ALREADY_EXISTS,pDatabaseHandler.enterSinkDB(SecondSink,SecondSinkID))<< "ERROR: database error";
}
@@ -1337,12 +1221,14 @@ TEST_F(databaseTest,enterSourcesThatAlreadyExistFail)
//fill the connection database
am_Source_s staticSource,SecondSource;
am_sourceID_t staticSourceID,SecondSourceID;
- createSource(staticSource,4,"FirstSource");
+ pCF.createSource(staticSource);
+ staticSource.sourceID=4;
ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(staticSource,staticSourceID))<< "ERROR: database error";
ASSERT_EQ(staticSource.sourceID,staticSourceID)<< "ERROR: ID not the one given in staticSource";
- createSource(SecondSource,4,"SecondSource");
+ pCF.createSource(SecondSource);
+ SecondSource.sourceID=4;
ASSERT_EQ(E_ALREADY_EXISTS,pDatabaseHandler.enterSourceDB(SecondSource,SecondSourceID))<< "ERROR: database error";
}
@@ -1353,7 +1239,7 @@ TEST_F(databaseTest,registerDomainCorrect)
std::vector<am_Domain_s> returnList;
am_Domain_s domain;
am_domainID_t domainID=0;
- createDomain(domain);
+ pCF.createDomain(domain);
ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID))<< "ERROR: database error";
ASSERT_NE(0,domainID)<< "ERROR: domainID zero";
@@ -1375,25 +1261,18 @@ TEST_F(databaseTest,registerDomainCorrect)
ASSERT_EQ(true,equal);
}
-TEST_F(databaseTest,registerDomainFailonID0)
-{
- am_Domain_s domain;
- am_domainID_t domainID=5;
- createDomain(domain,1);
- ASSERT_DEATH(pDatabaseHandler.enterDomainDB(domain,domainID),"Assertion `domainData.domainID==0'");
-}
-
TEST_F(databaseTest,registerConnectionCorrect)
{
am_Connection_s connection;
am_connectionID_t connectionID;
std::vector<am_Connection_s> returnList;
- createConnection(connection);
+ pCF.createConnection(connection);
ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection,connectionID))<< "ERROR: database error";;
ASSERT_NE(0,connectionID)<< "ERROR: connectionID zero";
//now check if we read out the correct values
+ ASSERT_EQ(E_OK,pDatabaseHandler.changeConnectionFinal(connectionID));
ASSERT_EQ(E_OK,pDatabaseHandler.getListConnections(returnList));
bool equal=false;
std::vector<am_Connection_s>::iterator listIterator=returnList.begin();
@@ -1421,17 +1300,19 @@ TEST_F(databaseTest,enterSinksCorrect)
am_sinkID_t staticSinkID,firstDynamicSinkID,secondDynamicSinkID;
std::vector<am_Sink_s> sinkList;
- createSink(staticSink,4,"Static");
+ pCF.createSink(staticSink);
+ staticSink.sinkID=4;
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(staticSink,staticSinkID))<< "ERROR: database error";
ASSERT_EQ(staticSink.sinkID,staticSinkID)<< "ERROR: ID not the one given in staticSink";
- createSink(firstDynamicSink,0,"firstDynamicSink");
-
+ pCF.createSink(firstDynamicSink);
+ firstDynamicSink.name="firstdynamic";
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(firstDynamicSink,firstDynamicSinkID))<< "ERROR: database error";
ASSERT_EQ(firstDynamicSinkID,DYNAMIC_ID_BOUNDARY)<< "ERROR: ID not the one given in firstDynamicSink";
- createSink(secondDynamicSink,0,"secondDynamicSink");
+ pCF.createSink(secondDynamicSink);
+ secondDynamicSink.name="seconddynamic";
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(secondDynamicSink,secondDynamicSinkID))<< "ERROR: database error";
ASSERT_NEAR(secondDynamicSinkID,DYNAMIC_ID_BOUNDARY,10)<< "ERROR: ID not the one given in secondDynamicSink";
@@ -1445,22 +1326,32 @@ TEST_F(databaseTest,enterSinksCorrect)
{
if(listIterator->sinkID==staticSinkID)
{
- equal = equal && compareSink(listIterator,staticSink);
+ equal = equal && pCF.compareSink(listIterator,staticSink);
}
if(listIterator->sinkID==firstDynamicSinkID)
{
- equal = equal && compareSink(listIterator,firstDynamicSink);
+ equal = equal && pCF.compareSink(listIterator,firstDynamicSink);
}
if(listIterator->sinkID==secondDynamicSinkID)
{
- equal = equal && compareSink(listIterator,secondDynamicSink);
+ equal = equal && pCF.compareSink(listIterator,secondDynamicSink);
}
}
ASSERT_EQ(true,equal);
}
+//Commented out - gives always a warning..
+//TEST_F(databaseTest,registerDomainFailonID0)
+//{
+// am_Domain_s domain;
+// am_domainID_t domainID=5;
+// pCF.createDomain(domain);
+// domain.domainID=1;
+// ASSERT_DEATH(pDatabaseHandler.enterDomainDB(domain,domainID),"Assertion `domainData.domainID==0'");
+//}
+
int main(int argc, char **argv)
{
diff --git a/AudioManagerDaemon/test/database/databaseTest.h b/AudioManagerDaemon/test/database/databaseTest.h
new file mode 100644
index 0000000..3255b71
--- /dev/null
+++ b/AudioManagerDaemon/test/database/databaseTest.h
@@ -0,0 +1,37 @@
+/*
+ * databasetest.h
+ *
+ * Created on: Dec 6, 2011
+ * Author: christian
+ */
+
+#ifndef DATABASETEST_H_
+#define DATABASETEST_H_
+
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+#include <dlt/dlt.h>
+#include <algorithm>
+#include <string>
+#include <vector>
+#include <set>
+#include "DatabaseHandler.h"
+#include "../CommonFunctions.h"
+
+DLT_DECLARE_CONTEXT(AudioManager)
+
+using namespace testing;
+
+class databaseTest : public Test {
+public:
+
+ DatabaseHandler pDatabaseHandler;
+ CommonFunctions pCF;
+
+ void SetUp();
+ void TearDown();
+
+ void createMainConnectionSetup();
+};
+
+#endif /* DATABASETEST_H_ */
diff --git a/AudioManagerDaemon/test/databasetest.h b/AudioManagerDaemon/test/databasetest.h
deleted file mode 100644
index a969fc9..0000000
--- a/AudioManagerDaemon/test/databasetest.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * databasetest.h
- *
- * Created on: Dec 6, 2011
- * Author: christian
- */
-
-#ifndef DATABASETEST_H_
-#define DATABASETEST_H_
-
-
-#include <gtest/gtest.h>
-#include <dlt/dlt.h>
-#include <algorithm>
-#include <string>
-#include <vector>
-#include <set>
-#include "DatabaseHandler.h"
-
-DLT_DECLARE_CONTEXT(AudioManager);
-
-using namespace testing;
-
-class databaseTest : public Test {
-public:
-
- DatabaseHandler pDatabaseHandler;
- void SetUp();
- void TearDown();
-
- static std::vector<am_ConnectionFormat_e> getStandardConnectionFormatList();
- static std::vector<am_SoundProperty_s> getStandardSoundPropertyList();
- static std::vector<am_MainSoundProperty_s> getStandardMainSoundPropertyList();
- static std::vector<bool> getStandardConvertionMatrix();
- bool compareSource(std::vector<am_Source_s>::iterator listIterator, const am_Source_s& sourceData);
- bool compareSink(std::vector<am_Sink_s>::iterator listIterator, const am_Sink_s& sinkData);
- bool compareGateway(std::vector<am_Gateway_s>::iterator listIterator, const am_Gateway_s& gatewayData);
- bool compareGateway1(const am_Gateway_s gateway1, const am_Gateway_s gatewayData);
- bool compareSinkMainSink(std::vector<am_SinkType_s>::iterator listIterator, const std::vector<am_Sink_s>& sinkList);
- bool compareSinkMainSource(std::vector<am_SourceType_s>::iterator listIterator, const std::vector<am_Source_s>& sourceList);
- std::string int2string(int i);
-
- void createSink(am_Sink_s& sink,am_sinkID_t sinkID,std::string name,am_domainID_t domainID, am_Availablility_e availability,
- am_AvailabilityReason_e availabilityReason, am_sinkClass_t sinkClassID,
- std::vector<am_ConnectionFormat_e> connectionFormatList,
- std::vector<am_SoundProperty_s> soundPropertyList,
- std::vector<am_MainSoundProperty_s> mainSoundPropertyList,
- am_mainVolume_t mainVolume, am_MuteState_e muteState,
- bool visible, am_volume_t volume);
-
- void createSource(am_Source_s& source, am_sourceID_t sourceID, std::string name, am_domainID_t domainID,
- am_Availablility_e availability, am_AvailabilityReason_e availabilityReason, am_sourceClass_t sourceClassID,
- std::vector<am_ConnectionFormat_e> listConnectionFormats,
- std::vector<am_SoundProperty_s> listSoundProperties,
- std::vector<am_MainSoundProperty_s> listMainSoundProperties,
- am_InterruptState_e interruptState, bool visible, am_volume_t volume, am_SourceState_e sourceState);
-
- void createDomain(am_Domain_s& domain, am_domainID_t domainID, std::string name, std::string nodename,
- std::string busname, bool complete, bool early, am_DomainState_e state);
-
- void createGateway(am_Gateway_s& gateway, am_gatewayID_t gatewayID, std::string name, am_sinkID_t sinkID, am_sourceID_t sourceID, am_domainID_t controlDomainID,
- am_domainID_t domainSinkID, am_domainID_t domainSourceID,std::vector<bool> convertionMatrix,
- std::vector<am_ConnectionFormat_e> listSourceFormats,std::vector<am_ConnectionFormat_e> listSinkFormats);
-
- void createConnection(am_Connection_s& connection, am_connectionID_t connectionID, am_sinkID_t sinkID,
- am_sourceID_t sourceID, am_timeSync_t delay, am_ConnectionFormat_e connectionFormat);
-
- void createMainConnection(am_MainConnection_s& mainConnection, am_Route_s route, am_timeSync_t delay,
- am_mainConnectionID_t connectionID, am_ConnectionState_e state);
-
-
- void connectionList2RoutingList(std::vector<am_RoutingElement_s>& routingList, const std::vector<am_Connection_s>& connectionList);
-
- void createMainConnectionSetup();
-
- struct sortBySinkID
- {
- bool operator()(const am_RoutingElement_s & a, const am_RoutingElement_s & b) const
- {
- return (a.sinkID < b.sinkID);
- }
- };
-
- struct sortByConnectionFormat
- {
- bool operator()(const am_ConnectionFormat_e & a, const am_ConnectionFormat_e & b) const
- {
- return (a < b);
- }
- };
-
- struct sortByMainSoundProperty
- {
- bool operator()(const am_MainSoundProperty_s & a, const am_MainSoundProperty_s & b) const
- {
- return (a.type > b.type);
- }
- };
-
- struct sortBySoundProperty
- {
- bool operator()(const am_SoundProperty_s & a, const am_SoundProperty_s & b) const
- {
- return (a.type < b.type);
- }
- };
-};
-
-#endif /* DATABASETEST_H_ */
diff --git a/AudioManagerDaemon/test/routingInterface/CMakeLists.txt b/AudioManagerDaemon/test/routingInterface/CMakeLists.txt
new file mode 100644
index 0000000..b3db54a
--- /dev/null
+++ b/AudioManagerDaemon/test/routingInterface/CMakeLists.txt
@@ -0,0 +1,77 @@
+#
+# Copyright (C) 2011, BMW AG
+#
+# GeniviAudioMananger RoutingInterfaceTest
+#
+# \file CMakeLists.txt
+#
+# \date 20-Oct-2011 3:42:04 PM
+# \author Christian Mueller (christian.ei.mueller@bmw.de)
+#
+# \section License
+# GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+# Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+#
+# This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+# You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+# Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+# Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+# As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+# Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+#
+
+cmake_minimum_required(VERSION 2.6)
+
+PROJECT(routingInterfaceTest)
+
+set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -rdynamic")
+#set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic")
+set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUNIT_TEST=1")
+
+set(STD_INCLUDE_DIRS "/usr/include")
+set(DBUS_FOLDER ${CMAKE_SOURCE_DIR}/../../../dbusInterfaces)
+set(AUDIO_INCLUDES_FOLDER ${CMAKE_SOURCE_DIR}/../../../includes)
+set(DBUS_INCLUDES_FOLDER ${CMAKE_SOURCE_DIR}/../../../../dbusIncludes)
+set(INCLUDES_FOLDER ${CMAKE_SOURCE_DIR}/../../include)
+set(EXECUTABLE_OUTPUT_PATH ../../../../test/)
+
+FIND_PACKAGE(PkgConfig)
+pkg_check_modules(SQLITE REQUIRED sqlite3)
+pkg_check_modules(DLT REQUIRED automotive-dlt)
+
+INCLUDE_DIRECTORIES(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${AUDIO_INCLUDES_FOLDER}
+ ${DBUS_ARCH_INCLUDE_DIR}
+ ${DBUS_INCLUDES_FOLDER}
+ ${CMAKE_SOURCE_DIR}
+ ${STD_INCLUDE_DIRS}
+ ${DLT_INCLUDE_DIRS}
+ ${DBUS_INCLUDE_DIR}
+ ${INCLUDES_FOLDER}
+)
+
+file(GLOB ROUTING_INTERFACE_SRCS_CXX
+ "../../src/ControlReceiver.cpp"
+ "../../src/DatabaseHandler.cpp"
+ "../../src/Observer.cpp"
+ "../../src/CommandSender.cpp"
+ "../../src/RoutingSender.cpp"
+ "../CommonFunctions.cpp"
+ "*.cpp"
+)
+
+ADD_EXECUTABLE(routinginterfacetest ${ROUTING_INTERFACE_SRCS_CXX})
+
+TARGET_LINK_LIBRARIES(routinginterfacetest
+ ${SQLITE_LIBRARIES}
+ ${DLT_LIBRARIES}
+ ${DBUS_LIBRARY}
+ ${CMAKE_THREAD_LIBS_INIT}
+ gtest
+ gmock
+)
+
+
+
diff --git a/AudioManagerDaemon/test/routingInterface/MockRoutingInterface.h b/AudioManagerDaemon/test/routingInterface/MockRoutingInterface.h
new file mode 100644
index 0000000..bd25156
--- /dev/null
+++ b/AudioManagerDaemon/test/routingInterface/MockRoutingInterface.h
@@ -0,0 +1,52 @@
+/*
+ * MockRoutingInterface.h
+ *
+ * Created on: Dec 10, 2011
+ * Author: christian
+ */
+
+#ifndef MOCKROUTINGINTERFACE_H_
+#define MOCKROUTINGINTERFACE_H_
+
+#include <routing/RoutingSendInterface.h>
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+namespace am {
+
+class MockRoutingSendInterface : public RoutingSendInterface {
+ public:
+ MOCK_METHOD1(startupRoutingInterface,
+ void(RoutingReceiveInterface* routingreceiveinterface));
+ MOCK_METHOD0(routingInterfacesReady,
+ void());
+ MOCK_METHOD0(routingInterfacesRundown,
+ void());
+ MOCK_METHOD1(asyncAbort,
+ am_Error_e(const am_Handle_s handle));
+ MOCK_METHOD5(asyncConnect,
+ am_Error_e(const am_Handle_s handle, const am_connectionID_t connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_ConnectionFormat_e connectionFormat));
+ MOCK_METHOD2(asyncDisconnect,
+ am_Error_e(const am_Handle_s handle, const am_connectionID_t connectionID));
+ MOCK_METHOD5(asyncSetSinkVolume,
+ am_Error_e(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time));
+ MOCK_METHOD5(asyncSetSourceVolume,
+ am_Error_e(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time));
+ MOCK_METHOD3(asyncSetSourceState,
+ am_Error_e(const am_Handle_s handle, const am_sourceID_t sourceID, const am_SourceState_e state));
+ MOCK_METHOD3(asyncSetSinkSoundProperty,
+ am_Error_e(const am_Handle_s handle, const am_SoundProperty_s& soundProperty, const am_sinkID_t sinkID));
+ MOCK_METHOD3(asyncSetSourceSoundProperty,
+ am_Error_e(const am_Handle_s handle, const am_SoundProperty_s& soundProperty, const am_sourceID_t sourceID));
+ MOCK_METHOD5(asyncCrossFade,
+ am_Error_e(const am_Handle_s handle, const am_crossfaderID_t crossfaderID, const am_HotSink_e hotSink, const am_RampType_e rampType, const am_time_t time));
+ MOCK_METHOD2(setDomainState,
+ am_Error_e(const am_domainID_t domainID, const am_DomainState_e domainState));
+ MOCK_CONST_METHOD1(returnBusName,
+ am_Error_e(std::string& BusName));
+ };
+
+} // namespace am
+
+
+#endif /* MOCKROUTINGINTERFACE_H_ */
diff --git a/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.cpp b/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.cpp
new file mode 100644
index 0000000..bc3e583
--- /dev/null
+++ b/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.cpp
@@ -0,0 +1,415 @@
+/*
+ * routingInterfaceTest.cpp
+ *
+ * Created on: Dec 10, 2011
+ * Author: christian
+ */
+
+#include "routingInterfaceTest.h"
+
+using ::testing::Field;
+using ::testing::Property;
+using ::testing::Matcher;
+using ::testing::Pointee;
+using ::testing::AllOf;
+using ::testing::SafeMatcherCast;
+using ::testing::MatcherCast;
+using ::testing::DefaultValue;
+using ::testing::Eq;
+using ::testing::An;
+using ::testing::ElementsAreArray;
+using ::testing::ElementsAre;
+using ::testing::NotNull;
+
+routingInterfaceTest::routingInterfaceTest()
+ :pDatabaseHandler(),
+ pRoutingSender(),
+ pCommandSender(),
+ pMockInterface(),
+ pRoutingInterfaceBackdoor(),
+ pCommandInterfaceBackdoor(),
+ pControlReceiver(&pDatabaseHandler,&pRoutingSender),
+ pObserver(&pCommandSender,&pRoutingSender)
+{
+ pDatabaseHandler.registerObserver(&pObserver);
+ pRoutingInterfaceBackdoor.unloadPlugins(&pRoutingSender);
+ pRoutingInterfaceBackdoor.injectInterface(&pRoutingSender,&pMockInterface,"mock");
+ pCommandInterfaceBackdoor.unloadPlugins(&pCommandSender);
+}
+
+routingInterfaceTest::~routingInterfaceTest()
+{
+}
+
+void routingInterfaceTest::SetUp()
+{
+ DLT_REGISTER_APP("Rtest","RoutingInterfacetest");
+ DLT_REGISTER_CONTEXT(AudioManager,"Main","Main Context");
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("RoutingSendInterface Test started "));
+
+}
+
+void routingInterfaceTest::TearDown()
+{
+ DLT_UNREGISTER_CONTEXT(AudioManager);
+}
+
+TEST_F(routingInterfaceTest,abort)
+{
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_Handle_s handle;
+ am_connectionID_t connectionID;
+ std::vector<am_Handle_s>listHandles;
+ pCF.createSink(sink);
+ pCF.createDomain(domain);
+ domain.name="mock";
+ domain.busname="mock";
+ sink.sinkID=2;
+ sink.domainID=1;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
+ EXPECT_CALL(pMockInterface,asyncConnect(_,_,1,sinkID,CF_ANALOG)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK,pControlReceiver.connect(handle,connectionID,CF_ANALOG,1,2));
+ ASSERT_NE(handle.handle,0);
+ ASSERT_EQ(handle.handleType,H_CONNECT);
+ ASSERT_EQ(E_OK,pControlReceiver.getListHandles(listHandles));
+ ASSERT_TRUE(listHandles[0].handle==handle.handle);
+ ASSERT_TRUE(listHandles[0].handleType==handle.handleType);
+ EXPECT_CALL(pMockInterface,asyncAbort(_)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK,pControlReceiver.abortAction(handle));
+}
+
+TEST_F(routingInterfaceTest,abortNonExistent)
+{
+ EXPECT_CALL(pMockInterface,asyncAbort(_)).Times(0);
+ am_Handle_s handle;
+ ASSERT_EQ(E_NON_EXISTENT,pControlReceiver.abortAction(handle));
+}
+
+TEST_F(routingInterfaceTest,alreadyConnected)
+{
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ pCF.createSink(sink);
+ pCF.createDomain(domain);
+ domain.name="mock";
+ domain.busname="mock";
+ sink.sinkID=2;
+ sink.domainID=1;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
+ EXPECT_CALL(pMockInterface,asyncConnect(_,_,1,sinkID,CF_ANALOG)).WillOnce(Return(E_OK));
+ am_Handle_s handle;
+ am_connectionID_t connectionID;
+ ASSERT_EQ(E_OK,pControlReceiver.connect(handle,connectionID,CF_ANALOG,1,2));
+ ASSERT_EQ(E_OK,pDatabaseHandler.changeConnectionFinal(connectionID));
+ ASSERT_EQ(E_ALREADY_EXISTS,pControlReceiver.connect(handle,connectionID,CF_ANALOG,1,2));
+ ASSERT_NE(handle.handle,0);
+ ASSERT_EQ(handle.handleType,H_CONNECT);
+}
+
+TEST_F(routingInterfaceTest,setSinkSoundPropertyNoChange)
+{
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_Handle_s handle;
+ am_SoundProperty_s soundProperty;
+ soundProperty.type=SP_TREBLE;
+ soundProperty.value=23;
+ std::vector<am_Handle_s>listHandles;
+ pCF.createSink(sink);
+ pCF.createDomain(domain);
+ domain.name="mock";
+ domain.busname="mock";
+ sink.sinkID=2;
+ sink.domainID=1;
+ sink.listSoundProperties.push_back(soundProperty);
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
+ EXPECT_CALL(pMockInterface,asyncSetSinkSoundProperty(_,_,sinkID)).Times(0);
+ ASSERT_EQ(E_NO_CHANGE,pControlReceiver.setSinkSoundProperty(handle,sinkID,soundProperty));
+}
+
+TEST_F(routingInterfaceTest,setSourceState)
+{
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_Handle_s handle;
+ handle.handle=0;
+ am_SourceState_e state=SS_PAUSED;
+ pCF.createSource(source);
+ pCF.createDomain(domain);
+ domain.name="mock";
+ domain.busname="mock";
+ source.domainID=1;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
+ EXPECT_CALL(pMockInterface,asyncSetSourceState(_,sourceID,state)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK,pControlReceiver.setSourceState(handle,sourceID,state));
+ ASSERT_NE(handle.handle,0);
+ ASSERT_EQ(handle.handleType,H_SETSOURCESTATE);
+}
+
+TEST_F(routingInterfaceTest,setSourceSoundProperty)
+{
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_Handle_s handle;
+ am_SoundProperty_s soundProperty;
+ std::vector<am_Handle_s>listHandles;
+ pCF.createSource(source);
+ pCF.createDomain(domain);
+ domain.name="mock";
+ domain.busname="mock";
+ source.sourceID=2;
+ source.domainID=1;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
+ EXPECT_CALL(pMockInterface,asyncSetSourceSoundProperty(_,_,sourceID)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK,pControlReceiver.setSourceSoundProperty(handle,sourceID,soundProperty));
+ ASSERT_NE(handle.handle,0);
+ ASSERT_EQ(handle.handleType,H_SETSOURCESOUNDPROPERTY);
+ ASSERT_EQ(E_OK,pControlReceiver.getListHandles(listHandles));
+ ASSERT_TRUE(listHandles[0].handle==handle.handle);
+ ASSERT_TRUE(listHandles[0].handleType==handle.handleType);
+}
+
+TEST_F(routingInterfaceTest,setSinkSoundProperty)
+{
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_Handle_s handle;
+ am_SoundProperty_s soundProperty;
+ std::vector<am_Handle_s>listHandles;
+ pCF.createSink(sink);
+ pCF.createDomain(domain);
+ domain.name="mock";
+ domain.busname="mock";
+ sink.sinkID=2;
+ sink.domainID=1;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
+ EXPECT_CALL(pMockInterface,asyncSetSinkSoundProperty(_,_,sinkID)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK,pControlReceiver.setSinkSoundProperty(handle,sinkID,soundProperty));
+ ASSERT_NE(handle.handle,0);
+ ASSERT_EQ(handle.handleType,H_SETSINKSOUNDPROPERTY);
+ ASSERT_EQ(E_OK,pControlReceiver.getListHandles(listHandles));
+ ASSERT_TRUE(listHandles[0].handle==handle.handle);
+ ASSERT_TRUE(listHandles[0].handleType==handle.handleType);
+}
+
+TEST_F(routingInterfaceTest,setSourceVolumeNoChange)
+{
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_Handle_s handle;
+ am_volume_t volume=34;
+ am_RampType_e rampType=RAMP_DIRECT;
+ am_time_t rampTime=300;
+ std::vector<am_Handle_s>listHandles;
+ pCF.createSource(source);
+ pCF.createDomain(domain);
+ domain.name="mock";
+ domain.busname="mock";
+ source.sourceID=2;
+ source.domainID=1;
+ source.volume=volume;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
+ EXPECT_CALL(pMockInterface,asyncSetSourceVolume(_,2,volume,rampType,rampTime)).Times(0);
+ ASSERT_EQ(E_NO_CHANGE,pControlReceiver.setSourceVolume(handle,2,volume,rampType,rampTime));
+ ASSERT_EQ(E_OK,pControlReceiver.getListHandles(listHandles));
+ ASSERT_TRUE(listHandles.empty());
+}
+
+TEST_F(routingInterfaceTest,setSourceVolume)
+{
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_Handle_s handle;
+ am_volume_t volume=34;
+ am_RampType_e rampType=RAMP_DIRECT;
+ am_time_t rampTime=300;
+ std::vector<am_Handle_s>listHandles;
+ pCF.createSource(source);
+ pCF.createDomain(domain);
+ domain.name="mock";
+ domain.busname="mock";
+ source.sourceID=2;
+ source.domainID=1;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
+ EXPECT_CALL(pMockInterface,asyncSetSourceVolume(_,2,volume,rampType,rampTime)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK,pControlReceiver.setSourceVolume(handle,2,volume,rampType,rampTime));
+ ASSERT_NE(handle.handle,0);
+ ASSERT_EQ(handle.handleType,H_SETSOURCEVOLUME);
+ ASSERT_EQ(E_OK,pControlReceiver.getListHandles(listHandles));
+ ASSERT_TRUE(listHandles[0].handle==handle.handle);
+ ASSERT_TRUE(listHandles[0].handleType==handle.handleType);
+}
+
+TEST_F(routingInterfaceTest,setSinkVolumeNoChange)
+{
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_Handle_s handle;
+ am_volume_t volume=34;
+ am_RampType_e rampType=RAMP_DIRECT;
+ am_time_t rampTime=300;
+ std::vector<am_Handle_s>listHandles;
+ pCF.createSink(sink);
+ pCF.createDomain(domain);
+ domain.name="mock";
+ domain.busname="mock";
+ sink.sinkID=2;
+ sink.domainID=1;
+ sink.volume=volume;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
+ EXPECT_CALL(pMockInterface,asyncSetSinkVolume(_,2,volume,rampType,rampTime)).Times(0);
+ ASSERT_EQ(E_NO_CHANGE,pControlReceiver.setSinkVolume(handle,2,volume,rampType,rampTime));
+ ASSERT_EQ(E_OK,pControlReceiver.getListHandles(listHandles));
+ ASSERT_TRUE(listHandles.empty());
+}
+
+TEST_F(routingInterfaceTest,setSinkVolume)
+{
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_Handle_s handle;
+ am_volume_t volume=34;
+ am_RampType_e rampType=RAMP_DIRECT;
+ am_time_t rampTime=300;
+ std::vector<am_Handle_s>listHandles;
+ pCF.createSink(sink);
+ pCF.createDomain(domain);
+ domain.name="mock";
+ domain.busname="mock";
+ sink.sinkID=2;
+ sink.domainID=1;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
+ EXPECT_CALL(pMockInterface,asyncSetSinkVolume(_,2,volume,rampType,rampTime)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK,pControlReceiver.setSinkVolume(handle,2,volume,rampType,rampTime));
+ ASSERT_NE(handle.handle,0);
+ ASSERT_EQ(handle.handleType,H_SETSINKVOLUME);
+ ASSERT_EQ(E_OK,pControlReceiver.getListHandles(listHandles));
+ ASSERT_TRUE(listHandles[0].handle==handle.handle);
+ ASSERT_TRUE(listHandles[0].handleType==handle.handleType);
+}
+
+TEST_F(routingInterfaceTest,connect)
+{
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_Handle_s handle;
+ am_connectionID_t connectionID;
+ std::vector<am_Handle_s>listHandles;
+ pCF.createSink(sink);
+ pCF.createDomain(domain);
+ domain.name="mock";
+ domain.busname="mock";
+ sink.sinkID=2;
+ sink.domainID=1;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
+ EXPECT_CALL(pMockInterface,asyncConnect(_,_,1,sinkID,CF_ANALOG)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK,pControlReceiver.connect(handle,connectionID,CF_ANALOG,1,2));
+ ASSERT_NE(handle.handle,0);
+ ASSERT_EQ(handle.handleType,H_CONNECT);
+ ASSERT_EQ(E_OK,pControlReceiver.getListHandles(listHandles));
+ ASSERT_TRUE(listHandles[0].handle==handle.handle);
+ ASSERT_TRUE(listHandles[0].handleType==handle.handleType);
+}
+
+TEST_F(routingInterfaceTest,disconnect)
+{
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_Handle_s handle;
+ am_connectionID_t connectionID;
+ std::vector<am_Handle_s>listHandles;
+ pCF.createSink(sink);
+ pCF.createDomain(domain);
+ domain.name="mock";
+ domain.busname="mock";
+ sink.sinkID=2;
+ sink.domainID=1;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
+ EXPECT_CALL(pMockInterface,asyncConnect(_,_,1,sinkID,CF_ANALOG)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK,pControlReceiver.connect(handle,connectionID,CF_ANALOG,1,2));
+ ASSERT_EQ(E_OK,pDatabaseHandler.changeConnectionFinal(connectionID));
+ EXPECT_CALL(pMockInterface,asyncDisconnect(_,connectionID)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK,pControlReceiver.disconnect(handle,connectionID));
+ ASSERT_NE(handle.handle,0);
+ ASSERT_EQ(handle.handleType,H_DISCONNECT);
+ ASSERT_EQ(E_OK,pControlReceiver.getListHandles(listHandles));
+ ASSERT_TRUE(listHandles[1].handle==handle.handle);
+ ASSERT_TRUE(listHandles[1].handleType==handle.handleType);
+}
+
+TEST_F(routingInterfaceTest,nothingTodisconnect)
+{
+ am_Handle_s handle;
+ am_connectionID_t connectionID=4;
+ std::vector<am_Handle_s>listHandles;
+ ASSERT_EQ(E_NON_EXISTENT,pControlReceiver.disconnect(handle,connectionID));
+ ASSERT_EQ(E_OK,pControlReceiver.getListHandles(listHandles));
+ ASSERT_TRUE(listHandles.empty());
+}
+
+
+TEST_F(routingInterfaceTest,setSourceStateNoChange)
+{
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_Handle_s handle;
+ handle.handle=0;
+ am_SourceState_e state=SS_PAUSED;
+ pCF.createSource(source);
+ pCF.createDomain(domain);
+ domain.name="mock";
+ domain.busname="mock";
+ source.domainID=1;
+ source.sourceState=state;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
+ EXPECT_CALL(pMockInterface,asyncSetSourceState(_,sourceID,state)).Times(0);
+ ASSERT_EQ(E_NO_CHANGE,pControlReceiver.setSourceState(handle,sourceID,state));
+}
+
+
+int main(int argc, char **argv)
+{
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
+
diff --git a/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.h b/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.h
new file mode 100644
index 0000000..f46ea5f
--- /dev/null
+++ b/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.h
@@ -0,0 +1,49 @@
+/*
+ * routingInterfaceTest.h
+ *
+ * Created on: Dec 10, 2011
+ * Author: christian
+ */
+
+#ifndef ROUTINGINTERFACETEST_H_
+#define ROUTINGINTERFACETEST_H_
+
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+#include <dlt/dlt.h>
+#include <algorithm>
+#include <string>
+#include <vector>
+#include <set>
+#include "MockRoutingInterface.h"
+#include "DatabaseHandler.h"
+#include "ControlReceiver.h"
+#include "ControlSender.h"
+#include "Observer.h"
+#include "../RoutingInterfaceBackdoor.h"
+#include "../CommandInterfaceBackdoor.h"
+#include "../CommonFunctions.h"
+
+DLT_DECLARE_CONTEXT(AudioManager)
+
+using namespace testing;
+using namespace am;
+
+class routingInterfaceTest : public Test{
+public:
+ routingInterfaceTest();
+ virtual ~routingInterfaceTest();
+ DatabaseHandler pDatabaseHandler;
+ RoutingSender pRoutingSender;
+ CommandSender pCommandSender;
+ MockRoutingSendInterface pMockInterface;
+ RoutingInterfaceBackdoor pRoutingInterfaceBackdoor;
+ CommandInterfaceBackdoor pCommandInterfaceBackdoor;
+ ControlReceiver pControlReceiver;
+ Observer pObserver;
+ CommonFunctions pCF;
+ void SetUp();
+ void TearDown();
+};
+
+#endif /* ROUTINGINTERFACETEST_H_ */