Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit 9bf06a9

Browse files
committed
improve getNativeLastCommandOutput checks
1 parent f7957bf commit 9bf06a9

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

Diff for: android/app/src/main/cpp/mobileffmpeg.c

+10-8
Original file line numberDiff line numberDiff line change
@@ -848,14 +848,16 @@ JNIEXPORT int JNICALL Java_com_arthenica_mobileffmpeg_Config_setNativeEnvironmen
848848
* @return output of the last executed command
849849
*/
850850
JNIEXPORT jstring JNICALL Java_com_arthenica_mobileffmpeg_Config_getNativeLastCommandOutput(JNIEnv *env, jclass object) {
851-
int size = strlen(lastCommandOutput);
851+
if (lastCommandOutput != NULL) {
852+
int size = strlen(lastCommandOutput);
852853

853-
if (size > 0) {
854-
jbyteArray byteArray = (*env)->NewByteArray(env, size);
855-
(*env)->SetByteArrayRegion(env, byteArray, 0, size, lastCommandOutput);
856-
jstring charsetName = (*env)->NewStringUTF(env, "UTF-8");
857-
return (jstring) (*env)->NewObject(env, stringClass, stringConstructor, byteArray, charsetName);
858-
} else {
859-
return (*env)->NewStringUTF(env, "");
854+
if (size > 0) {
855+
jbyteArray byteArray = (*env)->NewByteArray(env, size);
856+
(*env)->SetByteArrayRegion(env, byteArray, 0, size, lastCommandOutput);
857+
jstring charsetName = (*env)->NewStringUTF(env, "UTF-8");
858+
return (jstring) (*env)->NewObject(env, stringClass, stringConstructor, byteArray, charsetName);
859+
}
860860
}
861+
862+
return (*env)->NewStringUTF(env, "");
861863
}

Diff for: android/test-app/src/main/java/com/arthenica/mobileffmpeg/test/CommandTabFragment.java

+2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ public void onClick(View v) {
7878
outputText = getView().findViewById(R.id.outputText);
7979
outputText.setMovementMethod(new ScrollingMovementMethod());
8080
}
81+
82+
android.util.Log.d(MainActivity.TAG, "Last command output was: " + FFmpeg.getLastCommandOutput());
8183
}
8284

8385
@Override

0 commit comments

Comments
 (0)