Message ID | 20190905230720.90115-2-ffmpeg@tmm1.net |
---|---|
State | New |
Headers | show |
On Thu, Sep 05, 2019 at 04:07:20PM -0700, Aman Gupta wrote: > From: Aman Gupta <aman@tmm1.net> > > This will make it easy to switch to ANativeWindow_fromSurface > and ANativeWindow_release in the future. > > Signed-off-by: Aman Gupta <aman@tmm1.net> > --- > libavcodec/mediacodec_surface.c | 11 ++++------- > libavcodec/mediacodec_surface.h | 7 +++++-- > 2 files changed, 9 insertions(+), 9 deletions(-) > > diff --git a/libavcodec/mediacodec_surface.c b/libavcodec/mediacodec_surface.c > index efcc4dc63c..a292386e34 100644 > --- a/libavcodec/mediacodec_surface.c > +++ b/libavcodec/mediacodec_surface.c > @@ -25,10 +25,9 @@ > #include "ffjni.h" > #include "mediacodec_surface.h" > > -void *ff_mediacodec_surface_ref(void *surface, void *log_ctx) > +FFANativeWindow *ff_mediacodec_surface_ref(void *surface, void *log_ctx) > { > JNIEnv *env = NULL; > - void *reference = NULL; > > if (!surface) > return NULL; > @@ -38,12 +37,10 @@ void *ff_mediacodec_surface_ref(void *surface, void *log_ctx) > return NULL; > } > > - reference = (*env)->NewGlobalRef(env, surface); > - > - return reference; > + return (*env)->NewGlobalRef(env, surface); This should be done in a separate commit. [...]
diff --git a/libavcodec/mediacodec_surface.c b/libavcodec/mediacodec_surface.c index efcc4dc63c..a292386e34 100644 --- a/libavcodec/mediacodec_surface.c +++ b/libavcodec/mediacodec_surface.c @@ -25,10 +25,9 @@ #include "ffjni.h" #include "mediacodec_surface.h" -void *ff_mediacodec_surface_ref(void *surface, void *log_ctx) +FFANativeWindow *ff_mediacodec_surface_ref(void *surface, void *log_ctx) { JNIEnv *env = NULL; - void *reference = NULL; if (!surface) return NULL; @@ -38,12 +37,10 @@ void *ff_mediacodec_surface_ref(void *surface, void *log_ctx) return NULL; } - reference = (*env)->NewGlobalRef(env, surface); - - return reference; + return (*env)->NewGlobalRef(env, surface); } -int ff_mediacodec_surface_unref(void *surface, void *log_ctx) +int ff_mediacodec_surface_unref(FFANativeWindow *window, void *log_ctx) { JNIEnv *env = NULL; @@ -52,7 +49,7 @@ int ff_mediacodec_surface_unref(void *surface, void *log_ctx) return AVERROR_EXTERNAL; } - (*env)->DeleteGlobalRef(env, surface); + (*env)->DeleteGlobalRef(env, window); return 0; } diff --git a/libavcodec/mediacodec_surface.h b/libavcodec/mediacodec_surface.h index 0178b8ae71..933dc2bf51 100644 --- a/libavcodec/mediacodec_surface.h +++ b/libavcodec/mediacodec_surface.h @@ -25,7 +25,10 @@ #include "libavcodec/avcodec.h" -void *ff_mediacodec_surface_ref(void *surface, void *log_ctx); -int ff_mediacodec_surface_unref(void *surface, void *log_ctx); +struct FFANativeWindow; +typedef struct FFANativeWindow FFANativeWindow; + +FFANativeWindow *ff_mediacodec_surface_ref(void *surface, void *log_ctx); +int ff_mediacodec_surface_unref(FFANativeWindow *window, void *log_ctx); #endif /* AVCODEC_MEDIACODEC_SURFACE_H */