Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ import io.github.peerless2012.ass.media.type.AssRenderType
* @param renderType The subtitle render type.
*/
@OptIn(UnstableApi::class)
class AssHandler(val renderType: AssRenderType) : Listener {
class AssHandler(
val renderType: AssRenderType,
val config: AssHandlerConfig = AssHandlerConfig()
) : Listener {

/** The ASS instance used for creating tracks and renderers. This is lazy to avoid loading
* libass if the played media does not have ASS tracks. */
Expand Down Expand Up @@ -259,11 +262,9 @@ class AssHandler(val renderType: AssRenderType) : Listener {
render.setFrameSize(videoSize.width, videoSize.height)
}
}
val totalMemoryBytes = Runtime.getRuntime().maxMemory()
val cacheSize = ((totalMemoryBytes / (1024 * 1024)) / 4).toInt()
Log.i("AssHandler", "Ass cacheSize: ${cacheSize}MB")
// https://github.com/peerless2012/libass-android/issues/48#issuecomment-3086561167
render.setCacheLimit(1024, cacheSize)
Log.i("AssHandler", "Ass cacheSize: ${config.cacheSize}MB")
Log.i("AssHandler", "Ass glyphSize: ${config.glyphSize}")
render.setCacheLimit(config.glyphSize, config.cacheSize)
}
renderCallback?.invoke(render)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package io.github.peerless2012.ass.media

data class AssHandlerConfig(
val glyphSize: Int = 1024,
val cacheSize: Int = 128){
}