Merge "MediaMuxerJNI:Throw relevant exception on error"

This commit is contained in:
TreeHugger Robot
2019-12-20 19:54:29 +00:00
committed by Android (Google) Code Review

View File

@@ -26,11 +26,15 @@
#include <unistd.h>
#include <fcntl.h>
#include <android/api-level.h>
#include <media/stagefright/foundation/ABuffer.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/AMessage.h>
#include <media/stagefright/MediaErrors.h>
#include <media/stagefright/MediaMuxer.h>
extern "C" int android_get_application_target_sdk_version();
namespace android {
struct fields_t {
@@ -229,10 +233,31 @@ static void android_media_MediaMuxer_stop(JNIEnv *env, jclass /* clazz */,
status_t err = muxer->stop();
if (err != OK) {
jniThrowException(env, "java/lang/IllegalStateException",
"Failed to stop the muxer");
return;
if (android_get_application_target_sdk_version() >= __ANDROID_API_R__) {
switch (err) {
case OK:
break;
case ERROR_IO: {
jniThrowException(env, "java/lang/UncheckedIOException",
"Muxer stopped unexpectedly");
return;
}
case ERROR_MALFORMED: {
jniThrowException(env, "java/io/IOError",
"Failure of reading or writing operation");
return;
}
default: {
jniThrowException(env, "java/lang/IllegalStateException",
"Failed to stop the muxer");
return;
}
}
} else {
if (err != OK) {
jniThrowException(env, "java/lang/IllegalStateException", "Failed to stop the muxer");
return;
}
}
}