summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kocialkowski <contact@paulk.fr>2013-12-21 16:18:41 (GMT)
committerPaul Kocialkowski <contact@paulk.fr>2014-01-03 22:33:29 (GMT)
commiteed98830cd4def768d1d06b8208ee2daf2a16064 (patch)
treef0884ba2f789f107cb420e1b36e48d7f6c90325b
parent9e20b26f9510614ab9c65cbacaa2394f55349ca8 (diff)
downloaddevice_samsung_crespo-eed98830cd4def768d1d06b8208ee2daf2a16064.zip
device_samsung_crespo-eed98830cd4def768d1d06b8208ee2daf2a16064.tar.gz
device_samsung_crespo-eed98830cd4def768d1d06b8208ee2daf2a16064.tar.bz2
Audio-RIL-Interface
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
-rw-r--r--audio-ril-interface/Android.mk35
-rw-r--r--audio-ril-interface/audio-ril-interface.c193
-rw-r--r--device_base.mk3
-rw-r--r--libaudio/AudioHardware.cpp8
4 files changed, 234 insertions, 5 deletions
diff --git a/audio-ril-interface/Android.mk b/audio-ril-interface/Android.mk
new file mode 100644
index 0000000..77f5904
--- /dev/null
+++ b/audio-ril-interface/Android.mk
@@ -0,0 +1,35 @@
+#
+# Copyright (C) 2013 Paul Kocialkowski <contact@paulk.fr>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := audio-ril-interface.c
+
+LOCAL_C_INCLUDES := \
+ hardware/ril/samsung-ril/include \
+ hardware/ril/samsung-ril/srs-client/include \
+ device/samsung/crespo/libaudio/
+
+LOCAL_SHARED_LIBRARIES := liblog libcutils libsrs-client
+LOCAL_PRELINK_MODULE := false
+
+LOCAL_MODULE := libaudio-ril-interface
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/audio-ril-interface/audio-ril-interface.c b/audio-ril-interface/audio-ril-interface.c
new file mode 100644
index 0000000..1ab56fd
--- /dev/null
+++ b/audio-ril-interface/audio-ril-interface.c
@@ -0,0 +1,193 @@
+/*
+ * Copyright (C) 2013 Paul Kocialkowski <contact@paulk.fr>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdlib.h>
+
+#define LOG_TAG "Audio-RIL-Interface"
+#include <cutils/log.h>
+
+#include <secril-client.h>
+
+#include <samsung-ril-socket.h>
+#include <srs-client.h>
+
+HRilClient OpenClient_RILD(void)
+{
+ struct srs_client *client = NULL;
+
+ ALOGD("%s()", __func__);
+
+ signal(SIGPIPE, SIG_IGN);
+
+ srs_client_create(&client);
+
+ return (void *) client;
+}
+
+int Connect_RILD(HRilClient data)
+{
+ struct srs_client *client;
+ int rc;
+
+ ALOGD("%s(%p)", __func__, data);
+
+ if (data == NULL)
+ return RIL_CLIENT_ERR_INVAL;
+
+ client = (struct srs_client *) data;
+
+ rc = srs_client_open(client);
+ if (rc < 0) {
+ ALOGE("%s: Failed to open SRS client", __func__);
+ return RIL_CLIENT_ERR_CONNECT;
+ }
+
+ rc = srs_client_ping(client);
+ if (rc < 0) {
+ ALOGE("%s: Failed to ping SRS client", __func__);
+ return RIL_CLIENT_ERR_UNKNOWN;
+ }
+
+ return RIL_CLIENT_ERR_SUCCESS;
+}
+
+int Disconnect_RILD(HRilClient data)
+{
+ struct srs_client *client;
+ int rc;
+
+ ALOGD("%s(%p)", __func__, data);
+
+ if (data == NULL)
+ return RIL_CLIENT_ERR_INVAL;
+
+ client = (struct srs_client *) data;
+
+ rc = srs_client_close(client);
+ if (rc < 0) {
+ ALOGE("%s: Failed to close SRS client", __func__);
+ return RIL_CLIENT_ERR_INVAL;
+ }
+
+ return RIL_CLIENT_ERR_SUCCESS;
+}
+
+int CloseClient_RILD(HRilClient data)
+{
+ struct srs_client *client;
+ int rc;
+
+ ALOGD("%s(%p)", __func__, data);
+
+ if (data == NULL)
+ return RIL_CLIENT_ERR_INVAL;
+
+ client = (struct srs_client *) data;
+
+ srs_client_destroy(client);
+
+ return RIL_CLIENT_ERR_SUCCESS;
+}
+
+int isConnected_RILD(HRilClient data)
+{
+ struct srs_client *client;
+ int rc;
+
+ ALOGD("%s(%p)", __func__, data);
+
+ if (data == NULL)
+ return RIL_CLIENT_ERR_INVAL;
+
+ client = (struct srs_client *) data;
+
+ rc = srs_client_ping(client);
+ if (rc < 0) {
+ ALOGE("%s: Failed to ping SRS client", __func__);
+ return 0;
+ }
+
+ return 1;
+}
+
+int SetCallVolume(HRilClient data, SoundType type, int level)
+{
+ struct srs_client *client;
+ struct srs_snd_call_volume call_volume;
+ int rc;
+
+ ALOGD("%s(%p, %d, %d)", __func__, data, type, level);
+
+ if (data == NULL)
+ return RIL_CLIENT_ERR_INVAL;
+
+ client = (struct srs_client *) data;
+
+ call_volume.type = (enum srs_snd_type) type;
+ call_volume.volume = level;
+
+ rc = srs_client_send(client, SRS_SND_SET_CALL_VOLUME, &call_volume, sizeof(call_volume));
+ if (rc < 0)
+ return RIL_CLIENT_ERR_UNKNOWN;
+
+ return RIL_CLIENT_ERR_SUCCESS;
+}
+
+
+int SetCallAudioPath(HRilClient data, AudioPath path)
+{
+ struct srs_client *client;
+ struct srs_snd_call_audio_path call_audio_path;
+ int rc;
+
+ ALOGD("%s(%p, %d)", __func__, data, path);
+
+ if (data == NULL)
+ return RIL_CLIENT_ERR_INVAL;
+
+ client = (struct srs_client *) data;
+
+ call_audio_path.path = path;
+
+ rc = srs_client_send(client, SRS_SND_SET_CALL_AUDIO_PATH, &call_audio_path, sizeof(call_audio_path));
+ if (rc < 0)
+ return RIL_CLIENT_ERR_UNKNOWN;
+
+ return RIL_CLIENT_ERR_SUCCESS;
+}
+
+int SetCallClockSync(HRilClient data, SoundClockCondition condition)
+{
+ struct srs_client *client;
+ struct srs_snd_call_clock_sync call_clock_sync;
+ int rc;
+
+ ALOGD("%s(%p, %d)", __func__, data, condition);
+
+ if (data == NULL)
+ return RIL_CLIENT_ERR_INVAL;
+
+ client = (struct srs_client *) data;
+
+ call_clock_sync.sync = condition;
+
+ rc = srs_client_send(client, SRS_SND_SET_CALL_CLOCK_SYNC, &call_clock_sync, sizeof(call_clock_sync));
+ if (rc < 0)
+ return RIL_CLIENT_ERR_UNKNOWN;
+
+ return RIL_CLIENT_ERR_SUCCESS;
+}
diff --git a/device_base.mk b/device_base.mk
index dcd2c88..ee654ef 100644
--- a/device_base.mk
+++ b/device_base.mk
@@ -135,7 +135,8 @@ PRODUCT_PACKAGES += \
audio_policy.herring \
audio.primary.herring \
audio.a2dp.default \
- audio.usb.default
+ audio.usb.default \
+ libaudio-ril-interface
PRODUCT_COPY_FILES += \
device/samsung/crespo/libaudio/audio_policy.conf:system/etc/audio_policy.conf
diff --git a/libaudio/AudioHardware.cpp b/libaudio/AudioHardware.cpp
index 2169c60..1e2b9de 100644
--- a/libaudio/AudioHardware.cpp
+++ b/libaudio/AudioHardware.cpp
@@ -144,10 +144,10 @@ status_t AudioHardware::initCheck()
void AudioHardware::loadRILD(void)
{
- mSecRilLibHandle = dlopen("libsecril-client.so", RTLD_NOW);
+ mSecRilLibHandle = dlopen("libaudio-ril-interface.so", RTLD_NOW);
if (mSecRilLibHandle) {
- ALOGV("libsecril-client.so is loaded");
+ ALOGV("libaudio-ril-interface.so is loaded");
openClientRILD = (HRilClient (*)(void))
dlsym(mSecRilLibHandle, "OpenClient_RILD");
@@ -169,7 +169,7 @@ void AudioHardware::loadRILD(void)
if (!openClientRILD || !disconnectRILD || !closeClientRILD ||
!isConnectedRILD || !connectRILD ||
!setCallVolume || !setCallAudioPath || !setCallClockSync) {
- ALOGE("Can't load all functions from libsecril-client.so");
+ ALOGE("Can't load all functions from libaudio-ril-interface.so");
dlclose(mSecRilLibHandle);
mSecRilLibHandle = NULL;
@@ -183,7 +183,7 @@ void AudioHardware::loadRILD(void)
}
}
} else {
- ALOGE("Can't load libsecril-client.so");
+ ALOGE("Can't load libaudio-ril-interface.so");
}
}