aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Frühberger <Peter.Fruehberger@gmail.com>2017-01-08 14:24:58 +0100
committerGitHub <noreply@github.com>2017-01-08 14:24:58 +0100
commit60bcae225f2adbecf85857b34d486d639da275b9 (patch)
tree46ff9da7ec454e57ccca38431cf650744abe465b
parent509c6d6e8f74eaf7445794e936e17684e075d18d (diff)
parent2a13c92dc6f67d40a5688f7cd61b0dcc87a60546 (diff)
Merge pull request #11395 from fetzerch/aeoverride-krypton
[backport] [cmake] Platform specific overrides
-rw-r--r--project/cmake/scripts/common/Macros.cmake47
-rw-r--r--xbmc/cores/AudioEngine/AEDefines.h26
-rw-r--r--xbmc/cores/AudioEngine/CMakeLists.txt1
-rw-r--r--xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp7
-rw-r--r--xbmc/cores/AudioEngine/overrides/android/AEDefines.h24
5 files changed, 100 insertions, 5 deletions
diff --git a/project/cmake/scripts/common/Macros.cmake b/project/cmake/scripts/common/Macros.cmake
index 8fc1054895..17ab1aab22 100644
--- a/project/cmake/scripts/common/Macros.cmake
+++ b/project/cmake/scripts/common/Macros.cmake
@@ -51,6 +51,53 @@ function(source_group_by_folder target)
endif()
endfunction()
+# Marks header file as being overridden on a certain list of platforms.
+#
+# Explicitly marking a file as overridden on specific platforms avoids issues with globbing where
+# CMake would have to be called manually when overriding for a new platform.
+#
+# Usage: add_platform_override(${PROJECT_NAME} settings.h PLATFORMS android linux osx)
+function(add_platform_override target filename)
+ cmake_parse_arguments(ARG "" "" "PLATFORMS" ${ARGN})
+ if(NOT ARG_PLATFORMS)
+ message(FATAL_ERROR "Missing parameter PLATFORMS")
+ endif()
+
+ # Generate an _override.h header that is either empty (platform doesn't define overrides)
+ # or includes the corresponding platform override header.
+ # This _override.h has to be included by the generic header.
+
+ # Determine filename of override header.
+ string(REPLACE ".h" "_override.h" override_file ${filename})
+
+ # Check if we have an override defined for this platform.
+ # TODO: Replace by if(IN_LIST) once we bump to CMake 3.3
+ if(";${ARG_PLATFORMS};" MATCHES ";${CORE_SYSTEM_NAME};")
+ message(STATUS "Override active for ${filename} on ${CORE_SYSTEM_NAME}")
+ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${override_file} "#include \"overrides/${CORE_SYSTEM_NAME}/${filename}\"")
+
+ # Add platform specific header to target sources (for IDEs)
+ target_sources(${target} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/overrides/${CORE_SYSTEM_NAME}/${filename})
+ else()
+ # Issue an error if a file exists but it's not listed in add_platform_override.
+ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/overrides/${CORE_SYSTEM_NAME}/${filename})
+ message(FATAL_ERROR "Disabled platform override file detected, add it to the 'add_platform_override' call.")
+ endif()
+
+ message(STATUS "Override disabled for ${filename}, using generic implementation")
+ string(CONCAT COMMENT "// No platform override defined for ${CORE_SYSTEM_NAME}. To add overrides:\n"
+ "// Create '${CMAKE_CURRENT_SOURCE_DIR}/overrides/${CORE_SYSTEM_NAME}/${filename}' and redefine symbols from '${filename}'.\n"
+ "// Then adapt '${CMAKE_CURRENT_LIST_FILE}' and add '${CORE_SYSTEM_NAME}' to the 'add_platform_override' call.")
+ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${override_file} ${COMMENT})
+ endif()
+
+ # Add generated file to target sources (for IDEs)
+ target_sources(${target} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/${override_file})
+
+ # TODO: If we want to allow the usage of the header in others headers, change to PUBLIC
+ target_include_directories(${target} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
+endfunction()
+
# Add sources to main application
# Arguments:
# name name of the library to add
diff --git a/xbmc/cores/AudioEngine/AEDefines.h b/xbmc/cores/AudioEngine/AEDefines.h
new file mode 100644
index 0000000000..ab9e63ddf7
--- /dev/null
+++ b/xbmc/cores/AudioEngine/AEDefines.h
@@ -0,0 +1,26 @@
+#pragma once
+/*
+ * Copyright (C) 2010-2017 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#define AE_AC3_ENCODE_BITRATE 640000
+#define AE_DTS_ENCODE_BITRATE 1411200
+
+// Enable platform specific overrides
+#include "AEDefines_override.h"
diff --git a/xbmc/cores/AudioEngine/CMakeLists.txt b/xbmc/cores/AudioEngine/CMakeLists.txt
index 6400b4fa99..cc85b53eaf 100644
--- a/xbmc/cores/AudioEngine/CMakeLists.txt
+++ b/xbmc/cores/AudioEngine/CMakeLists.txt
@@ -128,6 +128,7 @@ if(CORE_SYSTEM_NAME STREQUAL freebsd)
endif()
core_add_library(audioengine)
+add_platform_override(${CORE_LIBRARY} AEDefines.h PLATFORMS android)
target_include_directories(${CORE_LIBRARY} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
if(NOT CORE_SYSTEM_NAME STREQUAL windows)
if(HAVE_SSE)
diff --git a/xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp b/xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp
index b281c69487..a2a88fa7ca 100644
--- a/xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp
+++ b/xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp
@@ -18,9 +18,7 @@
*
*/
-#define AC3_ENCODE_BITRATE 640000
-#define DTS_ENCODE_BITRATE 1411200
-
+#include "cores/AudioEngine/AEDefines.h"
#include "cores/AudioEngine/Encoders/AEEncoderFFmpeg.h"
#include "cores/AudioEngine/Utils/AEUtil.h"
#include "utils/log.h"
@@ -107,7 +105,7 @@ bool CAEEncoderFFmpeg::Initialize(AEAudioFormat &format, bool allow_planar_input
{
m_CodecName = "AC3";
m_CodecID = AV_CODEC_ID_AC3;
- m_BitRate = AC3_ENCODE_BITRATE;
+ m_BitRate = AE_AC3_ENCODE_BITRATE;
codec = avcodec_find_encoder(m_CodecID);
}
@@ -325,4 +323,3 @@ double CAEEncoderFFmpeg::GetDelay(unsigned int bufferSize)
return ((double)frames + ((double)bufferSize * m_OutputRatio)) * m_SampleRateMul;
}
-
diff --git a/xbmc/cores/AudioEngine/overrides/android/AEDefines.h b/xbmc/cores/AudioEngine/overrides/android/AEDefines.h
new file mode 100644
index 0000000000..4b1b0b0877
--- /dev/null
+++ b/xbmc/cores/AudioEngine/overrides/android/AEDefines.h
@@ -0,0 +1,24 @@
+#pragma once
+/*
+ * Copyright (C) 2010-2017 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+// Several Android TV devices only support 384 kbit/s as maximum
+#undef AE_AC3_ENCODE_BITRATE
+#define AE_AC3_ENCODE_BITRATE 384000