| 696 | } |
| 697 | |
| 698 | static int android_camera_read_close(AVFormatContext *avctx) |
| 699 | { |
| 700 | AndroidCameraCtx *ctx = avctx->priv_data; |
| 701 | |
| 702 | atomic_store(&ctx->exit, 1); |
| 703 | |
| 704 | if (ctx->capture_session) { |
| 705 | ACameraCaptureSession_stopRepeating(ctx->capture_session); |
| 706 | // Following warning is emitted, after capture session closed callback is received: |
| 707 | // ACameraCaptureSession: Device is closed but session 0 is not notified |
| 708 | // Seems to be a bug in Android, we can ignore this |
| 709 | ACameraCaptureSession_close(ctx->capture_session); |
| 710 | ctx->capture_session = NULL; |
| 711 | } |
| 712 | |
| 713 | if (ctx->capture_request) { |
| 714 | ACaptureRequest_removeTarget(ctx->capture_request, ctx->camera_output_target); |
| 715 | ACaptureRequest_free(ctx->capture_request); |
| 716 | ctx->capture_request = NULL; |
| 717 | } |
| 718 | |
| 719 | if (ctx->camera_output_target) { |
| 720 | ACameraOutputTarget_free(ctx->camera_output_target); |
| 721 | ctx->camera_output_target = NULL; |
| 722 | } |
| 723 | |
| 724 | if (ctx->capture_session_output) { |
| 725 | ACaptureSessionOutputContainer_remove(ctx->capture_session_output_container, |
| 726 | ctx->capture_session_output); |
| 727 | ACaptureSessionOutput_free(ctx->capture_session_output); |
| 728 | ctx->capture_session_output = NULL; |
| 729 | } |
| 730 | |
| 731 | if (ctx->image_reader_window) { |
| 732 | ANativeWindow_release(ctx->image_reader_window); |
| 733 | ctx->image_reader_window = NULL; |
| 734 | } |
| 735 | |
| 736 | if (ctx->capture_session_output_container) { |
| 737 | ACaptureSessionOutputContainer_free(ctx->capture_session_output_container); |
| 738 | ctx->capture_session_output_container = NULL; |
| 739 | } |
| 740 | |
| 741 | if (ctx->camera_dev) { |
| 742 | ACameraDevice_close(ctx->camera_dev); |
| 743 | ctx->camera_dev = NULL; |
| 744 | } |
| 745 | |
| 746 | if (ctx->image_reader) { |
| 747 | AImageReader_delete(ctx->image_reader); |
| 748 | ctx->image_reader = NULL; |
| 749 | } |
| 750 | |
| 751 | if (ctx->camera_metadata) { |
| 752 | ACameraMetadata_free(ctx->camera_metadata); |
| 753 | ctx->camera_metadata = NULL; |
| 754 | } |
| 755 |
no test coverage detected