From 8f0d283542fa8c55f2a9cdd520271b0b471e3393 Mon Sep 17 00:00:00 2001
From: popcornmix <popcornmix@gmail.com>
Date: Mon, 10 Jun 2019 22:07:55 +0100
Subject: [PATCH] RBP: add PiSink

---
 xbmc/cores/AudioEngine/CMakeLists.txt |  3 +++
 xbmc/platform/linux/CMakeLists.txt    | 10 +++++-----
 xbmc/platform/linux/RBP.cpp           | 24 ++++++++++++------------
 xbmc/platform/linux/RBP.h             | 22 +++++++++++-----------
 xbmc/windowing/gbm/WinSystemGbm.cpp   |  2 ++
 5 files changed, 33 insertions(+), 28 deletions(-)

diff --git a/xbmc/cores/AudioEngine/CMakeLists.txt b/xbmc/cores/AudioEngine/CMakeLists.txt
index 060c6a960d..e5b80cf54a 100644
--- a/xbmc/cores/AudioEngine/CMakeLists.txt
+++ b/xbmc/cores/AudioEngine/CMakeLists.txt
@@ -101,6 +101,9 @@ if(CORE_PLATFORM_NAME_LC STREQUAL rbpi)
                       Sinks/AESinkPi.h)
 endif()
 
+  list(APPEND SOURCES Sinks/AESinkPi.cpp)
+  list(APPEND HEADERS Sinks/AESinkPi.h)
+
 if(CORE_SYSTEM_NAME STREQUAL osx)
   list(APPEND SOURCES Sinks/AESinkDARWINOSX.cpp
                       Sinks/osx/AEDeviceEnumerationOSX.cpp
diff --git a/xbmc/platform/linux/CMakeLists.txt b/xbmc/platform/linux/CMakeLists.txt
index 88076c3d5a..16cdd478be 100644
--- a/xbmc/platform/linux/CMakeLists.txt
+++ b/xbmc/platform/linux/CMakeLists.txt
@@ -39,7 +39,7 @@ if(DBUS_FOUND)
                       DBusUtil.h)
 endif()
 
-if(CORE_PLATFORM_NAME_LC STREQUAL rbpi)
+#if(CORE_PLATFORM_NAME_LC STREQUAL rbpi)
   list(APPEND SOURCES RBP.cpp
                       OMXClock.cpp
                       OMXCore.cpp)
@@ -48,10 +48,10 @@ if(CORE_PLATFORM_NAME_LC STREQUAL rbpi)
                       DllOMX.h
                       OMXClock.h
                       OMXCore.h)
-else()
-  list(APPEND SOURCES RBP.cpp)
-  list(APPEND HEADERS RBP.h)
-endif()
+#else()
+#  list(APPEND SOURCES RBP.cpp)
+#  list(APPEND HEADERS RBP.h)
+#endif()
 
 if(HAVE_SSE4_1)
   add_subdirectory(sse4)
