[vlc-devel] [PATCH 6/6] vout/vulkan: add Android extension module
Niklas Haas
vlc at haasn.xyz
Mon Oct 29 14:28:54 CET 2018
From: Thomas Guillem <thomas at gllm.fr>
---
modules/video_output/Makefile.am | 9 +++
.../video_output/vulkan/platform_android.c | 64 +++++++++++++++++++
2 files changed, 73 insertions(+)
create mode 100644 modules/video_output/vulkan/platform_android.c
diff --git a/modules/video_output/Makefile.am b/modules/video_output/Makefile.am
index 6a459fe102..971957aad7 100644
--- a/modules/video_output/Makefile.am
+++ b/modules/video_output/Makefile.am
@@ -152,6 +152,12 @@ libvk_win32_plugin_la_CFLAGS = $(AM_CFLAGS) $(VULKAN_COMMONCFLAGS) \
-DVK_USE_PLATFORM_WIN32_KHR -DPLATFORM_NAME=Win32
libvk_win32_plugin_la_LIBADD = $(VULKAN_COMMONLIBS)
+libvk_android_plugin_la_SOURCES = $(VULKAN_COMMONSOURCES) video_output/vulkan/surface.c \
+ video_output/vulkan/platform_android.c
+libvk_android_plugin_la_CFLAGS = $(AM_CFLAGS) $(VULKAN_COMMONCFLAGS) \
+ -DVK_USE_PLATFORM_ANDROID_KHR -DPLATFORM_NAME=Android
+libvk_android_plugin_la_LIBADD = $(VULKAN_COMMONLIBS)
+
if HAVE_VULKAN
vout_LTLIBRARIES += libvk_plugin.la
if HAVE_XCB
@@ -160,6 +166,9 @@ endif
if HAVE_WIN32_DESKTOP
vout_LTLIBRARIES += libvk_win32_plugin.la
endif
+if HAVE_ANDROID
+vout_LTLIBRARIES += libvk_android_plugin.la
+endif
endif
### XCB ###
diff --git a/modules/video_output/vulkan/platform_android.c b/modules/video_output/vulkan/platform_android.c
new file mode 100644
index 0000000000..adb66114ca
--- /dev/null
+++ b/modules/video_output/vulkan/platform_android.c
@@ -0,0 +1,64 @@
+/**
+ * @file platform_android.c
+ * @brief Vulkan platform-specific code for Android
+ */
+/*****************************************************************************
+ * Copyright © 2018 Niklas Haas, Thomas Guillem
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#include "platform.h"
+#include "../android/utils.h"
+
+int vlc_vk_InitPlatform(vlc_vk_t *vk)
+{
+ if (vk->window->type != VOUT_WINDOW_TYPE_ANDROID_NATIVE)
+ return VLC_EGENERIC;
+
+ return VLC_SUCCESS;
+}
+
+void vlc_vk_ClosePlatform(vlc_vk_t *vk)
+{
+ AWindowHandler_releaseANativeWindow(vk->window->handle.anativewindow,
+ AWindow_Video);
+}
+
+const char * const vlc_vk_PlatformExt = VK_KHR_ANDROID_SURFACE_EXTENSION_NAME;
+
+int vlc_vk_CreateSurface(vlc_vk_t *vk)
+{
+ VkInstance vkinst = vk->instance->instance;
+
+ ANativeWindow *anw =
+ AWindowHandler_getANativeWindow(vk->window->handle.anativewindow,
+ AWindow_Video);
+
+ VkAndroidSurfaceCreateInfoKHR ainfo = {
+ .sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR,
+ .pNext = NULL,
+ .flags = 0,
+ .window = anw,
+ };
+
+ VkResult res = vkCreateAndroidSurfaceKHR(vkinst, &ainfo, NULL, &vk->surface);
+ if (res != VK_SUCCESS) {
+ msg_Err(vk, "Failed creating Android surface");
+ return VLC_EGENERIC;
+ }
+
+ return VLC_SUCCESS;
+}
--
2.19.1
More information about the vlc-devel
mailing list