Fix code warning.
Change-Id: Ib11fb49f528d3688351ae349d5b4e307c28b3967
diff --git a/mbtk/libmbtk_lib/audio/mbtk_pcm_stream.c b/mbtk/libmbtk_lib/audio/mbtk_pcm_stream.c
index 213534b..82d28ce 100755
--- a/mbtk/libmbtk_lib/audio/mbtk_pcm_stream.c
+++ b/mbtk/libmbtk_lib/audio/mbtk_pcm_stream.c
@@ -3,6 +3,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
+#include <cutils/str_parms.h>
#include "mbtk_log.h"
#include "mbtk_audio_internal.h"
@@ -74,7 +75,7 @@
static void audio_recorder_thread(void *arg)
{
- int rc, len, frames = 0;
+ int len, frames = 0;
char buff[MBTK_PCM_WB_BUF_SIZE];
audio_info->info.recorder.state = AUDIO_RECORDER_STATE_RUNNING;
@@ -207,7 +208,7 @@
//printf("Direction is %d, Type is %d, Src_Dst is %d, Priority is %d, Dest is %d. \n",data[0], data[1], data[2], data[3], data[4]);
if (update_vcm) {
- configure_vcm(data); /*TODO check if all inputs got all values successfully*/
+ configure_vcm((unsigned int*)data); /*TODO check if all inputs got all values successfully*/
}
return 0;
@@ -587,7 +588,7 @@
};
static struct mopen_audio_t *internal_hdl = NULL;
-typedef int (*_play_callback)(int hdl, int result);
+typedef int (*_play_callback)(void *hdl, int result);
static int config_parameters_new(int in_out, int NBWB)
@@ -649,7 +650,7 @@
//printf("Direction is %d, Type is %d, Src_Dst is %d, Priority is %d, Dest is %d. \n",data[0], data[1], data[2], data[3], data[4]);
if (update_vcm) {
- configure_vcm(data); /*TODO check if all inputs got all values successfully*/
+ configure_vcm((unsigned int*)data); /*TODO check if all inputs got all values successfully*/
}
return 0;
@@ -677,6 +678,8 @@
} else if ((16000 == rate) && (1 == num_channels)) {
nb_wb = 1;//WB
pcxt->pcm_packet_size = 640;
+ } else {
+ return -1;
}
//config playback parameters.
@@ -689,7 +692,7 @@
{
struct mopen_audio_t *pcxt = (struct mopen_audio_t *)hdl;
if (NULL == hdl || NULL == internal_hdl)
- return 0;
+ return;
pthread_mutex_lock(&pcxt->_cond_mutex);
pcxt->state = _status;
pthread_mutex_unlock(&pcxt->_cond_mutex);
@@ -697,8 +700,6 @@
mbtk_audio_handle mbtk_audio_open_new(mbtk_audio_dev_enum dev, int flag, int rate, void *usrData)
{
-
- int value = 1;
struct mopen_audio_t *aud_hdl = NULL;
int ret;
@@ -750,7 +751,6 @@
return (void *)aud_hdl;
error:
- value = 0;
free(aud_hdl);
return NULL;
}
@@ -781,11 +781,6 @@
int res = 0;
int ret;
- char cmd[128] = {0};
- bool flay_flag = TRUE;
- int i = 0;
-
-
struct mopen_audio_t *pcxt = (struct mopen_audio_t *)dev_hdl;
_play_callback audio_play_cb = (_play_callback)pcxt->usrData;
if (NULL == dev_hdl || NULL == internal_hdl)
@@ -870,7 +865,6 @@
unsigned bufsize = 0;
char *data = NULL;
int first_set = 0;
- int res = 0;
int ret = 0;
int read_size = 0;
char *p = (char *)pData;
@@ -947,10 +941,11 @@
if(flay_flag && gain != 50)
{
sprintf(cmd, "ubus call audio_if config_dspgain \"{\'type\':1, \'gain\':%d}\"", gain);
- system(cmd);
-
- flay_flag = FALSE;
- usleep(80000);
+ ret = system(cmd);
+ if(ret != -1 && ret != 127) {
+ flay_flag = FALSE;
+ usleep(80000);
+ }
}
}
@@ -968,7 +963,6 @@
int mbtk_audio_close_new(void *dev_hdl)
{
LOGD("mbtk_audio_close()\n");
- int value = 0;
struct mopen_audio_t *_hdl = (struct mopen_audio_t *)dev_hdl;
if (NULL == _hdl || NULL == internal_hdl )
diff --git a/mbtk/libmbtk_lib/audio/mbtk_wav.c b/mbtk/libmbtk_lib/audio/mbtk_wav.c
index ac4bed8..403db74 100755
--- a/mbtk/libmbtk_lib/audio/mbtk_wav.c
+++ b/mbtk/libmbtk_lib/audio/mbtk_wav.c
@@ -3,6 +3,7 @@
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
+#include <stdlib.h>
#include "mbtk_log.h"
#include "mbtk_audio_internal.h"
@@ -122,7 +123,10 @@
recorder_header.data_sz = recorver_data_count;
recorder_header.riff_sz = recorder_header.data_sz + sizeof(recorder_header) - 8;
lseek(wav_recorder_fd, 0, SEEK_SET);
- write(wav_recorder_fd, &recorder_header, sizeof(struct wav_header));
+
+ if(sizeof(struct wav_header) == write(wav_recorder_fd, &recorder_header, sizeof(struct wav_header))) {
+ // Do nothting.
+ }
close(wav_recorder_fd);
wav_recorder_fd = -1;
@@ -177,7 +181,11 @@
return -1;
}
- read(wav_play_fd, &riff_wave_header, sizeof(riff_wave_header));
+ if(sizeof(riff_wave_header) != read(wav_play_fd, &riff_wave_header, sizeof(riff_wave_header))) {
+ LOGE("%s: read riff_wave_header fail.", __FUNCTION__);
+ return -1;
+ }
+
if ((riff_wave_header.riff_id != ID_RIFF) || (riff_wave_header.wave_id != ID_WAVE)) {
LOGE("Error: '%s' is not a riff/wave file", path);
close(wav_play_fd);
@@ -185,11 +193,17 @@
}
do {
- read(wav_play_fd, &chunk_header, sizeof(chunk_header));
+ if(sizeof(chunk_header) != read(wav_play_fd, &chunk_header, sizeof(chunk_header))) {
+ LOGE("%s: read chunk_header fail.", __FUNCTION__);
+ return -1;
+ }
switch (chunk_header.id) {
case ID_FMT:
- read(wav_play_fd, &chunk_fmt, sizeof(chunk_fmt));
+ if(sizeof(chunk_fmt) != read(wav_play_fd, &chunk_fmt, sizeof(chunk_fmt))) {
+ LOGE("%s: read chunk_fmt fail.", __FUNCTION__);
+ return -1;
+ }
/* If the format header is larger, skip the rest */
if (chunk_header.sz > sizeof(chunk_fmt))
lseek(wav_play_fd, chunk_header.sz - sizeof(chunk_fmt), SEEK_CUR);
@@ -353,7 +367,6 @@
int mbtk_audio_wav_recorder_start(const void *wav_file, mbtk_audio_sample_rate_enum sample_rate)
{
- int rc;
const char *path = (const char *)wav_file;
LOGD("wav_file is %s.", path);