]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/mediacodec.c
Merge commit 'ba7397baef796ca3991fe1c921bc91054407c48b'
[ffmpeg] / libavcodec / mediacodec.c
index 5b79798a87b49d8ca14e172e5a3a0daa4a98b3e5..4ad5921bc205a3a5b4be83e12c7f510ce68e72a8 100644 (file)
 
 #include "config.h"
 
+#include "libavutil/error.h"
+
+#include "mediacodec.h"
+
 #if CONFIG_H264_MEDIACODEC_HWACCEL
 
 #include <jni.h>
@@ -31,8 +35,8 @@
 #include "libavutil/mem.h"
 
 #include "ffjni.h"
-#include "mediacodec.h"
-#include "mediacodecdec.h"
+#include "mediacodecdec_common.h"
+#include "version.h"
 
 AVMediaCodecContext *av_mediacodec_alloc_context(void)
 {
@@ -43,9 +47,8 @@ int av_mediacodec_default_init(AVCodecContext *avctx, AVMediaCodecContext *ctx,
 {
     int ret = 0;
     JNIEnv *env = NULL;
-    int attached = 0;
 
-    env = ff_jni_attach_env(&attached, avctx);
+    env = ff_jni_get_env(avctx);
     if (!env) {
         return AVERROR_EXTERNAL;
     }
@@ -58,17 +61,12 @@ int av_mediacodec_default_init(AVCodecContext *avctx, AVMediaCodecContext *ctx,
         ret = AVERROR_EXTERNAL;
     }
 
-    if (attached) {
-        ff_jni_detach_env(avctx);
-    }
-
     return ret;
 }
 
 void av_mediacodec_default_free(AVCodecContext *avctx)
 {
     JNIEnv *env = NULL;
-    int attached = 0;
 
     AVMediaCodecContext *ctx = avctx->hwaccel_context;
 
@@ -76,7 +74,7 @@ void av_mediacodec_default_free(AVCodecContext *avctx)
         return;
     }
 
-    env = ff_jni_attach_env(&attached, avctx);
+    env = ff_jni_get_env(avctx);
     if (!env) {
         return;
     }
@@ -86,10 +84,6 @@ void av_mediacodec_default_free(AVCodecContext *avctx)
         ctx->surface = NULL;
     }
 
-    if (attached) {
-        ff_jni_detach_env(avctx);
-    }
-
     av_freep(&avctx->hwaccel_context);
 }
 
@@ -109,8 +103,6 @@ int av_mediacodec_release_buffer(AVMediaCodecBuffer *buffer, int render)
 
 #include <stdlib.h>
 
-#include "mediacodec.h"
-
 AVMediaCodecContext *av_mediacodec_alloc_context(void)
 {
     return NULL;
@@ -118,7 +110,7 @@ AVMediaCodecContext *av_mediacodec_alloc_context(void)
 
 int av_mediacodec_default_init(AVCodecContext *avctx, AVMediaCodecContext *ctx, void *surface)
 {
-    return 0;
+    return AVERROR(ENOSYS);
 }
 
 void av_mediacodec_default_free(AVCodecContext *avctx)
@@ -127,7 +119,7 @@ void av_mediacodec_default_free(AVCodecContext *avctx)
 
 int av_mediacodec_release_buffer(AVMediaCodecBuffer *buffer, int render)
 {
-    return 0;
+    return AVERROR(ENOSYS);
 }
 
 #endif