[Bugfix][T106][task-view-448] change printf to rlogd in lynq-vb-demo

    Only Configure: No
    Affected branch: unknown
    Affected module: network
    Is it affected on both ZXIC and MTK: only ZXIC
    Self-test: yes
    Doc Update: no

Change-Id: I39686f038ab0526d70c5e65a10ce51a1ce26075f
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-vb-demo/files/lynq_vb_demo.c b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-vb-demo/files/lynq_vb_demo.c
index fc94d2a..a3e6499 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-vb-demo/files/lynq_vb_demo.c
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-vb-demo/files/lynq_vb_demo.c
@@ -14,12 +14,17 @@
 #include <semaphore.h>

 #include <sys/types.h>

 #include <pthread.h>

+#include <log/log.h>

+#include <time.h>

+#define LOG_TAG "VB_DEMO"

+

+

 

 /*command max len*/

 #define VOICE_CMD_MAX_LEN 64

 

-#define EXIT_CMD_STOP	"stop\n"

-#define EXIT_CMD_Q	"q\n"

+#define EXIT_CMD_STOP    "stop\n"

+#define EXIT_CMD_Q    "q\n"

 #define EXIT_CMD_EXIT   "exit\n"

 

 #define REQ_VOICE_BUFFER_TEST_START        "voice_buffer_test_start"

@@ -38,7 +43,7 @@
 

 

 

-#define VB_MAX_INT	     0x7fffffff

+#define VB_MAX_INT         0x7fffffff

 #define VB_MIN_INT        0 

 #define VB_INT_OVERFLOW(x) if((x < VB_MIN_INT)||(x > VB_MAX_INT))  x = 0;

  

@@ -49,21 +54,21 @@
 typedef int (vb_thread_proc)(void*);

 struct vbuf_info_t

 {

-	int fd;

-    pthread_t	    rx_test_thread;	

-    pthread_t	    tx_test_thread;

-	pthread_t	    loop_test_thread;

-	int quit;

-	char        	*tx_buf;

-    char        	*rx_buf;

-	int buf_size;

-	char *tx_filename;

-	char *rx_filename;

+    int fd;

+    pthread_t        rx_test_thread;    

+    pthread_t        tx_test_thread;

+    pthread_t        loop_test_thread;

+    int quit;

+    char            *tx_buf;

+    char            *rx_buf;

+    int buf_size;

+    char *tx_filename;

+    char *rx_filename;

     FILE *tx_file;

-	FILE *rx_file;

+    FILE *rx_file;

     int tx_filesize;

-	int rx_filesize;		

-	int fs;	 	

+    int rx_filesize;        

+    int fs;         

 };

 

 static struct vbuf_info_t vbuf_rec;

@@ -74,40 +79,47 @@
      

     printf("voice_buffer_test_start                      value: 8000,16000\n");

     printf("voice_buffer_test_stop                       no value input\n");

-	printf("voice_buffer_loop_test_start                      value: 8000,16000\n");

+    printf("voice_buffer_loop_test_start                      value: 8000,16000\n");

     printf("voice_buffer_loop_test_stop                       no value input\n");

     printf("\n");

 }

 

 static int vbuffer_start_flag = 0;

 static int tx_optcount = 0;

-static int rx_optcount = 0;	

+static int rx_optcount = 0;    

 static int first_rderr_flag = 0;

 static int first_wrerr_flag = 0;

 

+static pthread_mutex_t s_vb_demo_mtx = PTHREAD_MUTEX_INITIALIZER;

+

 static int vb_close_fd_release_buf()

