From e24c16f49bc1240638780e254fcecf2e96098d68 Mon Sep 17 00:00:00 2001 From: Vinson Xu Date: Wed, 21 May 2014 08:15:56 +0000 Subject: PD #83054 fix crash bug because of opening video device failed Conflicts: aml_screen.cpp v4l2_vdin.cpp Change-Id: I05fb46bc711e23cb9301e79c7b3625ee84168161 --- diff --git a/aml_screen.cpp b/aml_screen.cpp index 8e0921b..48acbd6 100755 --- a/aml_screen.cpp +++ b/aml_screen.cpp @@ -102,7 +102,6 @@ static int aml_screen_device_close(struct hw_device_t *dev) int screen_source_start(struct aml_screen_device* dev) { android::vdin_screen_source* source = (android::vdin_screen_source*)dev->priv; - LOGV("screen_source_start"); return source->start(); } int screen_source_stop(struct aml_screen_device* dev) @@ -237,6 +236,13 @@ static int aml_screen_device_open(const struct hw_module_t* module, const char* free (dev); return -ENOMEM; } + + if(source->init()!=0){ + LOGE("open vdin_screen_source failed!"); + free (dev); + return -1; + } + dev->priv = (void*)source; /* initialize the procs */ diff --git a/v4l2_vdin.cpp b/v4l2_vdin.cpp index 393e123..007373d 100755 --- a/v4l2_vdin.cpp +++ b/v4l2_vdin.cpp @@ -125,10 +125,13 @@ vdin_screen_source::vdin_screen_source() mCameraHandle = open("/dev/video11", O_RDWR| O_NONBLOCK); if (mCameraHandle < 0){ ALOGE("[%s %d] mCameraHandle:%x", __FUNCTION__, __LINE__, mCameraHandle); + return -1; } mVideoInfo = (struct VideoInfo *) calloc (1, sizeof (struct VideoInfo)); if (mVideoInfo == NULL){ ALOGE("[%s %d] no memory for mVideoInfo", __FUNCTION__, __LINE__); + close(mCameraHandle); + return NO_MEMORY; } mBufferCount = 4; mPixelFormat = V4L2_PIX_FMT_NV21; diff --git a/v4l2_vdin.h b/v4l2_vdin.h index 19f2ea0..04dd34f 100755 --- a/v4l2_vdin.h +++ b/v4l2_vdin.h @@ -77,7 +77,7 @@ class vdin_screen_source { public: vdin_screen_source(); ~vdin_screen_source(); - + int init(); int start(); int stop(); int pause(); -- cgit