Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
224bb46f
Commit
224bb46f
authored
May 21, 2017
by
Matthieu Bouron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavc/mediacodec_wrapper: fix local reference leaks
parent
3766aa73
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
11 deletions
+26
-11
mediacodec_wrapper.c
libavcodec/mediacodec_wrapper.c
+26
-11
No files found.
libavcodec/mediacodec_wrapper.c
View file @
224bb46f
...
...
@@ -608,6 +608,7 @@ FFAMediaFormat *ff_AMediaFormat_new(void)
{
JNIEnv
*
env
=
NULL
;
FFAMediaFormat
*
format
=
NULL
;
jobject
object
=
NULL
;
format
=
av_mallocz
(
sizeof
(
FFAMediaFormat
));
if
(
!
format
)
{
...
...
@@ -625,23 +626,27 @@ FFAMediaFormat *ff_AMediaFormat_new(void)
goto
fail
;
}
format
->
object
=
(
*
env
)
->
NewObject
(
env
,
format
->
jfields
.
mediaformat_class
,
format
->
jfields
.
init_id
);
if
(
!
format
->
object
)
{
object
=
(
*
env
)
->
NewObject
(
env
,
format
->
jfields
.
mediaformat_class
,
format
->
jfields
.
init_id
);
if
(
!
object
)
{
goto
fail
;
}
format
->
object
=
(
*
env
)
->
NewGlobalRef
(
env
,
format
->
object
);
format
->
object
=
(
*
env
)
->
NewGlobalRef
(
env
,
object
);
if
(
!
format
->
object
)
{
goto
fail
;
}
return
format
;
fail:
ff_jni_reset_jfields
(
env
,
&
format
->
jfields
,
jni_amediaformat_mapping
,
1
,
format
);
if
(
object
)
{
(
*
env
)
->
DeleteLocalRef
(
env
,
object
);
}
if
(
!
format
->
object
)
{
ff_jni_reset_jfields
(
env
,
&
format
->
jfields
,
jni_amediaformat_mapping
,
1
,
format
);
av_freep
(
&
format
);
}
return
NULL
;
return
format
;
}
static
FFAMediaFormat
*
ff_AMediaFormat_newFromObject
(
void
*
object
)
...
...
@@ -1562,6 +1567,7 @@ uint8_t* ff_AMediaCodec_getInputBuffer(FFAMediaCodec* codec, size_t idx, size_t
JNIEnv
*
env
=
NULL
;
jobject
buffer
=
NULL
;
jobject
input_buffers
=
NULL
;
JNI_GET_ENV_OR_RETURN
(
env
,
codec
,
NULL
);
...
...
@@ -1572,12 +1578,12 @@ uint8_t* ff_AMediaCodec_getInputBuffer(FFAMediaCodec* codec, size_t idx, size_t
}
}
else
{
if
(
!
codec
->
input_buffers
)
{
codec
->
input_buffers
=
(
*
env
)
->
CallObjectMethod
(
env
,
codec
->
object
,
codec
->
jfields
.
get_input_buffers_id
);
input_buffers
=
(
*
env
)
->
CallObjectMethod
(
env
,
codec
->
object
,
codec
->
jfields
.
get_input_buffers_id
);
if
(
ff_jni_exception_check
(
env
,
1
,
codec
)
<
0
)
{
goto
fail
;
}
codec
->
input_buffers
=
(
*
env
)
->
NewGlobalRef
(
env
,
codec
->
input_buffers
);
codec
->
input_buffers
=
(
*
env
)
->
NewGlobalRef
(
env
,
input_buffers
);
if
(
ff_jni_exception_check
(
env
,
1
,
codec
)
<
0
)
{
goto
fail
;
}
...
...
@@ -1596,6 +1602,10 @@ fail:
(
*
env
)
->
DeleteLocalRef
(
env
,
buffer
);
}
if
(
input_buffers
)
{
(
*
env
)
->
DeleteLocalRef
(
env
,
input_buffers
);
}
return
ret
;
}
...
...
@@ -1605,6 +1615,7 @@ uint8_t* ff_AMediaCodec_getOutputBuffer(FFAMediaCodec* codec, size_t idx, size_t
JNIEnv
*
env
=
NULL
;
jobject
buffer
=
NULL
;
jobject
output_buffers
=
NULL
;
JNI_GET_ENV_OR_RETURN
(
env
,
codec
,
NULL
);
...
...
@@ -1615,12 +1626,12 @@ uint8_t* ff_AMediaCodec_getOutputBuffer(FFAMediaCodec* codec, size_t idx, size_t
}
}
else
{
if
(
!
codec
->
output_buffers
)
{
codec
->
output_buffers
=
(
*
env
)
->
CallObjectMethod
(
env
,
codec
->
object
,
codec
->
jfields
.
get_output_buffers_id
);
output_buffers
=
(
*
env
)
->
CallObjectMethod
(
env
,
codec
->
object
,
codec
->
jfields
.
get_output_buffers_id
);
if
(
ff_jni_exception_check
(
env
,
1
,
codec
)
<
0
)
{
goto
fail
;
}
codec
->
output_buffers
=
(
*
env
)
->
NewGlobalRef
(
env
,
codec
->
output_buffers
);
codec
->
output_buffers
=
(
*
env
)
->
NewGlobalRef
(
env
,
output_buffers
);
if
(
ff_jni_exception_check
(
env
,
1
,
codec
)
<
0
)
{
goto
fail
;
}
...
...
@@ -1639,6 +1650,10 @@ fail:
(
*
env
)
->
DeleteLocalRef
(
env
,
buffer
);
}
if
(
output_buffers
)
{
(
*
env
)
->
DeleteLocalRef
(
env
,
output_buffers
);
}
return
ret
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment