summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-x[-rw-r--r--]alsa-lib/include/config.h2
-rwxr-xr-x[-rw-r--r--]asound.conf66
-rwxr-xr-x[-rw-r--r--]libaudio/Android.mk31
-rwxr-xr-x[-rw-r--r--]libaudio/AudioHardwareALSA.cpp1013
-rwxr-xr-xlibaudio/AudioHardwareALSA.h224
-rwxr-xr-xlibaudio/secril-client.h298
-rw-r--r--libaudio/secril_stub.c49
7 files changed, 575 insertions, 1108 deletions
diff --git a/alsa-lib/include/config.h b/alsa-lib/include/config.h
index 52dfc11..e743490 100644..100755
--- a/alsa-lib/include/config.h
+++ b/alsa-lib/include/config.h
@@ -46,7 +46,7 @@
/* #undef BUILD_PCM_PLUGIN_MULAW */
/* Build PCM rate plugin */
-/* #undef BUILD_PCM_PLUGIN_RATE */
+#define BUILD_PCM_PLUGIN_RATE "1"
/* Build PCM route plugin */
/* #undef BUILD_PCM_PLUGIN_ROUTE */
diff --git a/asound.conf b/asound.conf
index 7d58718..a1c9119 100644..100755
--- a/asound.conf
+++ b/asound.conf
@@ -374,11 +374,7 @@ pcm.AndroidPlayback_Speaker_Headset_incall {
pcm.AndroidRecord {
type hooks
- slave.pcm {
- type hw
- card 0
- device 0 # Must be of type "digital audio capture"
- }
+ slave.pcm default
hooks.0 {
type ctl_elems
hook_args [
@@ -389,11 +385,7 @@ pcm.AndroidRecord {
pcm.AndroidRecord_Microphone {
type hooks
- slave.pcm {
- type hw
- card 0
- device 0 # Must be of type "digital audio capture"
- }
+ slave.pcm default
hooks.0 {
type ctl_elems
hook_args [
@@ -404,11 +396,7 @@ pcm.AndroidRecord_Microphone {
pcm.AndroidRecord_Earpiece_normal {
type hooks
- slave.pcm {
- type hw
- card 0
- device 0 # Must be of type "digital audio capture"
- }
+ slave.pcm default
hooks.0 {
type ctl_elems
hook_args [
@@ -419,11 +407,7 @@ pcm.AndroidRecord_Earpiece_normal {
pcm.AndroidRecord_Speaker_normal {
type hooks
- slave.pcm {
- type hw
- card 0
- device 0 # Must be of type "digital audio capture"
- }
+ slave.pcm default
hooks.0 {
type ctl_elems
hook_args [
@@ -434,11 +418,7 @@ pcm.AndroidRecord_Speaker_normal {
pcm.AndroidRecord_Headset_normal {
type hooks
- slave.pcm {
- type hw
- card 0
- device 0 # Must be of type "digital audio capture"
- }
+ slave.pcm default
hooks.0 {
type ctl_elems
hook_args [
@@ -464,11 +444,7 @@ pcm.AndroidRecord_Bluetooth_normal {
pcm.AndroidRecord_Speaker_Headset_normal {
type hooks
- slave.pcm {
- type hw
- card 0
- device 0 # Must be of type "digital audio capture"
- }
+ slave.pcm default
hooks.0 {
type ctl_elems
hook_args [
@@ -511,11 +487,7 @@ pcm.AndroidRecord_Headset_ringtone {
pcm.AndroidRecord_Earpiece_incall {
type hooks
- slave.pcm {
- type hw
- card 0
- device 0 # Must be of type "digital audio playback"
- }
+ slave.pcm default
hooks.0 {
type ctl_elems
hook_args [
@@ -527,11 +499,7 @@ pcm.AndroidRecord_Earpiece_incall {
pcm.AndroidRecord_Speaker_incall {
type hooks
- slave.pcm {
- type hw
- card 0
- device 0 # Must be of type "digital audio playback"
- }
+ slave.pcm default
hooks.0 {
type ctl_elems
hook_args [
@@ -543,11 +511,7 @@ pcm.AndroidRecord_Speaker_incall {
pcm.AndroidRecord_Headset_incall {
type hooks
- slave.pcm {
- type hw
- card 0
- device 0 # Must be of type "digital audio playback"
- }
+ slave.pcm default
hooks.0 {
type ctl_elems
hook_args [
@@ -559,11 +523,7 @@ pcm.AndroidRecord_Headset_incall {
pcm.AndroidRecord_Bluetooth_incall {
type hooks
- slave.pcm {
- type hw
- card 0
- device 0 # Must be of type "digital audio playback"
- }
+ slave.pcm default
hooks.0 {
type ctl_elems
hook_args [
@@ -575,11 +535,7 @@ pcm.AndroidRecord_Bluetooth_incall {
pcm.AndroidRecord_Speaker_Headset_incall {
type hooks
- slave.pcm {
- type hw
- card 0
- device 0 # Must be of type "digital audio playback"
- }
+ slave.pcm default
hooks.0 {
type ctl_elems
hook_args [
diff --git a/libaudio/Android.mk b/libaudio/Android.mk
index 0a93f7d..5d44ca7 100644..100755
--- a/libaudio/Android.mk
+++ b/libaudio/Android.mk
@@ -19,20 +19,6 @@ ifeq ($(BOARD_USES_GENERIC_AUDIO),false)
LOCAL_CFLAGS += -DALSA_DEFAULT_SAMPLE_RATE=$(ALSA_DEFAULT_SAMPLE_RATE)
endif
-# Samsung Feature
-ifeq ($(TARGET_BOARD_PLATFORM),s5pc110)
- LOCAL_CFLAGS += -DSLSI_S5PC110
-
-# Samsung Driver Feature
-# LOCAL_CFLAGS += -DSEC_SWP_SOUND -DSEC_IPC -DPOWER_GATING -DSYNCHRONIZE_CP -DBT_NR_EC_ONOFF
- LOCAL_CFLAGS += -DSEC_SWP_SOUND -DSEC_IPC
- LOCAL_CFLAGS += -DTURN_ON_DEVICE_ONLY_USE
-endif
-
-ifeq ($(TARGET_BOARD_PLATFORM),s5pc100)
- LOCAL_CFLAGS += -DSLSI_S5PC100
-endif
-
LOCAL_C_INCLUDES += device/samsung/crespo/alsa-lib/include
LOCAL_SRC_FILES := AudioHardwareALSA.cpp
@@ -52,14 +38,6 @@ ifeq ($(BOARD_HAVE_BLUETOOTH),true)
LOCAL_SHARED_LIBRARIES += liba2dp
endif
-ifneq ($(NO_IPC_ALSA_RILD),true)
-ifeq ($(BOARD_USES_LIBSECRIL_STUB),true)
- LOCAL_SHARED_LIBRARIES += libsecril-client-stub
-else
- LOCAL_SHARED_LIBRARIES += libsecril-client
-endif
- LOCAL_CFLAGS += -DIPC_ALSA_RILD
-endif
include $(BUILD_SHARED_LIBRARY)
# To build audiopolicy library
@@ -83,15 +61,6 @@ endif
include $(BUILD_SHARED_LIBRARY)
-ifeq ($(BOARD_USES_LIBSECRIL_STUB),true)
-# A stub to replace libsecril-client at build time
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := secril_stub.c
-LOCAL_MODULE := libsecril-client-stub
-LOCAL_MODULE_TAGS := optional
-include $(BUILD_SHARED_LIBRARY)
-endif
-
endif
endif
endif
diff --git a/libaudio/AudioHardwareALSA.cpp b/libaudio/AudioHardwareALSA.cpp
index 52d0418..f1b23f8 100644..100755
--- a/libaudio/AudioHardwareALSA.cpp
+++ b/libaudio/AudioHardwareALSA.cpp
@@ -34,13 +34,10 @@
#include <alsa/asoundlib.h>
#include "AudioHardwareALSA.h"
-#define READ_FRAME_SIZE 2080
-#define READ_FRAME_SIZE_STANDARD 4160
+// #define READ_FRAME_SIZE 2080
+// #define READ_FRAME_SIZE_STANDARD 4160
-#if defined SEC_IPC
-// sangsu fix : headers for IPC
-#include <telephony/ril.h>
-#endif
+#include <dlfcn.h>
#define SND_MIXER_VOL_RANGE_MIN (0)
#define SND_MIXER_VOL_RANGE_MAX (100)
@@ -51,21 +48,6 @@
if (strlen(x) + strlen(y) < ALSA_NAME_MAX) \
strcat(x, y);
-
-// If you want to dump PCM data, activate this feature
-//#define PCM_INPUT_DUMP
-//#define PCM_OUTPUT_DUMP
-
-#ifdef PCM_INPUT_DUMP
-#define PCM_INPUT_DUMP_PATH "/data/Read_PCM_Dump.dat"
-FILE *fpInput = NULL ;
-#endif
-
-#ifdef PCM_OUTPUT_DUMP
-#define PCM_OUTPUT_DUMP_PATH "/data/Write_PCM_Dump.dat"
-FILE *fpOutput = NULL ;
-#endif
-
extern "C"
{
extern int ffs(int i);
@@ -90,20 +72,11 @@ extern "C"
namespace android
{
-#if 0
-typedef AudioSystem::audio_routes audio_routes;
-#define ROUTE_ALL AudioSystem::ROUTE_ALL
-#define ROUTE_EARPIECE AudioSystem::ROUTE_EARPIECE
-#define ROUTE_SPEAKER AudioSystem::ROUTE_SPEAKER
-#define ROUTE_BLUETOOTH_SCO AudioSystem::ROUTE_BLUETOOTH_SCO
-#define ROUTE_HEADSET AudioSystem::ROUTE_HEADSET
-#define ROUTE_BLUETOOTH_A2DP AudioSystem::ROUTE_BLUETOOTH_A2DP
-#elif defined SEC_SWP_SOUND
typedef AudioSystem::audio_devices audio_routes;
#define ROUTE_ALL AudioSystem::DEVICE_OUT_ALL
#define ROUTE_EARPIECE AudioSystem::DEVICE_OUT_EARPIECE
#define ROUTE_HEADSET AudioSystem::DEVICE_OUT_WIRED_HEADSET
-#define ROUTE_HEADPHONE AudioSystem::DEVICE_OUT_WIRED_HEADPHONE
+#define ROUTE_HEADPHONE AudioSystem::DEVICE_OUT_WIRED_HEADPHONE
#define ROUTE_SPEAKER AudioSystem::DEVICE_OUT_SPEAKER
#define ROUTE_BLUETOOTH_SCO AudioSystem::DEVICE_OUT_BLUETOOTH_SCO
#define ROUTE_BLUETOOTH_SCO_HEADSET AudioSystem::DEVICE_OUT_BLUETOOTH_SCO_HEADSET
@@ -111,15 +84,7 @@ typedef AudioSystem::audio_devices audio_routes;
#define ROUTE_BLUETOOTH_A2DP AudioSystem::DEVICE_OUT_BLUETOOTH_A2DP
#define ROUTE_BLUETOOTH_A2DP_HEADPHONES AudioSystem::DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES
#define ROUTE_BLUETOOTH_A2DP_SPEAKER AudioSystem::DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER
-#else
-typedef AudioSystem::audio_devices audio_routes;
-#define ROUTE_ALL AudioSystem::DEVICE_OUT_ALL
-#define ROUTE_EARPIECE AudioSystem::DEVICE_OUT_EARPIECE
-#define ROUTE_SPEAKER AudioSystem::DEVICE_OUT_SPEAKER
-#define ROUTE_BLUETOOTH_SCO AudioSystem::DEVICE_OUT_BLUETOOTH_SCO
-#define ROUTE_HEADSET AudioSystem::DEVICE_OUT_WIRED_HEADSET
-#define ROUTE_BLUETOOTH_A2DP AudioSystem::DEVICE_OUT_BLUETOOTH_A2DP
-#endif
+
// ----------------------------------------------------------------------------
@@ -148,46 +113,36 @@ static void ALSAErrorHandler(const char *file,
/* The following table(s) need to match in order of the route bits
*/
-#if defined SEC_SWP_SOUND
-static const char *deviceSuffix[] = {
- // output devices
- /* ROUTE_EARPIECE */ "_Earpiece",
- /* ROUTE_SPEAKER */ "_Speaker",
- /* ROUTE_HEADSET */ "_Headset",
- /* ROUTE_HEADPHONE */ "_Headset",
- /* ROUTE_BLUETOOTH_SCO */ "_Bluetooth",
- /* ROUTE_BLUETOOTH_SCO_HEADSET */ "_Bluetooth",
- /* ROUTE_BLUETOOTH_SCO_CARKIT */ "_Bluetooth", //"_Bluetooth_Carkit"
- /* ROUTE_BLUETOOTH_A2DP */ "_Bluetooth", //"_Bluetooth-A2DP"
- /* ROUTE_BLUETOOTH_A2DP_HEADPHONES */ "_Bluetooth", //"_Bluetooth-A2DP_HeadPhone"
- /* ROUTE_BLUETOOTH_A2DP_SPEAKER */ "_Bluetooth", // "_Bluetooth-A2DP_Speaker"
- /* ROUTE_AUX_DIGITAL */ "_AuxDigital",
- /* ROUTE_TV_OUT */ "_TvOut",
- /* ROUTE_AUX_DIGITAL */ "_ExtraDockSpeaker",
- /* ROUTE_NULL */ "_Null",
- /* ROUTE_NULL */ "_Null",
- /* ROUTE_DEFAULT */ "_OutDefault",
-
- // input devices
- /* ROUTE_COMMUNICATION */ "_Communication",
- /* ROUTE_AMBIENT */ "_Ambient",
- /* ROUTE_BUILTIN_MIC */ "_Speaker",
- /* ROUTE_BLUETOOTH_SCO_HEADSET */ "_Bluetooth",
- /* ROUTE_WIRED_HEADSET */ "_Headset",
- /* ROUTE_AUX_DIGITAL */ "_AuxDigital",
- /* ROUTE_VOICE_CALL */ "_VoiceCall",
- /* ROUTE_BACK_MIC */ "_BackMic",
- /* ROUTE_IN_DEFAULT */ "_InDefault",
-};
-#else
static const char *deviceSuffix[] = {
+ // output devices
/* ROUTE_EARPIECE */ "_Earpiece",
/* ROUTE_SPEAKER */ "_Speaker",
- /* ROUTE_BLUETOOTH_SCO */ "_Bluetooth",
/* ROUTE_HEADSET */ "_Headset",
- /* ROUTE_BLUETOOTH_A2DP */ "_Bluetooth-A2DP",
+ /* ROUTE_HEADPHONE */ "_Headset",
+ /* ROUTE_BLUETOOTH_SCO */ "_Bluetooth",
+ /* ROUTE_BLUETOOTH_SCO_HEADSET */ "_Bluetooth",
+ /* ROUTE_BLUETOOTH_SCO_CARKIT */ "_Bluetooth", //"_Bluetooth_Carkit"
+ /* ROUTE_BLUETOOTH_A2DP */ "_Bluetooth", //"_Bluetooth-A2DP"
+ /* ROUTE_BLUETOOTH_A2DP_HEADPHONES */ "_Bluetooth", //"_Bluetooth-A2DP_HeadPhone"
+ /* ROUTE_BLUETOOTH_A2DP_SPEAKER */ "_Bluetooth", // "_Bluetooth-A2DP_Speaker"
+ /* ROUTE_AUX_DIGITAL */ "_AuxDigital",
+ /* ROUTE_TV_OUT */ "_TvOut",
+ /* ROUTE_AUX_DIGITAL */ "_ExtraDockSpeaker",
+ /* ROUTE_NULL */ "_Null",
+ /* ROUTE_NULL */ "_Null",
+ /* ROUTE_DEFAULT */ "_OutDefault",
+
+ // input devices
+ /* ROUTE_COMMUNICATION */ "_Communication",
+ /* ROUTE_AMBIENT */ "_Ambient",
+ /* ROUTE_BUILTIN_MIC */ "_Speaker",
+ /* ROUTE_BLUETOOTH_SCO_HEADSET */ "_Bluetooth",
+ /* ROUTE_WIRED_HEADSET */ "_Headset",
+ /* ROUTE_AUX_DIGITAL */ "_AuxDigital",
+ /* ROUTE_VOICE_CALL */ "_VoiceCall",
+ /* ROUTE_BACK_MIC */ "_BackMic",
+ /* ROUTE_IN_DEFAULT */ "_InDefault",
};
-#endif
static const int deviceSuffixLen = (sizeof(deviceSuffix) / sizeof(char *));
@@ -251,23 +206,14 @@ const uint32_t AudioHardwareALSA::inputSamplingRates[] = {
AudioHardwareALSA::AudioHardwareALSA() :
mOutput(0),
- mInput(0)
-#if defined SEC_IPC
- ,mIPC(0) //for IPC
-#endif
-#if defined TURN_ON_DEVICE_ONLY_USE
- ,mActivatedInputDevice(false)
-#endif
-#if defined SYNCHRONIZE_CP
- ,mActivatedCP(false)
-#endif
-
+ mInput(0),
+ mSecRilLibHandle(NULL),
+ mRilClient(0)
{
snd_lib_error_set_handler(&ALSAErrorHandler);
mMixer = new ALSAMixer;
-#if defined SEC_IPC
- mIPC = new AudioHardwareIPC; // IPC init
-#endif
+
+ loadRILD();
}
AudioHardwareALSA::~AudioHardwareALSA()
@@ -275,11 +221,66 @@ AudioHardwareALSA::~AudioHardwareALSA()
if (mOutput) delete mOutput;
if (mInput) delete mInput;
if (mMixer) delete mMixer;
-#if defined SEC_IPC
- if (mIPC) delete mIPC; // for IPC
-#endif
+
+ if (mSecRilLibHandle) {
+ if (disconnectRILD(mRilClient) != RIL_CLIENT_ERR_SUCCESS)
+ LOGE("Disconnect_RILD() error");
+
+ if (closeClientRILD(mRilClient) != RIL_CLIENT_ERR_SUCCESS)
+ LOGE("CloseClient_RILD() error");
+
+ mRilClient = 0;
+
+ dlclose(mSecRilLibHandle);
+ mSecRilLibHandle = NULL;
+ }
}
+
+void AudioHardwareALSA::loadRILD(void)
+{
+ mSecRilLibHandle = dlopen("libsecril-client.so", RTLD_NOW);
+
+ if (mSecRilLibHandle) {
+ LOGV("libsecril-client.so is loaded");
+
+ openClientRILD = (HRilClient (*)(void))
+ dlsym(mSecRilLibHandle, "OpenClient_RILD");
+ disconnectRILD = (int (*)(HRilClient))
+ dlsym(mSecRilLibHandle, "Disconnect_RILD");
+ closeClientRILD = (int (*)(HRilClient))
+ dlsym(mSecRilLibHandle, "CloseClient_RILD");
+ isConnectedRILD = (int (*)(HRilClient))
+ dlsym(mSecRilLibHandle, "isConnected_RILD");
+ connectRILD = (int (*)(HRilClient))
+ dlsym(mSecRilLibHandle, "Connect_RILD");
+ setCallVolume = (int (*)(HRilClient, SoundType, int))
+ dlsym(mSecRilLibHandle, "SetCallVolume");
+ setCallAudioPath = (int (*)(HRilClient, AudioPath))
+ dlsym(mSecRilLibHandle, "SetCallAudioPath");
+
+ if (!openClientRILD || !disconnectRILD || !closeClientRILD ||
+ !isConnectedRILD || !connectRILD ||
+ !setCallVolume || !setCallAudioPath) {
+ LOGE("Can't load all functions from libsecril-client.so");
+
+ dlclose(mSecRilLibHandle);
+ mSecRilLibHandle = NULL;
+ } else {
+ mRilClient = openClientRILD();
+ if (!mRilClient) {
+ LOGE("OpenClient_RILD() error");
+
+ dlclose(mSecRilLibHandle);
+ mSecRilLibHandle = NULL;
+ }
+ }
+ } else {
+ LOGE("Can't load libsecril-client.so");
+ }
+}
+
+
status_t AudioHardwareALSA::initCheck()
{
if (mMixer && mMixer->isValid())
@@ -296,48 +297,70 @@ status_t AudioHardwareALSA::standby()
return NO_ERROR;
}
+
+status_t AudioHardwareALSA::connectRILDIfRequired(void)
+{
+ if (!mSecRilLibHandle) {
+ LOGE("connectIfRequired() lib is not loaded");
+ return INVALID_OPERATION;
+ }
+
+ if (isConnectedRILD(mRilClient) == 0) {
+ return OK;
+ }
+
+ if (connectRILD(mRilClient) != RIL_CLIENT_ERR_SUCCESS) {
+ LOGE("Connect_RILD() error");
+ return INVALID_OPERATION;
+ }
+
+ return OK;
+}
+
+
status_t AudioHardwareALSA::setVoiceVolume(float volume)
{
- LOGI("### setVoiceVolume");
-#if defined SEC_IPC
+ LOGI("### setVoiceVolume");
+
// sangsu fix : transmic volume level IPC to modem
- if (AudioSystem::MODE_IN_CALL == mMode)
- {
- uint32_t routes = mRoutes[mMode];
-
- LOGI("### route(%d) call volume(%f)", routes, volume);
- switch (routes){
- case AudioSystem::ROUTE_EARPIECE:
- case AudioSystem::ROUTE_HEADPHONE: // Use receive path with 3 pole headset.
- LOGI("### earpiece call volume");
- mIPC->transmitVolumeIPC(OEM_SOUND_TYPE_VOICE, volume);
- break;
-
- case AudioSystem::ROUTE_SPEAKER:
- LOGI("### speaker call volume");
- mIPC->transmitVolumeIPC(OEM_SOUND_TYPE_SPEAKER, volume);
- break;
-
- case AudioSystem::ROUTE_BLUETOOTH_SCO:
- case AudioSystem::DEVICE_OUT_BLUETOOTH_SCO_HEADSET:
- case AudioSystem::DEVICE_OUT_BLUETOOTH_SCO_CARKIT:
- case AudioSystem::ROUTE_BLUETOOTH_A2DP:
- LOGI("### bluetooth call volume");
- mIPC->transmitVolumeIPC(OEM_SOUND_TYPE_BTVOICE, volume);
- break;
-
- case AudioSystem::ROUTE_HEADSET:
- LOGI("### headset call volume");
- mIPC->transmitVolumeIPC(OEM_SOUND_TYPE_HEADSET, volume);
- break;
-
- default:
- LOGE("### Call volume setting error!!!0x%08x \n", routes);
- break;
- }
- }
- // sangsu fix end
-#endif
+ if ( (AudioSystem::MODE_IN_CALL == mMode) && (mSecRilLibHandle) &&
+ (connectRILDIfRequired() == OK) ) {
+
+ uint32_t routes = mRoutes[mMode];
+ int int_volume = (int)(volume * 5);
+
+ LOGI("### route(%d) call volume(%f)", routes, volume);
+ switch (routes) {
+ case AudioSystem::ROUTE_EARPIECE:
+ case AudioSystem::ROUTE_HEADPHONE: // Use receive path with 3 pole headset.
+ LOGI("### earpiece call volume");
+ setCallVolume(mRilClient, SOUND_TYPE_VOICE, int_volume);
+ break;
+
+ case AudioSystem::ROUTE_SPEAKER:
+ LOGI("### speaker call volume");
+ setCallVolume(mRilClient, SOUND_TYPE_SPEAKER, int_volume);
+ break;
+
+ case AudioSystem::ROUTE_BLUETOOTH_SCO:
+ case AudioSystem::DEVICE_OUT_BLUETOOTH_SCO_HEADSET:
+ case AudioSystem::DEVICE_OUT_BLUETOOTH_SCO_CARKIT:
+ case AudioSystem::ROUTE_BLUETOOTH_A2DP:
+ LOGI("### bluetooth call volume");
+ setCallVolume(mRilClient, SOUND_TYPE_BTVOICE, int_volume);
+ break;
+
+ case AudioSystem::ROUTE_HEADSET:
+ LOGI("### headset call volume");
+ setCallVolume(mRilClient, SOUND_TYPE_HEADSET, int_volume);
+ break;
+
+ default:
+ LOGE("### Call volume setting error!!!0x%08x \n", routes);
+ break;
+ }
+ }
+ // sangsu fix end
// The voice volume is used by the VOICE_CALL audio stream.
if (mMixer)
@@ -354,34 +377,23 @@ status_t AudioHardwareALSA::setMasterVolume(float volume)
return INVALID_OPERATION;
}
-#if defined TURN_ON_DEVICE_ONLY_USE
int AudioHardwareALSA::setMicStatus(int on)
{
- LOGI("[%s], on=%d", __func__, on);
- ALSAControl *mALSAControl = new ALSAControl();
- status_t ret = mALSAControl->set("Mic Status", on);
- delete mALSAControl;
- return NO_ERROR;
+ LOGI("[%s], on=%d", __func__, on);
+ ALSAControl *mALSAControl = new ALSAControl();
+ status_t ret = mALSAControl->set("Mic Status", on);
+ delete mALSAControl;
+ return NO_ERROR;
}
-#endif
-#if 0
-AudioStreamOut *
-AudioHardwareALSA::AudioStreamOut* openOutputStream(
- int format=0,
- int channelCount=0,
- uint32_t sampleRate=0,
- status_t *status=0)
-#else
AudioStreamOut *
AudioHardwareALSA::openOutputStream(
- uint32_t devices,
- int *format,
- uint32_t *channels,
- uint32_t *sampleRate,
- status_t *status)
-#endif
+ uint32_t devices,
+ int *format,
+ uint32_t *channels,
+ uint32_t *sampleRate,
+ status_t *status)
{
AutoMutex lock(mLock);
@@ -397,25 +409,13 @@ AudioHardwareALSA::openOutputStream(
*status = out->set(format, channels, sampleRate);
-#ifdef PCM_OUTPUT_DUMP
- if(fpOutput == NULL)
- {
- fpOutput = fopen(PCM_OUTPUT_DUMP_PATH, "w");
- if (fpOutput == NULL)
- LOGE("fpOutput File Open Error!!");
- }
-#endif
-
if (*status == NO_ERROR) {
mOutput = out;
// Some information is expected to be available immediately after
// the device is open.
/* Tushar - Sets the current device output here - we may set device here */
- //uint32_t routes = mRoutes[mMode];
- //mOutput->setDevice(mMode, routes);
- LOGI("%s] Setting ALSA device.", __func__);
+ LOGI("%s] Setting ALSA device.", __func__);
mOutput->setDevice(mMode, devices, PLAYBACK); /* tushar - Enable all devices as of now */
- mOutput->setWakeLock();
}
else {
delete out;
@@ -427,15 +427,10 @@ AudioHardwareALSA::openOutputStream(
void
AudioHardwareALSA::closeOutputStream(AudioStreamOut* out)
{
- /* TODO:Tushar: May lead to segmentation fault - check*/
- //delete out;
+ /* TODO:Tushar: May lead to segmentation fault - check*/
+ //delete out;
AutoMutex lock(mLock);
-#ifdef PCM_OUTPUT_DUMP
- fclose(fpOutput);
- fpOutput = NULL;
-#endif
-
if (mOutput == 0 || mOutput != out) {
LOGW("Attempt to close invalid output stream");
}
@@ -446,14 +441,7 @@ AudioHardwareALSA::closeOutputStream(AudioStreamOut* out)
}
-#if 0
-AudioStreamIn *
-AudioHardwareALSA::openInputStream(int format,
- int channelCount,
- uint32_t sampleRate,
- status_t *status,
- AudioSystem::audio_in_acoustics acoustics)
-#else
+
AudioStreamIn*
AudioHardwareALSA::openInputStream(
uint32_t devices,
@@ -462,7 +450,6 @@ AudioHardwareALSA::openInputStream(
uint32_t *sampleRate,
status_t *status,
AudioSystem::audio_in_acoustics acoustics)
-#endif
{
AutoMutex lock(mLock);
@@ -479,23 +466,8 @@ AudioHardwareALSA::openInputStream(
mInput = in;
// Some information is expected to be available immediately after
// the device is open.
- //uint32_t routes = mRoutes[mMode];
- //mInput->setDevice(mMode, routes);
mInput->setDevice(mMode, devices, CAPTURE); /* Tushar - as per modified arch */
- mInput->setWakeLock();
-#if defined TURN_ON_DEVICE_ONLY_USE
- mActivatedInputDevice = true;
setMicStatus(1);
-#endif
-#ifdef PCM_INPUT_DUMP
- if(fpInput == NULL)
- {
- fpInput = fopen(PCM_INPUT_DUMP_PATH, "w");
- if (fpInput == NULL)
- LOGE("fpInput File Open Error!!");
- }
-#endif
-
return mInput;
}
else {
@@ -507,147 +479,81 @@ AudioHardwareALSA::openInputStream(
void
AudioHardwareALSA::closeInputStream(AudioStreamIn* in)
{
- /* TODO:Tushar: May lead to segmentation fault - check*/
- //delete in;
- AutoMutex lock(mLock);
+ /* TODO:Tushar: May lead to segmentation fault - check*/
+ //delete in;
+ AutoMutex lock(mLock);
if (mInput == 0 || mInput != in) {
LOGW("Attempt to close invalid input stream");
- }
- else {
+ } else {
delete mInput;
mInput = 0;
-#ifdef PCM_INPUT_DUMP
- fclose(fpInput);
- fpInput = NULL;
-#endif
-#if defined TURN_ON_DEVICE_ONLY_USE
- mActivatedInputDevice = false;
setMicStatus(0);
-#endif
-
}
}
-#if defined SEC_SWP_SOUND
+
status_t AudioHardwareALSA::doRouting(uint32_t device)
{
- uint32_t routes;
- status_t ret;
-
- AutoMutex lock(mLock);
- int mode = mMode; // Prevent to changing mode on setup sequence.
-
- if (mOutput) {
- routes = device;
- //routes = 0; /* Tushar - temp implementation */
-
- // Setup sound path for CP clocking
-
-#if defined SEC_IPC
-
- if (AudioSystem::MODE_IN_CALL == mode)
- {
-
- LOGI("### incall mode route (%d)", routes);
- switch(routes){
- case AudioSystem::ROUTE_EARPIECE:
- LOGI("### incall mode earpiece route");
- mIPC->transmitAudioPathIPC(OEM_SOUND_AUDIO_PATH_HANDSET);
- break;
-
- case AudioSystem::ROUTE_SPEAKER:
- LOGI("### incall mode speaker route");
- mIPC->transmitAudioPathIPC(OEM_SOUND_AUDIO_PATH_SPEAKER);
- break;
-
- case AudioSystem::ROUTE_BLUETOOTH_SCO:
- case AudioSystem::ROUTE_BLUETOOTH_SCO_HEADSET:
- case AudioSystem::ROUTE_BLUETOOTH_SCO_CARKIT:
-#if defined BT_NR_EC_ONOFF
- if(mBluetoothECOff)
- {
- LOGI("### incall mode bluetooth EC OFF route");
- mIPC->transmitAudioPathIPC(OEM_SOUND_AUDIO_PATH_BT_NSEC_OFF);
- }
- else
- {
-#endif
- LOGI("### incall mode bluetooth route");
- mIPC->transmitAudioPathIPC(OEM_SOUND_AUDIO_PATH_BLUETOOTH);
-#if defined BT_NR_EC_ONOFF
- }
-#endif
- break;
-
- case AudioSystem::ROUTE_HEADSET :
- case AudioSystem::ROUTE_HEADPHONE :
- LOGI("### incall mode headset route");
- mIPC->transmitAudioPathIPC(OEM_SOUND_AUDIO_PATH_HEADSET);
- break;
-
- case AudioSystem::ROUTE_BLUETOOTH_A2DP:
- LOGI("### incall mode bluetooth route");
- mIPC->transmitAudioPathIPC(OEM_SOUND_AUDIO_PATH_BLUETOOTH);
- break;
-
- default:
- LOGE("### incall mode Error!! route = [%d]", routes);
- break;
- }
- }
-#endif// end of #if defined SEC_IPC
-
- ret = mOutput->setDevice(mode, routes, PLAYBACK);
-
-#if defined SEC_IPC
- if (AudioSystem::MODE_IN_CALL == mode)
- {
-#if defined SYNCHRONIZE_CP
- if(!mActivatedCP)
- {
- mIPC->transmitClock_IPC(OEM_SOUND_CLOCK_START);
- mActivatedCP = true;
- }
-#endif
- }
-
- if (AudioSystem::MODE_NORMAL== mode) // Call stop.
- {
-#if defined SYNCHRONIZE_CP
- if(mActivatedCP)
- mActivatedCP = false;
-#endif
-
- }
-#endif // end of #if defined SEC_IPC
-
-#ifndef SYNCHRONIZE_CP
-// ret = mOutput->setDevice(mode, routes, PLAYBACK);
-#endif
- return ret;
- }
-
- return NO_INIT;
-}
-
-#else
-/** This function is no more used */
-status_t AudioHardwareALSA::doRouting()
-{
- uint32_t routes;
+ status_t ret;
+
AutoMutex lock(mLock);
+ int mode = mMode; // Prevent to changing mode on setup sequence.
+
+ LOGV("doRouting (%d)", device);
- LOGD("Inside AudioHardwareALSA::doRouting \n");
if (mOutput) {
- //routes = mRoutes[mMode];
- routes = 0; /* Tushar - temp implementation */
- return mOutput->setDevice(mMode, routes, PLAYBACK);
+ //device = 0; /* Tushar - temp implementation */
+
+ // Setup sound path for CP clocking
+ if ( (AudioSystem::MODE_IN_CALL == mode) && (mSecRilLibHandle) &&
+ (connectRILDIfRequired() == OK) ) {
+
+ LOGI("### incall mode route (%d)", device);
+
+ switch(device){
+ case AudioSystem::ROUTE_EARPIECE:
+ LOGI("### incall mode earpiece route");
+ setCallAudioPath(mRilClient, SOUND_AUDIO_PATH_HANDSET);
+ break;
+
+ case AudioSystem::ROUTE_SPEAKER:
+ LOGI("### incall mode speaker route");
+ setCallAudioPath(mRilClient, SOUND_AUDIO_PATH_SPEAKER);
+ break;
+
+ case AudioSystem::ROUTE_BLUETOOTH_SCO:
+ case AudioSystem::ROUTE_BLUETOOTH_SCO_HEADSET:
+ case AudioSystem::ROUTE_BLUETOOTH_SCO_CARKIT:
+ LOGI("### incall mode bluetooth route");
+ setCallAudioPath(mRilClient, SOUND_AUDIO_PATH_BLUETOOTH);
+ break;
+
+ case AudioSystem::ROUTE_HEADSET :
+ case AudioSystem::ROUTE_HEADPHONE :
+ LOGI("### incall mode headset route");
+ setCallAudioPath(mRilClient, SOUND_AUDIO_PATH_HEADSET);
+ break;
+
+ case AudioSystem::ROUTE_BLUETOOTH_A2DP:
+ LOGI("### incall mode bluetooth route");
+ setCallAudioPath(mRilClient, SOUND_AUDIO_PATH_BLUETOOTH);
+ break;
+
+ default:
+ LOGE("### incall mode Error!! route = [%d]", device);
+ break;
+ }
+ }
+
+ ret = mOutput->setDevice(mode, device, PLAYBACK);
+
+ return ret;
}
- return NO_INIT;
+ return NO_INIT;
}
-#endif
+
status_t AudioHardwareALSA::setMicMute(bool state)
{
@@ -721,7 +627,6 @@ ALSAStreamOps::ALSAStreamOps() :
mHandle(0),
mHardwareParams(0),
mSoftwareParams(0),
- mMode(-1),
mDevice(0)
{
if (snd_pcm_hw_params_malloc(&mHardwareParams) < 0) {
@@ -751,44 +656,44 @@ status_t ALSAStreamOps::set(int *pformat,
uint32_t *pchannels,
uint32_t *prate)
{
- int lformat = pformat ? *pformat : 0;
- unsigned int lchannels = pchannels ? *pchannels : 0;
- unsigned int lrate = prate ? *prate : 0;
+ int lformat = pformat ? *pformat : 0;
+ unsigned int lchannels = pchannels ? *pchannels : 0;
+ unsigned int lrate = prate ? *prate : 0;
- LOGD("ALSAStreamOps - input - format = %d, channels = %d, rate = %d\n", lformat, lchannels, lrate);
- LOGD("ALSAStreamOps - default - format = %d, channelCount = %d, rate = %d\n", mDefaults->format, mDefaults->channelCount, mDefaults->sampleRate);
+ LOGD("ALSAStreamOps - input - format = %d, channels = %d, rate = %d\n", lformat, lchannels, lrate);
+ LOGD("ALSAStreamOps - default - format = %d, channelCount = %d, rate = %d\n", mDefaults->format, mDefaults->channelCount, mDefaults->sampleRate);
- if(lformat == 0) lformat = getAndroidFormat(mDefaults->format);//format();
- if(lchannels == 0) lchannels = getAndroidChannels(mDefaults->channelCount);// channelCount();
- if(lrate == 0) lrate = mDefaults->sampleRate;
+ if (lformat == 0) lformat = getAndroidFormat(mDefaults->format);//format();
+ if (lchannels == 0) lchannels = getAndroidChannels(mDefaults->channelCount);// channelCount();
+ if (lrate == 0) lrate = mDefaults->sampleRate;
- if((lformat != getAndroidFormat(mDefaults->format)) ||
- (lchannels != getAndroidChannels(mDefaults->channelCount))) {
- if(pformat) *pformat = getAndroidFormat(mDefaults->format);
- if(pchannels) *pchannels = getAndroidChannels(mDefaults->channelCount);
- return BAD_VALUE;
- }
- if (mDefaults->direction == SND_PCM_STREAM_PLAYBACK) {
- if (lrate != mDefaults->sampleRate) {
- if(prate) *prate = mDefaults->sampleRate;
+ if ( (lformat != getAndroidFormat(mDefaults->format)) ||
+ (lchannels != getAndroidChannels(mDefaults->channelCount)) ) {
+ if (pformat) *pformat = getAndroidFormat(mDefaults->format);
+ if (pchannels) *pchannels = getAndroidChannels(mDefaults->channelCount);
+ return BAD_VALUE;
+ }
+ if (mDefaults->direction == SND_PCM_STREAM_PLAYBACK) {
+ if (lrate != mDefaults->sampleRate) {
+ if (prate) *prate = mDefaults->sampleRate;
return BAD_VALUE;
- }
- } else {
- mDefaults->smpRateShift = AudioHardwareALSA::checkInputSampleRate(lrate);
- // audioFlinger will reopen the input stream with correct smp rate
- if (AudioHardwareALSA::inputSamplingRates[mDefaults->smpRateShift] != lrate) {
- if(prate) *prate = AudioHardwareALSA::inputSamplingRates[mDefaults->smpRateShift];
+ }
+ } else {
+ mDefaults->smpRateShift = AudioHardwareALSA::checkInputSampleRate(lrate);
+ // audioFlinger will reopen the input stream with correct smp rate
+ if (AudioHardwareALSA::inputSamplingRates[mDefaults->smpRateShift] != lrate) {
+ if(prate) *prate = AudioHardwareALSA::inputSamplingRates[mDefaults->smpRateShift];
return BAD_VALUE;
- }
- }
+ }
+ }
mDefaults->sampleRate = lrate;
- if(pformat) *pformat = getAndroidFormat(mDefaults->format);
- if(pchannels) *pchannels = getAndroidChannels(mDefaults->channelCount);
- if(prate) *prate = mDefaults->sampleRate;
+ if(pformat) *pformat = getAndroidFormat(mDefaults->format);
+ if(pchannels) *pchannels = getAndroidChannels(mDefaults->channelCount);
+ if(prate) *prate = mDefaults->sampleRate;
- return NO_ERROR;
+ return NO_ERROR;
}
@@ -985,7 +890,7 @@ status_t ALSAStreamOps::open(int mode, uint32_t device)
int err;
- LOGI("Try to open ALSA %s device %s", stream, devName);
+ LOGI("Try to open ALSA %s device %s", stream, devName);
for(;;) {
// The PCM stream is opened in blocking mode, per ALSA defaults. The
@@ -1003,7 +908,7 @@ status_t ALSAStreamOps::open(int mode, uint32_t device)
if (err < 0) {
// None of the Android defined audio devices exist. Open a generic one.
- devName = "hw:00,1"; // 090507 SMDKC110 Froyo
+ devName = "hw:00,1"; // 090507 SMDKC110 Froyo
err = snd_pcm_open(&mHandle, devName, mDefaults->direction, 0);
if (err < 0) {
@@ -1013,7 +918,6 @@ status_t ALSAStreamOps::open(int mode, uint32_t device)
}
}
- mMode = mode;
mDevice = device;
LOGI("Initialized ALSA %s device %s", stream, devName);
@@ -1026,9 +930,8 @@ void ALSAStreamOps::close()
mHandle = NULL;
if (handle) {
+ snd_pcm_drain(handle);
snd_pcm_close(handle);
- mMode = -1;
- mDevice = 0;
}
}
@@ -1052,7 +955,7 @@ status_t ALSAStreamOps::setSoftwareParams()
// Configure ALSA to start the transfer when the buffer is almost full.
snd_pcm_get_params(mHandle, &bufferSize, &periodSize);
- LOGE("bufferSize %d, periodSize %d\n", bufferSize, periodSize);
+ LOGE("bufferSize %d, periodSize %d\n", (int)bufferSize, (int)periodSize);
if (mDefaults->direction == SND_PCM_STREAM_PLAYBACK) {
// For playback, configure ALSA to start the transfer when the
@@ -1221,11 +1124,6 @@ status_t ALSAStreamOps::setDevice(int mode, uint32_t device, uint audio_mode)
// FIXME:: always use default sampling rate
sampleRate(DEFAULT_SAMPLE_RATE);
- // Disable hardware resampling.
- status = setHardwareResample(false);
- if (status != NO_ERROR)
- return status;
-
snd_pcm_uframes_t bufferSize = mDefaults->bufferSize;
snd_pcm_uframes_t periodSize = mDefaults->periodSize;
period_val = bufferSize/periodSize;
@@ -1265,12 +1163,12 @@ status_t ALSAStreamOps::setDevice(int mode, uint32_t device, uint audio_mode)
// err = snd_pcm_hw_params_set_buffer_time_near (mHandle, mHardwareParams,
// &latency, NULL);
// if(audio_mode == PLAYBACK) {
-// period_val = PERIODS_PLAYBACK;
-// if(snd_pcm_hw_params_set_periods(mHandle, mHardwareParams, period_val, 0) < 0)
-// LOGE("Fail to set period size %d for playback", period_val);
+// period_val = PERIODS_PLAYBACK;
+// if(snd_pcm_hw_params_set_periods(mHandle, mHardwareParams, period_val, 0) < 0)
+// LOGE("Fail to set period size %d for playback", period_val);
// }
// else
-// period_val = PERIODS_CAPTURE;
+// period_val = PERIODS_CAPTURE;
//
// if (err < 0) {
// LOGD("snd_pcm_hw_params_set_buffer_time_near() failed: %s", snd_strerror(err));
@@ -1413,8 +1311,8 @@ status_t AudioStreamOutALSA::setVolume(float left, float right)
if (! mParent->mMixer || ! mDevice)
return NO_INIT;
- /** Tushar - Need to decide on the volume value
- * that we pass onto the mixer. */
+ /** Tushar - Need to decide on the volume value
+ * that we pass onto the mixer. */
return mParent->mMixer->setVolume (mDevice, (left + right)/2);
}
@@ -1429,7 +1327,6 @@ status_t AudioStreamOutALSA::setVolume(float volume)
/* New Arch */
status_t AudioStreamOutALSA::setParameters(const String8& keyValuePairs)
{
-#if defined SLSI_S5PC110
AudioParameter param = AudioParameter(keyValuePairs);
status_t status = NO_ERROR;
int device;
@@ -1438,11 +1335,7 @@ status_t AudioStreamOutALSA::setParameters(const String8& keyValuePairs)
if (param.getInt(String8(AudioParameter::keyRouting), device) == NO_ERROR)
{
- mDevice = device;
-
-// if (mParent->mInput) mParent->mInput->mDevice = device;
- mParent->mRoutes[mParent->mMode] = mDevice;
- mParent->doRouting(mDevice);
+ mParent->doRouting(device);
param.remove(String8(AudioParameter::keyRouting));
}
@@ -1457,23 +1350,11 @@ status_t AudioStreamOutALSA::setParameters(const String8& keyValuePairs)
status = BAD_VALUE;
}
return status;
-#else
- /* TODO: Implement as per new arch */
-
- LOGD("AudioStreamOutAlsa::setParameters... %s \n\n",keyValuePairs.string());
- if (! mParent->mOutput )//|| ! mMode)
- return NO_INIT;
+}
- int device = keyValuePairs.string()[keyValuePairs.length()-1] - 48 -1 ; //easy conversion frm ascii to int and then to required number
- LOGV("\n\n-------->> ALSA SET PARAMS device %d \n\n",(1<<device));
- mParent->mOutput->setDevice(mMode, 1<<device, PLAYBACK);
- return NO_ERROR;
-#endif
-}
String8 AudioStreamOutALSA::getParameters(const String8& keys)
{
-#if defined SLSI_S5PC110
AudioParameter param = AudioParameter(keys);
String8 value;
String8 key = String8(AudioParameter::keyRouting);
@@ -1484,20 +1365,17 @@ String8 AudioStreamOutALSA::getParameters(const String8& keys)
LOGD("AudioStreamOutALSA::getParameters() %s", param.toString().string());
return param.toString();
-#else
- /* TODO: Implement as per new arch */
- return keys;
-#endif
}
+
status_t AudioStreamOutALSA::getRenderPosition(uint32_t *dspFrames)
{
- //TODO: enable when supported by driver
- return INVALID_OPERATION;
+ //TODO: enable when supported by driver
+ return INVALID_OPERATION;
}
-#if 1 // Fix for underrun error
+
ssize_t AudioStreamOutALSA::write(const void *buffer, size_t bytes)
{
snd_pcm_sframes_t n;
@@ -1508,17 +1386,11 @@ ssize_t AudioStreamOutALSA::write(const void *buffer, size_t bytes)
if (!mPowerLock) {
LOGD("Calling setDevice from write @..%d.\n",__LINE__);
- ALSAStreamOps::setDevice(mMode, mDevice, PLAYBACK);
+ ALSAStreamOps::setDevice(mParent->mode(), mDevice, PLAYBACK);
acquire_wake_lock (PARTIAL_WAKE_LOCK, "AudioOutLock");
mPowerLock = true;
}
- // if (isStandby())
- // return 0;
-#ifdef PCM_OUTPUT_DUMP
- fwrite(buffer, bytes, 1, fpOutput);
- LOGD("Output PCM dumped!!");
-#endif
do {
// write correct number of bytes per attempt
n = snd_pcm_writei(mHandle, (char *) buffer + sent, snd_pcm_bytes_to_frames(mHandle, bytes
@@ -1527,7 +1399,7 @@ ssize_t AudioStreamOutALSA::write(const void *buffer, size_t bytes)
LOGD("Calling setDevice.. pcm_write returned error @..%d.\n",__LINE__);
// Somehow the stream is in a bad state. The driver probably
// has a bug and snd_pcm_recover() doesn't seem to handle this.
- ALSAStreamOps::setDevice(mMode, mDevice, PLAYBACK);
+ ALSAStreamOps::setDevice(mParent->mode(), mDevice, PLAYBACK);
} else if (n < 0) {
if (mHandle) {
// snd_pcm_recover() will return 0 if successful in recovering from
@@ -1543,41 +1415,6 @@ ssize_t AudioStreamOutALSA::write(const void *buffer, size_t bytes)
//LOGI("Request Bytes=%d, Actual Written=%d",bytes,sent);
return snd_pcm_frames_to_bytes(mHandle, sent);
}
-#else
-ssize_t AudioStreamOutALSA::write(const void *buffer, size_t bytes)
-{
- snd_pcm_sframes_t n;
- status_t err;
-
- AutoMutex lock(mLock);
-#if 0
- if (isStandby())
- return 0;
-#endif
- if (!mPowerLock) {
- acquire_wake_lock (PARTIAL_WAKE_LOCK, "AudioLock");
- ALSAStreamOps::setDevice(mMode, mDevice,PLAYBACK);
- mPowerLock = true;
- }
- if (!mHandle) {
- return -1;
- }
- n = snd_pcm_writei(mHandle,
- buffer,
- snd_pcm_bytes_to_frames(mHandle, bytes));
- if (n < 0 && mHandle) {
- // snd_pcm_recover() will return 0 if successful in recovering from
- // an error, or -errno if the error was unrecoverable.
- //device driver sometimes does not recover -vladi
- n = snd_pcm_recover(mHandle, n, 0);
- if(n < 0) //if recover fails
- ALSAStreamOps::setDevice(mMode, mDevice, PLAYBACK);
- }
-
- return static_cast<ssize_t>(n);
-}
-#endif
-
status_t AudioStreamOutALSA::dump(int fd, const Vector<String16>& args)
@@ -1589,41 +1426,28 @@ status_t AudioStreamOutALSA::setDevice(int mode, uint32_t newDevice, uint32_t au
{
AutoMutex lock(mLock);
- return ALSAStreamOps::setDevice(mode, newDevice, audio_mode);
+ LOGV("AudioStreamOutALSA::setDevice(mode %d, newDevice %x, audio_mode %d), mDevice %x",
+ mode, newDevice, audio_mode, mDevice);
+ if (newDevice != mDevice) {
+ mParent->mRoutes[mParent->mMode] = newDevice;
+ return ALSAStreamOps::setDevice(mode, newDevice, audio_mode);
+ }
+ return NO_ERROR;
}
status_t AudioStreamOutALSA::standby() {
AutoMutex lock(mLock);
LOGD("Inside AudioStreamOutALSA::standby\n");
- if (mHandle)
- snd_pcm_drain ( mHandle);
+
+ ALSAStreamOps::close();
if (mPowerLock) {
- if (!mParent->mActivatedInputDevice) { // Let PCM device alive on activating input stream.
- snd_pcm_close( mHandle);
- mHandle = NULL;
-#if 1 // Fix for underrun error
- release_wake_lock("AudioOutLock");
-#else
- release_wake_lock ("AudioLock");
-#endif
- mPowerLock = false;
- }
+ release_wake_lock("AudioOutLock");
+ mPowerLock = false;
}
- // close(); //Don't call this as this function will reset the mode also
return NO_ERROR;
}
-bool AudioStreamOutALSA::isStandby()
-{
- return (!mPowerLock);
-}
-
-void AudioStreamOutALSA::setWakeLock()
-{
- acquire_wake_lock (PARTIAL_WAKE_LOCK, "AudioOutLock");
- mPowerLock = true;
-}
#define USEC_TO_MSEC(x) ((x + 999) / 1000)
@@ -1656,7 +1480,7 @@ AudioStreamInALSA::AudioStreamInALSA(AudioHardwareALSA *parent) :
AudioStreamInALSA::~AudioStreamInALSA()
{
- standby_l();
+ standby();
mParent->mInput = NULL;
}
@@ -1678,17 +1502,10 @@ ssize_t AudioStreamInALSA::read(void *buffer, ssize_t bytes)
if (!mPowerLock) {
acquire_wake_lock (PARTIAL_WAKE_LOCK, "AudioInLock");
-#ifdef PCM_INPUT_DUMP
- fwrite(buffer, readBytes, 1, fpInput);
- LOGD("Input PCM dumped!!");
-#endif
-#if defined TURN_ON_DEVICE_ONLY_USE
- mParent->mActivatedInputDevice = true;
// setMicStatus(1);
-#endif
- LOGD("Calling setDevice from read@..%d.\n",__LINE__);
- ALSAStreamOps::setDevice(mMode, mDevice,CAPTURE);
+ LOGD("Calling setDevice from read@..%d.\n",__LINE__);
+ ALSAStreamOps::setDevice(mParent->mode(), mDevice,CAPTURE);
mPowerLock = true;
}
if (!mHandle) {
@@ -1696,8 +1513,8 @@ ssize_t AudioStreamInALSA::read(void *buffer, ssize_t bytes)
}
// FIXME: only support reads of exactly bufferSize() for now
- if (bytes != bufferSize()) {
- LOGW("AudioStreamInALSA::read bad read size %d expected %d", bytes, bufferSize());
+ if (bytes != (ssize_t)bufferSize()) {
+ LOGW("AudioStreamInALSA::read bad read size %d expected %d", (int)bytes, bufferSize());
return -1;
}
@@ -1708,9 +1525,9 @@ ssize_t AudioStreamInALSA::read(void *buffer, ssize_t bytes)
(uint8_t *)mBuffer,
frames << shift);
if (n < 0) {
- LOGD("AudioStreamInALSA::read error %d", n);
+ LOGD("AudioStreamInALSA::read error %d", (int)n);
n = snd_pcm_recover(mHandle, n, 0);
- LOGD("AudioStreamInALSA::snd_pcm_recover error %d", n);
+ LOGD("AudioStreamInALSA::snd_pcm_recover error %d", (int)n);
if (n)
return static_cast<ssize_t> (n);
} else {
@@ -1725,19 +1542,15 @@ ssize_t AudioStreamInALSA::read(void *buffer, ssize_t bytes)
// downsampler in AudioFlinger (SR in < 2 * SR out)
int16_t *out = (int16_t *)buffer;
if (mDefaults->channelCount == 1) {
- for (size_t i = 0; i < n; i++) {
+ for (ssize_t i = 0; i < n; i++) {
out[i] = mBuffer[i << shift];
}
} else {
- for (size_t i = 0; i < n; i++) {
+ for (ssize_t i = 0; i < n; i++) {
out[i] = mBuffer[i << shift];
out[i + 1] = mBuffer[(i << shift) + 1];
}
}
-#ifdef PCM_INPUT_DUMP
- fwrite(buffer, bytes, 1, fpInput);
- LOGD("Input PCM dumped!!");
-#endif
return snd_pcm_frames_to_bytes(mHandle, n);
}
@@ -1757,86 +1570,52 @@ status_t AudioStreamInALSA::setDevice(int mode, uint32_t newDevice, uint32_t aud
status_t AudioStreamInALSA::standby()
{
AutoMutex lock(mLock);
+ LOGD("Entering AudioStreamInALSA::standby\n");
- return standby_l();
-}
+ ALSAStreamOps::close();
-status_t AudioStreamInALSA::standby_l()
-{
- LOGD("Entering AudioStreamInALSA::standby\n");
if (mPowerLock) {
- mParent->mActivatedInputDevice = false;
- snd_pcm_close(mHandle);
- LOGD("AudioStreamInALSA::standby snd_pcm_close()");
- mHandle = NULL;
- release_wake_lock ("AudioInLock");
- mPowerLock = false;
+ release_wake_lock ("AudioInLock");
+ mPowerLock = false;
}
return NO_ERROR;
}
-void AudioStreamInALSA::setWakeLock()
-{
- acquire_wake_lock (PARTIAL_WAKE_LOCK, "AudioInLock");
- mPowerLock = true;
-}
-
/* New Arch */
status_t AudioStreamInALSA::setParameters(const String8& keyValuePairs)
{
-#if defined SLSI_S5PC110
- AudioParameter param = AudioParameter(keyValuePairs);
- String8 key = String8(AudioParameter::keyRouting);
- status_t status = NO_ERROR;
- int device;
- LOGD("AudioStreamInALSA::setParameters() %s", keyValuePairs.string());
-
- if (param.getInt(key, device) == NO_ERROR) {
- mDevice = device;
- if(mPowerLock && mDevice != 0)
- setDevice(mMode, mDevice, CAPTURE);
- param.remove(key);
- }
-
- if (param.size()) {
- status = BAD_VALUE;
- }
- return status;
-#else
- /* TODO: Implement as per new arch */
-
- if (! mParent->mInput )//|| ! mMode)
- return NO_INIT;
+ AudioParameter param = AudioParameter(keyValuePairs);
+ String8 key = String8(AudioParameter::keyRouting);
+ status_t status = NO_ERROR;
+ int device;
+ LOGD("AudioStreamInALSA::setParameters() %s", keyValuePairs.string());
- // yman.seo use setDevice temp.
- int device = keyValuePairs.string()[keyValuePairs.length()-1] - 48 -1 ; //easy conversion frm ascii to int and then to required number
- LOGD("\n\n-------->> ALSA AudioStreamIn SET PARAMS device %d \n\n",(1<<device));
- if(mParent->mActivatedInputDevice )//Recording stopped with Alarm ,then don't call setDevice() of record, just return
- return mParent->mInput->setDevice(mMode, 1<<device, CAPTURE);
+ if (param.getInt(key, device) == NO_ERROR) {
+ if(mHandle != NULL && device != 0)
+ setDevice(mParent->mode(), device, CAPTURE);
+ param.remove(key);
+ }
- return NO_ERROR;
-// yman.seo return NO_ERROR;
-#endif
+ if (param.size()) {
+ status = BAD_VALUE;
+ }
+ return status;
}
+
String8 AudioStreamInALSA::getParameters(const String8& keys)
{
-#if defined SLSI_S5PC110
- AudioParameter param = AudioParameter(keys);
- String8 value;
- String8 key = String8(AudioParameter::keyRouting);
+ AudioParameter param = AudioParameter(keys);
+ String8 value;
+ String8 key = String8(AudioParameter::keyRouting);
- if (param.get(key, value) == NO_ERROR) {
- param.addInt(key, (int)mDevice);
- }
+ if (param.get(key, value) == NO_ERROR) {
+ param.addInt(key, (int)mDevice);
+ }
- LOGD("AudioStreamInALSA::getParameters() %s", param.toString().string());
- return param.toString();
-#else
- /* TODO: Implement as per new arch */
- return keys;
-#endif
+ LOGD("AudioStreamInALSA::getParameters() %s", param.toString().string());
+ return param.toString();
}
@@ -2158,7 +1937,7 @@ status_t ALSAMixer::getCaptureMuteState(uint32_t device, bool *state)
status_t ALSAMixer::setPlaybackMuteState(uint32_t device, bool state)
{
- LOGE("\n set playback mute device %d, state %d \n", device,state);
+ LOGE("\n set playback mute device %d, state %d \n", device,state);
for (int j = 0; mixerProp[j][SND_PCM_STREAM_PLAYBACK].routes; j++)
if (mixerProp[j][SND_PCM_STREAM_PLAYBACK].routes & device) {
@@ -2319,155 +2098,5 @@ status_t ALSAControl::set(const char *name, unsigned int value, int index)
return (ret < 0) ? BAD_VALUE : NO_ERROR;
}
-// ----------------------------------------------------------------------------
-
-#if defined SEC_IPC
-AudioHardwareIPC::AudioHardwareIPC() :
- mClient(NULL)
-{
-LOGD("### %s", __func__);
- int err = 0;
-
- mClient = OpenClient_RILD();
- if (mClient == NULL){
- LOGE("[*] OpenClient_RILD() error\n");
- err = 1;
- }
-
- if (RegisterRequestCompleteHandler(mClient, RIL_REQUEST_OEM_HOOK_RAW,
- onRawReqComplete) != RIL_CLIENT_ERR_SUCCESS){
- LOGE("[*] RegisterRequestCompleteHandler() error\n");
- err = 1;
- }
-
- if (RegisterUnsolicitedHandler(mClient, 11004, onUnsol) !=
- RIL_CLIENT_ERR_SUCCESS){
- LOGE("[*] RegisterUnsolicitedHandler() error\n");
- err = 1;
- }
-
- if (!err) LOGD("Success Initializing IPC");
- else LOGE("Failed Initializing IPC");
-}
-
-AudioHardwareIPC::~AudioHardwareIPC()
-{
- LOGD("### %s", __func__);
- if (RegisterRequestCompleteHandler(mClient, RIL_REQUEST_OEM_HOOK_RAW, NULL) != RIL_CLIENT_ERR_SUCCESS)
- LOGE("RegisterRequestCompleteHandler(NULL) error\n");
-
- if (RegisterUnsolicitedHandler(mClient, 11004, NULL) != RIL_CLIENT_ERR_SUCCESS)
- LOGE("RegisterUnsolicitedHandler(NULL) error\n");
-
- if (Disconnect_RILD(mClient) != RIL_CLIENT_ERR_SUCCESS)
- LOGE("[*] Disconnect_RILD() error\n");
-
- if (CloseClient_RILD(mClient) != RIL_CLIENT_ERR_SUCCESS)
- LOGE("[*] CloseClient_RILD() error\n");
- mClient = NULL;
-}
-
-status_t AudioHardwareIPC::transmitVolumeIPC(uint32_t type, float volume)
-{
- int ret = 0;
- uint32_t level = (uint32_t)(volume * 5);
-
- if (isConnected_RILD(mClient) == 0) {
- if (Connect_RILD(mClient) != RIL_CLIENT_ERR_SUCCESS){
- LOGE("[*] Connect_RILD() error\n");
- return INVALID_OPERATION;
- }
- }
-
- memset(data, 0, 100);
- data[0] = OEM_FUNCTION_ID_SOUND;
- data[1] = OEM_SOUND_SET_VOLUME_CTRL;
- data[2] = 0x00; // data length
- data[3] = 0x06; // data length
- data[4] = type; // volume type
- data[5] = level; // volume level
-
- ret = InvokeOemRequestHookRaw(mClient, data, 6); //sizeof(data));
- if (ret != RIL_CLIENT_ERR_AGAIN && ret != RIL_CLIENT_ERR_SUCCESS){
- LOGE("[*] InvokeOemRequestHookRaw() error ret = %d\n", ret);
- return INVALID_OPERATION;
- }
- return NO_ERROR;
-}
-
-status_t AudioHardwareIPC::transmitAudioPathIPC(uint32_t path)
-{
- int ret = 0;
-
- LOGI("### %s %d ", __func__, path);
- if (isConnected_RILD(mClient) == 0) {
- if (Connect_RILD(mClient) != RIL_CLIENT_ERR_SUCCESS){
- LOGE("[*] Connect_RILD() error\n");
- return INVALID_OPERATION;
- }
- }
-
- memset(data, 0, 100);
- data[0] = OEM_FUNCTION_ID_SOUND;
- data[1] = OEM_SOUND_SET_AUDIO_PATH_CTRL;
- data[2] = 0x00; // data length
- data[3] = 0x05; // data length
- data[4] = path; // audio path
-
- ret = InvokeOemRequestHookRaw(mClient, data, 5); //sizeof(data));
- if (ret != RIL_CLIENT_ERR_AGAIN && ret != RIL_CLIENT_ERR_SUCCESS){
- LOGE("[*] InvokeOemRequestHookRaw() error ret = %d\n", ret);
- return INVALID_OPERATION;
- }
- return NO_ERROR;
-}
-
-
-#if defined SYNCHRONIZE_CP
-status_t AudioHardwareIPC::transmitClock_IPC(uint32_t condition)
-{
- int ret = 0;
-
- LOGV("### %s %d ", __func__, condition);
-
- if (isConnected_RILD(mClient) == 0) {
- if (Connect_RILD(mClient) != RIL_CLIENT_ERR_SUCCESS){
- LOGE("[*] Connect_RILD() error\n");
- return INVALID_OPERATION;
- }
- }
-
- memset(data, 0, 100);
- data[0] = OEM_FUNCTION_ID_SOUND;
- data[1] = OEM_SOUND_SET_CLOCK_CTRL;
- data[2] = 0x00; // data length
- data[3] = 0x05; // data length
- data[4] = condition;
-
- ret = InvokeOemRequestHookRaw(mClient, data, 5); //sizeof(data));
-
- if (ret != RIL_CLIENT_ERR_AGAIN && ret != RIL_CLIENT_ERR_SUCCESS){
- LOGE("[*] InvokeOemRequestHookRaw() error ret = %d\n", ret);
- return INVALID_OPERATION;
- }
-
- return NO_ERROR;
-}
-#endif
-
-static int onRawReqComplete(HRilClient client, const void *data, size_t datalen)
-{
- LOGV("[*] %s(): datalen(%d)\n", __FUNCTION__, datalen);
- return 0;
-}
-static int onUnsol(HRilClient client, const void *data, size_t datalen)
-{
- int a;
- a = ((int *)data)[0];
- LOGV("%s(): a(%d)\n", __FUNCTION__, a);
-
- return 0;
-}
-#endif //SEC_IPC
}; // namespace android
diff --git a/libaudio/AudioHardwareALSA.h b/libaudio/AudioHardwareALSA.h
index 0390beb..f65aa68 100755
--- a/libaudio/AudioHardwareALSA.h
+++ b/libaudio/AudioHardwareALSA.h
@@ -24,73 +24,9 @@
#include <hardware_legacy/AudioHardwareBase.h>
-#if defined SEC_IPC
-#include <hardware/hardware.h>
-
// sangsu fix : headers for IPC
#include "secril-client.h"
-// sangsu fix : defines for IPC
-#define OEM_FUNCTION_ID_SOUND 0x08 // sound Main Cmd
-
-//sangsu fix : sound sub command for IPC
-#define OEM_SOUND_SET_VOLUME_CTRL 0x03
-#define OEM_SOUND_GET_VOLUME_CTRL 0x04
-#define OEM_SOUND_SET_AUDIO_PATH_CTRL 0x05
-#define OEM_SOUND_GET_AUDIO_PATH_CTRL 0x06
-
-//sangsu fix : audio path for IPC
-#define OEM_SOUND_AUDIO_PATH_HANDSET 0x01
-#define OEM_SOUND_AUDIO_PATH_HEADSET 0x02
-#define OEM_SOUND_AUDIO_PATH_HANDFREE 0x03
-#define OEM_SOUND_AUDIO_PATH_BLUETOOTH 0x04
-#define OEM_SOUND_AUDIO_PATH_STREOBT 0x05
-#define OEM_SOUND_AUDIO_PATH_SPEAKER 0x06
-#define OEM_SOUND_AUDIO_PATH_HEADSET35 0x07
-#define OEM_SOUND_AUDIO_PATH_BT_NSEC_OFF 0x08
-
-// sangsu fix : volume level for IPC
-#define OEM_SOUND_VOLUME_LEVEL_MUTE 0x00
-#define OEM_SOUND_VOLUME_LEVEL1 0x01
-#define OEM_SOUND_VOLUME_LEVEL2 0x02
-#define OEM_SOUND_VOLUME_LEVEL3 0x03
-#define OEM_SOUND_VOLUME_LEVEL4 0x04
-#define OEM_SOUND_VOLUME_LEVEL5 0x05
-#define OEM_SOUND_VOLUME_LEVEL6 0x06
-#define OEM_SOUND_VOLUME_LEVEL7 0x07
-#define OEM_SOUND_VOLUME_LEVEL8 0x08
-
-// For synchronizing I2S clocking
-#if defined SYNCHRONIZE_CP
-#define OEM_SOUND_SET_CLOCK_CTRL 0x0A
-#define OEM_SOUND_CLOCK_START 0x01
-#define OEM_SOUND_CLOCK_STOP 0x00
-#endif
-
-// For VT
-#if defined VIDEO_TELEPHONY
-#define OEM_SOUND_VIDEO_CALL_STOP 0x00
-#define OEM_SOUND_VIDEO_CALL_START 0x01
-#define OEM_SOUND_SET_VIDEO_CALL_CTRL 0x07
-#endif
-
-// sangsu fix : volume type for IPC
-#define OEM_SOUND_TYPE_VOICE 0x01 // Receiver(0x00) + Voice(0x01)
-#define OEM_SOUND_TYPE_KEYTONE 0x02 // Receiver(0x00) + Key tone (0x02)
-#define OEM_SOUND_TYPE_BELL 0x03 // Receiver(0x00) + Bell (0x03)
-#define OEM_SOUND_TYPE_MESSAGE 0x04 // Receiver(0x00) + Message(0x04)
-#define OEM_SOUND_TYPE_ALARM 0x05 // Receiver(0x00) + Alarm (0x05)
-#define OEM_SOUND_TYPE_SPEAKER 0x11 // SpeakerPhone (0x10) + Voice(0x01)
-#define OEM_SOUND_TYPE_HFKVOICE 0x21 // HFK (0x20) + Voice(0x01)
-#define OEM_SOUND_TYPE_HFKKEY 0x22 // HFK (0x20) + Key tone (0x02)
-#define OEM_SOUND_TYPE_HFKBELL 0x23 // HFK (0x20) + Bell (0x03)
-#define OEM_SOUND_TYPE_HFKMSG 0x24 // HFK (0x20) + Message(0x04)
-#define OEM_SOUND_TYPE_HFKALARM 0x25 // HFK (0x20) + Alarm (0x05)
-#define OEM_SOUND_TYPE_HFKPDA 0x26 // HFK (0x20) + PDA miscellaneous sound (0x06)
-#define OEM_SOUND_TYPE_HEADSET 0x31 // Headset (0x30) + Voice(0x01)
-#define OEM_SOUND_TYPE_BTVOICE 0x41 // BT(0x40) + Voice(0x01)
-#endif
-
#ifndef ALSA_DEFAULT_SAMPLE_RATE
#define ALSA_DEFAULT_SAMPLE_RATE 44100 // in Hz
#endif
@@ -112,7 +48,6 @@
namespace android
{
-
class AudioHardwareALSA;
// ----------------------------------------------------------------------------
@@ -181,13 +116,13 @@ namespace android
status_t sampleRate(uint32_t rate);
virtual size_t bufferSize() const;
virtual int format() const;
- int getAndroidFormat(snd_pcm_format_t format);
+ int getAndroidFormat(snd_pcm_format_t format);
virtual uint32_t channels() const;
int channelCount() const;
status_t channelCount(int channelCount);
uint32_t getAndroidChannels(int channelCount) const;
-
+
status_t open(int mode, uint32_t device);
void close();
status_t setSoftwareParams();
@@ -209,7 +144,6 @@ namespace android
snd_pcm_t *mHandle;
snd_pcm_hw_params_t *mHardwareParams;
snd_pcm_sw_params_t *mSoftwareParams;
- int mMode;
uint32_t mDevice;
StreamDefaults *mDefaults;
@@ -224,9 +158,9 @@ namespace android
virtual ~AudioStreamOutALSA();
- status_t set(int *format,
- uint32_t *channelCount,
- uint32_t *sampleRate){
+ status_t set(int *format,
+ uint32_t *channelCount,
+ uint32_t *sampleRate){
return ALSAStreamOps::set(format, channelCount, sampleRate);
}
@@ -239,7 +173,7 @@ namespace android
return ALSAStreamOps::bufferSize();
}
- virtual uint32_t channels() const
+ virtual uint32_t channels() const
{
return ALSAStreamOps::channels();
}
@@ -254,18 +188,16 @@ namespace android
virtual ssize_t write(const void *buffer, size_t bytes);
virtual status_t dump(int fd, const Vector<String16>& args);
virtual status_t setDevice(int mode, uint32_t newDevice, uint32_t audio_mode);
- virtual status_t setVolume(float left, float right); //Tushar: New arch
+ virtual status_t setVolume(float left, float right); //Tushar: New arch
status_t setVolume(float volume);
status_t standby();
- bool isStandby();
- void setWakeLock();
- virtual status_t setParameters(const String8& keyValuePairs);
- virtual String8 getParameters(const String8& keys);
-
- virtual status_t getRenderPosition(uint32_t *dspFrames);
+ virtual status_t setParameters(const String8& keyValuePairs);
+ virtual String8 getParameters(const String8& keys);
+
+ virtual status_t getRenderPosition(uint32_t *dspFrames);
private:
@@ -279,9 +211,9 @@ namespace android
AudioStreamInALSA(AudioHardwareALSA *parent);
virtual ~AudioStreamInALSA();
- status_t set(int *format,
- uint32_t *channelCount,
- uint32_t *sampleRate){
+ status_t set(int *format,
+ uint32_t *channelCount,
+ uint32_t *sampleRate) {
return ALSAStreamOps::set(format, channelCount, sampleRate);
}
@@ -294,7 +226,7 @@ namespace android
return ALSAStreamOps::bufferSize();
}
- virtual uint32_t channels() const
+ virtual uint32_t channels() const
{
return ALSAStreamOps::channels();
}
@@ -311,37 +243,18 @@ namespace android
virtual status_t setGain(float gain);
virtual status_t standby();
- status_t standby_l();
- void setWakeLock();
- virtual status_t setParameters(const String8& keyValuePairs);
- virtual String8 getParameters(const String8& keys);
+ virtual status_t setParameters(const String8& keyValuePairs);
+ virtual String8 getParameters(const String8& keys);
- virtual unsigned int getInputFramesLost() const { return 0; }
+ virtual unsigned int getInputFramesLost() const { return 0; }
private:
- AudioHardwareALSA *mParent;
- bool mPowerLock;
- int16_t mBuffer[2 * PERIOD_SZ_CAPTURE];
+ AudioHardwareALSA *mParent;
+ bool mPowerLock;
+ int16_t mBuffer[2 * PERIOD_SZ_CAPTURE];
};
-#if defined SEC_IPC
- //TODO..implementation has to be done
- class AudioHardwareIPC
- {
- public:
- AudioHardwareIPC();
- virtual ~AudioHardwareIPC();
- status_t transmitVolumeIPC(uint32_t type, float volume);
- status_t transmitAudioPathIPC(uint32_t path);
-#if defined SYNCHRONIZE_CP
- status_t transmitClock_IPC(uint32_t condition);
-#endif
- private:
- HRilClient mClient;
- char data[100];
- };
-#endif
class AudioHardwareALSA : public AudioHardwareBase
{
public:
@@ -373,34 +286,32 @@ namespace android
// mic mute
virtual status_t setMicMute(bool state);
virtual status_t getMicMute(bool* state);
- virtual size_t getInputBufferSize(
- uint32_t sampleRate,
- int format,
- int channelCount);
-#if defined TURN_ON_DEVICE_ONLY_USE
- virtual int setMicStatus(int on); // To deliver status of input stream(activated or not). If it's activated, doesn't turn off codec.
-#endif
- /** This method creates and opens the audio hardware output stream */
- virtual AudioStreamOut* openOutputStream(
- uint32_t devices,
- int *format=0,
- uint32_t *channels=0,
- uint32_t *sampleRate=0,
- status_t *status=0);
- virtual void closeOutputStream(AudioStreamOut* out);
-
- /** This method creates and opens the audio hardware input stream */
- virtual AudioStreamIn* openInputStream(
- uint32_t devices,
- int *format,
- uint32_t *channels,
- uint32_t *sampleRate,
- status_t *status,
- AudioSystem::audio_in_acoustics acoustics);
- virtual void closeInputStream(AudioStreamIn* in);
-
- static uint32_t checkInputSampleRate(uint32_t sampleRate);
- static const uint32_t inputSamplingRates[];
+ virtual size_t getInputBufferSize(uint32_t sampleRate,
+ int format,
+ int channelCount);
+ virtual int setMicStatus(int on); // To deliver status of input stream(activated or not). If it's activated, doesn't turn off codec.
+
+ /** This method creates and opens the audio hardware output stream */
+ virtual AudioStreamOut* openOutputStream(uint32_t devices,
+ int *format = 0,
+ uint32_t *channels = 0,
+ uint32_t *sampleRate = 0,
+ status_t *status = 0);
+ virtual void closeOutputStream(AudioStreamOut* out);
+
+ /** This method creates and opens the audio hardware input stream */
+ virtual AudioStreamIn* openInputStream(uint32_t devices,
+ int *format,
+ uint32_t *channels,
+ uint32_t *sampleRate,
+ status_t *status,
+ AudioSystem::audio_in_acoustics acoustics);
+ virtual void closeInputStream(AudioStreamIn* in);
+
+ static uint32_t checkInputSampleRate(uint32_t sampleRate);
+ static const uint32_t inputSamplingRates[];
+
+ int mode() { return mMode; }
protected:
/**
@@ -409,34 +320,35 @@ namespace android
* doRouting when required. If the device has any special requirements these
* methods can be overriden.
*/
- virtual status_t doRouting(uint32_t device);
+ virtual status_t doRouting(uint32_t device);
- virtual status_t dump(int fd, const Vector<String16>& args);
+ virtual status_t dump(int fd, const Vector<String16>& args);
friend class AudioStreamOutALSA;
friend class AudioStreamInALSA;
- ALSAMixer *mMixer;
- AudioStreamOutALSA *mOutput;
- AudioStreamInALSA *mInput;
-#if defined SEC_IPC
- AudioHardwareIPC *mIPC; //for IPC
- uint32_t mRoutes[AudioSystem::NUM_MODES];
-#endif
+ ALSAMixer *mMixer;
+ AudioStreamOutALSA *mOutput;
+ AudioStreamInALSA *mInput;
+ uint32_t mRoutes[AudioSystem::NUM_MODES];
private:
- Mutex mLock;
-#if defined TURN_ON_DEVICE_ONLY_USE
- bool mActivatedInputDevice;
-#endif
+ Mutex mLock;
+ bool mActivatedInputDevice;
+
+ void *mSecRilLibHandle;
+ HRilClient mRilClient;
+ HRilClient (*openClientRILD) (void);
+ int (*disconnectRILD) (HRilClient);
+ int (*closeClientRILD) (HRilClient);
+ int (*isConnectedRILD) (HRilClient);
+ int (*connectRILD) (HRilClient);
+ int (*setCallVolume) (HRilClient, SoundType, int);
+ int (*setCallAudioPath)(HRilClient, AudioPath);
+
+ void loadRILD(void);
+ status_t connectRILDIfRequired(void);
};
- // ----------------------------------------------------------------------------
-
-#if defined SEC_IPC
-// sangsu fix : global functions for IPC
-static int onRawReqComplete(HRilClient client, const void *data, size_t datalen);
-static int onUnsol(HRilClient client, const void *data, size_t datalen);
-#endif
}; // namespace android
#endif // ANDROID_AUDIO_HARDWARE_ALSA_H
diff --git a/libaudio/secril-client.h b/libaudio/secril-client.h
index d301566..2473ae7 100755
--- a/libaudio/secril-client.h
+++ b/libaudio/secril-client.h
@@ -1,124 +1,174 @@
-/**
- * @file secril-client.h
- *
- * @author Myeongcheol Kim (mcmount.kim@samsung.com)
- *
- * @brief RIL client library for multi-client support
- */
-
-#ifndef __SECRIL_CLIENT_H__
-#define __SECRIL_CLIENT_H__
-
-#include <sys/types.h>
-
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-struct RilClient
-{
- void *prv;
-};
-
-typedef struct RilClient * HRilClient;
-
-
-//---------------------------------------------------------------------------
-// Defines
-//---------------------------------------------------------------------------
-#define RIL_CLIENT_ERR_SUCCESS 0
-#define RIL_CLIENT_ERR_AGAIN 1
-#define RIL_CLIENT_ERR_INIT 2 // Client is not initialized
-#define RIL_CLIENT_ERR_INVAL 3 // Invalid value
-#define RIL_CLIENT_ERR_CONNECT 4 // Connection error
-#define RIL_CLIENT_ERR_IO 5 // IO error
-#define RIL_CLIENT_ERR_RESOURCE 6 // Resource not available
-#define RIL_CLIENT_ERR_UNKNOWN 7
-
-
-//---------------------------------------------------------------------------
-// Type definitions
-//---------------------------------------------------------------------------
-
-typedef int (*RilOnComplete)(HRilClient handle, const void *data, size_t datalen);
-
-typedef int (*RilOnUnsolicited)(HRilClient handle, const void *data, size_t datalen);
-
-typedef int (*RilOnError)(void *data, int error);
-
-
-//---------------------------------------------------------------------------
-// Client APIs
-//---------------------------------------------------------------------------
-
-/**
- * Open RILD multi-client.
- * Return is client handle, NULL on error.
- */
-HRilClient OpenClient_RILD(void);
-
-/**
- * Stop RILD multi-client. If client socket was connected,
- * it will be disconnected.
- */
-int CloseClient_RILD(HRilClient client);
-
-/**
- * Connect to RIL deamon. One client task starts.
- * Return is 0 or error code.
- */
-int Connect_RILD(HRilClient client);
-
-/**
- * check whether RILD is connected
- * Returns 0 or 1
- */
-int isConnected_RILD(HRilClient client);
-
-/**
- * Disconnect connection to RIL deamon(socket close).
- * Return is 0 or error code.
- */
-int Disconnect_RILD(HRilClient client);
-
-/**
- * Register unsolicited response handler. If handler is NULL,
- * the handler for the request ID is unregistered.
- * The response handler is invoked in the client task context.
- * Return is 0 or error code.
- */
-int RegisterUnsolicitedHandler(HRilClient client, uint32_t id, RilOnUnsolicited handler);
-
-/**
- * Register solicited response handler. If handler is NULL,
- * the handler for the ID is unregistered.
- * The response handler is invoked in the client task context.
- * Return is 0 or error code.
- */
-int RegisterRequestCompleteHandler(HRilClient client, uint32_t id, RilOnComplete handler);
-
-
-/**
- * Register error callback. If handler is NULL,
- * the callback is unregistered.
- * The response handler is invoked in the client task context.
- * Return is 0 or error code.
- */
-int RegisterErrorCallback(HRilClient client, RilOnError cb, void *data);
-
-/**
- * Invoke OEM request. Request ID is RIL_REQUEST_OEM_HOOK_RAW.
- * Return is 0 or error code. For RIL_CLIENT_ERR_AGAIN caller should retry.
- */
-int InvokeOemRequestHookRaw(HRilClient client, char *data, size_t len);
-
-#ifdef __cplusplus
-};
-#endif
-
-#endif // __SECRIL_CLIENT_H__
-
-// end of file
-
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __SECRIL_CLIENT_H__
+#define __SECRIL_CLIENT_H__
+
+#include <sys/types.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct RilClient {
+ void *prv;
+};
+
+typedef struct RilClient * HRilClient;
+
+
+//---------------------------------------------------------------------------
+// Defines
+//---------------------------------------------------------------------------
+#define RIL_CLIENT_ERR_SUCCESS 0
+#define RIL_CLIENT_ERR_AGAIN 1
+#define RIL_CLIENT_ERR_INIT 2 // Client is not initialized
+#define RIL_CLIENT_ERR_INVAL 3 // Invalid value
+#define RIL_CLIENT_ERR_CONNECT 4 // Connection error
+#define RIL_CLIENT_ERR_IO 5 // IO error
+#define RIL_CLIENT_ERR_RESOURCE 6 // Resource not available
+#define RIL_CLIENT_ERR_UNKNOWN 7
+
+
+//---------------------------------------------------------------------------
+// Type definitions
+//---------------------------------------------------------------------------
+
+typedef int (*RilOnComplete)(HRilClient handle, const void *data, size_t datalen);
+
+typedef int (*RilOnUnsolicited)(HRilClient handle, const void *data, size_t datalen);
+
+typedef int (*RilOnError)(void *data, int error);
+
+
+//---------------------------------------------------------------------------
+// Client APIs
+//---------------------------------------------------------------------------
+
+/**
+ * Open RILD multi-client.
+ * Return is client handle, NULL on error.
+ */
+HRilClient OpenClient_RILD(void);
+
+/**
+ * Stop RILD multi-client. If client socket was connected,
+ * it will be disconnected.
+ */
+int CloseClient_RILD(HRilClient client);
+
+/**
+ * Connect to RIL deamon. One client task starts.
+ * Return is 0 or error code.
+ */
+int Connect_RILD(HRilClient client);
+
+/**
+ * check whether RILD is connected
+ * Returns 0 or 1
+ */
+int isConnected_RILD(HRilClient client);
+
+/**
+ * Disconnect connection to RIL deamon(socket close).
+ * Return is 0 or error code.
+ */
+int Disconnect_RILD(HRilClient client);
+
+/**
+ * Register unsolicited response handler. If handler is NULL,
+ * the handler for the request ID is unregistered.
+ * The response handler is invoked in the client task context.
+ * Return is 0 or error code.
+ */
+int RegisterUnsolicitedHandler(HRilClient client, uint32_t id, RilOnUnsolicited handler);
+
+/**
+ * Register solicited response handler. If handler is NULL,
+ * the handler for the ID is unregistered.
+ * The response handler is invoked in the client task context.
+ * Return is 0 or error code.
+ */
+int RegisterRequestCompleteHandler(HRilClient client, uint32_t id, RilOnComplete handler);
+
+/**
+ * Register error callback. If handler is NULL,
+ * the callback is unregistered.
+ * The response handler is invoked in the client task context.
+ * Return is 0 or error code.
+ */
+int RegisterErrorCallback(HRilClient client, RilOnError cb, void *data);
+
+/**
+ * Invoke OEM request. Request ID is RIL_REQUEST_OEM_HOOK_RAW.
+ * Return is 0 or error code. For RIL_CLIENT_ERR_AGAIN caller should retry.
+ */
+int InvokeOemRequestHookRaw(HRilClient client, char *data, size_t len);
+
+/**
+ * Sound device types.
+ */
+typedef enum _SoundType {
+ SOUND_TYPE_VOICE,
+ SOUND_TYPE_SPEAKER,
+ SOUND_TYPE_HEADSET,
+ SOUND_TYPE_BTVOICE
+} SoundType;
+
+/**
+ * External sound device path.
+ */
+typedef enum _AudioPath {
+ SOUND_AUDIO_PATH_HANDSET,
+ SOUND_AUDIO_PATH_HEADSET,
+ SOUND_AUDIO_PATH_SPEAKER,
+ SOUND_AUDIO_PATH_BLUETOOTH,
+ SOUND_AUDIO_PATH_BLUETOOTH_NO_NR
+} AudioPath;
+
+/**
+ * Clock adjustment parameters.
+ */
+typedef enum _SoundClockCondition {
+ SOUND_CLOCK_STOP,
+ SOUND_CLOCK_START
+} SoundClockCondition;
+
+/**
+ * Set in-call volume.
+ */
+int SetCallVolume(HRilClient client, SoundType type, int vol_level);
+
+/**
+ * Set external sound device path for noise reduction.
+ */
+int SetCallAudioPath(HRilClient client, AudioPath path);
+
+/**
+ * Set modem clock to master or slave.
+ */
+int SetCallClockSync(HRilClient client, SoundClockCondition condition);
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif // __SECRIL_CLIENT_H__
+
+// end of file
+
diff --git a/libaudio/secril_stub.c b/libaudio/secril_stub.c
deleted file mode 100644
index 0098804..0000000
--- a/libaudio/secril_stub.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "secril-client.h"
-
-int isConnected_RILD(HRilClient client) {
- return 0;
-}
-
-int Connect_RILD(HRilClient client) {
- return 0;
-}
-
-int InvokeOemRequestHookRaw(HRilClient client, char *data, size_t len) {
- return 0;
-}
-
-int RegisterRequestCompleteHandler(HRilClient client, uint32_t id, RilOnComplete handler) {
- return 0;
-}
-
-int RegisterUnsolicitedHandler(HRilClient client, uint32_t id, RilOnUnsolicited handler) {
- return 0;
-}
-
-int Disconnect_RILD(HRilClient client) {
- return 0;
-}
-
-int CloseClient_RILD(HRilClient client) {
- return 0;
-}
-
-HRilClient OpenClient_RILD(void) {
- return 0;
-}