diff --git a/xbmc/platform/linux/RBP.cpp b/xbmc/platform/linux/RBP.cpp
index 6c045e9674..9ff4ed4e6f 100644
--- a/xbmc/platform/linux/RBP.cpp
+++ b/xbmc/platform/linux/RBP.cpp
@@ -68,13 +68,13 @@ typedef int vc_image_t_size_check[(sizeof(VC_IMAGE_T) == 64) * 2 - 1];
 CRBP::CRBP()
 {
   m_initialized     = false;
-#ifdef TARGET_RASPBERRY_PI
+//#ifdef TARGET_RASPBERRY_PI
   m_omx_initialized = false;
-#endif
+//#endif
   m_DllBcmHost      = new DllBcmHost();
-#ifdef TARGET_RASPBERRY_PI
+//#ifdef TARGET_RASPBERRY_PI
   m_OMX             = new COMXCore();
-#endif
+//#endif
   m_display = DISPMANX_NO_HANDLE;
   m_mb = mbox_open();
   vcsm_init();
@@ -103,11 +103,11 @@ bool CRBP::Initialize()
 
   m_DllBcmHost->bcm_host_init();
 
-#ifdef TARGET_RASPBERRY_PI
+//#ifdef TARGET_RASPBERRY_PI
   m_omx_initialized = m_OMX->Initialize();
   if(!m_omx_initialized)
     return false;
-#endif
+//#endif
 
   char response[80] = "";
   m_arm_mem = 0;
@@ -278,13 +278,13 @@ uint32_t CRBP::LastVsync()
 
 void CRBP::Deinitialize()
 {
-#ifdef TARGET_RASPBERRY_PI
-  if (m_omx_image_init)
-    g_OMXImage.Deinitialize();
+//#ifdef TARGET_RASPBERRY_PI
+//  if (m_omx_image_init)
+//    g_OMXImage.Deinitialize();
 
   if(m_omx_initialized)
     m_OMX->Deinitialize();
-#endif
+//#endif
 
   m_DllBcmHost->bcm_host_deinit();
 
@@ -295,9 +295,9 @@ void CRBP::Deinitialize()
   m_omx_image_init  = false;
 #endif
   m_initialized     = false;
-#ifdef TARGET_RASPBERRY_PI
+//#ifdef TARGET_RASPBERRY_PI
   m_omx_initialized = false;
-#endif
+//#endif
   if (m_mb)
     mbox_close(m_mb);
   m_mb = 0;
diff --git a/xbmc/platform/linux/RBP.h b/xbmc/platform/linux/RBP.h
index 63e02a1826..d3f46d34a1 100644
--- a/xbmc/platform/linux/RBP.h
+++ b/xbmc/platform/linux/RBP.h
@@ -19,9 +19,9 @@
 #endif
 
 #include "DllBCM.h"
-#ifdef TARGET_RASPBERRY_PI
+//#ifdef TARGET_RASPBERRY_PI
 #include "OMXCore.h"
-#endif
+//#endif
 #include "xbmc/utils/CPUInfo.h"
 #include "threads/CriticalSection.h"
 #include "threads/Event.h"
@@ -97,9 +97,9 @@ public:
   int GetGUIResolutionLimit() { return m_gui_resolution_limit; }
   // stride can be null for packed output
   unsigned char *CaptureDisplay(int width, int height, int *stride, bool swap_red_blue, bool video_only = true);
-#ifdef TARGET_RASPBERRY_PI
+//#ifdef TARGET_RASPBERRY_PI
   DllOMX *GetDllOMX() { return m_OMX ? m_OMX->GetDll() : NULL; }
-#endif
+//#endif
   uint32_t LastVsync(int64_t &time);
   uint32_t LastVsync();
   uint32_t WaitVsync(uint32_t target = ~0U);
@@ -110,26 +110,26 @@ public:
 private:
   DllBcmHost *m_DllBcmHost;
   bool       m_initialized;
-#ifdef TARGET_RASPBERRY_PI
+//#ifdef TARGET_RASPBERRY_PI
   bool       m_omx_initialized;
-  bool       m_omx_image_init;
-#endif
+  //bool       m_omx_image_init;
+//#endif
   int        m_arm_mem;
   int        m_gpu_mem;
   int        m_gui_resolution_limit;
   bool       m_codec_mpg2_enabled;
   bool       m_codec_wvc1_enabled;
-#ifdef TARGET_RASPBERRY_PI
+//#ifdef TARGET_RASPBERRY_PI
   COMXCore   *m_OMX;
-#endif
+//#endif
   DISPMANX_DISPLAY_HANDLE_T m_display;
   CCriticalSection m_vsync_lock;
   XbmcThreads::ConditionVariable m_vsync_cond;
   uint32_t m_vsync_count;
   int64_t m_vsync_time;
-#ifdef TARGET_RASPBERRY_PI
+//#ifdef TARGET_RASPBERRY_PI
   class DllLibOMXCore;
-#endif
+//#endif
   CCriticalSection m_critSection;
 
   int m_mb;
diff --git a/xbmc/windowing/gbm/WinSystemGbm.cpp b/xbmc/windowing/gbm/WinSystemGbm.cpp
index 9ad1f2daf1..418e0cf8b1 100644
--- a/xbmc/windowing/gbm/WinSystemGbm.cpp
+++ b/xbmc/windowing/gbm/WinSystemGbm.cpp
@@ -25,6 +25,7 @@
 #include "DRMLegacy.h"
 #include "OffScreenModeSetting.h"
 #include "messaging/ApplicationMessenger.h"
+#include "cores/AudioEngine/Sinks/AESinkPi.h"
 
 using namespace KODI::WINDOWING::GBM;
 
@@ -33,6 +34,7 @@ CWinSystemGbm::CWinSystemGbm() :
   m_GBM(new CGBMUtils),
   m_libinput(new CLibInputHandler)
 {
+  CAESinkPi::Register();
   OPTIONALS::ALSARegister();
   OPTIONALS::PulseAudioRegister();
 
-- 
2.20.1

