Merge pull request #131 from DarkKnight2122

Concurrent Downloads and Proactive Memory Management for media downloader engine
This commit is contained in:
ᴋᴀʟᴀᴅɪɴ
2026-04-17 23:04:00 +05:30
committed by GitHub
4 changed files with 30 additions and 21 deletions

View File

@@ -121,6 +121,7 @@ class DownloadProcessor (
inputFile.outputStream().use {
bitmap.compress(compressFormat, 100, it)
}
bitmap.recycle()
fileType = FileType.fromFile(inputFile)
}
}
@@ -673,6 +674,10 @@ class DownloadProcessor (
mergedBitmap.compress(compressFormat, 100, it)
}
originalBitmap.recycle()
overlayBitmap.recycle()
mergedBitmap.recycle()
saveMediaToGallery(pendingTask, mergedImage, downloadMetadata)
mergedImage.delete()
renamedOverlayMedia.delete()

View File

@@ -92,6 +92,10 @@ class FFMpegProcessor(
private val sharedExecutor = Executors.newSingleThreadExecutor()
protected fun finalize() {
runCatching { sharedExecutor.shutdown() }
}
private suspend fun newFFMpegTask(globalArguments: ArgumentList, inputArguments: ArgumentList, outputArguments: ArgumentList) = suspendCancellableCoroutine<FFmpegSession> {
val stringBuilder = StringBuilder()
arrayOf(globalArguments, inputArguments, outputArguments).forEach { argumentList ->