audio: check for ril presence before calling into it
This prevents a seg fault if no ril is present.
Change-Id: I5f9443e31bdcab07df21d9f12ed2dd92807300f8
diff --git a/audio/audio_hw.c b/audio/audio_hw.c
index 3da3cee..02b8d33 100644
--- a/audio/audio_hw.c
+++ b/audio/audio_hw.c
@@ -267,8 +267,7 @@
int in_call;
/* RIL */
- void *ril_handle;
- void *ril_client;
+ struct ril_handle ril;
};
struct tuna_stream_out {
@@ -355,8 +354,8 @@
}
}
- ril_set_call_clock_sync(adev->ril_client, SOUND_CLOCK_START);
- ril_set_call_audio_path(adev->ril_client, SOUND_AUDIO_PATH_HANDSET);
+ ril_set_call_clock_sync(&adev->ril, SOUND_CLOCK_START);
+ ril_set_call_audio_path(&adev->ril, SOUND_AUDIO_PATH_HANDSET);
pcm_start(adev->pcm_modem_dl);
pcm_start(adev->pcm_modem_ul);
@@ -888,7 +887,7 @@
/* convert the float volume to something suitable for the RIL */
if (adev->in_call) {
int int_volume = (int)(volume * 5);
- ril_set_call_volume(adev->ril_client, SOUND_TYPE_VOICE, int_volume);
+ ril_set_call_volume(&adev->ril, SOUND_TYPE_VOICE, int_volume);
}
return 0;
@@ -1032,7 +1031,7 @@
struct tuna_audio_device *adev = (struct tuna_audio_device *)device;
/* RIL */
- ril_close(adev->ril_handle, adev->ril_client);
+ ril_close(&adev->ril);
mixer_close(adev->mixer);
free(device);
@@ -1127,7 +1126,7 @@
adev->pcm_modem_ul = NULL;
/* RIL */
- ril_open(&adev->ril_handle, &adev->ril_client);
+ ril_open(&adev->ril);
*device = &adev->device.common;