-{    

-    int ret = voice_buffer_close(vbuf_rec.fd); 

-    if(ret != 0) 

+{   

+    int ret=0;

+    if(vbuf_rec.fd>0)

     {

-		printf("%s : vb close fail \n",__func__);

+        ret = voice_buffer_close(vbuf_rec.fd); 

+        if(ret != 0) 

+        {

+            RLOGE("%s : vb close fail ret is %d\n",__func__,ret);

+        }

+        vbuf_rec.fd = -1;

     }

-	vbuf_rec.fd = -1;

+    

 

     if(vbuf_rec.rx_buf)

     {

-	    free(vbuf_rec.rx_buf);

-    	vbuf_rec.rx_buf = NULL;

+        free(vbuf_rec.rx_buf);

+        vbuf_rec.rx_buf = NULL;

     }

 

     if(vbuf_rec.tx_buf)

     {

         free(vbuf_rec.tx_buf);

-    	vbuf_rec.tx_buf = NULL;

+        vbuf_rec.tx_buf = NULL;

     }

 

-	vbuffer_start_flag = 0;	

-    printf("close buf fd and release buf end\n");

+    vbuffer_start_flag = 0;    

+    RLOGD("close buf fd and release buf end\n");

     return ret;

 }

 

@@ -124,56 +136,56 @@
     int r_size;

 

  

-    printf( "%s: start size=%d! \n",__func__,size);

+    RLOGD( "%s: start size=%d! \n",__func__,size);

     memset (buf,0, size);

     

     while (!vbuf_rec.quit) 

     {

-		rx_optcount ++;	

-		VB_INT_OVERFLOW(rx_optcount);

-		if((rx_optcount%1000) == 0){

-            printf("%s: rx_optcount=%d! \n",__func__,rx_optcount);

+        rx_optcount ++;    

+        VB_INT_OVERFLOW(rx_optcount);

+        if((rx_optcount%1000) == 0){

+            RLOGD("%s: rx_optcount=%d! \n",__func__,rx_optcount);

 

-		}

-		else if(rx_optcount == 1000000){

-            printf("%s: rx_optcount=%d! \n",__func__,rx_optcount);

-			rx_optcount = 0;

-			

-		}

+        }

+        else if(rx_optcount == 1000000){

+            RLOGD("%s: rx_optcount=%d! \n",__func__,rx_optcount);

+            rx_optcount = 0;

+            

+        }

 

         //read form ps

-		r_size = voice_buffer_read(vbuf_rec.fd, buf, size);

+        r_size = voice_buffer_read(vbuf_rec.fd, buf, size);

         if(r_size <= 0) 

         {

-            first_rderr_flag++;			

-			VB_INT_OVERFLOW(first_rderr_flag);			

+            first_rderr_flag++;            

+            VB_INT_OVERFLOW(first_rderr_flag);            

             continue ;

         }

-		else{

-			first_rderr_flag = 0;

+        else{

+            first_rderr_flag = 0;

 

-		}

-		

+        }

+        

         if(vbuf_rec.rx_file != NULL) 

         {

-			r_size = fwrite(buf, 1,size, vbuf_rec.rx_file);

+            r_size = fwrite(buf, 1,size, vbuf_rec.rx_file);

 

-		    if (r_size != size) {

-		        //printf("Error fwrite size not eq,r_size=%d,size=%d\n",r_size,size);

-		    }

-			else{

-			

-		        bytes_read += size;

-				if(bytes_read >= vbuf_rec.rx_filesize){

-					fseek(vbuf_rec.rx_file, 0, SEEK_SET);

-					bytes_read = 0;

-					printf("fwrite over write maxsize(%d)!!!\n",vbuf_rec.rx_filesize);

-				

-				}

-			}

+            if (r_size != size) {

+                //printf("Error fwrite size not eq,r_size=%d,size=%d\n",r_size,size);

+            }

+            else{

+            

+                bytes_read += size;

+                if(bytes_read >= vbuf_rec.rx_filesize){

+                    fseek(vbuf_rec.rx_file, 0, SEEK_SET);

+                    bytes_read = 0;

+                    RLOGD("fwrite over write maxsize(%d)!!!\n",vbuf_rec.rx_filesize);

+                

+                }

+            }

         }

-		

-		

+        

+        

     }

     

     return 0;

@@ -184,65 +196,65 @@
     int ret;

     int num_read;

 

-	

+    

     char* buf = vbuf_rec.tx_buf;

-	

+    

     int size = vbuf_rec.buf_size;

      int w_size;

 

-	 printf("%s: start size=%d! \n",__func__,size);

+     RLOGD("%s: start size=%d! \n",__func__,size);

  

-	

+    

     memset(buf, 0,size);    

     while (!vbuf_rec.quit) 

     {

 

-	    if(vbuf_rec.tx_file != NULL) 

-	    {

+        if(vbuf_rec.tx_file != NULL) 

+        {

 

-	        num_read = fread(buf,1,size, vbuf_rec.tx_file);

-			

-	        if (num_read != size) {

-		        //printf("Error fread size not eq,num_read=%d,size=%d\n",num_read,size);

-			}

-	        if (num_read <= 0) {

-		        printf("Error fread size not eq,num_read=%d,size=%d\n",num_read,size); 

-				fseek(vbuf_rec.tx_file, 0, SEEK_SET);

-			}

-	    }			

-		tx_optcount ++;

-		VB_INT_OVERFLOW(tx_optcount);

-		

-		w_size = voice_buffer_write(vbuf_rec.fd, buf, size);

+            num_read = fread(buf,1,size, vbuf_rec.tx_file);

+            

+            if (num_read != size) {

+                //printf("Error fread size not eq,num_read=%d,size=%d\n",num_read,size);

+            }

+            if (num_read <= 0) {

+                RLOGD("Error fread size not eq,num_read=%d,size=%d\n",num_read,size); 

+                fseek(vbuf_rec.tx_file, 0, SEEK_SET);

+            }

+        }            

+        tx_optcount ++;

+        VB_INT_OVERFLOW(tx_optcount);

+        

+        w_size = voice_buffer_write(vbuf_rec.fd, buf, size);

         if(w_size <= 0) 

         {

-        	first_wrerr_flag++;

-			

-			VB_INT_OVERFLOW(first_wrerr_flag);

-			

+            first_wrerr_flag++;

+            

+            VB_INT_OVERFLOW(first_wrerr_flag);

+            

             continue;

         }

-		else{

-			first_wrerr_flag = 0;

+        else{

+            first_wrerr_flag = 0;

 

-		}

+        }

 

     }

     return 0;

 }

 

 

