int ril_set_call_volume(struct ril_handle *ril, enum ril_sound_type sound_type,
                        float volume)
{
    LOGD("%s: type=%d vol=%d", __func__, sound_type, (int)(volume * ril->volume_steps_max));
    if (ril_connect_if_required(ril))
        return 0;

    return _ril_set_call_volume(ril->client, sound_type,
                                (int)(volume * ril->volume_steps_max));
}
int audio_ril_interface_set_voice_volume(struct tinyalsa_audio_ril_interface *ril_interface,
	audio_devices_t device, float volume)
{
	int rc;

	enum ril_sound_type sound_type;

	if(ril_interface == NULL)
		return -1;

	ALOGD("%s(%d, %f)", __func__, device, volume);

	pthread_mutex_lock(&ril_interface->lock);

	/* Should this be returning -1 when a failure occurs? */
	if (audio_ril_interface_connect_if_required(ril_interface))
	  return 0;

	if(_ril_set_call_volume == NULL)
		goto error;

	switch((int) device) {
		case AUDIO_DEVICE_OUT_EARPIECE:
			sound_type = SOUND_TYPE_VOICE;
			break;
		case AUDIO_DEVICE_OUT_SPEAKER:
			sound_type = SOUND_TYPE_SPEAKER;
			break;
		case AUDIO_DEVICE_OUT_WIRED_HEADSET:
		case AUDIO_DEVICE_OUT_WIRED_HEADPHONE:
			sound_type = SOUND_TYPE_HEADSET;
			break;
		case AUDIO_DEVICE_OUT_BLUETOOTH_SCO:
		case AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET:
		case AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT:
		case AUDIO_DEVICE_OUT_BLUETOOTH_A2DP:
		case AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES:
		case AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER:
			sound_type = SOUND_TYPE_BTVOICE;
			break;
		default:
			sound_type = SOUND_TYPE_VOICE;
			break;
	}

	rc = _ril_set_call_volume(ril_interface->interface, sound_type,
				  (int)(volume * ril_interface->volume_steps_max));

	if(rc < 0) {
		ALOGE("Failed to set RIL interface voice volume");
		goto error;
	}

	pthread_mutex_unlock(&ril_interface->lock);

	return 0;

error:
	pthread_mutex_unlock(&ril_interface->lock);

	return -1;
}