From d9927380ed7c8366f762049be9f3fee225860833 Mon Sep 17 00:00:00 2001
From: liyujie <2352380935@qq.com>
Date: Thu, 28 Aug 2025 12:04:16 +0000
Subject: [PATCH] [2/4]解决USB摄像头打开相机预览界面绿屏

---
 android/hardware/aw/camera/3_4/common.cpp |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/android/hardware/aw/camera/3_4/common.cpp b/android/hardware/aw/camera/3_4/common.cpp
index 667e909..ba610b0 100755
--- a/android/hardware/aw/camera/3_4/common.cpp
+++ b/android/hardware/aw/camera/3_4/common.cpp
@@ -57,6 +57,39 @@
   }
 }
 
+bool saveBuffers(const char *path,
+                 void *y_addr,
+                 void *cr_addr,
+                 unsigned int y_size,
+                 unsigned int cr_size,
+                 bool is_oneframe) {
+  int fd;
+  HAL_LOGD("Debug to save a frame!");
+  if((access(path, 0) != -1) && (is_oneframe)) {
+    HAL_LOGD("File %s is exists!!!\n", path);
+  }
+  if(is_oneframe)
+    fd = open(path, O_CREAT|O_RDWR|O_TRUNC, 0777); //save one frame data
+  else
+    fd = open(path, O_CREAT|O_RDWR|O_APPEND, 0777); //save more frames
+  if(!fd) {
+    HAL_LOGE("Open file error");
+    return false;
+  }
+  if(write(fd, y_addr, y_size)){
+    HAL_LOGD("Write Y data successfully");
+    if(write(fd, cr_addr, cr_size)){
+      HAL_LOGD("Write U data successfully");
+      close(fd);
+      return true;
+    }
+  }
+  HAL_LOGE("Write file fail");
+  close(fd);
+  return false;
+}
+
+
 bool saveSizes(int width, int height) {
   int fd;
   char buf[128];

--
Gitblit v1.6.2