-static int vb_thread_create( const char *name,pthread_t	*thread_t, vb_thread_proc *proc, 

-								int stack_size, unsigned priority,void *arg )

+static int vb_thread_create( const char *name,pthread_t    *thread_t, vb_thread_proc *proc, 

+                                int stack_size, unsigned priority,void *arg )

 {

     pthread_attr_t thread_attr;

     int ret;

-	int default_size;

+    int default_size;

     

     struct sched_param    param;

     int  policy = SCHED_FIFO;

     

-    printf("%s: start! \n",__func__);

+    RLOGD("%s: start! \n",__func__);

     

     /* Init thread attributes */

     pthread_attr_init(&thread_attr);    

@@ -251,18 +263,18 @@
     ret = pthread_create( thread_t, &thread_attr,proc, arg);

     if (ret != 0) 

     {

-    	printf("%s: pthread_create fail,ret=%d! \n",__func__,ret);

+        RLOGE("%s: pthread_create fail,ret=%d! \n",__func__,ret);

     

-    	pthread_attr_destroy(&thread_attr);

+        pthread_attr_destroy(&thread_attr);

         return ret;

     }

-	

+    

     pthread_attr_getstacksize(&thread_attr, &default_size);

-    printf("%s: pthread_attr_getstacksize(%d)! \n",__func__,default_size);

+    RLOGD("%s: pthread_attr_getstacksize(%d)! \n",__func__,default_size);

     

     pthread_attr_destroy(&thread_attr);

-	

-    printf("%s: end \n",__func__);

+    

+    RLOGD("%s: end \n",__func__);

     return 0;

 }

 

@@ -273,136 +285,136 @@
 {

     int ret = 0;

     int buf_size = 320;

-	tx_optcount = 0;

-	rx_optcount = 0;	

+    tx_optcount = 0;

+    rx_optcount = 0;    

     int* buf_int;

 

-	int i;

+    int i;

 

-	if(vbuffer_start_flag == 1){ 

-		printf(" VB already start,return \n");

+    if(vbuffer_start_flag == 1){ 

+        RLOGE(" VB already start,return \n");

 

-		return 0;

-	}

+        return 0;

+    }

 

-	vbuffer_start_flag = 1;

+    vbuffer_start_flag = 1;

 

 

 

-	if((vbuf_rec.fd != -1)&&(vbuf_rec.fd != 0)){

-		printf(" VB fd already get, vbuf_rec.fd=%d return \n",vbuf_rec.fd);

-	}

+    if((vbuf_rec.fd != -1)&&(vbuf_rec.fd != 0)){

+        RLOGE(" VB fd already get, vbuf_rec.fd=%d return \n",vbuf_rec.fd);

+    }

 

-	if(fs == 8000){

+    if(fs == 8000){

 

-		buf_size = 320;

-	}

-	else if(fs == 16000){

+        buf_size = 320;

+    }

+    else if(fs == 16000){

 

-		buf_size = 640;

-	}	

-	else

-	{

-		buf_size = 320;

-	}

- 	printf("Starting vb stream fs=%d buf_size=%d \n",fs,buf_size);

+        buf_size = 640;

+    }    

+    else

+    {

+        buf_size = 320;

+    }

+     RLOGD("Starting vb stream fs=%d buf_size=%d \n",fs,buf_size);

 

- 	printf("%s:open tx and rx file \n",__func__);

-	if(fs == 8000){

+     RLOGD("%s:open tx and rx file \n",__func__);

+    if(fs == 8000){

 

-   		vbuf_rec.tx_filename = VBUFFER_TX_FILE_NAME;//"/cache/tx.pcm";

-    	vbuf_rec.rx_filename = VBUFFER_RX_FILE_NAME;//"/cache/rx.pcm";

+        vbuf_rec.tx_filename = VBUFFER_TX_FILE_NAME;//"/cache/tx.pcm";

+        vbuf_rec.rx_filename = VBUFFER_RX_FILE_NAME;//"/cache/rx.pcm";

 

-	}

-	else if(fs == 16000){

+    }

+    else if(fs == 16000){

 

-    	vbuf_rec.tx_filename = VBUFFER_TX16_FILE_NAME;//"/cache/tx16.pcm";

-    	vbuf_rec.rx_filename = VBUFFER_RX16_FILE_NAME;//"/cache/rx16.pcm";

+        vbuf_rec.tx_filename = VBUFFER_TX16_FILE_NAME;//"/cache/tx16.pcm";

+        vbuf_rec.rx_filename = VBUFFER_RX16_FILE_NAME;//"/cache/rx16.pcm";

 

-	}	

-	else

-	{

-		vbuf_rec.tx_filename = VBUFFER_TX_FILE_NAME;//"/cache/tx.pcm";

-		vbuf_rec.rx_filename = VBUFFER_RX_FILE_NAME;//"/cache/rx.pcm";

+    }    

+    else

+    {

+        vbuf_rec.tx_filename = VBUFFER_TX_FILE_NAME;//"/cache/tx.pcm";

+        vbuf_rec.rx_filename = VBUFFER_RX_FILE_NAME;//"/cache/rx.pcm";

 

-	}

+    }

 

 

 

-	

+    

     vbuf_rec.tx_file = fopen(vbuf_rec.tx_filename , "rb");

     if (!vbuf_rec.tx_file) {

-        printf("Unable to open file '%s'\n", vbuf_rec.tx_filename);

+        RLOGE("Unable to open file '%s'\n", vbuf_rec.tx_filename);

         //return -1;

     }

 

 

     vbuf_rec.rx_file = fopen(vbuf_rec.rx_filename, "wb");

     if (!vbuf_rec.rx_file) {

-        printf(stderr, "Unable to create file '%s'\n", vbuf_rec.rx_filename);

-		//fclose(vbuf_rec.tx_file);

+        RLOGE("Unable to create file '%s'\n", vbuf_rec.rx_filename);

+        //fclose(vbuf_rec.tx_file);

  

         //return -1;

     }

-	vbuf_rec.rx_filesize = RX_FILE_LEN_MAX;	

-	printf("%s : vbuf_rec.rx_filesize(%d) \n",__func__,vbuf_rec.rx_filesize);

+    vbuf_rec.rx_filesize = RX_FILE_LEN_MAX;    

+    RLOGD("%s : vbuf_rec.rx_filesize(%d) \n",__func__,vbuf_rec.rx_filesize);

 

     vbuf_rec.rx_buf = (char*) malloc(buf_size);

-	if(!vbuf_rec.rx_buf) {

-		printf("%s : malloc buf fail,return \n",__func__);

-		goto err;

-	}	

+    if(!vbuf_rec.rx_buf) {

+        RLOGE("%s : malloc buf fail,return \n",__func__);

+        goto err;

+    }    

     vbuf_rec.tx_buf = (char*) malloc(buf_size);  

-	if(!vbuf_rec.tx_buf) {

-		free(vbuf_rec.rx_buf);

-		printf("%s : malloc buf fail,return \n",__func__);

-	    vbuf_rec.rx_buf = NULL;

-		goto err;

-	}	

-	vbuf_rec.buf_size = buf_size;

-	

+    if(!vbuf_rec.tx_buf) {

+        free(vbuf_rec.rx_buf);

+        RLOGE("%s : malloc buf fail,return \n",__func__);

+        vbuf_rec.rx_buf = NULL;

+        goto err;

+    }    

+    vbuf_rec.buf_size = buf_size;

+    

     vbuf_rec.quit = 0;

-	

-	printf("%s : vb open start \n",__func__);

+    

+    RLOGD("%s : vb open start \n",__func__);

 

-	

+    

     vbuf_rec.fd = voice_buffer_open();

-	if(vbuf_rec.fd <= 0){

-		printf("%s : vb open fail fd=%d,return \n",__func__,vbuf_rec.fd);

-		ret = -1;

-		goto err;

-		

-	}

-	printf("%s :voice_buffer_open end \n",__func__);

-	

-	printf("%s :rx tx vb_thread_create start \n",__func__);

+    if(vbuf_rec.fd <= 0){

+        RLOGE("%s : vb open fail fd=%d,return \n",__func__,vbuf_rec.fd);

+        ret = -1;

+        goto err;

+        

+    }

+    RLOGD("%s :voice_buffer_open end \n",__func__);

+    

+    RLOGD("%s :rx tx vb_thread_create start \n",__func__);

     ret = vb_thread_create ("vb_playback_test",&vbuf_rec.rx_test_thread, vb_rx_test_thread_func, 

-    							4*1024,35,NULL);

+                                4*1024,35,NULL);

     if (ret != 0)

     {

-		printf("%s :rx vb_thread_create fail ret=%d,return \n",__func__,ret);  

+        RLOGE("%s :rx vb_thread_create fail ret=%d,return \n",__func__,ret);  

         vbuf_rec.rx_test_thread = NULL;

-		goto err;

+        goto err;

     }

 

-	printf("%s :rx vb_thread_create end \n",__func__);

+    RLOGD("%s :rx vb_thread_create end \n",__func__);

 

     ret = vb_thread_create ( "vbuf_record_test", &vbuf_rec.tx_test_thread, vb_tx_test_thread_func,

-    							4*1024,35,NULL);

+                                4*1024,35,NULL);

     if (ret != 0) 

     {

     

-		printf("%s :tx vb_thread_create fail ret=%d,return \n",__func__,ret);       

+        RLOGE("%s :tx vb_thread_create fail ret=%d,return \n",__func__,ret);       

         vbuf_rec.tx_test_thread = NULL;

-		goto err;

+        goto err;

     }

-	printf("%s :tx vb_thread_create end \n",__func__);

+    RLOGD("%s :tx vb_thread_create end \n",__func__);

 

     return 0;

 

 err:

     voice_buffer_stream_test_stop();

-	

+    

     return ret;

 }

 

