From 408205122a4822d093bd582e4bbe2ceb15659cbb Mon Sep 17 00:00:00 2001 From: shabinder Date: Mon, 23 Aug 2021 23:19:22 +0530 Subject: [PATCH] Add FFmpeg-kit Sub-Module --- .gitmodules | 3 +++ .../file_manager/DesktopFileManager.kt | 8 +++----- ffmpeg-kit | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) create mode 160000 ffmpeg-kit diff --git a/.gitmodules b/.gitmodules index 6b523bd4..1e6d2ea1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "mosaic"] path = mosaic url = https://github.com/JakeWharton/mosaic +[submodule "ffmpeg-kit"] + path = ffmpeg-kit + url = https://github.com/tanersener/ffmpeg-kit diff --git a/common/core-components/src/desktopMain/kotlin/com.shabinder.common.core_components/file_manager/DesktopFileManager.kt b/common/core-components/src/desktopMain/kotlin/com.shabinder.common.core_components/file_manager/DesktopFileManager.kt index 922efcae..5e88d7a0 100644 --- a/common/core-components/src/desktopMain/kotlin/com.shabinder.common.core_components/file_manager/DesktopFileManager.kt +++ b/common/core-components/src/desktopMain/kotlin/com.shabinder.common.core_components/file_manager/DesktopFileManager.kt @@ -36,11 +36,8 @@ import com.shabinder.common.models.event.coroutines.SuspendableEvent import com.shabinder.common.models.event.coroutines.failure import com.shabinder.common.models.event.coroutines.map import com.shabinder.database.Database -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.* import kotlinx.coroutines.flow.MutableSharedFlow -import kotlinx.coroutines.launch -import kotlinx.coroutines.withContext import org.jetbrains.skija.Image import org.koin.dsl.bind import org.koin.dsl.module @@ -103,7 +100,7 @@ class DesktopFileManager( File(imageCacheDir()).deleteRecursively() } - override suspend fun cacheImage(image: Any, path: String) { + override suspend fun cacheImage(image: Any, path: String): Unit = withContext(dispatcherIO) { try { (image as? BufferedImage)?.let { ImageIO.write(it, "jpeg", File(path)) @@ -185,6 +182,7 @@ class DesktopFileManager( } } + @OptIn(DelicateCoroutinesApi::class) @Suppress("BlockingMethodInNonBlockingContext") private suspend fun freshImage(url: String, reqWidth: Int, reqHeight: Int): ImageBitmap? { return withContext(Dispatchers.IO) { diff --git a/ffmpeg-kit b/ffmpeg-kit new file mode 160000 index 00000000..46afc3f3 --- /dev/null +++ b/ffmpeg-kit @@ -0,0 +1 @@ +Subproject commit 46afc3f34a91efffb3c2bc595d64e2d714d48245