diff options
Diffstat (limited to 'audio_ril_interface.c')
-rw-r--r-- | audio_ril_interface.c | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/audio_ril_interface.c b/audio_ril_interface.c index d3a8658..0b4383d 100644 --- a/audio_ril_interface.c +++ b/audio_ril_interface.c @@ -42,16 +42,25 @@ int audio_ril_interface_set_mic_mute(struct tinyalsa_audio_ril_interface *ril_in LOGD("%s(%d)", __func__, state); + pthread_mutex_lock(&ril_interface->lock); + if(ril_interface->interface->mic_mute == NULL) - return -1; + goto error; rc = ril_interface->interface->mic_mute(ril_interface->interface->pdata, (int) state); if(rc < 0) { LOGE("Failed to set RIL interface mic mute"); - return -1; + goto error; } + pthread_mutex_unlock(&ril_interface->lock); + return 0; + +error: + pthread_mutex_unlock(&ril_interface->lock); + + return -1; } int audio_ril_interface_set_voice_volume(struct tinyalsa_audio_ril_interface *ril_interface, @@ -64,39 +73,57 @@ int audio_ril_interface_set_voice_volume(struct tinyalsa_audio_ril_interface *ri LOGD("%s(%d, %f)", __func__, device, volume); + pthread_mutex_lock(&ril_interface->lock); + if(ril_interface->interface->voice_volume == NULL) - return -1; + goto error; rc = ril_interface->interface->voice_volume(ril_interface->interface->pdata, device, volume); if(rc < 0) { LOGE("Failed to set RIL interface voice volume"); - return -1; + goto error; } + pthread_mutex_unlock(&ril_interface->lock); + return 0; + +error: + pthread_mutex_unlock(&ril_interface->lock); + + return -1; } int audio_ril_interface_set_route(struct tinyalsa_audio_ril_interface *ril_interface, audio_devices_t device) { int rc; + LOGD("%s(%d)", __func__, device); + if(ril_interface == NULL) return -1; - LOGD("%s(%d)", __func__, device); + pthread_mutex_lock(&ril_interface->lock); ril_interface->device_current = device; if(ril_interface->interface->route == NULL) - return -1; + goto error; rc = ril_interface->interface->route(ril_interface->interface->pdata, device); if(rc < 0) { LOGE("Failed to set RIL interface route"); - return -1; + goto error; } + pthread_mutex_unlock(&ril_interface->lock); + return 0; + +error: + pthread_mutex_unlock(&ril_interface->lock); + + return -1; } /* |