@@ -411,42 +423,42 @@
 int voice_buffer_stream_test_stop(void)

 {

     int ret = 0;

-	printf("%s:rx tx thread exit start \n",__func__);

-	if(vbuf_rec.quit == 1) {

-		printf("%s,already stop ,return\n",__func__);

+    RLOGD("%s:rx tx thread exit start \n",__func__);

+    if(vbuf_rec.quit == 1) {

+        RLOGD("%s,already stop ,return\n",__func__);

 

-	}

+    }

     

     vbuf_rec.quit = 1;

-	voice_buffer_stop(vbuf_rec.fd);

+    voice_buffer_stop(vbuf_rec.fd);

     if (vbuf_rec.tx_test_thread) 

     {

         pthread_join (vbuf_rec.tx_test_thread,NULL);

         vbuf_rec.tx_test_thread = NULL;

-		

+        

     }

     

     if (vbuf_rec.rx_test_thread) 

-    {	

+    {    

         pthread_join (vbuf_rec.rx_test_thread,NULL);

         vbuf_rec.rx_test_thread = NULL;

     }    

-	

-	if(vbuf_rec.tx_file != NULL) 

-	{

-		fclose(vbuf_rec.tx_file);

-		printf("%s : vb close ,close tx file \n",__func__);

-		vbuf_rec.tx_file = NULL;

-	}

-		

-	if(vbuf_rec.rx_file != NULL) 

-	{

+    

+    if(vbuf_rec.tx_file != NULL) 

+    {

+        fclose(vbuf_rec.tx_file);

+        RLOGD("%s : vb close ,close tx file \n",__func__);

+        vbuf_rec.tx_file = NULL;

+    }

+        

+    if(vbuf_rec.rx_file != NULL) 

+    {

 

-		fclose(vbuf_rec.rx_file);

-		printf("%s : vb close ,close rx file \n",__func__);

-		vbuf_rec.rx_file = NULL;

-		

-	}

+        fclose(vbuf_rec.rx_file);

+        RLOGD("%s : vb close ,close rx file \n",__func__);

+        vbuf_rec.rx_file = NULL;

+        

+    }

 

     vb_close_fd_release_buf();

     return 0;

@@ -460,55 +472,55 @@
     char* buf = vbuf_rec.rx_buf;

     int size = vbuf_rec.buf_size;

 

-	//char* buf = vbuf_rec.tx_buf;

-	

+    //char* buf = vbuf_rec.tx_buf;

+    

     //int size = vbuf_rec.buf_size;

     int w_size;

     int r_size;

 

  

-    printf( "%s: start size=%d! \n",__func__,size);

+    RLOGD( "%s: start size=%d! \n",__func__,size);

     memset (buf,0, size);

     

     while (!vbuf_rec.quit) 

     {

-		rx_optcount ++;	

-		VB_INT_OVERFLOW(rx_optcount);

-		if((rx_optcount%1000) == 0){

-            printf("%s: rx_optcount=%d! \n",__func__,rx_optcount);

+        rx_optcount ++;    

+        VB_INT_OVERFLOW(rx_optcount);

+        if((rx_optcount%1000) == 0){

+            RLOGD("%s: rx_optcount=%d! \n",__func__,rx_optcount);

 

-		}

-		else if(rx_optcount == 1000000){

-            printf("%s: rx_optcount=%d! \n",__func__,rx_optcount);

-			rx_optcount = 0;

-			

-		}

+        }

+        else if(rx_optcount == 1000000){

+            RLOGD("%s: rx_optcount=%d! \n",__func__,rx_optcount);

+            rx_optcount = 0;

+            

+        }

 

         //read form ps

-		r_size = voice_buffer_read(vbuf_rec.fd, vbuf_rec.rx_buf, size);

+        r_size = voice_buffer_read(vbuf_rec.fd, vbuf_rec.rx_buf, size);

         if(r_size <= 0) 

         {

-            first_rderr_flag++;			

-			VB_INT_OVERFLOW(first_rderr_flag);			

+            first_rderr_flag++;            

+            VB_INT_OVERFLOW(first_rderr_flag);            

             continue ;

         }

-		else{

-			first_rderr_flag = 0;

-		}

+        else{

+            first_rderr_flag = 0;

+        }

         memcpy(vbuf_rec.tx_buf,vbuf_rec.rx_buf,size);

-		w_size = voice_buffer_write(vbuf_rec.fd, vbuf_rec.tx_buf, size);

+        w_size = voice_buffer_write(vbuf_rec.fd, vbuf_rec.tx_buf, size);

         if(w_size <= 0) 

         {

-        	first_wrerr_flag++;

-			

-			VB_INT_OVERFLOW(first_wrerr_flag);

-			

+            first_wrerr_flag++;

+            

+            VB_INT_OVERFLOW(first_wrerr_flag);

+            

             continue;

         }

-		else{

-			first_wrerr_flag = 0;

-		}

-		

+        else{

+            first_wrerr_flag = 0;

+        }

+        

     }

     

     return 0;

@@ -521,98 +533,98 @@
 {

     int ret = -1;

     int buf_size = 320;

-	tx_optcount = 0;

-	rx_optcount = 0;	

+    tx_optcount = 0;

+    rx_optcount = 0;    

     int* buf_int;

 

-	int i;

+    int i;

 

-	if(vbuffer_start_flag == 1){ 

-		printf(" VB already start,return \n");

+    if(vbuffer_start_flag == 1){ 

+        RLOGE(" VB already start,return \n");

 

-		return 0;

-	}

-

-	if((vbuf_rec.fd != -1)&&(vbuf_rec.fd != 0)){

-		printf(" VB fd already get, vbuf_rec.fd=%d return \n",vbuf_rec.fd);

-	}

-

-	vbuffer_start_flag = 1;

-

-	if(fs == 8000){

-

-		buf_size = 320;

-	}

-	else if(fs == 16000){

-

-		buf_size = 640;

-	}	

-	else

-	{

-		buf_size = 320;

-	}

- 	printf("Starting vb stream fs=%d buf_size=%d \n",fs,buf_size);

-

-    vbuf_rec.rx_buf = (char*) malloc(buf_size);

-	if(!vbuf_rec.rx_buf) {

-		printf("%s : malloc buf fail,return \n",__func__);

-		goto err;

-	}	

-    vbuf_rec.tx_buf = (char*) malloc(buf_size);  

-	if(!vbuf_rec.tx_buf) {		

-	   printf("%s : malloc buf fail,return \n",__func__);

-	   goto err;

-	}	

-	vbuf_rec.buf_size = buf_size;

-	

-    vbuf_rec.quit = 0;

-	

-	printf("%s : vb open start \n",__func__);

-

-	

-    vbuf_rec.fd = voice_buffer_open();

-	if(vbuf_rec.fd <= 0){

-		printf("%s : vb open fail fd=%d,return \n",__func__,vbuf_rec.fd);		

-		goto err;

-		

-	}	

-	printf("%s :loop vb_thread_create start \n",__func__);

-    ret = vb_thread_create ("vb_playback_test",&vbuf_rec.loop_test_thread, vb_loop_test_thread_func, 

-    							4*1024,35,NULL);

-    if (ret != 0)

-    {

-		printf("%s :rx vb_thread_create fail ret=%d,return \n",__func__,ret);    

-		goto err;

+        return 0;

     }

 

-	printf("%s :rx vb_thread_create end \n",__func__);

+    if((vbuf_rec.fd != -1)&&(vbuf_rec.fd != 0)){

+        RLOGE(" VB fd already get, vbuf_rec.fd=%d return \n",vbuf_rec.fd);

+    }

+

+    vbuffer_start_flag = 1;

+

+    if(fs == 8000){

+

+        buf_size = 320;

+    }

+    else if(fs == 16000){

+

+        buf_size = 640;

+    }    

+    else

+    {

+        buf_size = 320;

+    }

+     RLOGD("Starting vb stream fs=%d buf_size=%d \n",fs,buf_size);

+

+    vbuf_rec.rx_buf = (char*) malloc(buf_size);

+    if(!vbuf_rec.rx_buf) {

+        RLOGE("%s : malloc buf fail,return \n",__func__);

+        goto err;

+    }    

+    vbuf_rec.tx_buf = (char*) malloc(buf_size);  

+    if(!vbuf_rec.tx_buf) {        

+       RLOGE("%s : malloc buf fail,return \n",__func__);

+       goto err;

+    }    

+    vbuf_rec.buf_size = buf_size;

+    

+    vbuf_rec.quit = 0;

+    

+    RLOGD("%s : vb open start \n",__func__);

+

+    

+    vbuf_rec.fd = voice_buffer_open();

+    if(vbuf_rec.fd <= 0){

+        RLOGE("%s : vb open fail fd=%d,return \n",__func__,vbuf_rec.fd);        

+        goto err;

+        

+    }    

+    RLOGD("%s :loop vb_thread_create start \n",__func__);

+    ret = vb_thread_create ("vb_playback_test",&vbuf_rec.loop_test_thread, vb_loop_test_thread_func, 

+                                4*1024,35,NULL);

+    if (ret != 0)

+    {

+        RLOGE("%s :rx vb_thread_create fail ret=%d,return \n",__func__,ret);    

+        goto err;

+    }

+

+    RLOGD("%s :rx vb_thread_create end \n",__func__);

 

     return 0;

 

 err:

-	voice_buffer_stream_loop_test_stop();

-	

+    voice_buffer_stream_loop_test_stop();

+    

     return ret;

 }

 

 int voice_buffer_stream_loop_test_stop(void)

 {

     int ret = 0;

-	printf("%s:loop thread exit start \n",__func__);

-	if(vbuf_rec.quit == 1) {

-		printf("%s,already stop ,return\n",__func__);

+    RLOGD("%s:loop thread exit start \n",__func__);

+    if(vbuf_rec.quit == 1) {

+        RLOGD("%s,already stop ,return\n",__func__);

 

-	}

+    }

     

     vbuf_rec.quit = 1;

-	voice_buffer_stop(vbuf_rec.fd);

+    voice_buffer_stop(vbuf_rec.fd);

     if (vbuf_rec.loop_test_thread) 

     {

         pthread_join (vbuf_rec.loop_test_thread,NULL);

         vbuf_rec.tx_test_thread = NULL;

-		

+        

     }

-    	

+        

     vb_close_fd_release_buf();

     return 0;

 }

@@ -635,102 +647,110 @@
 void voice_buffer_cmd_proc(char *cmdstr)

 {

     int ret = 0;

-	char data[VOICE_CMD_MAX_LEN];

-	int cmdstr_len = strlen(cmdstr); //-strlen("\r")

+    char data[VOICE_CMD_MAX_LEN];

+    int cmdstr_len = strlen(cmdstr); //-strlen("\r")

     int value = 0;

     int *p_value = &value;

+

+    

     

     cmdstr[cmdstr_len] = '\0'; //+strlen("\0")

 

-	ret = sscanf(cmdstr, "%s", data);

+    ret = sscanf(cmdstr, "%s", data);

     if(1 != ret){

-        printf("data sscanf failed!(%d)\n", ret);

+        RLOGE("data sscanf failed!(%d)\n", ret);

         return;

     }

-	if(0 == strncmp(data, REQ_VOICE_BUFFER_TEST_START, strlen(REQ_VOICE_BUFFER_TEST_START))){

 

-		ret = sscanf(cmdstr, "%*s %d", &value);

+    pthread_mutex_lock(&s_vb_demo_mtx);

+    if(0 == strncmp(data, REQ_VOICE_BUFFER_TEST_START, strlen(REQ_VOICE_BUFFER_TEST_START))){

+

+        ret = sscanf(cmdstr, "%*s %d", &value);

         if(1 != ret){

-            printf("%s,value sscanf failed!(%d)\n",data, ret);

-            return;

+            RLOGE("%s,value sscanf failed!(%d)\n",data, ret);

+            goto vb_cmd_end;

         }

-		

-        printf("%s set value %d\n", data, value);

-		ret = voice_buffer_stream_test_start(value);

+        

+        RLOGD("%s set value %d\n", data, value);

+        ret = voice_buffer_stream_test_start(value);

 

-		printf("%s return ret=%d\n", data, ret);

-		

-	}

-	else if(0 == strncmp(data, REQ_VOICE_BUFFER_TEST_STOP, strlen(REQ_VOICE_BUFFER_TEST_STOP))){

-		ret = voice_buffer_stream_test_stop();

-		printf("%s return %d\n", data, ret);

-	}

-	else if(0 == strncmp(data, REQ_VOICE_BUFFER_LOOP_TEST_START, strlen(REQ_VOICE_BUFFER_LOOP_TEST_START))){

+        RLOGD("%s return ret=%d\n", data, ret);

+        

+    }

+    else if(0 == strncmp(data, REQ_VOICE_BUFFER_TEST_STOP, strlen(REQ_VOICE_BUFFER_TEST_STOP))){

+        ret = voice_buffer_stream_test_stop();

+        RLOGD("%s return %d\n", data, ret);

+    }

+    else if(0 == strncmp(data, REQ_VOICE_BUFFER_LOOP_TEST_START, strlen(REQ_VOICE_BUFFER_LOOP_TEST_START))){

 

-		ret = sscanf(cmdstr, "%*s %d", &value);

+        ret = sscanf(cmdstr, "%*s %d", &value);

         if(1 != ret){

-            printf("%s,value sscanf failed!(%d)\n",data, ret);

-            return;

+            RLOGE("%s,value sscanf failed!(%d)\n",data, ret);

+            goto vb_cmd_end;

         }

-		

-        printf("%s set value %d\n", data, value);

-		ret = voice_buffer_stream_loop_test_start(value);

+        

+        RLOGD("%s set value %d\n", data, value);

+        ret = voice_buffer_stream_loop_test_start(value);

 

-		printf("%s return ret=%d\n", data, ret);

-		

-	}

-	else if(0 == strncmp(data, REQ_VOICE_BUFFER_LOOP_TEST_STOP, strlen(REQ_VOICE_BUFFER_LOOP_TEST_STOP))){

-		printf("voice_buffer_stream_loop_test_stop \n");

-		ret = voice_buffer_stream_loop_test_stop();

-		printf("%s return %d\n", data, ret);

-	}

+        RLOGD("%s return ret=%d\n", data, ret);

+        

+    }

+    else if(0 == strncmp(data, REQ_VOICE_BUFFER_LOOP_TEST_STOP, strlen(REQ_VOICE_BUFFER_LOOP_TEST_STOP))){

+        RLOGD("voice_buffer_stream_loop_test_stop \n");

+        ret = voice_buffer_stream_loop_test_stop();

+        RLOGD("%s return %d\n", data, ret);

+    }

     else if(0 == strncmp(data, REQ_VOICE_BUFFER_RTP_TEST_START, strlen(REQ_VOICE_BUFFER_RTP_TEST_START))){

 

-		ret = sscanf(cmdstr, "%*s %d", &value);

+        ret = sscanf(cmdstr, "%*s %d", &value);

         if(1 != ret){

-            printf("%s,value sscanf failed!(%d)\n",data, ret);

-            return;

+            RLOGE("%s,value sscanf failed!(%d)\n",data, ret);

+            goto vb_cmd_end;

         }

-		

-        printf("%s set value %d\n", data, value);

-		ret = voice_buffer_rtp_test_start(value);

+        

+        RLOGD("%s set value %d\n", data, value);

+        ret = voice_buffer_rtp_test_start(value);

 

-		printf("%s return ret=%d\n", data, ret);

-		

-	}

-	else if(0 == strncmp(data, REQ_VOICE_BUFFER_RTP_TEST_STOP, strlen(REQ_VOICE_BUFFER_RTP_TEST_STOP))){

-		ret = voice_buffer_rtp_test_stop();

-		printf("%s return %d\n", data, ret);

-	}	

+        RLOGD("%s return ret=%d\n", data, ret);

+        

+    }

+    else if(0 == strncmp(data, REQ_VOICE_BUFFER_RTP_TEST_STOP, strlen(REQ_VOICE_BUFFER_RTP_TEST_STOP))){

+        ret = voice_buffer_rtp_test_stop();

+        RLOGD("%s return %d\n", data, ret);

+    }    

     else{

-		printf("Request unknow.\n");

+        RLOGE("Request unknow.\n");

         printUsage(cmdstr);

-	}

+    }

+vb_cmd_end:

+    pthread_mutex_unlock(&s_vb_demo_mtx);

 }

 

 void vb_buffer_stop_all()

 {

-	voice_buffer_stream_loop_test_stop();

+    voice_buffer_stream_loop_test_stop();

     voice_buffer_stream_test_stop();

     voice_buffer_rtp_test_stop();

 }

 

 void signal_handle_func(int sig)

 {

-	printf("sig(%d) signal_handle_func exit ",sig);

-    

+    RLOGD("sig(%d) signal_handle_func exit ",sig);

+

+    pthread_mutex_lock(&s_vb_demo_mtx);   

     vb_buffer_stop_all();

-	exit(0);

+    pthread_mutex_unlock(&s_vb_demo_mtx);

+    exit(0);

 }

 

 int main(int argc, char **argv)

 {

     char cmdstr[VOICE_CMD_MAX_LEN];

-	

-	signal(SIGINT, signal_handle_func);

-	signal(SIGQUIT, signal_handle_func);

-	signal(SIGTERM, signal_handle_func);

-	signal(SIGPIPE, signal_handle_func);

+    

+    signal(SIGINT, signal_handle_func);

+    signal(SIGQUIT, signal_handle_func);

+    signal(SIGTERM, signal_handle_func);

+    signal(SIGPIPE, signal_handle_func);

 

     memset(&vbuf_rec,0,sizeof(vbuf_rec));

 #if 0

@@ -743,27 +763,28 @@
     else

     {

 #endif

-        while(1){

-            printf("Please input an voice_demo command:\n");

+    printf("Please input an voice_demo command:\n");  

+        while(1){           

             if(NULL != fgets(cmdstr, VOICE_CMD_MAX_LEN - 1, stdin)){

                 if(0 == strcmp(EXIT_CMD_STOP, cmdstr) || 

                     0 == strcmp(EXIT_CMD_Q, cmdstr) || 

                     0 == strcmp(EXIT_CMD_EXIT, cmdstr)){

-					vb_buffer_stop_all();

-    				break;

-    			}

+                    vb_buffer_stop_all();

+                    break;

+                }

                 

-                printf("len:%d, cmdstr:%s\n", strlen(cmdstr), cmdstr);

+                RLOGI("len:%d, cmdstr:%s\n", strlen(cmdstr), cmdstr);

                 

                 if(1 >= strlen(cmdstr)){

-    				continue;

-    			}

-                voice_buffer_cmd_proc(cmdstr);

+                    continue;

+                }

+                voice_buffer_cmd_proc(cmdstr);               

             }         

-        }

-//    }    

+            sleep(5);                    

+      }

+    

 

-    printf("voice_demo end\n");

+    RLOGD("voice_demo end\n");

     

     return 0;

 }

diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-vb-demo/files/makefile b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-vb-demo/files/makefile
index 6a6f960..7117ebc 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-vb-demo/files/makefile
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-vb-demo/files/makefile
@@ -26,6 +26,7 @@
 LOCAL_LIBS := \
     -L. \
     -ldl \
+    -llog \
     -lpthread \
     -lvoice \
 
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-vb-demo/lynq-vb-demo.bb b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-vb-demo/lynq-vb-demo.bb
index b01d3b0..5691603 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-vb-demo/lynq-vb-demo.bb
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-vb-demo/lynq-vb-demo.bb
@@ -3,7 +3,7 @@
 DESCRIPTION = "lynq-vb-demo"
 LICENSE = "CLOSED"
 LIC_FILES_CHKSUM = "file://LICENSE;md5=b1e07e8d88e26263e71d3a9e2aa9a2ff"
-DEPENDS += "libvoice"
+DEPENDS += "libbinder libvoice"
 SRC_URI = "file://lynq_vb_demo.c \
            file://makefile \
 "