Skip to content

Commit fe1df82

Browse files
committed
fix: 修复因为16kb申请内存造成的OOM (#63)
Related to #63
1 parent 51ab29e commit fe1df82

14 files changed

Lines changed: 93 additions & 12 deletions

File tree

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ android {
2626
applicationId "com.coder.ffmpegcommand"
2727
minSdk 21
2828
targetSdk 33
29-
versionCode 7
30-
versionName "1.3.5"
29+
versionCode 8
30+
versionName "1.3.6"
3131

3232
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
3333

542 Bytes
Binary file not shown.

app/outputs/release/output-metadata.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
"type": "SINGLE",
1212
"filters": [],
1313
"attributes": [],
14-
"versionCode": 7,
15-
"versionName": "1.3.5",
14+
"versionCode": 8,
15+
"versionName": "1.3.6",
1616
"outputFile": "app-release.apk"
1717
}
1818
],

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
android:label="@string/app_name"
1717
android:requestLegacyExternalStorage="true"
1818
android:supportsRtl="true"
19+
android:enableOnBackInvokedCallback="true"
1920
android:networkSecurityConfig="@xml/network_security_config"
2021
android:theme="@style/AppTheme">
2122
<activity android:name="com.coder.ffmpegcommand.ui.MainActivity"

ffmpeg-lite/build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ android {
1313

1414
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1515
consumerProguardFiles "consumer-rules.pro"
16+
17+
buildConfigField "String", "MODULE_NAME", "\"ffmpeg-lite\""
1618
}
1719

1820
buildTypes {
@@ -25,6 +27,11 @@ android {
2527
sourceCompatibility JavaVersion.VERSION_1_8
2628
targetCompatibility JavaVersion.VERSION_1_8
2729
}
30+
31+
buildFeatures {
32+
buildConfig true
33+
}
34+
2835
kotlinOptions {
2936
jvmTarget = '1.8'
3037
}

ffmpeg-lite/config.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ext {
77
release(MavenPublication) {
88
groupId = 'com.github.AnJoiner.FFmpegCommand'
99
artifactId = project.name
10-
version = '1.3.5'
10+
version = '1.3.6'
1111

1212
// 指定要发布的 artifact
1313
from project.components.release

ffmpeg-lite/src/main/java/com/coder/ffmpeg/jni/FFmpegConfig.kt

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.coder.ffmpeg.jni
22

33
import android.content.Context
4+
import com.coder.ffmpeg.BuildConfig
45
import java.io.File
56
import java.io.FileOutputStream
67
import java.io.IOException
@@ -15,25 +16,53 @@ class FFmpegConfig {
1516
init {
1617
System.loadLibrary("ffmpeg-org")
1718
System.loadLibrary("ffmpeg-command")
19+
20+
nativeInit()
1821
}
1922

23+
/**
24+
* native Init, for basic config
25+
*/
26+
private external fun nativeInit()
27+
28+
/**
29+
* Whether to enable debugging mode
30+
* @param debug true or false
31+
*/
32+
private external fun nativeSetDebug(debug: Boolean)
33+
2034
/**
2135
* Whether to enable debugging mode
2236
* @param debug true or false
2337
*/
24-
external fun setDebug(debug: Boolean)
38+
@JvmStatic
39+
fun setDebug(debug: Boolean) {
40+
nativeSetDebug(debug)
41+
}
2542

2643
/**
2744
* Set the env of native
2845
* @param name env name
2946
* @param value env value
3047
*/
31-
private external fun setNativeEnv(name: String, value: String)
48+
private external fun nativeSetNativeEnv(name: String, value: String)
49+
50+
/**
51+
* Set the env of native
52+
* @param name env name
53+
* @param value env value
54+
*/
55+
@JvmStatic
56+
private fun setNativeEnv(name: String, value: String) {
57+
nativeSetNativeEnv(name, value)
58+
}
59+
3260
/**
3361
* Set font config dir for fontconfig
3462
* Note:It's a config dir not font dir
3563
* @param configPath the font config dir
3664
*/
65+
@JvmStatic
3766
fun setFontConfigPath(configPath: String) {
3867
setNativeEnv("FONTCONFIG_PATH", configPath)
3968
}
@@ -43,6 +72,7 @@ class FFmpegConfig {
4372
* Note:It's a config file not font file
4473
* @param configFile the font config file
4574
*/
75+
@JvmStatic
4676
fun setFontConfigFile(configFile: String) {
4777
setNativeEnv("FONTCONFIG_FILE", configFile)
4878
}
@@ -53,6 +83,7 @@ class FFmpegConfig {
5383
* @param fontDir the font dir contain fonts (.ttf and .otf files)
5484
* @param fontNameMapping
5585
*/
86+
@JvmStatic
5687
fun setFontDir(context: Context, fontDir:String, fontNameMapping: Map<String, String>){
5788
setFontDirList(context, Collections.singletonList(fontDir),fontNameMapping)
5889
}
@@ -61,6 +92,7 @@ class FFmpegConfig {
6192
* @param context context for application
6293
* @param fontDirList list of directories that contain fonts (.ttf and .otf files)
6394
*/
95+
@JvmStatic
6496
fun setFontDirList(context: Context, fontDirList: List<String>, fontNameMapping: Map<String, String>) {
6597
var validFontNameMappingCount = 0
6698
val cacheDir = context.cacheDir
@@ -121,8 +153,9 @@ class FFmpegConfig {
121153
}
122154
}
123155

156+
@JvmStatic
124157
fun getRepo():String {
125-
return "ffmpeg-lite"
158+
return BuildConfig.MODULE_NAME
126159
}
127160
}
128161
}
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

ffmpeg/build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ android {
1313

1414
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1515
consumerProguardFiles 'consumer-rules.pro'
16+
17+
buildConfigField "String", "MODULE_NAME", "\"ffmpeg\""
1618
}
1719

1820
buildTypes {
@@ -25,6 +27,11 @@ android {
2527
sourceCompatibility JavaVersion.VERSION_1_8
2628
targetCompatibility JavaVersion.VERSION_1_8
2729
}
30+
31+
buildFeatures {
32+
buildConfig true
33+
}
34+
2835
kotlinOptions {
2936
jvmTarget = '1.8'
3037
}

0 commit comments

Comments
 (0)