Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
BC
public
msandroidcamera2
Commits
4480fbeb
Commit
4480fbeb
authored
Jan 20, 2020
by
Sylvain Berfini
🎩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved capture stop() to fix issues
parent
462562b3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
18 deletions
+24
-18
android-camera2-capture.cpp
android-camera2-capture.cpp
+24
-18
No files found.
android-camera2-capture.cpp
View file @
4480fbeb
...
@@ -127,14 +127,18 @@ static void android_camera2_capture_device_on_disconnected(void *context, ACamer
...
@@ -127,14 +127,18 @@ static void android_camera2_capture_device_on_disconnected(void *context, ACamer
ms_message
(
"[Camera2 Capture] Camera %s is diconnected"
,
ACameraDevice_getId
(
device
));
ms_message
(
"[Camera2 Capture] Camera %s is diconnected"
,
ACameraDevice_getId
(
device
));
AndroidCamera2Context
*
d
=
(
AndroidCamera2Context
*
)
context
;
AndroidCamera2Context
*
d
=
(
AndroidCamera2Context
*
)
context
;
ms_filter_lock
(
d
->
filter
);
android_camera2_capture_stop
(
d
);
android_camera2_capture_stop
(
d
);
ms_filter_unlock
(
d
->
filter
);
}
}
static
void
android_camera2_capture_device_on_error
(
void
*
context
,
ACameraDevice
*
device
,
int
error
)
{
static
void
android_camera2_capture_device_on_error
(
void
*
context
,
ACameraDevice
*
device
,
int
error
)
{
ms_error
(
"[Camera2 Capture] Error %d on camera %s"
,
error
,
ACameraDevice_getId
(
device
));
ms_error
(
"[Camera2 Capture] Error %d on camera %s"
,
error
,
ACameraDevice_getId
(
device
));
AndroidCamera2Context
*
d
=
(
AndroidCamera2Context
*
)
context
;
AndroidCamera2Context
*
d
=
(
AndroidCamera2Context
*
)
context
;
ms_filter_lock
(
d
->
filter
);
android_camera2_capture_stop
(
d
);
android_camera2_capture_stop
(
d
);
ms_filter_unlock
(
d
->
filter
);
}
}
static
void
android_camera2_capture_session_on_ready
(
void
*
context
,
ACameraCaptureSession
*
session
)
{
static
void
android_camera2_capture_session_on_ready
(
void
*
context
,
ACameraCaptureSession
*
session
)
{
...
@@ -500,15 +504,11 @@ static void android_camera2_capture_stop(AndroidCamera2Context *d) {
...
@@ -500,15 +504,11 @@ static void android_camera2_capture_stop(AndroidCamera2Context *d) {
d
->
captureSession
=
nullptr
;
d
->
captureSession
=
nullptr
;
}
}
if
(
d
->
imageReader
)
{
if
(
d
->
capturePreviewRequest
)
{
AImageReader_delete
(
d
->
imageReader
);
ACaptureRequest_removeTarget
(
d
->
capturePreviewRequest
,
d
->
cameraCaptureOutputTarget
);
d
->
imageReader
=
nullptr
;
ACaptureRequest_free
(
d
->
capturePreviewRequest
);
d
->
capturePreviewRequest
=
nullptr
;
if
(
d
->
imageReaderListener
)
{
}
delete
d
->
imageReaderListener
;
d
->
imageReaderListener
=
nullptr
;
}
}
if
(
d
->
cameraCaptureOutputTarget
)
{
if
(
d
->
cameraCaptureOutputTarget
)
{
ACameraOutputTarget_free
(
d
->
cameraCaptureOutputTarget
);
ACameraOutputTarget_free
(
d
->
cameraCaptureOutputTarget
);
...
@@ -520,11 +520,6 @@ static void android_camera2_capture_stop(AndroidCamera2Context *d) {
...
@@ -520,11 +520,6 @@ static void android_camera2_capture_stop(AndroidCamera2Context *d) {
d
->
cameraPreviewOutputTarget
=
nullptr
;
d
->
cameraPreviewOutputTarget
=
nullptr
;
}
}
if
(
d
->
capturePreviewRequest
)
{
ACaptureRequest_free
(
d
->
capturePreviewRequest
);
d
->
capturePreviewRequest
=
nullptr
;
}
if
(
d
->
captureSessionOutputContainer
)
{
if
(
d
->
captureSessionOutputContainer
)
{
if
(
d
->
sessionCaptureOutput
)
{
if
(
d
->
sessionCaptureOutput
)
{
ACaptureSessionOutputContainer_remove
(
d
->
captureSessionOutputContainer
,
d
->
sessionCaptureOutput
);
ACaptureSessionOutputContainer_remove
(
d
->
captureSessionOutputContainer
,
d
->
sessionCaptureOutput
);
...
@@ -538,16 +533,27 @@ static void android_camera2_capture_stop(AndroidCamera2Context *d) {
...
@@ -538,16 +533,27 @@ static void android_camera2_capture_stop(AndroidCamera2Context *d) {
d
->
sessionPreviewOutput
=
nullptr
;
d
->
sessionPreviewOutput
=
nullptr
;
}
}
if
(
d
->
captureWindow
)
{
ANativeWindow_release
(
d
->
captureWindow
);
d
->
captureWindow
=
nullptr
;
}
ACaptureSessionOutputContainer_free
(
d
->
captureSessionOutputContainer
);
ACaptureSessionOutputContainer_free
(
d
->
captureSessionOutputContainer
);
d
->
captureSessionOutputContainer
=
nullptr
;
d
->
captureSessionOutputContainer
=
nullptr
;
}
}
if
(
d
->
captureWindow
)
{
android_camera2_capture_close_camera
(
d
);
ANativeWindow_release
(
d
->
captureWindow
);
d
->
captureWindow
=
nullptr
;
if
(
d
->
imageReader
)
{
AImageReader_delete
(
d
->
imageReader
);
d
->
imageReader
=
nullptr
;
if
(
d
->
imageReaderListener
)
{
delete
d
->
imageReaderListener
;
d
->
imageReaderListener
=
nullptr
;
}
}
}
android_camera2_capture_close_camera
(
d
);
android_camera2_capture_destroy_preview
(
d
);
android_camera2_capture_destroy_preview
(
d
);
ms_message
(
"[Camera2 Capture] Capture stopped"
);
ms_message
(
"[Camera2 Capture] Capture stopped"
);
...
...
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