From e4345cba361a7b4d6ecf87ba42a1d994cbd2ef90 Mon Sep 17 00:00:00 2001 From: Rudolf Tammekivi Date: Wed, 12 Feb 2014 19:13:02 +0200 Subject: [PATCH] legacy/msm7x30: Use new audio API defines. Also fix some error cases where input is routed from the wrong device. Change-Id: Ibee1c54cb42245b88725ff7f001c167da1d9f770 --- legacy/msm7x30/AudioHardware.cpp | 152 ++++++++++++++++--------------- legacy/msm7x30/AudioHardware.h | 10 +- legacy/msm7x30/audio_hw_hal.cpp | 73 --------------- 3 files changed, 83 insertions(+), 152 deletions(-) diff --git a/legacy/msm7x30/AudioHardware.cpp b/legacy/msm7x30/AudioHardware.cpp index a8cd28a..f8b3818 100644 --- a/legacy/msm7x30/AudioHardware.cpp +++ b/legacy/msm7x30/AudioHardware.cpp @@ -390,7 +390,7 @@ static status_t updateDeviceInfo(int rx_device,int tx_device) { isTxDeviceEnabled = true; } if(msm_route_stream(PCM_REC,temp_ptr->dec_id,DEV_ID(temp_ptr->dev_id),0)) { - ALOGE("msm_route_stream(PCM_PLAY,%d,%d,0) failed",temp_ptr->dec_id,DEV_ID(temp_ptr->dev_id)); + ALOGE("msm_route_stream(PCM_REC,%d,%d,0) failed",temp_ptr->dec_id,DEV_ID(temp_ptr->dev_id)); } if(msm_route_stream(PCM_REC,temp_ptr->dec_id,DEV_ID(tx_device),1)) { ALOGE("msm_route_stream(PCM_REC,%d,%d,1) failed",temp_ptr->dec_id,DEV_ID(tx_device)); @@ -615,6 +615,9 @@ AudioStreamOut* AudioHardware::openOutputStream( audio_output_flags_t flags = static_cast (*status); + if (!audio_is_output_device(devices)) + return 0; + { // scope for the lock Mutex::Autolock lock(mLock); @@ -719,14 +722,13 @@ AudioStreamIn* AudioHardware::openInputStream( ALOGD("AudioHardware::openInputStream devices %x format %d channels %d samplerate %d", devices, *format, *channels, *sampleRate); - if (!AudioSystem::isInputDevice((AudioSystem::audio_devices)devices)) { + if (!audio_is_input_device(devices)) return 0; - } mLock.lock(); AudioStreamIn *in; - if((devices == AudioSystem::DEVICE_IN_COMMUNICATION)&& (*sampleRate == 8000)) { + if((devices == AUDIO_DEVICE_IN_COMMUNICATION)&& (*sampleRate == 8000)) { ALOGV("Create Audio stream Voip \n"); AudioStreamInVoip* inVoip = new AudioStreamInVoip(); status_t lStatus = NO_ERROR; @@ -814,7 +816,7 @@ status_t AudioHardware::setMicMute_nosync(bool state) if (mMicMute != state) { mMicMute = state; ALOGD("setMicMute_nosync calling voice mute with the mMicMute %d", mMicMute); - if (isStreamOnAndActive(PCM_REC) && (mMode == AudioSystem::MODE_IN_COMMUNICATION)) { + if (isStreamOnAndActive(PCM_REC) && (mMode == AUDIO_MODE_IN_COMMUNICATION)) { vMicMute = state; ALOGD("VOIP Active: vMicMute %d\n", vMicMute); msm_device_mute(DEV_ID(cur_tx), vMicMute); @@ -891,11 +893,11 @@ status_t AudioHardware::setParameters(const String8& keyValuePairs) } else { mTtyMode = TTY_OFF; } - if(mMode != AudioSystem::MODE_IN_CALL){ + if(mMode != AUDIO_MODE_IN_CALL){ return NO_ERROR; } ALOGI("Changed TTY Mode=%s", value.string()); - if((mMode == AudioSystem::MODE_IN_CALL) && + if((mMode == AUDIO_MODE_IN_CALL) && (cur_rx == DEVICE_HEADSET_RX) && (cur_tx == DEVICE_HEADSET_TX)) doRouting(NULL); @@ -1284,20 +1286,20 @@ status_t AudioHardware::doRouting(AudioStreamInMSM72xx *input, int outputDevice) // ignore routing device information when we start a recording in voice // call // Recording will happen through currently active tx device - if((inputDevice == AudioSystem::DEVICE_IN_VOICE_CALL) + if((inputDevice == AUDIO_DEVICE_IN_VOICE_CALL) #ifdef QCOM_FM_ENABLED - || (inputDevice == AudioSystem::DEVICE_IN_FM_RX) - || (inputDevice == AudioSystem::DEVICE_IN_FM_RX_A2DP) + || (inputDevice == AUDIO_DEVICE_IN_FM_RX) + || (inputDevice == AUDIO_DEVICE_IN_FM_RX_A2DP) #endif ) return NO_ERROR; - if (inputDevice != 0) { - if (inputDevice & AudioSystem::DEVICE_IN_BLUETOOTH_SCO_HEADSET) { + if (inputDevice & AUDIO_DEVICE_BIT_IN) { + if (inputDevice == AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET) { ALOGI("Routing audio to Bluetooth PCM\n"); sndDevice = SND_DEVICE_BT; - } else if (inputDevice & AudioSystem::DEVICE_IN_WIRED_HEADSET) { - if ((outputDevices & AudioSystem::DEVICE_OUT_WIRED_HEADSET) && - (outputDevices & AudioSystem::DEVICE_OUT_SPEAKER)) { + } else if (inputDevice == AUDIO_DEVICE_IN_WIRED_HEADSET) { + if ((outputDevices & AUDIO_DEVICE_OUT_WIRED_HEADSET) && + (outputDevices & AUDIO_DEVICE_OUT_SPEAKER)) { ALOGI("Routing audio to Wired Headset and Speaker\n"); sndDevice = SND_DEVICE_HEADSET_AND_SPEAKER; audProcess = (ADRC_ENABLE | EQ_ENABLE | RX_IIR_ENABLE | MBADRC_ENABLE); @@ -1306,10 +1308,10 @@ status_t AudioHardware::doRouting(AudioStreamInMSM72xx *input, int outputDevice) sndDevice = SND_DEVICE_HEADSET; } } else { - if (outputDevices == AudioSystem::DEVICE_OUT_WIRED_HEADPHONE) { + if (outputDevices == AUDIO_DEVICE_OUT_WIRED_HEADPHONE) { ALOGI("Routing audio to Speakerphone\n"); sndDevice = SND_DEVICE_NO_MIC_HEADSET; - } else if (outputDevices & AudioSystem::DEVICE_OUT_EARPIECE) { + } else if (outputDevices & AUDIO_DEVICE_OUT_EARPIECE) { ALOGI("Routing audio to Handset\n"); sndDevice = SND_DEVICE_HANDSET; } else { @@ -1318,18 +1320,17 @@ status_t AudioHardware::doRouting(AudioStreamInMSM72xx *input, int outputDevice) } } } - // if inputDevice == 0, restore output routing } if (sndDevice == -1) { if (outputDevices & (outputDevices - 1)) { - if ((outputDevices & AudioSystem::DEVICE_OUT_SPEAKER) == 0) { + if ((outputDevices & AUDIO_DEVICE_OUT_SPEAKER) == 0) { ALOGW("Hardware does not support requested route combination (%#X)," " picking closest possible route...", outputDevices); } } - if ((mTtyMode != TTY_OFF) && (mMode == AudioSystem::MODE_IN_CALL) && - (outputDevices & AudioSystem::DEVICE_OUT_WIRED_HEADSET)) { + if ((mTtyMode != TTY_OFF) && (mMode == AUDIO_MODE_IN_CALL) && + (outputDevices & AUDIO_DEVICE_OUT_WIRED_HEADSET)) { if (mTtyMode == TTY_FULL) { ALOGI("Routing audio to TTY FULL Mode\n"); sndDevice = SND_DEVICE_TTY_FULL; @@ -1341,32 +1342,32 @@ status_t AudioHardware::doRouting(AudioStreamInMSM72xx *input, int outputDevice) sndDevice = SND_DEVICE_TTY_HCO; } } else if (outputDevices & - (AudioSystem::DEVICE_OUT_BLUETOOTH_SCO | AudioSystem::DEVICE_OUT_BLUETOOTH_SCO_HEADSET)) { + (AUDIO_DEVICE_OUT_BLUETOOTH_SCO | AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET)) { ALOGI("Routing audio to Bluetooth PCM\n"); sndDevice = SND_DEVICE_BT; - } else if (outputDevices & AudioSystem::DEVICE_OUT_BLUETOOTH_SCO_CARKIT) { + } else if (outputDevices & AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT) { ALOGI("Routing audio to Bluetooth PCM\n"); sndDevice = SND_DEVICE_CARKIT; - } else if (outputDevices & AudioSystem::DEVICE_OUT_AUX_DIGITAL) { + } else if (outputDevices & AUDIO_DEVICE_OUT_AUX_DIGITAL) { ALOGI("Routing audio to HDMI\n"); sndDevice = SND_DEVICE_HDMI; - } else if ((outputDevices & AudioSystem::DEVICE_OUT_WIRED_HEADSET) && - (outputDevices & AudioSystem::DEVICE_OUT_SPEAKER)) { + } else if ((outputDevices & AUDIO_DEVICE_OUT_WIRED_HEADSET) && + (outputDevices & AUDIO_DEVICE_OUT_SPEAKER)) { ALOGI("Routing audio to Wired Headset and Speaker\n"); sndDevice = SND_DEVICE_HEADSET_AND_SPEAKER; audProcess = (ADRC_ENABLE | EQ_ENABLE | RX_IIR_ENABLE | MBADRC_ENABLE); } #ifdef QCOM_FM_ENABLED - else if ((outputDevices & AudioSystem::DEVICE_OUT_FM_TX) && - (outputDevices & AudioSystem::DEVICE_OUT_SPEAKER)) { + else if ((outputDevices & AUDIO_DEVICE_OUT_FM_TX) && + (outputDevices & AUDIO_DEVICE_OUT_SPEAKER)) { ALOGI("Routing audio to FM Tx and Speaker\n"); sndDevice = SND_DEVICE_FM_TX_AND_SPEAKER; enableComboDevice(sndDevice,1); audProcess = (ADRC_ENABLE | EQ_ENABLE | RX_IIR_ENABLE | MBADRC_ENABLE); } #endif - else if (outputDevices & AudioSystem::DEVICE_OUT_WIRED_HEADPHONE) { - if (outputDevices & AudioSystem::DEVICE_OUT_SPEAKER) { + else if (outputDevices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE) { + if (outputDevices & AUDIO_DEVICE_OUT_SPEAKER) { ALOGI("Routing audio to No microphone Wired Headset and Speaker (%d,%x)\n", mMode, outputDevices); sndDevice = SND_DEVICE_HEADPHONE_AND_SPEAKER; audProcess = (ADRC_ENABLE | EQ_ENABLE | RX_IIR_ENABLE | MBADRC_ENABLE); @@ -1374,21 +1375,21 @@ status_t AudioHardware::doRouting(AudioStreamInMSM72xx *input, int outputDevice) ALOGI("Routing audio to No microphone Wired Headset (%d,%x)\n", mMode, outputDevices); sndDevice = SND_DEVICE_NO_MIC_HEADSET; } - } else if (outputDevices & AudioSystem::DEVICE_OUT_WIRED_HEADSET) { + } else if (outputDevices & AUDIO_DEVICE_OUT_WIRED_HEADSET) { ALOGI("Routing audio to Wired Headset\n"); sndDevice = SND_DEVICE_HEADSET; audProcess = (ADRC_ENABLE | EQ_ENABLE | RX_IIR_ENABLE | MBADRC_ENABLE); - } else if (outputDevices & AudioSystem::DEVICE_OUT_SPEAKER) { + } else if (outputDevices & AUDIO_DEVICE_OUT_SPEAKER) { ALOGI("Routing audio to Speakerphone\n"); sndDevice = SND_DEVICE_SPEAKER; audProcess = (ADRC_ENABLE | EQ_ENABLE | RX_IIR_ENABLE | MBADRC_ENABLE); - } else if(outputDevices & AudioSystem::DEVICE_OUT_EARPIECE){ + } else if(outputDevices & AUDIO_DEVICE_OUT_EARPIECE){ ALOGI("Routing audio to Handset\n"); sndDevice = SND_DEVICE_HANDSET; audProcess = (ADRC_ENABLE | EQ_ENABLE | RX_IIR_ENABLE | MBADRC_ENABLE); } #ifdef QCOM_FM_ENABLED - else if(outputDevices & AudioSystem::DEVICE_OUT_FM_TX){ + else if(outputDevices & AUDIO_DEVICE_OUT_FM_TX){ ALOGI("Routing audio to FM Tx Device\n"); sndDevice = SND_DEVICE_FM_TX; audProcess = (ADRC_ENABLE | EQ_ENABLE | RX_IIR_ENABLE | MBADRC_ENABLE); @@ -1396,7 +1397,7 @@ status_t AudioHardware::doRouting(AudioStreamInMSM72xx *input, int outputDevice) #endif } - if (mDualMicEnabled && mMode == AudioSystem::MODE_IN_CALL) { + if (mDualMicEnabled && mMode == AUDIO_MODE_IN_CALL) { if (sndDevice == SND_DEVICE_HANDSET) { ALOGI("Routing audio to handset with DualMike enabled\n"); sndDevice = SND_DEVICE_IN_S_SADC_OUT_HANDSET; @@ -1605,7 +1606,7 @@ status_t AudioHardware::disableFM() status_t AudioHardware::checkMicMute() { Mutex::Autolock lock(mLock); - if (mMode != AudioSystem::MODE_IN_CALL) { + if (mMode != AUDIO_MODE_IN_CALL) { setMicMute_nosync(true); } @@ -1918,10 +1919,13 @@ status_t AudioHardware::AudioStreamOutMSM72xx::setParameters(const String8& keyV key = String8(AudioParameter::keyHandleFm); if (param.getInt(key, device) == NO_ERROR) { - if (device & AUDIO_DEVICE_OUT_FM) + if (device & AUDIO_DEVICE_OUT_FM) { + mDevices |= device; mHardware->enableFM(); - else + } else { mHardware->disableFM(); + mDevices &= device; + } param.remove(key); } #endif @@ -1962,7 +1966,7 @@ status_t AudioHardware::AudioStreamOutMSM72xx::getRenderPosition(uint32_t *dspFr } AudioHardware::AudioStreamOutDirect::AudioStreamOutDirect() : - mHardware(0), mFd(-1), mStartCount(0), mRetryCount(0), mStandby(true), mDevices(0),mChannels(AudioSystem::CHANNEL_OUT_MONO), + mHardware(0), mFd(-1), mStartCount(0), mRetryCount(0), mStandby(true), mDevices(0),mChannels(AUDIO_CHANNEL_OUT_MONO), mSampleRate(AUDIO_HW_VOIP_SAMPLERATE_8K), mBufferSize(AUDIO_HW_VOIP_BUFFERSIZE_8K) { } @@ -2306,7 +2310,7 @@ status_t AudioHardware::AudioStreamInMSM72xx::set( return BAD_VALUE; } - if((*pFormat == AUDIO_FORMAT_AAC) && (*pChannels & (AudioSystem::CHANNEL_IN_VOICE_DNLINK | AudioSystem::CHANNEL_IN_VOICE_UPLINK))) { + if((*pFormat == AUDIO_FORMAT_AAC) && (*pChannels & (AUDIO_CHANNEL_IN_VOICE_DNLINK | AUDIO_CHANNEL_IN_VOICE_UPLINK))) { ALOGE("voice call recording in AAC format does not support"); return BAD_VALUE; } @@ -2320,7 +2324,7 @@ status_t AudioHardware::AudioStreamInMSM72xx::set( return BAD_VALUE; } - if (pChannels == 0 || (*pChannels & (AudioSystem::CHANNEL_IN_MONO | AudioSystem::CHANNEL_IN_STEREO)) == 0) { + if (pChannels == 0 || (*pChannels & (AUDIO_CHANNEL_IN_MONO | AUDIO_CHANNEL_IN_STEREO)) == 0) { *pChannels = AUDIO_HW_IN_CHANNELS; return BAD_VALUE; } @@ -2335,7 +2339,7 @@ status_t AudioHardware::AudioStreamInMSM72xx::set( status_t status =0; struct msm_voicerec_mode voc_rec_cfg; #ifdef QCOM_FM_ENABLED - if(devices == AudioSystem::DEVICE_IN_FM_RX_A2DP) { + if(devices == AUDIO_DEVICE_IN_FM_RX_A2DP) { status = ::open("/dev/msm_a2dp_in", O_RDONLY); if (status < 0) { ALOGE("Cannot open /dev/msm_a2dp_in errno: %d", errno); @@ -2352,7 +2356,7 @@ status_t AudioHardware::AudioStreamInMSM72xx::set( } ALOGV("set config"); - config.channel_count = AudioSystem::popCount((*pChannels) & (AudioSystem::CHANNEL_IN_STEREO | AudioSystem::CHANNEL_IN_MONO)); + config.channel_count = AudioSystem::popCount((*pChannels) & (AUDIO_CHANNEL_IN_STEREO | AUDIO_CHANNEL_IN_MONO)); config.sample_rate = *pRate; config.buffer_size = bufferSize(); config.buffer_count = 2; @@ -2362,9 +2366,9 @@ status_t AudioHardware::AudioStreamInMSM72xx::set( ALOGE("Cannot set config"); if (ioctl(mFd, AUDIO_GET_CONFIG, &config) == 0) { if (config.channel_count == 1) { - *pChannels = AudioSystem::CHANNEL_IN_MONO; + *pChannels = AUDIO_CHANNEL_IN_MONO; } else { - *pChannels = AudioSystem::CHANNEL_IN_STEREO; + *pChannels = AUDIO_CHANNEL_IN_STEREO; } *pRate = config.sample_rate; } @@ -2410,7 +2414,7 @@ status_t AudioHardware::AudioStreamInMSM72xx::set( } ALOGV("set config"); - config.channel_count = AudioSystem::popCount((*pChannels) & (AudioSystem::CHANNEL_IN_STEREO | AudioSystem::CHANNEL_IN_MONO)); + config.channel_count = AudioSystem::popCount((*pChannels) & (AUDIO_CHANNEL_IN_STEREO | AUDIO_CHANNEL_IN_MONO)); config.sample_rate = *pRate; config.buffer_size = bufferSize(); config.buffer_count = 2; @@ -2431,9 +2435,9 @@ status_t AudioHardware::AudioStreamInMSM72xx::set( ALOGE("Cannot set config"); if (ioctl(mFd, AUDIO_GET_CONFIG, &config) == 0) { if (config.channel_count == 1) { - *pChannels = AudioSystem::CHANNEL_IN_MONO; + *pChannels = AUDIO_CHANNEL_IN_MONO; } else { - *pChannels = AudioSystem::CHANNEL_IN_STEREO; + *pChannels = AUDIO_CHANNEL_IN_STEREO; } *pRate = config.sample_rate; } @@ -2454,16 +2458,16 @@ status_t AudioHardware::AudioStreamInMSM72xx::set( mDevices = devices; mFormat = AUDIO_HW_IN_FORMAT; mChannels = *pChannels; - if (mDevices == AudioSystem::DEVICE_IN_VOICE_CALL) + if (mDevices == AUDIO_DEVICE_IN_VOICE_CALL) { - if ((mChannels & AudioSystem::CHANNEL_IN_VOICE_DNLINK) && - (mChannels & AudioSystem::CHANNEL_IN_VOICE_UPLINK)) { + if ((mChannels & AUDIO_CHANNEL_IN_VOICE_DNLINK) && + (mChannels & AUDIO_CHANNEL_IN_VOICE_UPLINK)) { ALOGI("Recording Source: Voice Call Both Uplink and Downlink"); voc_rec_cfg.rec_mode = VOC_REC_BOTH; - } else if (mChannels & AudioSystem::CHANNEL_IN_VOICE_DNLINK) { + } else if (mChannels & AUDIO_CHANNEL_IN_VOICE_DNLINK) { ALOGI("Recording Source: Voice Call DownLink"); voc_rec_cfg.rec_mode = VOC_REC_DOWNLINK; - } else if (mChannels & AudioSystem::CHANNEL_IN_VOICE_UPLINK) { + } else if (mChannels & AUDIO_CHANNEL_IN_VOICE_UPLINK) { ALOGI("Recording Source: Voice Call UpLink"); voc_rec_cfg.rec_mode = VOC_REC_UPLINK; } @@ -2489,16 +2493,16 @@ status_t AudioHardware::AudioStreamInMSM72xx::set( mDevices = devices; mChannels = *pChannels; - if (mDevices == AudioSystem::DEVICE_IN_VOICE_CALL) + if (mDevices == AUDIO_DEVICE_IN_VOICE_CALL) { - if ((mChannels & AudioSystem::CHANNEL_IN_VOICE_DNLINK) && - (mChannels & AudioSystem::CHANNEL_IN_VOICE_UPLINK)) { + if ((mChannels & AUDIO_CHANNEL_IN_VOICE_DNLINK) && + (mChannels & AUDIO_CHANNEL_IN_VOICE_UPLINK)) { ALOGI("Recording Source: Voice Call Both Uplink and Downlink"); voc_rec_cfg.rec_mode = VOC_REC_BOTH; - } else if (mChannels & AudioSystem::CHANNEL_IN_VOICE_DNLINK) { + } else if (mChannels & AUDIO_CHANNEL_IN_VOICE_DNLINK) { ALOGI("Recording Source: Voice Call DownLink"); voc_rec_cfg.rec_mode = VOC_REC_DOWNLINK; - } else if (mChannels & AudioSystem::CHANNEL_IN_VOICE_UPLINK) { + } else if (mChannels & AUDIO_CHANNEL_IN_VOICE_UPLINK) { ALOGI("Recording Source: Voice Call UpLink"); voc_rec_cfg.rec_mode = VOC_REC_UPLINK; } @@ -2558,16 +2562,16 @@ status_t AudioHardware::AudioStreamInMSM72xx::set( mDevices = devices; mChannels = *pChannels; - if (mDevices == AudioSystem::DEVICE_IN_VOICE_CALL) + if (mDevices == AUDIO_DEVICE_IN_VOICE_CALL) { - if ((mChannels & AudioSystem::CHANNEL_IN_VOICE_DNLINK) && - (mChannels & AudioSystem::CHANNEL_IN_VOICE_UPLINK)) { + if ((mChannels & AUDIO_CHANNEL_IN_VOICE_DNLINK) && + (mChannels & AUDIO_CHANNEL_IN_VOICE_UPLINK)) { ALOGI("Recording Source: Voice Call Both Uplink and Downlink"); voc_rec_cfg.rec_mode = VOC_REC_BOTH; - } else if (mChannels & AudioSystem::CHANNEL_IN_VOICE_DNLINK) { + } else if (mChannels & AUDIO_CHANNEL_IN_VOICE_DNLINK) { ALOGI("Recording Source: Voice Call DownLink"); voc_rec_cfg.rec_mode = VOC_REC_DOWNLINK; - } else if (mChannels & AudioSystem::CHANNEL_IN_VOICE_UPLINK) { + } else if (mChannels & AUDIO_CHANNEL_IN_VOICE_UPLINK) { ALOGI("Recording Source: Voice Call UpLink"); voc_rec_cfg.rec_mode = VOC_REC_UPLINK; } @@ -2628,16 +2632,16 @@ status_t AudioHardware::AudioStreamInMSM72xx::set( mDevices = devices; mChannels = *pChannels; - if (mDevices == AudioSystem::DEVICE_IN_VOICE_CALL) + if (mDevices == AUDIO_DEVICE_IN_VOICE_CALL) { - if ((mChannels & AudioSystem::CHANNEL_IN_VOICE_DNLINK) && - (mChannels & AudioSystem::CHANNEL_IN_VOICE_UPLINK)) { + if ((mChannels & AUDIO_CHANNEL_IN_VOICE_DNLINK) && + (mChannels & AUDIO_CHANNEL_IN_VOICE_UPLINK)) { ALOGI("Recording Source: Voice Call Both Uplink and Downlink"); voc_rec_cfg.rec_mode = VOC_REC_BOTH; - } else if (mChannels & AudioSystem::CHANNEL_IN_VOICE_DNLINK) { + } else if (mChannels & AUDIO_CHANNEL_IN_VOICE_DNLINK) { ALOGI("Recording Source: Voice Call DownLink"); voc_rec_cfg.rec_mode = VOC_REC_DOWNLINK; - } else if (mChannels & AudioSystem::CHANNEL_IN_VOICE_UPLINK) { + } else if (mChannels & AUDIO_CHANNEL_IN_VOICE_UPLINK) { ALOGI("Recording Source: Voice Call UpLink"); voc_rec_cfg.rec_mode = VOC_REC_UPLINK; } @@ -2724,9 +2728,9 @@ status_t AudioHardware::AudioStreamInMSM72xx::set( aac_enc_cfg.sample_rate = mSampleRate = *pRate; mFormat = *pFormat; mBufferSize = 2048; - if (*pChannels & (AudioSystem::CHANNEL_IN_MONO)) + if (*pChannels & (AUDIO_CHANNEL_IN_MONO)) aac_enc_cfg.channels = 1; - else if (*pChannels & (AudioSystem::CHANNEL_IN_STEREO)) + else if (*pChannels & (AUDIO_CHANNEL_IN_STEREO)) aac_enc_cfg.channels = 2; aac_enc_cfg.bit_rate = 128000; @@ -2805,7 +2809,7 @@ ssize_t AudioHardware::AudioStreamInMSM72xx::read( void* buffer, ssize_t bytes) return -1; } #ifdef QCOM_FM_ENABLED - if((mDevices == AudioSystem::DEVICE_IN_FM_RX) || (mDevices == AudioSystem::DEVICE_IN_FM_RX_A2DP) ){ + if((mDevices == AUDIO_DEVICE_IN_FM_RX) || (mDevices == AUDIO_DEVICE_IN_FM_RX_A2DP) ){ if(ioctl(mFd, AUDIO_GET_SESSION_ID, &dec_id)) { ALOGE("AUDIO_GET_SESSION_ID failed*********"); hw->mLock.unlock(); @@ -2824,7 +2828,7 @@ ssize_t AudioHardware::AudioStreamInMSM72xx::read( void* buffer, ssize_t bytes) return -1; } mFirstread = false; - if (mDevices == AudioSystem::DEVICE_IN_FM_RX_A2DP) { + if (mDevices == AUDIO_DEVICE_IN_FM_RX_A2DP) { addToTable(dec_id,cur_tx,INVALID_DEVICE,FM_A2DP,true); mFmRec = FM_A2DP_REC; } @@ -3916,7 +3920,7 @@ status_t AudioHardware::AudioSessionOutLPA::getRenderPosition(uint32_t *dspFrame status_t AudioHardware::setupDeviceforVoipCall(bool value) { - int mode = (value ? AudioSystem::MODE_IN_COMMUNICATION : AudioSystem::MODE_NORMAL); + int mode = (value ? AUDIO_MODE_IN_COMMUNICATION : AUDIO_MODE_NORMAL); if (setMode(mode) != NO_ERROR) { ALOGV("setMode fails"); return UNKNOWN_ERROR; @@ -4010,7 +4014,7 @@ status_t AudioHardware::AudioStreamInVoip::set( return BAD_VALUE; } - if (pChannels == 0 || (*pChannels & (AudioSystem::CHANNEL_IN_MONO)) == 0) { + if (pChannels == 0 || (*pChannels & (AUDIO_CHANNEL_IN_MONO)) == 0) { *pChannels = AUDIO_HW_IN_CHANNELS; ALOGE(" Channle count does not match\n"); return BAD_VALUE; diff --git a/legacy/msm7x30/AudioHardware.h b/legacy/msm7x30/AudioHardware.h index e197e47..05b4f4a 100644 --- a/legacy/msm7x30/AudioHardware.h +++ b/legacy/msm7x30/AudioHardware.h @@ -212,9 +212,9 @@ enum tty_modes { #define AUDIO_HW_OUT_LATENCY_MS 0 // Additionnal latency introduced by audio DSP and hardware in ms #define AUDIO_HW_IN_SAMPLERATE 8000 // Default audio input sample rate -#define AUDIO_HW_IN_CHANNELS (AudioSystem::CHANNEL_IN_MONO) // Default audio input channel mask +#define AUDIO_HW_IN_CHANNELS (AUDIO_CHANNEL_IN_MONO) // Default audio input channel mask #define AUDIO_HW_IN_BUFFERSIZE 2048 // Default audio input buffer size -#define AUDIO_HW_IN_FORMAT (AudioSystem::PCM_16_BIT) // Default audio input sample format +#define AUDIO_HW_IN_FORMAT (AUDIO_FORMAT_PCM_16_BIT) // Default audio input sample format #define AUDIO_HW_VOIP_BUFFERSIZE_8K 320 #define AUDIO_HW_VOIP_BUFFERSIZE_16K 640 #define AUDIO_HW_VOIP_SAMPLERATE_8K 8000 @@ -356,8 +356,8 @@ class AudioHardware : public AudioHardwareBase virtual uint32_t sampleRate() const { return 44100; } // must be 32-bit aligned - driver only seems to like 4800 virtual size_t bufferSize() const { return 4800; } - virtual uint32_t channels() const { return AudioSystem::CHANNEL_OUT_STEREO; } - virtual int format() const { return AudioSystem::PCM_16_BIT; } + virtual uint32_t channels() const { return AUDIO_CHANNEL_OUT_STEREO; } + virtual int format() const { return AUDIO_FORMAT_PCM_16_BIT; } virtual uint32_t latency() const { return (1000*AUDIO_HW_NUM_OUT_BUF*(bufferSize()/frameSize()))/sampleRate()+AUDIO_HW_OUT_LATENCY_MS; } virtual status_t setVolume(float left, float right) { return INVALID_OPERATION; } virtual ssize_t write(const void* buffer, size_t bytes); @@ -390,7 +390,7 @@ class AudioHardware : public AudioHardwareBase // must be 32-bit aligned - driver only seems to like 4800 virtual size_t bufferSize() const { ALOGE(" AudioStreamOutDirect: bufferSize\n"); return 320; } virtual uint32_t channels() const {ALOGD(" AudioStreamOutDirect: channels\n"); return mChannels; } - virtual int format() const {ALOGE(" AudioStreamOutDirect: format\n"); return AudioSystem::PCM_16_BIT; } + virtual int format() const {ALOGE(" AudioStreamOutDirect: format\n"); return AUDIO_FORMAT_PCM_16_BIT; } virtual uint32_t latency() const { return (1000*AUDIO_HW_NUM_OUT_BUF*(bufferSize()/frameSize()))/sampleRate()+AUDIO_HW_OUT_LATENCY_MS; } virtual status_t setVolume(float left, float right) { return INVALID_OPERATION; } virtual ssize_t write(const void* buffer, size_t bytes); diff --git a/legacy/msm7x30/audio_hw_hal.cpp b/legacy/msm7x30/audio_hw_hal.cpp index 789ad68..5d262b0 100644 --- a/legacy/msm7x30/audio_hw_hal.cpp +++ b/legacy/msm7x30/audio_hw_hal.cpp @@ -55,73 +55,6 @@ struct qcom_stream_in { AudioStreamIn *qcom_in; }; -enum { - HAL_API_REV_1_0, - HAL_API_REV_2_0, - HAL_API_REV_NUM -} hal_api_rev; -static uint32_t audio_device_conv_table[][HAL_API_REV_NUM] = -{ - /* output devices */ - { AudioSystem::DEVICE_OUT_EARPIECE, AUDIO_DEVICE_OUT_EARPIECE }, - { AudioSystem::DEVICE_OUT_SPEAKER, AUDIO_DEVICE_OUT_SPEAKER }, - { AudioSystem::DEVICE_OUT_WIRED_HEADSET, AUDIO_DEVICE_OUT_WIRED_HEADSET }, - { AudioSystem::DEVICE_OUT_WIRED_HEADPHONE, AUDIO_DEVICE_OUT_WIRED_HEADPHONE }, - { AudioSystem::DEVICE_OUT_BLUETOOTH_SCO, AUDIO_DEVICE_OUT_BLUETOOTH_SCO }, - { AudioSystem::DEVICE_OUT_BLUETOOTH_SCO_HEADSET, AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET }, - { AudioSystem::DEVICE_OUT_BLUETOOTH_SCO_CARKIT, AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT }, - { AudioSystem::DEVICE_OUT_BLUETOOTH_A2DP, AUDIO_DEVICE_OUT_BLUETOOTH_A2DP }, - { AudioSystem::DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES, AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES }, - { AudioSystem::DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER, AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER }, - { AudioSystem::DEVICE_OUT_AUX_DIGITAL, AUDIO_DEVICE_OUT_AUX_DIGITAL }, - { AudioSystem::DEVICE_OUT_ANLG_DOCK_HEADSET, AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET }, - { AudioSystem::DEVICE_OUT_DGTL_DOCK_HEADSET, AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET }, -#ifdef QCOM_FM_ENABLED - { AudioSystem::DEVICE_OUT_FM, AUDIO_DEVICE_OUT_FM }, - { AudioSystem::DEVICE_OUT_FM_TX, AUDIO_DEVICE_OUT_FM_TX }, -#endif - { AudioSystem::DEVICE_OUT_DEFAULT, AUDIO_DEVICE_OUT_DEFAULT }, - /* input devices */ - { AudioSystem::DEVICE_IN_COMMUNICATION, AUDIO_DEVICE_IN_COMMUNICATION }, - { AudioSystem::DEVICE_IN_AMBIENT, AUDIO_DEVICE_IN_AMBIENT }, - { AudioSystem::DEVICE_IN_BUILTIN_MIC, AUDIO_DEVICE_IN_BUILTIN_MIC }, - { AudioSystem::DEVICE_IN_BLUETOOTH_SCO_HEADSET, AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET }, - { AudioSystem::DEVICE_IN_WIRED_HEADSET, AUDIO_DEVICE_IN_WIRED_HEADSET }, - { AudioSystem::DEVICE_IN_AUX_DIGITAL, AUDIO_DEVICE_IN_AUX_DIGITAL }, - { AudioSystem::DEVICE_IN_VOICE_CALL, AUDIO_DEVICE_IN_VOICE_CALL }, - { AudioSystem::DEVICE_IN_BACK_MIC, AUDIO_DEVICE_IN_BACK_MIC }, -#ifdef QCOM_FM_ENABLED - { AudioSystem::DEVICE_IN_FM_RX, AUDIO_DEVICE_IN_FM_RX }, - { AudioSystem::DEVICE_IN_FM_RX_A2DP, AUDIO_DEVICE_IN_FM_RX_A2DP }, -#endif - { AudioSystem::DEVICE_IN_DEFAULT, AUDIO_DEVICE_IN_DEFAULT }, -}; - -static uint32_t convert_audio_device(uint32_t from_device, int from_rev, int to_rev) -{ - const uint32_t k_num_devices = sizeof(audio_device_conv_table)/sizeof(uint32_t)/HAL_API_REV_NUM; - uint32_t to_device = AUDIO_DEVICE_NONE; - uint32_t in_bit = 0; - - if (from_rev != HAL_API_REV_1_0) { - in_bit = from_device & AUDIO_DEVICE_BIT_IN; - from_device &= ~AUDIO_DEVICE_BIT_IN; - } - - while (from_device) { - uint32_t i = 31 - __builtin_clz(from_device); - uint32_t cur_device = (1 << i) | in_bit; - - for (i = 0; i < k_num_devices; i++) { - if (audio_device_conv_table[i][from_rev] == cur_device) { - to_device |= audio_device_conv_table[i][to_rev]; - break; - } - } - from_device &= ~cur_device; - } - return to_device; -} /** audio_stream_out implementation **/ static uint32_t out_get_sample_rate(const struct audio_stream *stream) { @@ -194,7 +127,6 @@ static int out_set_parameters(struct audio_stream *stream, const char *kvpairs) AudioParameter parms = AudioParameter(String8(kvpairs)); if (parms.getInt(String8(AUDIO_PARAMETER_STREAM_ROUTING), val) == NO_ERROR) { - val = convert_audio_device(val, HAL_API_REV_2_0, HAL_API_REV_1_0); parms.remove(String8(AUDIO_PARAMETER_STREAM_ROUTING)); parms.addInt(String8(AUDIO_PARAMETER_STREAM_ROUTING), val); s8 = parms.toString(); @@ -211,7 +143,6 @@ static char * out_get_parameters(const struct audio_stream *stream, const char * s8 = out->qcom_out->getParameters(String8(keys)); AudioParameter parms = AudioParameter(s8); if (parms.getInt(String8(AUDIO_PARAMETER_STREAM_ROUTING), val) == NO_ERROR) { - val = convert_audio_device(val, HAL_API_REV_1_0, HAL_API_REV_2_0); parms.remove(String8(AUDIO_PARAMETER_STREAM_ROUTING)); parms.addInt(String8(AUDIO_PARAMETER_STREAM_ROUTING), val); s8 = parms.toString(); @@ -391,7 +322,6 @@ static int in_set_parameters(struct audio_stream *stream, const char *kvpairs) String8 s8 = String8(kvpairs); if (parms.getInt(String8(AUDIO_PARAMETER_STREAM_ROUTING), val) == NO_ERROR) { - val = convert_audio_device(val, HAL_API_REV_2_0, HAL_API_REV_1_0); parms.remove(String8(AUDIO_PARAMETER_STREAM_ROUTING)); parms.addInt(String8(AUDIO_PARAMETER_STREAM_ROUTING), val); s8 = parms.toString(); @@ -409,7 +339,6 @@ static char * in_get_parameters(const struct audio_stream *stream, s8 = in->qcom_in->getParameters(String8(keys)); AudioParameter parms = AudioParameter(s8); if (parms.getInt(String8(AUDIO_PARAMETER_STREAM_ROUTING), val) == NO_ERROR) { - val = convert_audio_device(val, HAL_API_REV_1_0, HAL_API_REV_2_0); parms.remove(String8(AUDIO_PARAMETER_STREAM_ROUTING)); parms.addInt(String8(AUDIO_PARAMETER_STREAM_ROUTING), val); s8 = parms.toString(); @@ -604,7 +533,6 @@ static int adev_open_output_stream(struct audio_hw_device *dev, if (!out) return -ENOMEM; - devices = convert_audio_device(devices, HAL_API_REV_2_0, HAL_API_REV_1_0); status = static_cast (flags); out->qcom_out = qadev->hwif->openOutputStream(devices, (int *) &config->format, @@ -676,7 +604,6 @@ static int adev_open_input_stream(struct audio_hw_device *dev, if (!in) return -ENOMEM; - devices = convert_audio_device(devices, HAL_API_REV_2_0, HAL_API_REV_1_0); in->qcom_in = qadev->hwif->openInputStream(devices, (int *)&config->format, &config->channel_mask, &config->sample_rate,