Skip to content

Commit

Permalink
Error handling in case of preview, host disconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
gkdeepa committed Dec 2, 2021
1 parent 4107dfe commit 1fc7b96
Showing 1 changed file with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
From 545e451cbf1a457bdf721cf6fff6d5b1543b2f72 Mon Sep 17 00:00:00 2001
From: gkdeepa <[email protected]>
Date: Thu, 2 Dec 2021 13:16:21 +0530
Subject: [PATCH] Error handling if disconnects in preview

Tracked-On:
---
src/CameraSocketServerThread.cpp | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/CameraSocketServerThread.cpp b/src/CameraSocketServerThread.cpp
index c06fb22..15cdd1c 100644
--- a/src/CameraSocketServerThread.cpp
+++ b/src/CameraSocketServerThread.cpp
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-//#define LOG_NDEBUG 0
+#define LOG_NDEBUG 0
//#define LOG_NNDEBUG 0
#define LOG_TAG "CameraSocketServerThread: "
#include <log/log.h>
@@ -320,7 +320,7 @@ bool CameraSocketServerThread::threadLoop() {
mClientFd = -1;
clearBuffer(fbuffer, 640, 480);
break;
- } else if ((event & POLLIN) || (trans_mode == VSOCK) || (trans_mode == TCP) ) { // preview / record
+ } else if ((event & POLLIN) ) { // preview / record
// data is available in socket => read data
if (gIsInFrameI420) {
ssize_t size = 0;
@@ -330,6 +330,11 @@ bool CameraSocketServerThread::threadLoop() {
{
while(size_update != 460800){
size = recv(mClientFd, (char *)fbuffer+size_update, 460800, 0);
+ if(size < 0){
+ //error handling while in preview
+ ALOGE(LOG_TAG "entered into recv error, break to recover");
+ break;
+ }
size_update += size;
if (size_update == 460800){
handle->clientRevCount++;
--
2.17.1

0 comments on commit 1fc7b96

Please sign in to comment.