summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRavi Kumar Alamanda <ralama@codeaurora.org>2014-08-20 16:24:38 -0700
committerArne Coucheron <arco68@gmail.com>2016-05-11 00:12:20 +0200
commit01418bf407aad26338bf07ca6c02808ea77b9e06 (patch)
tree2303803ddc2284e4b2ed6ab74ba68fc0a6eee238
parenta9bb962e75d03ba538cfbf9cc5cc71875f47b316 (diff)
downloadhardware_qcom_audio-01418bf407aad26338bf07ca6c02808ea77b9e06.tar.gz
hardware_qcom_audio-01418bf407aad26338bf07ca6c02808ea77b9e06.tar.bz2
hardware_qcom_audio-01418bf407aad26338bf07ca6c02808ea77b9e06.zip
hal: avoid usage of extern functions and tables
If there is any difference in the signature of a function declared as extern, it will not be reported by the compiler and may result in unexpected results when executed. All the API functions should be declared in a header file. Change-Id: I89662e23da8118c3a9eac728b389498ed52e19c2
-rw-r--r--hal/audio_hw.h6
-rw-r--r--hal/voice.c12
-rw-r--r--hal/voice.h4
-rw-r--r--hal/voice_extn/voice_extn.c10
4 files changed, 17 insertions, 15 deletions
diff --git a/hal/audio_hw.h b/hal/audio_hw.h
index 370a90e2..f345cccc 100644
--- a/hal/audio_hw.h
+++ b/hal/audio_hw.h
@@ -58,7 +58,7 @@ typedef int snd_device_t;
* Each usecase is mapped to a specific PCM device.
* Refer to pcm_device_table[].
*/
-typedef enum {
+enum {
USECASE_INVALID = -1,
/* Playback usecases */
USECASE_AUDIO_PLAYBACK_DEEP_BUFFER = 0,
@@ -106,7 +106,9 @@ typedef enum {
USECASE_AUDIO_RECORD_AFE_PROXY,
AUDIO_USECASE_MAX
-} audio_usecase_t;
+};
+
+const char * const use_case_table[AUDIO_USECASE_MAX];
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
diff --git a/hal/voice.c b/hal/voice.c
index 17f04276..1082f54b 100644
--- a/hal/voice.c
+++ b/hal/voice.c
@@ -41,8 +41,6 @@ struct pcm_config pcm_config_voice_call = {
.format = PCM_FORMAT_S16_LE,
};
-extern const char * const use_case_table[AUDIO_USECASE_MAX];
-
static struct voice_session *voice_get_session_from_use_case(struct audio_device *adev,
audio_usecase_t usecase_id)
{
@@ -57,7 +55,7 @@ static struct voice_session *voice_get_session_from_use_case(struct audio_device
return session;
}
-int stop_call(struct audio_device *adev, audio_usecase_t usecase_id)
+int voice_stop_usecase(struct audio_device *adev, audio_usecase_t usecase_id)
{
int i, ret = 0;
struct audio_usecase *uc_info;
@@ -106,7 +104,7 @@ int stop_call(struct audio_device *adev, audio_usecase_t usecase_id)
return ret;
}
-int start_call(struct audio_device *adev, audio_usecase_t usecase_id)
+int voice_start_usecase(struct audio_device *adev, audio_usecase_t usecase_id)
{
int i, ret = 0;
struct audio_usecase *uc_info;
@@ -185,7 +183,7 @@ int start_call(struct audio_device *adev, audio_usecase_t usecase_id)
goto done;
error_start_voice:
- stop_call(adev, usecase_id);
+ voice_stop_usecase(adev, usecase_id);
done:
ALOGD("%s: exit: status(%d)", __func__, ret);
@@ -374,7 +372,7 @@ int voice_start_call(struct audio_device *adev)
ret = voice_extn_start_call(adev);
if (ret == -ENOSYS) {
- ret = start_call(adev, USECASE_VOICE_CALL);
+ ret = voice_start_usecase(adev, USECASE_VOICE_CALL);
}
adev->voice.in_call = true;
@@ -388,7 +386,7 @@ int voice_stop_call(struct audio_device *adev)
adev->voice.in_call = false;
ret = voice_extn_stop_call(adev);
if (ret == -ENOSYS) {
- ret = stop_call(adev, USECASE_VOICE_CALL);
+ ret = voice_stop_usecase(adev, USECASE_VOICE_CALL);
}
return ret;
diff --git a/hal/voice.h b/hal/voice.h
index 5d1ae407..95609b33 100644
--- a/hal/voice.h
+++ b/hal/voice.h
@@ -42,6 +42,7 @@ struct audio_device;
struct str_parms;
struct stream_in;
struct stream_out;
+typedef int audio_usecase_t;
struct call_state {
int current;
@@ -71,6 +72,9 @@ enum {
INCALL_REC_UPLINK_AND_DOWNLINK,
};
+int voice_start_usecase(struct audio_device *adev, audio_usecase_t usecase_id);
+int voice_stop_usecase(struct audio_device *adev, audio_usecase_t usecase_id);
+
int voice_start_call(struct audio_device *adev);
int voice_stop_call(struct audio_device *adev);
int voice_set_parameters(struct audio_device *adev, struct str_parms *parms);
diff --git a/hal/voice_extn/voice_extn.c b/hal/voice_extn/voice_extn.c
index b26a8241..c751c959 100644
--- a/hal/voice_extn/voice_extn.c
+++ b/hal/voice_extn/voice_extn.c
@@ -70,8 +70,6 @@ struct pcm_config pcm_config_incall_music = {
.avail_min = LOW_LATENCY_OUTPUT_PERIOD_SIZE / 4,
};
-extern int start_call(struct audio_device *adev, audio_usecase_t usecase_id);
-extern int stop_call(struct audio_device *adev, audio_usecase_t usecase_id);
int voice_extn_is_call_state_active(struct audio_device *adev, bool *is_call_active);
static bool is_valid_call_state(int call_state)
@@ -168,9 +166,9 @@ static int update_calls(struct audio_device *adev)
{
case CALL_INACTIVE:
ALOGD("%s: INACTIVE -> ACTIVE vsid:%x", __func__, session->vsid);
- ret = start_call(adev, usecase_id);
+ ret = voice_start_usecase(adev, usecase_id);
if(ret < 0) {
- ALOGE("%s: voice_start_call() failed for usecase: %d\n",
+ ALOGE("%s: voice_start_usecase() failed for usecase: %d\n",
__func__, usecase_id);
} else {
session->state.current = session->state.new;
@@ -208,9 +206,9 @@ static int update_calls(struct audio_device *adev)
case CALL_HOLD:
case CALL_LOCAL_HOLD:
ALOGD("%s: ACTIVE/HOLD/LOCAL_HOLD -> INACTIVE vsid:%x", __func__, session->vsid);
- ret = stop_call(adev, usecase_id);
+ ret = voice_stop_usecase(adev, usecase_id);
if(ret < 0) {
- ALOGE("%s: voice_end_call() failed for usecase: %d\n",
+ ALOGE("%s: voice_stop_usecase() failed for usecase: %d\n",
__func__, usecase_id);
} else {
session->state.current = session->state.new;