summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher N. Hesse <raymanfx@gmail.com>2018-01-29 03:28:10 +0100
committerJan Altensen <info@stricted.net>2019-02-05 20:11:25 +0100
commit6a960023b977c4e5a7790e7309fe67708b49a2fd (patch)
treedeb8441f9a5718cf4e3ce57984945a1bc5c521b5
parentb8250d0f58d6356f66f4ea812f388f64a81e97c0 (diff)
downloadandroid_hardware_samsung-6a960023b977c4e5a7790e7309fe67708b49a2fd.tar.gz
android_hardware_samsung-6a960023b977c4e5a7790e7309fe67708b49a2fd.tar.bz2
android_hardware_samsung-6a960023b977c4e5a7790e7309fe67708b49a2fd.zip
audio: Directly link voice data <-> session
This is part of a cleanup series. In the future, we should reconsider the struct usage and (maybe?) move the members into one common place. Change-Id: I3218d75acb0c4965332ba0de30b40ca7821596a7
-rw-r--r--audio/audio_hw.h2
-rw-r--r--audio/voice.c20
-rw-r--r--audio/voice.h3
3 files changed, 8 insertions, 17 deletions
diff --git a/audio/audio_hw.h b/audio/audio_hw.h
index 4677f29..820d355 100644
--- a/audio/audio_hw.h
+++ b/audio/audio_hw.h
@@ -372,7 +372,7 @@ struct voice_data {
float volume;
bool bluetooth_nrec;
bool bluetooth_wb;
- void *session;
+ struct voice_session *session;
};
struct audio_device {
diff --git a/audio/voice.c b/audio/voice.c
index 5b5adf6..a4cc03a 100644
--- a/audio/voice.c
+++ b/audio/voice.c
@@ -38,17 +38,6 @@
#include "audience.h"
#endif
-/**
- * container_of - cast a member of a structure out to the containing structure
- * @ptr: the pointer to the member.
- * @type: the type of the container struct this is embedded in.
- * @member: the name of the member within the struct.
- *
- */
-#define container_of(ptr, type, member) ({ \
- void *__mptr = (void *)(ptr); \
- ((type *)((uintptr_t)__mptr - offsetof(type, member))); })
-
static struct pcm_config pcm_config_voicecall = {
.channels = 2,
.rate = 8000,
@@ -170,7 +159,6 @@ static void stop_voice_session_bt_sco(struct voice_session *session) {
void start_voice_session_bt_sco(struct voice_session *session)
{
struct pcm_config *voice_sco_config;
- struct voice_data *vdata = container_of(session, struct voice_data, session);
if (session->pcm_sco_rx != NULL || session->pcm_sco_tx != NULL) {
ALOGW("%s: SCO PCMs already open!\n", __func__);
@@ -179,7 +167,7 @@ void start_voice_session_bt_sco(struct voice_session *session)
ALOGV("%s: Opening SCO PCMs", __func__);
- if (vdata->bluetooth_wb) {
+ if (session->vdata->bluetooth_wb) {
ALOGV("%s: pcm_config wideband", __func__);
voice_sco_config = &pcm_config_voice_sco_wb;
} else {
@@ -383,10 +371,8 @@ bool voice_session_uses_twomic(struct voice_session *session)
bool voice_session_uses_wideband(struct voice_session *session)
{
- struct voice_data *vdata = container_of(session, struct voice_data, session);
-
if (session->out_device & AUDIO_DEVICE_OUT_ALL_SCO) {
- return vdata->bluetooth_wb;
+ return session->vdata->bluetooth_wb;
}
return session->wb_amr_type >= 1;
@@ -473,6 +459,8 @@ struct voice_session *voice_session_init(struct audio_device *adev)
}
}
+ session->vdata = &adev->voice;
+
return session;
}
diff --git a/audio/voice.h b/audio/voice.h
index 630221f..01c6aac 100644
--- a/audio/voice.h
+++ b/audio/voice.h
@@ -34,6 +34,9 @@ struct voice_session {
/* from uc_info */
audio_devices_t out_device;
+
+ /* parent container */
+ struct voice_data *vdata;
};
void prepare_voice_session(struct voice_session *session,