diff options
author | Linux Build Service Account <lnxbuild@localhost> | 2014-10-06 13:40:54 -0700 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2014-10-06 13:40:54 -0700 |
commit | 2914aeca9c9bfcdf35357794b7f2b9a73de25212 (patch) | |
tree | e307a06497e6a69db2b9d6cf9ec00ecaa9ff2da1 | |
parent | 1b390418e89f0ed95176cdb80c1538d66438294f (diff) | |
parent | a5f32b4246de447d88e1a14f3c202bc22f674fcc (diff) | |
download | android_hardware_qcom_audio-2914aeca9c9bfcdf35357794b7f2b9a73de25212.tar.gz android_hardware_qcom_audio-2914aeca9c9bfcdf35357794b7f2b9a73de25212.tar.bz2 android_hardware_qcom_audio-2914aeca9c9bfcdf35357794b7f2b9a73de25212.zip |
Merge "hal : fix miscellaneous errors"
-rw-r--r-- | hal/audio_extn/spkr_protection.c | 13 | ||||
-rw-r--r-- | hal/audio_hw.c | 11 |
2 files changed, 22 insertions, 2 deletions
diff --git a/hal/audio_extn/spkr_protection.c b/hal/audio_extn/spkr_protection.c index b6bb2c97..59b46fc3 100644 --- a/hal/audio_extn/spkr_protection.c +++ b/hal/audio_extn/spkr_protection.c @@ -339,6 +339,9 @@ static int spkr_calibrate(int t0) } } uc_info_rx = (struct audio_usecase *)calloc(1, sizeof(struct audio_usecase)); + if (!uc_info_rx) { + return -ENOMEM; + } uc_info_rx->id = USECASE_AUDIO_SPKR_CALIB_RX; uc_info_rx->type = PCM_PLAYBACK; uc_info_rx->in_snd_device = SND_DEVICE_NONE; @@ -368,6 +371,10 @@ static int spkr_calibrate(int t0) } uc_info_tx = (struct audio_usecase *) calloc(1, sizeof(struct audio_usecase)); + if (!uc_info_tx) { + status.status = -ENOMEM; + goto exit; + } uc_info_tx->id = USECASE_AUDIO_SPKR_CALIB_TX; uc_info_tx->type = PCM_CAPTURE; uc_info_tx->in_snd_device = SND_DEVICE_IN_CAPTURE_VI_FEEDBACK; @@ -812,6 +819,9 @@ int audio_extn_spkr_prot_start_processing(snd_device_t snd_device) snd_device = audio_extn_get_spkr_prot_snd_device(snd_device); spkr_prot_set_spkrstatus(true); uc_info_tx = (struct audio_usecase *)calloc(1, sizeof(struct audio_usecase)); + if (!uc_info_tx) { + return -ENOMEM; + } ALOGV("%s: snd_device(%d: %s)", __func__, snd_device, platform_get_snd_device_name(snd_device)); audio_route_apply_and_update_path(adev->audio_route, @@ -892,7 +902,8 @@ void audio_extn_spkr_prot_stop_processing(snd_device_t snd_device) } handle.spkr_processing_state = SPKR_PROCESSING_IN_IDLE; pthread_mutex_unlock(&handle.mutex_spkr_prot); - audio_route_reset_and_update_path(adev->audio_route, + if (adev) + audio_route_reset_and_update_path(adev->audio_route, platform_get_snd_device_name(snd_device)); ALOGV("%s: Exit", __func__); } diff --git a/hal/audio_hw.c b/hal/audio_hw.c index 6daa1d16..02441ba6 100644 --- a/hal/audio_hw.c +++ b/hal/audio_hw.c @@ -326,7 +326,7 @@ int disable_audio_route(struct audio_device *adev, snd_device_t snd_device; char mixer_path[MIXER_PATH_MAX_LENGTH]; - if (usecase == NULL) + if (usecase == NULL || usecase->id == USECASE_INVALID) return -EINVAL; ALOGV("%s: enter: usecase(%d)", __func__, usecase->id); @@ -1645,6 +1645,8 @@ static int out_set_parameters(struct audio_stream *stream, const char *kvpairs) ALOGD("%s: enter: usecase(%d: %s) kvpairs: %s", __func__, out->usecase, use_case_table[out->usecase], kvpairs); parms = str_parms_create_str(kvpairs); + if (!parms) + goto error; err = str_parms_get_str(parms, AUDIO_PARAMETER_STREAM_ROUTING, value, sizeof(value)); if (err >= 0) { val = atoi(value); @@ -1721,6 +1723,7 @@ static int out_set_parameters(struct audio_stream *stream, const char *kvpairs) } str_parms_destroy(parms); +error: ALOGV("%s: exit: code(%d)", __func__, ret); return ret; } @@ -2212,6 +2215,8 @@ static int in_set_parameters(struct audio_stream *stream, const char *kvpairs) ALOGD("%s: enter: kvpairs=%s", __func__, kvpairs); parms = str_parms_create_str(kvpairs); + if (!parms) + goto error; pthread_mutex_lock(&in->lock); pthread_mutex_lock(&adev->lock); @@ -2251,6 +2256,7 @@ done: pthread_mutex_unlock(&in->lock); str_parms_destroy(parms); +error: ALOGV("%s: exit: status(%d)", __func__, ret); return ret; } @@ -2738,6 +2744,8 @@ static int adev_set_parameters(struct audio_hw_device *dev, const char *kvpairs) ALOGD("%s: enter: %s", __func__, kvpairs); parms = str_parms_create_str(kvpairs); + if (!parms) + goto error; ret = str_parms_get_str(parms, "SND_CARD_STATUS", value, sizeof(value)); if (ret >= 0) { char *snd_card_status = value+2; @@ -2840,6 +2848,7 @@ static int adev_set_parameters(struct audio_hw_device *dev, const char *kvpairs) done: str_parms_destroy(parms); pthread_mutex_unlock(&adev->lock); +error: ALOGV("%s: exit with code(%d)", __func__, status); return status; } |