diff options
208 files changed, 1881 insertions, 2812 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b4348f7a7..19c914a7de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,8 +118,7 @@ if(UNIX) option(ENABLE_INTERNAL_GTEST "Enable internal gtest?" OFF) option(ENABLE_INTERNAL_UDFREAD "Enable internal udfread?" OFF) endif() -# prefer kissfft from xbmc/contrib but let use system one on unices -cmake_dependent_option(ENABLE_INTERNAL_KISSFFT "Enable internal kissfft?" ON "UNIX" ON) + # System options if(NOT WIN32) option(WITH_ARCH "build with given arch" OFF) @@ -213,7 +212,6 @@ set(required_deps ASS>=0.15.0 Fstrcmp HarfBuzz Iconv - KissFFT LibDvd Lzo2 OpenSSL>=1.1.0 @@ -298,7 +296,7 @@ endif() set(outputFilterRegex "addons/xbmc.json") find_addon_xml_in_files(${outputFilterRegex}) -if(TARGET ALSA::ALSA AND TARGET PulseAudio::PulseAudio) +if(TARGET ${APP_NAME_LC}::Alsa AND TARGET PulseAudio::PulseAudio) list(APPEND AUDIO_BACKENDS_LIST "alsa+pulseaudio") endif() @@ -326,7 +324,7 @@ list(APPEND install_data ${ADDON_INSTALL_DATA}) add_library(compileinfo OBJECT ${CORE_BUILD_DIR}/xbmc/CompileInfo.cpp) set_target_properties(compileinfo PROPERTIES FOLDER "Build Utilities") target_compile_options(compileinfo PRIVATE ${SYSTEM_DEFINES} ${ARCH_DEFINES}) -add_dependencies(compileinfo fmt::fmt) +target_link_libraries(compileinfo PRIVATE ${APP_NAME_LC}::Fmt) if(NOT MSVC) target_compile_options(compileinfo PUBLIC ${CORE_COMPILE_OPTIONS}) @@ -411,6 +409,7 @@ core_add_optional_subdirs_from_filelist(${CMAKE_SOURCE_DIR}/cmake/treedata/optio ${CMAKE_SOURCE_DIR}/cmake/treedata/optional/${CORE_SYSTEM_NAME}/*.txt) target_link_libraries(lib${APP_NAME_LC} PUBLIC ${core_DEPENDS} ${SYSTEM_LDFLAGS} ${DEPLIBS} ${CMAKE_DL_LIBS} ${GLOBAL_TARGET_DEPS}) +core_target_link_libraries(lib${APP_NAME_LC}) set_target_properties(lib${APP_NAME_LC} PROPERTIES PROJECT_LABEL "xbmc") source_group_by_folder(lib${APP_NAME_LC} RELATIVE ${CMAKE_SOURCE_DIR}/xbmc) if(WIN32) @@ -435,7 +434,7 @@ else() endif() add_dependencies(${APP_NAME_LC} ${APP_NAME_LC}-libraries) -whole_archive(_MAIN_LIBRARIES ${FSTRCMP_LIBRARY} ${core_DEPENDS}) +whole_archive(_MAIN_LIBRARIES ${core_DEPENDS}) target_link_libraries(${APP_NAME_LC} ${_MAIN_LIBRARIES} lib${APP_NAME_LC} ${DEPLIBS}) unset(_MAIN_LIBRARIES) diff --git a/addons/resource.language.en_gb/resources/strings.po b/addons/resource.language.en_gb/resources/strings.po index 2108600360..95cc956764 100644 --- a/addons/resource.language.en_gb/resources/strings.po +++ b/addons/resource.language.en_gb/resources/strings.po @@ -3916,7 +3916,13 @@ msgctxt "#852" msgid "Valid port range is 1024-65535" msgstr "" -#empty strings from id 853 to 996 +#. Label for denoting any channel for a certain client in timer settings dialog +#: xbmc/pvr/dialogs/GUIDislogPVRTimerSettings.cpp +msgctxt "#853" +msgid "Any channel from client \"{0:s}\"" +msgstr "" + +#empty strings from id 854 to 996 #: xbmc/windows/GUIMediaWindow.cpp msgctxt "#997" diff --git a/addons/skin.estuary/xml/DialogPVRInfo.xml b/addons/skin.estuary/xml/DialogPVRInfo.xml index 44d9e56fc2..86a1edd432 100644 --- a/addons/skin.estuary/xml/DialogPVRInfo.xml +++ b/addons/skin.estuary/xml/DialogPVRInfo.xml @@ -49,7 +49,7 @@ <width>1050</width> <height>425</height> <align>justify</align> - <label>$INFO[ListItem.ChannelName,[B],[/B][CR]]$INFO[ListItem.Date,[COLOR grey]$LOCALIZE[552]:[/COLOR] ,[CR]]$INFO[ListItem.Duration,[COLOR grey]$LOCALIZE[180]:[/COLOR] ,[CR]]$VAR[RecordingSizeLabel]$VAR[PremieredLabel]$INFO[ListItem.Rating,[COLOR grey]$LOCALIZE[563]:[/COLOR] ,[CR]]$VAR[ExpirationDateTimeLabel]$VAR[PVRInstanceName]$INFO[ListItem.Genre,[COLOR grey]$LOCALIZE[515]: [/COLOR]][CR]$INFO[ListItem.ParentalRatingCode,[COLOR grey]$LOCALIZE[31017]: [/COLOR],[CR]]$INFO[ListItem.Writer,[COLOR grey]$LOCALIZE[20417]:[/COLOR] ,[CR]]$INFO[ListItem.Director,[COLOR grey]$LOCALIZE[20339]:[/COLOR] ,[CR]]$INFO[ListItem.Cast,[COLOR grey]$LOCALIZE[206]:[/COLOR] ,[CR]][CR]$INFO[ListItem.Plot]</label> + <label>$INFO[ListItem.ChannelName,[B],[/B][CR]]$INFO[ListItem.Date,[COLOR grey]$LOCALIZE[552]:[/COLOR] ,[CR]]$INFO[ListItem.Duration,[COLOR grey]$LOCALIZE[180]:[/COLOR] ,[CR]]$VAR[RecordingSizeLabel]$VAR[PremieredLabel]$INFO[ListItem.Rating,[COLOR grey]$LOCALIZE[563]:[/COLOR] ,[CR]]$VAR[ExpirationDateTimeLabel]$VAR[PVRInstanceName,,[CR]]$INFO[ListItem.Genre,[COLOR grey]$LOCALIZE[515]: [/COLOR]][CR]$INFO[ListItem.ParentalRatingCode,[COLOR grey]$LOCALIZE[31017]: [/COLOR],[CR]]$INFO[ListItem.Writer,[COLOR grey]$LOCALIZE[20417]:[/COLOR] ,[CR]]$INFO[ListItem.Director,[COLOR grey]$LOCALIZE[20339]:[/COLOR] ,[CR]]$INFO[ListItem.Cast,[COLOR grey]$LOCALIZE[206]:[/COLOR] ,[CR]][CR]$INFO[ListItem.Plot]</label> <autoscroll time="3000" delay="4000" repeat="5000">Skin.HasSetting(AutoScroll)</autoscroll> </control> <control type="grouplist" id="9000"> diff --git a/addons/skin.estuary/xml/Includes_PVR.xml b/addons/skin.estuary/xml/Includes_PVR.xml index c4081f232f..c482d2b708 100644 --- a/addons/skin.estuary/xml/Includes_PVR.xml +++ b/addons/skin.estuary/xml/Includes_PVR.xml @@ -440,7 +440,7 @@ <top>465</top> <width>830</width> <bottom>list_bottom_offset</bottom> - <label>$VAR[PVRInstanceName]$VAR[FlagLabel,,[CR]]$INFO[ListItem.Genre,[COLOR grey]$LOCALIZE[515]:[/COLOR] ,[CR]]$INFO[ListItem.ParentalRatingCode,[COLOR grey]$LOCALIZE[31017]: [/COLOR],[CR]]$INFO[ListItem.TimerType,[COLOR grey]$LOCALIZE[803]:[/COLOR] ,[CR]]$VAR[RecordingSizeLabel]$VAR[ExpirationDateTimeLabel]$INFO[ListItem.Plot,[CR]]</label> + <label>$VAR[PVRInstanceName,,[CR]]$VAR[FlagLabel,,[CR]]$INFO[ListItem.Genre,[COLOR grey]$LOCALIZE[515]:[/COLOR] ,[CR]]$INFO[ListItem.ParentalRatingCode,[COLOR grey]$LOCALIZE[31017]: [/COLOR],[CR]]$INFO[ListItem.TimerType,[COLOR grey]$LOCALIZE[803]:[/COLOR] ,[CR]]$VAR[RecordingSizeLabel]$VAR[ExpirationDateTimeLabel]$INFO[ListItem.Plot,[CR]]</label> <autoscroll delay="10000" time="3000" repeat="10000">Skin.HasSetting(AutoScroll)</autoscroll> </control> </control> @@ -451,7 +451,7 @@ <top>10</top> <width>830</width> <height>262</height> - <label>$LOCALIZE[19076] ($INFO[Container(5000).NumItems,[B],[/B] $LOCALIZE[31036]]) $INFO[ListItem.Property(recordingsize),- $LOCALIZE[20161]: [B],[/B]] $VAR[PVRInstanceName]</label> + <label>$LOCALIZE[19076] ($INFO[Container(5000).NumItems,[B],[/B] $LOCALIZE[31036]]) $INFO[ListItem.Property(recordingsize),- $LOCALIZE[20161]: [B],[/B]]</label> <font>font37</font> <visible>!ListItem.IsParentFolder</visible> </control> @@ -526,6 +526,53 @@ <visible>!String.IsEmpty(PVR.ChannelNumberInput)</visible> </control> </include> + <include name="EpgEventDetails"> + <definition> + <control type="group"> + <top>0</top> + <left>350</left> + <right>$PARAM[right]</right> + <control type="label"> + <width>100%</width> + <height>30</height> + <label>[B]$INFO[ListItem.EpgEventTitle][/B] $INFO[ListItem.Year,([COLOR grey],[/COLOR])]</label> + </control> + <control type="label"> + <top>35</top> + <width>100%</width> + <height>30</height> + <label>$VAR[FlagDashLabel][I][COLOR grey]$VAR[SeasonEpisodeLabel][/COLOR]$INFO[ListItem.EpisodeName,[COLOR white],[/COLOR]][/I]</label> + </control> + </control> + <control type="textbox"> + <left>350</left> + <top>85</top> + <right>$PARAM[right]</right> + <height>130</height> + <align>justify</align> + <label>$INFO[ListItem.Plot]</label> + <autoscroll delay="10000" time="3000" repeat="10000">Skin.HasSetting(AutoScroll)</autoscroll> + </control> + <control type="group"> + <top>220</top> + <left>350</left> + <control type="label"> + <top>0</top> + <width>25%</width> + <height>30</height> + <label>$INFO[ListItem.StartTime,[COLOR button_focus]$LOCALIZE[555]:[/COLOR] ]$INFO[ListItem.EndTime, - ]</label> + </control> + <control type="label"> + <top>0</top> + <right>$PARAM[right]</right> + <width>75%</width> + <height>30</height> + <align>right</align> + <label>$INFO[ListItem.Genre,[COLOR button_focus]$LOCALIZE[515]:[/COLOR] ]</label> + </control> + </control> + </definition> + </include> <include name="EpgGrid"> <definition> <control type="epggrid" id="$PARAM[control_id]"> diff --git a/addons/skin.estuary/xml/MyPVRGuide.xml b/addons/skin.estuary/xml/MyPVRGuide.xml index c84b51c15a..80e866422f 100644 --- a/addons/skin.estuary/xml/MyPVRGuide.xml +++ b/addons/skin.estuary/xml/MyPVRGuide.xml @@ -178,47 +178,29 @@ <height>250</height> <aspectratio align="center" aligny="center">keep</aspectratio> <fadetime>400</fadetime> - <texture>$INFO[ListItem.Icon]</texture> + <texture>$INFO[ListItem.ChannelLogo]</texture> </control> <control type="group"> - <top>0</top> - <left>350</left> - <control type="label"> - <width>70%</width> - <height>30</height> - <label>[B]$INFO[ListItem.EpgEventTitle][/B] $INFO[ListItem.Year,([COLOR grey],[/COLOR])]</label> - </control> - <control type="label"> - <top>0</top> - <right>30</right> - <width>30%</width> - <height>30</height> - <align>right</align> - <label>[COLOR button_focus]$INFO[ListItem.StartTime,[COLOR grey]$LOCALIZE[555]:[/COLOR] ][/COLOR]$INFO[ListItem.EndTime,[COLOR button_focus] - ,[/COLOR]]</label> - </control> - <control type="label"> - <top>35</top> - <width>60%</width> - <height>30</height> - <label>$VAR[FlagDashLabel][I][COLOR grey]$VAR[SeasonEpisodeLabel][/COLOR]$INFO[ListItem.EpisodeName,[COLOR white],[/COLOR]][/I]</label> - </control> - <control type="label"> - <top>35</top> - <right>30</right> - <width>40%</width> - <height>30</height> - <align>right</align> - <label>$INFO[ListItem.Genre,[COLOR grey]$LOCALIZE[515]:[/COLOR] ]</label> - </control> + <visible>String.IsEmpty(ListItem.EpgEventIcon)</visible> + <include content="EpgEventDetails"> + <param name="right" value="30"/> + </include> </control> - <control type="textbox"> - <left>350</left> - <top>85</top> + <control type="group"> + <visible>!String.IsEmpty(ListItem.EpgEventIcon)</visible> + <include content="EpgEventDetails"> + <param name="right" value="350"/> + </include> + </control> + <control type="image"> + <top>10</top> <right>30</right> - <height>170</height> - <align>justify</align> - <label>$INFO[ListItem.Plot]</label> - <autoscroll delay="10000" time="3000" repeat="10000">Skin.HasSetting(AutoScroll)</autoscroll> + <width>290</width> + <height>250</height> + <aspectratio align="center" aligny="center">keep</aspectratio> + <fadetime>400</fadetime> + <texture>$INFO[ListItem.EpgEventIcon]</texture> + <visible>!String.IsEmpty(ListItem.EpgEventIcon)</visible> </control> </control> </control> diff --git a/addons/skin.estuary/xml/Variables.xml b/addons/skin.estuary/xml/Variables.xml index 06d8b9b2b1..041a0c765f 100644 --- a/addons/skin.estuary/xml/Variables.xml +++ b/addons/skin.estuary/xml/Variables.xml @@ -799,6 +799,6 @@ <value>$INFO[ListItem.Duration,$LOCALIZE[180]: ][CR]$VAR[VideoCodecVar,, ]$INFO[ListItem.VideoResolution,| , ]$VAR[VideoResolutionTypeVar,, ]$VAR[VideoHDRVar,| , ]$INFO[ListItem.VideoAspect,| ,:1 ]$VAR[AudioCodecVar,| , ]$VAR[AudioChannelsVar]</value> </variable> <variable name="PVRInstanceName"> - <value condition="Integer.IsGreater(System.PVRCount,1)">$INFO[ListItem.BackendInstanceName,[COLOR grey]$LOCALIZE[31137]:[/COLOR] ,[CR]]</value> + <value condition="Integer.IsGreater(PVR.ClientCount,1)">$INFO[ListItem.PVRClientName,[COLOR grey]$LOCALIZE[31137]:[/COLOR] ,]$INFO[ListItem.PVRInstanceName, (,)]</value> </variable> </includes> diff --git a/cmake/modules/FindASS.cmake b/cmake/modules/FindASS.cmake index 8dd36bdc3b..9420dd8f79 100644 --- a/cmake/modules/FindASS.cmake +++ b/cmake/modules/FindASS.cmake @@ -5,35 +5,52 @@ # # This will define the following target: # -# ASS::ASS - The ASS library +# ${APP_NAME_LC}::ASS - The ASS library # -if(NOT TARGET ASS::ASS) +if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME}) + find_package(PkgConfig) # Do not use pkgconfig on windows - if(PKG_CONFIG_FOUND AND NOT WIN32) + if(PKG_CONFIG_FOUND AND NOT (WIN32 OR WINDOWS_STORE)) pkg_check_modules(PC_ASS libass QUIET IMPORTED_TARGET) # INTERFACE_LINK_OPTIONS is incorrectly populated when cmake generation is executed # when an existing build generation is already done. Just set this to blank set_target_properties(PkgConfig::PC_ASS PROPERTIES INTERFACE_LINK_OPTIONS "") + # First item is the full path of the library file found + # pkg_check_modules does not populate a variable of the found library explicitly + list(GET PC_ASS_LINK_LIBRARIES 0 ASS_LIBRARY) + set(ASS_INCLUDE_DIR ${PC_ASS_INCLUDEDIR}) set(ASS_VERSION ${PC_ASS_VERSION}) - elseif(WIN32) + elseif(WIN32 OR WINDOWS_STORE) find_package(libass CONFIG QUIET REQUIRED HINTS ${DEPENDS_PATH}/lib/cmake ${${CORE_PLATFORM_NAME_LC}_SEARCH_CONFIG}) + + # we only do this because we use find_package_handle_standard_args for config time output + # and it isnt capable of handling TARGETS, so we have to extract the info + get_target_property(_ASS_CONFIGURATIONS libass::libass IMPORTED_CONFIGURATIONS) + foreach(_ass_config IN LISTS _ASS_CONFIGURATIONS) + # Some non standard config (eg None on Debian) + # Just set to RELEASE var so select_library_configurations can continue to work its magic + string(TOUPPER ${_ass_config} _ass_config_UPPER) + if((NOT ${_ass_config_UPPER} STREQUAL "RELEASE") AND + (NOT ${_ass_config_UPPER} STREQUAL "DEBUG")) + get_target_property(ASS_LIBRARY_RELEASE libass::libass IMPORTED_LOCATION_${_ass_config_UPPER}) + else() + get_target_property(ASS_LIBRARY_${_ass_config_UPPER} libass::libass IMPORTED_LOCATION_${_ass_config_UPPER}) + endif() + endforeach() + + get_target_property(ASS_INCLUDE_DIR libass::libass INTERFACE_INCLUDE_DIRECTORIES) set(ASS_VERSION ${libass_VERSION}) - endif() - find_path(ASS_INCLUDE_DIR NAMES ass/ass.h - HINTS ${DEPENDS_PATH}/include ${PC_ASS_INCLUDEDIR} - ${${CORE_PLATFORM_LC}_SEARCH_CONFIG} - NO_CACHE) - find_library(ASS_LIBRARY NAMES ass libass - HINTS ${DEPENDS_PATH}/lib ${PC_ASS_LIBDIR} - ${${CORE_PLATFORM_LC}_SEARCH_CONFIG} - NO_CACHE) + include(SelectLibraryConfigurations) + select_library_configurations(ASS) + unset(ASS_LIBRARIES) + endif() include(FindPackageHandleStandardArgs) find_package_handle_standard_args(ASS @@ -42,16 +59,14 @@ if(NOT TARGET ASS::ASS) if(ASS_FOUND) if(TARGET PkgConfig::PC_ASS) - add_library(ASS::ASS ALIAS PkgConfig::PC_ASS) + add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} ALIAS PkgConfig::PC_ASS) elseif(TARGET libass::libass) # Kodi custom libass target used for windows platforms - add_library(ASS::ASS ALIAS libass::libass) - else() - add_library(ASS::ASS UNKNOWN IMPORTED) - set_target_properties(ASS::ASS PROPERTIES - IMPORTED_LOCATION "${ASS_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${ASS_INCLUDE_DIR}") + add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} ALIAS libass::libass) + endif() + else() + if(ASS_FIND_REQUIRED) + message(FATAL_ERROR "Ass libraries were not found.") endif() - set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP ASS::ASS) endif() endif() diff --git a/cmake/modules/FindAcbAPI.cmake b/cmake/modules/FindAcbAPI.cmake index 04f2de389f..8d43d1b1a8 100644 --- a/cmake/modules/FindAcbAPI.cmake +++ b/cmake/modules/FindAcbAPI.cmake @@ -5,9 +5,9 @@ # # This will define the following target: # -# ACBAPI::ACBAPI - The acbAPI library +# ${APP_NAME_LC}::AcbAPI - The acbAPI library -if(NOT TARGET ACBAPI::ACBAPI) +if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME}) find_package(PkgConfig) if(PKG_CONFIG_FOUND) pkg_check_modules(PC_ACBAPI libAcbAPI QUIET) @@ -28,15 +28,18 @@ if(NOT TARGET ACBAPI::ACBAPI) VERSION_VAR ACBAPI_VERSION) if(ACBAPI_FOUND) - add_library(ACBAPI::ACBAPI UNKNOWN IMPORTED) - set_target_properties(ACBAPI::ACBAPI PROPERTIES - IMPORTED_LOCATION "${ACBAPI_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${ACBAPI_INCLUDE_DIR}") - set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP ACBAPI::ACBAPI) + add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UNKNOWN IMPORTED) + set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES + IMPORTED_LOCATION "${ACBAPI_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${ACBAPI_INCLUDE_DIR}") # creates an empty library to install on webOS 5+ devices file(TOUCH dummy.c) add_library(AcbAPI SHARED dummy.c) set_target_properties(AcbAPI PROPERTIES VERSION 1.0.0 SOVERSION 1) + else() + if(AcbAPI_FIND_REQUIRED) + message(FATAL_ERROR "AcbAPI libraries were not found.") + endif() endif() endif() diff --git a/cmake/modules/FindAlsa.cmake b/cmake/modules/FindAlsa.cmake index baec0bd86f..c2d971f4e2 100644 --- a/cmake/modules/FindAlsa.cmake +++ b/cmake/modules/FindAlsa.cmake @@ -5,9 +5,9 @@ # # This will define the following target: # -# ALSA::ALSA - The Alsa library +# ${APP_NAME_LC}::Alsa - The Alsa library -if(NOT TARGET ALSA::ALSA) +if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME}) find_package(PkgConfig) if(Alsa_FIND_VERSION) @@ -41,10 +41,9 @@ if(NOT TARGET ALSA::ALSA) set(AUDIO_BACKENDS_LIST ${AUDIO_BACKENDS_LIST} PARENT_SCOPE) # We explicitly dont include ALSA_INCLUDE_DIR, as 'timer.h' is a dangerous file - add_library(ALSA::ALSA UNKNOWN IMPORTED) - set_target_properties(ALSA::ALSA PROPERTIES - IMPORTED_LOCATION "${ALSA_LIBRARY}" - INTERFACE_COMPILE_DEFINITIONS HAS_ALSA=1) - set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP ALSA::ALSA) + add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UNKNOWN IMPORTED) + set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES + IMPORTED_LOCATION "${ALSA_LIBRARY}" + INTERFACE_COMPILE_DEFINITIONS HAS_ALSA) endif() endif() diff --git a/cmake/modules/FindAvahi.cmake b/cmake/modules/FindAvahi.cmake index 6898217d14..6570375478 100644 --- a/cmake/modules/FindAvahi.cmake +++ b/cmake/modules/FindAvahi.cmake @@ -3,12 +3,12 @@ # --------- # Finds the avahi library # -# This will define the following target: +# This will define the following targets: # -# Avahi::Avahi - The avahi client library -# Avahi::AvahiCommon - The avahi common library +# ${APP_NAME_LC}::Avahi - The avahi client library +# ${APP_NAME_LC}::AvahiCommon - The avahi common library -if(NOT TARGET Avahi::Avahi) +if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME}) find_package(PkgConfig) if(PKG_CONFIG_FOUND) pkg_check_modules(PC_AVAHI avahi-client QUIET) @@ -16,20 +16,16 @@ if(NOT TARGET Avahi::Avahi) find_path(AVAHI_CLIENT_INCLUDE_DIR NAMES avahi-client/client.h HINTS ${DEPENDS_PATH}/include ${PC_AVAHI_INCLUDEDIR} - ${${CORE_PLATFORM_LC}_SEARCH_CONFIG} - NO_CACHE) + ${${CORE_PLATFORM_LC}_SEARCH_CONFIG}) find_path(AVAHI_COMMON_INCLUDE_DIR NAMES avahi-common/defs.h HINTS ${DEPENDS_PATH}/include ${PC_AVAHI_INCLUDEDIR} - ${${CORE_PLATFORM_LC}_SEARCH_CONFIG} - NO_CACHE) + ${${CORE_PLATFORM_LC}_SEARCH_CONFIG}) find_library(AVAHI_CLIENT_LIBRARY NAMES avahi-client HINTS ${DEPENDS_PATH}/lib ${PC_AVAHI_LIBDIR} - ${${CORE_PLATFORM_LC}_SEARCH_CONFIG} - NO_CACHE) + ${${CORE_PLATFORM_LC}_SEARCH_CONFIG}) find_library(AVAHI_COMMON_LIBRARY NAMES avahi-common HINTS ${DEPENDS_PATH}/lib ${PC_AVAHI_LIBDIR} - ${${CORE_PLATFORM_LC}_SEARCH_CONFIG} - NO_CACHE) + ${${CORE_PLATFORM_LC}_SEARCH_CONFIG}) set(AVAHI_VERSION ${PC_AVAHI_VERSION}) @@ -40,17 +36,17 @@ if(NOT TARGET Avahi::Avahi) VERSION_VAR AVAHI_VERSION) if(AVAHI_FOUND) - add_library(Avahi::AvahiCommon UNKNOWN IMPORTED) - set_target_properties(Avahi::AvahiCommon PROPERTIES - IMPORTED_LOCATION "${AVAHI_COMMON_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${AVAHI_COMMON_INCLUDE_DIR}" - INTERFACE_COMPILE_DEFINITIONS "HAS_AVAHI=1;HAS_ZEROCONF=1") - add_library(Avahi::Avahi UNKNOWN IMPORTED) - set_target_properties(Avahi::Avahi PROPERTIES - IMPORTED_LOCATION "${AVAHI_CLIENT_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${AVAHI_CLIENT_INCLUDE_DIR}" - INTERFACE_COMPILE_DEFINITIONS "HAS_AVAHI=1;HAS_ZEROCONF=1" - INTERFACE_LINK_LIBRARIES Avahi::AvahiCommon) - set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP Avahi::Avahi) + add_library(${APP_NAME_LC}::AvahiCommon UNKNOWN IMPORTED) + set_target_properties(${APP_NAME_LC}::AvahiCommon PROPERTIES + IMPORTED_LOCATION "${AVAHI_COMMON_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${AVAHI_COMMON_INCLUDE_DIR}" + INTERFACE_COMPILE_DEFINITIONS "HAS_AVAHI;HAS_ZEROCONF") + add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UNKNOWN IMPORTED) + set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES + IMPORTED_LOCATION "${AVAHI_CLIENT_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${AVAHI_CLIENT_INCLUDE_DIR}" + INTERFACE_COMPILE_DEFINITIONS "HAS_AVAHI;HAS_ZEROCONF" + INTERFACE_LINK_LIBRARIES ${APP_NAME_LC}::AvahiCommon) + endif() endif() diff --git a/cmake/modules/FindBluetooth.cmake b/cmake/modules/FindBluetooth.cmake index 70da7b1a4f..024c51e63b 100644 --- a/cmake/modules/FindBluetooth.cmake +++ b/cmake/modules/FindBluetooth.cmake @@ -5,20 +5,18 @@ # # This will define the following target: # -# Bluetooth::Bluetooth - The Bluetooth library +# ${APP_NAME_LC}::Bluetooth - The Bluetooth library -if(NOT TARGET Bluetooth::Bluetooth) +if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME}) find_package(PkgConfig) if(PKG_CONFIG_FOUND) pkg_check_modules(PC_BLUETOOTH bluez bluetooth QUIET) endif() find_path(BLUETOOTH_INCLUDE_DIR NAMES bluetooth/bluetooth.h - HINTS ${PC_BLUETOOTH_INCLUDEDIR} - NO_CACHE) + HINTS ${PC_BLUETOOTH_INCLUDEDIR}) find_library(BLUETOOTH_LIBRARY NAMES bluetooth libbluetooth - HINTS ${PC_BLUETOOTH_LIBDIR} - NO_CACHE) + HINTS ${PC_BLUETOOTH_LIBDIR}) set(BLUETOOTH_VERSION ${PC_BLUETOOTH_VERSION}) @@ -28,11 +26,10 @@ if(NOT TARGET Bluetooth::Bluetooth) VERSION_VAR BLUETOOTH_VERSION) if(BLUETOOTH_FOUND) - add_library(Bluetooth::Bluetooth UNKNOWN IMPORTED) - set_target_properties(Bluetooth::Bluetooth PROPERTIES - IMPORTED_LOCATION "${BLUETOOTH_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${BLUETOOTH_INCLUDE_DIR}" - INTERFACE_COMPILE_DEFINITIONS HAVE_LIBBLUETOOTH=1) - set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP Bluetooth::Bluetooth) + add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UNKNOWN IMPORTED) + set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES + IMPORTED_LOCATION "${BLUETOOTH_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${BLUETOOTH_INCLUDE_DIR}" + INTERFACE_COMPILE_DEFINITIONS HAVE_LIBBLUETOOTH) endif() endif() diff --git a/cmake/modules/FindBluray.cmake b/cmake/modules/FindBluray.cmake index 1c4f12c89d..30d27d9bdc 100644 --- a/cmake/modules/FindBluray.cmake +++ b/cmake/modules/FindBluray.cmake @@ -69,8 +69,8 @@ if(NOT TARGET Bluray::Bluray) endif() if(NOT CORE_PLATFORM_NAME_LC STREQUAL windowsstore) - set_target_properties(Bluray::Bluray PROPERTIES - INTERFACE_COMPILE_DEFINITIONS "HAVE_LIBBLURAY_BDJ=1") + set_property(TARGET Bluray::Bluray APPEND PROPERTY + INTERFACE_COMPILE_DEFINITIONS "HAVE_LIBBLURAY_BDJ") endif() set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP Bluray::Bluray) diff --git a/cmake/modules/FindCAP.cmake b/cmake/modules/FindCAP.cmake index 8cad7bab9f..d526642618 100644 --- a/cmake/modules/FindCAP.cmake +++ b/cmake/modules/FindCAP.cmake @@ -5,20 +5,18 @@ # # This will define the following target: # -# CAP::CAP - The LibCap library +# ${APP_NAME_LC}::CAP - The LibCap library -if(NOT TARGET CAP::CAP) +if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME}) find_package(PkgConfig) if(PKG_CONFIG_FOUND) pkg_check_modules(PC_CAP libcap QUIET) endif() find_path(CAP_INCLUDE_DIR NAMES sys/capability.h - HINTS ${PC_CAP_INCLUDEDIR} - NO_CACHE) + HINTS ${PC_CAP_INCLUDEDIR}) find_library(CAP_LIBRARY NAMES cap libcap - HINTS ${PC_CAP_LIBDIR} - NO_CACHE) + HINTS ${PC_CAP_LIBDIR}) set(CAP_VERSION ${PC_CAP_VERSION}) @@ -28,11 +26,10 @@ if(NOT TARGET CAP::CAP) VERSION_VAR CAP_VERSION) if(CAP_FOUND) - add_library(CAP::CAP UNKNOWN IMPORTED) - set_target_properties(CAP::CAP PROPERTIES - IMPORTED_LOCATION "${CAP_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${CAP_INCLUDE_DIR}" - INTERFACE_COMPILE_DEFINITIONS HAVE_LIBCAP=1) - set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP CAP::CAP) + add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UNKNOWN IMPORTED) + set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES + IMPORTED_LOCATION "${CAP_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${CAP_INCLUDE_DIR}" + INTERFACE_COMPILE_DEFINITIONS HAVE_LIBCAP) endif() endif() diff --git a/cmake/modules/FindCEC.cmake b/cmake/modules/FindCEC.cmake index 51b6cbb972..b15c8e4b14 100644 --- a/cmake/modules/FindCEC.cmake +++ b/cmake/modules/FindCEC.cmake @@ -5,9 +5,9 @@ # # This will define the following target: # -# CEC::CEC - The libCEC library +# ${APP_NAME_LC}::CEC - The libCEC library -if(NOT TARGET CEC::CEC) +if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME}) include(cmake/scripts/common/ModuleHelpers.cmake) macro(buildCEC) @@ -85,9 +85,8 @@ if(NOT TARGET CEC::CEC) # CEC cmake config doesnt include INTERFACE_INCLUDE_DIRECTORIES find_path(CEC_INCLUDE_DIR NAMES libcec/cec.h libCEC/CEC.h - HINTS ${DEPENDS_PATH}/include ${PC_CEC_INCLUDEDIR} - ${${CORE_PLATFORM_LC}_SEARCH_CONFIG} - NO_CACHE) + HINTS ${DEPENDS_PATH}/include + ${${CORE_PLATFORM_LC}_SEARCH_CONFIG}) set(CEC_VERSION ${libcec_VERSION}) else() find_package(PkgConfig) @@ -97,13 +96,11 @@ if(NOT TARGET CEC::CEC) endif() find_library(CEC_LIBRARY_RELEASE NAMES cec HINTS ${DEPENDS_PATH}/lib ${PC_CEC_LIBDIR} - ${${CORE_PLATFORM_LC}_SEARCH_CONFIG} - NO_CACHE) + ${${CORE_PLATFORM_LC}_SEARCH_CONFIG}) find_path(CEC_INCLUDE_DIR NAMES libcec/cec.h libCEC/CEC.h HINTS ${DEPENDS_PATH}/include ${PC_CEC_INCLUDEDIR} - ${${CORE_PLATFORM_LC}_SEARCH_CONFIG} - NO_CACHE) + ${${CORE_PLATFORM_LC}_SEARCH_CONFIG}) if(PC_CEC_VERSION) set(CEC_VERSION ${PC_CEC_VERSION}) @@ -127,26 +124,26 @@ if(NOT TARGET CEC::CEC) if(CEC_FOUND) # cmake target and not building internal if(TARGET libcec::cec AND NOT TARGET cec) - add_library(CEC::CEC ALIAS libcec::cec) + add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} ALIAS libcec::cec) # We need to append in case the cmake config already has definitions set_property(TARGET libcec::cec APPEND PROPERTY - INTERFACE_COMPILE_DEFINITIONS HAVE_LIBCEC=1) + INTERFACE_COMPILE_DEFINITIONS HAVE_LIBCEC) # pkgconfig target found elseif(TARGET PkgConfig::PC_CEC) - add_library(CEC::CEC ALIAS PkgConfig::PC_CEC) + add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} ALIAS PkgConfig::PC_CEC) set_property(TARGET PkgConfig::PC_CEC APPEND PROPERTY - INTERFACE_COMPILE_DEFINITIONS HAVE_LIBCEC=1) + INTERFACE_COMPILE_DEFINITIONS HAVE_LIBCEC) # building internal or no cmake config or pkgconfig else() - add_library(CEC::CEC UNKNOWN IMPORTED) - set_target_properties(CEC::CEC PROPERTIES - IMPORTED_LOCATION "${CEC_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${CEC_INCLUDE_DIR}" - INTERFACE_COMPILE_DEFINITIONS HAVE_LIBCEC=1) + add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UNKNOWN IMPORTED) + set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES + IMPORTED_LOCATION "${CEC_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${CEC_INCLUDE_DIR}" + INTERFACE_COMPILE_DEFINITIONS HAVE_LIBCEC) endif() if(TARGET cec) - add_dependencies(CEC::CEC cec) + add_dependencies(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} cec) endif() # Add internal build target when a Multi Config Generator is used @@ -164,8 +161,5 @@ if(NOT TARGET CEC::CEC) endif() add_dependencies(build_internal_depends cec) endif() - - set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP CEC::CEC) - endif() endif() diff --git a/cmake/modules/FindCrossGUID.cmake b/cmake/modules/FindCrossGUID.cmake index 38444f4433..b5035c3c53 100644 --- a/cmake/modules/FindCrossGUID.cmake +++ b/cmake/modules/FindCrossGUID.cmake @@ -4,7 +4,7 @@ # # This will define the following target: # -# CrossGUID::CrossGUID - The CrossGUID library +# ${APP_NAME_LC}::CrossGUID - The CrossGUID library macro(buildCrossGUID) include(cmake/scripts/common/ModuleHelpers.cmake) @@ -34,7 +34,7 @@ macro(buildCrossGUID) BUILD_DEP_TARGET() endmacro() -if(NOT TARGET CrossGUID::CrossGUID) +if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME}) if(ENABLE_INTERNAL_CROSSGUID) buildCrossGUID() else() @@ -47,16 +47,13 @@ if(NOT TARGET CrossGUID::CrossGUID) find_path(CROSSGUID_INCLUDE_DIR NAMES crossguid/guid.hpp guid.h HINTS ${DEPENDS_PATH}/include ${PC_CROSSGUID_INCLUDEDIR} - ${${CORE_PLATFORM_LC}_SEARCH_CONFIG} - NO_CACHE) + ${${CORE_PLATFORM_LC}_SEARCH_CONFIG}) find_library(CROSSGUID_LIBRARY_RELEASE NAMES crossguid HINTS ${DEPENDS_PATH}/lib ${PC_CROSSGUID_LIBDIR} - ${${CORE_PLATFORM_LC}_SEARCH_CONFIG} - NO_CACHE) + ${${CORE_PLATFORM_LC}_SEARCH_CONFIG}) find_library(CROSSGUID_LIBRARY_DEBUG NAMES crossguidd crossguid-dgb HINTS ${DEPENDS_PATH}/lib ${PC_CROSSGUID_LIBDIR} - ${${CORE_PLATFORM_LC}_SEARCH_CONFIG} - NO_CACHE) + ${${CORE_PLATFORM_LC}_SEARCH_CONFIG}) # NEW_CROSSGUID >= 0.2.0 release if(EXISTS "${CROSSGUID_INCLUDE_DIR}/crossguid/guid.hpp") @@ -74,53 +71,56 @@ if(NOT TARGET CrossGUID::CrossGUID) REQUIRED_VARS CROSSGUID_LIBRARY CROSSGUID_INCLUDE_DIR VERSION_VAR CROSSGUID_VERSION) - add_library(CrossGUID::CrossGUID UNKNOWN IMPORTED) - if(CROSSGUID_LIBRARY_RELEASE) - set_target_properties(CrossGUID::CrossGUID PROPERTIES - IMPORTED_CONFIGURATIONS RELEASE - IMPORTED_LOCATION_RELEASE "${CROSSGUID_LIBRARY_RELEASE}") - endif() - if(CROSSGUID_LIBRARY_DEBUG) - set_target_properties(CrossGUID::CrossGUID PROPERTIES - IMPORTED_CONFIGURATIONS DEBUG - IMPORTED_LOCATION_DEBUG "${CROSSGUID_LIBRARY_DEBUG}") - endif() - set_target_properties(CrossGUID::CrossGUID PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${CROSSGUID_INCLUDE_DIRS}" - INTERFACE_COMPILE_DEFINITIONS "${_crossguid_definitions}") - - if(UNIX AND NOT (APPLE OR ANDROID)) - # Suppress mismatch warning, see https://cmake.org/cmake/help/latest/module/FindPackageHandleStandardArgs.html - set(FPHSA_NAME_MISMATCHED 1) - find_package(UUID REQUIRED) - unset(FPHSA_NAME_MISMATCHED) - - if(TARGET UUID::UUID) - add_dependencies(CrossGUID::CrossGUID UUID::UUID) - target_link_libraries(CrossGUID::CrossGUID INTERFACE UUID::UUID) + if(CROSSGUID_FOUND) + add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UNKNOWN IMPORTED) + if(CROSSGUID_LIBRARY_RELEASE) + set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES + IMPORTED_CONFIGURATIONS RELEASE + IMPORTED_LOCATION_RELEASE "${CROSSGUID_LIBRARY_RELEASE}") + endif() + if(CROSSGUID_LIBRARY_DEBUG) + set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES + IMPORTED_CONFIGURATIONS DEBUG + IMPORTED_LOCATION_DEBUG "${CROSSGUID_LIBRARY_DEBUG}") + endif() + set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${CROSSGUID_INCLUDE_DIRS}" + INTERFACE_COMPILE_DEFINITIONS "${_crossguid_definitions}") + + if(UNIX AND NOT (APPLE OR ANDROID)) + # Suppress mismatch warning, see https://cmake.org/cmake/help/latest/module/FindPackageHandleStandardArgs.html + set(FPHSA_NAME_MISMATCHED 1) + find_package(UUID REQUIRED) + unset(FPHSA_NAME_MISMATCHED) + + if(TARGET UUID::UUID) + add_dependencies(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UUID::UUID) + target_link_libraries(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} INTERFACE UUID::UUID) + endif() endif() - endif() - if(TARGET crossguid) - add_dependencies(CrossGUID::CrossGUID crossguid) - endif() + if(TARGET crossguid) + add_dependencies(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} crossguid) + endif() - # Add internal build target when a Multi Config Generator is used - # We cant add a dependency based off a generator expression for targeted build types, - # https://gitlab.kitware.com/cmake/cmake/-/issues/19467 - # therefore if the find heuristics only find the library, we add the internal build - # target to the project to allow user to manually trigger for any build type they need - # in case only a specific build type is actually available (eg Release found, Debug Required) - # This is mainly targeted for windows who required different runtime libs for different - # types, and they arent compatible - if(_multiconfig_generator) - if(NOT TARGET crossguid) - buildCrossGUID() - set_target_properties(crossguid PROPERTIES EXCLUDE_FROM_ALL TRUE) + # Add internal build target when a Multi Config Generator is used + # We cant add a dependency based off a generator expression for targeted build types, + # https://gitlab.kitware.com/cmake/cmake/-/issues/19467 + # therefore if the find heuristics only find the library, we add the internal build + # target to the project to allow user to manually trigger for any build type they need + # in case only a specific build type is actually available (eg Release found, Debug Required) + # This is mainly targeted for windows who required different runtime libs for different + # types, and they arent compatible + if(_multiconfig_generator) + if(NOT TARGET crossguid) + buildCrossGUID() + set_target_properties(crossguid PROPERTIES EXCLUDE_FROM_ALL TRUE) + endif() + add_dependencies(build_internal_depends crossguid) + endif() + else() + if(CrossGUID_FIND_REQUIRED) + message(FATAL_ERROR "CrossGUID libraries were not found. You may want to use -DENABLE_INTERNAL_CROSSGUID=ON") endif() - add_dependencies(build_internal_depends crossguid) endif() - - set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP CrossGUID::CrossGUID) endif() -mark_as_advanced(CROSSGUID_INCLUDE_DIR CROSSGUID_LIBRARY) diff --git a/cmake/modules/FindCurl.cmake b/cmake/modules/FindCurl.cmake index 3872b9c64a..4e289cbe0e 100644 --- a/cmake/modules/FindCurl.cmake +++ b/cmake/modules/FindCurl.cmake @@ -5,9 +5,9 @@ # # This will define the following target: # -# Curl::Curl - The Curl library +# ${APP_NAME_LC}::Curl - The Curl library -if(NOT TARGET Curl::Curl) +if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME}) include(cmake/scripts/common/ModuleHelpers.cmake) macro(buildCurl) @@ -120,7 +120,7 @@ if(NOT TARGET Curl::Curl) endif() else() # CURL::libcurl is an alias. We need to get the actual aias target, as we cant make an - # alias of an alias (ie our Curl::Curl cant be an alias of Curl::libcurl) + # alias of an alias (ie our ${APP_NAME_LC}::Curl cant be an alias of Curl::libcurl) get_target_property(_CURL_ALIASTARGET CURL::libcurl ALIASED_TARGET) # This is for the case where a distro provides a non standard (Debug/Release) config type @@ -158,42 +158,42 @@ if(NOT TARGET Curl::Curl) # cmake target and not building internal if(TARGET CURL::libcurl AND NOT TARGET curl) # CURL::libcurl is an alias. We need to get the actual aias target, as we cant make an - # alias of an alias (ie our Curl::Curl cant be an alias of Curl::libcurl) + # alias of an alias (ie our ${APP_NAME_LC}::Curl cant be an alias of Curl::libcurl) if(NOT _CURL_ALIASTARGET) get_target_property(_CURL_ALIASTARGET CURL::libcurl ALIASED_TARGET) endif() - add_library(Curl::Curl ALIAS ${_CURL_ALIASTARGET}) + add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} ALIAS ${_CURL_ALIASTARGET}) else() - add_library(Curl::Curl UNKNOWN IMPORTED) - set_target_properties(Curl::Curl PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${CURL_INCLUDE_DIR}") + add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UNKNOWN IMPORTED) + set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${CURL_INCLUDE_DIR}") if(CURL_LIBRARY_RELEASE) - set_target_properties(Curl::Curl PROPERTIES - IMPORTED_CONFIGURATIONS RELEASE - IMPORTED_LOCATION_RELEASE "${CURL_LIBRARY_RELEASE}") + set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES + IMPORTED_CONFIGURATIONS RELEASE + IMPORTED_LOCATION_RELEASE "${CURL_LIBRARY_RELEASE}") endif() if(CURL_LIBRARY_DEBUG) - set_target_properties(Curl::Curl PROPERTIES - IMPORTED_CONFIGURATIONS DEBUG - IMPORTED_LOCATION_DEBUG "${CURL_LIBRARY_DEBUG}") + set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES + IMPORTED_CONFIGURATIONS DEBUG + IMPORTED_LOCATION_DEBUG "${CURL_LIBRARY_DEBUG}") endif() # Add link libraries for static lib usage found from pkg-config if(PC_CURL_LINK_LIBRARIES) - set_target_properties(Curl::Curl PROPERTIES - INTERFACE_LINK_LIBRARIES "${PC_CURL_LINK_LIBRARIES}") + set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES + INTERFACE_LINK_LIBRARIES "${PC_CURL_LINK_LIBRARIES}") endif() if(WIN32 OR WINDOWS_STORE) - set_property(TARGET Curl::Curl APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS "CURL_STATICLIB") + set_property(TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS "CURL_STATICLIB") endif() endif() if(TARGET curl) - add_dependencies(Curl::Curl curl) + add_dependencies(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} curl) endif() # Add internal build target when a Multi Config Generator is used @@ -211,9 +211,6 @@ if(NOT TARGET Curl::Curl) endif() add_dependencies(build_internal_depends curl) endif() - - set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP Curl::Curl) - else() if(Curl_FIND_REQUIRED) message(FATAL_ERROR "Curl libraries were not found.") diff --git a/cmake/modules/FindDBus.cmake b/cmake/modules/FindDBus.cmake index fc2a68fcc3..6025d21f08 100644 --- a/cmake/modules/FindDBus.cmake +++ b/cmake/modules/FindDBus.cmake @@ -5,9 +5,9 @@ # # This will define the following target: # -# DBus::DBus - The DBUS library +# ${APP_NAME_LC}::DBus - The DBUS library -if(NOT TARGET DBus::DBus) +if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME}) find_package(PkgConfig) if(PKG_CONFIG_FOUND) pkg_check_modules(PC_DBUS dbus-1 QUIET) @@ -31,13 +31,10 @@ if(NOT TARGET DBus::DBus) VERSION_VAR DBUS_VERSION) if(DBUS_FOUND) - add_library(DBus::DBus UNKNOWN IMPORTED) - set_target_properties(DBus::DBus PROPERTIES - IMPORTED_LOCATION "${DBUS_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${DBUS_INCLUDE_DIR};${DBUS_ARCH_INCLUDE_DIR}" - INTERFACE_COMPILE_DEFINITIONS HAS_DBUS=1) - set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP DBus::DBus) + add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UNKNOWN IMPORTED) + set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES + IMPORTED_LOCATION "${DBUS_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${DBUS_INCLUDE_DIR};${DBUS_ARCH_INCLUDE_DIR}" + INTERFACE_COMPILE_DEFINITIONS HAS_DBUS) endif() - - mark_as_advanced(DBUS_INCLUDE_DIR DBUS_LIBRARY) endif() diff --git a/cmake/modules/FindDetours.cmake b/cmake/modules/FindDetours.cmake index e31bc8fb50..6d87c85ea6 100644 --- a/cmake/modules/FindDetours.cmake +++ b/cmake/modules/FindDetours.cmake @@ -5,35 +5,36 @@ # # This will define the following target: # -# windows::Detours - The Detours library +# ${APP_NAME_LC}::Detours - The Detours library -if(NOT TARGET windows::Detours) - find_path(DETOURS_INCLUDE_DIR NAMES detours.h - NO_CACHE) +if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME}) + find_path(DETOURS_INCLUDE_DIR NAMES detours.h) find_library(DETOURS_LIBRARY_RELEASE NAMES detours - ${${CORE_PLATFORM_LC}_SEARCH_CONFIG} - NO_CACHE) + ${${CORE_PLATFORM_LC}_SEARCH_CONFIG}) find_library(DETOURS_LIBRARY_DEBUG NAMES detoursd - ${${CORE_PLATFORM_LC}_SEARCH_CONFIG} - NO_CACHE) + ${${CORE_PLATFORM_LC}_SEARCH_CONFIG}) include(SelectLibraryConfigurations) select_library_configurations(DETOURS) + unset(DETOURS_LIBRARIES) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Detours REQUIRED_VARS DETOURS_LIBRARY DETOURS_INCLUDE_DIR) if(DETOURS_FOUND) - add_library(windows::Detours UNKNOWN IMPORTED) - set_target_properties(windows::Detours PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${DETOURS_INCLUDE_DIR}" - IMPORTED_LOCATION "${DETOURS_LIBRARY_RELEASE}") + add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UNKNOWN IMPORTED) + set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${DETOURS_INCLUDE_DIR}" + IMPORTED_LOCATION "${DETOURS_LIBRARY_RELEASE}") if(DETOURS_LIBRARY_DEBUG) - set_target_properties(windows::Detours PROPERTIES - IMPORTED_LOCATION_DEBUG "${DETOURS_LIBRARY_DEBUG}") + set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES + IMPORTED_LOCATION_DEBUG "${DETOURS_LIBRARY_DEBUG}") + endif() + else() + if(Detours_FIND_REQUIRED) + message(FATAL_ERROR "Detour libraries were not found.") endif() - set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP windows::Detours) endif() endif() diff --git a/cmake/modules/FindEGL.cmake b/cmake/modules/FindEGL.cmake index 1a0ce39f7c..05d74c27e1 100644 --- a/cmake/modules/FindEGL.cmake +++ b/cmake/modules/FindEGL.cmake @@ -5,21 +5,19 @@ # # This will define the following target: # -# EGL::EGL - The EGL library +# ${APP_NAME_LC}::EGL - The EGL library -if(NOT TARGET EGL::EGL) +if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME}) find_package(PkgConfig) if(PKG_CONFIG_FOUND) pkg_check_modules(PC_EGL egl QUIET) endif() find_path(EGL_INCLUDE_DIR EGL/egl.h - HINTS ${PC_EGL_INCLUDEDIR} - NO_CACHE) + HINTS ${PC_EGL_INCLUDEDIR}) find_library(EGL_LIBRARY NAMES EGL egl - HINTS ${PC_EGL_LIBDIR} - NO_CACHE) + HINTS ${PC_EGL_LIBDIR}) set(EGL_VERSION ${PC_EGL_VERSION}) @@ -37,16 +35,15 @@ if(NOT TARGET EGL::EGL) check_include_files("EGL/egl.h;EGL/eglext.h;EGL/eglext_angle.h" HAVE_EGLEXTANGLE) unset(CMAKE_REQUIRED_INCLUDES) - add_library(EGL::EGL UNKNOWN IMPORTED) - set_target_properties(EGL::EGL PROPERTIES - IMPORTED_LOCATION "${EGL_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${EGL_INCLUDE_DIR}" - INTERFACE_COMPILE_DEFINITIONS HAS_EGL=1) + add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UNKNOWN IMPORTED) + set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES + IMPORTED_LOCATION "${EGL_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${EGL_INCLUDE_DIR}" + INTERFACE_COMPILE_DEFINITIONS HAS_EGL) if(HAVE_EGLEXTANGLE) - set_property(TARGET EGL::EGL APPEND PROPERTY - INTERFACE_COMPILE_DEFINITIONS HAVE_EGLEXTANGLE=1) + set_property(TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} APPEND PROPERTY + INTERFACE_COMPILE_DEFINITIONS HAVE_EGLEXTANGLE) endif() - set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP EGL::EGL) endif() endif() diff --git a/cmake/modules/FindEffects11.cmake b/cmake/modules/FindEffects11.cmake index 0f4e4afaa8..6cb8409838 100644 --- a/cmake/modules/FindEffects11.cmake +++ b/cmake/modules/FindEffects11.cmake @@ -4,9 +4,9 @@ # # This will define the following target: # -# windows::Effects11 - The Effects11 library +# ${APP_NAME_LC}::Effects11 - The Effects11 library -if(NOT TARGET windows::Effects11) +if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME}) include(cmake/scripts/common/ModuleHelpers.cmake) macro(buildEffects11) @@ -74,26 +74,26 @@ if(NOT TARGET windows::Effects11) if(Effects11_FOUND) if(TARGET Microsoft::Effects11 AND NOT TARGET effects11) - add_library(windows::Effects11 ALIAS Microsoft::Effects11) + add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} ALIAS Microsoft::Effects11) else() - add_library(windows::Effects11 UNKNOWN IMPORTED) - set_target_properties(windows::Effects11 PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${EFFECTS11_INCLUDE_DIR}") + add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UNKNOWN IMPORTED) + set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${EFFECTS11_INCLUDE_DIR}") if(EFFECTS11_LIBRARY_RELEASE) - set_target_properties(windows::Effects11 PROPERTIES - IMPORTED_CONFIGURATIONS RELEASE - IMPORTED_LOCATION_RELEASE "${EFFECTS11_LIBRARY_RELEASE}") + set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES + IMPORTED_CONFIGURATIONS RELEASE + IMPORTED_LOCATION_RELEASE "${EFFECTS11_LIBRARY_RELEASE}") endif() if(EFFECTS11_LIBRARY_DEBUG) - set_target_properties(windows::Effects11 PROPERTIES - IMPORTED_CONFIGURATIONS DEBUG - IMPORTED_LOCATION_DEBUG "${EFFECTS11_LIBRARY_DEBUG}") + set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES + IMPORTED_CONFIGURATIONS DEBUG + IMPORTED_LOCATION_DEBUG "${EFFECTS11_LIBRARY_DEBUG}") endif() endif() if(TARGET effects11) - add_dependencies(windows::Effects11 effects11) + add_dependencies(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} effects11) endif() # Add internal build target when a Multi Config Generator is used @@ -111,8 +111,6 @@ if(NOT TARGET windows::Effects11) endif() add_dependencies(build_internal_depends effects11) endif() - - set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP windows::Effects11) else() if(Effects11_FIND_REQUIRED) message(FATAL_ERROR "Could NOT find or build Effects11 library.") diff --git a/cmake/modules/FindFmt.cmake b/cmake/modules/FindFmt.cmake index 6a3f36eab8..a96e911717 100644 --- a/cmake/modules/FindFmt.cmake +++ b/cmake/modules/FindFmt.cmake @@ -4,9 +4,9 @@ # # This will define the following target: # -# fmt::fmt - The Fmt library +# ${APP_NAME_LC}::Fmt - The Fmt library -if(NOT TARGET fmt::fmt) +if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME}) include(cmake/scripts/common/ModuleHelpers.cmake) @@ -58,45 +58,37 @@ if(NOT TARGET fmt::fmt) find_path(FMT_INCLUDE_DIR NAMES fmt/format.h HINTS ${DEPENDS_PATH}/include ${PC_FMT_INCLUDEDIR} - ${${CORE_PLATFORM_LC}_SEARCH_CONFIG} - NO_CACHE) + ${${CORE_PLATFORM_LC}_SEARCH_CONFIG}) find_library(FMT_LIBRARY_RELEASE NAMES fmt HINTS ${DEPENDS_PATH}/lib ${PC_FMT_LIBDIR} - ${${CORE_PLATFORM_LC}_SEARCH_CONFIG} - NO_CACHE) + ${${CORE_PLATFORM_LC}_SEARCH_CONFIG}) find_library(FMT_LIBRARY_DEBUG NAMES fmtd HINTS ${DEPENDS_PATH}/lib ${PC_FMT_LIBDIR} - ${${CORE_PLATFORM_LC}_SEARCH_CONFIG} - NO_CACHE) + ${${CORE_PLATFORM_LC}_SEARCH_CONFIG}) + else() + # This is for the case where a distro provides a non standard (Debug/Release) config type + # eg Debian's config file is fmtConfigTargets-none.cmake + # convert this back to either DEBUG/RELEASE or just RELEASE + # we only do this because we use find_package_handle_standard_args for config time output + # and it isnt capable of handling TARGETS, so we have to extract the info + get_target_property(_FMT_CONFIGURATIONS fmt::fmt IMPORTED_CONFIGURATIONS) + foreach(_fmt_config IN LISTS _FMT_CONFIGURATIONS) + # Some non standard config (eg None on Debian) + # Just set to RELEASE var so select_library_configurations can continue to work its magic + string(TOUPPER ${_fmt_config} _fmt_config_UPPER) + if((NOT ${_fmt_config_UPPER} STREQUAL "RELEASE") AND + (NOT ${_fmt_config_UPPER} STREQUAL "DEBUG")) + get_target_property(FMT_LIBRARY_RELEASE fmt::fmt IMPORTED_LOCATION_${_fmt_config_UPPER}) + else() + get_target_property(FMT_LIBRARY_${_fmt_config_UPPER} fmt::fmt IMPORTED_LOCATION_${_fmt_config_UPPER}) + endif() + endforeach() + + get_target_property(FMT_INCLUDE_DIR fmt::fmt INTERFACE_INCLUDE_DIRECTORIES) endif() endif() - # fmt::fmt target exists and is of suitable versioning. the INTERNAL_FMT build - # is not created. - # We create variables based off TARGET data for use with FPHSA - if(TARGET fmt::fmt AND NOT TARGET fmt) - # This is for the case where a distro provides a non standard (Debug/Release) config type - # eg Debian's config file is fmtConfigTargets-none.cmake - # convert this back to either DEBUG/RELEASE or just RELEASE - # we only do this because we use find_package_handle_standard_args for config time output - # and it isnt capable of handling TARGETS, so we have to extract the info - get_target_property(_FMT_CONFIGURATIONS fmt::fmt IMPORTED_CONFIGURATIONS) - foreach(_fmt_config IN LISTS _FMT_CONFIGURATIONS) - # Some non standard config (eg None on Debian) - # Just set to RELEASE var so select_library_configurations can continue to work its magic - string(TOUPPER ${_fmt_config} _fmt_config_UPPER) - if((NOT ${_fmt_config_UPPER} STREQUAL "RELEASE") AND - (NOT ${_fmt_config_UPPER} STREQUAL "DEBUG")) - get_target_property(FMT_LIBRARY_RELEASE fmt::fmt IMPORTED_LOCATION_${_fmt_config_UPPER}) - else() - get_target_property(FMT_LIBRARY_${_fmt_config_UPPER} fmt::fmt IMPORTED_LOCATION_${_fmt_config_UPPER}) - endif() - endforeach() - - get_target_property(FMT_INCLUDE_DIR fmt::fmt INTERFACE_INCLUDE_DIRECTORIES) - endif() - include(SelectLibraryConfigurations) select_library_configurations(FMT) unset(FMT_LIBRARIES) @@ -106,29 +98,30 @@ if(NOT TARGET fmt::fmt) REQUIRED_VARS FMT_LIBRARY FMT_INCLUDE_DIR VERSION_VAR FMT_VERSION) if(Fmt_FOUND) - if(TARGET fmt OR NOT TARGET fmt::fmt) - if(NOT TARGET fmt::fmt) - add_library(fmt::fmt UNKNOWN IMPORTED) - endif() + # cmake target and not building internal + if(TARGET fmt::fmt AND NOT TARGET fmt) + add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} ALIAS fmt::fmt) + else() + add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UNKNOWN IMPORTED) if(FMT_LIBRARY_RELEASE) - set_target_properties(fmt::fmt PROPERTIES - IMPORTED_CONFIGURATIONS RELEASE - IMPORTED_LOCATION_RELEASE "${FMT_LIBRARY_RELEASE}") + set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES + IMPORTED_CONFIGURATIONS RELEASE + IMPORTED_LOCATION_RELEASE "${FMT_LIBRARY_RELEASE}") endif() if(FMT_LIBRARY_DEBUG) - set_target_properties(fmt::fmt PROPERTIES - IMPORTED_CONFIGURATIONS DEBUG - IMPORTED_LOCATION_DEBUG "${FMT_LIBRARY_DEBUG}") + set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES + IMPORTED_CONFIGURATIONS DEBUG + IMPORTED_LOCATION_DEBUG "${FMT_LIBRARY_DEBUG}") endif() - set_target_properties(fmt::fmt PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${FMT_INCLUDE_DIR}") + set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${FMT_INCLUDE_DIR}") endif() if(TARGET fmt) - add_dependencies(fmt::fmt fmt) + add_dependencies(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} fmt) # We are building as a requirement, so set LIB_BUILD property to allow calling # modules to know we will be building, and they will want to rebuild as well. - set_target_properties(fmt::fmt PROPERTIES LIB_BUILD ON) + set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES LIB_BUILD ON) endif() # Add internal build target when a Multi Config Generator is used @@ -146,14 +139,9 @@ if(NOT TARGET fmt::fmt) endif() add_dependencies(build_internal_depends fmt) endif() - endif() - - # Check whether we already have fmt::fmt target added to dep property list - get_property(CHECK_INTERNAL_DEPS GLOBAL PROPERTY INTERNAL_DEPS_PROP) - list(FIND CHECK_INTERNAL_DEPS "fmt::fmt" FMT_PROP_FOUND) - - # list(FIND) returns -1 if search item not found - if(FMT_PROP_FOUND STREQUAL "-1") - set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP fmt::fmt) + else() + if(Fmt_FIND_REQUIRED) + message(FATAL_ERROR "Fmt libraries were not found. You may want to use -DENABLE_INTERNAL_FMT=ON") + endif() endif() endif() diff --git a/cmake/modules/FindFreeType.cmake b/cmake/modules/FindFreeType.cmake index f6bfcee7c4..1131bd2a9d 100644 --- a/cmake/modules/FindFreeType.cmake +++ b/cmake/modules/FindFreeType.cmake @@ -5,12 +5,12 @@ # # This will define the following target: # -# FreeType::FreeType - The FreeType library +# ${APP_NAME_LC}::FreeType - The FreeType library -if(NOT TARGET FreeType::FreeType) +if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME}) find_package(PkgConfig) # Do not use pkgconfig on windows - if(PKG_CONFIG_FOUND AND NOT WIN32) + if(PKG_CONFIG_FOUND AND NOT (WIN32 OR WINDOWS_STORE)) pkg_check_modules(PC_FREETYPE freetype2 QUIET) endif() @@ -19,12 +19,10 @@ if(NOT TARGET FreeType::FreeType) ${PC_FREETYPE_INCLUDEDIR} ${PC_FREETYPE_INCLUDE_DIRS} PATH_SUFFIXES freetype2 - ${${CORE_PLATFORM_LC}_SEARCH_CONFIG} - NO_CACHE) + ${${CORE_PLATFORM_LC}_SEARCH_CONFIG}) find_library(FREETYPE_LIBRARY NAMES freetype freetype246MT HINTS ${DEPENDS_PATH}/lib ${PC_FREETYPE_LIBDIR} - ${${CORE_PLATFORM_LC}_SEARCH_CONFIG} - NO_CACHE) + ${${CORE_PLATFORM_LC}_SEARCH_CONFIG}) set(FREETYPE_VERSION ${PC_FREETYPE_VERSION}) @@ -34,10 +32,13 @@ if(NOT TARGET FreeType::FreeType) VERSION_VAR FREETYPE_VERSION) if(FREETYPE_FOUND) - add_library(FreeType::FreeType UNKNOWN IMPORTED) - set_target_properties(FreeType::FreeType PROPERTIES - IMPORTED_LOCATION "${FREETYPE_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${FREETYPE_INCLUDE_DIR}") - set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP FreeType::FreeType) + add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UNKNOWN IMPORTED) + set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES + IMPORTED_LOCATION "${FREETYPE_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${FREETYPE_INCLUDE_DIR}") + else() + if(Freetype_FIND_REQUIRED) + message(FATAL_ERROR "Freetype libraries were not found.") + endif() endif() endif() diff --git a/cmake/modules/FindFstrcmp.cmake b/cmake/modules/FindFstrcmp.cmake index fa754c5b8f..786456a2c7 100644 --- a/cmake/modules/FindFstrcmp.cmake +++ b/cmake/modules/FindFstrcmp.cmake @@ -5,10 +5,10 @@ # # This will define the following target: # -# fstrcmp::fstrcmp - The fstrcmp library +# ${APP_NAME_LC}::Fstrcmp - The fstrcmp library # -if(NOT TARGET fstrcmp::fstrcmp) +if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME}) if(ENABLE_INTERNAL_FSTRCMP) find_program(LIBTOOL libtool REQUIRED) include(cmake/scripts/common/ModuleHelpers.cmake) @@ -28,19 +28,17 @@ if(NOT TARGET fstrcmp::fstrcmp) BUILD_DEP_TARGET() else() find_package(PkgConfig) - if(PKG_CONFIG_FOUND) + if(PKG_CONFIG_FOUND AND NOT (WIN32 OR WINDOWS_STORE)) pkg_check_modules(PC_FSTRCMP fstrcmp QUIET) endif() find_path(FSTRCMP_INCLUDE_DIR NAMES fstrcmp.h HINTS ${DEPENDS_PATH}/include ${PC_FSTRCMP_INCLUDEDIR} - ${${CORE_PLATFORM_LC}_SEARCH_CONFIG} - NO_CACHE) + ${${CORE_PLATFORM_LC}_SEARCH_CONFIG}) find_library(FSTRCMP_LIBRARY NAMES fstrcmp HINTS ${DEPENDS_PATH}/lib ${PC_FSTRCMP_LIBDIR} - ${${CORE_PLATFORM_LC}_SEARCH_CONFIG} - NO_CACHE) + ${${CORE_PLATFORM_LC}_SEARCH_CONFIG}) set(FSTRCMP_VER ${PC_FSTRCMP_VERSION}) endif() @@ -50,14 +48,18 @@ if(NOT TARGET fstrcmp::fstrcmp) REQUIRED_VARS FSTRCMP_LIBRARY FSTRCMP_INCLUDE_DIR VERSION_VAR FSTRCMP_VER) - add_library(fstrcmp::fstrcmp UNKNOWN IMPORTED) - set_target_properties(fstrcmp::fstrcmp PROPERTIES - IMPORTED_LOCATION "${FSTRCMP_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${FSTRCMP_INCLUDE_DIR}") + if(FSTRCMP_FOUND) + add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UNKNOWN IMPORTED) + set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES + IMPORTED_LOCATION "${FSTRCMP_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${FSTRCMP_INCLUDE_DIR}") - if(TARGET fstrcmp) - add_dependencies(fstrcmp::fstrcmp fstrcmp) + if(TARGET fstrcmp) + add_dependencies(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} fstrcmp) + endif() + else() + if(Fstrcmp_FIND_REQUIRED) + message(FATAL_ERROR "Fstrcmp libraries were not found. You may want to use -DENABLE_INTERNAL_FSTRCMP=ON") + endif() endif() - - set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP fstrcmp::fstrcmp) endif() diff --git a/cmake/modules/FindGBM.cmake b/cmake/modules/FindGBM.cmake index 38b4174f85..30af021829 100644 --- a/cmake/modules/FindGBM.cmake +++ b/cmake/modules/FindGBM.cmake @@ -4,20 +4,18 @@ # # This will define the following target: # -# GBM::GBM - The GBM library +# ${APP_NAME_LC}::GBM - The GBM library -if(NOT TARGET GBM::GBM) +if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME}) find_package(PkgConfig) if(PKG_CONFIG_FOUND) pkg_check_modules(PC_GBM gbm QUIET) endif() find_path(GBM_INCLUDE_DIR NAMES gbm.h - HINTS ${PC_GBM_INCLUDEDIR} - NO_CACHE) + HINTS ${PC_GBM_INCLUDEDIR}) find_library(GBM_LIBRARY NAMES gbm - HINTS ${PC_GBM_LIBDIR} - NO_CACHE) + HINTS ${PC_GBM_LIBDIR}) set(GBM_VERSION ${PC_GBM_VERSION}) @@ -45,19 +43,18 @@ if(NOT TARGET GBM::GBM) " GBM_HAS_MODIFIERS) if(GBM_FOUND) - add_library(GBM::GBM UNKNOWN IMPORTED) - set_target_properties(GBM::GBM PROPERTIES - IMPORTED_LOCATION "${GBM_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${GBM_INCLUDE_DIR}" - INTERFACE_COMPILE_DEFINITIONS "HAVE_GBM=1") + add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UNKNOWN IMPORTED) + set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES + IMPORTED_LOCATION "${GBM_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${GBM_INCLUDE_DIR}" + INTERFACE_COMPILE_DEFINITIONS "HAVE_GBM") if(GBM_HAS_BO_MAP) - set_property(TARGET GBM::GBM APPEND PROPERTY - INTERFACE_COMPILE_DEFINITIONS HAS_GBM_BO_MAP=1) + set_property(TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} APPEND PROPERTY + INTERFACE_COMPILE_DEFINITIONS HAS_GBM_BO_MAP) endif() if(GBM_HAS_MODIFIERS) - set_property(TARGET GBM::GBM APPEND PROPERTY - INTERFACE_COMPILE_DEFINITIONS HAS_GBM_MODIFIERS=1) + set_property(TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} APPEND PROPERTY + INTERFACE_COMPILE_DEFINITIONS HAS_GBM_MODIFIERS) endif() - set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP GBM::GBM) endif() endif() diff --git a/cmake/modules/FindHarfBuzz.cmake b/cmake/modules/FindHarfBuzz.cmake index bef71c8f6c..834012e727 100644 --- a/cmake/modules/FindHarfBuzz.cmake +++ b/cmake/modules/FindHarfBuzz.cmake @@ -5,11 +5,11 @@ # # This will define the following target: # -# HarfBuzz::HarfBuzz - The HarfBuzz library +# ${APP_NAME_LC}::HarfBuzz - The HarfBuzz library -if(NOT TARGET HarfBuzz::HarfBuzz) +if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME}) find_package(PkgConfig) - if(PKG_CONFIG_FOUND) + if(PKG_CONFIG_FOUND AND NOT (WIN32 OR WINDOWS_STORE)) pkg_check_modules(PC_HARFBUZZ harfbuzz QUIET) endif() @@ -17,12 +17,10 @@ if(NOT TARGET HarfBuzz::HarfBuzz) HINTS ${DEPENDS_PATH}/include ${PC_HARFBUZZ_INCLUDEDIR} ${PC_HARFBUZZ_INCLUDE_DIRS} - ${${CORE_PLATFORM_LC}_SEARCH_CONFIG} - NO_CACHE) + ${${CORE_PLATFORM_LC}_SEARCH_CONFIG}) find_library(HARFBUZZ_LIBRARY NAMES harfbuzz HINTS ${DEPENDS_PATH}/lib ${PC_HARFBUZZ_LIBDIR} - ${${CORE_PLATFORM_LC}_SEARCH_CONFIG} - NO_CACHE) + ${${CORE_PLATFORM_LC}_SEARCH_CONFIG}) set(HARFBUZZ_VERSION ${PC_HARFBUZZ_VERSION}) @@ -32,10 +30,13 @@ if(NOT TARGET HarfBuzz::HarfBuzz) VERSION_VAR HARFBUZZ_VERSION) if(HARFBUZZ_FOUND) - add_library(HarfBuzz::HarfBuzz UNKNOWN IMPORTED) - set_target_properties(HarfBuzz::HarfBuzz PROPERTIES - IMPORTED_LOCATION "${HARFBUZZ_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${HARFBUZZ_INCLUDE_DIR}") - set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP HarfBuzz::HarfBuzz) + add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UNKNOWN IMPORTED) + set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES + IMPORTED_LOCATION "${HARFBUZZ_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${HARFBUZZ_INCLUDE_DIR}") + else() + if(HarfBuzz_FIND_REQUIRED) + message(FATAL_ERROR "Harfbuzz libraries were not found.") + endif() endif() endif() diff --git a/cmake/modules/FindIconv.cmake b/cmake/modules/FindIconv.cmake index 1e9b54fd5a..3acd96ea63 100644 --- a/cmake/modules/FindIconv.cmake +++ b/cmake/modules/FindIconv.cmake @@ -5,16 +5,14 @@ # # This will define the following target: # -# ICONV::ICONV - The ICONV library +# ${APP_NAME_LC}::ICONV - The ICONV library -if(NOT TARGET ICONV::ICONV) +if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME}) find_path(ICONV_INCLUDE_DIR NAMES iconv.h - HINTS ${DEPENDS_PATH}/include - NO_CACHE) + HINTS ${DEPENDS_PATH}/include) find_library(ICONV_LIBRARY NAMES iconv libiconv c - HINTS ${DEPENDS_PATH}/lib - NO_CACHE) + HINTS ${DEPENDS_PATH}/lib) set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARY}) check_function_exists(iconv HAVE_ICONV_FUNCTION) @@ -23,6 +21,7 @@ if(NOT TARGET ICONV::ICONV) set(HAVE_ICONV_FUNCTION ${HAVE_LIBICONV_FUNCTION2}) unset(HAVE_LIBICONV_FUNCTION2) endif() + unset(CMAKE_REQUIRED_LIBRARIES) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Iconv @@ -32,11 +31,14 @@ if(NOT TARGET ICONV::ICONV) # Libc causes grief for linux, so search if found library is libc.* and only # create imported TARGET if its not if(NOT ${ICONV_LIBRARY} MATCHES ".*libc\..*") - add_library(ICONV::ICONV UNKNOWN IMPORTED) - set_target_properties(ICONV::ICONV PROPERTIES - IMPORTED_LOCATION "${ICONV_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${ICONV_INCLUDE_DIR}") - set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP ICONV::ICONV) + add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UNKNOWN IMPORTED) + set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES + IMPORTED_LOCATION "${ICONV_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${ICONV_INCLUDE_DIR}") + endif() + else() + if(Iconv_FIND_REQUIRED) + message(FATAL_ERROR "Iconv libraries were not found.") endif() endif() endif() diff --git a/cmake/modules/FindKissFFT.cmake b/cmake/modules/FindKissFFT.cmake deleted file mode 100644 index 41fc34254f..0000000000 --- a/cmake/modules/FindKissFFT.cmake +++ /dev/null @@ -1,46 +0,0 @@ -#.rst: -# FindKissFFT -# ------------ -# Finds the KissFFT as a Fast Fourier Transformation (FFT) library -# -# This will define the following variables: -# -# KISSFFT_FOUND - System has KissFFT -# KISSFFT_INCLUDE_DIRS - the KissFFT include directory -# KISSFFT_LIBRARIES - the KissFFT libraries -# - -if(ENABLE_INTERNAL_KISSFFT) - # KissFFT is located in xbmc/contrib/kissfft - set(KISSFFT_FOUND TRUE) - set(KISSFFT_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/xbmc/contrib") - message(STATUS "Found KissFFT: ${KISSFFT_INCLUDE_DIRS}") -else() - find_package(PkgConfig) - if(PKG_CONFIG_FOUND) - pkg_check_modules(PC_KISSFFT kissfft QUIET) - endif() - - find_path(KISSFFT_INCLUDE_DIR kissfft/kiss_fft.h kissfft/kiss_fftr.h - HINTS ${PC_KISSFFT_INCLUDEDIR}) - find_library(KISSFFT_LIBRARY NAMES kissfft-float kissfft-int32 kissfft-int16 kissfft-simd - HINTS ${PC_KISSFFT_LIBDIR}) - - # Check if all REQUIRED_VARS are satisfied and set KISSFFT_FOUND - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(KissFFT REQUIRED_VARS KISSFFT_INCLUDE_DIR KISSFFT_LIBRARY) - - if(KISSFFT_FOUND) - set(KISSFFT_INCLUDE_DIRS ${KISSFFT_INCLUDE_DIR}) - set(KISSFFT_LIBRARIES ${KISSFFT_LIBRARY}) - - if(NOT TARGET kissfft) - add_library(kissfft UNKNOWN IMPORTED) - set_target_properties(kissfft PROPERTIES - IMPORTED_LOCATION "${KISSFFT_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${KISSFFT_INCLUDE_DIR}") - endif() - endif() - - mark_as_advanced(KISSFFT_INCLUDE_DIR KISSFFT_LIBRARY) -endif() diff --git a/cmake/modules/FindLCMS2.cmake b/cmake/modules/FindLCMS2.cmake index e0501d2624..bb13ba8d82 100644 --- a/cmake/modules/FindLCMS2.cmake +++ b/cmake/modules/FindLCMS2.cmake @@ -5,10 +5,9 @@ # # This will define the following target: # -# LCMS2::LCMS2 - The LCMS Color Management library - -if(NOT TARGET LCMS2::LCMS2) +# ${APP_NAME_LC}::LCMS2 - The LCMS Color Management library +if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME}) if(LCMS2_FIND_VERSION) if(LCMS2_FIND_VERSION_EXACT) set(LCMS2_FIND_SPEC "=${LCMS2_FIND_VERSION_COMPLETE}") @@ -18,16 +17,14 @@ if(NOT TARGET LCMS2::LCMS2) endif() find_package(PkgConfig) - if(PKG_CONFIG_FOUND) + if(PKG_CONFIG_FOUND AND NOT (WIN32 OR WINDOWS_STORE)) pkg_check_modules(PC_LCMS2 lcms2${LCMS2_FIND_SPEC} QUIET) endif() find_path(LCMS2_INCLUDE_DIR NAMES lcms2.h - HINTS ${PC_LCMS2_INCLUDEDIR} - NO_CACHE) + HINTS ${DEPENDS_PATH}/include ${PC_LCMS2_INCLUDEDIR}) find_library(LCMS2_LIBRARY NAMES lcms2 liblcms2 - HINTS ${PC_LCMS2_LIBDIR} - NO_CACHE) + HINTS ${DEPENDS_PATH}/lib ${PC_LCMS2_LIBDIR}) set(LCMS2_VERSION ${PC_LCMS2_VERSION}) @@ -37,11 +34,10 @@ if(NOT TARGET LCMS2::LCMS2) VERSION_VAR LCMS2_VERSION) if(LCMS2_FOUND) - add_library(LCMS2::LCMS2 UNKNOWN IMPORTED) - set_target_properties(LCMS2::LCMS2 PROPERTIES - IMPORTED_LOCATION "${LCMS2_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${LCMS2_INCLUDE_DIR}" - INTERFACE_COMPILE_DEFINITIONS "HAVE_LCMS2=1;CMS_NO_REGISTER_KEYWORD=1") - set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP LCMS2::LCMS2) + add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UNKNOWN IMPORTED) + set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES + IMPORTED_LOCATION "${LCMS2_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${LCMS2_INCLUDE_DIR}" + INTERFACE_COMPILE_DEFINITIONS "HAVE_LCMS2;CMS_NO_REGISTER_KEYWORD") endif() endif() diff --git a/cmake/modules/FindLibAndroidJNI.cmake b/cmake/modules/FindLibAndroidJNI.cmake index 05d6a5734d..c1851befce 100644 --- a/cmake/modules/FindLibAndroidJNI.cmake +++ b/cmake/modules/FindLibAndroidJNI.cmake @@ -4,9 +4,9 @@ # # This will define the following target: # -# libandroidjni::libandroidjni - The LibAndroidJNI library +# ${APP_NAME_LC}::LibAndroidJNI - The LibAndroidJNI library -if(NOT TARGET libandroidjni::libandroidjni) +if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME}) include(cmake/scripts/common/ModuleHelpers.cmake) set(MODULE_LC libandroidjni) @@ -26,13 +26,11 @@ if(NOT TARGET libandroidjni::libandroidjni) REQUIRED_VARS LIBANDROIDJNI_LIBRARY LIBANDROIDJNI_INCLUDE_DIR VERSION_VAR LIBANDROIDJNI_VER) - add_library(libandroidjni::libandroidjni STATIC IMPORTED) - set_target_properties(libandroidjni::libandroidjni PROPERTIES - FOLDER "External Projects" - IMPORTED_LOCATION "${LIBANDROIDJNI_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${LIBANDROIDJNI_INCLUDE_DIR}") + add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} STATIC IMPORTED) + set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES + FOLDER "External Projects" + IMPORTED_LOCATION "${LIBANDROIDJNI_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${LIBANDROIDJNI_INCLUDE_DIR}") - add_dependencies(libandroidjni::libandroidjni libandroidjni) - - set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP libandroidjni::libandroidjni) + add_dependencies(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} libandroidjni) endif() diff --git a/cmake/modules/FindLibDRM.cmake b/cmake/modules/FindLibDRM.cmake index 8fbd7f4354..a58a817aa4 100644 --- a/cmake/modules/FindLibDRM.cmake +++ b/cmake/modules/FindLibDRM.cmake @@ -5,10 +5,9 @@ # # This will define the following target: # -# LibDRM::LibDRM - The LibDRM library - -if(NOT TARGET LIBDRM::LIBDRM) +# ${APP_NAME_LC}::LibDRM - The LibDRM library +if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME}) if(LibDRM_FIND_VERSION) if(LibDRM_FIND_VERSION_EXACT) set(LibDRM_FIND_SPEC "=${LibDRM_FIND_VERSION_COMPLETE}") @@ -24,11 +23,9 @@ if(NOT TARGET LIBDRM::LIBDRM) find_path(LIBDRM_INCLUDE_DIR NAMES drm.h PATH_SUFFIXES libdrm drm - HINTS ${PC_LIBDRM_INCLUDEDIR} - NO_CACHE) + HINTS ${PC_LIBDRM_INCLUDEDIR}) find_library(LIBDRM_LIBRARY NAMES drm - HINTS ${PC_LIBDRM_LIBDIR} - NO_CACHE) + HINTS ${PC_LIBDRM_LIBDIR}) set(LIBDRM_VERSION ${PC_LIBDRM_VERSION}) @@ -51,20 +48,20 @@ if(NOT TARGET LIBDRM::LIBDRM) include(CheckSymbolExists) set(CMAKE_REQUIRED_LIBRARIES ${LIBDRM_LIBRARY}) check_symbol_exists(drmGetFormatModifierName xf86drm.h LIBDRM_HAS_MODIFIER_NAME) + set(CMAKE_REQUIRED_LIBRARIES) if(LIBDRM_FOUND) - add_library(LIBDRM::LIBDRM UNKNOWN IMPORTED) - set_target_properties(LIBDRM::LIBDRM PROPERTIES - IMPORTED_LOCATION "${LIBDRM_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${LIBDRM_INCLUDE_DIR}") + add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UNKNOWN IMPORTED) + set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES + IMPORTED_LOCATION "${LIBDRM_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${LIBDRM_INCLUDE_DIR}") if(LIBDRM_HAS_HDR_OUTPUT_METADATA) - set_property(TARGET LIBDRM::LIBDRM APPEND PROPERTY - INTERFACE_COMPILE_DEFINITIONS HAVE_HDR_OUTPUT_METADATA=1) + set_property(TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} APPEND PROPERTY + INTERFACE_COMPILE_DEFINITIONS HAVE_HDR_OUTPUT_METADATA) endif() if(LIBDRM_HAS_MODIFIER_NAME) - set_property(TARGET LIBDRM::LIBDRM APPEND PROPERTY - INTERFACE_COMPILE_DEFINITIONS HAVE_DRM_MODIFIER_NAME=1) + set_property(TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} APPEND PROPERTY + INTERFACE_COMPILE_DEFINITIONS HAVE_DRM_MODIFIER_NAME) endif() - set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP LIBDRM::LIBDRM) endif() endif() diff --git a/cmake/modules/FindLibUSB.cmake b/cmake/modules/FindLibUSB.cmake index 2610ffbafe..b6e90a8207 100644 --- a/cmake/modules/FindLibUSB.cmake +++ b/cmake/modules/FindLibUSB.cmake @@ -5,9 +5,9 @@ # # This will define the following target: # -# LibUSB::LibUSB - The USB library +# ${APP_NAME_LC}::LibUSB - The USB library -if(NOT TARGET LibUSB::LibUSB) +if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME}) find_package(PkgConfig) if(PKG_CONFIG_FOUND) @@ -15,11 +15,9 @@ if(NOT TARGET LibUSB::LibUSB) endif() find_path(LIBUSB_INCLUDE_DIR usb.h - HINTS ${PC_LIBUSB_INCLUDEDIR} - NO_CACHE) + HINTS ${PC_LIBUSB_INCLUDEDIR}) find_library(LIBUSB_LIBRARY NAMES usb - HINTS ${PC_LIBUSB_INCLUDEDIR} - NO_CACHE) + HINTS ${PC_LIBUSB_INCLUDEDIR}) set(LIBUSB_VERSION ${PC_LIBUSB_VERSION}) include(FindPackageHandleStandardArgs) @@ -28,11 +26,10 @@ if(NOT TARGET LibUSB::LibUSB) VERSION_VAR LIBUSB_VERSION) if(LIBUSB_FOUND) - add_library(LibUSB::LibUSB UNKNOWN IMPORTED) - set_target_properties(LibUSB::LibUSB PROPERTIES - IMPORTED_LOCATION "${LIBUSB_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${LIBUSB_INCLUDE_DIR}" - INTERFACE_COMPILE_DEFINITIONS USE_LIBUSB=1) - set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP LibUSB::LibUSB) + add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UNKNOWN IMPORTED) + set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES + IMPORTED_LOCATION "${LIBUSB_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${LIBUSB_INCLUDE_DIR}" + INTERFACE_COMPILE_DEFINITIONS HAVE_LIBUSB) endif() endif() diff --git a/cmake/modules/FindLibZip.cmake b/cmake/modules/FindLibZip.cmake index ccbc4e38a6..c108970c34 100644 --- a/cmake/modules/FindLibZip.cmake +++ b/cmake/modules/FindLibZip.cmake @@ -3,15 +3,9 @@ # ----------- # Finds the LibZip library # -# This will define the following variables:: +# The following imported target will be created: # -# LIBZIP_FOUND - system has LibZip -# LIBZIP_INCLUDE_DIRS - the LibZip include directory -# LIBZIP_LIBRARIES - the LibZip libraries -# -# and the following imported targets: -# -# libzip::zip - The LibZip library +# ${APP_NAME_LC}::LibZip - The LibZip library include(cmake/scripts/common/ModuleHelpers.cmake) @@ -19,11 +13,11 @@ set(MODULE_LC libzip) SETUP_BUILD_VARS() # Check for existing lib -find_package(LIBZIP CONFIG QUIET +find_package(libzip CONFIG QUIET HINTS ${DEPENDS_PATH}/lib ${${CORE_PLATFORM_NAME_LC}_SEARCH_CONFIG}) -if(NOT LIBZIP_FOUND OR LIBZIP_VERSION VERSION_LESS ${${MODULE}_VER}) +if(NOT LIBZIP_FOUND OR libzip_VERSION VERSION_LESS ${${MODULE}_VER}) # Check for dependencies find_package(GnuTLS MODULE REQUIRED) @@ -41,13 +35,27 @@ if(NOT LIBZIP_FOUND OR LIBZIP_VERSION VERSION_LESS ${${MODULE}_VER}) BUILD_DEP_TARGET() else() - find_path(LIBZIP_INCLUDE_DIR NAMES zip.h - HINTS ${DEPENDS_PATH}/include - ${${CORE_PLATFORM_NAME_LC}_SEARCH_CONFIG}) + # we only do this because we use find_package_handle_standard_args for config time output + # and it isnt capable of handling TARGETS, so we have to extract the info + get_target_property(_ZIP_CONFIGURATIONS libzip::zip IMPORTED_CONFIGURATIONS) + foreach(_zip_config IN LISTS _ZIP_CONFIGURATIONS) + # Some non standard config (eg None on Debian) + # Just set to RELEASE var so select_library_configurations can continue to work its magic + string(TOUPPER ${_zip_config} _zip_config_UPPER) + if((NOT ${_zip_config_UPPER} STREQUAL "RELEASE") AND + (NOT ${_zip_config_UPPER} STREQUAL "DEBUG")) + get_target_property(ZIP_LIBRARY_RELEASE libzip::zip IMPORTED_LOCATION_${_zip_config_UPPER}) + else() + get_target_property(ZIP_LIBRARY_${_zip_config_UPPER} libzip::zip IMPORTED_LOCATION_${_zip_config_UPPER}) + endif() + endforeach() + + get_target_property(ZIP_INCLUDE_DIR libzip::zip INTERFACE_INCLUDE_DIRECTORIES) + set(LIBZIP_VERSION ${libzip_VERSION}) - find_library(LIBZIP_LIBRARY NAMES zip - HINTS ${DEPENDS_PATH}/lib - ${${CORE_PLATFORM_NAME_LC}_SEARCH_CONFIG}) + include(SelectLibraryConfigurations) + select_library_configurations(LIBZIP) + unset(LIBZIP_LIBRARIES) endif() include(FindPackageHandleStandardArgs) @@ -56,31 +64,29 @@ find_package_handle_standard_args(LibZip VERSION_VAR LIBZIP_VERSION) if(LIBZIP_FOUND) - set(LIBZIP_LIBRARIES ${LIBZIP_LIBRARY}) - set(LIBZIP_INCLUDE_DIRS ${LIBZIP_INCLUDE_DIR}) + # cmake target and not building internal + if(TARGET libzip::zip AND NOT TARGET libzip) - if(NOT TARGET libzip::zip) - add_library(libzip::zip UNKNOWN IMPORTED) + add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} ALIAS libzip::zip) - set_target_properties(libzip::zip PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${LIBZIP_INCLUDE_DIR}" - IMPORTED_LOCATION "${LIBZIP_LIBRARY}") - - if(TARGET libzip) - add_dependencies(libzip::zip libzip) - endif() - else() # ToDo: When we correctly import dependencies cmake targets for the following # BZip2::BZip2, LibLZMA::LibLZMA, GnuTLS::GnuTLS, Nettle::Nettle,ZLIB::ZLIB # For now, we just override set_target_properties(libzip::zip PROPERTIES INTERFACE_LINK_LIBRARIES "") + else() + add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UNKNOWN IMPORTED) + + set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${LIBZIP_INCLUDE_DIR}" + IMPORTED_LOCATION "${LIBZIP_LIBRARY}") + + if(TARGET libzip) + add_dependencies(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} libzip) + endif() endif() - set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP libzip::zip) else() - if(LIBZIP_FIND_REQUIRED) + if(LibZip_FIND_REQUIRED) message(FATAL_ERROR "LibZip not found.") endif() endif() - -mark_as_advanced(LIBZIP_INCLUDE_DIR LIBZIP_LIBRARY) diff --git a/cmake/modules/FindOpenGLES.cmake b/cmake/modules/FindOpenGLES.cmake index 5dbb42e514..92172bd628 100644 --- a/cmake/modules/FindOpenGLES.cmake +++ b/cmake/modules/FindOpenGLES.cmake @@ -29,19 +29,6 @@ if(NOT TARGET OpenGL::GLES) REQUIRED_VARS OPENGLES_gl_LIBRARY OPENGLES_INCLUDE_DIR) if(OPENGLES_FOUND) - if(CORE_SYSTEM_NAME STREQUAL darwin_embedded) - # Cmake only added support for Frameworks as the IMPORTED_LOCATION as of 3.28 - # https://gitlab.kitware.com/cmake/cmake/-/merge_requests/8586 - # Until we move to cmake 3.28 as minimum, explicitly set to binary inside framework - if(OPENGLES_gl_LIBRARY MATCHES "/([^/]+)\\.framework$") - set(_gles_fw "${OPENGLES_gl_LIBRARY}/${CMAKE_MATCH_1}") - if(EXISTS "${_gles_fw}.tbd") - string(APPEND _gles_fw ".tbd") - endif() - set(OPENGLES_gl_LIBRARY ${_gles_fw}) - endif() - endif() - if(${OPENGLES_gl_LIBRARY} MATCHES ".+\.so$") add_library(OpenGL::GLES SHARED IMPORTED) else() diff --git a/cmake/modules/FindOpenGl.cmake b/cmake/modules/FindOpenGl.cmake index cabee46db3..1af7469e18 100644 --- a/cmake/modules/FindOpenGl.cmake +++ b/cmake/modules/FindOpenGl.cmake @@ -26,19 +26,6 @@ if(NOT TARGET OpenGL::GL) REQUIRED_VARS OPENGL_gl_LIBRARY OPENGL_INCLUDE_DIR) if(OPENGL_FOUND) - if(CORE_SYSTEM_NAME STREQUAL osx) - # Cmake only added support for Frameworks as the IMPORTED_LOCATION as of 3.28 - # https://gitlab.kitware.com/cmake/cmake/-/merge_requests/8586 - # Until we move to cmake 3.28 as minimum, explicitly set to binary inside framework - if(OPENGL_gl_LIBRARY MATCHES "/([^/]+)\\.framework$") - set(_gl_fw "${OPENGL_gl_LIBRARY}/${CMAKE_MATCH_1}") - if(EXISTS "${_gl_fw}.tbd") - string(APPEND _gl_fw ".tbd") - endif() - set(OPENGL_gl_LIBRARY ${_gl_fw}) - endif() - endif() - add_library(OpenGL::GL UNKNOWN IMPORTED) set_target_properties(OpenGL::GL PROPERTIES IMPORTED_LOCATION "${OPENGL_gl_LIBRARY}" diff --git a/cmake/modules/FindSpdlog.cmake b/cmake/modules/FindSpdlog.cmake index a4ff560efa..d1c76451d6 100644 --- a/cmake/modules/FindSpdlog.cmake +++ b/cmake/modules/FindSpdlog.cmake @@ -42,7 +42,7 @@ macro(buildSpdlog) BUILD_DEP_TARGET() - add_dependencies(${MODULE_LC} fmt::fmt) + add_dependencies(${MODULE_LC} ${APP_NAME_LC}::Fmt) endmacro() if(NOT TARGET spdlog::spdlog) @@ -55,9 +55,9 @@ if(NOT TARGET spdlog::spdlog) find_package(Fmt ${LIB_FMT_VER} MODULE REQUIRED) endif() - if(TARGET fmt::fmt) + if(TARGET ${APP_NAME_LC}::Fmt) # Check if we want to force a build due to a dependency rebuild - get_property(LIB_FORCE_REBUILD TARGET fmt::fmt PROPERTY LIB_BUILD) + get_property(LIB_FORCE_REBUILD TARGET ${APP_NAME_LC}::Fmt PROPERTY LIB_BUILD) endif() set(MODULE_LC spdlog) diff --git a/cmake/modules/FindLLVM.cmake b/cmake/modules/buildtools/FindLLVM.cmake index 7b97aa081e..7b97aa081e 100644 --- a/cmake/modules/FindLLVM.cmake +++ b/cmake/modules/buildtools/FindLLVM.cmake diff --git a/cmake/scripts/common/Macros.cmake b/cmake/scripts/common/Macros.cmake index db9d2e8433..08455f6d80 100644 --- a/cmake/scripts/common/Macros.cmake +++ b/cmake/scripts/common/Macros.cmake @@ -75,6 +75,8 @@ function(core_add_library name) add_dependencies(${name} ${GLOBAL_TARGET_DEPS}) # Adds global target to library. This propagates dep lib info (eg include_dir locations) + core_target_link_libraries(${name}) + # ToDo: remove the next line when the GLOBAL_TARGET_DEPS is removed completely target_link_libraries(${name} PRIVATE ${GLOBAL_TARGET_DEPS}) set(CORE_LIBRARY ${name} PARENT_SCOPE) @@ -829,3 +831,21 @@ macro(find_addon_xml_in_files) # Append also versions.h to depends list(APPEND ADDON_XML_DEPENDS "${CORE_SOURCE_DIR}/xbmc/addons/kodi-dev-kit/include/kodi/versions.h") endmacro() + +# Iterate over optional/required dep lists and link any created targets +# to the target supplied as first argument +function(core_target_link_libraries core_lib) + foreach(_depspec ${required_deps}) + split_dependency_specification(${_depspec} dep version) + if(TARGET ${APP_NAME_LC}::${dep}) + target_link_libraries(${core_lib} PUBLIC ${APP_NAME_LC}::${dep}) + endif() + endforeach() + + foreach(_depspec ${optional_deps}) + split_dependency_specification(${_depspec} dep version) + if(TARGET ${APP_NAME_LC}::${dep}) + target_link_libraries(${core_lib} PUBLIC ${APP_NAME_LC}::${dep}) + endif() + endforeach() +endfunction() diff --git a/cmake/scripts/linux/ExtraTargets.cmake b/cmake/scripts/linux/ExtraTargets.cmake index ee13ae6f08..d3b3f1807c 100644 --- a/cmake/scripts/linux/ExtraTargets.cmake +++ b/cmake/scripts/linux/ExtraTargets.cmake @@ -7,7 +7,7 @@ if(TARGET X::X AND TARGET XRandR::XRandR) endif() # WiiRemote -if(ENABLE_EVENTCLIENTS AND TARGET Bluetooth::Bluetooth) +if(ENABLE_EVENTCLIENTS AND TARGET ${APP_NAME_LC}::Bluetooth) find_package(CWiid QUIET) find_package(GLU QUIET) if(CWIID_FOUND AND GLU_FOUND) diff --git a/cmake/scripts/linux/Install.cmake b/cmake/scripts/linux/Install.cmake index 9c45c91774..47dc8faeef 100644 --- a/cmake/scripts/linux/Install.cmake +++ b/cmake/scripts/linux/Install.cmake @@ -199,7 +199,7 @@ install(FILES ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/scripts/${APP_NAME}Config.cm if(ENABLE_EVENTCLIENTS) find_package(PythonInterpreter REQUIRED) - execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(prefix=''))" + execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from sysconfig import get_path; print(get_path('platlib', scheme='posix_prefix'))" OUTPUT_VARIABLE PYTHON_LIB_PATH OUTPUT_STRIP_TRAILING_WHITESPACE) # Install kodi-eventclients-common BT python files install(PROGRAMS ${CMAKE_SOURCE_DIR}/tools/EventClients/lib/python/bt/__init__.py @@ -275,7 +275,7 @@ if(ENABLE_EVENTCLIENTS) DESTINATION ${bindir} COMPONENT kodi-eventclients-ps3) - if(TARGET Bluetooth::Bluetooth AND CWIID_FOUND AND GLU_FOUND) + if(TARGET ${APP_NAME_LC}::Bluetooth AND CWIID_FOUND AND GLU_FOUND) # Install kodi-eventclients-wiiremote install(PROGRAMS ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/WiiRemote/${APP_NAME_LC}-wiiremote DESTINATION ${bindir} diff --git a/cmake/treedata/common/externals.txt b/cmake/treedata/common/externals.txt deleted file mode 100644 index 812bebcccc..0000000000 --- a/cmake/treedata/common/externals.txt +++ /dev/null @@ -1 +0,0 @@ -xbmc/contrib/kissfft kissfft diff --git a/tools/EventClients/Clients/WiiRemote/CMakeLists.txt b/tools/EventClients/Clients/WiiRemote/CMakeLists.txt index 0462fbe9c3..2a8e41cc91 100644 --- a/tools/EventClients/Clients/WiiRemote/CMakeLists.txt +++ b/tools/EventClients/Clients/WiiRemote/CMakeLists.txt @@ -11,12 +11,12 @@ set(HEADERS CWIID_WiiRemote.h) add_executable(${APP_NAME_LC}-wiiremote ${SOURCES} ${HEADERS}) target_include_directories(${APP_NAME_LC}-wiiremote - PRIVATE $<TARGET_PROPERTY:Bluetooth::Bluetooth,INTERFACE_INCLUDE_DIRECTORIES> + PRIVATE $<TARGET_PROPERTY:${APP_NAME_LC}::Bluetooth,INTERFACE_INCLUDE_DIRECTORIES> ${CWIID_INCLUDE_DIRS}) target_link_libraries(${APP_NAME_LC}-wiiremote PRIVATE ${SYSTEM_LDFLAGS} - Bluetooth::Bluetooth + ${APP_NAME_LC}::Bluetooth ${CWIID_LIBRARIES}) target_compile_options(${APP_NAME_LC}-wiiremote PRIVATE ${ARCH_DEFINES}) diff --git a/tools/depends/native/cmake/CMAKE-VERSION b/tools/depends/native/cmake/CMAKE-VERSION new file mode 100644 index 0000000000..28fa53e725 --- /dev/null +++ b/tools/depends/native/cmake/CMAKE-VERSION @@ -0,0 +1,4 @@ +APPNAME=cmake +VERSION=3.29.3 +ARCHIVE=$(APPNAME)-$(VERSION).tar.gz +SHA512=930060cf484a769992ebc798d5e81984560b2cd7e163db7053181ad842656ccd0085e7e077c9c620e719d212f78283ca0db19bec5491a355d38078bbe0bac254 diff --git a/tools/depends/native/cmake/Makefile b/tools/depends/native/cmake/Makefile index e6f37b12a0..7d8faa14e2 100644 --- a/tools/depends/native/cmake/Makefile +++ b/tools/depends/native/cmake/Makefile @@ -1,13 +1,6 @@ -include ../../Makefile.include +include ../../Makefile.include CMAKE-VERSION ../../download-files.include PLATFORM=$(NATIVEPLATFORM) -DEPS = ../../Makefile.include Makefile ../../download-files.include - -APPNAME=cmake -VERSION=3.26.4 -SOURCE=$(APPNAME)-$(VERSION) -ARCHIVE=$(SOURCE).tar.gz -SHA512=fe817c8d5e247db3f0a9a58ee37c466a47220100d9e90711cd5d06c223cef87e41d1a756e75d1537e5f8cd010dcb8971cbeab4684b1ac12bcecf84bf7b720167 -include ../../download-files.include +DEPS = ../../Makefile.include Makefile CMAKE-VERSION ../../download-files.include # configuration settings diff --git a/xbmc/Autorun.cpp b/xbmc/Autorun.cpp index 5f8d321a5f..78aa9583a5 100644 --- a/xbmc/Autorun.cpp +++ b/xbmc/Autorun.cpp @@ -102,7 +102,7 @@ bool CAutorun::PlayDisc(const std::string& path, bool bypassSettings, bool start if ( !bypassSettings && CServiceBroker::GetSettingsComponent()->GetSettings()->GetInt(CSettings::SETTING_AUDIOCDS_AUTOACTION) != AUTOCD_PLAY && !CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_DVDS_AUTORUN)) return false; - int nSize = CServiceBroker::GetPlaylistPlayer().GetPlaylist(PLAYLIST::TYPE_MUSIC).size(); + int nSize = CServiceBroker::GetPlaylistPlayer().GetPlaylist(PLAYLIST::Id::TYPE_MUSIC).size(); int nAddedToPlaylist = 0; std::string mediaPath; @@ -131,7 +131,7 @@ bool CAutorun::PlayDisc(const std::string& path, bool bypassSettings, bool start { CGUIMessage msg( GUI_MSG_PLAYLIST_CHANGED, 0, 0 ); CServiceBroker::GetGUI()->GetWindowManager().SendMessage( msg ); - CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::TYPE_MUSIC); + CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::Id::TYPE_MUSIC); // Start playing the items we inserted return CServiceBroker::GetPlaylistPlayer().Play(nSize, ""); } @@ -215,10 +215,10 @@ bool CAutorun::RunDisc(IDirectory* pDir, const std::string& strDrive, int& nAdde if (!startFromBeginning && !item->GetVideoInfoTag()->m_strFileNameAndPath.empty()) item->SetStartOffset(STARTOFFSET_RESUME); - CServiceBroker::GetPlaylistPlayer().ClearPlaylist(PLAYLIST::TYPE_VIDEO); - CServiceBroker::GetPlaylistPlayer().SetShuffle(PLAYLIST::TYPE_VIDEO, false); - CServiceBroker::GetPlaylistPlayer().Add(PLAYLIST::TYPE_VIDEO, item); - CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::TYPE_VIDEO); + CServiceBroker::GetPlaylistPlayer().ClearPlaylist(PLAYLIST::Id::TYPE_VIDEO); + CServiceBroker::GetPlaylistPlayer().SetShuffle(PLAYLIST::Id::TYPE_VIDEO, false); + CServiceBroker::GetPlaylistPlayer().Add(PLAYLIST::Id::TYPE_VIDEO, item); + CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::Id::TYPE_VIDEO); CServiceBroker::GetPlaylistPlayer().Play(0, ""); return true; } @@ -237,10 +237,10 @@ bool CAutorun::RunDisc(IDirectory* pDir, const std::string& strDrive, int& nAdde if (!startFromBeginning && !item->GetVideoInfoTag()->m_strFileNameAndPath.empty()) item->SetStartOffset(STARTOFFSET_RESUME); - CServiceBroker::GetPlaylistPlayer().ClearPlaylist(PLAYLIST::TYPE_VIDEO); - CServiceBroker::GetPlaylistPlayer().SetShuffle(PLAYLIST::TYPE_VIDEO, false); - CServiceBroker::GetPlaylistPlayer().Add(PLAYLIST::TYPE_VIDEO, item); - CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::TYPE_VIDEO); + CServiceBroker::GetPlaylistPlayer().ClearPlaylist(PLAYLIST::Id::TYPE_VIDEO); + CServiceBroker::GetPlaylistPlayer().SetShuffle(PLAYLIST::Id::TYPE_VIDEO, false); + CServiceBroker::GetPlaylistPlayer().Add(PLAYLIST::Id::TYPE_VIDEO, item); + CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::Id::TYPE_VIDEO); CServiceBroker::GetPlaylistPlayer().Play(0, ""); return true; } @@ -346,10 +346,10 @@ bool CAutorun::RunDisc(IDirectory* pDir, const std::string& strDrive, int& nAdde // internal *.evo playback. CLog::Log(LOGINFO,"HD DVD: Internal multifile playback initiated."); - CServiceBroker::GetPlaylistPlayer().ClearPlaylist(PLAYLIST::TYPE_VIDEO); - CServiceBroker::GetPlaylistPlayer().SetShuffle(PLAYLIST::TYPE_VIDEO, false); - CServiceBroker::GetPlaylistPlayer().Add(PLAYLIST::TYPE_VIDEO, items); - CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::TYPE_VIDEO); + CServiceBroker::GetPlaylistPlayer().ClearPlaylist(PLAYLIST::Id::TYPE_VIDEO); + CServiceBroker::GetPlaylistPlayer().SetShuffle(PLAYLIST::Id::TYPE_VIDEO, false); + CServiceBroker::GetPlaylistPlayer().Add(PLAYLIST::Id::TYPE_VIDEO, items); + CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::Id::TYPE_VIDEO); CServiceBroker::GetPlaylistPlayer().Play(0, ""); return true; } @@ -370,9 +370,9 @@ bool CAutorun::RunDisc(IDirectory* pDir, const std::string& strDrive, int& nAdde if (items.Size()) { items.Sort(SortByLabel, SortOrderAscending); - CServiceBroker::GetPlaylistPlayer().ClearPlaylist(PLAYLIST::TYPE_VIDEO); - CServiceBroker::GetPlaylistPlayer().Add(PLAYLIST::TYPE_VIDEO, items); - CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::TYPE_VIDEO); + CServiceBroker::GetPlaylistPlayer().ClearPlaylist(PLAYLIST::Id::TYPE_VIDEO); + CServiceBroker::GetPlaylistPlayer().Add(PLAYLIST::Id::TYPE_VIDEO, items); + CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::Id::TYPE_VIDEO); CServiceBroker::GetPlaylistPlayer().Play(0, ""); return true; } @@ -429,9 +429,9 @@ bool CAutorun::RunDisc(IDirectory* pDir, const std::string& strDrive, int& nAdde if (!g_passwordManager.IsMasterLockUnlocked(true)) return false; } - CServiceBroker::GetPlaylistPlayer().ClearPlaylist(PLAYLIST::TYPE_VIDEO); - CServiceBroker::GetPlaylistPlayer().Add(PLAYLIST::TYPE_VIDEO, itemlist); - CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::TYPE_VIDEO); + CServiceBroker::GetPlaylistPlayer().ClearPlaylist(PLAYLIST::Id::TYPE_VIDEO); + CServiceBroker::GetPlaylistPlayer().Add(PLAYLIST::Id::TYPE_VIDEO, itemlist); + CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::Id::TYPE_VIDEO); CServiceBroker::GetPlaylistPlayer().Play(0, ""); } } @@ -444,7 +444,7 @@ bool CAutorun::RunDisc(IDirectory* pDir, const std::string& strDrive, int& nAdde if (!pItem->m_bIsFolder && MUSIC::IsAudio(*pItem)) { nAddedToPlaylist++; - CServiceBroker::GetPlaylistPlayer().Add(PLAYLIST::TYPE_MUSIC, pItem); + CServiceBroker::GetPlaylistPlayer().Add(PLAYLIST::Id::TYPE_MUSIC, pItem); } } } diff --git a/xbmc/FileItemListModification.cpp b/xbmc/FileItemListModification.cpp index 8496ee9136..c2ce636e9e 100644 --- a/xbmc/FileItemListModification.cpp +++ b/xbmc/FileItemListModification.cpp @@ -12,9 +12,11 @@ #include "playlists/SmartPlaylistFileItemListModifier.h" #include "video/windows/VideoFileItemListModifier.h" +using namespace KODI; + CFileItemListModification::CFileItemListModification() { - m_modifiers.insert(new CSmartPlaylistFileItemListModifier()); + m_modifiers.insert(new PLAYLIST::CSmartPlaylistFileItemListModifier()); m_modifiers.insert(new CMusicFileItemListModifier()); m_modifiers.insert(new CVideoFileItemListModifier()); } diff --git a/xbmc/GUIInfoManager.cpp b/xbmc/GUIInfoManager.cpp index ffca6c0eb7..835fd306b0 100644 --- a/xbmc/GUIInfoManager.cpp +++ b/xbmc/GUIInfoManager.cpp @@ -41,6 +41,7 @@ #include <memory> #include <mutex> +using namespace KODI; using namespace KODI::GUILIB; using namespace KODI::GUILIB::GUIINFO; using namespace INFO; @@ -1334,15 +1335,6 @@ const infomap weather[] = {{ "isfetched", WEATHER_IS_FETCHED }, /// @skinning_v17 **[New Boolean Condition]** \link System_HasPVRAddon /// `System.HasPVRAddon`\endlink <p> /// } -/// \table_row3{ <b>`System.PVRCount`</b>, -/// \anchor System_PVRCount -/// _integer_, -/// @return Number of PVR clients enabled. -/// @note If a PVR is enabled but unreachable\, it is still counted. -/// <p><hr> -/// @skinning_v22 **[New Integer Value]** \link System_PVRCount `System.PVRCount`\endlink -/// <p> -/// } /// \table_row3{ <b>`System.HasCMS`</b>, /// \anchor System_HasCMS /// _boolean_, @@ -1984,7 +1976,6 @@ const infomap system_labels[] = { {"hascms", SYSTEM_HAS_CMS}, {"privacypolicy", SYSTEM_PRIVACY_POLICY}, {"haspvraddon", SYSTEM_HAS_PVR_ADDON}, - {"pvrcount", SYSTEM_PVR_COUNT}, {"addonupdatecount", SYSTEM_ADDON_UPDATE_COUNT}, {"supportscpuusage", SYSTEM_SUPPORTS_CPU_USAGE}, {"supportedhdrtypes", SYSTEM_SUPPORTED_HDR_TYPES}, @@ -2798,6 +2789,14 @@ const infomap musicpartymode[] = {{ "enabled", MUSICPM_ENABLED }, /// @return The channel name of the radio programme that's currently playing (PVR). /// <p> /// } +/// \table_row3{ <b>`MusicPlayer.ChannelLogo`</b>, +/// \anchor MusicPlayer_ChannelLogo +/// _string_, +/// @return The path for the logo of the currently playing radio channel\, if available (PVR). +/// <p><hr> +/// @skinning_v22 **[New Infolabel]** \link MusicPlayer_ChannelLogo `MusicPlayer.ChannelLogo`\endlink +/// <p> +/// } /// \table_row3{ <b>`MusicPlayer.ChannelNumberLabel`</b>, /// \anchor MusicPlayer_ChannelNumberLabel /// _string_, @@ -2887,6 +2886,7 @@ const infomap musicpartymode[] = {{ "enabled", MUSICPM_ENABLED }, /// \table_end /// /// ----------------------------------------------------------------------------- +// clang-format off const infomap musicplayer[] = {{ "title", MUSICPLAYER_TITLE }, { "album", MUSICPLAYER_ALBUM }, { "artist", MUSICPLAYER_ARTIST }, @@ -2921,6 +2921,7 @@ const infomap musicplayer[] = {{ "title", MUSICPLAYER_TITLE }, { "playcount", MUSICPLAYER_PLAYCOUNT }, { "lastplayed", MUSICPLAYER_LASTPLAYED }, { "channelname", MUSICPLAYER_CHANNEL_NAME }, + { "channellogo", MUSICPLAYER_CHANNEL_LOGO }, { "channelnumberlabel", MUSICPLAYER_CHANNEL_NUMBER }, { "channelgroup", MUSICPLAYER_CHANNEL_GROUP }, { "dbid", MUSICPLAYER_DBID }, @@ -2932,6 +2933,7 @@ const infomap musicplayer[] = {{ "title", MUSICPLAYER_TITLE }, { "totaldiscs", MUSICPLAYER_TOTALDISCS }, { "station", MUSICPLAYER_STATIONNAME } }; +// clang-format on /// \page modules__infolabels_boolean_conditions /// \subsection modules__infolabels_boolean_conditions_Videoplayer Video player @@ -3470,8 +3472,7 @@ const infomap musicplayer[] = {{ "title", MUSICPLAYER_TITLE }, /// \table_row3{ <b>`VideoPlayer.Cast`</b>, /// \anchor VideoPlayer_Cast /// _string_, -/// @return A concatenated string of cast members of the current movie\, if it's in -/// the database. +/// @return A list of cast members\, separated by carriage returns. /// <p><hr> /// @skinning_v15 **[Infolabel Updated]** \link VideoPlayer_Cast `VideoPlayer.Cast`\endlink /// also supports EPG. @@ -3480,8 +3481,8 @@ const infomap musicplayer[] = {{ "title", MUSICPLAYER_TITLE }, /// \table_row3{ <b>`VideoPlayer.CastAndRole`</b>, /// \anchor VideoPlayer_CastAndRole /// _string_, -/// @return A concatenated string of cast members and roles of the current movie\, -/// if it's in the database. +/// @return A list of cast members and roles\, separated by carriage +/// returns. Every cast/role combination is formatted 'cast' as 'role' where 'as' is localised. /// <p> /// } /// \table_row3{ <b>`VideoPlayer.Album`</b>, @@ -3860,6 +3861,14 @@ const infomap musicplayer[] = {{ "title", MUSICPLAYER_TITLE }, /// @return The name of the currently tuned channel (PVR). /// <p> /// } +/// \table_row3{ <b>`VideoPlayer.ChannelLogo`</b>, +/// \anchor VideoPlayer_ChannelLogo +/// _string_, +/// @return The path for the logo of the currently playing TV channel\, if available (PVR). +/// <p><hr> +/// @skinning_v22 **[New Infolabel]** \link VideoPlayer_ChannelLogo `VideoPlayer.ChannelLogo`\endlink +/// <p> +/// } /// \table_row3{ <b>`VideoPlayer.ChannelNumberLabel`</b>, /// \anchor VideoPlayer_ChannelNumberLabel /// _string_, @@ -3941,7 +3950,7 @@ const infomap musicplayer[] = {{ "title", MUSICPLAYER_TITLE }, /// \table_row3{ <b>`VideoPlayer.VideoVersionName`</b>, /// \anchor VideoPlayer_VideoVersionName /// _string_, -/// @return String containing the version name of the currently playing video (movie) - empty if not a movie, version name is not set or not a version +/// @return String containing the version name of the currently playing video (movie) - empty if not a movie\, version name is not set or not a version /// <p><hr> /// @skinning_v21 **[New Infolabel]** \link VideoPlayer_VideoVersionName `VideoPlayer.VideoVersionName`\endlink /// } @@ -4006,6 +4015,7 @@ const infomap videoplayer[] = {{ "title", VIDEOPLAYER_TITLE }, { "nextendtime", VIDEOPLAYER_NEXT_ENDTIME }, { "nextduration", VIDEOPLAYER_NEXT_DURATION }, { "channelname", VIDEOPLAYER_CHANNEL_NAME }, + { "channellogo", VIDEOPLAYER_CHANNEL_LOGO }, { "channelnumberlabel", VIDEOPLAYER_CHANNEL_NUMBER }, { "channelgroup", VIDEOPLAYER_CHANNEL_GROUP }, { "hasepg", VIDEOPLAYER_HAS_EPG }, @@ -5874,8 +5884,7 @@ const infomap container_str[] = {{ "property", CONTAINER_PROPERTY }, /// \table_row3{ <b>`ListItem.Cast`</b>, /// \anchor ListItem_Cast /// _string_, -/// @return A concatenated string of cast members of the currently selected -/// movie\, for use in dialogvideoinfo.xml. +/// @return A list of cast members\, separated by carriage returns. /// <p><hr> /// @skinning_v15 **[Infolabel Updated]** \link ListItem_Cast `ListItem.Cast`\endlink /// also supports EPG. @@ -5884,8 +5893,8 @@ const infomap container_str[] = {{ "property", CONTAINER_PROPERTY }, /// \table_row3{ <b>`ListItem.CastAndRole`</b>, /// \anchor ListItem_CastAndRole /// _string_, -/// @return A concatenated string of cast members and roles of the currently -/// selected movie\, for use in dialogvideoinfo.xml. +/// @return A list of cast members and roles\, separated by carriage +/// returns. Every cast/role combination is formatted 'cast' as 'role' where 'as' is localised. /// <p> /// } /// \table_row3{ <b>`ListItem.Studio`</b>, @@ -5984,6 +5993,14 @@ const infomap container_str[] = {{ "property", CONTAINER_PROPERTY }, /// @return The name of current selected TV channel in a container. /// <p> /// } +/// \table_row3{ <b>`ListItem.ChannelLogo`</b>, +/// \anchor ListItem_ChannelLogo +/// _string_, +/// @return The path for the logo of the currently selected radio or TV channel\, if available (PVR). +/// <p><hr> +/// @skinning_v22 **[New Infolabel]** \link ListItem_ChannelLogo `ListItem.ChannelLogo`\endlink +/// <p> +/// } /// \table_row3{ <b>`ListItem.VideoCodec`</b>, /// \anchor ListItem_VideoCodec /// _string_, @@ -6488,7 +6505,7 @@ const infomap container_str[] = {{ "property", CONTAINER_PROPERTY }, /// _string_, /// @return From addon defined message text when it is marked as special condition inside repository. /// <p><hr> -/// @skinning_v19 **[New Infolabel]** \link ListItem_AddonLifecycleDesc `ListItem.AddonLifecycleDesc``\endlink +/// @skinning_v19 **[New Infolabel]** \link ListItem_AddonLifecycleDesc `ListItem.AddonLifecycleDesc`\endlink /// replaces `ListItem.AddonBroken`. /// <p> /// } @@ -6910,7 +6927,7 @@ const infomap container_str[] = {{ "property", CONTAINER_PROPERTY }, /// \table_row3{ <b>`ListItem.AlbumStatus`</b>, /// \anchor ListItem_AlbumStatus /// _string_, -/// @return The Musicbrainz release status of the album (official, bootleg, promotion etc) +/// @return The Musicbrainz release status of the album (official\, bootleg\, promotion etc) /// <p><hr> /// @skinning_v19 **[New Infolabel]** \link ListItem_AlbumStatus `ListItem.AlbumStatus`\endlink /// } @@ -6928,14 +6945,6 @@ const infomap container_str[] = {{ "property", CONTAINER_PROPERTY }, /// <p><hr> /// @skinning_v21 **[New Infolabel]** \link ListItem_SongVideoURL `ListItem.SongVideoURL`\endlink /// } -/// \table_row3{ <b>`ListItem.BackendInstanceName`</b>, -/// \anchor ListItem_BackendInstanceName -/// _string_, -/// @return The name used by the PVR client addon instance for the selected item. -/// <p><hr> -/// @skinning_v22 **[New Infolabel]** \link ListItem_BackendInstanceName `ListItem.BackendInstanceName`\endlink -/// <p> -/// } /// \table_row3{ <b>`ListItem.VideoWidth`</b>, /// \anchor ListItem_VideoWidth /// _string_, @@ -6978,6 +6987,25 @@ const infomap container_str[] = {{ "property", CONTAINER_PROPERTY }, /// <p><hr> /// @skinning_v21 **[New Infolabel]** \link ListItem_HasVideoExtras `ListItem.HasVideoExtras`\endlink /// } +/// \table_row3{ <b>`ListItem.PVRClientName`</b>, +/// \anchor ListItem_PVRClientName +/// _string_, +/// @return If selected item is of type PVR (recording\, timer\, EPG)\, the name of the PVR client +/// add-on\, as specified by the add-on developer. Empty if theitem is not of type PVR. +/// <p><hr> +/// @skinning_v22 **[New Infolabel]** \link ListItem_PVRClientName `ListItem.PVRClientName`\endlink +/// <p> +/// } +/// \table_row3{ <b>`ListItem.PVRInstanceName`</b>, +/// \anchor ListItem_PVRInstanceName +/// _string_, +/// @return If selected item is of type PVR (recording\, timer\, EPG)\, the name of the instance +/// of the PVR client add-on\, as specified by the user in the add-on settings. Empty if the +/// PVR client add-on does not support multiple instances or item is not of type PVR. +/// <p><hr> +/// @skinning_v22 **[New Infolabel]** \link ListItem_PVRInstanceName `ListItem.PVRInstanceName`\endlink +/// <p> +/// } /// \table_end /// /// ----------------------------------------------------------------------------- @@ -7126,6 +7154,7 @@ const infomap listitem_labels[]= {{ "thumb", LISTITEM_THUMB }, { "nextenddate", LISTITEM_NEXT_ENDDATE }, { "nextduration", LISTITEM_NEXT_DURATION }, { "channelname", LISTITEM_CHANNEL_NAME }, + { "channellogo", LISTITEM_CHANNEL_LOGO }, { "channelnumberlabel", LISTITEM_CHANNEL_NUMBER }, { "channelgroup", LISTITEM_CHANNEL_GROUP }, { "hasepg", LISTITEM_HAS_EPG }, @@ -7199,7 +7228,8 @@ const infomap listitem_labels[]= {{ "thumb", LISTITEM_THUMB }, { "isvideoextra", LISTITEM_ISVIDEOEXTRA }, { "videoversionname", LISTITEM_VIDEOVERSION_NAME }, { "hasvideoextras", LISTITEM_HASVIDEOEXTRAS }, - { "backendinstancename", LISTITEM_BACKEND_INSTANCE_NAME }, + { "pvrclientname", LISTITEM_PVR_CLIENT_NAME }, + { "pvrinstancename", LISTITEM_PVR_INSTANCE_NAME }, }; // clang-format on @@ -8208,10 +8238,20 @@ const infomap playlist[] = {{ "length", PLAYLIST_LENGTH }, /// _string_, /// @return The icon of the currently playing epg event\, if any. /// <p><hr> -/// @skinning_v18 **[New Infolabel]** \link PVR_EpgEventIcon `PVR_EpgEventIcon`\endlink +/// @skinning_v18 **[New Infolabel]** \link PVR_EpgEventIcon `PVR.EpgEventIcon`\endlink /// <p> /// } +/// \table_row3{ <b>`PVR.ClientCount`</b>, +/// \anchor PVR_ClientCount +/// _integer_, +/// @return Number of PVR clients enabled. +/// <p><hr> +/// @skinning_v22 **[New Integer Value]** \link PVR_ClientCount `PVR.ClientCount`\endlink +/// <p> +/// } +/// \table_end /// +/// ----------------------------------------------------------------------------- // clang-format off const infomap pvr[] = {{ "isrecording", PVR_IS_RECORDING }, { "hastimer", PVR_HAS_TIMER }, @@ -8291,7 +8331,8 @@ const infomap pvr[] = {{ "isrecording", PVR_IS_RECORDING { "timeshiftprogressepgend", PVR_TIMESHIFT_PROGRESS_EPG_END }, { "timeshiftprogressbufferstart", PVR_TIMESHIFT_PROGRESS_BUFFER_START }, { "timeshiftprogressbufferend", PVR_TIMESHIFT_PROGRESS_BUFFER_END }, - { "epgeventicon", PVR_EPG_EVENT_ICON }}; + { "epgeventicon", PVR_EPG_EVENT_ICON }, + { "clientcount", PVR_CLIENT_COUNT }}; // clang-format on /// \page modules__infolabels_boolean_conditions @@ -10532,14 +10573,14 @@ int CGUIInfoManager::TranslateSingleString(const std::string &strCondition, bool return ret; else { - PLAYLIST::Id playlistid = PLAYLIST::TYPE_NONE; + PLAYLIST::Id playlistid = PLAYLIST::Id::TYPE_NONE; if (StringUtils::EqualsNoCase(prop.param(), "video")) - playlistid = PLAYLIST::TYPE_VIDEO; + playlistid = PLAYLIST::Id::TYPE_VIDEO; else if (StringUtils::EqualsNoCase(prop.param(), "music")) - playlistid = PLAYLIST::TYPE_MUSIC; + playlistid = PLAYLIST::Id::TYPE_MUSIC; - if (playlistid != PLAYLIST::TYPE_NONE) - return AddMultiInfo(CGUIInfo(ret, playlistid, 1)); + if (playlistid != PLAYLIST::Id::TYPE_NONE) + return AddMultiInfo(CGUIInfo(ret, static_cast<int>(playlistid), 1)); } } } diff --git a/xbmc/NfoFile.cpp b/xbmc/NfoFile.cpp index f74d0efd20..2b5a302bb6 100644 --- a/xbmc/NfoFile.cpp +++ b/xbmc/NfoFile.cpp @@ -11,7 +11,6 @@ #include "NfoFile.h" -#include "FileItem.h" #include "FileItemList.h" #include "ServiceBroker.h" #include "addons/AddonManager.h" @@ -60,13 +59,12 @@ CInfoScanner::INFO_TYPE CNfoFile::Create(const std::string& strPath, int infos=0; while (m_headPos != std::string::npos && details.m_iEpisode != episode) { - m_headPos = m_doc.find("<episodedetails", m_headPos); + m_headPos = m_doc.find("<episodedetails", m_headPos + 1); if (m_headPos == std::string::npos) break; bNfo = GetDetails(details); infos++; - m_headPos++; } if (details.m_iEpisode != episode) { diff --git a/xbmc/PartyModeManager.cpp b/xbmc/PartyModeManager.cpp index dd74bad29e..50de8a3286 100644 --- a/xbmc/PartyModeManager.cpp +++ b/xbmc/PartyModeManager.cpp @@ -35,6 +35,7 @@ #include <algorithm> +using namespace KODI; using namespace KODI::MESSAGING; #define QUEUE_DEPTH 10 @@ -49,7 +50,7 @@ CPartyModeManager::CPartyModeManager(void) bool CPartyModeManager::Enable(PartyModeContext context /*= PARTYMODECONTEXT_MUSIC*/, const std::string& strXspPath /*= ""*/) { // Filter using our PartyMode xml file - CSmartPlaylist playlist; + PLAYLIST::CSmartPlaylist playlist; std::string partyModePath; bool playlistLoaded; @@ -563,7 +564,8 @@ void CPartyModeManager::Announce() { CVariant data; - data["player"]["playerid"] = CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist(); + data["player"]["playerid"] = + static_cast<int>(CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist()); data["property"]["partymode"] = m_bEnabled; CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::Player, "OnPropertyChanged", data); @@ -572,5 +574,5 @@ void CPartyModeManager::Announce() PLAYLIST::Id CPartyModeManager::GetPlaylistId() const { - return m_bIsVideo ? PLAYLIST::TYPE_VIDEO : PLAYLIST::TYPE_MUSIC; + return m_bIsVideo ? PLAYLIST::Id::TYPE_VIDEO : PLAYLIST::Id::TYPE_MUSIC; } diff --git a/xbmc/PartyModeManager.h b/xbmc/PartyModeManager.h index 4acb496f2d..1809aeb850 100644 --- a/xbmc/PartyModeManager.h +++ b/xbmc/PartyModeManager.h @@ -15,9 +15,9 @@ class CFileItem; typedef std::shared_ptr<CFileItem> CFileItemPtr; class CFileItemList; -namespace PLAYLIST +namespace KODI::PLAYLIST { -using Id = int; +enum class Id; class CPlayList; } @@ -37,7 +37,7 @@ public: void Disable(); void Play(int iPos); void OnSongChange(bool bUpdatePlayed = false); - void AddUserSongs(PLAYLIST::CPlayList& tempList, bool bPlay = false); + void AddUserSongs(KODI::PLAYLIST::CPlayList& tempList, bool bPlay = false); void AddUserSongs(CFileItemList& tempList, bool bPlay = false); bool IsEnabled(PartyModeContext context=PARTYMODECONTEXT_UNKNOWN) const; int GetSongsPlayed(); @@ -59,7 +59,7 @@ private: void ClearState(); void UpdateStats(); void Announce(); - PLAYLIST::Id GetPlaylistId() const; + KODI::PLAYLIST::Id GetPlaylistId() const; // state bool m_bEnabled; diff --git a/xbmc/PlayListPlayer.cpp b/xbmc/PlayListPlayer.cpp index 17e198aa76..346727ca55 100644 --- a/xbmc/PlayListPlayer.cpp +++ b/xbmc/PlayListPlayer.cpp @@ -41,15 +41,16 @@ #include "video/VideoDatabase.h" #include "video/VideoFileItemClassify.h" -using namespace PLAYLIST; -using namespace KODI; using namespace KODI::MESSAGING; using namespace KODI::VIDEO; +namespace KODI::PLAYLIST +{ + CPlayListPlayer::CPlayListPlayer(void) { - m_PlaylistMusic = new CPlayList(TYPE_MUSIC); - m_PlaylistVideo = new CPlayList(TYPE_VIDEO); + m_PlaylistMusic = new CPlayList(Id::TYPE_MUSIC); + m_PlaylistVideo = new CPlayList(Id::TYPE_VIDEO); m_PlaylistEmpty = new CPlayList; m_iCurrentSong = -1; m_bPlayedFirstFile = false; @@ -90,7 +91,7 @@ bool CPlayListPlayer::OnMessage(CGUIMessage &message) if (message.GetParam1() == GUI_MSG_UPDATE_ITEM && message.GetItem()) { // update the items in our playlist(s) if necessary - for (Id playlistId : {TYPE_MUSIC, TYPE_VIDEO}) + for (Id playlistId : {Id::TYPE_MUSIC, Id::TYPE_VIDEO}) { CPlayList& playlist = GetPlaylist(playlistId); CFileItemPtr item = std::static_pointer_cast<CFileItem>(message.GetItem()); @@ -100,12 +101,13 @@ bool CPlayListPlayer::OnMessage(CGUIMessage &message) break; case GUI_MSG_PLAYBACK_STOPPED: { - if (m_iCurrentPlayList != TYPE_NONE && m_bPlaybackStarted) + if (m_iCurrentPlayList != Id::TYPE_NONE && m_bPlaybackStarted) { - CGUIMessage msg(GUI_MSG_PLAYLISTPLAYER_STOPPED, 0, 0, m_iCurrentPlayList, m_iCurrentSong); + CGUIMessage msg(GUI_MSG_PLAYLISTPLAYER_STOPPED, 0, 0, static_cast<int>(m_iCurrentPlayList), + m_iCurrentSong); CServiceBroker::GetGUI()->GetWindowManager().SendThreadMessage(msg); Reset(); - m_iCurrentPlayList = TYPE_NONE; + m_iCurrentPlayList = Id::TYPE_NONE; return true; } } @@ -122,7 +124,7 @@ bool CPlayListPlayer::OnMessage(CGUIMessage &message) int CPlayListPlayer::GetNextItemIdx(int offset) const { - if (m_iCurrentPlayList == TYPE_NONE) + if (m_iCurrentPlayList == Id::TYPE_NONE) return -1; const CPlayList& playlist = GetPlaylist(m_iCurrentPlayList); @@ -132,7 +134,7 @@ int CPlayListPlayer::GetNextItemIdx(int offset) const int song = m_iCurrentSong; // party mode - if (g_partyModeManager.IsEnabled() && GetCurrentPlaylist() == TYPE_MUSIC) + if (g_partyModeManager.IsEnabled() && GetCurrentPlaylist() == Id::TYPE_MUSIC) return song + offset; // wrap around in the case of repeating @@ -148,7 +150,7 @@ int CPlayListPlayer::GetNextItemIdx(int offset) const int CPlayListPlayer::GetNextItemIdx() { - if (m_iCurrentPlayList == TYPE_NONE) + if (m_iCurrentPlayList == Id::TYPE_NONE) return -1; CPlayList& playlist = GetPlaylist(m_iCurrentPlayList); if (playlist.size() <= 0) @@ -156,7 +158,7 @@ int CPlayListPlayer::GetNextItemIdx() int iSong = m_iCurrentSong; // party mode - if (g_partyModeManager.IsEnabled() && GetCurrentPlaylist() == TYPE_MUSIC) + if (g_partyModeManager.IsEnabled() && GetCurrentPlaylist() == Id::TYPE_MUSIC) return iSong + 1; // if repeat one, keep playing the current song if its valid @@ -167,10 +169,11 @@ int CPlayListPlayer::GetNextItemIdx() { CLog::Log(LOGERROR, "Playlist Player: RepeatOne stuck on unplayable item: {}, path [{}]", m_iCurrentSong, playlist[m_iCurrentSong]->GetPath()); - CGUIMessage msg(GUI_MSG_PLAYLISTPLAYER_STOPPED, 0, 0, m_iCurrentPlayList, m_iCurrentSong); + CGUIMessage msg(GUI_MSG_PLAYLISTPLAYER_STOPPED, 0, 0, static_cast<int>(m_iCurrentPlayList), + m_iCurrentSong); CServiceBroker::GetGUI()->GetWindowManager().SendThreadMessage(msg); Reset(); - m_iCurrentPlayList = TYPE_NONE; + m_iCurrentPlayList = Id::TYPE_NONE; return -1; } return iSong; @@ -195,10 +198,11 @@ bool CPlayListPlayer::PlayNext(int offset, bool bAutoPlay) if(!bAutoPlay) CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(559), g_localizeStrings.Get(34201)); - CGUIMessage msg(GUI_MSG_PLAYLISTPLAYER_STOPPED, 0, 0, m_iCurrentPlayList, m_iCurrentSong); + CGUIMessage msg(GUI_MSG_PLAYLISTPLAYER_STOPPED, 0, 0, static_cast<int>(m_iCurrentPlayList), + m_iCurrentSong); CServiceBroker::GetGUI()->GetWindowManager().SendThreadMessage(msg); Reset(); - m_iCurrentPlayList = TYPE_NONE; + m_iCurrentPlayList = Id::TYPE_NONE; return false; } @@ -211,7 +215,7 @@ bool CPlayListPlayer::PlayNext(int offset, bool bAutoPlay) bool CPlayListPlayer::PlayPrevious() { - if (m_iCurrentPlayList == TYPE_NONE) + if (m_iCurrentPlayList == Id::TYPE_NONE) return false; const CPlayList& playlist = GetPlaylist(m_iCurrentPlayList); @@ -240,7 +244,7 @@ bool CPlayListPlayer::IsSingleItemNonRepeatPlaylist() const bool CPlayListPlayer::Play() { - if (m_iCurrentPlayList == TYPE_NONE) + if (m_iCurrentPlayList == Id::TYPE_NONE) return false; const CPlayList& playlist = GetPlaylist(m_iCurrentPlayList); @@ -252,7 +256,7 @@ bool CPlayListPlayer::Play() bool CPlayListPlayer::PlayItemIdx(int itemIdx) { - if (m_iCurrentPlayList == TYPE_NONE) + if (m_iCurrentPlayList == Id::TYPE_NONE) return false; CPlayList& playlist = GetPlaylist(m_iCurrentPlayList); @@ -277,9 +281,9 @@ bool CPlayListPlayer::Play(const CFileItemPtr& pItem, bool isAudio{MUSIC::IsAudio(*pItem)}; if (isAudio && !isVideo) - playlistId = TYPE_MUSIC; + playlistId = Id::TYPE_MUSIC; else if (isVideo && !isAudio) - playlistId = TYPE_VIDEO; + playlistId = Id::TYPE_VIDEO; else if (pItem->HasProperty("playlist_type_hint")) { // There are two main cases that can fall here: @@ -293,7 +297,8 @@ bool CPlayListPlayer::Play(const CFileItemPtr& pItem, // to detect the media type, IsVideo() / IsAudio() both return false // // for these cases the type is unknown so we rely on the hint - playlistId = pItem->GetProperty("playlist_type_hint").asInteger32(TYPE_NONE); + playlistId = + Id{pItem->GetProperty("playlist_type_hint").asInteger32(static_cast<int>(Id::TYPE_NONE))}; } else { @@ -317,7 +322,7 @@ bool CPlayListPlayer::Play(int iSong, bool bPlayPrevious /* = false */, bool forceSelection /* = false */) { - if (m_iCurrentPlayList == TYPE_NONE) + if (m_iCurrentPlayList == Id::TYPE_NONE) return false; CPlayList& playlist = GetPlaylist(m_iCurrentPlayList); @@ -374,11 +379,12 @@ bool CPlayListPlayer::Play(int iSong, // open error dialog HELPERS::ShowOKDialogText(CVariant{16026}, CVariant{16027}); - CGUIMessage msg(GUI_MSG_PLAYLISTPLAYER_STOPPED, 0, 0, m_iCurrentPlayList, m_iCurrentSong); + CGUIMessage msg(GUI_MSG_PLAYLISTPLAYER_STOPPED, 0, 0, static_cast<int>(m_iCurrentPlayList), + m_iCurrentSong); CServiceBroker::GetGUI()->GetWindowManager().SendThreadMessage(msg); Reset(); GetPlaylist(m_iCurrentPlayList).Clear(); - m_iCurrentPlayList = TYPE_NONE; + m_iCurrentPlayList = Id::TYPE_NONE; m_iFailedSongs = 0; m_failedSongsStart = std::chrono::steady_clock::now(); return false; @@ -393,10 +399,11 @@ bool CPlayListPlayer::Play(int iSong, else { CLog::Log(LOGDEBUG,"Playlist Player: no more playable items... aborting playback"); - CGUIMessage msg(GUI_MSG_PLAYLISTPLAYER_STOPPED, 0, 0, m_iCurrentPlayList, m_iCurrentSong); + CGUIMessage msg(GUI_MSG_PLAYLISTPLAYER_STOPPED, 0, 0, static_cast<int>(m_iCurrentPlayList), + m_iCurrentSong); CServiceBroker::GetGUI()->GetWindowManager().SendThreadMessage(msg); Reset(); - m_iCurrentPlayList = TYPE_NONE; + m_iCurrentPlayList = Id::TYPE_NONE; return false; } } @@ -463,10 +470,10 @@ CPlayList& CPlayListPlayer::GetPlaylist(Id playlistId) { switch (playlistId) { - case TYPE_MUSIC: + case Id::TYPE_MUSIC: return *m_PlaylistMusic; break; - case TYPE_VIDEO: + case Id::TYPE_VIDEO: return *m_PlaylistVideo; break; default: @@ -480,10 +487,10 @@ const CPlayList& CPlayListPlayer::GetPlaylist(Id playlistId) const { switch (playlistId) { - case TYPE_MUSIC: + case Id::TYPE_MUSIC: return *m_PlaylistMusic; break; - case TYPE_VIDEO: + case Id::TYPE_VIDEO: return *m_PlaylistVideo; break; default: @@ -535,11 +542,11 @@ bool CPlayListPlayer::RepeatedOne(Id playlistId) const void CPlayListPlayer::SetShuffle(Id playlistId, bool bYesNo, bool bNotify /* = false */) { - if (playlistId != TYPE_MUSIC && playlistId != TYPE_VIDEO) + if (playlistId != Id::TYPE_MUSIC && playlistId != Id::TYPE_VIDEO) return; // disable shuffle in party mode - if (g_partyModeManager.IsEnabled() && playlistId == TYPE_MUSIC) + if (g_partyModeManager.IsEnabled() && playlistId == Id::TYPE_MUSIC) return; // do we even need to do anything? @@ -589,10 +596,10 @@ void CPlayListPlayer::SetShuffle(Id playlistId, bool bYesNo, bool bNotify /* = f bool CPlayListPlayer::IsShuffled(Id playlistId) const { // even if shuffled, party mode says its not - if (g_partyModeManager.IsEnabled() && playlistId == TYPE_MUSIC) + if (g_partyModeManager.IsEnabled() && playlistId == Id::TYPE_MUSIC) return false; - if (playlistId == TYPE_MUSIC || playlistId == TYPE_VIDEO) + if (playlistId == Id::TYPE_MUSIC || playlistId == Id::TYPE_VIDEO) return GetPlaylist(playlistId).IsShuffled(); return false; @@ -600,11 +607,11 @@ bool CPlayListPlayer::IsShuffled(Id playlistId) const void CPlayListPlayer::SetRepeat(Id playlistId, RepeatState state, bool bNotify /* = false */) { - if (playlistId != TYPE_MUSIC && playlistId != TYPE_VIDEO) + if (playlistId != Id::TYPE_MUSIC && playlistId != Id::TYPE_VIDEO) return; // disable repeat in party mode - if (g_partyModeManager.IsEnabled() && playlistId == TYPE_MUSIC) + if (g_partyModeManager.IsEnabled() && playlistId == Id::TYPE_MUSIC) state = RepeatState::NONE; // notify the user if there was a change in the repeat state @@ -668,8 +675,8 @@ void CPlayListPlayer::ReShuffle(Id playlistId, int iPosition) { const auto& components = CServiceBroker::GetAppComponents(); const auto appPlayer = components.GetComponent<CApplicationPlayer>(); - if ((appPlayer->IsPlayingAudio() && playlistId == TYPE_MUSIC) || - (appPlayer->IsPlayingVideo() && playlistId == TYPE_VIDEO)) + if ((appPlayer->IsPlayingAudio() && playlistId == Id::TYPE_MUSIC) || + (appPlayer->IsPlayingVideo() && playlistId == Id::TYPE_VIDEO)) { GetPlaylist(playlistId).Shuffle(m_iCurrentSong + 2); } @@ -684,7 +691,7 @@ void CPlayListPlayer::ReShuffle(Id playlistId, int iPosition) void CPlayListPlayer::Add(Id playlistId, const CPlayList& playlist) { - if (playlistId != TYPE_MUSIC && playlistId != TYPE_VIDEO) + if (playlistId != Id::TYPE_MUSIC && playlistId != Id::TYPE_VIDEO) return; CPlayList& list = GetPlaylist(playlistId); int iSize = list.size(); @@ -695,7 +702,7 @@ void CPlayListPlayer::Add(Id playlistId, const CPlayList& playlist) void CPlayListPlayer::Add(Id playlistId, const CFileItemPtr& pItem) { - if (playlistId != TYPE_MUSIC && playlistId != TYPE_VIDEO) + if (playlistId != Id::TYPE_MUSIC && playlistId != Id::TYPE_VIDEO) return; CPlayList& list = GetPlaylist(playlistId); int iSize = list.size(); @@ -710,7 +717,7 @@ void CPlayListPlayer::Add(Id playlistId, const CFileItemPtr& pItem) void CPlayListPlayer::Add(Id playlistId, const CFileItemList& items) { - if (playlistId != TYPE_MUSIC && playlistId != TYPE_VIDEO) + if (playlistId != Id::TYPE_MUSIC && playlistId != Id::TYPE_VIDEO) return; CPlayList& list = GetPlaylist(playlistId); int iSize = list.size(); @@ -725,7 +732,7 @@ void CPlayListPlayer::Add(Id playlistId, const CFileItemList& items) void CPlayListPlayer::Insert(Id playlistId, const CPlayList& playlist, int iIndex) { - if (playlistId != TYPE_MUSIC && playlistId != TYPE_VIDEO) + if (playlistId != Id::TYPE_MUSIC && playlistId != Id::TYPE_VIDEO) return; CPlayList& list = GetPlaylist(playlistId); int iSize = list.size(); @@ -738,7 +745,7 @@ void CPlayListPlayer::Insert(Id playlistId, const CPlayList& playlist, int iInde void CPlayListPlayer::Insert(Id playlistId, const CFileItemPtr& pItem, int iIndex) { - if (playlistId != TYPE_MUSIC && playlistId != TYPE_VIDEO) + if (playlistId != Id::TYPE_MUSIC && playlistId != Id::TYPE_VIDEO) return; CPlayList& list = GetPlaylist(playlistId); int iSize = list.size(); @@ -751,7 +758,7 @@ void CPlayListPlayer::Insert(Id playlistId, const CFileItemPtr& pItem, int iInde void CPlayListPlayer::Insert(Id playlistId, const CFileItemList& items, int iIndex) { - if (playlistId != TYPE_MUSIC && playlistId != TYPE_VIDEO) + if (playlistId != Id::TYPE_MUSIC && playlistId != Id::TYPE_VIDEO) return; CPlayList& list = GetPlaylist(playlistId); int iSize = list.size(); @@ -768,7 +775,7 @@ void CPlayListPlayer::Insert(Id playlistId, const CFileItemList& items, int iInd void CPlayListPlayer::Remove(Id playlistId, int iPosition) { - if (playlistId != TYPE_MUSIC && playlistId != TYPE_VIDEO) + if (playlistId != Id::TYPE_MUSIC && playlistId != Id::TYPE_VIDEO) return; CPlayList& list = GetPlaylist(playlistId); list.Remove(iPosition); @@ -792,7 +799,7 @@ void CPlayListPlayer::Clear() void CPlayListPlayer::Swap(Id playlistId, int indexItem1, int indexItem2) { - if (playlistId != TYPE_MUSIC && playlistId != TYPE_VIDEO) + if (playlistId != Id::TYPE_MUSIC && playlistId != Id::TYPE_VIDEO) return; CPlayList& list = GetPlaylist(playlistId); @@ -817,12 +824,12 @@ void CPlayListPlayer::AnnouncePropertyChanged(Id playlistId, const auto appPlayer = components.GetComponent<CApplicationPlayer>(); if (strProperty.empty() || value.isNull() || - (playlistId == TYPE_VIDEO && !appPlayer->IsPlayingVideo()) || - (playlistId == TYPE_MUSIC && !appPlayer->IsPlayingAudio())) + (playlistId == Id::TYPE_VIDEO && !appPlayer->IsPlayingVideo()) || + (playlistId == Id::TYPE_MUSIC && !appPlayer->IsPlayingAudio())) return; CVariant data; - data["player"]["playerid"] = playlistId; + data["player"]["playerid"] = static_cast<int>(playlistId); data["property"][strProperty] = value; CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::Player, "OnPropertyChanged", data); @@ -877,7 +884,7 @@ void PLAYLIST::CPlayListPlayer::OnApplicationMessage(KODI::MESSAGING::ThreadMess { CFileItemList *list = static_cast<CFileItemList*>(pMsg->lpVoid); - Add(pMsg->param1, (*list)); + Add(Id{pMsg->param1}, (*list)); delete list; } break; @@ -886,32 +893,32 @@ void PLAYLIST::CPlayListPlayer::OnApplicationMessage(KODI::MESSAGING::ThreadMess if (pMsg->lpVoid) { CFileItemList *list = static_cast<CFileItemList*>(pMsg->lpVoid); - Insert(pMsg->param1, (*list), pMsg->param2); + Insert(Id{pMsg->param1}, (*list), pMsg->param2); delete list; } break; case TMSG_PLAYLISTPLAYER_REMOVE: if (pMsg->param1 != -1) - Remove(pMsg->param1, pMsg->param2); + Remove(Id{pMsg->param1}, pMsg->param2); break; case TMSG_PLAYLISTPLAYER_CLEAR: - ClearPlaylist(pMsg->param1); + ClearPlaylist(Id{pMsg->param1}); break; case TMSG_PLAYLISTPLAYER_SHUFFLE: - SetShuffle(pMsg->param1, pMsg->param2 > 0); + SetShuffle(Id{pMsg->param1}, pMsg->param2 > 0); break; case TMSG_PLAYLISTPLAYER_REPEAT: - SetRepeat(pMsg->param1, static_cast<RepeatState>(pMsg->param2)); + SetRepeat(Id{pMsg->param1}, static_cast<RepeatState>(pMsg->param2)); break; case TMSG_PLAYLISTPLAYER_GET_ITEMS: if (pMsg->lpVoid) { - PLAYLIST::CPlayList playlist = GetPlaylist(pMsg->param1); + PLAYLIST::CPlayList playlist = GetPlaylist(Id{pMsg->param1}); CFileItemList *list = static_cast<CFileItemList*>(pMsg->lpVoid); for (int i = 0; i < playlist.size(); i++) @@ -924,7 +931,7 @@ void PLAYLIST::CPlayListPlayer::OnApplicationMessage(KODI::MESSAGING::ThreadMess { auto indexes = static_cast<std::vector<int>*>(pMsg->lpVoid); if (indexes->size() == 2) - Swap(pMsg->param1, indexes->at(0), indexes->at(1)); + Swap(Id{pMsg->param1}, indexes->at(0), indexes->at(1)); delete indexes; } break; @@ -954,12 +961,12 @@ void PLAYLIST::CPlayListPlayer::OnApplicationMessage(KODI::MESSAGING::ThreadMess if (list->Size() > 0) { - Id playlistId = TYPE_MUSIC; + Id playlistId = Id::TYPE_MUSIC; for (int i = 0; i < list->Size(); i++) { if (IsVideo(*list->Get(i))) { - playlistId = TYPE_VIDEO; + playlistId = Id::TYPE_VIDEO; break; } } @@ -997,10 +1004,10 @@ void PLAYLIST::CPlayListPlayer::OnApplicationMessage(KODI::MESSAGING::ThreadMess delete list; } - else if (pMsg->param1 == TYPE_MUSIC || pMsg->param1 == TYPE_VIDEO) + else if (Id{pMsg->param1} == Id::TYPE_MUSIC || Id{pMsg->param1} == Id::TYPE_VIDEO) { - if (GetCurrentPlaylist() != pMsg->param1) - SetCurrentPlaylist(pMsg->param1); + if (GetCurrentPlaylist() != Id{pMsg->param1}) + SetCurrentPlaylist(Id{pMsg->param1}); CServiceBroker::GetAppMessenger()->SendMsg(TMSG_PLAYLISTPLAYER_PLAY, pMsg->param2); } @@ -1018,12 +1025,12 @@ void PLAYLIST::CPlayListPlayer::OnApplicationMessage(KODI::MESSAGING::ThreadMess bool stopVideo = true; bool stopMusic = true; - Id playlistId = pMsg->param1; - if (playlistId != TYPE_NONE) + Id playlistId = Id{pMsg->param1}; + if (playlistId != Id::TYPE_NONE) { - stopSlideshow = (playlistId == TYPE_PICTURE); - stopVideo = (playlistId == TYPE_VIDEO); - stopMusic = (playlistId == TYPE_MUSIC); + stopSlideshow = (playlistId == Id::TYPE_PICTURE); + stopVideo = (playlistId == Id::TYPE_VIDEO); + stopMusic = (playlistId == Id::TYPE_MUSIC); } if ((stopSlideshow && CServiceBroker::GetGUI()->GetWindowManager().GetActiveWindow() == WINDOW_SLIDESHOW) || @@ -1075,3 +1082,5 @@ void PLAYLIST::CPlayListPlayer::OnApplicationMessage(KODI::MESSAGING::ThreadMess break; } } + +} // namespace KODI::PLAYLIST diff --git a/xbmc/PlayListPlayer.h b/xbmc/PlayListPlayer.h index f17abf6280..6dbb13a4b4 100644 --- a/xbmc/PlayListPlayer.h +++ b/xbmc/PlayListPlayer.h @@ -22,7 +22,7 @@ class CFileItemList; class CVariant; -namespace PLAYLIST +namespace KODI::PLAYLIST { class CPlayList; @@ -93,24 +93,24 @@ public: int GetNextItemIdx(int offset) const; /*! \brief Set the active playlist - \param id Values can be PLAYLIST::TYPE_NONE, PLAYLIST::TYPE_MUSIC or PLAYLIST::TYPE_VIDEO + \param id Id of playlist \sa GetCurrentPlaylist */ - void SetCurrentPlaylist(PLAYLIST::Id playlistId); + void SetCurrentPlaylist(Id playlistId); /*! \brief Get the currently active playlist - \return PLAYLIST::TYPE_NONE, PLAYLIST::TYPE_MUSIC or PLAYLIST::TYPE_VIDEO + \return Id of playlist \sa SetCurrentPlaylist, GetPlaylist */ - PLAYLIST::Id GetCurrentPlaylist() const; + Id GetCurrentPlaylist() const; /*! \brief Get a particular playlist object - \param id Values can be PLAYLIST::TYPE_MUSIC or PLAYLIST::TYPE_VIDEO + \param id Id of playlist \return A reference to the CPlayList object. \sa GetCurrentPlaylist */ - CPlayList& GetPlaylist(PLAYLIST::Id playlistId); - const CPlayList& GetPlaylist(PLAYLIST::Id playlistId) const; + CPlayList& GetPlaylist(Id playlistId); + const CPlayList& GetPlaylist(Id playlistId) const; /*! \brief Removes any item from all playlists located on a removable share \return Number of items removed from PLAYLIST::TYPE_MUSIC and PLAYLIST::TYPE_VIDEO @@ -122,7 +122,7 @@ public: */ void Reset(); - void ClearPlaylist(PLAYLIST::Id playlistId); + void ClearPlaylist(Id playlistId); void Clear(); /*! \brief Set shuffle state of a playlist. @@ -133,7 +133,7 @@ public: \param notify notify the user with a Toast notification (defaults to false) \sa IsShuffled */ - void SetShuffle(PLAYLIST::Id playlistId, bool shuffle, bool notify = false); + void SetShuffle(Id playlistId, bool shuffle, bool notify = false); /*! \brief Return whether a playlist is shuffled. If partymode is enabled, this always returns false. @@ -141,7 +141,7 @@ public: \return true if the given playlist is shuffled and party mode isn't enabled, false otherwise. \sa SetShuffle */ - bool IsShuffled(PLAYLIST::Id playlistId) const; + bool IsShuffled(Id playlistId) const; /*! \brief Return whether or not something has been played yet from the current playlist. \return true if something has been played, false otherwise. @@ -155,38 +155,39 @@ public: \param notify notify the user with a Toast notification \sa GetRepeat */ - void SetRepeat(PLAYLIST::Id playlistId, PLAYLIST::RepeatState state, bool notify = false); - PLAYLIST::RepeatState GetRepeat(PLAYLIST::Id playlistId) const; + void SetRepeat(Id playlistId, RepeatState state, bool notify = false); + RepeatState GetRepeat(Id playlistId) const; // add items via the playlist player - void Add(PLAYLIST::Id playlistId, const CPlayList& playlist); - void Add(PLAYLIST::Id playlistId, const CFileItemPtr& pItem); - void Add(PLAYLIST::Id playlistId, const CFileItemList& items); - void Insert(PLAYLIST::Id playlistId, const CPlayList& playlist, int iIndex); - void Insert(PLAYLIST::Id playlistId, const CFileItemPtr& pItem, int iIndex); - void Insert(PLAYLIST::Id playlistId, const CFileItemList& items, int iIndex); - void Remove(PLAYLIST::Id playlistId, int iPosition); - void Swap(PLAYLIST::Id playlistId, int indexItem1, int indexItem2); + void Add(Id playlistId, const CPlayList& playlist); + void Add(Id playlistId, const CFileItemPtr& pItem); + void Add(Id playlistId, const CFileItemList& items); + void Insert(Id playlistId, const CPlayList& playlist, int iIndex); + void Insert(Id playlistId, const CFileItemPtr& pItem, int iIndex); + void Insert(Id playlistId, const CFileItemList& items, int iIndex); + void Remove(Id playlistId, int iPosition); + void Swap(Id playlistId, int indexItem1, int indexItem2); bool IsSingleItemNonRepeatPlaylist() const; bool OnAction(const CAction &action); + protected: /*! \brief Returns true if the given is set to repeat all \param playlist Playlist to be query \return true if the given playlist is set to repeat all, false otherwise. */ - bool Repeated(PLAYLIST::Id playlistId) const; + bool Repeated(Id playlistId) const; /*! \brief Returns true if the given is set to repeat one \param playlist Playlist to be query \return true if the given playlist is set to repeat one, false otherwise. */ - bool RepeatedOne(PLAYLIST::Id playlistId) const; + bool RepeatedOne(Id playlistId) const; - void ReShuffle(PLAYLIST::Id playlistId, int iPosition); + void ReShuffle(Id playlistId, int iPosition); - void AnnouncePropertyChanged(PLAYLIST::Id playlistId, + void AnnouncePropertyChanged(Id playlistId, const std::string& strProperty, const CVariant& value); @@ -195,15 +196,15 @@ protected: int m_iFailedSongs; std::chrono::time_point<std::chrono::steady_clock> m_failedSongsStart; int m_iCurrentSong; - PLAYLIST::Id m_iCurrentPlayList{PLAYLIST::TYPE_NONE}; + Id m_iCurrentPlayList{Id::TYPE_NONE}; CPlayList* m_PlaylistMusic; CPlayList* m_PlaylistVideo; CPlayList* m_PlaylistEmpty; - std::map<PLAYLIST::Id, PLAYLIST::RepeatState> m_repeatState{ - {PLAYLIST::TYPE_MUSIC, PLAYLIST::RepeatState::NONE}, - {PLAYLIST::TYPE_VIDEO, PLAYLIST::RepeatState::NONE}, - {PLAYLIST::TYPE_PICTURE, PLAYLIST::RepeatState::NONE}, + std::map<Id, RepeatState> m_repeatState{ + {Id::TYPE_MUSIC, RepeatState::NONE}, + {Id::TYPE_VIDEO, RepeatState::NONE}, + {Id::TYPE_PICTURE, RepeatState::NONE}, }; }; -} +} // namespace KODI::PLAYLIST diff --git a/xbmc/ServiceBroker.h b/xbmc/ServiceBroker.h index 659b07d61d..d5f00b6e00 100644 --- a/xbmc/ServiceBroker.h +++ b/xbmc/ServiceBroker.h @@ -37,7 +37,7 @@ namespace PVR class CPVRManager; } -namespace PLAYLIST +namespace KODI::PLAYLIST { class CPlayListPlayer; } @@ -152,7 +152,7 @@ public: static CContextMenuManager& GetContextMenuManager(); static CDataCacheCore& GetDataCacheCore(); static CPlatform& GetPlatform(); - static PLAYLIST::CPlayListPlayer& GetPlaylistPlayer(); + static KODI::PLAYLIST::CPlayListPlayer& GetPlaylistPlayer(); static CSlideShowDelegator& GetSlideShowDelegator(); static KODI::GAME::CControllerManager& GetGameControllerManager(); static KODI::GAME::CGameServices& GetGameServices(); diff --git a/xbmc/ServiceManager.h b/xbmc/ServiceManager.h index 6dcc28cbd0..2896166c23 100644 --- a/xbmc/ServiceManager.h +++ b/xbmc/ServiceManager.h @@ -27,7 +27,7 @@ namespace PVR class CPVRManager; } -namespace PLAYLIST +namespace KODI::PLAYLIST { class CPlayListPlayer; } @@ -127,7 +127,7 @@ public: KODI::RETRO::CGUIGameRenderManager& GetGameRenderManager(); PERIPHERALS::CPeripherals& GetPeripherals(); - PLAYLIST::CPlayListPlayer& GetPlaylistPlayer(); + KODI::PLAYLIST::CPlayListPlayer& GetPlaylistPlayer(); CSlideShowDelegator& GetSlideShowDelegator(); int init_level = 0; @@ -167,7 +167,7 @@ protected: std::unique_ptr<CContextMenuManager> m_contextMenuManager; std::unique_ptr<CDataCacheCore> m_dataCacheCore; std::unique_ptr<CPlatform> m_Platform; - std::unique_ptr<PLAYLIST::CPlayListPlayer> m_playlistPlayer; + std::unique_ptr<KODI::PLAYLIST::CPlayListPlayer> m_playlistPlayer; std::unique_ptr<KODI::GAME::CControllerManager> m_gameControllerManager; std::unique_ptr<KODI::GAME::CGameServices> m_gameServices; std::unique_ptr<KODI::RETRO::CGUIGameRenderManager> m_gameRenderManager; diff --git a/xbmc/Util.cpp b/xbmc/Util.cpp index 82cc638bee..eb10ab14fc 100644 --- a/xbmc/Util.cpp +++ b/xbmc/Util.cpp @@ -92,7 +92,6 @@ using namespace MEDIA_DETECT; #endif using namespace XFILE; -using namespace PLAYLIST; using KODI::UTILITY::CDigest; using namespace KODI; diff --git a/xbmc/application/Application.cpp b/xbmc/application/Application.cpp index 8cb1731647..12470ca7a7 100644 --- a/xbmc/application/Application.cpp +++ b/xbmc/application/Application.cpp @@ -1368,12 +1368,12 @@ bool CApplication::OnAction(const CAction &action) if (action.GetID() == ACTION_SHOW_PLAYLIST) { const PLAYLIST::Id playlistId = CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist(); - if (playlistId == PLAYLIST::TYPE_VIDEO && + if (playlistId == PLAYLIST::Id::TYPE_VIDEO && CServiceBroker::GetGUI()->GetWindowManager().GetActiveWindow() != WINDOW_VIDEO_PLAYLIST) { CServiceBroker::GetGUI()->GetWindowManager().ActivateWindow(WINDOW_VIDEO_PLAYLIST); } - else if (playlistId == PLAYLIST::TYPE_MUSIC && + else if (playlistId == PLAYLIST::Id::TYPE_MUSIC && CServiceBroker::GetGUI()->GetWindowManager().GetActiveWindow() != WINDOW_MUSIC_PLAYLIST) { @@ -1843,8 +1843,8 @@ int CApplication::Run() CFileItemList& playlist = CServiceBroker::GetAppParams()->GetPlaylist(); if (playlist.Size() > 0) { - CServiceBroker::GetPlaylistPlayer().Add(PLAYLIST::TYPE_MUSIC, playlist); - CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::TYPE_MUSIC); + CServiceBroker::GetPlaylistPlayer().Add(PLAYLIST::Id::TYPE_MUSIC, playlist); + CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::Id::TYPE_MUSIC); CServiceBroker::GetAppMessenger()->PostMsg(TMSG_PLAYLISTPLAYER_PLAY, -1); } @@ -2176,16 +2176,16 @@ bool CApplication::PlayMedia(CFileItem& item, const std::string& player, PLAYLIS CUtil::GetRecursiveListing(item.GetPath(), items, "", DIR_FLAG_NO_FILE_DIRS); if (items.Size()) { - CSmartPlaylist smartpl; + PLAYLIST::CSmartPlaylist smartpl; //get name and type of smartplaylist, this will always succeed as GetDirectory also did this. smartpl.OpenAndReadName(item.GetURL()); PLAYLIST::CPlayList playlist; playlist.Add(items); - PLAYLIST::Id smartplPlaylistId = PLAYLIST::TYPE_VIDEO; + PLAYLIST::Id smartplPlaylistId = PLAYLIST::Id::TYPE_VIDEO; if (smartpl.GetType() == "songs" || smartpl.GetType() == "albums" || smartpl.GetType() == "artists") - smartplPlaylistId = PLAYLIST::TYPE_MUSIC; + smartplPlaylistId = PLAYLIST::Id::TYPE_MUSIC; return ProcessAndStartPlaylist(smartpl.GetName(), playlist, smartplPlaylistId); } @@ -2214,7 +2214,7 @@ bool CApplication::PlayMedia(CFileItem& item, const std::string& player, PLAYLIS if (playlist) { - if (playlistId != PLAYLIST::TYPE_NONE) + if (playlistId != PLAYLIST::Id::TYPE_NONE) { int track=0; if (item.HasProperty("playlist_starting_track")) @@ -2456,7 +2456,7 @@ bool CApplication::PlayFile(CFileItem item, // this really aught to be inside !bRestart, but since PlayStack // uses that to init playback, we have to keep it outside const PLAYLIST::Id playlistId = CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist(); - if (MUSIC::IsAudio(item) && playlistId == PLAYLIST::TYPE_MUSIC) + if (MUSIC::IsAudio(item) && playlistId == PLAYLIST::Id::TYPE_MUSIC) { // playing from a playlist by the looks // don't switch to fullscreen if we are not playing the first item... options.fullscreen = !CServiceBroker::GetPlaylistPlayer().HasPlayedFirstFile() && @@ -2464,7 +2464,7 @@ bool CApplication::PlayFile(CFileItem item, CSettings::SETTING_MUSICFILES_SELECTACTION) && !CMediaSettings::GetInstance().DoesMediaStartWindowed(); } - else if (VIDEO::IsVideo(item) && playlistId == PLAYLIST::TYPE_VIDEO && + else if (VIDEO::IsVideo(item) && playlistId == PLAYLIST::Id::TYPE_VIDEO && CServiceBroker::GetPlaylistPlayer().GetPlaylist(playlistId).size() > 1) { // playing from a playlist by the looks // don't switch to fullscreen if we are not playing the first item... @@ -2526,7 +2526,7 @@ bool CApplication::PlayFile(CFileItem item, #endif if (item.HasPVRChannelInfoTag()) - CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::TYPE_NONE); + CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::Id::TYPE_NONE); return true; } @@ -2564,7 +2564,7 @@ void CApplication::PlaybackCleanup() const auto appPower = GetComponent<CApplicationPowerHandling>(); if (!appPlayer->IsPlayingAudio() && - CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::TYPE_NONE && + CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::Id::TYPE_NONE && CServiceBroker::GetGUI()->GetWindowManager().GetActiveWindow() == WINDOW_VISUALISATION) { CServiceBroker::GetSettingsComponent()->GetSettings()->Save(); // save vis settings @@ -2728,7 +2728,9 @@ bool CApplication::OnMessage(CGUIMessage& message) // update the playlist manager int currentSong = CServiceBroker::GetPlaylistPlayer().GetCurrentItemIdx(); int param = ((currentSong & 0xffff) << 16) | (m_nextPlaylistItem & 0xffff); - CGUIMessage msg(GUI_MSG_PLAYLISTPLAYER_CHANGED, 0, 0, CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist(), param, item); + CGUIMessage msg(GUI_MSG_PLAYLISTPLAYER_CHANGED, 0, 0, + static_cast<int>(CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist()), + param, item); CServiceBroker::GetGUI()->GetWindowManager().SendThreadMessage(msg); CServiceBroker::GetPlaylistPlayer().SetCurrentItemIdx(m_nextPlaylistItem); m_itemCurrentFile = std::make_shared<CFileItem>(*item); @@ -2744,7 +2746,8 @@ bool CApplication::OnMessage(CGUIMessage& message) CVariant param; param["player"]["speed"] = 1; - param["player"]["playerid"] = CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist(); + param["player"]["playerid"] = + static_cast<int>(CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist()); CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::Player, "OnPlay", m_itemCurrentFile, param); @@ -2918,7 +2921,8 @@ bool CApplication::OnMessage(CGUIMessage& message) { CVariant param; param["player"]["speed"] = 1; - param["player"]["playerid"] = CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist(); + param["player"]["playerid"] = + static_cast<int>(CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist()); CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::Player, "OnAVStart", m_itemCurrentFile, param); m_playerEvent.Set(); @@ -2939,7 +2943,8 @@ bool CApplication::OnMessage(CGUIMessage& message) #endif CVariant param; param["player"]["speed"] = 1; - param["player"]["playerid"] = CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist(); + param["player"]["playerid"] = + static_cast<int>(CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist()); CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::Player, "OnAVChange", m_itemCurrentFile, param); return true; @@ -2949,7 +2954,8 @@ bool CApplication::OnMessage(CGUIMessage& message) { CVariant param; param["player"]["speed"] = 0; - param["player"]["playerid"] = CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist(); + param["player"]["playerid"] = + static_cast<int>(CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist()); CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::Player, "OnPause", m_itemCurrentFile, param); return true; @@ -2959,7 +2965,8 @@ bool CApplication::OnMessage(CGUIMessage& message) { CVariant param; param["player"]["speed"] = 1; - param["player"]["playerid"] = CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist(); + param["player"]["playerid"] = + static_cast<int>(CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist()); CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::Player, "OnResume", m_itemCurrentFile, param); return true; @@ -2972,7 +2979,8 @@ bool CApplication::OnMessage(CGUIMessage& message) const int64_t seekOffset = message.GetParam2AsI64(); JSONRPC::CJSONUtils::MillisecondsToTimeObject(iTime, param["player"]["time"]); JSONRPC::CJSONUtils::MillisecondsToTimeObject(seekOffset, param["player"]["seekoffset"]); - param["player"]["playerid"] = CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist(); + param["player"]["playerid"] = + static_cast<int>(CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist()); const auto& components = CServiceBroker::GetAppComponents(); const auto appPlayer = components.GetComponent<CApplicationPlayer>(); param["player"]["speed"] = static_cast<int>(appPlayer->GetPlaySpeed()); @@ -2988,7 +2996,8 @@ bool CApplication::OnMessage(CGUIMessage& message) { CVariant param; param["player"]["speed"] = message.GetParam1(); - param["player"]["playerid"] = CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist(); + param["player"]["playerid"] = + static_cast<int>(CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist()); CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::Player, "OnSpeedChanged", m_itemCurrentFile, param); @@ -3538,7 +3547,8 @@ bool CApplication::ProcessAndStartPlaylist(const std::string& strPlayList, PLAYLIST::Id playlistId, int track) { - CLog::Log(LOGDEBUG, "CApplication::ProcessAndStartPlaylist({}, {})", strPlayList, playlistId); + CLog::Log(LOGDEBUG, "CApplication::ProcessAndStartPlaylist({}, {})", strPlayList, + static_cast<int>(playlistId)); // initial exit conditions // no songs in playlist just return @@ -3546,7 +3556,7 @@ bool CApplication::ProcessAndStartPlaylist(const std::string& strPlayList, return false; // illegal playlist - if (playlistId == PLAYLIST::TYPE_NONE || playlistId == PLAYLIST::TYPE_PICTURE) + if (playlistId == PLAYLIST::Id::TYPE_NONE || playlistId == PLAYLIST::Id::TYPE_PICTURE) return false; // setup correct playlist diff --git a/xbmc/application/Application.h b/xbmc/application/Application.h index d31e591bcd..50b9fc4615 100644 --- a/xbmc/application/Application.h +++ b/xbmc/application/Application.h @@ -59,7 +59,7 @@ namespace MEDIA_DETECT class CAutorun; } -namespace PLAYLIST +namespace KODI::PLAYLIST { class CPlayList; } @@ -120,10 +120,10 @@ public: int GetMessageMask() override; void OnApplicationMessage(KODI::MESSAGING::ThreadMessage* pMsg) override; - bool PlayMedia(CFileItem& item, const std::string& player, PLAYLIST::Id playlistId); + bool PlayMedia(CFileItem& item, const std::string& player, KODI::PLAYLIST::Id playlistId); bool ProcessAndStartPlaylist(const std::string& strPlayList, - PLAYLIST::CPlayList& playlist, - PLAYLIST::Id playlistId, + KODI::PLAYLIST::CPlayList& playlist, + KODI::PLAYLIST::Id playlistId, int track = 0); bool PlayFile(CFileItem item, const std::string& player, diff --git a/xbmc/application/ApplicationPlayer.cpp b/xbmc/application/ApplicationPlayer.cpp index d088f46b6a..18e78d3c0c 100644 --- a/xbmc/application/ApplicationPlayer.cpp +++ b/xbmc/application/ApplicationPlayer.cpp @@ -228,12 +228,12 @@ bool CApplicationPlayer::HasGame() const PLAYLIST::Id CApplicationPlayer::GetPreferredPlaylist() const { if (IsPlayingVideo()) - return PLAYLIST::TYPE_VIDEO; + return PLAYLIST::Id::TYPE_VIDEO; if (IsPlayingAudio()) - return PLAYLIST::TYPE_MUSIC; + return PLAYLIST::Id::TYPE_MUSIC; - return PLAYLIST::TYPE_NONE; + return PLAYLIST::Id::TYPE_NONE; } bool CApplicationPlayer::HasRDS() const diff --git a/xbmc/application/ApplicationPlayer.h b/xbmc/application/ApplicationPlayer.h index f0c04b1594..d695f66aef 100644 --- a/xbmc/application/ApplicationPlayer.h +++ b/xbmc/application/ApplicationPlayer.h @@ -95,7 +95,7 @@ public: int64_t GetChapterPos(int chapterIdx = -1) const; float GetPercentage() const; std::string GetPlayerState(); - PLAYLIST::Id GetPreferredPlaylist() const; + KODI::PLAYLIST::Id GetPreferredPlaylist() const; int GetSubtitleDelay() const; int GetSubtitle(); void GetSubtitleCapabilities(std::vector<int>& subCaps) const; diff --git a/xbmc/contrib/kissfft/CMakeLists.txt b/xbmc/contrib/kissfft/CMakeLists.txt deleted file mode 100644 index e11a6f8026..0000000000 --- a/xbmc/contrib/kissfft/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -if(ENABLE_INTERNAL_KISSFFT) - set(SOURCES kiss_fft.c - kiss_fftr.c) - - set(HEADERS _kiss_fft_guts.h - kiss_fft.h - kiss_fftr.h) - - core_add_library(kissfft) -endif() diff --git a/xbmc/contrib/kissfft/COPYING b/xbmc/contrib/kissfft/COPYING deleted file mode 100644 index 6b4b622e7b..0000000000 --- a/xbmc/contrib/kissfft/COPYING +++ /dev/null @@ -1,11 +0,0 @@ -Copyright (c) 2003-2010 Mark Borgerding . All rights reserved. - -KISS FFT is provided under: - - SPDX-License-Identifier: BSD-3-Clause - -Being under the terms of the BSD 3-clause "New" or "Revised" License, -according with: - - LICENSES/BSD-3-Clause - diff --git a/xbmc/contrib/kissfft/_kiss_fft_guts.h b/xbmc/contrib/kissfft/_kiss_fft_guts.h deleted file mode 100644 index 0a2feee1f3..0000000000 --- a/xbmc/contrib/kissfft/_kiss_fft_guts.h +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (c) 2003-2010, Mark Borgerding. All rights reserved. - * This file is part of KISS FFT - https://github.com/mborgerding/kissfft - * - * SPDX-License-Identifier: BSD-3-Clause - * See COPYING file for more information. - */ - -/* kiss_fft.h - defines kiss_fft_scalar as either short or a float type - and defines - typedef struct { kiss_fft_scalar r; kiss_fft_scalar i; }kiss_fft_cpx; */ -#include "kiss_fft.h" -#include <limits.h> - -#define MAXFACTORS 32 -/* e.g. an fft of length 128 has 4 factors - as far as kissfft is concerned - 4*4*4*2 - */ - -struct kiss_fft_state{ - int nfft; - int inverse; - int factors[2*MAXFACTORS]; - kiss_fft_cpx twiddles[1]; -}; - -/* - Explanation of macros dealing with complex math: - - C_MUL(m,a,b) : m = a*b - C_FIXDIV( c , div ) : if a fixed point impl., c /= div. noop otherwise - C_SUB( res, a,b) : res = a - b - C_SUBFROM( res , a) : res -= a - C_ADDTO( res , a) : res += a - * */ -#ifdef FIXED_POINT -#if (FIXED_POINT==32) -# define FRACBITS 31 -# define SAMPPROD int64_t -#define SAMP_MAX 2147483647 -#else -# define FRACBITS 15 -# define SAMPPROD int32_t -#define SAMP_MAX 32767 -#endif - -#define SAMP_MIN -SAMP_MAX - -#if defined(CHECK_OVERFLOW) -# define CHECK_OVERFLOW_OP(a,op,b) \ - if ( (SAMPPROD)(a) op (SAMPPROD)(b) > SAMP_MAX || (SAMPPROD)(a) op (SAMPPROD)(b) < SAMP_MIN ) { \ - fprintf(stderr,"WARNING:overflow @ " __FILE__ "(%d): (%d " #op" %d) = %ld\n",__LINE__,(a),(b),(SAMPPROD)(a) op (SAMPPROD)(b) ); } -#endif - - -# define smul(a,b) ( (SAMPPROD)(a)*(b) ) -# define sround( x ) (kiss_fft_scalar)( ( (x) + (1<<(FRACBITS-1)) ) >> FRACBITS ) - -# define S_MUL(a,b) sround( smul(a,b) ) - -# define C_MUL(m,a,b) \ - do{ (m).r = sround( smul((a).r,(b).r) - smul((a).i,(b).i) ); \ - (m).i = sround( smul((a).r,(b).i) + smul((a).i,(b).r) ); }while(0) - -# define DIVSCALAR(x,k) \ - (x) = sround( smul( x, SAMP_MAX/k ) ) - -# define C_FIXDIV(c,div) \ - do { DIVSCALAR( (c).r , div); \ - DIVSCALAR( (c).i , div); }while (0) - -# define C_MULBYSCALAR( c, s ) \ - do{ (c).r = sround( smul( (c).r , s ) ) ;\ - (c).i = sround( smul( (c).i , s ) ) ; }while(0) - -#else /* not FIXED_POINT*/ - -# define S_MUL(a,b) ( (a)*(b) ) -#define C_MUL(m,a,b) \ - do{ (m).r = (a).r*(b).r - (a).i*(b).i;\ - (m).i = (a).r*(b).i + (a).i*(b).r; }while(0) -# define C_FIXDIV(c,div) /* NOOP */ -# define C_MULBYSCALAR( c, s ) \ - do{ (c).r *= (s);\ - (c).i *= (s); }while(0) -#endif - -#ifndef CHECK_OVERFLOW_OP -# define CHECK_OVERFLOW_OP(a,op,b) /* noop */ -#endif - -#define C_ADD( res, a,b)\ - do { \ - CHECK_OVERFLOW_OP((a).r,+,(b).r)\ - CHECK_OVERFLOW_OP((a).i,+,(b).i)\ - (res).r=(a).r+(b).r; (res).i=(a).i+(b).i; \ - }while(0) -#define C_SUB( res, a,b)\ - do { \ - CHECK_OVERFLOW_OP((a).r,-,(b).r)\ - CHECK_OVERFLOW_OP((a).i,-,(b).i)\ - (res).r=(a).r-(b).r; (res).i=(a).i-(b).i; \ - }while(0) -#define C_ADDTO( res , a)\ - do { \ - CHECK_OVERFLOW_OP((res).r,+,(a).r)\ - CHECK_OVERFLOW_OP((res).i,+,(a).i)\ - (res).r += (a).r; (res).i += (a).i;\ - }while(0) - -#define C_SUBFROM( res , a)\ - do {\ - CHECK_OVERFLOW_OP((res).r,-,(a).r)\ - CHECK_OVERFLOW_OP((res).i,-,(a).i)\ - (res).r -= (a).r; (res).i -= (a).i; \ - }while(0) - - -#ifdef FIXED_POINT -# define KISS_FFT_COS(phase) floor(.5+SAMP_MAX * cos (phase)) -# define KISS_FFT_SIN(phase) floor(.5+SAMP_MAX * sin (phase)) -# define HALF_OF(x) ((x)>>1) -#elif defined(USE_SIMD) -# define KISS_FFT_COS(phase) _mm_set1_ps( cos(phase) ) -# define KISS_FFT_SIN(phase) _mm_set1_ps( sin(phase) ) -# define HALF_OF(x) ((x)*_mm_set1_ps(.5)) -#else -# define KISS_FFT_COS(phase) (kiss_fft_scalar) cos(phase) -# define KISS_FFT_SIN(phase) (kiss_fft_scalar) sin(phase) -# define HALF_OF(x) ((x)*.5f) -#endif - -#define kf_cexp(x,phase) \ - do{ \ - (x)->r = KISS_FFT_COS(phase);\ - (x)->i = KISS_FFT_SIN(phase);\ - }while(0) - - -/* a debugging function */ -#define pcpx(c)\ - fprintf(stderr,"%g + %gi\n",(double)((c)->r),(double)((c)->i) ) - - -#ifdef KISS_FFT_USE_ALLOCA -// define this to allow use of alloca instead of malloc for temporary buffers -// Temporary buffers are used in two case: -// 1. FFT sizes that have "bad" factors. i.e. not 2,3 and 5 -// 2. "in-place" FFTs. Notice the quotes, since kissfft does not really do an in-place transform. -#include <alloca.h> -#define KISS_FFT_TMP_ALLOC(nbytes) alloca(nbytes) -#define KISS_FFT_TMP_FREE(ptr) -#else -#define KISS_FFT_TMP_ALLOC(nbytes) KISS_FFT_MALLOC(nbytes) -#define KISS_FFT_TMP_FREE(ptr) KISS_FFT_FREE(ptr) -#endif diff --git a/xbmc/contrib/kissfft/kiss_fft.c b/xbmc/contrib/kissfft/kiss_fft.c deleted file mode 100644 index 1db72b59d5..0000000000 --- a/xbmc/contrib/kissfft/kiss_fft.c +++ /dev/null @@ -1,401 +0,0 @@ -/* - * Copyright (c) 2003-2010, Mark Borgerding. All rights reserved. - * This file is part of KISS FFT - https://github.com/mborgerding/kissfft - * - * SPDX-License-Identifier: BSD-3-Clause - * See COPYING file for more information. - */ - -#include "_kiss_fft_guts.h" -/* The guts header contains all the multiplication and addition macros that are defined for - fixed or floating point complex numbers. It also declares the kf_ internal functions. - */ - -static void kf_bfly2( - kiss_fft_cpx * Fout, - const size_t fstride, - const kiss_fft_cfg st, - int m - ) -{ - kiss_fft_cpx * Fout2; - kiss_fft_cpx * tw1 = st->twiddles; - kiss_fft_cpx t; - Fout2 = Fout + m; - do{ - C_FIXDIV(*Fout,2); C_FIXDIV(*Fout2,2); - - C_MUL (t, *Fout2 , *tw1); - tw1 += fstride; - C_SUB( *Fout2 , *Fout , t ); - C_ADDTO( *Fout , t ); - ++Fout2; - ++Fout; - }while (--m); -} - -static void kf_bfly4( - kiss_fft_cpx * Fout, - const size_t fstride, - const kiss_fft_cfg st, - const size_t m - ) -{ - kiss_fft_cpx *tw1,*tw2,*tw3; - kiss_fft_cpx scratch[6]; - size_t k=m; - const size_t m2=2*m; - const size_t m3=3*m; - - - tw3 = tw2 = tw1 = st->twiddles; - - do { - C_FIXDIV(*Fout,4); C_FIXDIV(Fout[m],4); C_FIXDIV(Fout[m2],4); C_FIXDIV(Fout[m3],4); - - C_MUL(scratch[0],Fout[m] , *tw1 ); - C_MUL(scratch[1],Fout[m2] , *tw2 ); - C_MUL(scratch[2],Fout[m3] , *tw3 ); - - C_SUB( scratch[5] , *Fout, scratch[1] ); - C_ADDTO(*Fout, scratch[1]); - C_ADD( scratch[3] , scratch[0] , scratch[2] ); - C_SUB( scratch[4] , scratch[0] , scratch[2] ); - C_SUB( Fout[m2], *Fout, scratch[3] ); - tw1 += fstride; - tw2 += fstride*2; - tw3 += fstride*3; - C_ADDTO( *Fout , scratch[3] ); - - if(st->inverse) { - Fout[m].r = scratch[5].r - scratch[4].i; - Fout[m].i = scratch[5].i + scratch[4].r; - Fout[m3].r = scratch[5].r + scratch[4].i; - Fout[m3].i = scratch[5].i - scratch[4].r; - }else{ - Fout[m].r = scratch[5].r + scratch[4].i; - Fout[m].i = scratch[5].i - scratch[4].r; - Fout[m3].r = scratch[5].r - scratch[4].i; - Fout[m3].i = scratch[5].i + scratch[4].r; - } - ++Fout; - }while(--k); -} - -static void kf_bfly3( - kiss_fft_cpx * Fout, - const size_t fstride, - const kiss_fft_cfg st, - size_t m - ) -{ - size_t k=m; - const size_t m2 = 2*m; - kiss_fft_cpx *tw1,*tw2; - kiss_fft_cpx scratch[5]; - kiss_fft_cpx epi3; - epi3 = st->twiddles[fstride*m]; - - tw1=tw2=st->twiddles; - - do{ - C_FIXDIV(*Fout,3); C_FIXDIV(Fout[m],3); C_FIXDIV(Fout[m2],3); - - C_MUL(scratch[1],Fout[m] , *tw1); - C_MUL(scratch[2],Fout[m2] , *tw2); - - C_ADD(scratch[3],scratch[1],scratch[2]); - C_SUB(scratch[0],scratch[1],scratch[2]); - tw1 += fstride; - tw2 += fstride*2; - - Fout[m].r = Fout->r - HALF_OF(scratch[3].r); - Fout[m].i = Fout->i - HALF_OF(scratch[3].i); - - C_MULBYSCALAR( scratch[0] , epi3.i ); - - C_ADDTO(*Fout,scratch[3]); - - Fout[m2].r = Fout[m].r + scratch[0].i; - Fout[m2].i = Fout[m].i - scratch[0].r; - - Fout[m].r -= scratch[0].i; - Fout[m].i += scratch[0].r; - - ++Fout; - }while(--k); -} - -static void kf_bfly5( - kiss_fft_cpx * Fout, - const size_t fstride, - const kiss_fft_cfg st, - int m - ) -{ - kiss_fft_cpx *Fout0,*Fout1,*Fout2,*Fout3,*Fout4; - int u; - kiss_fft_cpx scratch[13]; - kiss_fft_cpx * twiddles = st->twiddles; - kiss_fft_cpx *tw; - kiss_fft_cpx ya,yb; - ya = twiddles[fstride*m]; - yb = twiddles[fstride*2*m]; - - Fout0=Fout; - Fout1=Fout0+m; - Fout2=Fout0+2*m; - Fout3=Fout0+3*m; - Fout4=Fout0+4*m; - - tw=st->twiddles; - for ( u=0; u<m; ++u ) { - C_FIXDIV( *Fout0,5); C_FIXDIV( *Fout1,5); C_FIXDIV( *Fout2,5); C_FIXDIV( *Fout3,5); C_FIXDIV( *Fout4,5); - scratch[0] = *Fout0; - - C_MUL(scratch[1] ,*Fout1, tw[u*fstride]); - C_MUL(scratch[2] ,*Fout2, tw[2*u*fstride]); - C_MUL(scratch[3] ,*Fout3, tw[3*u*fstride]); - C_MUL(scratch[4] ,*Fout4, tw[4*u*fstride]); - - C_ADD( scratch[7],scratch[1],scratch[4]); - C_SUB( scratch[10],scratch[1],scratch[4]); - C_ADD( scratch[8],scratch[2],scratch[3]); - C_SUB( scratch[9],scratch[2],scratch[3]); - - Fout0->r += scratch[7].r + scratch[8].r; - Fout0->i += scratch[7].i + scratch[8].i; - - scratch[5].r = scratch[0].r + S_MUL(scratch[7].r,ya.r) + S_MUL(scratch[8].r,yb.r); - scratch[5].i = scratch[0].i + S_MUL(scratch[7].i,ya.r) + S_MUL(scratch[8].i,yb.r); - - scratch[6].r = S_MUL(scratch[10].i,ya.i) + S_MUL(scratch[9].i,yb.i); - scratch[6].i = -S_MUL(scratch[10].r,ya.i) - S_MUL(scratch[9].r,yb.i); - - C_SUB(*Fout1,scratch[5],scratch[6]); - C_ADD(*Fout4,scratch[5],scratch[6]); - - scratch[11].r = scratch[0].r + S_MUL(scratch[7].r,yb.r) + S_MUL(scratch[8].r,ya.r); - scratch[11].i = scratch[0].i + S_MUL(scratch[7].i,yb.r) + S_MUL(scratch[8].i,ya.r); - scratch[12].r = - S_MUL(scratch[10].i,yb.i) + S_MUL(scratch[9].i,ya.i); - scratch[12].i = S_MUL(scratch[10].r,yb.i) - S_MUL(scratch[9].r,ya.i); - - C_ADD(*Fout2,scratch[11],scratch[12]); - C_SUB(*Fout3,scratch[11],scratch[12]); - - ++Fout0;++Fout1;++Fout2;++Fout3;++Fout4; - } -} - -/* perform the butterfly for one stage of a mixed radix FFT */ -static void kf_bfly_generic( - kiss_fft_cpx * Fout, - const size_t fstride, - const kiss_fft_cfg st, - int m, - int p - ) -{ - int u,k,q1,q; - kiss_fft_cpx * twiddles = st->twiddles; - kiss_fft_cpx t; - int Norig = st->nfft; - - kiss_fft_cpx * scratch = (kiss_fft_cpx*)KISS_FFT_TMP_ALLOC(sizeof(kiss_fft_cpx)*p); - - for ( u=0; u<m; ++u ) { - k=u; - for ( q1=0 ; q1<p ; ++q1 ) { - scratch[q1] = Fout[ k ]; - C_FIXDIV(scratch[q1],p); - k += m; - } - - k=u; - for ( q1=0 ; q1<p ; ++q1 ) { - int twidx=0; - Fout[ k ] = scratch[0]; - for (q=1;q<p;++q ) { - twidx += fstride * k; - if (twidx>=Norig) twidx-=Norig; - C_MUL(t,scratch[q] , twiddles[twidx] ); - C_ADDTO( Fout[ k ] ,t); - } - k += m; - } - } - KISS_FFT_TMP_FREE(scratch); -} - -static -void kf_work( - kiss_fft_cpx * Fout, - const kiss_fft_cpx * f, - const size_t fstride, - int in_stride, - int * factors, - const kiss_fft_cfg st - ) -{ - kiss_fft_cpx * Fout_beg=Fout; - const int p=*factors++; /* the radix */ - const int m=*factors++; /* stage's fft length/p */ - const kiss_fft_cpx * Fout_end = Fout + p*m; - -#ifdef _OPENMP - // use openmp extensions at the - // top-level (not recursive) - if (fstride==1 && p<=5) - { - int k; - - // execute the p different work units in different threads -# pragma omp parallel for - for (k=0;k<p;++k) - kf_work( Fout +k*m, f+ fstride*in_stride*k,fstride*p,in_stride,factors,st); - // all threads have joined by this point - - switch (p) { - case 2: kf_bfly2(Fout,fstride,st,m); break; - case 3: kf_bfly3(Fout,fstride,st,m); break; - case 4: kf_bfly4(Fout,fstride,st,m); break; - case 5: kf_bfly5(Fout,fstride,st,m); break; - default: kf_bfly_generic(Fout,fstride,st,m,p); break; - } - return; - } -#endif - - if (m==1) { - do{ - *Fout = *f; - f += fstride*in_stride; - }while(++Fout != Fout_end ); - }else{ - do{ - // recursive call: - // DFT of size m*p performed by doing - // p instances of smaller DFTs of size m, - // each one takes a decimated version of the input - kf_work( Fout , f, fstride*p, in_stride, factors,st); - f += fstride*in_stride; - }while( (Fout += m) != Fout_end ); - } - - Fout=Fout_beg; - - // recombine the p smaller DFTs - switch (p) { - case 2: kf_bfly2(Fout,fstride,st,m); break; - case 3: kf_bfly3(Fout,fstride,st,m); break; - case 4: kf_bfly4(Fout,fstride,st,m); break; - case 5: kf_bfly5(Fout,fstride,st,m); break; - default: kf_bfly_generic(Fout,fstride,st,m,p); break; - } -} - -/* facbuf is populated by p1,m1,p2,m2, ... - where - p[i] * m[i] = m[i-1] - m0 = n */ -static -void kf_factor(int n,int * facbuf) -{ - int p=4; - double floor_sqrt; - floor_sqrt = floor( sqrt((double)n) ); - - /*factor out powers of 4, powers of 2, then any remaining primes */ - do { - while (n % p) { - switch (p) { - case 4: p = 2; break; - case 2: p = 3; break; - default: p += 2; break; - } - if (p > floor_sqrt) - p = n; /* no more factors, skip to end */ - } - n /= p; - *facbuf++ = p; - *facbuf++ = n; - } while (n > 1); -} - -/* - * - * User-callable function to allocate all necessary storage space for the fft. - * - * The return value is a contiguous block of memory, allocated with malloc. As such, - * It can be freed with free(), rather than a kiss_fft-specific function. - * */ -kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem ) -{ - kiss_fft_cfg st=NULL; - size_t memneeded = sizeof(struct kiss_fft_state) - + sizeof(kiss_fft_cpx)*(nfft-1); /* twiddle factors*/ - - if ( lenmem==NULL ) { - st = ( kiss_fft_cfg)KISS_FFT_MALLOC( memneeded ); - }else{ - if (mem != NULL && *lenmem >= memneeded) - st = (kiss_fft_cfg)mem; - *lenmem = memneeded; - } - if (st) { - int i; - st->nfft=nfft; - st->inverse = inverse_fft; - - for (i=0;i<nfft;++i) { - const double pi=3.141592653589793238462643383279502884197169399375105820974944; - double phase = -2*pi*i / nfft; - if (st->inverse) - phase *= -1; - kf_cexp(st->twiddles+i, phase ); - } - - kf_factor(nfft,st->factors); - } - return st; -} - - -void kiss_fft_stride(kiss_fft_cfg st,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int in_stride) -{ - if (fin == fout) { - //NOTE: this is not really an in-place FFT algorithm. - //It just performs an out-of-place FFT into a temp buffer - kiss_fft_cpx * tmpbuf = (kiss_fft_cpx*)KISS_FFT_TMP_ALLOC( sizeof(kiss_fft_cpx)*st->nfft); - kf_work(tmpbuf,fin,1,in_stride, st->factors,st); - memcpy(fout,tmpbuf,sizeof(kiss_fft_cpx)*st->nfft); - KISS_FFT_TMP_FREE(tmpbuf); - }else{ - kf_work( fout, fin, 1,in_stride, st->factors,st ); - } -} - -void kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout) -{ - kiss_fft_stride(cfg,fin,fout,1); -} - - -void kiss_fft_cleanup(void) -{ - // nothing needed any more -} - -int kiss_fft_next_fast_size(int n) -{ - while(1) { - int m=n; - while ( (m%2) == 0 ) m/=2; - while ( (m%3) == 0 ) m/=3; - while ( (m%5) == 0 ) m/=5; - if (m<=1) - break; /* n is completely factorable by twos, threes, and fives */ - n++; - } - return n; -} diff --git a/xbmc/contrib/kissfft/kiss_fft.h b/xbmc/contrib/kissfft/kiss_fft.h deleted file mode 100644 index 9db7f9285c..0000000000 --- a/xbmc/contrib/kissfft/kiss_fft.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2003-2010, Mark Borgerding. All rights reserved. - * This file is part of KISS FFT - https://github.com/mborgerding/kissfft - * - * SPDX-License-Identifier: BSD-3-Clause - * See COPYING file for more information. - */ - -#ifndef KISS_FFT_H -#define KISS_FFT_H - -#include <stdlib.h> -#include <stdio.h> -#include <math.h> -#include <string.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/* - ATTENTION! - If you would like a : - -- a utility that will handle the caching of fft objects - -- real-only (no imaginary time component ) FFT - -- a multi-dimensional FFT - -- a command-line utility to perform ffts - -- a command-line utility to perform fast-convolution filtering - - Then see kfc.h kiss_fftr.h kiss_fftnd.h fftutil.c kiss_fastfir.c - in the tools/ directory. -*/ - -#ifdef USE_SIMD -# include <xmmintrin.h> -# define kiss_fft_scalar __m128 -#define KISS_FFT_MALLOC(nbytes) _mm_malloc(nbytes,16) -#define KISS_FFT_FREE _mm_free -#else -#define KISS_FFT_MALLOC malloc -#define KISS_FFT_FREE free -#endif - - -#ifdef FIXED_POINT -#include <sys/types.h> -# if (FIXED_POINT == 32) -# define kiss_fft_scalar int32_t -# else -# define kiss_fft_scalar int16_t -# endif -#else -# ifndef kiss_fft_scalar -/* default is float */ -# define kiss_fft_scalar float -# endif -#endif - -typedef struct { - kiss_fft_scalar r; - kiss_fft_scalar i; -}kiss_fft_cpx; - -typedef struct kiss_fft_state* kiss_fft_cfg; - -/* - * kiss_fft_alloc - * - * Initialize a FFT (or IFFT) algorithm's cfg/state buffer. - * - * typical usage: kiss_fft_cfg mycfg=kiss_fft_alloc(1024,0,NULL,NULL); - * - * The return value from fft_alloc is a cfg buffer used internally - * by the fft routine or NULL. - * - * If lenmem is NULL, then kiss_fft_alloc will allocate a cfg buffer using malloc. - * The returned value should be free()d when done to avoid memory leaks. - * - * The state can be placed in a user supplied buffer 'mem': - * If lenmem is not NULL and mem is not NULL and *lenmem is large enough, - * then the function places the cfg in mem and the size used in *lenmem - * and returns mem. - * - * If lenmem is not NULL and ( mem is NULL or *lenmem is not large enough), - * then the function returns NULL and places the minimum cfg - * buffer size in *lenmem. - * */ - -kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem); - -/* - * kiss_fft(cfg,in_out_buf) - * - * Perform an FFT on a complex input buffer. - * for a forward FFT, - * fin should be f[0] , f[1] , ... ,f[nfft-1] - * fout will be F[0] , F[1] , ... ,F[nfft-1] - * Note that each element is complex and can be accessed like - f[k].r and f[k].i - * */ -void kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout); - -/* - A more generic version of the above function. It reads its input from every Nth sample. - * */ -void kiss_fft_stride(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int fin_stride); - -/* If kiss_fft_alloc allocated a buffer, it is one contiguous - buffer and can be simply free()d when no longer needed*/ -#define kiss_fft_free free - -/* - Cleans up some memory that gets managed internally. Not necessary to call, but it might clean up - your compiler output to call this before you exit. -*/ -void kiss_fft_cleanup(void); - - -/* - * Returns the smallest integer k, such that k>=n and k has only "fast" factors (2,3,5) - */ -int kiss_fft_next_fast_size(int n); - -/* for real ffts, we need an even size */ -#define kiss_fftr_next_fast_size_real(n) \ - (kiss_fft_next_fast_size( ((n)+1)>>1)<<1) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/xbmc/contrib/kissfft/kiss_fftr.c b/xbmc/contrib/kissfft/kiss_fftr.c deleted file mode 100644 index e9d3fe9906..0000000000 --- a/xbmc/contrib/kissfft/kiss_fftr.c +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (c) 2003-2004, Mark Borgerding. All rights reserved. - * This file is part of KISS FFT - https://github.com/mborgerding/kissfft - * - * SPDX-License-Identifier: BSD-3-Clause - * See COPYING file for more information. - */ - -#include "kiss_fftr.h" - -#include "_kiss_fft_guts.h" - -struct kiss_fftr_state{ - kiss_fft_cfg substate; - kiss_fft_cpx * tmpbuf; - kiss_fft_cpx * super_twiddles; -#ifdef USE_SIMD - void * pad; -#endif -}; - -kiss_fftr_cfg kiss_fftr_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem) -{ - int i; - kiss_fftr_cfg st = NULL; - size_t subsize, memneeded; - - if (nfft & 1) { - fprintf(stderr,"Real FFT optimization must be even.\n"); - return NULL; - } - nfft >>= 1; - - kiss_fft_alloc (nfft, inverse_fft, NULL, &subsize); - memneeded = sizeof(struct kiss_fftr_state) + subsize + sizeof(kiss_fft_cpx) * ( nfft * 3 / 2); - - if (lenmem == NULL) { - st = (kiss_fftr_cfg) KISS_FFT_MALLOC (memneeded); - } else { - if (*lenmem >= memneeded) - st = (kiss_fftr_cfg) mem; - *lenmem = memneeded; - } - if (!st) - return NULL; - - st->substate = (kiss_fft_cfg) (st + 1); /*just beyond kiss_fftr_state struct */ - st->tmpbuf = (kiss_fft_cpx *) (((char *) st->substate) + subsize); - st->super_twiddles = st->tmpbuf + nfft; - kiss_fft_alloc(nfft, inverse_fft, st->substate, &subsize); - - for (i = 0; i < nfft/2; ++i) { - double phase = - -3.14159265358979323846264338327 * ((double) (i+1) / nfft + .5); - if (inverse_fft) - phase *= -1; - kf_cexp (st->super_twiddles+i,phase); - } - return st; -} - -void kiss_fftr(kiss_fftr_cfg st,const kiss_fft_scalar *timedata,kiss_fft_cpx *freqdata) -{ - /* input buffer timedata is stored row-wise */ - int k,ncfft; - kiss_fft_cpx fpnk,fpk,f1k,f2k,tw,tdc; - - if ( st->substate->inverse) { - fprintf(stderr,"kiss fft usage error: improper alloc\n"); - exit(1); - } - - ncfft = st->substate->nfft; - - /*perform the parallel fft of two real signals packed in real,imag*/ - kiss_fft( st->substate , (const kiss_fft_cpx*)timedata, st->tmpbuf ); - /* The real part of the DC element of the frequency spectrum in st->tmpbuf - * contains the sum of the even-numbered elements of the input time sequence - * The imag part is the sum of the odd-numbered elements - * - * The sum of tdc.r and tdc.i is the sum of the input time sequence. - * yielding DC of input time sequence - * The difference of tdc.r - tdc.i is the sum of the input (dot product) [1,-1,1,-1... - * yielding Nyquist bin of input time sequence - */ - - tdc.r = st->tmpbuf[0].r; - tdc.i = st->tmpbuf[0].i; - C_FIXDIV(tdc,2); - CHECK_OVERFLOW_OP(tdc.r ,+, tdc.i); - CHECK_OVERFLOW_OP(tdc.r ,-, tdc.i); - freqdata[0].r = tdc.r + tdc.i; - freqdata[ncfft].r = tdc.r - tdc.i; -#ifdef USE_SIMD - freqdata[ncfft].i = freqdata[0].i = _mm_set1_ps(0); -#else - freqdata[ncfft].i = freqdata[0].i = 0; -#endif - - for ( k=1;k <= ncfft/2 ; ++k ) { - fpk = st->tmpbuf[k]; - fpnk.r = st->tmpbuf[ncfft-k].r; - fpnk.i = - st->tmpbuf[ncfft-k].i; - C_FIXDIV(fpk,2); - C_FIXDIV(fpnk,2); - - C_ADD( f1k, fpk , fpnk ); - C_SUB( f2k, fpk , fpnk ); - C_MUL( tw , f2k , st->super_twiddles[k-1]); - - freqdata[k].r = HALF_OF(f1k.r + tw.r); - freqdata[k].i = HALF_OF(f1k.i + tw.i); - freqdata[ncfft-k].r = HALF_OF(f1k.r - tw.r); - freqdata[ncfft-k].i = HALF_OF(tw.i - f1k.i); - } -} - -void kiss_fftri(kiss_fftr_cfg st,const kiss_fft_cpx *freqdata,kiss_fft_scalar *timedata) -{ - /* input buffer timedata is stored row-wise */ - int k, ncfft; - - if (st->substate->inverse == 0) { - fprintf (stderr, "kiss fft usage error: improper alloc\n"); - exit (1); - } - - ncfft = st->substate->nfft; - - st->tmpbuf[0].r = freqdata[0].r + freqdata[ncfft].r; - st->tmpbuf[0].i = freqdata[0].r - freqdata[ncfft].r; - C_FIXDIV(st->tmpbuf[0],2); - - for (k = 1; k <= ncfft / 2; ++k) { - kiss_fft_cpx fk, fnkc, fek, fok, tmp; - fk = freqdata[k]; - fnkc.r = freqdata[ncfft - k].r; - fnkc.i = -freqdata[ncfft - k].i; - C_FIXDIV( fk , 2 ); - C_FIXDIV( fnkc , 2 ); - - C_ADD (fek, fk, fnkc); - C_SUB (tmp, fk, fnkc); - C_MUL (fok, tmp, st->super_twiddles[k-1]); - C_ADD (st->tmpbuf[k], fek, fok); - C_SUB (st->tmpbuf[ncfft - k], fek, fok); -#ifdef USE_SIMD - st->tmpbuf[ncfft - k].i *= _mm_set1_ps(-1.0); -#else - st->tmpbuf[ncfft - k].i *= -1; -#endif - } - kiss_fft (st->substate, st->tmpbuf, (kiss_fft_cpx *) timedata); -} diff --git a/xbmc/contrib/kissfft/kiss_fftr.h b/xbmc/contrib/kissfft/kiss_fftr.h deleted file mode 100644 index f7586bee8d..0000000000 --- a/xbmc/contrib/kissfft/kiss_fftr.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2003-2004, Mark Borgerding. All rights reserved. - * This file is part of KISS FFT - https://github.com/mborgerding/kissfft - * - * SPDX-License-Identifier: BSD-3-Clause - * See COPYING file for more information. - */ - -#ifndef KISS_FTR_H -#define KISS_FTR_H - -#include "kiss_fft.h" -#ifdef __cplusplus -extern "C" { -#endif - - -/* - - Real optimized version can save about 45% cpu time vs. complex fft of a real seq. - - - - */ - -typedef struct kiss_fftr_state *kiss_fftr_cfg; - - -kiss_fftr_cfg kiss_fftr_alloc(int nfft,int inverse_fft,void * mem, size_t * lenmem); -/* - nfft must be even - - If you don't care to allocate space, use mem = lenmem = NULL -*/ - - -void kiss_fftr(kiss_fftr_cfg cfg,const kiss_fft_scalar *timedata,kiss_fft_cpx *freqdata); -/* - input timedata has nfft scalar points - output freqdata has nfft/2+1 complex points -*/ - -void kiss_fftri(kiss_fftr_cfg cfg,const kiss_fft_cpx *freqdata,kiss_fft_scalar *timedata); -/* - input freqdata has nfft/2+1 complex points - output timedata has nfft scalar points -*/ - -#define kiss_fftr_free free - -#ifdef __cplusplus -} -#endif -#endif diff --git a/xbmc/cores/AudioEngine/CMakeLists.txt b/xbmc/cores/AudioEngine/CMakeLists.txt index debf3dd203..5536d7b17c 100644 --- a/xbmc/cores/AudioEngine/CMakeLists.txt +++ b/xbmc/cores/AudioEngine/CMakeLists.txt @@ -48,7 +48,7 @@ set(HEADERS AEResampleFactory.h Utils/AEUtil.h Utils/PackerMAT.h) -if(TARGET ALSA::ALSA) +if(TARGET ${APP_NAME_LC}::Alsa) list(APPEND SOURCES Sinks/AESinkALSA.cpp Utils/AEELDParser.cpp) list(APPEND HEADERS Sinks/AESinkALSA.h diff --git a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp index 528822ddbb..317aacf998 100644 --- a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp +++ b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp @@ -1969,10 +1969,10 @@ bool CActiveAE::RunStages() // TrueHD is very jumpy, meaning the frames don't come in equidistantly. They are only smoothed // at the end when the IEC packing happens. Therefore adjust earlier. - const bool ignoreWL = + const bool isTrueHDPassthrough = (m_mode == MODE_RAW && m_sinkFormat.m_streamInfo.m_type == CAEStreamInfo::STREAM_TYPE_TRUEHD); - if ((m_stats.GetWaterLevel() < (MAX_WATER_LEVEL + 0.0001f) || ignoreWL) && + if ((m_stats.GetWaterLevel() < (MAX_WATER_LEVEL + 0.0001f) || isTrueHDPassthrough) && (m_mode != MODE_TRANSCODE || (m_encoderBuffers && !m_encoderBuffers->m_freeSamples.empty()))) { // calculate sync error @@ -1994,6 +1994,12 @@ bool CActiveAE::RunStages() double playingPts = pts - delay; double maxError = ((*it)->m_syncState == CAESyncInfo::SYNC_INSYNC) ? 1000 : 5000; double error = playingPts - (*it)->m_pClock->GetClock(); + + // underestimate error for TrueHD passthrough + // oscillations should be less than frametime 40ms to avoid unnecessary a/v sync corrections + if (isTrueHDPassthrough) + error *= 0.45; + if (error > maxError) { CLog::Log(LOGWARNING, "ActiveAE - large audio sync error: {:f}", error); diff --git a/xbmc/cores/AudioEngine/Utils/PackerMAT.cpp b/xbmc/cores/AudioEngine/Utils/PackerMAT.cpp index 29ee54ea92..024fdbc55b 100644 --- a/xbmc/cores/AudioEngine/Utils/PackerMAT.cpp +++ b/xbmc/cores/AudioEngine/Utils/PackerMAT.cpp @@ -47,17 +47,16 @@ CPackerMAT::CPackerMAT() m_buffer.reserve(MAT_BUFFER_SIZE); } +// On a high level, a MAT frame consists of a sequence of padded TrueHD frames +// The size of the padded frame can be determined from the frame time/sequence code in the frame header, +// since it varies to accommodate spikes in bitrate. +// In average all frames are always padded to 2560 bytes, so that 24 frames fit in one MAT frame, however +// due to bitrate spikes single sync frames have been observed to use up to twice that size, in which +// case they'll be preceded by smaller frames to keep the average bitrate constant. +// A constant padding to 2560 bytes can work (this is how the ffmpeg spdifenc module works), however +// high-bitrate streams can overshoot this size and therefor require proper handling of dynamic padding. bool CPackerMAT::PackTrueHD(const uint8_t* data, int size) { - // On a high level, a MAT frame consists of a sequence of padded TrueHD frames - // The size of the padded frame can be determined from the frame time/sequence code in the frame header, - // since it varies to accommodate spikes in bitrate. - // In average all frames are always padded to 2560 bytes, so that 24 frames fit in one MAT frame, however - // due to bitrate spikes single sync frames have been observed to use up to twice that size, in which - // case they'll be preceded by smaller frames to keep the average bitrate constant. - // A constant padding to 2560 bytes can work (this is how the ffmpeg spdifenc module works), however - // high-bitrate streams can overshoot this size and therefor require proper handling of dynamic padding. - TrueHDMajorSyncInfo info; // get the ratebits and output timing from the sync frame @@ -112,7 +111,7 @@ bool CPackerMAT::PackTrueHD(const uint8_t* data, int size) // until the next major sync frame if (m_state.padding > MAT_BUFFER_SIZE * 5) { - CLog::LogF(LOGINFO, "seek detected, re-initializing MAT packer state"); + CLog::Log(LOGINFO, "CPackerMAT::PackTrueHD: seek detected, re-initializing MAT packer state"); m_state = {}; m_state.init = true; m_buffer.clear(); diff --git a/xbmc/cores/RetroPlayer/buffers/CMakeLists.txt b/xbmc/cores/RetroPlayer/buffers/CMakeLists.txt index 91413f7527..ef66479c46 100644 --- a/xbmc/cores/RetroPlayer/buffers/CMakeLists.txt +++ b/xbmc/cores/RetroPlayer/buffers/CMakeLists.txt @@ -24,7 +24,7 @@ if(TARGET OpenGL::GL) RenderBufferPoolOpenGL.h) endif() -if(("gbm" IN_LIST CORE_PLATFORM_NAME_LC OR "wayland" IN_LIST CORE_PLATFORM_NAME_LC) AND TARGET EGL::EGL) +if(("gbm" IN_LIST CORE_PLATFORM_NAME_LC OR "wayland" IN_LIST CORE_PLATFORM_NAME_LC) AND TARGET ${APP_NAME_LC}::EGL) list(APPEND SOURCES RenderBufferDMA.cpp RenderBufferPoolDMA.cpp) list(APPEND HEADERS RenderBufferDMA.h diff --git a/xbmc/cores/RetroPlayer/rendering/VideoRenderers/CMakeLists.txt b/xbmc/cores/RetroPlayer/rendering/VideoRenderers/CMakeLists.txt index 4a2a65c7e2..5680b8ec9e 100644 --- a/xbmc/cores/RetroPlayer/rendering/VideoRenderers/CMakeLists.txt +++ b/xbmc/cores/RetroPlayer/rendering/VideoRenderers/CMakeLists.txt @@ -18,7 +18,7 @@ if(TARGET OpenGL::GL) list(APPEND HEADERS RPRendererOpenGL.h) endif() -if(("gbm" IN_LIST CORE_PLATFORM_NAME_LC OR "wayland" IN_LIST CORE_PLATFORM_NAME_LC) AND TARGET EGL::EGL) +if(("gbm" IN_LIST CORE_PLATFORM_NAME_LC OR "wayland" IN_LIST CORE_PLATFORM_NAME_LC) AND TARGET ${APP_NAME_LC}::EGL) list(APPEND SOURCES RPRendererDMA.cpp) list(APPEND HEADERS RPRendererDMA.h) endif() diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp index ce6de6f20d..2d9e3279f0 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp @@ -28,7 +28,6 @@ #include "settings/SettingsComponent.h" #include "settings/lib/Setting.h" #include "utils/BitstreamConverter.h" -#include "utils/BitstreamWriter.h" #include "utils/CPUInfo.h" #include "utils/StringUtils.h" #include "utils/TimeUtils.h" @@ -58,6 +57,11 @@ #include <androidjni/SurfaceTexture.h> #include <androidjni/UUID.h> +extern "C" +{ +#include <libavutil/intreadwrite.h> +} + using namespace KODI::MESSAGING; enum MEDIACODEC_STATES @@ -632,10 +636,10 @@ bool CDVDVideoCodecAndroidMediaCodec::Open(CDVDStreamInfo &hints, CDVDCodecOptio offset += sizeof(annexL_hdr1); memcpy(m_hints.extradata.GetData() + offset, hints.extradata.GetData(), 4); offset += 4; - BS_WL32(buf, hints.height); + AV_WL32(buf, hints.height); memcpy(m_hints.extradata.GetData() + offset, buf, 4); offset += 4; - BS_WL32(buf, hints.width); + AV_WL32(buf, hints.width); memcpy(m_hints.extradata.GetData() + offset, buf, 4); offset += 4; memcpy(m_hints.extradata.GetData() + offset, annexL_hdr2, sizeof(annexL_hdr2)); diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/CMakeLists.txt b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/CMakeLists.txt index 8598052b41..bd4d6333ee 100644 --- a/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/CMakeLists.txt +++ b/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/CMakeLists.txt @@ -14,7 +14,7 @@ if(VAAPI_FOUND) list(APPEND SOURCES RendererVAAPIGLES.cpp) list(APPEND HEADERS RendererVAAPIGLES.h) endif() - if(TARGET EGL::EGL) + if(TARGET ${APP_NAME_LC}::EGL) list(APPEND SOURCES VaapiEGL.cpp) list(APPEND HEADERS VaapiEGL.h) endif() diff --git a/xbmc/dialogs/GUIDialogMediaFilter.cpp b/xbmc/dialogs/GUIDialogMediaFilter.cpp index 55b1013967..df904cb354 100644 --- a/xbmc/dialogs/GUIDialogMediaFilter.cpp +++ b/xbmc/dialogs/GUIDialogMediaFilter.cpp @@ -31,6 +31,8 @@ #include "video/VideoDatabase.h" #include "video/VideoDbUrl.h" +using namespace KODI; + #define CONTROL_HEADING 2 #define CONTROL_OKAY_BUTTON 28 @@ -186,7 +188,8 @@ bool CGUIDialogMediaFilter::OnMessage(CGUIMessage& message) return CGUIDialogSettingsManualBase::OnMessage(message); } -void CGUIDialogMediaFilter::ShowAndEditMediaFilter(const std::string &path, CSmartPlaylist &filter) +void CGUIDialogMediaFilter::ShowAndEditMediaFilter(const std::string& path, + PLAYLIST::CSmartPlaylist& filter) { CGUIDialogMediaFilter *dialog = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogMediaFilter>(WINDOW_DIALOG_MEDIA_FILTER); if (dialog == NULL) @@ -411,7 +414,7 @@ void CGUIDialogMediaFilter::InitializeSettings() { if (rule->m_field == filter.field) { - filter.rule = static_cast<CSmartPlaylistRule*>(rule.get()); + filter.rule = static_cast<PLAYLIST::CSmartPlaylistRule*>(rule.get()); handledRules++; break; } @@ -644,7 +647,7 @@ int CGUIDialogMediaFilter::GetItems(const Filter &filter, std::vector<std::strin CFileItemList selectItems; // remove the rule for the field of the filter we want to retrieve items for - CSmartPlaylist tmpFilter = *m_filter; + PLAYLIST::CSmartPlaylist tmpFilter = *m_filter; for (CDatabaseQueryRules::iterator rule = tmpFilter.m_ruleCombination.m_rules.begin(); rule != tmpFilter.m_ruleCombination.m_rules.end(); ++rule) { @@ -730,14 +733,17 @@ int CGUIDialogMediaFilter::GetItems(const Filter &filter, std::vector<std::strin return items.size(); } -CSmartPlaylistRule* CGUIDialogMediaFilter::AddRule(Field field, CDatabaseQueryRule::SEARCH_OPERATOR ruleOperator /* = CDatabaseQueryRule::OPERATOR_CONTAINS */) +PLAYLIST::CSmartPlaylistRule* CGUIDialogMediaFilter::AddRule( + Field field, + CDatabaseQueryRule::SEARCH_OPERATOR ruleOperator /* = CDatabaseQueryRule::OPERATOR_CONTAINS */) { - CSmartPlaylistRule rule; + PLAYLIST::CSmartPlaylistRule rule; rule.m_field = field; rule.m_operator = ruleOperator; m_filter->m_ruleCombination.AddRule(rule); - return (CSmartPlaylistRule *)m_filter->m_ruleCombination.m_rules.back().get(); + return static_cast<PLAYLIST::CSmartPlaylistRule*>( + m_filter->m_ruleCombination.m_rules.back().get()); } void CGUIDialogMediaFilter::DeleteRule(Field field) diff --git a/xbmc/dialogs/GUIDialogMediaFilter.h b/xbmc/dialogs/GUIDialogMediaFilter.h index 893f1c20c3..8bf931bdd7 100644 --- a/xbmc/dialogs/GUIDialogMediaFilter.h +++ b/xbmc/dialogs/GUIDialogMediaFilter.h @@ -21,8 +21,11 @@ class CDbUrl; class CSetting; +namespace KODI::PLAYLIST +{ class CSmartPlaylist; class CSmartPlaylistRule; +} // namespace KODI::PLAYLIST struct StringSettingOption; class CGUIDialogMediaFilter : public CGUIDialogSettingsManualBase @@ -34,7 +37,8 @@ public: // specializations of CGUIControl bool OnMessage(CGUIMessage &message) override; - static void ShowAndEditMediaFilter(const std::string &path, CSmartPlaylist &filter); + static void ShowAndEditMediaFilter(const std::string& path, + KODI::PLAYLIST::CSmartPlaylist& filter); struct Filter { @@ -46,7 +50,7 @@ public: std::string controlFormat; CDatabaseQueryRule::SEARCH_OPERATOR ruleOperator; std::shared_ptr<CSetting> setting = nullptr; - CSmartPlaylistRule* rule = nullptr; + KODI::PLAYLIST::CSmartPlaylistRule* rule = nullptr; void* data = nullptr; }; @@ -77,7 +81,9 @@ protected: void GetRange(const Filter &filter, float &min, float &interval, float &max); bool GetMinMax(const std::string &table, const std::string &field, int &min, int &max, const CDatabase::Filter &filter = CDatabase::Filter()); - CSmartPlaylistRule* AddRule(Field field, CDatabaseQueryRule::SEARCH_OPERATOR ruleOperator = CDatabaseQueryRule::OPERATOR_CONTAINS); + KODI::PLAYLIST::CSmartPlaylistRule* AddRule( + Field field, + CDatabaseQueryRule::SEARCH_OPERATOR ruleOperator = CDatabaseQueryRule::OPERATOR_CONTAINS); void DeleteRule(Field field); static void GetStringListOptions(const std::shared_ptr<const CSetting>& setting, @@ -87,6 +93,6 @@ protected: CDbUrl* m_dbUrl; std::string m_mediaType; - CSmartPlaylist *m_filter; + KODI::PLAYLIST::CSmartPlaylist* m_filter; std::map<std::string, Filter> m_filters; }; diff --git a/xbmc/dialogs/GUIDialogSmartPlaylistEditor.cpp b/xbmc/dialogs/GUIDialogSmartPlaylistEditor.cpp index 24a0675c40..ddfd0d9d0a 100644 --- a/xbmc/dialogs/GUIDialogSmartPlaylistEditor.cpp +++ b/xbmc/dialogs/GUIDialogSmartPlaylistEditor.cpp @@ -31,6 +31,8 @@ #include <utility> +using namespace KODI; + #define CONTROL_HEADING 2 #define CONTROL_RULE_LIST 10 #define CONTROL_NAME 12 @@ -209,7 +211,8 @@ void CGUIDialogSmartPlaylistEditor::OnRuleList(int item) OnRuleAdd(); else { - CSmartPlaylistRule rule = *std::static_pointer_cast<CSmartPlaylistRule>(m_playlist.m_ruleCombination.m_rules[item]); + auto rule = *std::static_pointer_cast<PLAYLIST::CSmartPlaylistRule>( + m_playlist.m_ruleCombination.m_rules[item]); if (CGUIDialogSmartPlaylistRule::EditRule(rule, m_playlist.GetType())) *m_playlist.m_ruleCombination.m_rules[item] = rule; } @@ -268,10 +271,11 @@ void CGUIDialogSmartPlaylistEditor::OnCancel() void CGUIDialogSmartPlaylistEditor::OnMatch() { // toggle between AND and OR setting - if (m_playlist.m_ruleCombination.GetType() == CSmartPlaylistRuleCombination::CombinationOr) - m_playlist.m_ruleCombination.SetType(CSmartPlaylistRuleCombination::CombinationAnd); + if (m_playlist.m_ruleCombination.GetType() == + PLAYLIST::CSmartPlaylistRuleCombination::CombinationOr) + m_playlist.m_ruleCombination.SetType(PLAYLIST::CSmartPlaylistRuleCombination::CombinationAnd); else - m_playlist.m_ruleCombination.SetType(CSmartPlaylistRuleCombination::CombinationOr); + m_playlist.m_ruleCombination.SetType(PLAYLIST::CSmartPlaylistRuleCombination::CombinationOr); UpdateButtons(); } @@ -327,12 +331,12 @@ void CGUIDialogSmartPlaylistEditor::OnType() m_playlist.SetType(ConvertType(allowedTypes[newSelected])); // Remove any invalid grouping left over when changing the type - Field currentGroup = CSmartPlaylistRule::TranslateGroup(m_playlist.GetGroup().c_str()); + Field currentGroup = PLAYLIST::CSmartPlaylistRule::TranslateGroup(m_playlist.GetGroup().c_str()); if (currentGroup != FieldNone && currentGroup != FieldUnknown) { - std::vector<Field> groups = CSmartPlaylistRule::GetGroups(m_playlist.GetType()); + std::vector<Field> groups = PLAYLIST::CSmartPlaylistRule::GetGroups(m_playlist.GetType()); if (std::find(groups.begin(), groups.end(), currentGroup) == groups.end()) - m_playlist.SetGroup(CSmartPlaylistRule::TranslateGroup(FieldUnknown)); + m_playlist.SetGroup(PLAYLIST::CSmartPlaylistRule::TranslateGroup(FieldUnknown)); } UpdateButtons(); @@ -340,7 +344,7 @@ void CGUIDialogSmartPlaylistEditor::OnType() void CGUIDialogSmartPlaylistEditor::OnOrder() { - std::vector<SortBy> orders = CSmartPlaylistRule::GetOrders(m_playlist.GetType()); + std::vector<SortBy> orders = PLAYLIST::CSmartPlaylistRule::GetOrders(m_playlist.GetType()); CGUIDialogSelect* dialog = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogSelect>(WINDOW_DIALOG_SELECT); dialog->Reset(); for (auto order: orders) @@ -366,22 +370,22 @@ void CGUIDialogSmartPlaylistEditor::OnOrderDirection() void CGUIDialogSmartPlaylistEditor::OnGroupBy() { - std::vector<Field> groups = CSmartPlaylistRule::GetGroups(m_playlist.GetType()); - Field currentGroup = CSmartPlaylistRule::TranslateGroup(m_playlist.GetGroup().c_str()); + std::vector<Field> groups = PLAYLIST::CSmartPlaylistRule::GetGroups(m_playlist.GetType()); + Field currentGroup = PLAYLIST::CSmartPlaylistRule::TranslateGroup(m_playlist.GetGroup().c_str()); CGUIDialogSelect* dialog = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogSelect>(WINDOW_DIALOG_SELECT); dialog->Reset(); for (auto group : groups) - dialog->Add(CSmartPlaylistRule::GetLocalizedGroup(group)); + dialog->Add(PLAYLIST::CSmartPlaylistRule::GetLocalizedGroup(group)); dialog->SetHeading(CVariant{ 21458 }); - dialog->SetSelected(CSmartPlaylistRule::GetLocalizedGroup(currentGroup)); + dialog->SetSelected(PLAYLIST::CSmartPlaylistRule::GetLocalizedGroup(currentGroup)); dialog->Open(); int newSelected = dialog->GetSelectedItem(); // check if selection has changed if (!dialog->IsConfirmed() || newSelected < 0 || groups[newSelected] == currentGroup) return; - m_playlist.SetGroup(CSmartPlaylistRule::TranslateGroup(groups[newSelected])); + m_playlist.SetGroup(PLAYLIST::CSmartPlaylistRule::TranslateGroup(groups[newSelected])); - if (m_playlist.IsGroupMixed() && !CSmartPlaylistRule::CanGroupMix(currentGroup)) + if (m_playlist.IsGroupMixed() && !PLAYLIST::CSmartPlaylistRule::CanGroupMix(currentGroup)) m_playlist.SetGroupMixed(false); UpdateButtons(); @@ -407,7 +411,8 @@ void CGUIDialogSmartPlaylistEditor::UpdateButtons() UpdateRuleControlButtons(); - if (m_playlist.m_ruleCombination.GetType() == CSmartPlaylistRuleCombination::CombinationOr) + if (m_playlist.m_ruleCombination.GetType() == + PLAYLIST::CSmartPlaylistRuleCombination::CombinationOr) SET_CONTROL_LABEL2(CONTROL_MATCH, g_localizeStrings.Get(21426)); // one or more of the rules else SET_CONTROL_LABEL2(CONTROL_MATCH, g_localizeStrings.Get(21425)); // all of the rules @@ -424,7 +429,8 @@ void CGUIDialogSmartPlaylistEditor::UpdateButtons() for (const auto& rule: m_playlist.m_ruleCombination.m_rules) { CFileItemPtr item(new CFileItem("", false)); - item->SetLabel(std::static_pointer_cast<CSmartPlaylistRule>(rule)->GetLocalizedRule()); + item->SetLabel( + std::static_pointer_cast<PLAYLIST::CSmartPlaylistRule>(rule)->GetLocalizedRule()); m_ruleLabels->Add(item); } CFileItemPtr item(new CFileItem("", false)); @@ -447,9 +453,10 @@ void CGUIDialogSmartPlaylistEditor::UpdateButtons() SET_CONTROL_LABEL2(CONTROL_TYPE, GetLocalizedType(ConvertType(m_playlist.GetType()))); // setup groups - std::vector<Field> groups = CSmartPlaylistRule::GetGroups(m_playlist.GetType()); - Field currentGroup = CSmartPlaylistRule::TranslateGroup(m_playlist.GetGroup().c_str()); - SET_CONTROL_LABEL2(CONTROL_GROUP_BY, CSmartPlaylistRule::GetLocalizedGroup(currentGroup)); + std::vector<Field> groups = PLAYLIST::CSmartPlaylistRule::GetGroups(m_playlist.GetType()); + Field currentGroup = PLAYLIST::CSmartPlaylistRule::TranslateGroup(m_playlist.GetGroup().c_str()); + SET_CONTROL_LABEL2(CONTROL_GROUP_BY, + PLAYLIST::CSmartPlaylistRule::GetLocalizedGroup(currentGroup)); if (m_playlist.IsGroupMixed()) CONTROL_SELECT(CONTROL_GROUP_MIXED); else @@ -458,7 +465,7 @@ void CGUIDialogSmartPlaylistEditor::UpdateButtons() // disable the group controls if there's no group // or only one group which can't be mixed if (groups.empty() || - (groups.size() == 1 && !CSmartPlaylistRule::CanGroupMix(groups[0]))) + (groups.size() == 1 && !PLAYLIST::CSmartPlaylistRule::CanGroupMix(groups[0]))) { CONTROL_DISABLE(CONTROL_GROUP_BY); CONTROL_DISABLE(CONTROL_GROUP_MIXED); @@ -466,7 +473,8 @@ void CGUIDialogSmartPlaylistEditor::UpdateButtons() else { CONTROL_ENABLE(CONTROL_GROUP_BY); - CONTROL_ENABLE_ON_CONDITION(CONTROL_GROUP_MIXED, CSmartPlaylistRule::CanGroupMix(currentGroup)); + CONTROL_ENABLE_ON_CONDITION(CONTROL_GROUP_MIXED, + PLAYLIST::CSmartPlaylistRule::CanGroupMix(currentGroup)); } } @@ -601,7 +609,7 @@ void CGUIDialogSmartPlaylistEditor::OnRuleRemove(int item) void CGUIDialogSmartPlaylistEditor::OnRuleAdd() { - CSmartPlaylistRule rule; + PLAYLIST::CSmartPlaylistRule rule; if (CGUIDialogSmartPlaylistRule::EditRule(rule,m_playlist.GetType())) m_playlist.m_ruleCombination.AddRule(rule); UpdateButtons(); @@ -613,7 +621,7 @@ bool CGUIDialogSmartPlaylistEditor::NewPlaylist(const std::string &type) if (!editor) return false; editor->m_path = ""; - editor->m_playlist = CSmartPlaylist(); + editor->m_playlist = PLAYLIST::CSmartPlaylist(); editor->m_mode = type; editor->Initialize(); editor->Open(); @@ -631,7 +639,7 @@ bool CGUIDialogSmartPlaylistEditor::EditPlaylist(const std::string &path, const if (URIUtils::PathEquals(path, CServiceBroker::GetSettingsComponent()->GetProfileManager()->GetUserDataItem("PartyMode-Video.xsp"))) editor->m_mode = "partyvideo"; - CSmartPlaylist playlist; + PLAYLIST::CSmartPlaylist playlist; bool loaded(playlist.Load(path)); if (!loaded) { // failed to load diff --git a/xbmc/dialogs/GUIDialogSmartPlaylistEditor.h b/xbmc/dialogs/GUIDialogSmartPlaylistEditor.h index c754f91cc6..3c0c889dcb 100644 --- a/xbmc/dialogs/GUIDialogSmartPlaylistEditor.h +++ b/xbmc/dialogs/GUIDialogSmartPlaylistEditor.h @@ -53,7 +53,7 @@ protected: std::string ConvertType(PLAYLIST_TYPE type); std::string GetLocalizedType(PLAYLIST_TYPE type); - CSmartPlaylist m_playlist; + KODI::PLAYLIST::CSmartPlaylist m_playlist; // our list of rules for display purposes CFileItemList* m_ruleLabels; diff --git a/xbmc/dialogs/GUIDialogSmartPlaylistRule.cpp b/xbmc/dialogs/GUIDialogSmartPlaylistRule.cpp index 9040f48340..396bea02cf 100644 --- a/xbmc/dialogs/GUIDialogSmartPlaylistRule.cpp +++ b/xbmc/dialogs/GUIDialogSmartPlaylistRule.cpp @@ -30,6 +30,8 @@ #include <utility> +using namespace KODI; + #define CONTROL_FIELD 15 #define CONTROL_OPERATOR 16 #define CONTROL_VALUE 17 @@ -101,7 +103,7 @@ void CGUIDialogSmartPlaylistRule::OnBrowse() videodatabase.Open(); std::string basePath; - if (CSmartPlaylist::IsMusicType(m_type)) + if (PLAYLIST::CSmartPlaylist::IsMusicType(m_type)) basePath = "musicdb://"; else basePath = "videodb://"; @@ -177,7 +179,7 @@ void CGUIDialogSmartPlaylistRule::OnBrowse() } else if (m_rule.m_field == FieldArtist || m_rule.m_field == FieldAlbumArtist) { - if (CSmartPlaylist::IsMusicType(m_type)) + if (PLAYLIST::CSmartPlaylist::IsMusicType(m_type)) database.GetArtistsNav("musicdb://artists/", items, m_rule.m_field == FieldAlbumArtist, -1); if (m_type == "musicvideos" || m_type == "mixed") @@ -190,7 +192,7 @@ void CGUIDialogSmartPlaylistRule::OnBrowse() } else if (m_rule.m_field == FieldAlbum) { - if (CSmartPlaylist::IsMusicType(m_type)) + if (PLAYLIST::CSmartPlaylist::IsMusicType(m_type)) database.GetAlbumsNav("musicdb://albums/", items); if (m_type == "musicvideos" || m_type == "mixed") @@ -208,9 +210,9 @@ void CGUIDialogSmartPlaylistRule::OnBrowse() } else if (m_rule.m_field == FieldYear) { - if (CSmartPlaylist::IsMusicType(m_type)) + if (PLAYLIST::CSmartPlaylist::IsMusicType(m_type)) database.GetYearsNav("musicdb://years/", items); - if (CSmartPlaylist::IsVideoType(m_type)) + if (PLAYLIST::CSmartPlaylist::IsVideoType(m_type)) { CFileItemList items2; videodatabase.GetYearsNav(basePath + "years/", items2, type); @@ -278,9 +280,9 @@ void CGUIDialogSmartPlaylistRule::OnBrowse() // Note: This can cause infinite loops (playlist that refers to the same playlist) but I don't // think there's any decent way to deal with this, as the infinite loop may be an arbitrary // number of playlists deep, eg playlist1 -> playlist2 -> playlist3 ... -> playlistn -> playlist1 - if (CSmartPlaylist::IsVideoType(m_type)) + if (PLAYLIST::CSmartPlaylist::IsVideoType(m_type)) XFILE::CDirectory::GetDirectory("special://videoplaylists/", items, ".xsp", XFILE::DIR_FLAG_NO_FILE_DIRS); - if (CSmartPlaylist::IsMusicType(m_type)) + if (PLAYLIST::CSmartPlaylist::IsMusicType(m_type)) { CFileItemList items2; XFILE::CDirectory::GetDirectory("special://musicplaylists/", items2, ".xsp", XFILE::DIR_FLAG_NO_FILE_DIRS); @@ -290,13 +292,13 @@ void CGUIDialogSmartPlaylistRule::OnBrowse() for (int i = 0; i < items.Size(); i++) { CFileItemPtr item = items[i]; - CSmartPlaylist playlist; + PLAYLIST::CSmartPlaylist playlist; // don't list unloadable smartplaylists or any referenceable smartplaylists // which do not match the type of the current smartplaylist if (!playlist.Load(item->GetPath()) || - (m_rule.m_field == FieldPlaylist && - (!CSmartPlaylist::CheckTypeCompatibility(m_type, playlist.GetType()) || - (!playlist.GetGroup().empty() || playlist.IsGroupMixed())))) + (m_rule.m_field == FieldPlaylist && + (!PLAYLIST::CSmartPlaylist::CheckTypeCompatibility(m_type, playlist.GetType()) || + (!playlist.GetGroup().empty() || playlist.IsGroupMixed())))) { items.Remove(i); i -= 1; @@ -313,7 +315,7 @@ void CGUIDialogSmartPlaylistRule::OnBrowse() VECSOURCES sources; if (m_type == "songs" || m_type == "mixed") sources = *CMediaSourceSettings::GetInstance().GetSources("music"); - if (CSmartPlaylist::IsVideoType(m_type)) + if (PLAYLIST::CSmartPlaylist::IsVideoType(m_type)) { VECSOURCES sources2 = *CMediaSourceSettings::GetInstance().GetSources("video"); sources.insert(sources.end(),sources2.begin(),sources2.end()); @@ -382,10 +384,11 @@ void CGUIDialogSmartPlaylistRule::OnBrowse() std::pair<std::string, int> OperatorLabel(CDatabaseQueryRule::SEARCH_OPERATOR op) { - return std::make_pair(CSmartPlaylistRule::GetLocalizedOperator(op), op); + return std::make_pair(PLAYLIST::CSmartPlaylistRule::GetLocalizedOperator(op), op); } -std::vector<std::pair<std::string, int>> CGUIDialogSmartPlaylistRule::GetValidOperators(const CSmartPlaylistRule& rule) +std::vector<std::pair<std::string, int>> CGUIDialogSmartPlaylistRule::GetValidOperators( + const PLAYLIST::CSmartPlaylistRule& rule) { std::vector< std::pair<std::string, int> > labels; switch (rule.GetFieldType(rule.m_field)) @@ -446,14 +449,14 @@ void CGUIDialogSmartPlaylistRule::OnCancel() void CGUIDialogSmartPlaylistRule::OnField() { - const auto fields = CSmartPlaylistRule::GetFields(m_type); + const auto fields = PLAYLIST::CSmartPlaylistRule::GetFields(m_type); CGUIDialogSelect* dialog = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogSelect>(WINDOW_DIALOG_SELECT); dialog->Reset(); dialog->SetHeading(CVariant{20427}); int selected = -1; for (auto field = fields.begin(); field != fields.end(); field++) { - dialog->Add(CSmartPlaylistRule::GetLocalizedField(*field)); + dialog->Add(PLAYLIST::CSmartPlaylistRule::GetLocalizedField(*field)); if (*field == m_rule.m_field) selected = std::distance(fields.begin(), field); } @@ -487,7 +490,7 @@ void CGUIDialogSmartPlaylistRule::OnOperator() dialog->SetHeading(CVariant{ 16023 }); for (auto label : labels) dialog->Add(std::get<0>(label)); - dialog->SetSelected(CSmartPlaylistRule::GetLocalizedOperator(m_rule.m_operator)); + dialog->SetSelected(PLAYLIST::CSmartPlaylistRule::GetLocalizedOperator(m_rule.m_operator)); dialog->Open(); int newSelected = dialog->GetSelectedItem(); // check if selection has changed @@ -501,11 +504,11 @@ void CGUIDialogSmartPlaylistRule::OnOperator() void CGUIDialogSmartPlaylistRule::UpdateButtons() { if (m_rule.m_field == 0) - m_rule.m_field = CSmartPlaylistRule::GetFields(m_type)[0]; - SET_CONTROL_LABEL(CONTROL_FIELD, CSmartPlaylistRule::GetLocalizedField(m_rule.m_field)); + m_rule.m_field = PLAYLIST::CSmartPlaylistRule::GetFields(m_type)[0]; + SET_CONTROL_LABEL(CONTROL_FIELD, PLAYLIST::CSmartPlaylistRule::GetLocalizedField(m_rule.m_field)); CONTROL_ENABLE(CONTROL_VALUE); - if (CSmartPlaylistRule::IsFieldBrowseable(m_rule.m_field)) + if (PLAYLIST::CSmartPlaylistRule::IsFieldBrowseable(m_rule.m_field)) CONTROL_ENABLE(CONTROL_BROWSE); else CONTROL_DISABLE(CONTROL_BROWSE); @@ -549,7 +552,7 @@ void CGUIDialogSmartPlaylistRule::OnInitWindow() CGUIEditControl *editControl = dynamic_cast<CGUIEditControl*>(GetControl(CONTROL_VALUE)); if (editControl != NULL) - editControl->SetInputValidation(CSmartPlaylistRule::Validate, &m_rule); + editControl->SetInputValidation(PLAYLIST::CSmartPlaylistRule::Validate, &m_rule); } void CGUIDialogSmartPlaylistRule::OnDeinitWindow(int nextWindowID) @@ -562,7 +565,8 @@ void CGUIDialogSmartPlaylistRule::OnDeinitWindow(int nextWindowID) SendMessage(GUI_MSG_LABEL_RESET, CONTROL_OPERATOR); } -bool CGUIDialogSmartPlaylistRule::EditRule(CSmartPlaylistRule &rule, const std::string& type) +bool CGUIDialogSmartPlaylistRule::EditRule(PLAYLIST::CSmartPlaylistRule& rule, + const std::string& type) { CGUIDialogSmartPlaylistRule *editor = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogSmartPlaylistRule>(WINDOW_DIALOG_SMART_PLAYLIST_RULE); if (!editor) return false; diff --git a/xbmc/dialogs/GUIDialogSmartPlaylistRule.h b/xbmc/dialogs/GUIDialogSmartPlaylistRule.h index 23ca11d0af..75127d33fa 100644 --- a/xbmc/dialogs/GUIDialogSmartPlaylistRule.h +++ b/xbmc/dialogs/GUIDialogSmartPlaylistRule.h @@ -22,7 +22,7 @@ public: void OnInitWindow() override; void OnDeinitWindow(int nextWindowID) override; - static bool EditRule(CSmartPlaylistRule &rule, const std::string& type="songs"); + static bool EditRule(KODI::PLAYLIST::CSmartPlaylistRule& rule, const std::string& type = "songs"); protected: void OnField(); @@ -31,8 +31,9 @@ protected: void OnCancel(); void UpdateButtons(); void OnBrowse(); - std::vector< std::pair<std::string, int> > GetValidOperators(const CSmartPlaylistRule& rule); - CSmartPlaylistRule m_rule; + std::vector<std::pair<std::string, int>> GetValidOperators( + const KODI::PLAYLIST::CSmartPlaylistRule& rule); + KODI::PLAYLIST::CSmartPlaylistRule m_rule; bool m_cancelled; std::string m_type; }; diff --git a/xbmc/filesystem/LibraryDirectory.cpp b/xbmc/filesystem/LibraryDirectory.cpp index ec5a16bfc0..6bd3146a3c 100644 --- a/xbmc/filesystem/LibraryDirectory.cpp +++ b/xbmc/filesystem/LibraryDirectory.cpp @@ -24,6 +24,7 @@ #include "utils/XMLUtils.h" #include "utils/log.h" +using namespace KODI; using namespace XFILE; CLibraryDirectory::CLibraryDirectory(void) = default; @@ -44,7 +45,7 @@ bool CLibraryDirectory::GetDirectory(const CURL& url, CFileItemList &items) std::string type = XMLUtils::GetAttribute(node, "type"); if (type == "filter") { - CSmartPlaylist playlist; + PLAYLIST::CSmartPlaylist playlist; std::string type, label; XMLUtils::GetString(node, "content", type); if (type.empty()) diff --git a/xbmc/filesystem/PlaylistDirectory.cpp b/xbmc/filesystem/PlaylistDirectory.cpp index f656c77dab..8d77552ca4 100644 --- a/xbmc/filesystem/PlaylistDirectory.cpp +++ b/xbmc/filesystem/PlaylistDirectory.cpp @@ -15,6 +15,7 @@ #include "URL.h" #include "playlists/PlayList.h" +using namespace KODI; using namespace XFILE; CPlaylistDirectory::CPlaylistDirectory() = default; @@ -23,13 +24,13 @@ CPlaylistDirectory::~CPlaylistDirectory() = default; bool CPlaylistDirectory::GetDirectory(const CURL& url, CFileItemList &items) { - PLAYLIST::Id playlistId = PLAYLIST::TYPE_NONE; + PLAYLIST::Id playlistId = PLAYLIST::Id::TYPE_NONE; if (url.IsProtocol("playlistmusic")) - playlistId = PLAYLIST::TYPE_MUSIC; + playlistId = PLAYLIST::Id::TYPE_MUSIC; else if (url.IsProtocol("playlistvideo")) - playlistId = PLAYLIST::TYPE_VIDEO; + playlistId = PLAYLIST::Id::TYPE_VIDEO; - if (playlistId == PLAYLIST::TYPE_NONE) + if (playlistId == PLAYLIST::Id::TYPE_NONE) return false; const PLAYLIST::CPlayList& playlist = CServiceBroker::GetPlaylistPlayer().GetPlaylist(playlistId); @@ -39,7 +40,7 @@ bool CPlaylistDirectory::GetDirectory(const CURL& url, CFileItemList &items) { CFileItemPtr item = playlist[i]; item->SetProperty("playlistposition", i); - item->SetProperty("playlisttype", playlistId); + item->SetProperty("playlisttype", static_cast<int>(playlistId)); //item->m_iprogramCount = i; // the programCount is set as items are added! items.Add(item); } diff --git a/xbmc/filesystem/PlaylistFileDirectory.cpp b/xbmc/filesystem/PlaylistFileDirectory.cpp index 108c9c9a65..d95989067f 100644 --- a/xbmc/filesystem/PlaylistFileDirectory.cpp +++ b/xbmc/filesystem/PlaylistFileDirectory.cpp @@ -15,7 +15,7 @@ #include "playlists/PlayList.h" #include "playlists/PlayListFactory.h" -using namespace PLAYLIST; +using namespace KODI; namespace XFILE { @@ -26,14 +26,14 @@ namespace XFILE bool CPlaylistFileDirectory::GetDirectory(const CURL& url, CFileItemList& items) { const std::string pathToUrl = url.Get(); - std::unique_ptr<CPlayList> pPlayList (CPlayListFactory::Create(pathToUrl)); + std::unique_ptr<PLAYLIST::CPlayList> pPlayList(PLAYLIST::CPlayListFactory::Create(pathToUrl)); if (nullptr != pPlayList) { // load it if (!pPlayList->Load(pathToUrl)) return false; //hmmm unable to load playlist? - CPlayList playlist = *pPlayList; + PLAYLIST::CPlayList playlist = *pPlayList; // convert playlist items to songs for (int i = 0; i < playlist.size(); ++i) { @@ -48,7 +48,7 @@ namespace XFILE bool CPlaylistFileDirectory::ContainsFiles(const CURL& url) { const std::string pathToUrl = url.Get(); - std::unique_ptr<CPlayList> pPlayList (CPlayListFactory::Create(pathToUrl)); + std::unique_ptr<PLAYLIST::CPlayList> pPlayList(PLAYLIST::CPlayListFactory::Create(pathToUrl)); if (nullptr != pPlayList) { // load it @@ -64,5 +64,4 @@ namespace XFILE { return XFILE::CFile::Delete(url); } -} - + } // namespace XFILE diff --git a/xbmc/filesystem/SmartPlaylistDirectory.cpp b/xbmc/filesystem/SmartPlaylistDirectory.cpp index b3d361ecc2..8acddd21b6 100644 --- a/xbmc/filesystem/SmartPlaylistDirectory.cpp +++ b/xbmc/filesystem/SmartPlaylistDirectory.cpp @@ -26,7 +26,6 @@ #include "video/VideoDatabase.h" #include "video/VideoDbUrl.h" -#include <math.h> #include <memory> #define PROPERTY_PATH_DB "path.db" @@ -35,6 +34,8 @@ #define PROPERTY_GROUP_BY "group.by" #define PROPERTY_GROUP_MIXED "group.mixed" +using namespace KODI; + namespace XFILE { CSmartPlaylistDirectory::CSmartPlaylistDirectory() = default; @@ -44,7 +45,7 @@ namespace XFILE bool CSmartPlaylistDirectory::GetDirectory(const CURL& url, CFileItemList& items) { // Load in the SmartPlaylist and get the WHERE query - CSmartPlaylist playlist; + PLAYLIST::CSmartPlaylist playlist; if (!playlist.Load(url)) return false; bool result = GetDirectory(playlist, items); @@ -54,7 +55,10 @@ namespace XFILE return result; } - bool CSmartPlaylistDirectory::GetDirectory(const CSmartPlaylist &playlist, CFileItemList& items, const std::string &strBaseDir /* = "" */, bool filter /* = false */) + bool CSmartPlaylistDirectory::GetDirectory(const PLAYLIST::CSmartPlaylist& playlist, + CFileItemList& items, + const std::string& strBaseDir /* = "" */, + bool filter /* = false */) { bool success = false, success2 = false; std::vector<std::string> virtualFolders; @@ -78,7 +82,7 @@ namespace XFILE std::string group = playlist.GetGroup(); bool isGrouped = !group.empty() && !StringUtils::EqualsNoCase(group, "none") && !playlist.IsGroupMixed(); // Hint for playlist files like STRM - PLAYLIST::Id playlistTypeHint = PLAYLIST::TYPE_NONE; + PLAYLIST::Id playlistTypeHint = PLAYLIST::Id::TYPE_NONE; // get all virtual folders and add them to the item list playlist.GetVirtualFolders(virtualFolders); @@ -99,7 +103,7 @@ namespace XFILE playlist.GetType() == "tvshows" || playlist.GetType() == "episodes") { - playlistTypeHint = PLAYLIST::TYPE_VIDEO; + playlistTypeHint = PLAYLIST::Id::TYPE_VIDEO; CVideoDatabase db; if (db.Open()) { @@ -155,11 +159,11 @@ namespace XFILE } else if (playlist.IsMusicType() || playlist.GetType().empty()) { - playlistTypeHint = PLAYLIST::TYPE_MUSIC; + playlistTypeHint = PLAYLIST::Id::TYPE_MUSIC; CMusicDatabase db; if (db.Open()) { - CSmartPlaylist plist(playlist); + PLAYLIST::CSmartPlaylist plist(playlist); if (playlist.GetType() == "mixed" || playlist.GetType().empty()) plist.SetType("songs"); @@ -213,11 +217,11 @@ namespace XFILE if (playlist.GetType() == "musicvideos" || playlist.GetType() == "mixed") { - playlistTypeHint = PLAYLIST::TYPE_VIDEO; + playlistTypeHint = PLAYLIST::Id::TYPE_VIDEO; CVideoDatabase db; if (db.Open()) { - CSmartPlaylist mvidPlaylist(playlist); + PLAYLIST::CSmartPlaylist mvidPlaylist(playlist); if (playlist.GetType() == "mixed") mvidPlaylist.SetType("musicvideos"); @@ -302,7 +306,7 @@ namespace XFILE { CFileItemPtr item = items[i]; item->m_iprogramCount = i; // hack for playlist order - item->SetProperty("playlist_type_hint", playlistTypeHint); + item->SetProperty("playlist_type_hint", static_cast<int>(playlistTypeHint)); } if (playlist.GetType() == "mixed") @@ -323,7 +327,7 @@ namespace XFILE { CFileItemList list; bool filesExist = false; - if (CSmartPlaylist::IsMusicType(playlistType)) + if (PLAYLIST::CSmartPlaylist::IsMusicType(playlistType)) filesExist = CDirectory::GetDirectory("special://musicplaylists/", list, ".xsp", DIR_FLAG_DEFAULTS); else // all others are video filesExist = CDirectory::GetDirectory("special://videoplaylists/", list, ".xsp", DIR_FLAG_DEFAULTS); @@ -332,7 +336,7 @@ namespace XFILE for (int i = 0; i < list.Size(); i++) { CFileItemPtr item = list[i]; - CSmartPlaylist playlist; + PLAYLIST::CSmartPlaylist playlist; if (playlist.OpenAndReadName(item->GetURL())) { if (StringUtils::EqualsNoCase(playlist.GetName(), name)) diff --git a/xbmc/filesystem/SmartPlaylistDirectory.h b/xbmc/filesystem/SmartPlaylistDirectory.h index 145c2620d8..7cca5c67d7 100644 --- a/xbmc/filesystem/SmartPlaylistDirectory.h +++ b/xbmc/filesystem/SmartPlaylistDirectory.h @@ -12,7 +12,10 @@ #include <string> +namespace KODI::PLAYLIST +{ class CSmartPlaylist; +} namespace XFILE { @@ -26,7 +29,10 @@ namespace XFILE bool ContainsFiles(const CURL& url) override; bool Remove(const CURL& url) override; - static bool GetDirectory(const CSmartPlaylist &playlist, CFileItemList& items, const std::string &strBaseDir = "", bool filter = false); + static bool GetDirectory(const KODI::PLAYLIST::CSmartPlaylist& playlist, + CFileItemList& items, + const std::string& strBaseDir = "", + bool filter = false); static std::string GetPlaylistByName(const std::string& name, const std::string& playlistType); }; diff --git a/xbmc/games/controllers/windows/GUIConfigurationWizard.cpp b/xbmc/games/controllers/windows/GUIConfigurationWizard.cpp index e2c7130c58..ce980cf7c3 100644 --- a/xbmc/games/controllers/windows/GUIConfigurationWizard.cpp +++ b/xbmc/games/controllers/windows/GUIConfigurationWizard.cpp @@ -293,8 +293,8 @@ bool CGUIConfigurationWizard::MapPrimitive(JOYSTICK::IButtonMap* buttonMap, } else { - CLog::Log(LOGDEBUG, "{}: mapping feature \"{}\" for device {}", m_strControllerId, - feature.Name(), buttonMap->Location()); + CLog::Log(LOGDEBUG, "{}: mapping feature \"{}\" for device {} to \"{}\"", + m_strControllerId, feature.Name(), buttonMap->Location(), primitive.ToString()); switch (feature.Type()) { diff --git a/xbmc/games/windows/GUIWindowGames.cpp b/xbmc/games/windows/GUIWindowGames.cpp index 2d9eb600db..64ef6e149e 100644 --- a/xbmc/games/windows/GUIWindowGames.cpp +++ b/xbmc/games/windows/GUIWindowGames.cpp @@ -337,5 +337,5 @@ void CGUIWindowGames::OnItemInfo(int itemNumber) bool CGUIWindowGames::PlayGame(const CFileItem& item) { CFileItem itemCopy(item); - return g_application.PlayMedia(itemCopy, "", PLAYLIST::TYPE_NONE); + return g_application.PlayMedia(itemCopy, "", PLAYLIST::Id::TYPE_NONE); } diff --git a/xbmc/guilib/guiinfo/GUIInfoHelper.cpp b/xbmc/guilib/guiinfo/GUIInfoHelper.cpp index f713f3a26c..fc84c8eb18 100644 --- a/xbmc/guilib/guiinfo/GUIInfoHelper.cpp +++ b/xbmc/guilib/guiinfo/GUIInfoHelper.cpp @@ -37,7 +37,7 @@ std::string GetPlaylistLabel(int item, PLAYLIST::Id playlistId /* = TYPE_NONE */ { PLAYLIST::CPlayListPlayer& player = CServiceBroker::GetPlaylistPlayer(); - if (playlistId == PLAYLIST::TYPE_NONE) + if (playlistId == PLAYLIST::Id::TYPE_NONE) playlistId = player.GetCurrentPlaylist(); switch (item) diff --git a/xbmc/guilib/guiinfo/GUIInfoHelper.h b/xbmc/guilib/guiinfo/GUIInfoHelper.h index 5fd0d2d341..e5a4e2ca9c 100644 --- a/xbmc/guilib/guiinfo/GUIInfoHelper.h +++ b/xbmc/guilib/guiinfo/GUIInfoHelper.h @@ -28,7 +28,7 @@ namespace GUILIB namespace GUIINFO { -std::string GetPlaylistLabel(int item, PLAYLIST::Id playlistid = PLAYLIST::TYPE_NONE); +std::string GetPlaylistLabel(int item, PLAYLIST::Id playlistid = PLAYLIST::Id::TYPE_NONE); CGUIWindow* GetWindow(int contextWindow); CGUIControl* GetActiveContainer(int containerId, int contextWindow); diff --git a/xbmc/guilib/guiinfo/GUIInfoLabels.h b/xbmc/guilib/guiinfo/GUIInfoLabels.h index ae6f255b31..b926d860e9 100644 --- a/xbmc/guilib/guiinfo/GUIInfoLabels.h +++ b/xbmc/guilib/guiinfo/GUIInfoLabels.h @@ -224,6 +224,9 @@ #define MUSICPLAYER_CONTENT 246 #define MUSICPLAYER_ISMULTIDISC 247 +// More Musicplayer infolabels +#define MUSICPLAYER_CHANNEL_LOGO 248 + // Videoplayer infolabels #define VIDEOPLAYER_HDR_TYPE 249 // Keep videoplayer infolabels that work with offset and position together @@ -318,6 +321,9 @@ #define RETROPLAYER_STRETCH_MODE 331 #define RETROPLAYER_VIDEO_ROTATION 332 +// More PVR infolabels +#define VIDEOPLAYER_CHANNEL_LOGO 333 + #define CONTAINER_HAS_PARENT_ITEM 341 #define CONTAINER_CAN_FILTER 342 #define CONTAINER_CAN_FILTERADVANCED 343 @@ -486,7 +492,6 @@ #define SYSTEM_PLATFORM_DARWIN_TVOS 755 #define SYSTEM_SUPPORTED_HDR_TYPES 756 #define SYSTEM_PLATFORM_WEBOS 757 -#define SYSTEM_PVR_COUNT 758 #define SLIDESHOW_ISPAUSED 800 #define SLIDESHOW_ISRANDOM 801 @@ -594,7 +599,6 @@ static constexpr unsigned int SYSTEM_LOCALE = 1012; #define PVR_CAN_RECORD_PLAYING_CHANNEL (PVR_CONDITIONS_START + 17) #define PVR_IS_RECORDING_PLAYING_CHANNEL (PVR_CONDITIONS_START + 18) #define PVR_IS_PLAYING_ACTIVE_RECORDING (PVR_CONDITIONS_START + 19) -#define PVR_CONDITIONS_END PVR_IS_PLAYING_ACTIVE_RECORDING #define PVR_STRINGS_START 1200 #define PVR_NEXT_RECORDING_CHANNEL (PVR_STRINGS_START) @@ -670,7 +674,9 @@ static constexpr unsigned int SYSTEM_LOCALE = 1012; #define PVR_TIMESHIFT_SEEKBAR (PVR_STRINGS_START + 73) #define PVR_BACKEND_PROVIDERS (PVR_STRINGS_START + 74) #define PVR_BACKEND_CHANNEL_GROUPS (PVR_STRINGS_START + 75) -#define PVR_STRINGS_END PVR_BACKEND_CHANNEL_GROUPS + +#define PVR_INTS_START 1300 +#define PVR_CLIENT_COUNT (PVR_INTS_START) #define RDS_DATA_START 1400 #define RDS_HAS_RDS (RDS_DATA_START) @@ -979,7 +985,9 @@ static constexpr unsigned int SYSTEM_LOCALE = 1012; #define LISTITEM_ISVIDEOEXTRA (LISTITEM_START + 214) #define LISTITEM_VIDEOVERSION_NAME (LISTITEM_START + 215) #define LISTITEM_HASVIDEOEXTRAS (LISTITEM_START + 216) -#define LISTITEM_BACKEND_INSTANCE_NAME (LISTITEM_START + 217) +#define LISTITEM_PVR_CLIENT_NAME (LISTITEM_START + 217) +#define LISTITEM_PVR_INSTANCE_NAME (LISTITEM_START + 218) +#define LISTITEM_CHANNEL_LOGO (LISTITEM_START + 219) #define LISTITEM_END (LISTITEM_START + 2500) diff --git a/xbmc/guilib/guiinfo/MusicGUIInfo.cpp b/xbmc/guilib/guiinfo/MusicGUIInfo.cpp index cb246febda..9482cec038 100644 --- a/xbmc/guilib/guiinfo/MusicGUIInfo.cpp +++ b/xbmc/guilib/guiinfo/MusicGUIInfo.cpp @@ -430,14 +430,14 @@ bool CMusicGUIInfo::GetLabel(std::string& value, const CFileItem *item, int cont value = item->GetProperty(info.GetData3()).asString(); return true; case MUSICPLAYER_PLAYLISTLEN: - if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::TYPE_MUSIC) + if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::Id::TYPE_MUSIC) { value = GUIINFO::GetPlaylistLabel(PLAYLIST_LENGTH); return true; } break; case MUSICPLAYER_PLAYLISTPOS: - if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::TYPE_MUSIC) + if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::Id::TYPE_MUSIC) { value = GUIINFO::GetPlaylistLabel(PLAYLIST_POSITION); return true; @@ -548,14 +548,14 @@ bool CMusicGUIInfo::GetPartyModeLabel(std::string& value, const CGUIInfo &info) bool CMusicGUIInfo::GetPlaylistInfo(std::string& value, const CGUIInfo &info) const { const PLAYLIST::CPlayList& playlist = - CServiceBroker::GetPlaylistPlayer().GetPlaylist(PLAYLIST::TYPE_MUSIC); + CServiceBroker::GetPlaylistPlayer().GetPlaylist(PLAYLIST::Id::TYPE_MUSIC); if (playlist.size() < 1) return false; int index = info.GetData2(); if (info.GetData1() == 1) { // relative index (requires current playlist is TYPE_MUSIC) - if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() != PLAYLIST::TYPE_MUSIC) + if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() != PLAYLIST::Id::TYPE_MUSIC) return false; index = CServiceBroker::GetPlaylistPlayer().GetNextItemIdx(index); @@ -645,7 +645,7 @@ bool CMusicGUIInfo::GetBool(bool& value, const CGUIListItem *gitem, int contextW return value; // if no match for this provider, other providers shall be asked. case MUSICPLAYER_HASPREVIOUS: // requires current playlist be TYPE_MUSIC - if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::TYPE_MUSIC) + if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::Id::TYPE_MUSIC) { value = (CServiceBroker::GetPlaylistPlayer().GetCurrentItemIdx() > 0); // not first song return true; @@ -653,10 +653,10 @@ bool CMusicGUIInfo::GetBool(bool& value, const CGUIListItem *gitem, int contextW break; case MUSICPLAYER_HASNEXT: // requires current playlist be TYPE_MUSIC - if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::TYPE_MUSIC) + if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::Id::TYPE_MUSIC) { value = (CServiceBroker::GetPlaylistPlayer().GetCurrentItemIdx() < - (CServiceBroker::GetPlaylistPlayer().GetPlaylist(PLAYLIST::TYPE_MUSIC).size() - + (CServiceBroker::GetPlaylistPlayer().GetPlaylist(PLAYLIST::Id::TYPE_MUSIC).size() - 1)); // not last song return true; } @@ -666,7 +666,7 @@ bool CMusicGUIInfo::GetBool(bool& value, const CGUIListItem *gitem, int contextW const auto& components = CServiceBroker::GetAppComponents(); const auto appPlayer = components.GetComponent<CApplicationPlayer>(); if (appPlayer->IsPlayingAudio() && - CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::TYPE_MUSIC) + CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::Id::TYPE_MUSIC) { value = true; return true; @@ -678,7 +678,7 @@ bool CMusicGUIInfo::GetBool(bool& value, const CGUIListItem *gitem, int contextW int index = info.GetData2(); if (info.GetData1() == 1) { // relative index - if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() != PLAYLIST::TYPE_MUSIC) + if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() != PLAYLIST::Id::TYPE_MUSIC) { value = false; return true; @@ -687,7 +687,8 @@ bool CMusicGUIInfo::GetBool(bool& value, const CGUIListItem *gitem, int contextW } value = (index >= 0 && - index < CServiceBroker::GetPlaylistPlayer().GetPlaylist(PLAYLIST::TYPE_MUSIC).size()); + index < + CServiceBroker::GetPlaylistPlayer().GetPlaylist(PLAYLIST::Id::TYPE_MUSIC).size()); return true; } case MUSICPLAYER_ISMULTIDISC: diff --git a/xbmc/guilib/guiinfo/PlayerGUIInfo.cpp b/xbmc/guilib/guiinfo/PlayerGUIInfo.cpp index 4ec5d88952..62e620dc41 100644 --- a/xbmc/guilib/guiinfo/PlayerGUIInfo.cpp +++ b/xbmc/guilib/guiinfo/PlayerGUIInfo.cpp @@ -347,7 +347,8 @@ bool CPlayerGUIInfo::GetLabel(std::string& value, const CFileItem *item, int con case PLAYLIST_POSITION: case PLAYLIST_RANDOM: case PLAYLIST_REPEAT: - value = GUIINFO::GetPlaylistLabel(info.m_info, info.GetData1()); + value = + GUIINFO::GetPlaylistLabel(info.m_info, PLAYLIST::Id{static_cast<int>(info.GetData1())}); return true; } @@ -546,8 +547,8 @@ bool CPlayerGUIInfo::GetBool(bool& value, const CGUIListItem *gitem, int context case PLAYLIST_ISRANDOM: { PLAYLIST::CPlayListPlayer& player = CServiceBroker::GetPlaylistPlayer(); - PLAYLIST::Id playlistid = info.GetData1(); - if (info.GetData2() > 0 && playlistid != PLAYLIST::TYPE_NONE) + PLAYLIST::Id playlistid = PLAYLIST::Id{static_cast<int>(info.GetData1())}; + if (info.GetData2() > 0 && playlistid != PLAYLIST::Id::TYPE_NONE) value = player.IsShuffled(playlistid); else value = player.IsShuffled(player.GetCurrentPlaylist()); @@ -556,8 +557,8 @@ bool CPlayerGUIInfo::GetBool(bool& value, const CGUIListItem *gitem, int context case PLAYLIST_ISREPEAT: { PLAYLIST::CPlayListPlayer& player = CServiceBroker::GetPlaylistPlayer(); - PLAYLIST::Id playlistid = info.GetData1(); - if (info.GetData2() > 0 && playlistid != PLAYLIST::TYPE_NONE) + PLAYLIST::Id playlistid = PLAYLIST::Id{static_cast<int>(info.GetData1())}; + if (info.GetData2() > 0 && playlistid != PLAYLIST::Id::TYPE_NONE) value = (player.GetRepeat(playlistid) == PLAYLIST::RepeatState::ALL); else value = player.GetRepeat(player.GetCurrentPlaylist()) == PLAYLIST::RepeatState::ALL; @@ -566,8 +567,8 @@ bool CPlayerGUIInfo::GetBool(bool& value, const CGUIListItem *gitem, int context case PLAYLIST_ISREPEATONE: { PLAYLIST::CPlayListPlayer& player = CServiceBroker::GetPlaylistPlayer(); - PLAYLIST::Id playlistid = info.GetData1(); - if (info.GetData2() > 0 && playlistid != PLAYLIST::TYPE_NONE) + PLAYLIST::Id playlistid = PLAYLIST::Id{static_cast<int>(info.GetData1())}; + if (info.GetData2() > 0 && playlistid != PLAYLIST::Id::TYPE_NONE) value = (player.GetRepeat(playlistid) == PLAYLIST::RepeatState::ONE); else value = player.GetRepeat(player.GetCurrentPlaylist()) == PLAYLIST::RepeatState::ONE; @@ -590,7 +591,7 @@ bool CPlayerGUIInfo::GetBool(bool& value, const CGUIListItem *gitem, int context { if (item->HasProperty("playlistposition")) { - value = static_cast<int>(item->GetProperty("playlisttype").asInteger()) == + value = PLAYLIST::Id{item->GetProperty("playlisttype").asInteger32()} == CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() && static_cast<int>(item->GetProperty("playlistposition").asInteger()) == CServiceBroker::GetPlaylistPlayer().GetCurrentItemIdx(); diff --git a/xbmc/guilib/guiinfo/SystemGUIInfo.cpp b/xbmc/guilib/guiinfo/SystemGUIInfo.cpp index 683937302a..9d9a04bdf4 100644 --- a/xbmc/guilib/guiinfo/SystemGUIInfo.cpp +++ b/xbmc/guilib/guiinfo/SystemGUIInfo.cpp @@ -26,8 +26,6 @@ #include "guilib/guiinfo/GUIInfoLabels.h" #include "powermanagement/PowerManager.h" #include "profiles/ProfileManager.h" -#include "pvr/PVRManager.h" -#include "pvr/addons/PVRClients.h" #include "settings/AdvancedSettings.h" #include "settings/MediaSettings.h" #include "settings/SettingUtils.h" @@ -146,6 +144,7 @@ bool CSystemGUIInfo::GetLabel(std::string& value, const CFileItem *item, int con case NETWORK_GATEWAY_ADDRESS: case NETWORK_DNS1_ADDRESS: case NETWORK_DNS2_ADDRESS: + case NETWORK_LINK_STATE: case SYSTEM_OS_VERSION_INFO: case SYSTEM_CPUFREQUENCY: case SYSTEM_INTERNET_STATE: @@ -341,12 +340,6 @@ bool CSystemGUIInfo::GetLabel(std::string& value, const CFileItem *item, int con value = g_langInfo.GetRegionLocale(); return true; } - - case SYSTEM_PVR_COUNT: - { - value = std::to_string(CServiceBroker::GetPVRManager().Clients()->EnabledClientAmount()); - return true; - } } return false; } @@ -382,11 +375,6 @@ bool CSystemGUIInfo::GetInt(int& value, const CGUIListItem *gitem, int contextWi case SYSTEM_BATTERY_LEVEL: value = CServiceBroker::GetPowerManager().BatteryLevel(); return true; - case SYSTEM_PVR_COUNT: - { - value = CServiceBroker::GetPVRManager().Clients()->EnabledClientAmount(); - return true; - } } return false; diff --git a/xbmc/guilib/guiinfo/VideoGUIInfo.cpp b/xbmc/guilib/guiinfo/VideoGUIInfo.cpp index 6bec6186b7..0a112ea3ef 100644 --- a/xbmc/guilib/guiinfo/VideoGUIInfo.cpp +++ b/xbmc/guilib/guiinfo/VideoGUIInfo.cpp @@ -558,14 +558,14 @@ bool CVideoGUIInfo::GetLabel(std::string& value, const CFileItem *item, int cont // VIDEOPLAYER_* /////////////////////////////////////////////////////////////////////////////////////////////// case VIDEOPLAYER_PLAYLISTLEN: - if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::TYPE_VIDEO) + if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::Id::TYPE_VIDEO) { value = GUIINFO::GetPlaylistLabel(PLAYLIST_LENGTH); return true; } break; case VIDEOPLAYER_PLAYLISTPOS: - if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::TYPE_VIDEO) + if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::Id::TYPE_VIDEO) { value = GUIINFO::GetPlaylistLabel(PLAYLIST_POSITION); return true; @@ -657,14 +657,14 @@ bool CVideoGUIInfo::GetLabel(std::string& value, const CFileItem *item, int cont bool CVideoGUIInfo::GetPlaylistInfo(std::string& value, const CGUIInfo& info) const { const PLAYLIST::CPlayList& playlist = - CServiceBroker::GetPlaylistPlayer().GetPlaylist(PLAYLIST::TYPE_VIDEO); + CServiceBroker::GetPlaylistPlayer().GetPlaylist(PLAYLIST::Id::TYPE_VIDEO); if (playlist.size() < 1) return false; int index = info.GetData2(); if (info.GetData1() == 1) { // relative index (requires current playlist is TYPE_VIDEO) - if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() != PLAYLIST::TYPE_VIDEO) + if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() != PLAYLIST::Id::TYPE_VIDEO) return false; index = CServiceBroker::GetPlaylistPlayer().GetNextItemIdx(index); diff --git a/xbmc/input/joysticks/DriverPrimitive.cpp b/xbmc/input/joysticks/DriverPrimitive.cpp index fa8f7c9592..3f1a5ab895 100644 --- a/xbmc/input/joysticks/DriverPrimitive.cpp +++ b/xbmc/input/joysticks/DriverPrimitive.cpp @@ -8,6 +8,9 @@ #include "DriverPrimitive.h" +#include "input/keyboard/KeyboardTranslator.h" +#include "utils/StringUtils.h" + #include <utility> using namespace KODI; @@ -199,3 +202,70 @@ bool CDriverPrimitive::IsValid(void) const return false; } + +std::string CDriverPrimitive::ToString() const +{ + switch (m_type) + { + case PRIMITIVE_TYPE::BUTTON: + return StringUtils::Format("button {}", m_driverIndex); + case PRIMITIVE_TYPE::MOTOR: + return StringUtils::Format("motor {}", m_driverIndex); + case PRIMITIVE_TYPE::MOUSE_BUTTON: + return StringUtils::Format("mouse button {}", m_driverIndex); + case PRIMITIVE_TYPE::HAT: + { + switch (m_hatDirection) + { + case HAT_DIRECTION::UP: + return StringUtils::Format("hat {} up", m_driverIndex); + case HAT_DIRECTION::DOWN: + return StringUtils::Format("hat {} down", m_driverIndex); + case HAT_DIRECTION::RIGHT: + return StringUtils::Format("hat {} right", m_driverIndex); + case HAT_DIRECTION::LEFT: + return StringUtils::Format("hat {} left", m_driverIndex); + default: + break; + } + break; + } + case PRIMITIVE_TYPE::SEMIAXIS: + { + switch (m_semiAxisDirection) + { + case SEMIAXIS_DIRECTION::POSITIVE: + return StringUtils::Format("semiaxis +{}", m_driverIndex); + case SEMIAXIS_DIRECTION::NEGATIVE: + return StringUtils::Format("semiaxis -{}", m_driverIndex); + default: + break; + } + break; + } + case PRIMITIVE_TYPE::KEY: + return StringUtils::Format("key {}", + KEYBOARD::CKeyboardTranslator::TranslateKeycode(m_keycode)); + case PRIMITIVE_TYPE::RELATIVE_POINTER: + { + switch (m_pointerDirection) + { + case RELATIVE_POINTER_DIRECTION::UP: + return StringUtils::Format("pointer {} up", m_driverIndex); + case RELATIVE_POINTER_DIRECTION::DOWN: + return StringUtils::Format("pointer {} down", m_driverIndex); + case RELATIVE_POINTER_DIRECTION::RIGHT: + return StringUtils::Format("pointer {} right", m_driverIndex); + case RELATIVE_POINTER_DIRECTION::LEFT: + return StringUtils::Format("pointer {} left", m_driverIndex); + default: + break; + } + break; + } + default: + break; + } + + return ""; +} diff --git a/xbmc/input/joysticks/DriverPrimitive.h b/xbmc/input/joysticks/DriverPrimitive.h index 2d8b153fe0..e4edea9f26 100644 --- a/xbmc/input/joysticks/DriverPrimitive.h +++ b/xbmc/input/joysticks/DriverPrimitive.h @@ -180,6 +180,13 @@ public: */ bool IsValid(void) const; + /*! + * \brief Convert primitive to a string suitable for logging + * + * \return The primitive as described by a short string, or empty if invalid + */ + std::string ToString() const; + private: PRIMITIVE_TYPE m_type = PRIMITIVE_TYPE::UNKNOWN; unsigned int m_driverIndex = 0; diff --git a/xbmc/input/joysticks/generic/ButtonMapping.cpp b/xbmc/input/joysticks/generic/ButtonMapping.cpp index 4b5dd8aca5..03faf73926 100644 --- a/xbmc/input/joysticks/generic/ButtonMapping.cpp +++ b/xbmc/input/joysticks/generic/ButtonMapping.cpp @@ -451,31 +451,34 @@ bool CButtonMapping::MapPrimitive(const CDriverPrimitive& primitive) { bool bHandled = false; - auto now = std::chrono::steady_clock::now(); - - bool bTimeoutElapsed = true; - - if (m_buttonMapper->NeedsCooldown()) - bTimeoutElapsed = (now >= m_lastAction + std::chrono::milliseconds(MAPPING_COOLDOWN_MS)); - - if (bTimeoutElapsed) - { - bHandled = m_buttonMapper->MapPrimitive(m_buttonMap, m_keymap, primitive); - - if (bHandled) - m_lastAction = std::chrono::steady_clock::now(); - } - else if (m_buttonMap->IsIgnored(primitive)) + if (m_buttonMap->IsIgnored(primitive)) { bHandled = true; } else { - auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(now - m_lastAction); + auto now = std::chrono::steady_clock::now(); - CLog::Log(LOGDEBUG, "Button mapping: rapid input after {}ms dropped for profile \"{}\"", - duration.count(), m_buttonMapper->ControllerID()); - bHandled = true; + bool bTimeoutElapsed = true; + + if (m_buttonMapper->NeedsCooldown()) + bTimeoutElapsed = (now >= m_lastAction + std::chrono::milliseconds(MAPPING_COOLDOWN_MS)); + + if (bTimeoutElapsed) + { + bHandled = m_buttonMapper->MapPrimitive(m_buttonMap, m_keymap, primitive); + + if (bHandled) + m_lastAction = std::chrono::steady_clock::now(); + } + else + { + auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(now - m_lastAction); + + CLog::Log(LOGDEBUG, "Button mapping: rapid input after {}ms dropped for profile \"{}\"", + duration.count(), m_buttonMapper->ControllerID()); + bHandled = true; + } } return bHandled; diff --git a/xbmc/input/keyboard/KeyboardStat.cpp b/xbmc/input/keyboard/KeyboardStat.cpp index 5e390ee562..d6784c920c 100644 --- a/xbmc/input/keyboard/KeyboardStat.cpp +++ b/xbmc/input/keyboard/KeyboardStat.cpp @@ -14,6 +14,7 @@ #include "KeyboardStat.h" #include "ServiceBroker.h" +#include "input/keyboard/KeyboardTranslator.h" #include "input/keyboard/KeyboardTypes.h" #include "input/keyboard/XBMC_keytable.h" #include "input/keyboard/XBMC_vkeys.h" @@ -91,8 +92,9 @@ CKey CKeyboardStat::TranslateKey(XBMC_keysym& keysym) const lockingModifiers |= CKey::MODIFIER_SCROLLLOCK; CLog::Log(LOGDEBUG, - "Keyboard: scancode: {:#02x}, sym: {:#04x}, unicode: {:#04x}, modifier: 0x{:x}", - keysym.scancode, keysym.sym, keysym.unicode, keysym.mod); + "Keyboard: scancode: {:#02x}, sym: {:#04x} ({}), unicode: {:#04x}, modifier: 0x{:x}", + keysym.scancode, keysym.sym, CKeyboardTranslator::TranslateKeycode(keysym.sym), + keysym.unicode, keysym.mod); // The keysym.unicode is usually valid, even if it is zero. A zero // unicode just means this is a non-printing keypress. The ascii and diff --git a/xbmc/interfaces/AnnouncementManager.cpp b/xbmc/interfaces/AnnouncementManager.cpp index 46fd378615..26836829f4 100644 --- a/xbmc/interfaces/AnnouncementManager.cpp +++ b/xbmc/interfaces/AnnouncementManager.cpp @@ -22,12 +22,11 @@ #include <memory> #include <mutex> -#include <stdio.h> #define LOOKUP_PROPERTY "database-lookup" using namespace ANNOUNCEMENT; -using namespace KODI::VIDEO; +using namespace KODI; const std::string CAnnouncementManager::ANNOUNCEMENT_SENDER = "xbmc"; @@ -191,8 +190,9 @@ void CAnnouncementManager::DoAnnounce(AnnouncementFlag flag, if (data.isMember("player") && data["player"].isMember("playerid")) { - object["player"]["playerid"] = - channel->IsRadio() ? PLAYLIST::TYPE_MUSIC : PLAYLIST::TYPE_VIDEO; + object["player"]["playerid"] = channel->IsRadio() + ? static_cast<int>(PLAYLIST::Id::TYPE_MUSIC) + : static_cast<int>(PLAYLIST::Id::TYPE_VIDEO); } } else if (item->HasVideoInfoTag() && !item->HasPVRRecordingInfoTag()) @@ -298,7 +298,7 @@ void CAnnouncementManager::DoAnnounce(AnnouncementFlag flag, object["item"]["artist"] = item->GetMusicInfoTag()->GetArtist(); } } - else if (IsVideo(*item)) + else if (VIDEO::IsVideo(*item)) { // video item but has no video info tag. type = "movie"; diff --git a/xbmc/interfaces/builtins/AddonBuiltins.cpp b/xbmc/interfaces/builtins/AddonBuiltins.cpp index 056128d2b3..2c20cfd0df 100644 --- a/xbmc/interfaces/builtins/AddonBuiltins.cpp +++ b/xbmc/interfaces/builtins/AddonBuiltins.cpp @@ -43,7 +43,7 @@ #endif using namespace ADDON; -using namespace KODI::MESSAGING; +using namespace KODI; using KODI::MESSAGING::HELPERS::DialogResponse; /*! \brief Install an addon. @@ -75,7 +75,8 @@ static int EnableAddon(const std::vector<std::string>& params) if (!CServiceBroker::GetAddonMgr().GetAddon(addonid, addon, OnlyEnabled::CHOICE_NO)) return -1; - auto response = HELPERS::ShowYesNoDialogLines(CVariant{24076}, CVariant{24135}, CVariant{addon->Name()}, CVariant{24136}); + auto response = MESSAGING::HELPERS::ShowYesNoDialogLines( + CVariant{24076}, CVariant{24135}, CVariant{addon->Name()}, CVariant{24136}); if (response == DialogResponse::CHOICE_YES) CServiceBroker::GetAddonMgr().EnableAddon(addonid); @@ -189,7 +190,7 @@ static int RunAddon(const std::vector<std::string>& params) else item = CFileItem(addon); - if (!g_application.PlayMedia(item, "", PLAYLIST::TYPE_NONE)) + if (!g_application.PlayMedia(item, "", PLAYLIST::Id::TYPE_NONE)) { CLog::Log(LOGERROR, "RunAddon could not start {}", addonid); return false; diff --git a/xbmc/interfaces/builtins/PlayerBuiltins.cpp b/xbmc/interfaces/builtins/PlayerBuiltins.cpp index 1043f0944f..2d7f92608f 100644 --- a/xbmc/interfaces/builtins/PlayerBuiltins.cpp +++ b/xbmc/interfaces/builtins/PlayerBuiltins.cpp @@ -81,14 +81,14 @@ static int PlayOffset(const std::vector<std::string>& params) std::string strPlaylist = params[0]; strPos = params[1]; - PLAYLIST::Id playlistId = PLAYLIST::TYPE_NONE; + PLAYLIST::Id playlistId = PLAYLIST::Id::TYPE_NONE; if (paramlow == "music") - playlistId = PLAYLIST::TYPE_MUSIC; + playlistId = PLAYLIST::Id::TYPE_MUSIC; else if (paramlow == "video") - playlistId = PLAYLIST::TYPE_VIDEO; + playlistId = PLAYLIST::Id::TYPE_VIDEO; // unknown playlist - if (playlistId == PLAYLIST::TYPE_NONE) + if (playlistId == PLAYLIST::Id::TYPE_NONE) { CLog::Log(LOGERROR, "Playlist.PlayOffset called with unknown playlist: {}", strPlaylist); return false; @@ -310,12 +310,12 @@ static int PlayerControl(const std::vector<std::string>& params) // save settings for now playing windows switch (playlistId) { - case PLAYLIST::TYPE_MUSIC: + case PLAYLIST::Id::TYPE_MUSIC: CMediaSettings::GetInstance().SetMusicPlaylistShuffled( CServiceBroker::GetPlaylistPlayer().IsShuffled(playlistId)); CServiceBroker::GetSettingsComponent()->GetSettings()->Save(); break; - case PLAYLIST::TYPE_VIDEO: + case PLAYLIST::Id::TYPE_VIDEO: CMediaSettings::GetInstance().SetVideoPlaylistShuffled( CServiceBroker::GetPlaylistPlayer().IsShuffled(playlistId)); CServiceBroker::GetSettingsComponent()->GetSettings()->Save(); @@ -324,7 +324,7 @@ static int PlayerControl(const std::vector<std::string>& params) } // send message - CGUIMessage msg(GUI_MSG_PLAYLISTPLAYER_RANDOM, 0, 0, playlistId, + CGUIMessage msg(GUI_MSG_PLAYLISTPLAYER_RANDOM, 0, 0, static_cast<int>(playlistId), CServiceBroker::GetPlaylistPlayer().IsShuffled(playlistId)); CServiceBroker::GetGUI()->GetWindowManager().SendThreadMessage(msg); } @@ -362,19 +362,23 @@ static int PlayerControl(const std::vector<std::string>& params) // save settings for now playing windows switch (playlistId) { - case PLAYLIST::TYPE_MUSIC: + case PLAYLIST::Id::TYPE_MUSIC: CMediaSettings::GetInstance().SetMusicPlaylistRepeat(repeatState == PLAYLIST::RepeatState::ALL); CServiceBroker::GetSettingsComponent()->GetSettings()->Save(); break; - case PLAYLIST::TYPE_VIDEO: + case PLAYLIST::Id::TYPE_VIDEO: CMediaSettings::GetInstance().SetVideoPlaylistRepeat(repeatState == PLAYLIST::RepeatState::ALL); CServiceBroker::GetSettingsComponent()->GetSettings()->Save(); + break; + default: + break; } // send messages so now playing window can get updated - CGUIMessage msg(GUI_MSG_PLAYLISTPLAYER_REPEAT, 0, 0, playlistId, static_cast<int>(repeatState)); + CGUIMessage msg(GUI_MSG_PLAYLISTPLAYER_REPEAT, 0, 0, static_cast<int>(playlistId), + static_cast<int>(repeatState)); CServiceBroker::GetGUI()->GetWindowManager().SendThreadMessage(msg); } else if (StringUtils::StartsWithNoCase(params[0], "resumelivetv")) @@ -394,8 +398,9 @@ static int PlayerControl(const std::vector<std::string>& params) } CFileItem playItem(groupMember); - if (!g_application.PlayMedia( - playItem, "", channel->IsRadio() ? PLAYLIST::TYPE_MUSIC : PLAYLIST::TYPE_VIDEO)) + if (!g_application.PlayMedia(playItem, "", + channel->IsRadio() ? PLAYLIST::Id::TYPE_MUSIC + : PLAYLIST::Id::TYPE_VIDEO)) { CLog::Log(LOGERROR, "ResumeLiveTv could not play channel: {}", channel->ChannelName()); return false; @@ -438,11 +443,11 @@ void GetItemsForPlayList(const std::shared_ptr<CFileItem>& item, CFileItemList& PLAYLIST::Id GetPlayListId(const CFileItem& item) { - PLAYLIST::Id playlistId{PLAYLIST::TYPE_NONE}; + PLAYLIST::Id playlistId{PLAYLIST::Id::TYPE_NONE}; if (VIDEO::IsVideo(item)) - playlistId = PLAYLIST::TYPE_VIDEO; + playlistId = PLAYLIST::Id::TYPE_VIDEO; else if (MUSIC::IsAudio(item)) - playlistId = PLAYLIST::TYPE_MUSIC; + playlistId = PLAYLIST::Id::TYPE_MUSIC; return playlistId; } @@ -551,12 +556,12 @@ int PlayOrQueueMedia(const std::vector<std::string>& params, bool forcePlay) break; } - PLAYLIST::Id playlistId = containsVideo ? PLAYLIST::TYPE_VIDEO : PLAYLIST::TYPE_MUSIC; + PLAYLIST::Id playlistId = containsVideo ? PLAYLIST::Id::TYPE_VIDEO : PLAYLIST::Id::TYPE_MUSIC; // Mixed playlist item played by music player, mixed content folder has music removed if (containsMusic && containsVideo) { if (item.IsPlayList()) - playlistId = PLAYLIST::TYPE_MUSIC; + playlistId = PLAYLIST::Id::TYPE_MUSIC; else { for (int i = items.Size() - 1; i >= 0; i--) //remove music entries @@ -623,7 +628,7 @@ int PlayOrQueueMedia(const std::vector<std::string>& params, bool forcePlay) if ((MUSIC::IsAudio(item) || VIDEO::IsVideo(item)) && !item.IsSmartPlayList() && !item.IsPVR()) { if (!item.HasProperty("playlist_type_hint")) - item.SetProperty("playlist_type_hint", GetPlayListId(item)); + item.SetProperty("playlist_type_hint", static_cast<int>(GetPlayListId(item))); CServiceBroker::GetPlaylistPlayer().Play(std::make_shared<CFileItem>(item), ""); } @@ -771,8 +776,8 @@ static int SubtitleShiftDown(const std::vector<std::string>& params) /// | Partymode(path to .xsp) | Partymode for *.xsp-file | Partymode for *.xsp-file | | /// | ShowVideoMenu | Shows the DVD/BR menu if available | none | | /// | FrameAdvance(n) *** | Advance video by _n_ frames | none | Kodi v18 | -/// | SubtitleShiftUp(save) | Shift up the subtitle position, add "save" to save the change permanently | none | Kodi v20 | -/// | SubtitleShiftDown(save) | Shift down the subtitle position, add "save" to save the change permanently | none | Kodi v20 | +/// | SubtitleShiftUp(save) | Shift up the subtitle position\, add "save" to save the change permanently | none | Kodi v20 | +/// | SubtitleShiftDown(save) | Shift down the subtitle position\, add "save" to save the change permanently | none | Kodi v20 | /// <br> /// '*' = For these controls\, the PlayerControl built-in function can make use of the 'notify'-parameter. For example: PlayerControl(random\, notify) /// <br> @@ -803,8 +808,8 @@ static int SubtitleShiftDown(const std::vector<std::string>& params) /// <b>`PlayMedia(media[\,isdir][\,1]\,[playoffset=xx])`</b> /// , /// Plays the given media. This can be a playlist\, music\, or video file\, directory\, -/// plugin\, disc image stack\, video file stack or an URL. The optional parameter `,isdir` can -/// be used for playing a directory. `,1` will start the media without switching to fullscreen. +/// plugin\, disc image stack\, video file stack or an URL. The optional parameter `\,isdir` can +/// be used for playing a directory. `\,1` will start the media without switching to fullscreen. /// If media is a playlist or a disc image stack or a video file stack\, you can use /// playoffset=xx where xx is the position to start playback from. /// @param[in] media URL to media to play (optional). @@ -831,8 +836,8 @@ static int SubtitleShiftDown(const std::vector<std::string>& params) /// <b>`QueueMedia(media[\,isdir][\,1][\,playnext]\,[playoffset=xx])`</b> /// \anchor Builtin_QueueMedia, /// Queues the given media. This can be a playlist\, music\, or video file\, directory\, -/// plugin\, disc image stack\, video file stack or an URL. The optional parameter `,isdir` can -/// be used for playing a directory. `,1` will start the media without switching to fullscreen. +/// plugin\, disc image stack\, video file stack or an URL. The optional parameter `\,isdir` can +/// be used for playing a directory. `\,1` will start the media without switching to fullscreen. /// If media is a playlist or a disc image stack or a video file stack\, you can use /// playoffset=xx where xx is the position to start playback from. /// where xx is the position to start playback from. @@ -842,8 +847,8 @@ static int SubtitleShiftDown(const std::vector<std::string>& params) /// @param[in] resume Set `resume` to force resuming (optional). /// @param[in] noresume Set `noresume` to force not resuming (optional). /// @param[in] playoffset Set `playoffset=<offset>` to start playback from a given position in a playlist or stack (optional). -/// @param[in] playnext Set `playnext` to play the media right after the currently playing item, if player is currently -/// playing. If player is not playing, append media to current playlist (optional). +/// @param[in] playnext Set `playnext` to play the media right after the currently playing item\, if player is currently +/// playing. If player is not playing\, append media to current playlist (optional). /// <p><hr> /// @skinning_v20 **[New builtin]** \link Builtin_QueueMedia `QueueMedia(media[\,isdir][\,1][\,playnext]\,[playoffset=xx])`\endlink /// <p> diff --git a/xbmc/interfaces/json-rpc/JSONRPC.cpp b/xbmc/interfaces/json-rpc/JSONRPC.cpp index 9f44f3883e..96d3fb5aa7 100644 --- a/xbmc/interfaces/json-rpc/JSONRPC.cpp +++ b/xbmc/interfaces/json-rpc/JSONRPC.cpp @@ -65,31 +65,31 @@ void CJSONRPC::Initialize() CJSONServiceDescription::AddEnum("List.Filter.Operators", smartplaylistList); smartplaylistList.clear(); - CSmartPlaylist::GetAvailableFields("movies", smartplaylistList); + PLAYLIST::CSmartPlaylist::GetAvailableFields("movies", smartplaylistList); CJSONServiceDescription::AddEnum("List.Filter.Fields.Movies", smartplaylistList); smartplaylistList.clear(); - CSmartPlaylist::GetAvailableFields("tvshows", smartplaylistList); + PLAYLIST::CSmartPlaylist::GetAvailableFields("tvshows", smartplaylistList); CJSONServiceDescription::AddEnum("List.Filter.Fields.TVShows", smartplaylistList); smartplaylistList.clear(); - CSmartPlaylist::GetAvailableFields("episodes", smartplaylistList); + PLAYLIST::CSmartPlaylist::GetAvailableFields("episodes", smartplaylistList); CJSONServiceDescription::AddEnum("List.Filter.Fields.Episodes", smartplaylistList); smartplaylistList.clear(); - CSmartPlaylist::GetAvailableFields("musicvideos", smartplaylistList); + PLAYLIST::CSmartPlaylist::GetAvailableFields("musicvideos", smartplaylistList); CJSONServiceDescription::AddEnum("List.Filter.Fields.MusicVideos", smartplaylistList); smartplaylistList.clear(); - CSmartPlaylist::GetAvailableFields("artists", smartplaylistList); + PLAYLIST::CSmartPlaylist::GetAvailableFields("artists", smartplaylistList); CJSONServiceDescription::AddEnum("List.Filter.Fields.Artists", smartplaylistList); smartplaylistList.clear(); - CSmartPlaylist::GetAvailableFields("albums", smartplaylistList); + PLAYLIST::CSmartPlaylist::GetAvailableFields("albums", smartplaylistList); CJSONServiceDescription::AddEnum("List.Filter.Fields.Albums", smartplaylistList); smartplaylistList.clear(); - CSmartPlaylist::GetAvailableFields("songs", smartplaylistList); + PLAYLIST::CSmartPlaylist::GetAvailableFields("songs", smartplaylistList); CJSONServiceDescription::AddEnum("List.Filter.Fields.Songs", smartplaylistList); smartplaylistList.clear(); diff --git a/xbmc/interfaces/json-rpc/JSONUtils.h b/xbmc/interfaces/json-rpc/JSONUtils.h index 150e23b95d..f6643fd03e 100644 --- a/xbmc/interfaces/json-rpc/JSONUtils.h +++ b/xbmc/interfaces/json-rpc/JSONUtils.h @@ -483,7 +483,7 @@ namespace JSONRPC else xspObj["rules"] = filter; - CSmartPlaylist playlist; + KODI::PLAYLIST::CSmartPlaylist playlist; return playlist.Load(xspObj) && playlist.SaveAsJson(xsp, false); } }; diff --git a/xbmc/interfaces/json-rpc/PlayerOperations.cpp b/xbmc/interfaces/json-rpc/PlayerOperations.cpp index d48a9d33c8..62a95b947e 100644 --- a/xbmc/interfaces/json-rpc/PlayerOperations.cpp +++ b/xbmc/interfaces/json-rpc/PlayerOperations.cpp @@ -94,7 +94,7 @@ JSONRPC_STATUS CPlayerOperations::GetActivePlayers(const std::string &method, IT if (activePlayers & Video) { CVariant video = CVariant(CVariant::VariantTypeObject); - video["playerid"] = GetPlaylist(Video); + video["playerid"] = static_cast<int>(GetPlaylist(Video)); video["type"] = "video"; video["playertype"] = strPlayerType; result.append(video); @@ -102,7 +102,7 @@ JSONRPC_STATUS CPlayerOperations::GetActivePlayers(const std::string &method, IT if (activePlayers & Audio) { CVariant audio = CVariant(CVariant::VariantTypeObject); - audio["playerid"] = GetPlaylist(Audio); + audio["playerid"] = static_cast<int>(GetPlaylist(Audio)); audio["type"] = "audio"; audio["playertype"] = strPlayerType; result.append(audio); @@ -110,7 +110,7 @@ JSONRPC_STATUS CPlayerOperations::GetActivePlayers(const std::string &method, IT if (activePlayers & Picture) { CVariant picture = CVariant(CVariant::VariantTypeObject); - picture["playerid"] = GetPlaylist(Picture); + picture["playerid"] = static_cast<int>(GetPlaylist(Picture)); picture["type"] = "picture"; picture["playertype"] = "internal"; result.append(picture); @@ -800,9 +800,9 @@ JSONRPC_STATUS CPlayerOperations::Open(const std::string &method, ITransportLaye if (parameterObject["item"].isMember("playlistid")) { - PLAYLIST::Id playlistid = parameterObject["item"]["playlistid"].asInteger(); + PLAYLIST::Id playlistid = PLAYLIST::Id{parameterObject["item"]["playlistid"].asInteger32()}; - if (playlistid == PLAYLIST::TYPE_MUSIC || playlistid == PLAYLIST::TYPE_VIDEO) + if (playlistid == PLAYLIST::Id::TYPE_MUSIC || playlistid == PLAYLIST::Id::TYPE_VIDEO) { // Apply the "shuffled" option if available if (optionShuffled.isBoolean()) @@ -817,13 +817,13 @@ JSONRPC_STATUS CPlayerOperations::Open(const std::string &method, ITransportLaye switch (playlistid) { - case PLAYLIST::TYPE_MUSIC: - case PLAYLIST::TYPE_VIDEO: - CServiceBroker::GetAppMessenger()->PostMsg(TMSG_MEDIA_PLAY, playlistid, + case PLAYLIST::Id::TYPE_MUSIC: + case PLAYLIST::Id::TYPE_VIDEO: + CServiceBroker::GetAppMessenger()->PostMsg(TMSG_MEDIA_PLAY, static_cast<int>(playlistid), playlistStartPosition); break; - case PLAYLIST::TYPE_PICTURE: + case PLAYLIST::Id::TYPE_PICTURE: { std::string firstPicturePath; if (playlistStartPosition > 0) @@ -838,6 +838,8 @@ JSONRPC_STATUS CPlayerOperations::Open(const std::string &method, ITransportLaye return StartSlideshow("", false, optionShuffled.isBoolean() && optionShuffled.asBoolean(), firstPicturePath); break; } + default: + break; } return ACK; @@ -1094,7 +1096,8 @@ JSONRPC_STATUS CPlayerOperations::SetShuffle(const std::string &method, ITranspo if ((shuffle.isBoolean() && !shuffle.asBoolean()) || (shuffle.isString() && shuffle.asString() == "toggle")) { - CServiceBroker::GetAppMessenger()->SendMsg(TMSG_PLAYLISTPLAYER_SHUFFLE, playlistid, 0); + CServiceBroker::GetAppMessenger()->SendMsg(TMSG_PLAYLISTPLAYER_SHUFFLE, + static_cast<int>(playlistid), 0); } } else @@ -1102,7 +1105,8 @@ JSONRPC_STATUS CPlayerOperations::SetShuffle(const std::string &method, ITranspo if ((shuffle.isBoolean() && shuffle.asBoolean()) || (shuffle.isString() && shuffle.asString() == "toggle")) { - CServiceBroker::GetAppMessenger()->SendMsg(TMSG_PLAYLISTPLAYER_SHUFFLE, playlistid, 1); + CServiceBroker::GetAppMessenger()->SendMsg(TMSG_PLAYLISTPLAYER_SHUFFLE, + static_cast<int>(playlistid), 1); } } break; @@ -1162,8 +1166,8 @@ JSONRPC_STATUS CPlayerOperations::SetRepeat(const std::string &method, ITranspor else repeat = ParseRepeatState(parameterObject["repeat"]); - CServiceBroker::GetAppMessenger()->SendMsg(TMSG_PLAYLISTPLAYER_REPEAT, playlistid, - static_cast<int>(repeat)); + CServiceBroker::GetAppMessenger()->SendMsg( + TMSG_PLAYLISTPLAYER_REPEAT, static_cast<int>(playlistid), static_cast<int>(repeat)); break; } @@ -1440,20 +1444,20 @@ int CPlayerOperations::GetActivePlayers() PlayerType CPlayerOperations::GetPlayer(const CVariant &player) { - PLAYLIST::Id playerPlaylistId = player.asInteger(); + PLAYLIST::Id playerPlaylistId = PLAYLIST::Id{player.asInteger32()}; PlayerType playerID; switch (playerPlaylistId) { - case PLAYLIST::TYPE_VIDEO: + case PLAYLIST::Id::TYPE_VIDEO: playerID = Video; break; - case PLAYLIST::TYPE_MUSIC: + case PLAYLIST::Id::TYPE_MUSIC: playerID = Audio; break; - case PLAYLIST::TYPE_PICTURE: + case PLAYLIST::Id::TYPE_PICTURE: playerID = Picture; break; @@ -1471,7 +1475,7 @@ PlayerType CPlayerOperations::GetPlayer(const CVariant &player) PLAYLIST::Id CPlayerOperations::GetPlaylist(PlayerType player) { PLAYLIST::Id playlistId = CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist(); - if (playlistId == PLAYLIST::TYPE_NONE) // No active playlist, try guessing + if (playlistId == PLAYLIST::Id::TYPE_NONE) // No active playlist, try guessing { const auto& components = CServiceBroker::GetAppComponents(); const auto appPlayer = components.GetComponent<CApplicationPlayer>(); @@ -1481,13 +1485,13 @@ PLAYLIST::Id CPlayerOperations::GetPlaylist(PlayerType player) switch (player) { case Video: - return playlistId == PLAYLIST::TYPE_NONE ? PLAYLIST::TYPE_VIDEO : playlistId; + return playlistId == PLAYLIST::Id::TYPE_NONE ? PLAYLIST::Id::TYPE_VIDEO : playlistId; case Audio: - return playlistId == PLAYLIST::TYPE_NONE ? PLAYLIST::TYPE_MUSIC : playlistId; + return playlistId == PLAYLIST::Id::TYPE_NONE ? PLAYLIST::Id::TYPE_MUSIC : playlistId; case Picture: - return PLAYLIST::TYPE_PICTURE; + return PLAYLIST::Id::TYPE_PICTURE; default: return playlistId; @@ -1715,7 +1719,7 @@ JSONRPC_STATUS CPlayerOperations::GetPropertyValue(PlayerType player, const std: } else if (property == "playlistid") { - result = playlistId; + result = static_cast<int>(playlistId); } else if (property == "position") { diff --git a/xbmc/interfaces/json-rpc/PlayerOperations.h b/xbmc/interfaces/json-rpc/PlayerOperations.h index 0a537727ec..db422f40ce 100644 --- a/xbmc/interfaces/json-rpc/PlayerOperations.h +++ b/xbmc/interfaces/json-rpc/PlayerOperations.h @@ -21,9 +21,9 @@ class CPVRChannelGroup; class CPVREpgInfoTag; } -namespace PLAYLIST +namespace KODI::PLAYLIST { -using Id = int; +enum class Id; enum class RepeatState; } // namespace PLAYLIST @@ -88,12 +88,12 @@ namespace JSONRPC private: static int GetActivePlayers(); static PlayerType GetPlayer(const CVariant &player); - static PLAYLIST::Id GetPlaylist(PlayerType player); + static KODI::PLAYLIST::Id GetPlaylist(PlayerType player); static JSONRPC_STATUS StartSlideshow(const std::string& path, bool recursive, bool random, const std::string &firstPicturePath = ""); static void SendSlideshowAction(int actionID); static JSONRPC_STATUS GetPropertyValue(PlayerType player, const std::string &property, CVariant &result); - static PLAYLIST::RepeatState ParseRepeatState(const CVariant& repeat); + static KODI::PLAYLIST::RepeatState ParseRepeatState(const CVariant& repeat); static double ParseTimeInSeconds(const CVariant &time); static bool IsPVRChannel(); static std::shared_ptr<PVR::CPVREpgInfoTag> GetCurrentEpg(); diff --git a/xbmc/interfaces/json-rpc/PlaylistOperations.cpp b/xbmc/interfaces/json-rpc/PlaylistOperations.cpp index 49955bc68f..f98cf46c94 100644 --- a/xbmc/interfaces/json-rpc/PlaylistOperations.cpp +++ b/xbmc/interfaces/json-rpc/PlaylistOperations.cpp @@ -23,21 +23,22 @@ #include "utils/Variant.h" using namespace JSONRPC; +using namespace KODI; JSONRPC_STATUS CPlaylistOperations::GetPlaylists(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { result = CVariant(CVariant::VariantTypeArray); CVariant playlist = CVariant(CVariant::VariantTypeObject); - playlist["playlistid"] = PLAYLIST::TYPE_MUSIC; + playlist["playlistid"] = static_cast<int>(PLAYLIST::Id::TYPE_MUSIC); playlist["type"] = "audio"; result.append(playlist); - playlist["playlistid"] = PLAYLIST::TYPE_VIDEO; + playlist["playlistid"] = static_cast<int>(PLAYLIST::Id::TYPE_VIDEO); playlist["type"] = "video"; result.append(playlist); - playlist["playlistid"] = PLAYLIST::TYPE_PICTURE; + playlist["playlistid"] = static_cast<int>(PLAYLIST::Id::TYPE_PICTURE); playlist["type"] = "picture"; result.append(playlist); @@ -68,16 +69,21 @@ JSONRPC_STATUS CPlaylistOperations::GetItems(const std::string &method, ITranspo switch (playlistId) { - case PLAYLIST::TYPE_VIDEO: - case PLAYLIST::TYPE_MUSIC: - CServiceBroker::GetAppMessenger()->SendMsg(TMSG_PLAYLISTPLAYER_GET_ITEMS, playlistId, -1, + case PLAYLIST::Id::TYPE_VIDEO: + case PLAYLIST::Id::TYPE_MUSIC: + CServiceBroker::GetAppMessenger()->SendMsg(TMSG_PLAYLISTPLAYER_GET_ITEMS, + static_cast<int>(playlistId), -1, static_cast<void*>(&list)); break; - case PLAYLIST::TYPE_PICTURE: + case PLAYLIST::Id::TYPE_PICTURE: + { CSlideShowDelegator& slideShow = CServiceBroker::GetSlideShowDelegator(); slideShow.GetSlideShowContents(list); break; + } + default: + break; } HandleFileItemList("id", true, "items", list, parameterObject, result); @@ -89,11 +95,13 @@ bool CPlaylistOperations::CheckMediaParameter(PLAYLIST::Id playlistId, const CVa { if (itemObject.isMember("media") && itemObject["media"].asString().compare("files") != 0) { - if (playlistId == PLAYLIST::TYPE_VIDEO && itemObject["media"].asString().compare("video") != 0) + if (playlistId == PLAYLIST::Id::TYPE_VIDEO && + itemObject["media"].asString().compare("video") != 0) return false; - if (playlistId == PLAYLIST::TYPE_MUSIC && itemObject["media"].asString().compare("music") != 0) + if (playlistId == PLAYLIST::Id::TYPE_MUSIC && + itemObject["media"].asString().compare("music") != 0) return false; - if (playlistId == PLAYLIST::TYPE_PICTURE && + if (playlistId == PLAYLIST::Id::TYPE_PICTURE && itemObject["media"].asString().compare("video") != 0 && itemObject["media"].asString().compare("pictures") != 0) return false; @@ -111,16 +119,16 @@ JSONRPC_STATUS CPlaylistOperations::Add(const std::string &method, ITransportLay switch (playlistId) { - case PLAYLIST::TYPE_VIDEO: - case PLAYLIST::TYPE_MUSIC: + case PLAYLIST::Id::TYPE_VIDEO: + case PLAYLIST::Id::TYPE_MUSIC: { auto tmpList = new CFileItemList(); tmpList->Copy(list); - CServiceBroker::GetAppMessenger()->PostMsg(TMSG_PLAYLISTPLAYER_ADD, playlistId, -1, - static_cast<void*>(tmpList)); + CServiceBroker::GetAppMessenger()->PostMsg( + TMSG_PLAYLISTPLAYER_ADD, static_cast<int>(playlistId), -1, static_cast<void*>(tmpList)); break; } - case PLAYLIST::TYPE_PICTURE: + case PLAYLIST::Id::TYPE_PICTURE: { CSlideShowDelegator& slideShow = CServiceBroker::GetSlideShowDelegator(); for (int index = 0; index < list.Size(); index++) @@ -144,7 +152,7 @@ JSONRPC_STATUS CPlaylistOperations::Add(const std::string &method, ITransportLay JSONRPC_STATUS CPlaylistOperations::Insert(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { PLAYLIST::Id playlistId = GetPlaylist(parameterObject["playlistid"]); - if (playlistId == PLAYLIST::TYPE_PICTURE) + if (playlistId == PLAYLIST::Id::TYPE_PICTURE) return FailedToExecute; CFileItemList list; @@ -154,7 +162,7 @@ JSONRPC_STATUS CPlaylistOperations::Insert(const std::string &method, ITransport auto tmpList = new CFileItemList(); tmpList->Copy(list); CServiceBroker::GetAppMessenger()->PostMsg( - TMSG_PLAYLISTPLAYER_INSERT, playlistId, + TMSG_PLAYLISTPLAYER_INSERT, static_cast<int>(playlistId), static_cast<int>(parameterObject["position"].asInteger()), static_cast<void*>(tmpList)); return ACK; @@ -163,7 +171,7 @@ JSONRPC_STATUS CPlaylistOperations::Insert(const std::string &method, ITransport JSONRPC_STATUS CPlaylistOperations::Remove(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { PLAYLIST::Id playlistId = GetPlaylist(parameterObject["playlistid"]); - if (playlistId == PLAYLIST::TYPE_PICTURE) + if (playlistId == PLAYLIST::Id::TYPE_PICTURE) return FailedToExecute; int position = (int)parameterObject["position"].asInteger(); @@ -171,7 +179,8 @@ JSONRPC_STATUS CPlaylistOperations::Remove(const std::string &method, ITransport CServiceBroker::GetPlaylistPlayer().GetCurrentItemIdx() == position) return InvalidParams; - CServiceBroker::GetAppMessenger()->PostMsg(TMSG_PLAYLISTPLAYER_REMOVE, playlistId, position); + CServiceBroker::GetAppMessenger()->PostMsg(TMSG_PLAYLISTPLAYER_REMOVE, + static_cast<int>(playlistId), position); return ACK; } @@ -181,18 +190,23 @@ JSONRPC_STATUS CPlaylistOperations::Clear(const std::string &method, ITransportL PLAYLIST::Id playlistId = GetPlaylist(parameterObject["playlistid"]); switch (playlistId) { - case PLAYLIST::TYPE_MUSIC: - case PLAYLIST::TYPE_VIDEO: - CServiceBroker::GetAppMessenger()->PostMsg(TMSG_PLAYLISTPLAYER_CLEAR, playlistId); + case PLAYLIST::Id::TYPE_MUSIC: + case PLAYLIST::Id::TYPE_VIDEO: + CServiceBroker::GetAppMessenger()->PostMsg(TMSG_PLAYLISTPLAYER_CLEAR, + static_cast<int>(playlistId)); break; - case PLAYLIST::TYPE_PICTURE: + case PLAYLIST::Id::TYPE_PICTURE: + { CSlideShowDelegator& slideShow = CServiceBroker::GetSlideShowDelegator(); //! @todo: Stop should be a delegator method to void GUI coupling! Same goes for other player controls. CServiceBroker::GetAppMessenger()->PostMsg(TMSG_GUI_ACTION, WINDOW_SLIDESHOW, -1, static_cast<void*>(new CAction(ACTION_STOP))); slideShow.Reset(); break; + } + default: + break; } return ACK; @@ -201,25 +215,26 @@ JSONRPC_STATUS CPlaylistOperations::Clear(const std::string &method, ITransportL JSONRPC_STATUS CPlaylistOperations::Swap(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { PLAYLIST::Id playlistId = GetPlaylist(parameterObject["playlistid"]); - if (playlistId == PLAYLIST::TYPE_PICTURE) + if (playlistId == PLAYLIST::Id::TYPE_PICTURE) return FailedToExecute; auto tmpVec = new std::vector<int>(); tmpVec->push_back(static_cast<int>(parameterObject["position1"].asInteger())); tmpVec->push_back(static_cast<int>(parameterObject["position2"].asInteger())); - CServiceBroker::GetAppMessenger()->PostMsg(TMSG_PLAYLISTPLAYER_SWAP, playlistId, -1, - static_cast<void*>(tmpVec)); + CServiceBroker::GetAppMessenger()->PostMsg(TMSG_PLAYLISTPLAYER_SWAP, static_cast<int>(playlistId), + -1, static_cast<void*>(tmpVec)); return ACK; } PLAYLIST::Id CPlaylistOperations::GetPlaylist(const CVariant& playlist) { - PLAYLIST::Id playlistId = playlist.asInteger(PLAYLIST::TYPE_NONE); - if (playlistId != PLAYLIST::TYPE_NONE) + PLAYLIST::Id playlistId = + PLAYLIST::Id{playlist.asInteger32(static_cast<int>(PLAYLIST::Id::TYPE_NONE))}; + if (playlistId != PLAYLIST::Id::TYPE_NONE) return playlistId; - return PLAYLIST::TYPE_NONE; + return PLAYLIST::Id::TYPE_NONE; } JSONRPC_STATUS CPlaylistOperations::GetPropertyValue(PLAYLIST::Id playlistId, @@ -230,15 +245,15 @@ JSONRPC_STATUS CPlaylistOperations::GetPropertyValue(PLAYLIST::Id playlistId, { switch (playlistId) { - case PLAYLIST::TYPE_MUSIC: + case PLAYLIST::Id::TYPE_MUSIC: result = "audio"; break; - case PLAYLIST::TYPE_VIDEO: + case PLAYLIST::Id::TYPE_VIDEO: result = "video"; break; - case PLAYLIST::TYPE_PICTURE: + case PLAYLIST::Id::TYPE_PICTURE: result = "pictures"; break; @@ -252,15 +267,16 @@ JSONRPC_STATUS CPlaylistOperations::GetPropertyValue(PLAYLIST::Id playlistId, CFileItemList list; switch (playlistId) { - case PLAYLIST::TYPE_MUSIC: - case PLAYLIST::TYPE_VIDEO: + case PLAYLIST::Id::TYPE_MUSIC: + case PLAYLIST::Id::TYPE_VIDEO: { - CServiceBroker::GetAppMessenger()->SendMsg(TMSG_PLAYLISTPLAYER_GET_ITEMS, playlistId, -1, + CServiceBroker::GetAppMessenger()->SendMsg(TMSG_PLAYLISTPLAYER_GET_ITEMS, + static_cast<int>(playlistId), -1, static_cast<void*>(&list)); result = list.Size(); break; } - case PLAYLIST::TYPE_PICTURE: + case PLAYLIST::Id::TYPE_PICTURE: { CSlideShowDelegator& slideShow = CServiceBroker::GetSlideShowDelegator(); const int numSlides = slideShow.NumSlides(); @@ -301,15 +317,17 @@ bool CPlaylistOperations::HandleItemsParameter(PLAYLIST::Id playlistId, switch (playlistId) { - case PLAYLIST::TYPE_VIDEO: + case PLAYLIST::Id::TYPE_VIDEO: itemIt["media"] = "video"; break; - case PLAYLIST::TYPE_MUSIC: + case PLAYLIST::Id::TYPE_MUSIC: itemIt["media"] = "music"; break; - case PLAYLIST::TYPE_PICTURE: + case PLAYLIST::Id::TYPE_PICTURE: itemIt["media"] = "pictures"; break; + default: + break; } success |= FillFileItemList(itemIt, items); diff --git a/xbmc/interfaces/json-rpc/PlaylistOperations.h b/xbmc/interfaces/json-rpc/PlaylistOperations.h index a6a6f83c7e..881d5823b3 100644 --- a/xbmc/interfaces/json-rpc/PlaylistOperations.h +++ b/xbmc/interfaces/json-rpc/PlaylistOperations.h @@ -14,10 +14,10 @@ class CFileItemList; class CVariant; -namespace PLAYLIST +namespace KODI::PLAYLIST { -using Id = int; -} // namespace PLAYLIST +enum class Id; +} // namespace KODI::PLAYLIST namespace JSONRPC { @@ -34,12 +34,12 @@ namespace JSONRPC static JSONRPC_STATUS Clear(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result); static JSONRPC_STATUS Swap(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result); private: - static PLAYLIST::Id GetPlaylist(const CVariant& playlist); - static JSONRPC_STATUS GetPropertyValue(PLAYLIST::Id playlistId, + static KODI::PLAYLIST::Id GetPlaylist(const CVariant& playlist); + static JSONRPC_STATUS GetPropertyValue(KODI::PLAYLIST::Id playlistId, const std::string& property, CVariant& result); - static bool CheckMediaParameter(PLAYLIST::Id playlistId, const CVariant& itemObject); - static bool HandleItemsParameter(PLAYLIST::Id playlistId, + static bool CheckMediaParameter(KODI::PLAYLIST::Id playlistId, const CVariant& itemObject); + static bool HandleItemsParameter(KODI::PLAYLIST::Id playlistId, const CVariant& itemParam, CFileItemList& items); }; diff --git a/xbmc/interfaces/legacy/ModuleXbmc.cpp b/xbmc/interfaces/legacy/ModuleXbmc.cpp index 290d575359..de752344d7 100644 --- a/xbmc/interfaces/legacy/ModuleXbmc.cpp +++ b/xbmc/interfaces/legacy/ModuleXbmc.cpp @@ -578,11 +578,11 @@ namespace XBMCAddon int getPLAYLIST_MUSIC() { - return PLAYLIST::TYPE_MUSIC; + return static_cast<int>(PLAYLIST::Id::TYPE_MUSIC); } int getPLAYLIST_VIDEO() { - return PLAYLIST::TYPE_VIDEO; + return static_cast<int>(PLAYLIST::Id::TYPE_VIDEO); } int getTRAY_OPEN() { diff --git a/xbmc/interfaces/legacy/PlayList.cpp b/xbmc/interfaces/legacy/PlayList.cpp index 649bc89892..076e1928b1 100644 --- a/xbmc/interfaces/legacy/PlayList.cpp +++ b/xbmc/interfaces/legacy/PlayList.cpp @@ -14,6 +14,8 @@ #include "playlists/PlayListFactory.h" #include "utils/URIUtils.h" +using namespace KODI; + namespace XBMCAddon { namespace xbmc @@ -24,10 +26,11 @@ namespace XBMCAddon iPlayList(playList), pPlayList(NULL) { // we do not create our own playlist, just using the ones from playlistplayer - if (iPlayList != PLAYLIST::TYPE_MUSIC && iPlayList != PLAYLIST::TYPE_VIDEO) + if (PLAYLIST::Id{iPlayList} != PLAYLIST::Id::TYPE_MUSIC && + PLAYLIST::Id{iPlayList} != PLAYLIST::Id::TYPE_VIDEO) throw PlayListException("PlayList does not exist"); - pPlayList = &CServiceBroker::GetPlaylistPlayer().GetPlaylist(playList); + pPlayList = &CServiceBroker::GetPlaylistPlayer().GetPlaylist(PLAYLIST::Id{playList}); iPlayList = playList; } @@ -76,7 +79,7 @@ namespace XBMCAddon return false; // clear current playlist - CServiceBroker::GetPlaylistPlayer().ClearPlaylist(this->iPlayList); + CServiceBroker::GetPlaylistPlayer().ClearPlaylist(PLAYLIST::Id{this->iPlayList}); // add each item of the playlist to the playlistplayer for (int i=0; i < pPlayList->size(); ++i) diff --git a/xbmc/interfaces/legacy/PlayList.h b/xbmc/interfaces/legacy/PlayList.h index 6162945d2b..38471c48ab 100644 --- a/xbmc/interfaces/legacy/PlayList.h +++ b/xbmc/interfaces/legacy/PlayList.h @@ -49,7 +49,7 @@ namespace XBMCAddon class PlayList : public AddonClass { int iPlayList; - PLAYLIST::CPlayList *pPlayList; + KODI::PLAYLIST::CPlayList* pPlayList; public: explicit PlayList(int playList); diff --git a/xbmc/interfaces/legacy/Player.cpp b/xbmc/interfaces/legacy/Player.cpp index b3aff2dfd5..b6af4959ed 100644 --- a/xbmc/interfaces/legacy/Player.cpp +++ b/xbmc/interfaces/legacy/Player.cpp @@ -25,6 +25,8 @@ #include "messaging/ApplicationMessenger.h" #include "settings/MediaSettings.h" +using namespace KODI; + namespace { @@ -48,19 +50,19 @@ namespace XBMCAddon { namespace xbmc { - PlayParameter Player::defaultPlayParameter; + PlayParameter Player::defaultPlayParameter; - Player::Player() - { - iPlayList = PLAYLIST::TYPE_MUSIC; + Player::Player() + { + iPlayList = static_cast<int>(PLAYLIST::Id::TYPE_MUSIC); - // now that we're done, register hook me into the system - if (languageHook) - { - DelayedCallGuard dc(languageHook); - languageHook->RegisterPlayerCallback(this); - } + // now that we're done, register hook me into the system + if (languageHook) + { + DelayedCallGuard dc(languageHook); + languageHook->RegisterPlayerCallback(this); } + } Player::~Player() { @@ -125,8 +127,8 @@ namespace XBMCAddon CMediaSettings::GetInstance().SetMediaStartWindowed(windowed); // play current file in playlist - if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() != iPlayList) - CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(iPlayList); + if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() != PLAYLIST::Id{iPlayList}) + CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::Id{iPlayList}); CServiceBroker::GetAppMessenger()->SendMsg( TMSG_PLAYLISTPLAYER_PLAY, CServiceBroker::GetPlaylistPlayer().GetCurrentItemIdx()); } @@ -142,7 +144,7 @@ namespace XBMCAddon // play a python playlist (a playlist from playlistplayer.cpp) iPlayList = playlist->getPlayListId(); - CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(iPlayList); + CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::Id{iPlayList}); if (startpos > -1) CServiceBroker::GetPlaylistPlayer().SetCurrentItemIdx(startpos); CServiceBroker::GetAppMessenger()->SendMsg(TMSG_PLAYLISTPLAYER_PLAY, startpos); @@ -184,9 +186,9 @@ namespace XBMCAddon XBMC_TRACE; DelayedCallGuard dc(languageHook); - if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() != iPlayList) + if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() != PLAYLIST::Id{iPlayList}) { - CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(iPlayList); + CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::Id{iPlayList}); } CServiceBroker::GetPlaylistPlayer().SetCurrentItemIdx(selected); diff --git a/xbmc/music/ContextMenus.cpp b/xbmc/music/ContextMenus.cpp index 22df28acd2..56e53eb9c9 100644 --- a/xbmc/music/ContextMenus.cpp +++ b/xbmc/music/ContextMenus.cpp @@ -81,7 +81,7 @@ namespace { void Play(const std::shared_ptr<CFileItem>& item, const std::string& player) { - item->SetProperty("playlist_type_hint", PLAYLIST::TYPE_MUSIC); + item->SetProperty("playlist_type_hint", static_cast<int>(PLAYLIST::Id::TYPE_MUSIC)); const ContentUtils::PlayMode mode = item->GetProperty("CheckAutoPlayNextItem").asBoolean() ? ContentUtils::PlayMode::CHECK_AUTO_PLAY_NEXT_ITEM diff --git a/xbmc/music/GUIViewStateMusic.cpp b/xbmc/music/GUIViewStateMusic.cpp index a34d9170a2..5d43691b4d 100644 --- a/xbmc/music/GUIViewStateMusic.cpp +++ b/xbmc/music/GUIViewStateMusic.cpp @@ -33,7 +33,7 @@ using namespace MUSICDATABASEDIRECTORY; PLAYLIST::Id CGUIViewStateWindowMusic::GetPlaylist() const { - return PLAYLIST::TYPE_MUSIC; + return PLAYLIST::Id::TYPE_MUSIC; } bool CGUIViewStateWindowMusic::AutoPlayNextItem() @@ -625,7 +625,7 @@ void CGUIViewStateWindowMusicPlaylist::SaveViewState() PLAYLIST::Id CGUIViewStateWindowMusicPlaylist::GetPlaylist() const { - return PLAYLIST::TYPE_MUSIC; + return PLAYLIST::Id::TYPE_MUSIC; } bool CGUIViewStateWindowMusicPlaylist::AutoPlayNextItem() diff --git a/xbmc/music/GUIViewStateMusic.h b/xbmc/music/GUIViewStateMusic.h index 7f7311a8e7..59e21d4d84 100644 --- a/xbmc/music/GUIViewStateMusic.h +++ b/xbmc/music/GUIViewStateMusic.h @@ -16,7 +16,7 @@ public: explicit CGUIViewStateWindowMusic(const CFileItemList& items) : CGUIViewState(items) {} protected: VECSOURCES& GetSources() override; - PLAYLIST::Id GetPlaylist() const override; + KODI::PLAYLIST::Id GetPlaylist() const override; bool AutoPlayNextItem() override; std::string GetLockType() override; std::string GetExtensions() override; @@ -78,7 +78,7 @@ public: protected: void SaveViewState() override; - PLAYLIST::Id GetPlaylist() const override; + KODI::PLAYLIST::Id GetPlaylist() const override; bool AutoPlayNextItem() override; bool HideParentDirItems() override; VECSOURCES& GetSources() override; diff --git a/xbmc/music/MusicDatabase.cpp b/xbmc/music/MusicDatabase.cpp index a98db00388..f09351b5fb 100644 --- a/xbmc/music/MusicDatabase.cpp +++ b/xbmc/music/MusicDatabase.cpp @@ -64,6 +64,7 @@ #include <inttypes.h> +using namespace KODI; using namespace XFILE; using namespace MUSICDATABASEDIRECTORY; using namespace KODI::MESSAGING; @@ -13287,7 +13288,7 @@ bool CMusicDatabase::GetFilter(CDbUrl& musicUrl, Filter& filter, SortDescription auto option = options.find("xsp"); if (option != options.end()) { - CSmartPlaylist xsp; + PLAYLIST::CSmartPlaylist xsp; if (!xsp.LoadFromJson(option->second.asString())) return false; @@ -13870,7 +13871,7 @@ bool CMusicDatabase::GetFilter(CDbUrl& musicUrl, Filter& filter, SortDescription option = options.find("filter"); if (option != options.end()) { - CSmartPlaylist xspFilter; + PLAYLIST::CSmartPlaylist xspFilter; if (!xspFilter.LoadFromJson(option->second.asString())) return false; diff --git a/xbmc/music/MusicDbUrl.cpp b/xbmc/music/MusicDbUrl.cpp index 3b4893bc18..c11ac931fb 100644 --- a/xbmc/music/MusicDbUrl.cpp +++ b/xbmc/music/MusicDbUrl.cpp @@ -13,6 +13,7 @@ #include "utils/StringUtils.h" #include "utils/Variant.h" +using namespace KODI; using namespace XFILE; using namespace XFILE::MUSICDATABASEDIRECTORY; @@ -161,7 +162,7 @@ bool CMusicDbUrl::validateOption(const std::string &key, const CVariant &value) if (!value.isString()) return false; - CSmartPlaylist xspFilter; + PLAYLIST::CSmartPlaylist xspFilter; if (!xspFilter.LoadFromJson(value.asString())) return false; diff --git a/xbmc/music/MusicUtils.cpp b/xbmc/music/MusicUtils.cpp index c3e6b71625..5434688a8c 100644 --- a/xbmc/music/MusicUtils.cpp +++ b/xbmc/music/MusicUtils.cpp @@ -140,7 +140,7 @@ public: */ bool clearcache(false); const PLAYLIST::CPlayList& playlist = - CServiceBroker::GetPlaylistPlayer().GetPlaylist(PLAYLIST::TYPE_MUSIC); + CServiceBroker::GetPlaylistPlayer().GetPlaylist(PLAYLIST::Id::TYPE_MUSIC); for (int i = 0; i < playlist.size(); ++i) { @@ -669,12 +669,12 @@ void AddItemToPlayListAndPlay(const std::shared_ptr<CFileItem>& itemToQueue, MUSIC_UTILS::GetItemsForPlayList(itemToQueue, queuedItems); auto& playlistPlayer = CServiceBroker::GetPlaylistPlayer(); - playlistPlayer.ClearPlaylist(PLAYLIST::TYPE_MUSIC); + playlistPlayer.ClearPlaylist(PLAYLIST::Id::TYPE_MUSIC); playlistPlayer.Reset(); - playlistPlayer.Add(PLAYLIST::TYPE_MUSIC, queuedItems); + playlistPlayer.Add(PLAYLIST::Id::TYPE_MUSIC, queuedItems); // figure out where to start playback - PLAYLIST::CPlayList& playList = playlistPlayer.GetPlaylist(PLAYLIST::TYPE_MUSIC); + PLAYLIST::CPlayList& playList = playlistPlayer.GetPlaylist(PLAYLIST::Id::TYPE_MUSIC); int pos = 0; if (itemToPlay) { @@ -687,13 +687,13 @@ void AddItemToPlayListAndPlay(const std::shared_ptr<CFileItem>& itemToQueue, } } - if (playlistPlayer.IsShuffled(PLAYLIST::TYPE_MUSIC)) + if (playlistPlayer.IsShuffled(PLAYLIST::Id::TYPE_MUSIC)) { playList.Swap(0, playList.FindOrder(pos)); pos = 0; } - playlistPlayer.SetCurrentPlaylist(PLAYLIST::TYPE_MUSIC); + playlistPlayer.SetCurrentPlaylist(PLAYLIST::Id::TYPE_MUSIC); playlistPlayer.Play(pos, player); } } // unnamed namespace @@ -763,7 +763,7 @@ void PlayItem(const std::shared_ptr<CFileItem>& itemIn, // song, so just play it auto& playlistPlayer = CServiceBroker::GetPlaylistPlayer(); playlistPlayer.Reset(); - playlistPlayer.SetCurrentPlaylist(PLAYLIST::TYPE_NONE); + playlistPlayer.SetCurrentPlaylist(PLAYLIST::Id::TYPE_NONE); playlistPlayer.Play(item, player); } } @@ -785,14 +785,14 @@ void QueueItem(const std::shared_ptr<CFileItem>& itemIn, QueuePosition pos) auto& player = CServiceBroker::GetPlaylistPlayer(); PLAYLIST::Id playlistId = player.GetCurrentPlaylist(); - if (playlistId == PLAYLIST::TYPE_NONE) + if (playlistId == PLAYLIST::Id::TYPE_NONE) { const auto& components = CServiceBroker::GetAppComponents(); playlistId = components.GetComponent<CApplicationPlayer>()->GetPreferredPlaylist(); } - if (playlistId == PLAYLIST::TYPE_NONE) - playlistId = PLAYLIST::TYPE_MUSIC; + if (playlistId == PLAYLIST::Id::TYPE_NONE) + playlistId = PLAYLIST::Id::TYPE_MUSIC; // Check for the partymode playlist item, do nothing when "PartyMode.xsp" not exists if (item->IsSmartPlayList() && !CFileUtils::Exists(item->GetPath())) diff --git a/xbmc/music/windows/GUIWindowMusicBase.cpp b/xbmc/music/windows/GUIWindowMusicBase.cpp index 5ace8dcfe4..7bef12c9c0 100644 --- a/xbmc/music/windows/GUIWindowMusicBase.cpp +++ b/xbmc/music/windows/GUIWindowMusicBase.cpp @@ -257,8 +257,8 @@ bool CGUIWindowMusicBase::OnAction(const CAction &action) { if (action.GetID() == ACTION_SHOW_PLAYLIST) { - if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::TYPE_MUSIC || - CServiceBroker::GetPlaylistPlayer().GetPlaylist(PLAYLIST::TYPE_MUSIC).size() > 0) + if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::Id::TYPE_MUSIC || + CServiceBroker::GetPlaylistPlayer().GetPlaylist(PLAYLIST::Id::TYPE_MUSIC).size() > 0) { CServiceBroker::GetGUI()->GetWindowManager().ActivateWindow(WINDOW_MUSIC_PLAYLIST); return true; @@ -647,10 +647,10 @@ void CGUIWindowMusicBase::PlayItem(int iItem) URIUtils::RemoveSlashAtEnd(strPlayListDirectory); */ - CServiceBroker::GetPlaylistPlayer().ClearPlaylist(PLAYLIST::TYPE_MUSIC); + CServiceBroker::GetPlaylistPlayer().ClearPlaylist(PLAYLIST::Id::TYPE_MUSIC); CServiceBroker::GetPlaylistPlayer().Reset(); - CServiceBroker::GetPlaylistPlayer().Add(PLAYLIST::TYPE_MUSIC, queuedItems); - CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::TYPE_MUSIC); + CServiceBroker::GetPlaylistPlayer().Add(PLAYLIST::Id::TYPE_MUSIC, queuedItems); + CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::Id::TYPE_MUSIC); // play! CServiceBroker::GetPlaylistPlayer().Play(); @@ -688,7 +688,7 @@ void CGUIWindowMusicBase::LoadPlayList(const std::string& strPlayList) } int iSize = pPlayList->size(); - if (g_application.ProcessAndStartPlaylist(strPlayList, *pPlayList, PLAYLIST::TYPE_MUSIC)) + if (g_application.ProcessAndStartPlaylist(strPlayList, *pPlayList, PLAYLIST::Id::TYPE_MUSIC)) { if (m_guiState) m_guiState->SetPlaylistDirectory("playlistmusic://"); @@ -722,7 +722,7 @@ bool CGUIWindowMusicBase::OnPlayMedia(int iItem, const std::string &player) OnQueueItem(iItem); return true; } - pItem->SetProperty("playlist_type_hint", m_guiState->GetPlaylist()); + pItem->SetProperty("playlist_type_hint", static_cast<int>(m_guiState->GetPlaylist())); CServiceBroker::GetPlaylistPlayer().Play(pItem, player); return true; } diff --git a/xbmc/music/windows/GUIWindowMusicNav.cpp b/xbmc/music/windows/GUIWindowMusicNav.cpp index 46e1fab725..b54eb59e93 100644 --- a/xbmc/music/windows/GUIWindowMusicNav.cpp +++ b/xbmc/music/windows/GUIWindowMusicNav.cpp @@ -54,7 +54,6 @@ #include "view/GUIViewState.h" using namespace XFILE; -using namespace PLAYLIST; using namespace MUSICDATABASEDIRECTORY; using namespace KODI; using namespace KODI::MESSAGING; @@ -864,7 +863,7 @@ bool CGUIWindowMusicNav::GetSongsFromPlayList(const std::string& strPlayList, CF items.SetPath(strPlayList); CLog::Log(LOGDEBUG, "CGUIWindowMusicNav, opening playlist [{}]", strPlayList); - std::unique_ptr<CPlayList> pPlayList (CPlayListFactory::Create(strPlayList)); + std::unique_ptr<PLAYLIST::CPlayList> pPlayList(PLAYLIST::CPlayListFactory::Create(strPlayList)); if (nullptr != pPlayList) { // load it @@ -873,7 +872,7 @@ bool CGUIWindowMusicNav::GetSongsFromPlayList(const std::string& strPlayList, CF HELPERS::ShowOKDialogText(CVariant{6}, CVariant{477}); return false; //hmmm unable to load playlist? } - CPlayList playlist = *pPlayList; + PLAYLIST::CPlayList playlist = *pPlayList; // convert playlist items to songs for (int i = 0; i < playlist.size(); ++i) { diff --git a/xbmc/music/windows/GUIWindowMusicPlaylist.cpp b/xbmc/music/windows/GUIWindowMusicPlaylist.cpp index 92578e88be..d28169fa34 100644 --- a/xbmc/music/windows/GUIWindowMusicPlaylist.cpp +++ b/xbmc/music/windows/GUIWindowMusicPlaylist.cpp @@ -126,7 +126,7 @@ bool CGUIWindowMusicPlayList::OnMessage(CGUIMessage& message) const auto& components = CServiceBroker::GetAppComponents(); const auto appPlayer = components.GetComponent<CApplicationPlayer>(); if (appPlayer->IsPlayingAudio() && - CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::TYPE_MUSIC) + CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::Id::TYPE_MUSIC) { int iSong = CServiceBroker::GetPlaylistPlayer().GetCurrentItemIdx(); if (iSong >= 0 && iSong <= m_vecItems->Size()) @@ -145,10 +145,10 @@ bool CGUIWindowMusicPlayList::OnMessage(CGUIMessage& message) if (!g_partyModeManager.IsEnabled()) { CServiceBroker::GetPlaylistPlayer().SetShuffle( - PLAYLIST::TYPE_MUSIC, - !(CServiceBroker::GetPlaylistPlayer().IsShuffled(PLAYLIST::TYPE_MUSIC))); + PLAYLIST::Id::TYPE_MUSIC, + !(CServiceBroker::GetPlaylistPlayer().IsShuffled(PLAYLIST::Id::TYPE_MUSIC))); CMediaSettings::GetInstance().SetMusicPlaylistShuffled( - CServiceBroker::GetPlaylistPlayer().IsShuffled(PLAYLIST::TYPE_MUSIC)); + CServiceBroker::GetPlaylistPlayer().IsShuffled(PLAYLIST::Id::TYPE_MUSIC)); CServiceBroker::GetSettingsComponent()->GetSettings()->Save(); UpdateButtons(); Refresh(); @@ -171,39 +171,39 @@ bool CGUIWindowMusicPlayList::OnMessage(CGUIMessage& message) else if (iControl == CONTROL_BTNPLAY) { m_guiState->SetPlaylistDirectory("playlistmusic://"); - CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::TYPE_MUSIC); + CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::Id::TYPE_MUSIC); CServiceBroker::GetPlaylistPlayer().Reset(); CServiceBroker::GetPlaylistPlayer().Play(m_viewControl.GetSelectedItem(), ""); UpdateButtons(); } else if (iControl == CONTROL_BTNNEXT) { - CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::TYPE_MUSIC); + CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::Id::TYPE_MUSIC); CServiceBroker::GetPlaylistPlayer().PlayNext(); } else if (iControl == CONTROL_BTNPREVIOUS) { - CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::TYPE_MUSIC); + CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::Id::TYPE_MUSIC); CServiceBroker::GetPlaylistPlayer().PlayPrevious(); } else if (iControl == CONTROL_BTNREPEAT) { // increment repeat state PLAYLIST::RepeatState state = - CServiceBroker::GetPlaylistPlayer().GetRepeat(PLAYLIST::TYPE_MUSIC); + CServiceBroker::GetPlaylistPlayer().GetRepeat(PLAYLIST::Id::TYPE_MUSIC); if (state == PLAYLIST::RepeatState::NONE) - CServiceBroker::GetPlaylistPlayer().SetRepeat(PLAYLIST::TYPE_MUSIC, + CServiceBroker::GetPlaylistPlayer().SetRepeat(PLAYLIST::Id::TYPE_MUSIC, PLAYLIST::RepeatState::ALL); else if (state == PLAYLIST::RepeatState::ALL) - CServiceBroker::GetPlaylistPlayer().SetRepeat(PLAYLIST::TYPE_MUSIC, + CServiceBroker::GetPlaylistPlayer().SetRepeat(PLAYLIST::Id::TYPE_MUSIC, PLAYLIST::RepeatState::ONE); else - CServiceBroker::GetPlaylistPlayer().SetRepeat(PLAYLIST::TYPE_MUSIC, + CServiceBroker::GetPlaylistPlayer().SetRepeat(PLAYLIST::Id::TYPE_MUSIC, PLAYLIST::RepeatState::NONE); // save settings CMediaSettings::GetInstance().SetMusicPlaylistRepeat( - CServiceBroker::GetPlaylistPlayer().GetRepeat(PLAYLIST::TYPE_MUSIC) == + CServiceBroker::GetPlaylistPlayer().GetRepeat(PLAYLIST::Id::TYPE_MUSIC) == PLAYLIST::RepeatState::ALL); CServiceBroker::GetSettingsComponent()->GetSettings()->Save(); @@ -274,14 +274,14 @@ bool CGUIWindowMusicPlayList::MoveCurrentPlayListItem(int iItem, // is the currently playing item affected? bool bFixCurrentSong = false; - if ((CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::TYPE_MUSIC) && + if ((CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::Id::TYPE_MUSIC) && appPlayer->IsPlayingAudio() && ((CServiceBroker::GetPlaylistPlayer().GetCurrentItemIdx() == iSelected) || (CServiceBroker::GetPlaylistPlayer().GetCurrentItemIdx() == iNew))) bFixCurrentSong = true; PLAYLIST::CPlayList& playlist = - CServiceBroker::GetPlaylistPlayer().GetPlaylist(PLAYLIST::TYPE_MUSIC); + CServiceBroker::GetPlaylistPlayer().GetPlaylist(PLAYLIST::Id::TYPE_MUSIC); if (playlist.Swap(iSelected, iNew)) { // Correct the current playing song in playlistplayer @@ -353,11 +353,11 @@ void CGUIWindowMusicPlayList::SavePlayList() void CGUIWindowMusicPlayList::ClearPlayList() { ClearFileItems(); - CServiceBroker::GetPlaylistPlayer().ClearPlaylist(PLAYLIST::TYPE_MUSIC); - if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::TYPE_MUSIC) + CServiceBroker::GetPlaylistPlayer().ClearPlaylist(PLAYLIST::Id::TYPE_MUSIC); + if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::Id::TYPE_MUSIC) { CServiceBroker::GetPlaylistPlayer().Reset(); - CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::TYPE_NONE); + CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::Id::TYPE_NONE); } Refresh(); SET_CONTROL_FOCUS(CONTROL_BTNVIEWASICONS, 0); @@ -371,12 +371,12 @@ void CGUIWindowMusicPlayList::RemovePlayListItem(int iItem) const auto& components = CServiceBroker::GetAppComponents(); const auto appPlayer = components.GetComponent<CApplicationPlayer>(); // The current playing song can't be removed - if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::TYPE_MUSIC && + if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::Id::TYPE_MUSIC && appPlayer->IsPlayingAudio() && CServiceBroker::GetPlaylistPlayer().GetCurrentItemIdx() == iItem) return; - CServiceBroker::GetPlaylistPlayer().Remove(PLAYLIST::TYPE_MUSIC, iItem); + CServiceBroker::GetPlaylistPlayer().Remove(PLAYLIST::Id::TYPE_MUSIC, iItem); Refresh(); @@ -408,7 +408,7 @@ void CGUIWindowMusicPlayList::UpdateButtons() const auto& components = CServiceBroker::GetAppComponents(); const auto appPlayer = components.GetComponent<CApplicationPlayer>(); if (appPlayer->IsPlayingAudio() && - CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::TYPE_MUSIC) + CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::Id::TYPE_MUSIC) { CONTROL_ENABLE(CONTROL_BTNNEXT); CONTROL_ENABLE(CONTROL_BTNPREVIOUS); @@ -433,13 +433,13 @@ void CGUIWindowMusicPlayList::UpdateButtons() // update buttons CONTROL_DESELECT(CONTROL_BTNSHUFFLE); - if (CServiceBroker::GetPlaylistPlayer().IsShuffled(PLAYLIST::TYPE_MUSIC)) + if (CServiceBroker::GetPlaylistPlayer().IsShuffled(PLAYLIST::Id::TYPE_MUSIC)) CONTROL_SELECT(CONTROL_BTNSHUFFLE); // update repeat button int iLocalizedString; PLAYLIST::RepeatState repState = - CServiceBroker::GetPlaylistPlayer().GetRepeat(PLAYLIST::TYPE_MUSIC); + CServiceBroker::GetPlaylistPlayer().GetRepeat(PLAYLIST::Id::TYPE_MUSIC); if (repState == PLAYLIST::RepeatState::NONE) iLocalizedString = 595; // Repeat: Off else if (repState == PLAYLIST::RepeatState::ONE) @@ -464,7 +464,7 @@ bool CGUIWindowMusicPlayList::OnPlayMedia(int iItem, const std::string& player) else { PLAYLIST::Id playlistId = m_guiState->GetPlaylist(); - if (playlistId != PLAYLIST::TYPE_NONE) + if (playlistId != PLAYLIST::Id::TYPE_NONE) { if (m_guiState) m_guiState->SetPlaylistDirectory(m_vecItems->GetPath()); @@ -478,7 +478,7 @@ bool CGUIWindowMusicPlayList::OnPlayMedia(int iItem, const std::string& player) // not use the playlistplayer. CFileItemPtr pItem = m_vecItems->Get(iItem); CServiceBroker::GetPlaylistPlayer().Reset(); - CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::TYPE_NONE); + CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::Id::TYPE_NONE); g_application.PlayFile(*pItem, player); } } diff --git a/xbmc/music/windows/GUIWindowMusicPlaylistEditor.cpp b/xbmc/music/windows/GUIWindowMusicPlaylistEditor.cpp index 16ecdd0c3c..6d3d790898 100644 --- a/xbmc/music/windows/GUIWindowMusicPlaylistEditor.cpp +++ b/xbmc/music/windows/GUIWindowMusicPlaylistEditor.cpp @@ -13,6 +13,7 @@ #include "FileItemList.h" #include "GUIUserMessages.h" #include "ServiceBroker.h" +#include "URL.h" #include "Util.h" #include "dialogs/GUIDialogFileBrowser.h" #include "dialogs/GUIDialogKaiToast.h" @@ -39,6 +40,8 @@ #define CONTROL_PLAYLIST 100 #define CONTROL_LABEL_PLAYLIST 101 +using namespace KODI; + CGUIWindowMusicPlaylistEditor::CGUIWindowMusicPlaylistEditor(void) : CGUIWindowMusicBase(WINDOW_MUSIC_PLAYLIST_EDITOR, "MyMusicPlaylistEditor.xml") { diff --git a/xbmc/network/AirPlayServer.cpp b/xbmc/network/AirPlayServer.cpp index 6b30e11e06..3924755197 100644 --- a/xbmc/network/AirPlayServer.cpp +++ b/xbmc/network/AirPlayServer.cpp @@ -45,6 +45,7 @@ #include <plist/plist.h> +using namespace KODI; using KODI::UTILITY::CDigest; using namespace std::chrono_literals; @@ -178,7 +179,8 @@ void CAirPlayServer::Announce(ANNOUNCEMENT::AnnouncementFlag flag, { bool shouldRestoreVolume = true; if (data.isMember("player") && data["player"].isMember("playerid")) - shouldRestoreVolume = (data["player"]["playerid"] != PLAYLIST::TYPE_PICTURE); + shouldRestoreVolume = + (data["player"]["playerid"] != static_cast<int>(PLAYLIST::Id::TYPE_PICTURE)); if (shouldRestoreVolume) restoreVolume(); diff --git a/xbmc/network/NetworkFileItemClassify.cpp b/xbmc/network/NetworkFileItemClassify.cpp index ed4bd77be6..ef27892c93 100644 --- a/xbmc/network/NetworkFileItemClassify.cpp +++ b/xbmc/network/NetworkFileItemClassify.cpp @@ -14,15 +14,12 @@ namespace KODI::NETWORK { -bool IsInternetStream(const CFileItem& item, const bool bStrictCheck /* = false */) +bool IsInternetStream(const CFileItem& item) { if (item.HasProperty("IsHTTPDirectory")) - return bStrictCheck; + return false; - if (!item.GetDynPath().empty()) - return URIUtils::IsInternetStream(item.GetDynPath(), bStrictCheck); - - return URIUtils::IsInternetStream(item.GetPath(), bStrictCheck); + return URIUtils::IsInternetStream(item.GetDynPath()); } bool IsRemote(const CFileItem& item) @@ -32,10 +29,7 @@ bool IsRemote(const CFileItem& item) bool IsStreamedFilesystem(const CFileItem& item) { - if (!item.GetDynPath().empty()) - return URIUtils::IsStreamedFilesystem(item.GetDynPath()); - - return URIUtils::IsStreamedFilesystem(item.GetPath()); + return URIUtils::IsStreamedFilesystem(item.GetDynPath()); } } // namespace KODI::NETWORK diff --git a/xbmc/network/NetworkFileItemClassify.h b/xbmc/network/NetworkFileItemClassify.h index 5a96a98253..dc309e0145 100644 --- a/xbmc/network/NetworkFileItemClassify.h +++ b/xbmc/network/NetworkFileItemClassify.h @@ -14,7 +14,7 @@ namespace KODI::NETWORK { //! \brief Check whether an item is a an internet stream. -bool IsInternetStream(const CFileItem& item, const bool bStrictCheck = false); +bool IsInternetStream(const CFileItem& item); //! \brief Check whether an item is on a remote location. bool IsRemote(const CFileItem& item); diff --git a/xbmc/network/test/TestNetworkFileItemClassify.cpp b/xbmc/network/test/TestNetworkFileItemClassify.cpp index 13dbd44c72..9cd99615b1 100644 --- a/xbmc/network/test/TestNetworkFileItemClassify.cpp +++ b/xbmc/network/test/TestNetworkFileItemClassify.cpp @@ -33,120 +33,58 @@ struct SimpleDefinition } // namespace -struct InternetStreamDefinition -{ - InternetStreamDefinition(const std::string& path, bool folder, bool strict, bool res) - : item(path, folder), strictCheck(strict), result(res) - { - } - - CFileItem item; - bool strictCheck; - bool result; -}; - -class InternetStreamTest : public testing::WithParamInterface<InternetStreamDefinition>, +class InternetStreamTest : public testing::WithParamInterface<SimpleDefinition>, public testing::Test { }; TEST_P(InternetStreamTest, IsInternetStream) { - EXPECT_EQ(NETWORK::IsInternetStream(GetParam().item, GetParam().strictCheck), GetParam().result); + EXPECT_EQ(NETWORK::IsInternetStream(GetParam().item), GetParam().result); } const auto inetstream_tests = std::array{ - InternetStreamDefinition{"/home/user/test.disc", false, false, false}, - InternetStreamDefinition{"/home/user/test.disc", true, true, false}, - InternetStreamDefinition{"http://some.where/foo", false, false, true}, - InternetStreamDefinition{"http://some.where/foo", false, true, true}, - InternetStreamDefinition{"http://some.where/foo", true, false, true}, - InternetStreamDefinition{"http://some.where/foo", true, true, true}, - InternetStreamDefinition{"https://some.where/foo", false, false, true}, - InternetStreamDefinition{"https://some.where/foo", false, true, true}, - InternetStreamDefinition{"https://some.where/foo", true, false, true}, - InternetStreamDefinition{"https://some.where/foo", true, true, true}, - InternetStreamDefinition{"tcp://some.where/foo", false, false, true}, - InternetStreamDefinition{"tcp://some.where/foo", false, true, true}, - InternetStreamDefinition{"tcp://some.where/foo", true, false, true}, - InternetStreamDefinition{"tcp://some.where/foo", true, true, true}, - InternetStreamDefinition{"udp://some.where/foo", false, false, true}, - InternetStreamDefinition{"udp://some.where/foo", false, true, true}, - InternetStreamDefinition{"udp://some.where/foo", true, false, true}, - InternetStreamDefinition{"udp://some.where/foo", true, true, true}, - InternetStreamDefinition{"rtp://some.where/foo", false, false, true}, - InternetStreamDefinition{"rtp://some.where/foo", false, false, true}, - InternetStreamDefinition{"rtp://some.where/foo", true, false, true}, - InternetStreamDefinition{"rtp://some.where/foo", true, true, true}, - InternetStreamDefinition{"sdp://some.where/foo", false, false, true}, - InternetStreamDefinition{"sdp://some.where/foo", false, true, true}, - InternetStreamDefinition{"sdp://some.where/foo", true, false, true}, - InternetStreamDefinition{"sdp://some.where/foo", true, true, true}, - InternetStreamDefinition{"mms://some.where/foo", false, false, true}, - InternetStreamDefinition{"mms://some.where/foo", false, true, true}, - InternetStreamDefinition{"mms://some.where/foo", true, false, true}, - InternetStreamDefinition{"mms://some.where/foo", true, true, true}, - InternetStreamDefinition{"mmst://some.where/foo", false, false, true}, - InternetStreamDefinition{"mmst://some.where/foo", false, true, true}, - InternetStreamDefinition{"mmst://some.where/foo", true, false, true}, - InternetStreamDefinition{"mmst://some.where/foo", true, true, true}, - InternetStreamDefinition{"mmsh://some.where/foo", false, false, true}, - InternetStreamDefinition{"mmsh://some.where/foo", false, true, true}, - InternetStreamDefinition{"mmsh://some.where/foo", true, false, true}, - InternetStreamDefinition{"mmsh://some.where/foo", true, true, true}, - InternetStreamDefinition{"rtsp://some.where/foo", false, false, true}, - InternetStreamDefinition{"rtsp://some.where/foo", false, true, true}, - InternetStreamDefinition{"rtsp://some.where/foo", true, false, true}, - InternetStreamDefinition{"rtsp://some.where/foo", true, true, true}, - InternetStreamDefinition{"rtmp://some.where/foo", false, false, true}, - InternetStreamDefinition{"rtmp://some.where/foo", false, true, true}, - InternetStreamDefinition{"rtmp://some.where/foo", true, false, true}, - InternetStreamDefinition{"rtmp://some.where/foo", true, true, true}, - InternetStreamDefinition{"rtmpt://some.where/foo", false, false, true}, - InternetStreamDefinition{"rtmpt://some.where/foo", false, true, true}, - InternetStreamDefinition{"rtmpt://some.where/foo", true, false, true}, - InternetStreamDefinition{"rtmpt://some.where/foo", true, true, true}, - InternetStreamDefinition{"rtmpe://some.where/foo", false, false, true}, - InternetStreamDefinition{"rtmpe://some.where/foo", false, true, true}, - InternetStreamDefinition{"rtmpe://some.where/foo", true, false, true}, - InternetStreamDefinition{"rtmpe://some.where/foo", true, true, true}, - InternetStreamDefinition{"rtmpte://some.where/foo", false, false, true}, - InternetStreamDefinition{"rtmpte://some.where/foo", false, true, true}, - InternetStreamDefinition{"rtmpte://some.where/foo", true, false, true}, - InternetStreamDefinition{"rtmpte://some.where/foo", true, true, true}, - InternetStreamDefinition{"rtmps://some.where/foo", false, false, true}, - InternetStreamDefinition{"rtmps://some.where/foo", false, true, true}, - InternetStreamDefinition{"rtmps://some.where/foo", true, false, true}, - InternetStreamDefinition{"rtmps://some.where/foo", true, true, true}, - InternetStreamDefinition{"shout://some.where/foo", false, false, true}, - InternetStreamDefinition{"shout://some.where/foo", false, true, true}, - InternetStreamDefinition{"shout://some.where/foo", true, false, true}, - InternetStreamDefinition{"shout://some.where/foo", true, true, true}, - InternetStreamDefinition{"rss://some.where/foo", false, false, true}, - InternetStreamDefinition{"rss://some.where/foo", false, true, true}, - InternetStreamDefinition{"rss://some.where/foo", true, false, true}, - InternetStreamDefinition{"rss://some.where/foo", true, true, true}, - InternetStreamDefinition{"rsss://some.where/foo", false, false, true}, - InternetStreamDefinition{"rsss://some.where/foo", false, true, true}, - InternetStreamDefinition{"rsss://some.where/foo", true, false, true}, - InternetStreamDefinition{"rsss://some.where/foo", true, true, true}, - InternetStreamDefinition{"upnp://some.where/foo", false, false, false}, - InternetStreamDefinition{"upnp://some.where/foo", true, false, false}, - InternetStreamDefinition{"upnp://some.where/foo", false, true, true}, - InternetStreamDefinition{"upnp://some.where/foo", true, true, true}, - InternetStreamDefinition{"ftp://some.where/foo", false, false, false}, - InternetStreamDefinition{"ftp://some.where/foo", true, false, false}, - InternetStreamDefinition{"ftp://some.where/foo", false, true, true}, - InternetStreamDefinition{"ftp://some.where/foo", true, true, true}, - InternetStreamDefinition{"sftp://some.where/foo", false, false, false}, - InternetStreamDefinition{"sftp://some.where/foo", true, false, false}, - InternetStreamDefinition{"sftp://some.where/foo", false, true, true}, - InternetStreamDefinition{"sftp://some.where/foo", true, true, true}, - InternetStreamDefinition{"ssh://some.where/foo", false, false, false}, - InternetStreamDefinition{"ssh://some.where/foo", true, false, false}, - InternetStreamDefinition{"ssh://some.where/foo", false, true, true}, - InternetStreamDefinition{"ssh://some.where/foo", true, true, true}, - InternetStreamDefinition{"ssh://some.where/foo", true, true, true}, + SimpleDefinition{"/home/user/test.disc", false, false}, + SimpleDefinition{"http://some.where/foo", false, true}, + SimpleDefinition{"http://some.where/foo", true, true}, + SimpleDefinition{"https://some.where/foo", false, true}, + SimpleDefinition{"https://some.where/foo", true, true}, + SimpleDefinition{"tcp://some.where/foo", false, true}, + SimpleDefinition{"tcp://some.where/foo", true, true}, + SimpleDefinition{"udp://some.where/foo", false, true}, + SimpleDefinition{"udp://some.where/foo", true, true}, + SimpleDefinition{"rtp://some.where/foo", false, true}, + SimpleDefinition{"rtp://some.where/foo", true, true}, + SimpleDefinition{"sdp://some.where/foo", false, true}, + SimpleDefinition{"sdp://some.where/foo", true, true}, + SimpleDefinition{"mms://some.where/foo", false, true}, + SimpleDefinition{"mms://some.where/foo", true, true}, + SimpleDefinition{"mmst://some.where/foo", false, true}, + SimpleDefinition{"mmst://some.where/foo", true, true}, + SimpleDefinition{"mmsh://some.where/foo", false, true}, + SimpleDefinition{"mmsh://some.where/foo", true, true}, + SimpleDefinition{"rtsp://some.where/foo", false, true}, + SimpleDefinition{"rtsp://some.where/foo", true, true}, + SimpleDefinition{"rtmp://some.where/foo", false, true}, + SimpleDefinition{"rtmp://some.where/foo", true, true}, + SimpleDefinition{"rtmpt://some.where/foo", false, true}, + SimpleDefinition{"rtmpt://some.where/foo", true, true}, + SimpleDefinition{"rtmpe://some.where/foo", false, true}, + SimpleDefinition{"rtmpe://some.where/foo", true, true}, + SimpleDefinition{"rtmpte://some.where/foo", false, true}, + SimpleDefinition{"rtmpte://some.where/foo", true, true}, + SimpleDefinition{"rtmps://some.where/foo", false, true}, + SimpleDefinition{"rtmps://some.where/foo", true, true}, + SimpleDefinition{"shout://some.where/foo", false, true}, + SimpleDefinition{"shout://some.where/foo", true, true}, + SimpleDefinition{"rss://some.where/foo", false, true}, + SimpleDefinition{"rss://some.where/foo", true, true}, + SimpleDefinition{"rsss://some.where/foo", false, true}, + SimpleDefinition{"rsss://some.where/foo", true, true}, + SimpleDefinition{"upnp://some.where/foo", false, false}, + SimpleDefinition{"ftp://some.where/foo", false, false}, + SimpleDefinition{"sftp://some.where/foo", false, false}, + SimpleDefinition{"ssh://some.where/foo", false, false}, }; INSTANTIATE_TEST_SUITE_P(TestNetworkFileItemClassify, @@ -158,38 +96,27 @@ TEST(TestNetworkWorkFileItemClassify, InternetStreamStacks) std::string stackPath; EXPECT_TRUE(XFILE::CStackDirectory::ConstructStackPath( {"/home/foo/somthing.avi", "/home/bar/else.mkv"}, stackPath)); - EXPECT_FALSE(NETWORK::IsInternetStream(CFileItem(stackPath, false), false)); - EXPECT_FALSE(NETWORK::IsInternetStream(CFileItem(stackPath, true), false)); - EXPECT_FALSE(NETWORK::IsInternetStream(CFileItem(stackPath, false), true)); - EXPECT_FALSE(NETWORK::IsInternetStream(CFileItem(stackPath, true), true)); + EXPECT_FALSE(NETWORK::IsInternetStream(CFileItem(stackPath, false))); + EXPECT_FALSE(NETWORK::IsInternetStream(CFileItem(stackPath, true))); EXPECT_TRUE(XFILE::CStackDirectory::ConstructStackPath( {"https://home/foo/somthing.avi", "https://home/bar/else.mkv"}, stackPath)); - EXPECT_TRUE(NETWORK::IsInternetStream(CFileItem(stackPath, false), false)); - EXPECT_TRUE(NETWORK::IsInternetStream(CFileItem(stackPath, true), false)); - EXPECT_TRUE(NETWORK::IsInternetStream(CFileItem(stackPath, false), true)); - EXPECT_TRUE(NETWORK::IsInternetStream(CFileItem(stackPath, true), true)); + EXPECT_TRUE(NETWORK::IsInternetStream(CFileItem(stackPath, false))); + EXPECT_TRUE(NETWORK::IsInternetStream(CFileItem(stackPath, true))); EXPECT_TRUE(XFILE::CStackDirectory::ConstructStackPath( {"ftp://home/foo/somthing.avi", "ftp://home/bar/else.mkv"}, stackPath)); - EXPECT_FALSE(NETWORK::IsInternetStream(CFileItem(stackPath, false), false)); - EXPECT_FALSE(NETWORK::IsInternetStream(CFileItem(stackPath, true), false)); - EXPECT_TRUE(NETWORK::IsInternetStream(CFileItem(stackPath, false), true)); - EXPECT_TRUE(NETWORK::IsInternetStream(CFileItem(stackPath, true), true)); - - EXPECT_TRUE(XFILE::CStackDirectory::ConstructStackPath( - {"ftp://home/foo/somthing.avi", "/home/bar/else.mkv"}, stackPath)); - EXPECT_FALSE(NETWORK::IsInternetStream(CFileItem(stackPath, false), false)); - EXPECT_FALSE(NETWORK::IsInternetStream(CFileItem(stackPath, true), false)); - EXPECT_TRUE(NETWORK::IsInternetStream(CFileItem(stackPath, false), true)); - EXPECT_TRUE(NETWORK::IsInternetStream(CFileItem(stackPath, true), true)); + EXPECT_FALSE(NETWORK::IsInternetStream(CFileItem(stackPath, false))); + EXPECT_FALSE(NETWORK::IsInternetStream(CFileItem(stackPath, true))); EXPECT_TRUE(XFILE::CStackDirectory::ConstructStackPath( {"/home/foo/somthing.avi", "ftp://home/bar/else.mkv"}, stackPath)); - EXPECT_FALSE(NETWORK::IsInternetStream(CFileItem(stackPath, false), false)); - EXPECT_FALSE(NETWORK::IsInternetStream(CFileItem(stackPath, true), false)); - EXPECT_FALSE(NETWORK::IsInternetStream(CFileItem(stackPath, false), true)); - EXPECT_FALSE(NETWORK::IsInternetStream(CFileItem(stackPath, true), true)); + EXPECT_FALSE(NETWORK::IsInternetStream(CFileItem(stackPath, false))); + EXPECT_FALSE(NETWORK::IsInternetStream(CFileItem(stackPath, true))); + + CFileItem item("https://some.where/", true); + item.SetProperty("IsHTTPDirectory", true); + EXPECT_FALSE(NETWORK::IsInternetStream(item)); } class RemoteTest : public testing::WithParamInterface<SimpleDefinition>, public testing::Test diff --git a/xbmc/network/upnp/UPnPRenderer.cpp b/xbmc/network/upnp/UPnPRenderer.cpp index acc25a81a9..6cbba2c136 100644 --- a/xbmc/network/upnp/UPnPRenderer.cpp +++ b/xbmc/network/upnp/UPnPRenderer.cpp @@ -38,7 +38,7 @@ #include <Platinum/Source/Platinum/Platinum.h> -using namespace KODI::VIDEO; +using namespace KODI; NPT_SET_LOCAL_LOGGER("xbmc.upnp.renderer") @@ -631,15 +631,15 @@ NPT_Result CUPnPRenderer::OnSetNextAVTransportURI(PLT_ActionReference& action) CServiceBroker::GetGUI()->GetWindowManager().GetActiveWindow() != WINDOW_SLIDESHOW) { - PLAYLIST::Id playlistId = PLAYLIST::TYPE_MUSIC; - if (IsVideo(*item)) - playlistId = PLAYLIST::TYPE_VIDEO; + PLAYLIST::Id playlistId = PLAYLIST::Id::TYPE_MUSIC; + if (VIDEO::IsVideo(*item)) + playlistId = PLAYLIST::Id::TYPE_VIDEO; // note: auto-deleted when the message is consumed auto playlist = new CFileItemList(); playlist->AddFront(item, 0); - CServiceBroker::GetAppMessenger()->PostMsg(TMSG_PLAYLISTPLAYER_ADD, playlistId, -1, - static_cast<void*>(playlist)); + CServiceBroker::GetAppMessenger()->PostMsg( + TMSG_PLAYLISTPLAYER_ADD, static_cast<int>(playlistId), -1, static_cast<void*>(playlist)); service->SetStateVariable("NextAVTransportURI", uri); service->SetStateVariable("NextAVTransportURIMetaData", meta); diff --git a/xbmc/peripherals/bus/virtual/CMakeLists.txt b/xbmc/peripherals/bus/virtual/CMakeLists.txt index 0a70d59c84..b94d241194 100644 --- a/xbmc/peripherals/bus/virtual/CMakeLists.txt +++ b/xbmc/peripherals/bus/virtual/CMakeLists.txt @@ -4,7 +4,7 @@ set(SOURCES PeripheralBusAddon.cpp set(HEADERS PeripheralBusAddon.h PeripheralBusApplication.h) -if(TARGET CEC::CEC) +if(TARGET ${APP_NAME_LC}::CEC) list(APPEND SOURCES PeripheralBusCEC.cpp) list(APPEND HEADERS PeripheralBusCEC.h) endif() diff --git a/xbmc/peripherals/devices/CMakeLists.txt b/xbmc/peripherals/devices/CMakeLists.txt index 873acc4431..059ae173c7 100644 --- a/xbmc/peripherals/devices/CMakeLists.txt +++ b/xbmc/peripherals/devices/CMakeLists.txt @@ -22,7 +22,7 @@ set(HEADERS Peripheral.h PeripheralNyxboard.h PeripheralTuner.h) -if(TARGET CEC::CEC) +if(TARGET ${APP_NAME_LC}::CEC) list(APPEND SOURCES PeripheralCecAdapter.cpp) list(APPEND HEADERS PeripheralCecAdapter.h) endif() diff --git a/xbmc/pictures/GUIWindowPictures.cpp b/xbmc/pictures/GUIWindowPictures.cpp index b7345526fd..89d704bef8 100644 --- a/xbmc/pictures/GUIWindowPictures.cpp +++ b/xbmc/pictures/GUIWindowPictures.cpp @@ -49,7 +49,7 @@ using namespace XFILE; using namespace KODI::MESSAGING; -using namespace KODI::VIDEO; +using namespace KODI; using namespace std::chrono_literals; @@ -297,7 +297,7 @@ bool CGUIWindowPictures::GetDirectory(const std::string &strDirectory, CFileItem bool CGUIWindowPictures::OnPlayMedia(int iItem, const std::string &player) { - if (IsVideo(*m_vecItems->Get(iItem))) + if (VIDEO::IsVideo(*m_vecItems->Get(iItem))) return CGUIMediaWindow::OnPlayMedia(iItem); return ShowPicture(iItem, false); @@ -330,7 +330,7 @@ bool CGUIWindowPictures::ShowPicture(int iItem, bool startSlideShow) { if (!pItem->m_bIsFolder && !(URIUtils::IsRAR(pItem->GetPath()) || URIUtils::IsZIP(pItem->GetPath())) && - (pItem->IsPicture() || (bShowVideos && IsVideo(*pItem)))) + (pItem->IsPicture() || (bShowVideos && VIDEO::IsVideo(*pItem)))) { slideShow.Add(pItem.get()); } diff --git a/xbmc/pictures/GUIWindowSlideShow.cpp b/xbmc/pictures/GUIWindowSlideShow.cpp index b1fe3d56c5..495e8c3526 100644 --- a/xbmc/pictures/GUIWindowSlideShow.cpp +++ b/xbmc/pictures/GUIWindowSlideShow.cpp @@ -164,7 +164,7 @@ void CGUIWindowSlideShow::AnnouncePlayerPlay(const CFileItemPtr& item) { CVariant param; param["player"]["speed"] = m_bSlideShow && !m_bPause ? 1 : 0; - param["player"]["playerid"] = PLAYLIST::TYPE_PICTURE; + param["player"]["playerid"] = static_cast<int>(PLAYLIST::Id::TYPE_PICTURE); CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::Player, "OnPlay", item, param); } @@ -172,14 +172,14 @@ void CGUIWindowSlideShow::AnnouncePlayerPause(const CFileItemPtr& item) { CVariant param; param["player"]["speed"] = 0; - param["player"]["playerid"] = PLAYLIST::TYPE_PICTURE; + param["player"]["playerid"] = static_cast<int>(PLAYLIST::Id::TYPE_PICTURE); CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::Player, "OnPause", item, param); } void CGUIWindowSlideShow::AnnouncePlayerStop(const CFileItemPtr& item) { CVariant param; - param["player"]["playerid"] = PLAYLIST::TYPE_PICTURE; + param["player"]["playerid"] = static_cast<int>(PLAYLIST::Id::TYPE_PICTURE); param["end"] = true; CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::Player, "OnStop", item, param); } @@ -187,14 +187,14 @@ void CGUIWindowSlideShow::AnnouncePlayerStop(const CFileItemPtr& item) void CGUIWindowSlideShow::AnnouncePlaylistClear() { CVariant data; - data["playlistid"] = PLAYLIST::TYPE_PICTURE; + data["playlistid"] = static_cast<int>(PLAYLIST::Id::TYPE_PICTURE); CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::Playlist, "OnClear", data); } void CGUIWindowSlideShow::AnnouncePlaylistAdd(const CFileItemPtr& item, int pos) { CVariant data; - data["playlistid"] = PLAYLIST::TYPE_PICTURE; + data["playlistid"] = static_cast<int>(PLAYLIST::Id::TYPE_PICTURE); data["position"] = pos; CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::Playlist, "OnAdd", item, data); } @@ -205,7 +205,7 @@ void CGUIWindowSlideShow::AnnouncePropertyChanged(const std::string &strProperty return; CVariant data; - data["player"]["playerid"] = PLAYLIST::TYPE_PICTURE; + data["player"]["playerid"] = static_cast<int>(PLAYLIST::Id::TYPE_PICTURE); data["property"][strProperty] = value; CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::Player, "OnPropertyChanged", data); diff --git a/xbmc/platform/android/activity/AndroidKey.cpp b/xbmc/platform/android/activity/AndroidKey.cpp index 13e23b80a4..3467ed6420 100644 --- a/xbmc/platform/android/activity/AndroidKey.cpp +++ b/xbmc/platform/android/activity/AndroidKey.cpp @@ -13,6 +13,8 @@ #include "input/keyboard/XBMC_keysym.h" #include "windowing/android/WinSystemAndroid.h" +#include "platform/android/peripherals/AndroidJoystickTranslator.h" + #include <androidjni/KeyCharacterMap.h> typedef struct { @@ -261,38 +263,46 @@ bool CAndroidKey::onKeyboardEvent(AInputEvent *event) switch (action) { case AKEY_EVENT_ACTION_DOWN: - CXBMCApp::android_printf( - "CAndroidKey: key down (dev: %d; src: %d; code: %d; repeat: %d; flags: 0x%0X; alt: %s; " - "shift: %s; sym: %s)", - deviceId, source, keycode, repeat, flags, (state & AMETA_ALT_ON) ? "yes" : "no", - (state & AMETA_SHIFT_ON) ? "yes" : "no", (state & AMETA_SYM_ON) ? "yes" : "no"); + CXBMCApp::android_printf("CAndroidKey: key down (dev: %d; src: %d; code: %d (%s); repeat: " + "%d; flags: 0x%0X; alt: %s; shift: %s; sym: %s)", + deviceId, source, keycode, + PERIPHERALS::CAndroidJoystickTranslator::TranslateKeyCode(keycode), + repeat, flags, (state & AMETA_ALT_ON) ? "yes" : "no", + (state & AMETA_SHIFT_ON) ? "yes" : "no", + (state & AMETA_SYM_ON) ? "yes" : "no"); XBMC_Key((uint8_t)keycode, sym, modifiers, unicode, false); break; case AKEY_EVENT_ACTION_UP: - CXBMCApp::android_printf( - "CAndroidKey: key up (dev: %d; src: %d; code: %d; repeat: %d; flags: 0x%0X; alt: %s; " - "shift: %s; sym: %s)", - deviceId, source, keycode, repeat, flags, (state & AMETA_ALT_ON) ? "yes" : "no", - (state & AMETA_SHIFT_ON) ? "yes" : "no", (state & AMETA_SYM_ON) ? "yes" : "no"); + CXBMCApp::android_printf("CAndroidKey: key up (dev: %d; src: %d; code: %d (%s); repeat: %d; " + "flags: 0x%0X; alt: %s; shift: %s; sym: %s)", + deviceId, source, keycode, + PERIPHERALS::CAndroidJoystickTranslator::TranslateKeyCode(keycode), + repeat, flags, (state & AMETA_ALT_ON) ? "yes" : "no", + (state & AMETA_SHIFT_ON) ? "yes" : "no", + (state & AMETA_SYM_ON) ? "yes" : "no"); XBMC_Key((uint8_t)keycode, sym, modifiers, unicode, true); break; case AKEY_EVENT_ACTION_MULTIPLE: - CXBMCApp::android_printf( - "CAndroidKey: key multiple (dev: %d; src: %d; code: %d; repeat: %d; flags: 0x%0X; alt: " - "%s; shift: %s; sym: %s)", - deviceId, source, keycode, repeat, flags, (state & AMETA_ALT_ON) ? "yes" : "no", - (state & AMETA_SHIFT_ON) ? "yes" : "no", (state & AMETA_SYM_ON) ? "yes" : "no"); + CXBMCApp::android_printf("CAndroidKey: key multiple (dev: %d; src: %d; code: %d (%s); " + "repeat: %d; flags: 0x%0X; alt: %s; shift: %s; sym: %s)", + deviceId, source, keycode, + PERIPHERALS::CAndroidJoystickTranslator::TranslateKeyCode(keycode), + repeat, flags, (state & AMETA_ALT_ON) ? "yes" : "no", + (state & AMETA_SHIFT_ON) ? "yes" : "no", + (state & AMETA_SYM_ON) ? "yes" : "no"); return false; break; default: - CXBMCApp::android_printf( - "CAndroidKey: unknown key (dev: %d; src: %d; code: %d; repeat: %d; flags: 0x%0X; alt: " - "%s; shift: %s; sym: %s)", - deviceId, source, keycode, repeat, flags, (state & AMETA_ALT_ON) ? "yes" : "no", - (state & AMETA_SHIFT_ON) ? "yes" : "no", (state & AMETA_SYM_ON) ? "yes" : "no"); + CXBMCApp::android_printf("CAndroidKey: unknown key (dev: %d; src: %d; code: %d (%s); repeat: " + "%d; flags: 0x%0X; alt: %s; shift: %s; sym: %s)", + deviceId, source, keycode, + PERIPHERALS::CAndroidJoystickTranslator::TranslateKeyCode(keycode), + repeat, flags, (state & AMETA_ALT_ON) ? "yes" : "no", + (state & AMETA_SHIFT_ON) ? "yes" : "no", + (state & AMETA_SYM_ON) ? "yes" : "no"); return false; break; } diff --git a/xbmc/platform/android/peripherals/AndroidJoystickTranslator.cpp b/xbmc/platform/android/peripherals/AndroidJoystickTranslator.cpp index be919ab70e..3717616413 100644 --- a/xbmc/platform/android/peripherals/AndroidJoystickTranslator.cpp +++ b/xbmc/platform/android/peripherals/AndroidJoystickTranslator.cpp @@ -630,6 +630,98 @@ const char* CAndroidJoystickTranslator::TranslateKeyCode(int keyCode) return "AKEYCODE_TV_TIMER_PROGRAMMING"; case AKEYCODE_HELP: return "AKEYCODE_HELP"; + case AKEYCODE_NAVIGATE_PREVIOUS: + return "AKEYCODE_NAVIGATE_PREVIOUS"; + case AKEYCODE_NAVIGATE_NEXT: + return "AKEYCODE_NAVIGATE_NEXT"; + case AKEYCODE_NAVIGATE_IN: + return "AKEYCODE_NAVIGATE_IN"; + case AKEYCODE_NAVIGATE_OUT: + return "AKEYCODE_NAVIGATE_OUT"; + case AKEYCODE_STEM_PRIMARY: + return "AKEYCODE_STEM_PRIMARY"; + case AKEYCODE_STEM_1: + return "AKEYCODE_STEM_1"; + case AKEYCODE_STEM_2: + return "AKEYCODE_STEM_2"; + case AKEYCODE_STEM_3: + return "AKEYCODE_STEM_3"; + case AKEYCODE_DPAD_UP_LEFT: + return "AKEYCODE_DPAD_UP_LEFT"; + case AKEYCODE_DPAD_DOWN_LEFT: + return "AKEYCODE_DPAD_DOWN_LEFT"; + case AKEYCODE_DPAD_UP_RIGHT: + return "AKEYCODE_DPAD_UP_RIGHT"; + case AKEYCODE_DPAD_DOWN_RIGHT: + return "AKEYCODE_DPAD_DOWN_RIGHT"; + case AKEYCODE_MEDIA_SKIP_FORWARD: + return "AKEYCODE_MEDIA_SKIP_FORWARD"; + case AKEYCODE_MEDIA_SKIP_BACKWARD: + return "AKEYCODE_MEDIA_SKIP_BACKWARD"; + case AKEYCODE_MEDIA_STEP_FORWARD: + return "AKEYCODE_MEDIA_STEP_FORWARD"; + case AKEYCODE_MEDIA_STEP_BACKWARD: + return "AKEYCODE_MEDIA_STEP_BACKWARD"; + case AKEYCODE_SOFT_SLEEP: + return "AKEYCODE_SOFT_SLEEP"; + case AKEYCODE_CUT: + return "AKEYCODE_CUT"; + case AKEYCODE_COPY: + return "AKEYCODE_COPY"; + case AKEYCODE_PASTE: + return "AKEYCODE_PASTE"; + case AKEYCODE_SYSTEM_NAVIGATION_UP: + return "AKEYCODE_SYSTEM_NAVIGATION_UP"; + case AKEYCODE_SYSTEM_NAVIGATION_DOWN: + return "AKEYCODE_SYSTEM_NAVIGATION_DOWN"; + case AKEYCODE_SYSTEM_NAVIGATION_LEFT: + return "AKEYCODE_SYSTEM_NAVIGATION_LEFT"; + case AKEYCODE_SYSTEM_NAVIGATION_RIGHT: + return "AKEYCODE_SYSTEM_NAVIGATION_RIGHT"; + case AKEYCODE_ALL_APPS: + return "AKEYCODE_ALL_APPS"; + case AKEYCODE_REFRESH: + return "AKEYCODE_REFRESH"; + case AKEYCODE_THUMBS_UP: + return "AKEYCODE_THUMBS_UP"; + case AKEYCODE_THUMBS_DOWN: + return "AKEYCODE_THUMBS_DOWN"; + case AKEYCODE_PROFILE_SWITCH: + return "AKEYCODE_PROFILE_SWITCH"; + case AKEYCODE_VIDEO_APP_1: + return "AKEYCODE_VIDEO_APP_1"; + case AKEYCODE_VIDEO_APP_2: + return "AKEYCODE_VIDEO_APP_2"; + case AKEYCODE_VIDEO_APP_3: + return "AKEYCODE_VIDEO_APP_3"; + case AKEYCODE_VIDEO_APP_4: + return "AKEYCODE_VIDEO_APP_4"; + case AKEYCODE_VIDEO_APP_5: + return "AKEYCODE_VIDEO_APP_5"; + case AKEYCODE_VIDEO_APP_6: + return "AKEYCODE_VIDEO_APP_6"; + case AKEYCODE_VIDEO_APP_7: + return "AKEYCODE_VIDEO_APP_7"; + case AKEYCODE_VIDEO_APP_8: + return "AKEYCODE_VIDEO_APP_8"; + case AKEYCODE_FEATURED_APP_1: + return "AKEYCODE_FEATURED_APP_1"; + case AKEYCODE_FEATURED_APP_2: + return "AKEYCODE_FEATURED_APP_2"; + case AKEYCODE_FEATURED_APP_3: + return "AKEYCODE_FEATURED_APP_3"; + case AKEYCODE_FEATURED_APP_4: + return "AKEYCODE_FEATURED_APP_4"; + case AKEYCODE_DEMO_APP_1: + return "AKEYCODE_DEMO_APP_1"; + case AKEYCODE_DEMO_APP_2: + return "AKEYCODE_DEMO_APP_2"; + case AKEYCODE_DEMO_APP_3: + return "AKEYCODE_DEMO_APP_3"; + case AKEYCODE_DEMO_APP_4: + return "AKEYCODE_DEMO_APP_4"; + default: + break; } return "unknown"; diff --git a/xbmc/platform/android/peripherals/PeripheralBusAndroid.cpp b/xbmc/platform/android/peripherals/PeripheralBusAndroid.cpp index 74b78849e5..753dc71099 100644 --- a/xbmc/platform/android/peripherals/PeripheralBusAndroid.cpp +++ b/xbmc/platform/android/peripherals/PeripheralBusAndroid.cpp @@ -31,7 +31,7 @@ using namespace PERIPHERALS; #define JOYSTICK_PROVIDER_ANDROID "android" // Set this to the final key code in android/keycodes.h -const unsigned int KEY_CODE_FINAL = AKEYCODE_HELP; +const unsigned int KEY_CODE_FINAL = AKEYCODE_DEMO_APP_4; static const std::string DeviceLocationPrefix = "android/inputdevice/"; @@ -304,8 +304,8 @@ bool CPeripheralBusAndroid::OnInputDeviceEvent(const AInputEvent* event) auto joystickState = m_joystickStates.find(deviceId); if (joystickState == m_joystickStates.end()) { - CLog::Log(LOGWARNING, - "CPeripheralBusAndroid: ignoring input event for unknown input device with ID {}", + CLog::Log(LOGDEBUG, + "CPeripheralBusAndroid: ignoring input event for non-joystick device with ID {}", deviceId); return false; } diff --git a/xbmc/platform/freebsd/CMakeLists.txt b/xbmc/platform/freebsd/CMakeLists.txt index b8818cefc3..493d578a98 100644 --- a/xbmc/platform/freebsd/CMakeLists.txt +++ b/xbmc/platform/freebsd/CMakeLists.txt @@ -15,12 +15,12 @@ set(HEADERS ../linux/AppParamParserLinux.cpp ../linux/TimeUtils.h PlatformFreebsd.h) -if(TARGET ALSA::ALSA) +if(TARGET ${APP_NAME_LC}::Alsa) list(APPEND SOURCES ../linux/FDEventMonitor.cpp) list(APPEND HEADERS ../linux/FDEventMonitor.h) endif() -if(TARGET DBus::DBus) +if(TARGET ${APP_NAME_LC}::DBus) list(APPEND SOURCES ../linux/DBusMessage.cpp ../linux/DBusUtil.cpp) list(APPEND HEADERS ../linux/DBusMessage.h diff --git a/xbmc/platform/linux/CMakeLists.txt b/xbmc/platform/linux/CMakeLists.txt index 6c5bceae7c..fc162bf605 100644 --- a/xbmc/platform/linux/CMakeLists.txt +++ b/xbmc/platform/linux/CMakeLists.txt @@ -22,12 +22,12 @@ if(TARGET_WEBOS) PlatformWebOS.h) endif() -if(TARGET ALSA::ALSA) +if(TARGET ${APP_NAME_LC}::Alsa) list(APPEND SOURCES FDEventMonitor.cpp) list(APPEND HEADERS FDEventMonitor.h) endif() -if(TARGET DBus::DBus) +if(TARGET ${APP_NAME_LC}::DBus) list(APPEND SOURCES DBusMessage.cpp DBusUtil.cpp) list(APPEND HEADERS DBusMessage.h diff --git a/xbmc/platform/linux/network/zeroconf/CMakeLists.txt b/xbmc/platform/linux/network/zeroconf/CMakeLists.txt index 2ad37796e4..fb3ace7e89 100644 --- a/xbmc/platform/linux/network/zeroconf/CMakeLists.txt +++ b/xbmc/platform/linux/network/zeroconf/CMakeLists.txt @@ -1,4 +1,4 @@ -if(TARGET Avahi::Avahi) +if(TARGET ${APP_NAME_LC}::Avahi) set(SOURCES ZeroconfAvahi.cpp ZeroconfBrowserAvahi.cpp) set(HEADERS ZeroconfAvahi.h diff --git a/xbmc/platform/linux/peripherals/CMakeLists.txt b/xbmc/platform/linux/peripherals/CMakeLists.txt index 8295e1eae3..554f753e2f 100644 --- a/xbmc/platform/linux/peripherals/CMakeLists.txt +++ b/xbmc/platform/linux/peripherals/CMakeLists.txt @@ -1,7 +1,7 @@ if(TARGET UDEV::UDEV) list(APPEND SOURCES PeripheralBusUSBLibUdev.cpp) list(APPEND HEADERS PeripheralBusUSBLibUdev.h) -elseif(TARGET LibUSB::LibUSB) +elseif(TARGET ${APP_NAME_LC}::LibUSB) list(APPEND SOURCES PeripheralBusUSBLibUSB.cpp) list(APPEND HEADERS PeripheralBusUSBLibUSB.h) endif() diff --git a/xbmc/platform/linux/powermanagement/CMakeLists.txt b/xbmc/platform/linux/powermanagement/CMakeLists.txt index 1893bad11b..f931d392bc 100644 --- a/xbmc/platform/linux/powermanagement/CMakeLists.txt +++ b/xbmc/platform/linux/powermanagement/CMakeLists.txt @@ -3,7 +3,7 @@ set(SOURCES LinuxPowerSyscall.cpp) set(HEADERS FallbackPowerSyscall.h LinuxPowerSyscall.h) -if(TARGET DBus::DBus) +if(TARGET ${APP_NAME_LC}::DBus) list(APPEND SOURCES ConsoleUPowerSyscall.cpp LogindUPowerSyscall.cpp UPowerSyscall.cpp) diff --git a/xbmc/platform/linux/storage/CMakeLists.txt b/xbmc/platform/linux/storage/CMakeLists.txt index 9e56475a60..9fa51a23a4 100644 --- a/xbmc/platform/linux/storage/CMakeLists.txt +++ b/xbmc/platform/linux/storage/CMakeLists.txt @@ -2,7 +2,7 @@ set(SOURCES LinuxStorageProvider.cpp) set(HEADERS LinuxStorageProvider.h) -if(TARGET DBus::DBus) +if(TARGET ${APP_NAME_LC}::DBus) list(APPEND SOURCES UDisksProvider.cpp UDisks2Provider.cpp) list(APPEND HEADERS UDisksProvider.h diff --git a/xbmc/playlists/PlayList.cpp b/xbmc/playlists/PlayList.cpp index 8857b818ac..f64d82b8ea 100644 --- a/xbmc/playlists/PlayList.cpp +++ b/xbmc/playlists/PlayList.cpp @@ -30,10 +30,11 @@ #include <utility> #include <vector> -using namespace KODI; using namespace MUSIC_INFO; using namespace XFILE; -using namespace PLAYLIST; + +namespace KODI::PLAYLIST +{ CPlayList::CPlayList(Id id /* = PLAYLIST::TYPE_NONE */) : m_id(id) { @@ -44,32 +45,32 @@ CPlayList::CPlayList(Id id /* = PLAYLIST::TYPE_NONE */) : m_id(id) void CPlayList::AnnounceRemove(int pos) { - if (m_id == TYPE_NONE) + if (m_id == Id::TYPE_NONE) return; CVariant data; - data["playlistid"] = m_id; + data["playlistid"] = static_cast<int>(m_id); data["position"] = pos; CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::Playlist, "OnRemove", data); } void CPlayList::AnnounceClear() { - if (m_id == TYPE_NONE) + if (m_id == Id::TYPE_NONE) return; CVariant data; - data["playlistid"] = m_id; + data["playlistid"] = static_cast<int>(m_id); CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::Playlist, "OnClear", data); } void CPlayList::AnnounceAdd(const std::shared_ptr<CFileItem>& item, int pos) { - if (m_id == TYPE_NONE) + if (m_id == Id::TYPE_NONE) return; CVariant data; - data["playlistid"] = m_id; + data["playlistid"] = static_cast<int>(m_id); data["position"] = pos; CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::Playlist, "OnAdd", item, data); } @@ -513,3 +514,5 @@ const std::string& CPlayList::ResolveURL(const std::shared_ptr<CFileItem>& item) else return item->GetDynPath(); } + +} // namespace KODI::PLAYLIST diff --git a/xbmc/playlists/PlayList.h b/xbmc/playlists/PlayList.h index 8aa92be697..6986f6b99e 100644 --- a/xbmc/playlists/PlayList.h +++ b/xbmc/playlists/PlayList.h @@ -17,13 +17,13 @@ class CFileItem; class CFileItemList; -namespace PLAYLIST +namespace KODI::PLAYLIST { class CPlayList { public: - explicit CPlayList(PLAYLIST::Id id = PLAYLIST::TYPE_NONE); + explicit CPlayList(Id id = Id::TYPE_NONE); virtual ~CPlayList(void) = default; virtual bool Load(const std::string& strFileName); virtual bool LoadData(std::istream &stream); @@ -67,7 +67,7 @@ public: const std::string& ResolveURL(const std::shared_ptr<CFileItem>& item) const; protected: - PLAYLIST::Id m_id; + Id m_id; std::string m_strPlayListName; std::string m_strBasePath; int m_iPlayableItems; @@ -89,4 +89,5 @@ private: }; typedef std::shared_ptr<CPlayList> CPlayListPtr; -} + +} // namespace KODI::PLAYLIST diff --git a/xbmc/playlists/PlayListB4S.cpp b/xbmc/playlists/PlayListB4S.cpp index 693e62f81b..69baa857c6 100644 --- a/xbmc/playlists/PlayListB4S.cpp +++ b/xbmc/playlists/PlayListB4S.cpp @@ -22,7 +22,6 @@ #include <string> using namespace XFILE; -using namespace PLAYLIST; /* ------------------------ example b4s playlist file --------------------------------- <?xml version="1.0" encoding='UTF-8' standalone="yes"?> @@ -40,6 +39,10 @@ using namespace PLAYLIST; </playlist> </WinampXML> ------------------------ end of example b4s playlist file ---------------------------------*/ + +namespace KODI::PLAYLIST +{ + CPlayListB4S::CPlayListB4S(void) = default; CPlayListB4S::~CPlayListB4S(void) = default; @@ -131,3 +134,5 @@ void CPlayListB4S::Save(const std::string& strFileName) const file.Write(write.c_str(), write.size()); file.Close(); } + +} // namespace KODI::PLAYLIST diff --git a/xbmc/playlists/PlayListB4S.h b/xbmc/playlists/PlayListB4S.h index 6f688b51a8..f1296342cd 100644 --- a/xbmc/playlists/PlayListB4S.h +++ b/xbmc/playlists/PlayListB4S.h @@ -10,11 +10,10 @@ #include "PlayList.h" -namespace PLAYLIST +namespace KODI::PLAYLIST { -class CPlayListB4S : - public CPlayList +class CPlayListB4S : public CPlayList { public: CPlayListB4S(void); @@ -22,4 +21,4 @@ public: bool LoadData(std::istream& stream) override; void Save(const std::string& strFileName) const override; }; -} +} // namespace KODI::PLAYLIST diff --git a/xbmc/playlists/PlayListFactory.cpp b/xbmc/playlists/PlayListFactory.cpp index 4bae13dd27..0fb8ab7ebd 100644 --- a/xbmc/playlists/PlayListFactory.cpp +++ b/xbmc/playlists/PlayListFactory.cpp @@ -20,8 +20,8 @@ #include "utils/StringUtils.h" #include "utils/URIUtils.h" -using namespace KODI; -using namespace PLAYLIST; +namespace KODI::PLAYLIST +{ CPlayList* CPlayListFactory::Create(const std::string& filename) { @@ -146,3 +146,4 @@ bool CPlayListFactory::IsPlaylist(const std::string& filename) ".m3u|.m3u8|.b4s|.pls|.strm|.wpl|.asx|.ram|.url|.pxml|.xspf"); } +} // namespace KODI::PLAYLIST diff --git a/xbmc/playlists/PlayListFactory.h b/xbmc/playlists/PlayListFactory.h index 59a56f2f5f..5161150ea5 100644 --- a/xbmc/playlists/PlayListFactory.h +++ b/xbmc/playlists/PlayListFactory.h @@ -13,7 +13,7 @@ class CFileItem; class CURL; -namespace PLAYLIST +namespace KODI::PLAYLIST { class CPlayList; diff --git a/xbmc/playlists/PlayListM3U.cpp b/xbmc/playlists/PlayListM3U.cpp index e403c56117..572bdced77 100644 --- a/xbmc/playlists/PlayListM3U.cpp +++ b/xbmc/playlists/PlayListM3U.cpp @@ -22,10 +22,11 @@ #include <inttypes.h> -using namespace KODI; -using namespace PLAYLIST; using namespace XFILE; +namespace KODI::PLAYLIST +{ + const char* CPlayListM3U::StartMarker = "#EXTCPlayListM3U::M3U"; const char* CPlayListM3U::InfoMarker = "#EXTINF"; const char* CPlayListM3U::ArtistMarker = "#EXTART"; @@ -291,3 +292,4 @@ std::map< std::string, std::string > CPlayListM3U::ParseStreamLine(const std::st return params; } +} // namespace KODI::PLAYLIST diff --git a/xbmc/playlists/PlayListM3U.h b/xbmc/playlists/PlayListM3U.h index 467ed30db8..9955bb898d 100644 --- a/xbmc/playlists/PlayListM3U.h +++ b/xbmc/playlists/PlayListM3U.h @@ -9,12 +9,13 @@ #pragma once #include "PlayList.h" -#include "URL.h" -namespace PLAYLIST +#include <map> +#include <string> + +namespace KODI::PLAYLIST { -class CPlayListM3U : - public CPlayList +class CPlayListM3U : public CPlayList { public: static const char *StartMarker; diff --git a/xbmc/playlists/PlayListPLS.cpp b/xbmc/playlists/PlayListPLS.cpp index 29cd4eb1b7..4520c05d2e 100644 --- a/xbmc/playlists/PlayListPLS.cpp +++ b/xbmc/playlists/PlayListPLS.cpp @@ -28,13 +28,14 @@ #include <string> #include <vector> -using namespace KODI; using namespace XFILE; -using namespace PLAYLIST; #define START_PLAYLIST_MARKER "[playlist]" // may be case-insensitive (equivalent to .ini file on win32) #define PLAYLIST_NAME "PlaylistName" +namespace KODI::PLAYLIST +{ + /*---------------------------------------------------------------------- [playlist] PlaylistName=Playlist 001 @@ -427,3 +428,5 @@ bool CPlayListPLS::Resize(std::vector <int>::size_type newSize) } return true; } + +} // namespace KODI::PLAYLIST diff --git a/xbmc/playlists/PlayListPLS.h b/xbmc/playlists/PlayListPLS.h index 50d58e3916..2e400cbdd0 100644 --- a/xbmc/playlists/PlayListPLS.h +++ b/xbmc/playlists/PlayListPLS.h @@ -13,10 +13,9 @@ #include <string> #include <vector> -namespace PLAYLIST +namespace KODI::PLAYLIST { -class CPlayListPLS : - public CPlayList +class CPlayListPLS : public CPlayList { public: CPlayListPLS(void); @@ -39,6 +38,4 @@ class CPlayListRAM : public CPlayList public: bool LoadData(std::istream &stream) override; }; - - } diff --git a/xbmc/playlists/PlayListTypes.h b/xbmc/playlists/PlayListTypes.h index 84462c1b0b..cf8ad2efb6 100644 --- a/xbmc/playlists/PlayListTypes.h +++ b/xbmc/playlists/PlayListTypes.h @@ -8,15 +8,16 @@ #pragma once -namespace PLAYLIST +namespace KODI::PLAYLIST { -using Id = int; - -constexpr Id TYPE_NONE = -1; //! Playlist id of type none -constexpr Id TYPE_MUSIC = 0; //! Playlist id of type music -constexpr Id TYPE_VIDEO = 1; //! Playlist id of type video -constexpr Id TYPE_PICTURE = 2; //! Playlist id of type picture +enum class Id : int +{ + TYPE_NONE = -1, + TYPE_MUSIC = 0, + TYPE_VIDEO = 1, + TYPE_PICTURE = 2 +}; /*! * \brief Manages playlist playing. @@ -28,4 +29,4 @@ enum class RepeatState ALL }; -} // namespace PLAYLIST +} // namespace KODI::PLAYLIST diff --git a/xbmc/playlists/PlayListURL.cpp b/xbmc/playlists/PlayListURL.cpp index f2ec4e3f72..0cf689c4a3 100644 --- a/xbmc/playlists/PlayListURL.cpp +++ b/xbmc/playlists/PlayListURL.cpp @@ -13,7 +13,6 @@ #include "utils/StringUtils.h" #include "utils/URIUtils.h" -using namespace PLAYLIST; using namespace XFILE; // example url file @@ -22,6 +21,9 @@ using namespace XFILE; //[InternetShortcut] //URL=http://msdn2.microsoft.com/en-us/library/ms812698.aspx +namespace KODI::PLAYLIST +{ + CPlayListURL::CPlayListURL(void) = default; CPlayListURL::~CPlayListURL(void) = default; @@ -67,3 +69,4 @@ bool CPlayListURL::Load(const std::string& strFileName) return true; } +} // namespace KODI::PLAYLIST diff --git a/xbmc/playlists/PlayListURL.h b/xbmc/playlists/PlayListURL.h index d0baa0a452..f0259476f7 100644 --- a/xbmc/playlists/PlayListURL.h +++ b/xbmc/playlists/PlayListURL.h @@ -10,10 +10,9 @@ #include "PlayList.h" -namespace PLAYLIST +namespace KODI::PLAYLIST { -class CPlayListURL : - public CPlayList +class CPlayListURL : public CPlayList { public: CPlayListURL(void); diff --git a/xbmc/playlists/PlayListWPL.cpp b/xbmc/playlists/PlayListWPL.cpp index e7142ffc6e..fd9ff01867 100644 --- a/xbmc/playlists/PlayListWPL.cpp +++ b/xbmc/playlists/PlayListWPL.cpp @@ -21,7 +21,6 @@ #include <string> using namespace XFILE; -using namespace PLAYLIST; /* ------------------------ example wpl playlist file --------------------------------- <?wpl version="1.0"?> @@ -42,6 +41,9 @@ using namespace PLAYLIST; ------------------------ end of example wpl playlist file ---------------------------------*/ //Note: File is utf-8 encoded by default +namespace KODI::PLAYLIST +{ + CPlayListWPL::CPlayListWPL(void) = default; CPlayListWPL::~CPlayListWPL(void) = default; @@ -128,3 +130,5 @@ void CPlayListWPL::Save(const std::string& strFileName) const file.Write(write.c_str(), write.size()); file.Close(); } + +} // namespace KODI::PLAYLIST diff --git a/xbmc/playlists/PlayListWPL.h b/xbmc/playlists/PlayListWPL.h index e0bdf68e6f..1ee2f3716f 100644 --- a/xbmc/playlists/PlayListWPL.h +++ b/xbmc/playlists/PlayListWPL.h @@ -10,11 +10,10 @@ #include "PlayList.h" -namespace PLAYLIST +namespace KODI::PLAYLIST { -class CPlayListWPL : - public CPlayList +class CPlayListWPL : public CPlayList { public: CPlayListWPL(void); diff --git a/xbmc/playlists/PlayListXML.cpp b/xbmc/playlists/PlayListXML.cpp index 82af079044..043a36fa97 100644 --- a/xbmc/playlists/PlayListXML.cpp +++ b/xbmc/playlists/PlayListXML.cpp @@ -18,7 +18,6 @@ #include "utils/XMLUtils.h" #include "utils/log.h" -using namespace PLAYLIST; using namespace XFILE; /* @@ -53,6 +52,8 @@ using namespace XFILE; </streams> */ +namespace KODI::PLAYLIST +{ CPlayListXML::CPlayListXML(void) = default; @@ -195,3 +196,5 @@ void CPlayListXML::Save(const std::string& strFileName) const file.Write(write.c_str(), write.size()); file.Close(); } + +} // namespace KODI::PLAYLIST diff --git a/xbmc/playlists/PlayListXML.h b/xbmc/playlists/PlayListXML.h index d1e18bc9cf..784761dbd0 100644 --- a/xbmc/playlists/PlayListXML.h +++ b/xbmc/playlists/PlayListXML.h @@ -10,10 +10,9 @@ #include "PlayList.h" -namespace PLAYLIST +namespace KODI::PLAYLIST { -class CPlayListXML : - public CPlayList +class CPlayListXML : public CPlayList { public: CPlayListXML(void); diff --git a/xbmc/playlists/PlayListXSPF.cpp b/xbmc/playlists/PlayListXSPF.cpp index 6f665a790c..3b49eb64df 100644 --- a/xbmc/playlists/PlayListXSPF.cpp +++ b/xbmc/playlists/PlayListXSPF.cpp @@ -16,8 +16,6 @@ #include "utils/XBMCTinyXML.h" #include "utils/log.h" -using namespace PLAYLIST; - namespace { @@ -41,6 +39,9 @@ std::string GetXMLText(const TiXmlElement* pXmlElement) } +namespace KODI::PLAYLIST +{ + CPlayListXSPF::CPlayListXSPF(void) = default; CPlayListXSPF::~CPlayListXSPF(void) = default; @@ -130,3 +131,5 @@ bool CPlayListXSPF::Load(const std::string& strFileName) return true; } + +} // namespace KODI::PLAYLIST diff --git a/xbmc/playlists/PlayListXSPF.h b/xbmc/playlists/PlayListXSPF.h index 8960460f78..b16b809442 100644 --- a/xbmc/playlists/PlayListXSPF.h +++ b/xbmc/playlists/PlayListXSPF.h @@ -10,7 +10,7 @@ #include "PlayList.h" -namespace PLAYLIST +namespace KODI::PLAYLIST { class CPlayListXSPF : public CPlayList { diff --git a/xbmc/playlists/SmartPlayList.cpp b/xbmc/playlists/SmartPlayList.cpp index dc83a75145..4338bbec8c 100644 --- a/xbmc/playlists/SmartPlayList.cpp +++ b/xbmc/playlists/SmartPlayList.cpp @@ -35,6 +35,9 @@ using namespace XFILE; +namespace KODI::PLAYLIST +{ + typedef struct { char string[17]; @@ -1608,3 +1611,5 @@ CDatabaseQueryRuleCombination *CSmartPlaylist::CreateCombination() const { return new CSmartPlaylistRuleCombination(); } + +} // namespace KODI::PLAYLIST diff --git a/xbmc/playlists/SmartPlayList.h b/xbmc/playlists/SmartPlayList.h index 2a153c389a..1b027ce67a 100644 --- a/xbmc/playlists/SmartPlayList.h +++ b/xbmc/playlists/SmartPlayList.h @@ -12,14 +12,18 @@ #include "utils/SortUtils.h" #include "utils/XBMCTinyXML.h" -#include <memory> #include <set> #include <string> #include <vector> +class CGUIDialogSmartPlaylistEditor; +class CGUIDialogMediaFilter; class CURL; class CVariant; +namespace KODI::PLAYLIST +{ + class CSmartPlaylistRule : public CDatabaseQueryRule { public: @@ -66,7 +70,11 @@ protected: private: std::string GetVideoResolutionQuery(const std::string ¶meter) const; - static std::string FormatLinkQuery(const char *field, const char *table, const MediaType& mediaType, const std::string& mediaField, const std::string& parameter); + static std::string FormatLinkQuery(const char* field, + const char* table, + const MediaType& mediaType, + const std::string& mediaField, + const std::string& parameter); std::string FormatYearQuery(const std::string& field, const std::string& param, const std::string& parameter) const; @@ -114,8 +122,16 @@ public: bool IsVideoType() const; bool IsMusicType() const; - void SetMatchAllRules(bool matchAll) { m_ruleCombination.SetType(matchAll ? CSmartPlaylistRuleCombination::CombinationAnd : CSmartPlaylistRuleCombination::CombinationOr); } - bool GetMatchAllRules() const { return m_ruleCombination.GetType() == CSmartPlaylistRuleCombination::CombinationAnd; } + void SetMatchAllRules(bool matchAll) + { + m_ruleCombination.SetType(matchAll ? CSmartPlaylistRuleCombination::CombinationAnd + : CSmartPlaylistRuleCombination::CombinationOr); + } + + bool GetMatchAllRules() const + { + return m_ruleCombination.GetType() == CSmartPlaylistRuleCombination::CombinationAnd; + } void SetLimit(unsigned int limit) { m_limit = limit; } unsigned int GetLimit() const { return m_limit; } @@ -160,9 +176,10 @@ public: // rule creation CDatabaseQueryRule *CreateRule() const override; CDatabaseQueryRuleCombination *CreateCombination() const override; + private: - friend class CGUIDialogSmartPlaylistEditor; - friend class CGUIDialogMediaFilter; + friend class ::CGUIDialogSmartPlaylistEditor; + friend class ::CGUIDialogMediaFilter; const TiXmlNode* readName(const TiXmlNode *root); const TiXmlNode* readNameFromPath(const CURL &url); @@ -184,3 +201,4 @@ private: CXBMCTinyXML m_xmlDoc; }; +} // namespace KODI::PLAYLIST diff --git a/xbmc/playlists/SmartPlaylistFileItemListModifier.cpp b/xbmc/playlists/SmartPlaylistFileItemListModifier.cpp index 443dabcd4e..20beb18c62 100644 --- a/xbmc/playlists/SmartPlaylistFileItemListModifier.cpp +++ b/xbmc/playlists/SmartPlaylistFileItemListModifier.cpp @@ -20,6 +20,9 @@ #define PROPERTY_SORT_ORDER "sort.order" #define PROPERTY_SORT_ASCENDING "sort.ascending" +namespace KODI::PLAYLIST +{ + bool CSmartPlaylistFileItemListModifier::CanModify(const CFileItemList &items) const { return !GetUrlOption(items.GetPath(), URL_OPTION_XSP).empty(); @@ -53,3 +56,5 @@ std::string CSmartPlaylistFileItemListModifier::GetUrlOption(const std::string & CURL url(path); return url.GetOption(option); } + +} // namespace KODI::PLAYLIST diff --git a/xbmc/playlists/SmartPlaylistFileItemListModifier.h b/xbmc/playlists/SmartPlaylistFileItemListModifier.h index 5d640847b7..7b2bbce552 100644 --- a/xbmc/playlists/SmartPlaylistFileItemListModifier.h +++ b/xbmc/playlists/SmartPlaylistFileItemListModifier.h @@ -12,6 +12,9 @@ #include <string> +namespace KODI::PLAYLIST +{ + class CSmartPlaylistFileItemListModifier : public IFileItemListModifier { public: @@ -24,3 +27,5 @@ public: private: static std::string GetUrlOption(const std::string &path, const std::string &option); }; + +} // namespace KODI::PLAYLIST diff --git a/xbmc/playlists/test/TestPlayListB4S.cpp b/xbmc/playlists/test/TestPlayListB4S.cpp index 04a6632dc1..45d83194a3 100644 --- a/xbmc/playlists/test/TestPlayListB4S.cpp +++ b/xbmc/playlists/test/TestPlayListB4S.cpp @@ -16,13 +16,12 @@ #include <fstream> #include <gtest/gtest.h> -using namespace PLAYLIST; - +using namespace KODI; TEST(TestPlayListB4S, LoadData) { const std::string filename = XBMC_REF_FILE_PATH("/xbmc/playlists/test/test.b4s"); - CPlayListB4S playlist; + PLAYLIST::CPlayListB4S playlist; std::filebuf fb; if (!fb.open(filename, std::ios::in)) diff --git a/xbmc/playlists/test/TestPlayListFactory.cpp b/xbmc/playlists/test/TestPlayListFactory.cpp index 08b2b4b446..b201278d8f 100644 --- a/xbmc/playlists/test/TestPlayListFactory.cpp +++ b/xbmc/playlists/test/TestPlayListFactory.cpp @@ -15,24 +15,23 @@ #include <gtest/gtest.h> -using namespace PLAYLIST; - +using namespace KODI; TEST(TestPlayListFactory, XSPF) { std::string filename = XBMC_REF_FILE_PATH("/xbmc/playlists/test/newfile.xspf"); CURL url("http://example.com/playlists/playlist.xspf"); - CPlayList* playlist = nullptr; + PLAYLIST::CPlayList* playlist = nullptr; - EXPECT_TRUE(CPlayListFactory::IsPlaylist(url)); - EXPECT_TRUE(CPlayListFactory::IsPlaylist(filename)); + EXPECT_TRUE(PLAYLIST::CPlayListFactory::IsPlaylist(url)); + EXPECT_TRUE(PLAYLIST::CPlayListFactory::IsPlaylist(filename)); - playlist = CPlayListFactory::Create(filename); + playlist = PLAYLIST::CPlayListFactory::Create(filename); EXPECT_NE(playlist, nullptr); if (playlist) { - EXPECT_NE(dynamic_cast<CPlayListXSPF*>(playlist), nullptr); + EXPECT_NE(dynamic_cast<PLAYLIST::CPlayListXSPF*>(playlist), nullptr); delete playlist; } } diff --git a/xbmc/playlists/test/TestPlayListXSPF.cpp b/xbmc/playlists/test/TestPlayListXSPF.cpp index 574d05d120..b46895731e 100644 --- a/xbmc/playlists/test/TestPlayListXSPF.cpp +++ b/xbmc/playlists/test/TestPlayListXSPF.cpp @@ -15,13 +15,12 @@ #include <gtest/gtest.h> -using namespace PLAYLIST; - +using namespace KODI; TEST(TestPlayListXSPF, Load) { std::string filename = XBMC_REF_FILE_PATH("/xbmc/playlists/test/test.xspf"); - CPlayListXSPF playlist; + PLAYLIST::CPlayListXSPF playlist; std::vector<std::string> pathparts; std::vector<std::string>::reverse_iterator it; diff --git a/xbmc/profiles/ProfileManager.cpp b/xbmc/profiles/ProfileManager.cpp index 827bfb112f..8b181dd9dd 100644 --- a/xbmc/profiles/ProfileManager.cpp +++ b/xbmc/profiles/ProfileManager.cpp @@ -77,6 +77,7 @@ #define XML_NEXTID "nextIdProfile" #define XML_PROFILE "profile" +using namespace KODI; using namespace XFILE; static CProfile EmptyProfile; @@ -388,9 +389,9 @@ void CProfileManager::FinalizeLoadProfile() if (m_lastUsedProfile != m_currentProfile) { - playlistManager.ClearPlaylist(PLAYLIST::TYPE_VIDEO); - playlistManager.ClearPlaylist(PLAYLIST::TYPE_MUSIC); - playlistManager.SetCurrentPlaylist(PLAYLIST::TYPE_NONE); + playlistManager.ClearPlaylist(PLAYLIST::Id::TYPE_VIDEO); + playlistManager.ClearPlaylist(PLAYLIST::Id::TYPE_MUSIC); + playlistManager.SetCurrentPlaylist(PLAYLIST::Id::TYPE_NONE); } networkManager.NetworkMessage(CNetworkBase::SERVICES_UP, 1); diff --git a/xbmc/pvr/PVRPlaybackState.cpp b/xbmc/pvr/PVRPlaybackState.cpp index 34f0ff5b97..e29887ddce 100644 --- a/xbmc/pvr/PVRPlaybackState.cpp +++ b/xbmc/pvr/PVRPlaybackState.cpp @@ -222,7 +222,7 @@ void CPVRPlaybackState::OnPlaybackStarted(const CFileItem& item) const std::shared_ptr<const CPVRClient> client = CServiceBroker::GetPVRManager().GetClient(m_playingClientId); if (client) - m_strPlayingClientName = client->GetFriendlyName(); + m_strPlayingClientName = client->GetFullClientName(); } } diff --git a/xbmc/pvr/addons/PVRClient.cpp b/xbmc/pvr/addons/PVRClient.cpp index 98cfe8db2a..16ea68b8ab 100644 --- a/xbmc/pvr/addons/PVRClient.cpp +++ b/xbmc/pvr/addons/PVRClient.cpp @@ -408,28 +408,30 @@ const std::string& CPVRClient::GetConnectionString() const return m_strConnectionString; } -const std::string CPVRClient::GetFriendlyName() const +std::string CPVRClient::GetClientName() const { + return Name(); +} +std::string CPVRClient::GetInstanceName() const +{ + std::string instanceName; if (Addon()->SupportsInstanceSettings()) - { - std::string instanceName; Addon()->GetSettingString(ADDON_SETTING_INSTANCE_NAME_VALUE, instanceName, InstanceId()); - if (!instanceName.empty()) - return StringUtils::Format("{} ({})", Name(), instanceName); - } - return Name(); + + return instanceName; } -std::string CPVRClient::GetInstanceName() const +std::string CPVRClient::GetFullClientName() const { if (Addon()->SupportsInstanceSettings()) { std::string instanceName; Addon()->GetSettingString(ADDON_SETTING_INSTANCE_NAME_VALUE, instanceName, InstanceId()); - return instanceName; + if (!instanceName.empty()) + return StringUtils::Format("{} ({})", Name(), instanceName); } - return ""; + return Name(); } PVR_ERROR CPVRClient::GetDriveSpace(uint64_t& iTotal, uint64_t& iUsed) const @@ -1032,7 +1034,7 @@ PVR_ERROR CPVRClient::UpdateTimerTypes() CLog::LogF(LOGWARNING, "Add-on {} does not support timer types. It will work, but not benefit from " "the timer features introduced with PVR Addon API 2.0.0", - GetFriendlyName()); + Name()); // Create standard timer types (mostly) matching the timer functionality available in Isengard. // This is for migration only and does not make changes to the addons obsolete. Addons should @@ -1859,7 +1861,7 @@ void CPVRClient::cb_recording_notification(void* kodiInstance, } const std::string strLine1 = StringUtils::Format(g_localizeStrings.Get(bOnOff ? 19197 : 19198), - client->GetFriendlyName()); + client->GetFullClientName()); std::string strLine2; if (strName) strLine2 = strName; @@ -1872,7 +1874,7 @@ void CPVRClient::cb_recording_notification(void* kodiInstance, auto eventLog = CServiceBroker::GetEventLog(); if (eventLog) eventLog->Add(EventPtr( - new CNotificationEvent(client->GetFriendlyName(), strLine1, client->Icon(), strLine2))); + new CNotificationEvent(client->GetFullClientName(), strLine1, client->Icon(), strLine2))); CLog::LogFC(LOGDEBUG, LOGPVR, "Recording {} on client {}. name='{}' filename='{}'", bOnOff ? "started" : "finished", client->GetID(), strName, strFileName); diff --git a/xbmc/pvr/addons/PVRClient.h b/xbmc/pvr/addons/PVRClient.h index 42f634a775..9e8e491086 100644 --- a/xbmc/pvr/addons/PVRClient.h +++ b/xbmc/pvr/addons/PVRClient.h @@ -164,18 +164,26 @@ public: const std::string& GetConnectionString() const; /*! - * @brief A friendly name used to uniquely identify the addon instance + * @brief The name of the PVR client, as specified by the addon developer. * @return string that can be used in log messages and the GUI. */ - const std::string GetFriendlyName() const; + std::string GetClientName() const; /*! - * @brief The name used by the PVR client addon instance + * @brief The name of the PVR client addon instance, as specified by the user in the addon + * settings. Empty if addon does not support multiple instances. * @return string that can be used in log messages and the GUI. */ std::string GetInstanceName() const; /*! + * @brief A name used to uniquely identify the client, inclusing addon name and instance + * name, if multiple instances are supported by the client implementation. + * @return string that can be used in log messages and the GUI. + */ + std::string GetFullClientName() const; + + /*! * @brief Get the disk space reported by the server. * @param iTotal The total disk space. * @param iUsed The used disk space. diff --git a/xbmc/pvr/addons/PVRClients.cpp b/xbmc/pvr/addons/PVRClients.cpp index b2261d376d..46cf2f510a 100644 --- a/xbmc/pvr/addons/PVRClients.cpp +++ b/xbmc/pvr/addons/PVRClients.cpp @@ -885,7 +885,7 @@ void CPVRClients::ConnectionStateChange(CPVRClient* client, // Notify user. CServiceBroker::GetJobManager()->AddJob( - new CPVREventLogJob(bNotify, eLevel, client->GetFriendlyName(), strMsg, client->Icon()), + new CPVREventLogJob(bNotify, eLevel, client->GetFullClientName(), strMsg, client->Icon()), nullptr); } diff --git a/xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp b/xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp index efae8e7279..8bc352d0ff 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp @@ -840,7 +840,7 @@ void CGUIDialogPVRChannelManager::Update() CServiceBroker::GetPVRManager().GetClient(*channelFile); if (client) { - channelFile->SetProperty(PROPERTY_CLIENT_NAME, client->GetFriendlyName()); + channelFile->SetProperty(PROPERTY_CLIENT_NAME, client->GetFullClientName()); channelFile->SetProperty(PROPERTY_CLIENT_SUPPORTS_SETTINGS, client->GetClientCapabilities().SupportsChannelSettings()); } diff --git a/xbmc/pvr/dialogs/GUIDialogPVRClientPriorities.cpp b/xbmc/pvr/dialogs/GUIDialogPVRClientPriorities.cpp index ca83ba1298..5564552d19 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRClientPriorities.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRClientPriorities.cpp @@ -43,7 +43,7 @@ std::string CGUIDialogPVRClientPriorities::GetSettingsLabel( int iClientId = std::atoi(pSetting->GetId().c_str()); auto clientEntry = m_clients.find(iClientId); if (clientEntry != m_clients.end()) - return clientEntry->second->GetFriendlyName(); + return clientEntry->second->GetFullClientName(); CLog::LogF(LOGERROR, "Unable to obtain pvr client with id '{}'", iClientId); return CGUIDialogSettingsManualBase::GetLocalizedString(13205); // Unknown diff --git a/xbmc/pvr/dialogs/GUIDialogPVRGroupManager.cpp b/xbmc/pvr/dialogs/GUIDialogPVRGroupManager.cpp index 1fa8cd5175..1a5f33644b 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRGroupManager.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRGroupManager.cpp @@ -585,7 +585,7 @@ void CGUIDialogPVRGroupManager::Update() const std::shared_ptr<const CPVRClient> client = CServiceBroker::GetPVRManager().GetClient(*group); if (client) - group->SetProperty(PROPERTY_CLIENT_NAME, client->GetFriendlyName()); + group->SetProperty(PROPERTY_CLIENT_NAME, client->GetFullClientName()); } // Load group thumbnails diff --git a/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.cpp b/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.cpp index f6a3a2c651..9ff3dbb6b2 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.cpp @@ -890,7 +890,12 @@ void CGUIDialogPVRTimerSettings::InitializeChannelsList() { m_channelEntries.insert( {index, ChannelDescriptor(PVR_CHANNEL_INVALID_UID, client.second->GetID(), - g_localizeStrings.Get(809))}); // "Any channel" + clients.size() == 1 + // Any channel + ? g_localizeStrings.Get(809) + // Any channel from client "X" + : StringUtils::Format(g_localizeStrings.Get(853), + client.second->GetFullClientName()))}); ++index; } @@ -935,7 +940,7 @@ void CGUIDialogPVRTimerSettings::TypesFiller(const SettingConstPtr& setting, const auto client = clients->GetCreatedClient(typeEntry.second->GetClientId()); if (client) - clientName = client->GetFriendlyName(); + clientName = client->GetFullClientName(); list.emplace_back(typeEntry.second->GetDescription(), clientName, typeEntry.first, typeEntry.second->IsReminder() ? reminderTimerProps : recordingTimerProps); @@ -983,6 +988,31 @@ void CGUIDialogPVRTimerSettings::ChannelsFiller(const SettingConstPtr& setting, foundCurrent = true; } } + + if (foundCurrent) + { + // Verify m_channel is still valid. Update if not. + if (std::find_if(list.cbegin(), list.cend(), + [¤t](const auto& channel) + { return channel.value == current; }) == list.cend()) + { + // Set m_channel and current to first valid channel in list + const int first{list.front().value}; + const auto it = + std::find_if(pThis->m_channelEntries.cbegin(), pThis->m_channelEntries.cend(), + [first](const auto& channel) { return channel.first == first; }); + + if (it != pThis->m_channelEntries.cend()) + { + current = (*it).first; + pThis->m_channel = (*it).second; + } + else + { + CLog::LogF(LOGERROR, "Unable to find channel to select"); + } + } + } } else CLog::LogF(LOGERROR, "No dialog"); diff --git a/xbmc/pvr/guilib/PVRGUIActionsChannels.cpp b/xbmc/pvr/guilib/PVRGUIActionsChannels.cpp index fb61fc2e6f..f5b9831c8f 100644 --- a/xbmc/pvr/guilib/PVRGUIActionsChannels.cpp +++ b/xbmc/pvr/guilib/PVRGUIActionsChannels.cpp @@ -282,7 +282,7 @@ bool CPVRGUIActionsChannels::StartChannelScan(int clientId) pDialog->SetHeading(CVariant{19119}); // "On which backend do you want to search?" for (const auto& client : possibleScanClients) - pDialog->Add(client->GetFriendlyName()); + pDialog->Add(client->GetFullClientName()); pDialog->Open(); @@ -307,7 +307,7 @@ bool CPVRGUIActionsChannels::StartChannelScan(int clientId) /* start the channel scan */ CLog::LogFC(LOGDEBUG, LOGPVR, "Starting to scan for channels on client {}", - scanClient->GetFriendlyName()); + scanClient->GetFullClientName()); auto start = std::chrono::steady_clock::now(); /* do the scan */ diff --git a/xbmc/pvr/guilib/PVRGUIActionsClients.cpp b/xbmc/pvr/guilib/PVRGUIActionsClients.cpp index b9c598c794..191be4be6e 100644 --- a/xbmc/pvr/guilib/PVRGUIActionsClients.cpp +++ b/xbmc/pvr/guilib/PVRGUIActionsClients.cpp @@ -73,7 +73,7 @@ bool CPVRGUIActionsClients::ProcessSettingsMenuHooks() if (clients.size() == 1) pDialog->Add(hook.second.GetLabel()); else - pDialog->Add(hook.first->GetFriendlyName() + ": " + hook.second.GetLabel()); + pDialog->Add(hook.first->GetFullClientName() + ": " + hook.second.GetLabel()); } pDialog->Open(); diff --git a/xbmc/pvr/guilib/PVRGUIActionsTimers.cpp b/xbmc/pvr/guilib/PVRGUIActionsTimers.cpp index e515a9dd00..fd93a312d8 100644 --- a/xbmc/pvr/guilib/PVRGUIActionsTimers.cpp +++ b/xbmc/pvr/guilib/PVRGUIActionsTimers.cpp @@ -831,7 +831,7 @@ void AddEventLogEntry(const std::shared_ptr<const CPVRTimerInfoTag>& timer, int CServiceBroker::GetPVRManager().GetClient(timer->GetTimerType()->GetClientId()); if (client) { - name = client->GetFriendlyName(); + name = client->GetFullClientName(); icon = client->Icon(); } else diff --git a/xbmc/pvr/guilib/guiinfo/PVRGUIInfo.cpp b/xbmc/pvr/guilib/guiinfo/PVRGUIInfo.cpp index 03b5ef0bdd..fb09aba999 100644 --- a/xbmc/pvr/guilib/guiinfo/PVRGUIInfo.cpp +++ b/xbmc/pvr/guilib/guiinfo/PVRGUIInfo.cpp @@ -425,6 +425,15 @@ bool CPVRGUIInfo::GetListItemAndPlayerLabel(const CFileItem* item, case LISTITEM_CHANNEL_NAME: strValue = timer->ChannelName(); return true; + case LISTITEM_CHANNEL_LOGO: + strValue = timer->ChannelIcon(); + return true; + case LISTITEM_PVR_CLIENT_NAME: + strValue = CServiceBroker::GetPVRManager().GetClient(timer->ClientID())->GetClientName(); + return true; + case LISTITEM_PVR_INSTANCE_NAME: + strValue = CServiceBroker::GetPVRManager().GetClient(timer->ClientID())->GetInstanceName(); + return true; case LISTITEM_EPG_EVENT_TITLE: case LISTITEM_EPG_EVENT_ICON: case LISTITEM_GENRE: @@ -439,14 +448,6 @@ bool CPVRGUIInfo::GetListItemAndPlayerLabel(const CFileItem* item, case LISTITEM_CHANNEL_NUMBER: case LISTITEM_PREMIERED: break; // obtain value from channel/epg - case LISTITEM_BACKEND_INSTANCE_NAME: - { - strValue = CServiceBroker::GetPVRManager() - .Clients() - ->GetCreatedClient(timer->ClientID()) - ->GetInstanceName(); - return true; - } default: return false; } @@ -487,7 +488,6 @@ bool CPVRGUIInfo::GetListItemAndPlayerLabel(const CFileItem* item, if (recording->HasExpirationTime()) { strValue = GetAsLocalizedTimeString(recording->ExpirationTimeAsLocalTime()); - ; return true; } break; @@ -525,6 +525,18 @@ bool CPVRGUIInfo::GetListItemAndPlayerLabel(const CFileItem* item, } break; } + case VIDEOPLAYER_CHANNEL_LOGO: + case LISTITEM_CHANNEL_LOGO: + { + const std::shared_ptr<const CPVRChannelGroupMember> groupMember = + CServiceBroker::GetPVRManager().Get<PVR::GUI::Channels>().GetChannelGroupMember(*item); + if (groupMember) + { + strValue = groupMember->Channel()->IconPath(); + return true; + } + break; + } case LISTITEM_ICON: if (recording->ClientIconPath().empty() && recording->ClientThumbnailPath().empty() && // Only use a fallback if there is more than a single provider available @@ -566,14 +578,14 @@ bool CPVRGUIInfo::GetListItemAndPlayerLabel(const CFileItem* item, return true; } return false; - case LISTITEM_BACKEND_INSTANCE_NAME: - { - strValue = CServiceBroker::GetPVRManager() - .Clients() - ->GetCreatedClient(recording->ClientID()) - ->GetInstanceName(); + case LISTITEM_PVR_CLIENT_NAME: + strValue = + CServiceBroker::GetPVRManager().GetClient(recording->ClientID())->GetClientName(); + return true; + case LISTITEM_PVR_INSTANCE_NAME: + strValue = + CServiceBroker::GetPVRManager().GetClient(recording->ClientID())->GetInstanceName(); return true; - } } return false; } @@ -771,14 +783,12 @@ bool CPVRGUIInfo::GetListItemAndPlayerLabel(const CFileItem* item, case LISTITEM_PARENTAL_RATING_CODE: strValue = epgTag->ParentalRatingCode(); return true; - case LISTITEM_BACKEND_INSTANCE_NAME: - { - strValue = CServiceBroker::GetPVRManager() - .Clients() - ->GetCreatedClient(epgTag->ClientID()) - ->GetInstanceName(); + case LISTITEM_PVR_CLIENT_NAME: + strValue = CServiceBroker::GetPVRManager().GetClient(epgTag->ClientID())->GetClientName(); + return true; + case LISTITEM_PVR_INSTANCE_NAME: + strValue = CServiceBroker::GetPVRManager().GetClient(epgTag->ClientID())->GetInstanceName(); return true; - } case VIDEOPLAYER_PREMIERED: case LISTITEM_PREMIERED: if (epgTag->FirstAired().IsValid()) @@ -819,13 +829,17 @@ bool CPVRGUIInfo::GetListItemAndPlayerLabel(const CFileItem* item, if (!strValue.empty()) return true; } - // fall-thru is intended [[fallthrough]]; } case VIDEOPLAYER_CHANNEL_NAME: case LISTITEM_CHANNEL_NAME: strValue = channel->ChannelName(); return true; + case MUSICPLAYER_CHANNEL_LOGO: + case VIDEOPLAYER_CHANNEL_LOGO: + case LISTITEM_CHANNEL_LOGO: + strValue = channel->IconPath(); + return true; case MUSICPLAYER_CHANNEL_NUMBER: case VIDEOPLAYER_CHANNEL_NUMBER: case LISTITEM_CHANNEL_NUMBER: @@ -849,6 +863,13 @@ bool CPVRGUIInfo::GetListItemAndPlayerLabel(const CFileItem* item, strValue = channel->IsRadio() ? m_strPlayingRadioGroup : m_strPlayingTVGroup; return true; } + case LISTITEM_PVR_CLIENT_NAME: + strValue = CServiceBroker::GetPVRManager().GetClient(channel->ClientID())->GetClientName(); + return true; + case LISTITEM_PVR_INSTANCE_NAME: + strValue = + CServiceBroker::GetPVRManager().GetClient(channel->ClientID())->GetInstanceName(); + return true; } } @@ -1339,6 +1360,9 @@ bool CPVRGUIInfo::GetPVRInt(const CFileItem* item, const CGUIInfo& info, int& iV else iValue = 0xFF; return true; + case PVR_CLIENT_COUNT: + iValue = CServiceBroker::GetPVRManager().Clients()->EnabledClientAmount(); + return true; } return false; } diff --git a/xbmc/pvr/timers/PVRTimers.cpp b/xbmc/pvr/timers/PVRTimers.cpp index 5b899d21b6..69ac22f319 100644 --- a/xbmc/pvr/timers/PVRTimers.cpp +++ b/xbmc/pvr/timers/PVRTimers.cpp @@ -391,7 +391,7 @@ bool CPVRTimers::UpdateEntries(const CPVRTimersContainer& timers, { job->AddEvent(m_settings.GetBoolValue(CSettings::SETTING_PVRRECORD_TIMERNOTIFICATIONS), EventLevel::Information, // info, no error - client->GetFriendlyName(), entry.second, client->Icon()); + client->GetFullClientName(), entry.second, client->Icon()); } } @@ -511,7 +511,7 @@ bool CPVRTimers::UpdateEntries(int iMaxNotificationDelay) bool bDeleteTimer = false; if (!timer->IsOwnedByClient()) { - if (timer->IsEpgBased()) + if (timer->IsEpgBased() && timer->Channel()) { // update epg tag const std::shared_ptr<const CPVREpg> epg = diff --git a/xbmc/pvr/windows/GUIWindowPVRBase.cpp b/xbmc/pvr/windows/GUIWindowPVRBase.cpp index ce891a80f7..c6ef99abce 100644 --- a/xbmc/pvr/windows/GUIWindowPVRBase.cpp +++ b/xbmc/pvr/windows/GUIWindowPVRBase.cpp @@ -423,7 +423,7 @@ bool CGUIWindowPVRBase::OpenChannelGroupSelectionDialog() auto client = pvrMgr.GetClient(channelGroup->GetClientID()); if (client) - selectedClient = client->GetFriendlyName(); + selectedClient = client->GetFullClientName(); } CPVRThumbLoader loader; @@ -433,7 +433,7 @@ bool CGUIWindowPVRBase::OpenChannelGroupSelectionDialog() // set client name as label2 const std::shared_ptr<const CPVRClient> client = pvrMgr.GetClient(*group); if (client) - group->SetLabel2(client->GetFriendlyName()); + group->SetLabel2(client->GetFullClientName()); // set thumbnail loader.LoadItem(group.get()); diff --git a/xbmc/settings/MediaSettings.cpp b/xbmc/settings/MediaSettings.cpp index e3027df998..097a9c11f0 100644 --- a/xbmc/settings/MediaSettings.cpp +++ b/xbmc/settings/MediaSettings.cpp @@ -162,11 +162,12 @@ bool CMediaSettings::Load(const TiXmlNode *settings) // Set music playlist player repeat and shuffle from loaded settings if (m_musicPlaylistRepeat) - CServiceBroker::GetPlaylistPlayer().SetRepeat(PLAYLIST::TYPE_MUSIC, PLAYLIST::RepeatState::ALL); + CServiceBroker::GetPlaylistPlayer().SetRepeat(PLAYLIST::Id::TYPE_MUSIC, + PLAYLIST::RepeatState::ALL); else - CServiceBroker::GetPlaylistPlayer().SetRepeat(PLAYLIST::TYPE_MUSIC, + CServiceBroker::GetPlaylistPlayer().SetRepeat(PLAYLIST::Id::TYPE_MUSIC, PLAYLIST::RepeatState::NONE); - CServiceBroker::GetPlaylistPlayer().SetShuffle(PLAYLIST::TYPE_MUSIC, m_musicPlaylistShuffle); + CServiceBroker::GetPlaylistPlayer().SetShuffle(PLAYLIST::Id::TYPE_MUSIC, m_musicPlaylistShuffle); // Read the watchmode settings for the various media views pElement = settings->FirstChildElement("myvideos"); @@ -194,11 +195,12 @@ bool CMediaSettings::Load(const TiXmlNode *settings) // Set video playlist player repeat and shuffle from loaded settings if (m_videoPlaylistRepeat) - CServiceBroker::GetPlaylistPlayer().SetRepeat(PLAYLIST::TYPE_VIDEO, PLAYLIST::RepeatState::ALL); + CServiceBroker::GetPlaylistPlayer().SetRepeat(PLAYLIST::Id::TYPE_VIDEO, + PLAYLIST::RepeatState::ALL); else - CServiceBroker::GetPlaylistPlayer().SetRepeat(PLAYLIST::TYPE_VIDEO, + CServiceBroker::GetPlaylistPlayer().SetRepeat(PLAYLIST::Id::TYPE_VIDEO, PLAYLIST::RepeatState::NONE); - CServiceBroker::GetPlaylistPlayer().SetShuffle(PLAYLIST::TYPE_VIDEO, m_videoPlaylistShuffle); + CServiceBroker::GetPlaylistPlayer().SetShuffle(PLAYLIST::Id::TYPE_VIDEO, m_videoPlaylistShuffle); return true; } diff --git a/xbmc/utils/BitstreamConverter.cpp b/xbmc/utils/BitstreamConverter.cpp index fe08a00a00..c485c838d8 100644 --- a/xbmc/utils/BitstreamConverter.cpp +++ b/xbmc/utils/BitstreamConverter.cpp @@ -15,14 +15,13 @@ #endif #include "BitstreamConverter.h" -#include "BitstreamReader.h" -#include "BitstreamWriter.h" #include "HevcSei.h" #include <algorithm> extern "C" { +#include <libavutil/intreadwrite.h> #ifdef HAVE_LIBDOVI #include <libdovi/rpu_parser.h> #endif @@ -626,7 +625,7 @@ bool CBitstreamConverter::Convert(uint8_t *pData, int iSize) uint8_t *nal_start = pData; while (nal_start < end) { - nal_size = BS_RB24(nal_start); + nal_size = AV_RB24(nal_start); avio_wb32(pb, nal_size); nal_start += 3; avio_write(pb, nal_start, nal_size); @@ -1087,7 +1086,7 @@ void CBitstreamConverter::BitstreamAllocAndCopy(uint8_t** poutbuf, memcpy(*poutbuf + sps_pps_size + nal_header_size + offset, in, in_size); if (!offset) { - BS_WB32(*poutbuf + sps_pps_size, 1); + AV_WB32(*poutbuf + sps_pps_size, 1); } else if (nal_header_size == 4) { @@ -1147,7 +1146,7 @@ int CBitstreamConverter::isom_write_avcc(AVIOContext *pb, const uint8_t *data, i if (len > 6) { /* check for h264 start code */ - if (BS_RB32(data) == 0x00000001 || BS_RB24(data) == 0x000001) + if (AV_RB32(data) == 0x00000001 || AV_RB24(data) == 0x000001) { uint8_t *buf=NULL, *end, *start; uint32_t sps_size=0, pps_size=0; @@ -1164,7 +1163,7 @@ int CBitstreamConverter::isom_write_avcc(AVIOContext *pb, const uint8_t *data, i { uint32_t size; uint8_t nal_type; - size = std::min<uint32_t>(BS_RB32(buf), end - buf - 4); + size = std::min<uint32_t>(AV_RB32(buf), end - buf - 4); buf += 4; nal_type = buf[0] & 0x1f; if (nal_type == 7) /* SPS */ diff --git a/xbmc/utils/BitstreamReader.cpp b/xbmc/utils/BitstreamReader.cpp index 1ec8a11057..ba71931bd9 100644 --- a/xbmc/utils/BitstreamReader.cpp +++ b/xbmc/utils/BitstreamReader.cpp @@ -8,6 +8,11 @@ #include "BitstreamReader.h" +extern "C" +{ +#include <libavutil/intreadwrite.h> +} + CBitstreamReader::CBitstreamReader(const uint8_t* buf, int len) : buffer(buf), start(buf), length(len) { @@ -90,7 +95,7 @@ const uint8_t* find_start_code(const uint8_t *p, const uint8_t *end, uint32_t *s } p = (p < end)? p - 4 : end - 4; - *state = BS_RB32(p); + *state = AV_RB32(p); return p + 4; } diff --git a/xbmc/utils/BitstreamReader.h b/xbmc/utils/BitstreamReader.h index e25c2db217..1a3232992d 100644 --- a/xbmc/utils/BitstreamReader.h +++ b/xbmc/utils/BitstreamReader.h @@ -26,27 +26,4 @@ private: int m_posBits{0}; }; -const uint8_t* find_start_code(const uint8_t *p, const uint8_t *end, uint32_t *state); - -//////////////////////////////////////////////////////////////////////////////////////////// -//! @todo refactor this so as not to need these ffmpeg routines. -//! These are not exposed in ffmpeg's API so we dupe them here. - -/* - * AVC helper functions for muxers - * Copyright (c) 2006 Baptiste Coudurier <baptiste.coudurier@smartjog.com> - * This is part of FFmpeg - * - * SPDX-License-Identifier: LGPL-2.1-or-later - * See LICENSES/README.md for more information. - */ -constexpr uint32_t BS_RB24(const uint8_t* x) -{ - return (x[0] << 16) | (x[1] << 8) | x[2]; -} - -constexpr uint32_t BS_RB32(const uint8_t* x) -{ - return (x[0] << 24) | (x[1] << 16) | (x[2] << 8) | x[3]; -} - +const uint8_t* find_start_code(const uint8_t* p, const uint8_t* end, uint32_t* state); diff --git a/xbmc/utils/BitstreamWriter.cpp b/xbmc/utils/BitstreamWriter.cpp deleted file mode 100644 index 9d247bb077..0000000000 --- a/xbmc/utils/BitstreamWriter.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (C) 2017-2018 Team Kodi - * This file is part of Kodi - https://kodi.tv - * - * SPDX-License-Identifier: GPL-2.0-or-later - * See LICENSES/README.md for more information. - */ - -#include "BitstreamWriter.h" - -CBitstreamWriter::CBitstreamWriter(uint8_t* buffer, unsigned int buffer_size, int writer_le) - : writer_le(writer_le), buf(buffer), buf_ptr(buf) -{ -} - -void CBitstreamWriter::WriteBits(int n, unsigned int value) -{ - // Write up to 32 bits into a bitstream. - unsigned int bit_buf; - int bit_left; - - if (n == 32) - { - // Write exactly 32 bits into a bitstream. - // danger, recursion in play. - int lo = value & 0xffff; - int hi = value >> 16; - if (writer_le) - { - WriteBits(16, lo); - WriteBits(16, hi); - } - else - { - WriteBits(16, hi); - WriteBits(16, lo); - } - return; - } - - bit_buf = this->bit_buf; - bit_left = this->bit_left; - - if (writer_le) - { - bit_buf |= value << (32 - bit_left); - if (n >= bit_left) { - BS_WL32(buf_ptr, bit_buf); - buf_ptr += 4; - bit_buf = (bit_left == 32) ? 0 : value >> bit_left; - bit_left += 32; - } - bit_left -= n; - } - else - { - if (n < bit_left) { - bit_buf = (bit_buf << n) | value; - bit_left -= n; - } - else { - bit_buf <<= bit_left; - bit_buf |= value >> (n - bit_left); - BS_WB32(buf_ptr, bit_buf); - buf_ptr += 4; - bit_left += 32 - n; - bit_buf = value; - } - } - - this->bit_buf = bit_buf; - this->bit_left = bit_left; -} - -void CBitstreamWriter::SkipBits(int n) -{ - // Skip the given number of bits. - // Must only be used if the actual values in the bitstream do not matter. - // If n is 0 the behavior is undefined. - bit_left -= n; - buf_ptr -= 4 * (bit_left >> 5); - bit_left &= 31; -} - -void CBitstreamWriter::FlushBits() -{ - if (!writer_le) - { - if (bit_left < 32) - bit_buf <<= bit_left; - } - while (bit_left < 32) - { - - if (writer_le) - { - *buf_ptr++ = bit_buf; - bit_buf >>= 8; - } - else - { - *buf_ptr++ = bit_buf >> 24; - bit_buf <<= 8; - } - bit_left += 8; - } - bit_left = 32; - bit_buf = 0; -} diff --git a/xbmc/utils/BitstreamWriter.h b/xbmc/utils/BitstreamWriter.h deleted file mode 100644 index 34390d8f8e..0000000000 --- a/xbmc/utils/BitstreamWriter.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2017-2018 Team Kodi - * This file is part of Kodi - https://kodi.tv - * - * SPDX-License-Identifier: GPL-2.0-or-later - * See LICENSES/README.md for more information. - */ - -#pragma once - -#include <stdint.h> - -class CBitstreamWriter -{ -public: - CBitstreamWriter(uint8_t *buffer, unsigned int buffer_size, int writer_le); - void WriteBits(int n, unsigned int value); - void SkipBits(int n); - void FlushBits(); - -private: - int writer_le; - uint32_t bit_buf = 0; - int bit_left = 32; - uint8_t *buf, *buf_ptr; -}; - -//////////////////////////////////////////////////////////////////////////////////////////// -//! @todo refactor this so as not to need these ffmpeg routines. -//! These are not exposed in ffmpeg's API so we dupe them here. - -/* - * AVC helper functions for muxers - * Copyright (c) 2006 Baptiste Coudurier <baptiste.coudurier@smartjog.com> - * This is part of FFmpeg - * - * SPDX-License-Identifier: LGPL-2.1-or-later - * See LICENSES/README.md for more information. - */ -#define BS_WB32(p, d) { \ - ((uint8_t*)(p))[3] = (d); \ - ((uint8_t*)(p))[2] = (d) >> 8; \ - ((uint8_t*)(p))[1] = (d) >> 16; \ - ((uint8_t*)(p))[0] = (d) >> 24; } - -#define BS_WL32(p, d) { \ - ((uint8_t*)(p))[0] = (d); \ - ((uint8_t*)(p))[1] = (d) >> 8; \ - ((uint8_t*)(p))[2] = (d) >> 16; \ - ((uint8_t*)(p))[3] = (d) >> 24; } diff --git a/xbmc/utils/CMakeLists.txt b/xbmc/utils/CMakeLists.txt index 87429d34c3..d486bcd976 100644 --- a/xbmc/utils/CMakeLists.txt +++ b/xbmc/utils/CMakeLists.txt @@ -6,7 +6,6 @@ set(SOURCES ActorProtocol.cpp BitstreamConverter.cpp BitstreamReader.cpp BitstreamStats.cpp - BitstreamWriter.cpp BooleanLogic.cpp CharArrayParser.cpp CharsetConverter.cpp @@ -51,7 +50,6 @@ set(SOURCES ActorProtocol.cpp PlayerUtils.cpp RecentlyAddedJob.cpp RegExp.cpp - rfft.cpp RingBuffer.cpp RssManager.cpp RssReader.cpp @@ -88,7 +86,6 @@ set(HEADERS ActorProtocol.h BitstreamConverter.h BitstreamReader.h BitstreamStats.h - BitstreamWriter.h BooleanLogic.h CharArrayParser.h CharsetConverter.h @@ -154,7 +151,6 @@ set(HEADERS ActorProtocol.h ProgressJob.h RecentlyAddedJob.h RegExp.h - rfft.h RingBuffer.h RssManager.h RssReader.h @@ -191,7 +187,7 @@ if(TARGET XSLT::XSLT) list(APPEND SOURCES XSLTUtils.cpp) list(APPEND HEADERS XSLTUtils.h) endif() -if(TARGET EGL::EGL) +if(TARGET ${APP_NAME_LC}::EGL) list(APPEND SOURCES EGLUtils.cpp EGLFence.cpp) list(APPEND HEADERS EGLUtils.h @@ -234,12 +230,12 @@ if("gbm" IN_LIST CORE_PLATFORM_NAME_LC OR "wayland" IN_LIST CORE_PLATFORM_NAME_L list(APPEND HEADERS GBMBufferObject.h) endif() - if(TARGET EGL::EGL) + if(TARGET ${APP_NAME_LC}::EGL) list(APPEND SOURCES EGLImage.cpp) list(APPEND HEADERS EGLImage.h) endif() - if(TARGET LIBDRM::LIBDRM) + if(TARGET ${APP_NAME_LC}::LibDRM) list(APPEND SOURCES DRMHelpers.cpp) list(APPEND HEADERS DRMHelpers.h) endif() diff --git a/xbmc/utils/rfft.cpp b/xbmc/utils/rfft.cpp deleted file mode 100644 index e0ae383725..0000000000 --- a/xbmc/utils/rfft.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2015-2018 Team Kodi - * This file is part of Kodi - https://kodi.tv - * - * SPDX-License-Identifier: GPL-2.0-or-later - * See LICENSES/README.md for more information. - */ - -#include "rfft.h" - -#if defined(TARGET_WINDOWS) && !defined(_USE_MATH_DEFINES) -#define _USE_MATH_DEFINES -#endif -#include <math.h> - -RFFT::RFFT(int size, bool windowed) : - m_size(size), m_windowed(windowed) -{ - m_cfg = kiss_fftr_alloc(m_size,0,nullptr,nullptr); -} - -RFFT::~RFFT() -{ - // we don' use kiss_fftr_free here because - // its hardcoded to free and doesn't pay attention - // to SIMD (which might be used during kiss_fftr_alloc - //in the C'tor). - KISS_FFT_FREE(m_cfg); -} - -void RFFT::calc(const float* input, float* output) -{ - // temporary buffers - std::vector<kiss_fft_scalar> linput(m_size), rinput(m_size); - std::vector<kiss_fft_cpx> loutput(m_size), routput(m_size); - - for (size_t i=0;i<m_size;++i) - { - linput[i] = input[2*i]; - rinput[i] = input[2*i+1]; - } - - if (m_windowed) - { - hann(linput); - hann(rinput); - } - - // transform channels - kiss_fftr(m_cfg, &linput[0], &loutput[0]); - kiss_fftr(m_cfg, &rinput[0], &routput[0]); - - auto&& filter = [&](kiss_fft_cpx& data) - { - return static_cast<double>(sqrt(data.r * data.r + data.i * data.i)) * 2.0 / m_size * - (m_windowed ? sqrt(8.0 / 3.0) : 1.0); - }; - - // interleave while taking magnitudes and normalizing - for (size_t i=0;i<m_size/2;++i) - { - output[2*i] = filter(loutput[i]); - output[2*i+1] = filter(routput[i]); - } -} - -#include <iostream> - -void RFFT::hann(std::vector<kiss_fft_scalar>& data) -{ - for (size_t i=0;i<data.size();++i) - data[i] *= 0.5f * (1.0f - cos(2.0f * static_cast<float>(M_PI) * i / (data.size() - 1))); -} diff --git a/xbmc/utils/rfft.h b/xbmc/utils/rfft.h deleted file mode 100644 index ce54d63a24..0000000000 --- a/xbmc/utils/rfft.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2015-2018 Team Kodi - * This file is part of Kodi - https://kodi.tv - * - * SPDX-License-Identifier: GPL-2.0-or-later - * See LICENSES/README.md for more information. - */ - -#pragma once - -#include <vector> - -#include <kissfft/kiss_fftr.h> - -//! \brief Class performing a RFFT of interleaved stereo data. -class RFFT -{ -public: - //! \brief The constructor creates a RFFT plan. - //! \brief size Length of time data for a single channel. - //! \brief windowed Whether or not to apply a Hann window to data. - RFFT(int size, bool windowed=false); - - //! \brief Free the RFFT plan - ~RFFT(); - - //! \brief Calculate FFTs - //! \param input Input data of size 2*m_size - //! \param output Output data of size m_size. - void calc(const float* input, float* output); -protected: - //! \brief Apply a Hann window to a buffer. - //! \param data Vector with data to apply window to. - static void hann(std::vector<kiss_fft_scalar>& data); - - size_t m_size; //!< Size for a single channel. - bool m_windowed; //!< Whether or not a Hann window is applied. - kiss_fftr_cfg m_cfg; //!< FFT plan -}; diff --git a/xbmc/utils/test/CMakeLists.txt b/xbmc/utils/test/CMakeLists.txt index 823c8c419e..3cdc5d6448 100644 --- a/xbmc/utils/test/CMakeLists.txt +++ b/xbmc/utils/test/CMakeLists.txt @@ -31,7 +31,6 @@ set(SOURCES TestAlarmClock.cpp TestMime.cpp TestPOUtils.cpp TestRegExp.cpp - Testrfft.cpp TestRingBuffer.cpp TestRssReader.cpp TestScraperParser.cpp diff --git a/xbmc/utils/test/Testrfft.cpp b/xbmc/utils/test/Testrfft.cpp deleted file mode 100644 index a6c859d7c4..0000000000 --- a/xbmc/utils/test/Testrfft.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2015-2018 Team Kodi - * This file is part of Kodi - https://kodi.tv - * - * SPDX-License-Identifier: GPL-2.0-or-later - * See LICENSES/README.md for more information. - */ - -#include "utils/rfft.h" - -#include <gtest/gtest.h> - -#if defined(TARGET_WINDOWS) && !defined(_USE_MATH_DEFINES) -#define _USE_MATH_DEFINES -#endif - -#include <math.h> - - -TEST(TestRFFT, SimpleSignal) -{ - const int size = 32; - const int freq1 = 5; - const int freq2[] = {1,7}; - std::vector<float> input(2*size); - std::vector<float> output(size); - for (size_t i=0;i<size;++i) - { - input[2*i] = cos(freq1*2.0*M_PI*i/size); - input[2*i+1] = cos(freq2[0]*2.0*M_PI*i/size)+cos(freq2[1]*2.0*M_PI*i/size); - } - RFFT transform(size, false); - - transform.calc(&input[0], &output[0]); - - for (int i=0;i<size/2;++i) - { - EXPECT_NEAR(output[2*i],(i==freq1?1.0:0.0), 1e-7); - EXPECT_NEAR(output[2*i+1], ((i==freq2[0]||i==freq2[1])?1.0:0.0), 1e-7); - } -} diff --git a/xbmc/video/ContextMenus.cpp b/xbmc/video/ContextMenus.cpp index 6bfd70fafd..af65bf1eb8 100644 --- a/xbmc/video/ContextMenus.cpp +++ b/xbmc/video/ContextMenus.cpp @@ -327,7 +327,7 @@ protected: private: void Play(const std::string& player = "") { - m_item->SetProperty("playlist_type_hint", PLAYLIST::TYPE_VIDEO); + m_item->SetProperty("playlist_type_hint", static_cast<int>(PLAYLIST::Id::TYPE_VIDEO)); const ContentUtils::PlayMode mode{m_item->GetProperty("CheckAutoPlayNextItem").asBoolean() ? ContentUtils::PlayMode::CHECK_AUTO_PLAY_NEXT_ITEM : ContentUtils::PlayMode::PLAY_ONLY_THIS}; @@ -350,7 +350,7 @@ void SetPathAndPlay(const std::shared_ptr<CFileItem>& item, PlayMode mode) if (item->IsLiveTV()) // pvr tv or pvr radio? { - g_application.PlayMedia(*item, "", PLAYLIST::TYPE_VIDEO); + g_application.PlayMedia(*item, "", PLAYLIST::Id::TYPE_VIDEO); } else { diff --git a/xbmc/video/GUIViewStateVideo.cpp b/xbmc/video/GUIViewStateVideo.cpp index 1cf1a0115c..f9c4ca06e0 100644 --- a/xbmc/video/GUIViewStateVideo.cpp +++ b/xbmc/video/GUIViewStateVideo.cpp @@ -25,7 +25,7 @@ #include "video/VideoFileItemClassify.h" #include "view/ViewStateSettings.h" -using namespace KODI::VIDEO; +using namespace KODI; using namespace XFILE; using namespace VIDEODATABASEDIRECTORY; @@ -41,7 +41,7 @@ std::string CGUIViewStateWindowVideo::GetExtensions() PLAYLIST::Id CGUIViewStateWindowVideo::GetPlaylist() const { - return PLAYLIST::TYPE_VIDEO; + return PLAYLIST::Id::TYPE_VIDEO; } VECSOURCES& CGUIViewStateWindowVideo::GetSources() @@ -72,7 +72,7 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it SetSortOrder(SortOrderNone); } - else if (IsVideoDb(items)) + else if (VIDEO::IsVideoDb(items)) { NODE_TYPE NodeType=CVideoDatabaseDirectory::GetDirectoryChildType(items.GetPath()); CQueryParams params; @@ -340,7 +340,7 @@ CGUIViewStateWindowVideoNav::CGUIViewStateWindowVideoNav(const CFileItemList& it void CGUIViewStateWindowVideoNav::SaveViewState() { - if (IsVideoDb(m_items)) + if (VIDEO::IsVideoDb(m_items)) { NODE_TYPE NodeType = CVideoDatabaseDirectory::GetDirectoryChildType(m_items.GetPath()); CQueryParams params; diff --git a/xbmc/video/GUIViewStateVideo.h b/xbmc/video/GUIViewStateVideo.h index 4a7a8e65e0..5cf2cdcde2 100644 --- a/xbmc/video/GUIViewStateVideo.h +++ b/xbmc/video/GUIViewStateVideo.h @@ -18,7 +18,7 @@ public: protected: VECSOURCES& GetSources() override; std::string GetLockType() override; - PLAYLIST::Id GetPlaylist() const override; + KODI::PLAYLIST::Id GetPlaylist() const override; std::string GetExtensions() override; bool AutoPlayNextItem() override; }; diff --git a/xbmc/video/VideoDatabase.cpp b/xbmc/video/VideoDatabase.cpp index d23851bbc0..1e9cf8993f 100644 --- a/xbmc/video/VideoDatabase.cpp +++ b/xbmc/video/VideoDatabase.cpp @@ -11848,7 +11848,7 @@ bool CVideoDatabase::GetFilter(CDbUrl &videoUrl, Filter &filter, SortDescription auto option = options.find("xsp"); if (option != options.end()) { - CSmartPlaylist xsp; + PLAYLIST::CSmartPlaylist xsp; if (!xsp.LoadFromJson(option->second.asString())) return false; @@ -11876,7 +11876,7 @@ bool CVideoDatabase::GetFilter(CDbUrl &videoUrl, Filter &filter, SortDescription option = options.find("filter"); if (option != options.end()) { - CSmartPlaylist xspFilter; + PLAYLIST::CSmartPlaylist xspFilter; if (!xspFilter.LoadFromJson(option->second.asString())) return false; diff --git a/xbmc/video/VideoDbUrl.cpp b/xbmc/video/VideoDbUrl.cpp index 45b8634da0..99db0db0b9 100644 --- a/xbmc/video/VideoDbUrl.cpp +++ b/xbmc/video/VideoDbUrl.cpp @@ -13,6 +13,7 @@ #include "utils/StringUtils.h" #include "utils/Variant.h" +using namespace KODI; using namespace XFILE; CVideoDbUrl::CVideoDbUrl() @@ -204,7 +205,7 @@ bool CVideoDbUrl::validateOption(const std::string &key, const CVariant &value) if (!value.isString()) return false; - CSmartPlaylist xspFilter; + PLAYLIST::CSmartPlaylist xspFilter; if (!xspFilter.LoadFromJson(value.asString())) return false; diff --git a/xbmc/video/dialogs/GUIDialogVideoInfo.cpp b/xbmc/video/dialogs/GUIDialogVideoInfo.cpp index d5b7e68b28..0a485003e6 100644 --- a/xbmc/video/dialogs/GUIDialogVideoInfo.cpp +++ b/xbmc/video/dialogs/GUIDialogVideoInfo.cpp @@ -765,7 +765,7 @@ private: item->m_bIsFolder = false; } - item->SetProperty("playlist_type_hint", PLAYLIST::TYPE_VIDEO); + item->SetProperty("playlist_type_hint", static_cast<int>(PLAYLIST::Id::TYPE_VIDEO)); const ContentUtils::PlayMode mode{item->GetProperty("CheckAutoPlayNextItem").asBoolean() ? ContentUtils::PlayMode::CHECK_AUTO_PLAY_NEXT_ITEM : ContentUtils::PlayMode::PLAY_ONLY_THIS}; diff --git a/xbmc/video/dialogs/GUIDialogVideoManager.cpp b/xbmc/video/dialogs/GUIDialogVideoManager.cpp index eedd73e0db..6b83e44a4b 100644 --- a/xbmc/video/dialogs/GUIDialogVideoManager.cpp +++ b/xbmc/video/dialogs/GUIDialogVideoManager.cpp @@ -285,7 +285,7 @@ protected: private: void Play() { - m_item->SetProperty("playlist_type_hint", PLAYLIST::TYPE_VIDEO); + m_item->SetProperty("playlist_type_hint", static_cast<int>(PLAYLIST::Id::TYPE_VIDEO)); const ContentUtils::PlayMode mode{m_item->GetProperty("CheckAutoPlayNextItem").asBoolean() ? ContentUtils::PlayMode::CHECK_AUTO_PLAY_NEXT_ITEM : ContentUtils::PlayMode::PLAY_ONLY_THIS}; diff --git a/xbmc/video/guilib/VideoGUIUtils.cpp b/xbmc/video/guilib/VideoGUIUtils.cpp index 8cadb0e755..9126393b0f 100644 --- a/xbmc/video/guilib/VideoGUIUtils.cpp +++ b/xbmc/video/guilib/VideoGUIUtils.cpp @@ -341,12 +341,12 @@ void AddItemToPlayListAndPlay(const std::shared_ptr<CFileItem>& itemToQueue, VIDEO::UTILS::GetItemsForPlayList(itemToQueue, queuedItems); auto& playlistPlayer = CServiceBroker::GetPlaylistPlayer(); - playlistPlayer.ClearPlaylist(PLAYLIST::TYPE_VIDEO); + playlistPlayer.ClearPlaylist(PLAYLIST::Id::TYPE_VIDEO); playlistPlayer.Reset(); - playlistPlayer.Add(PLAYLIST::TYPE_VIDEO, queuedItems); + playlistPlayer.Add(PLAYLIST::Id::TYPE_VIDEO, queuedItems); // figure out where to start playback - PLAYLIST::CPlayList& playList = playlistPlayer.GetPlaylist(PLAYLIST::TYPE_VIDEO); + PLAYLIST::CPlayList& playList = playlistPlayer.GetPlaylist(PLAYLIST::Id::TYPE_VIDEO); int pos = 0; if (itemToPlay) { @@ -359,13 +359,13 @@ void AddItemToPlayListAndPlay(const std::shared_ptr<CFileItem>& itemToQueue, } } - if (playlistPlayer.IsShuffled(PLAYLIST::TYPE_VIDEO)) + if (playlistPlayer.IsShuffled(PLAYLIST::Id::TYPE_VIDEO)) { playList.Swap(0, playList.FindOrder(pos)); pos = 0; } - playlistPlayer.SetCurrentPlaylist(PLAYLIST::TYPE_VIDEO); + playlistPlayer.SetCurrentPlaylist(PLAYLIST::Id::TYPE_VIDEO); playlistPlayer.Play(pos, player); } @@ -429,7 +429,7 @@ void PlayItem( // single item, play it auto& playlistPlayer = CServiceBroker::GetPlaylistPlayer(); playlistPlayer.Reset(); - playlistPlayer.SetCurrentPlaylist(PLAYLIST::TYPE_NONE); + playlistPlayer.SetCurrentPlaylist(PLAYLIST::Id::TYPE_NONE); playlistPlayer.Play(item, player); } } @@ -453,11 +453,11 @@ void QueueItem(const std::shared_ptr<CFileItem>& itemIn, QueuePosition pos) // Determine the proper list to queue this element PLAYLIST::Id playlistId = player.GetCurrentPlaylist(); - if (playlistId == PLAYLIST::TYPE_NONE) + if (playlistId == PLAYLIST::Id::TYPE_NONE) playlistId = components.GetComponent<CApplicationPlayer>()->GetPreferredPlaylist(); - if (playlistId == PLAYLIST::TYPE_NONE) - playlistId = PLAYLIST::TYPE_VIDEO; + if (playlistId == PLAYLIST::Id::TYPE_NONE) + playlistId = PLAYLIST::Id::TYPE_VIDEO; CFileItemList queuedItems; GetItemsForPlayList(item, queuedItems); diff --git a/xbmc/video/windows/GUIWindowVideoBase.cpp b/xbmc/video/windows/GUIWindowVideoBase.cpp index 50da6ba3b8..d9aadc9de9 100644 --- a/xbmc/video/windows/GUIWindowVideoBase.cpp +++ b/xbmc/video/windows/GUIWindowVideoBase.cpp @@ -102,8 +102,8 @@ bool CGUIWindowVideoBase::OnAction(const CAction &action) return OnContextButton(m_viewControl.GetSelectedItem(),CONTEXT_BUTTON_SCAN); else if (action.GetID() == ACTION_SHOW_PLAYLIST) { - if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::TYPE_VIDEO || - CServiceBroker::GetPlaylistPlayer().GetPlaylist(PLAYLIST::TYPE_VIDEO).size() > 0) + if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::Id::TYPE_VIDEO || + CServiceBroker::GetPlaylistPlayer().GetPlaylist(PLAYLIST::Id::TYPE_VIDEO).size() > 0) { CServiceBroker::GetGUI()->GetWindowManager().ActivateWindow(WINDOW_VIDEO_PLAYLIST); return true; @@ -977,7 +977,7 @@ bool CGUIWindowVideoBase::OnPlayMedia(const std::shared_ptr<CFileItem>& pItem, // Reset Playlistplayer, playback started now does // not use the playlistplayer. CServiceBroker::GetPlaylistPlayer().Reset(); - CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::TYPE_NONE); + CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::Id::TYPE_NONE); auto itemCopy = std::make_shared<CFileItem>(*pItem); @@ -988,7 +988,7 @@ bool CGUIWindowVideoBase::OnPlayMedia(const std::shared_ptr<CFileItem>& pItem, } CLog::Log(LOGDEBUG, "{} {}", __FUNCTION__, CURL::GetRedacted(itemCopy->GetPath())); - itemCopy->SetProperty("playlist_type_hint", m_guiState->GetPlaylist()); + itemCopy->SetProperty("playlist_type_hint", static_cast<int>(m_guiState->GetPlaylist())); if (m_thumbLoader.IsLoading()) m_thumbLoader.StopAsync(); @@ -1015,7 +1015,7 @@ bool CGUIWindowVideoBase::OnPlayAndQueueMedia(const CFileItemPtr& item, const st { // Get the current playlist and make sure it is not shuffled PLAYLIST::Id playlistId = m_guiState->GetPlaylist(); - if (playlistId != PLAYLIST::TYPE_NONE && + if (playlistId != PLAYLIST::Id::TYPE_NONE && CServiceBroker::GetPlaylistPlayer().IsShuffled(playlistId)) { CServiceBroker::GetPlaylistPlayer().SetShuffle(playlistId, false); @@ -1147,10 +1147,10 @@ bool CGUIWindowVideoBase::PlayItem(const std::shared_ptr<CFileItem>& pItem, CFileItemList queuedItems; VIDEO::UTILS::GetItemsForPlayList(item, queuedItems); - CServiceBroker::GetPlaylistPlayer().ClearPlaylist(PLAYLIST::TYPE_VIDEO); + CServiceBroker::GetPlaylistPlayer().ClearPlaylist(PLAYLIST::Id::TYPE_VIDEO); CServiceBroker::GetPlaylistPlayer().Reset(); - CServiceBroker::GetPlaylistPlayer().Add(PLAYLIST::TYPE_VIDEO, queuedItems); - CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::TYPE_VIDEO); + CServiceBroker::GetPlaylistPlayer().Add(PLAYLIST::Id::TYPE_VIDEO, queuedItems); + CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::Id::TYPE_VIDEO); CServiceBroker::GetPlaylistPlayer().Play(); return true; } @@ -1159,7 +1159,7 @@ bool CGUIWindowVideoBase::PlayItem(const std::shared_ptr<CFileItem>& pItem, // Note: strm files being somehow special playlists need to be handled in OnPlay*Media // load the playlist the old way - LoadPlayList(pItem->GetDynPath(), PLAYLIST::TYPE_VIDEO); + LoadPlayList(pItem->GetDynPath(), PLAYLIST::Id::TYPE_VIDEO); return true; } else if (m_guiState.get() && m_guiState->AutoPlayNextItem() && !g_partyModeManager.IsEnabled()) diff --git a/xbmc/video/windows/GUIWindowVideoBase.h b/xbmc/video/windows/GUIWindowVideoBase.h index d71b7628fe..37e2b5c8c7 100644 --- a/xbmc/video/windows/GUIWindowVideoBase.h +++ b/xbmc/video/windows/GUIWindowVideoBase.h @@ -104,7 +104,8 @@ protected: bool OnPlayMedia(const std::shared_ptr<CFileItem>& item, const std::string& player); bool OnPlayAndQueueMedia(const CFileItemPtr& item, const std::string& player = "") override; using CGUIMediaWindow::LoadPlayList; - void LoadPlayList(const std::string& strPlayList, PLAYLIST::Id playlistId = PLAYLIST::TYPE_VIDEO); + void LoadPlayList(const std::string& strPlayList, + KODI::PLAYLIST::Id playlistId = KODI::PLAYLIST::Id::TYPE_VIDEO); bool PlayItem(const std::shared_ptr<CFileItem>& item, const std::string& player); /*! diff --git a/xbmc/video/windows/GUIWindowVideoPlaylist.cpp b/xbmc/video/windows/GUIWindowVideoPlaylist.cpp index 03619d1eb9..612070c781 100644 --- a/xbmc/video/windows/GUIWindowVideoPlaylist.cpp +++ b/xbmc/video/windows/GUIWindowVideoPlaylist.cpp @@ -124,7 +124,7 @@ bool CGUIWindowVideoPlaylist::OnMessage(CGUIMessage& message) const auto& components = CServiceBroker::GetAppComponents(); const auto appPlayer = components.GetComponent<CApplicationPlayer>(); if (appPlayer->IsPlayingVideo() && - CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::TYPE_VIDEO) + CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::Id::TYPE_VIDEO) { int iSong = CServiceBroker::GetPlaylistPlayer().GetCurrentItemIdx(); if (iSong >= 0 && iSong <= m_vecItems->Size()) @@ -143,10 +143,10 @@ bool CGUIWindowVideoPlaylist::OnMessage(CGUIMessage& message) if (!g_partyModeManager.IsEnabled()) { CServiceBroker::GetPlaylistPlayer().SetShuffle( - PLAYLIST::TYPE_VIDEO, - !(CServiceBroker::GetPlaylistPlayer().IsShuffled(PLAYLIST::TYPE_VIDEO))); + PLAYLIST::Id::TYPE_VIDEO, + !(CServiceBroker::GetPlaylistPlayer().IsShuffled(PLAYLIST::Id::TYPE_VIDEO))); CMediaSettings::GetInstance().SetVideoPlaylistShuffled( - CServiceBroker::GetPlaylistPlayer().IsShuffled(PLAYLIST::TYPE_VIDEO)); + CServiceBroker::GetPlaylistPlayer().IsShuffled(PLAYLIST::Id::TYPE_VIDEO)); CServiceBroker::GetSettingsComponent()->GetSettings()->Save(); UpdateButtons(); Refresh(); @@ -162,39 +162,39 @@ bool CGUIWindowVideoPlaylist::OnMessage(CGUIMessage& message) } else if (iControl == CONTROL_BTNPLAY) { - CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::TYPE_VIDEO); + CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::Id::TYPE_VIDEO); CServiceBroker::GetPlaylistPlayer().Reset(); CServiceBroker::GetPlaylistPlayer().Play(m_viewControl.GetSelectedItem(), ""); UpdateButtons(); } else if (iControl == CONTROL_BTNNEXT) { - CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::TYPE_VIDEO); + CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::Id::TYPE_VIDEO); CServiceBroker::GetPlaylistPlayer().PlayNext(); } else if (iControl == CONTROL_BTNPREVIOUS) { - CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::TYPE_VIDEO); + CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::Id::TYPE_VIDEO); CServiceBroker::GetPlaylistPlayer().PlayPrevious(); } else if (iControl == CONTROL_BTNREPEAT) { // increment repeat state PLAYLIST::RepeatState state = - CServiceBroker::GetPlaylistPlayer().GetRepeat(PLAYLIST::TYPE_VIDEO); + CServiceBroker::GetPlaylistPlayer().GetRepeat(PLAYLIST::Id::TYPE_VIDEO); if (state == PLAYLIST::RepeatState::NONE) - CServiceBroker::GetPlaylistPlayer().SetRepeat(PLAYLIST::TYPE_VIDEO, + CServiceBroker::GetPlaylistPlayer().SetRepeat(PLAYLIST::Id::TYPE_VIDEO, PLAYLIST::RepeatState::ALL); else if (state == PLAYLIST::RepeatState::ALL) - CServiceBroker::GetPlaylistPlayer().SetRepeat(PLAYLIST::TYPE_VIDEO, + CServiceBroker::GetPlaylistPlayer().SetRepeat(PLAYLIST::Id::TYPE_VIDEO, PLAYLIST::RepeatState::ONE); else - CServiceBroker::GetPlaylistPlayer().SetRepeat(PLAYLIST::TYPE_VIDEO, + CServiceBroker::GetPlaylistPlayer().SetRepeat(PLAYLIST::Id::TYPE_VIDEO, PLAYLIST::RepeatState::NONE); // save settings CMediaSettings::GetInstance().SetVideoPlaylistRepeat( - CServiceBroker::GetPlaylistPlayer().GetRepeat(PLAYLIST::TYPE_VIDEO) == + CServiceBroker::GetPlaylistPlayer().GetRepeat(PLAYLIST::Id::TYPE_VIDEO) == PLAYLIST::RepeatState::ALL); CServiceBroker::GetSettingsComponent()->GetSettings()->Save(); @@ -274,14 +274,14 @@ bool CGUIWindowVideoPlaylist::MoveCurrentPlayListItem(int iItem, const auto appPlayer = components.GetComponent<CApplicationPlayer>(); // is the currently playing item affected? bool bFixCurrentSong = false; - if ((CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::TYPE_VIDEO) && + if ((CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::Id::TYPE_VIDEO) && appPlayer->IsPlayingVideo() && ((CServiceBroker::GetPlaylistPlayer().GetCurrentItemIdx() == iSelected) || (CServiceBroker::GetPlaylistPlayer().GetCurrentItemIdx() == iNew))) bFixCurrentSong = true; PLAYLIST::CPlayList& playlist = - CServiceBroker::GetPlaylistPlayer().GetPlaylist(PLAYLIST::TYPE_VIDEO); + CServiceBroker::GetPlaylistPlayer().GetPlaylist(PLAYLIST::Id::TYPE_VIDEO); if (playlist.Swap(iSelected, iNew)) { // Correct the current playing song in playlistplayer @@ -306,11 +306,11 @@ bool CGUIWindowVideoPlaylist::MoveCurrentPlayListItem(int iItem, void CGUIWindowVideoPlaylist::ClearPlayList() { ClearFileItems(); - CServiceBroker::GetPlaylistPlayer().ClearPlaylist(PLAYLIST::TYPE_VIDEO); - if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::TYPE_VIDEO) + CServiceBroker::GetPlaylistPlayer().ClearPlaylist(PLAYLIST::Id::TYPE_VIDEO); + if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::Id::TYPE_VIDEO) { CServiceBroker::GetPlaylistPlayer().Reset(); - CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::TYPE_NONE); + CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::Id::TYPE_NONE); } m_viewControl.SetItems(*m_vecItems); UpdateButtons(); @@ -331,7 +331,7 @@ void CGUIWindowVideoPlaylist::UpdateButtons() const auto& components = CServiceBroker::GetAppComponents(); const auto appPlayer = components.GetComponent<CApplicationPlayer>(); if (appPlayer->IsPlayingVideo() && - CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::TYPE_VIDEO) + CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::Id::TYPE_VIDEO) { CONTROL_ENABLE(CONTROL_BTNNEXT); CONTROL_ENABLE(CONTROL_BTNPREVIOUS); @@ -357,12 +357,12 @@ void CGUIWindowVideoPlaylist::UpdateButtons() // update buttons CONTROL_DESELECT(CONTROL_BTNSHUFFLE); - if (CServiceBroker::GetPlaylistPlayer().IsShuffled(PLAYLIST::TYPE_VIDEO)) + if (CServiceBroker::GetPlaylistPlayer().IsShuffled(PLAYLIST::Id::TYPE_VIDEO)) CONTROL_SELECT(CONTROL_BTNSHUFFLE); // update repeat button PLAYLIST::RepeatState repState = - CServiceBroker::GetPlaylistPlayer().GetRepeat(PLAYLIST::TYPE_VIDEO); + CServiceBroker::GetPlaylistPlayer().GetRepeat(PLAYLIST::Id::TYPE_VIDEO); int iLocalizedString; if (repState == PLAYLIST::RepeatState::NONE) iLocalizedString = 595; // Repeat: Off @@ -392,9 +392,9 @@ protected: bool OnResumeSelected() override { auto& playlistPlayer = CServiceBroker::GetPlaylistPlayer(); - playlistPlayer.SetCurrentPlaylist(PLAYLIST::TYPE_VIDEO); + playlistPlayer.SetCurrentPlaylist(PLAYLIST::Id::TYPE_VIDEO); - const auto playlistItem{playlistPlayer.GetPlaylist(PLAYLIST::TYPE_VIDEO)[m_itemIndex]}; + const auto playlistItem{playlistPlayer.GetPlaylist(PLAYLIST::Id::TYPE_VIDEO)[m_itemIndex]}; playlistItem->SetStartOffset(STARTOFFSET_RESUME); if (playlistItem->HasVideoInfoTag() && m_item->HasVideoInfoTag()) playlistItem->GetVideoInfoTag()->SetResumePoint(m_item->GetVideoInfoTag()->GetResumePoint()); @@ -406,7 +406,7 @@ protected: bool OnPlaySelected() override { auto& playlistPlayer = CServiceBroker::GetPlaylistPlayer(); - playlistPlayer.SetCurrentPlaylist(PLAYLIST::TYPE_VIDEO); + playlistPlayer.SetCurrentPlaylist(PLAYLIST::Id::TYPE_VIDEO); playlistPlayer.Play(m_itemIndex, m_player); return true; } @@ -444,12 +444,12 @@ void CGUIWindowVideoPlaylist::RemovePlayListItem(int iItem) const auto appPlayer = components.GetComponent<CApplicationPlayer>(); // The current playing song can't be removed - if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::TYPE_VIDEO && + if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST::Id::TYPE_VIDEO && appPlayer->IsPlayingVideo() && CServiceBroker::GetPlaylistPlayer().GetCurrentItemIdx() == iItem) return; - CServiceBroker::GetPlaylistPlayer().Remove(PLAYLIST::TYPE_VIDEO, iItem); + CServiceBroker::GetPlaylistPlayer().Remove(PLAYLIST::Id::TYPE_VIDEO, iItem); Refresh(); diff --git a/xbmc/view/GUIViewState.cpp b/xbmc/view/GUIViewState.cpp index 3457aa24cb..cebf9319be 100644 --- a/xbmc/view/GUIViewState.cpp +++ b/xbmc/view/GUIViewState.cpp @@ -190,7 +190,7 @@ CGUIViewState::CGUIViewState(const CFileItemList& items) : m_items(items) { m_currentViewAsControl = 0; m_currentSortMethod = 0; - m_playlist = PLAYLIST::TYPE_NONE; + m_playlist = PLAYLIST::Id::TYPE_NONE; } CGUIViewState::~CGUIViewState() = default; @@ -492,7 +492,7 @@ void CGUIViewState::SetSortOrder(SortOrder sortOrder) bool CGUIViewState::AutoPlayNextVideoItem() const { - if (GetPlaylist() != PLAYLIST::TYPE_VIDEO) + if (GetPlaylist() != PLAYLIST::Id::TYPE_VIDEO) return false; return VIDEO::UTILS::IsAutoPlayNextItem(m_items.GetContent()); @@ -581,9 +581,9 @@ CGUIViewStateFromItems::CGUIViewStateFromItems(const CFileItemList &items) : CGU { const auto plugin = std::static_pointer_cast<CPluginSource>(addon); if (plugin->Provides(CPluginSource::AUDIO)) - m_playlist = PLAYLIST::TYPE_MUSIC; + m_playlist = PLAYLIST::Id::TYPE_MUSIC; if (plugin->Provides(CPluginSource::VIDEO)) - m_playlist = PLAYLIST::TYPE_VIDEO; + m_playlist = PLAYLIST::Id::TYPE_VIDEO; } } diff --git a/xbmc/view/GUIViewState.h b/xbmc/view/GUIViewState.h index 8723081242..e995a3b8b8 100644 --- a/xbmc/view/GUIViewState.h +++ b/xbmc/view/GUIViewState.h @@ -17,10 +17,10 @@ class CViewState; // forward class CFileItemList; -namespace PLAYLIST +namespace KODI::PLAYLIST { -using Id = int; -} // namespace PLAYLIST +enum class Id; +} // namespace KODI::PLAYLIST class CGUIViewState { @@ -50,7 +50,7 @@ public: virtual bool HideParentDirItems(); virtual bool DisableAddSourceButtons(); - virtual PLAYLIST::Id GetPlaylist() const; + virtual KODI::PLAYLIST::Id GetPlaylist() const; const std::string& GetPlaylistDirectory(); void SetPlaylistDirectory(const std::string& strDirectory); bool IsCurrentPlaylistDirectory(const std::string& strDirectory); @@ -88,7 +88,7 @@ protected: const CFileItemList& m_items; int m_currentViewAsControl; - PLAYLIST::Id m_playlist; + KODI::PLAYLIST::Id m_playlist; std::vector<GUIViewSortDetails> m_sortMethods; int m_currentSortMethod; diff --git a/xbmc/windowing/linux/CMakeLists.txt b/xbmc/windowing/linux/CMakeLists.txt index b6349047d3..1917cd683b 100644 --- a/xbmc/windowing/linux/CMakeLists.txt +++ b/xbmc/windowing/linux/CMakeLists.txt @@ -1,12 +1,12 @@ set(SOURCES "") set(HEADERS "") -if(TARGET DBus::DBus) +if(TARGET ${APP_NAME_LC}::DBus) list(APPEND SOURCES OSScreenSaverFreedesktop.cpp) list(APPEND HEADERS OSScreenSaverFreedesktop.h) endif() -if(TARGET EGL::EGL) +if(TARGET ${APP_NAME_LC}::EGL) list(APPEND SOURCES WinSystemEGL.cpp) list(APPEND HEADERS WinSystemEGL.h) endif() diff --git a/xbmc/windowing/wayland/CMakeLists.txt b/xbmc/windowing/wayland/CMakeLists.txt index c406de112f..b1ff8a236f 100644 --- a/xbmc/windowing/wayland/CMakeLists.txt +++ b/xbmc/windowing/wayland/CMakeLists.txt @@ -49,7 +49,7 @@ set(HEADERS Connection.h WinSystemWayland.h XkbcommonKeymap.h) -if(TARGET EGL::EGL) +if(TARGET ${APP_NAME_LC}::EGL) list(APPEND SOURCES WinSystemWaylandEGLContext.cpp) list(APPEND HEADERS WinSystemWaylandEGLContext.h) endif() diff --git a/xbmc/windowing/wayland/Output.cpp b/xbmc/windowing/wayland/Output.cpp index d4e031121b..833f7b96c0 100644 --- a/xbmc/windowing/wayland/Output.cpp +++ b/xbmc/windowing/wayland/Output.cpp @@ -31,9 +31,9 @@ COutput::COutput(std::uint32_t globalName, { std::unique_lock<CCriticalSection> lock(m_geometryCriticalSection); m_position = {x, y}; - // Some monitors report invalid (negative) values that would cause an exception - // with CSizeInt - if (physWidth < 0 || physHeight < 0) + // Some monitors report invalid (non-positive) values that would cause an exception + // with CSizeInt and/or lead to nonsensical DPI values. + if (physWidth <= 0 || physHeight <= 0) m_physicalSize = {}; else m_physicalSize = {physWidth, physHeight}; diff --git a/xbmc/windows/GUIMediaWindow.cpp b/xbmc/windows/GUIMediaWindow.cpp index f764b671c5..dcb5455503 100644 --- a/xbmc/windows/GUIMediaWindow.cpp +++ b/xbmc/windows/GUIMediaWindow.cpp @@ -1495,7 +1495,7 @@ bool CGUIMediaWindow::OnPlayMedia(int iItem, const std::string &player) // Reset Playlistplayer, playback started now does // not use the playlistplayer. CServiceBroker::GetPlaylistPlayer().Reset(); - CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::TYPE_NONE); + CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(PLAYLIST::Id::TYPE_NONE); CFileItemPtr pItem=m_vecItems->Get(iItem); CLog::Log(LOGDEBUG, "{} {}", __FUNCTION__, CURL::GetRedacted(pItem->GetPath())); @@ -1524,7 +1524,7 @@ bool CGUIMediaWindow::OnPlayAndQueueMedia(const CFileItemPtr& item, const std::s { //play and add current directory to temporary playlist PLAYLIST::Id playlistId = m_guiState->GetPlaylist(); - if (playlistId != PLAYLIST::TYPE_NONE) + if (playlistId != PLAYLIST::Id::TYPE_NONE) { // Remove ZIP, RAR files and folders CFileItemList playlist; @@ -1591,7 +1591,7 @@ void CGUIMediaWindow::UpdateFileList() PLAYLIST::Id playlistId = m_guiState->GetPlaylist(); int nSong = CServiceBroker::GetPlaylistPlayer().GetCurrentItemIdx(); CFileItem playlistItem; - if (nSong > -1 && playlistId != PLAYLIST::TYPE_NONE) + if (nSong > -1 && playlistId != PLAYLIST::Id::TYPE_NONE) playlistItem = *CServiceBroker::GetPlaylistPlayer().GetPlaylist(playlistId)[nSong]; CServiceBroker::GetPlaylistPlayer().ClearPlaylist(playlistId); diff --git a/xbmc/windows/GUIMediaWindow.h b/xbmc/windows/GUIMediaWindow.h index 6de5e2b320..5364bbe586 100644 --- a/xbmc/windows/GUIMediaWindow.h +++ b/xbmc/windows/GUIMediaWindow.h @@ -208,7 +208,7 @@ protected: int m_iLastControl; std::string m_startDirectory; - CSmartPlaylist m_filter; + KODI::PLAYLIST::CSmartPlaylist m_filter; bool m_canFilterAdvanced; /*! \brief Contains the path used for filtering (including any active filter) diff --git a/xbmc/windows/GUIWindowFileManager.cpp b/xbmc/windows/GUIWindowFileManager.cpp index fd001e0f99..b25c1e4924 100644 --- a/xbmc/windows/GUIWindowFileManager.cpp +++ b/xbmc/windows/GUIWindowFileManager.cpp @@ -656,7 +656,7 @@ void CGUIWindowFileManager::OnStart(CFileItem *pItem, const std::string &player) return; } } - g_application.ProcessAndStartPlaylist(strPlayList, *pPlayList, PLAYLIST::TYPE_MUSIC); + g_application.ProcessAndStartPlaylist(strPlayList, *pPlayList, PLAYLIST::Id::TYPE_MUSIC); return; } if (MUSIC::IsAudio(*pItem) || IsVideo(*pItem)) |