summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2012-08-31 17:44:06 -0700
committerEric Laurent <elaurent@google.com>2012-08-31 18:44:28 -0700
commit57b2dd1e78af53115985f18d31ec5421c9da947e (patch)
tree5126e9e885cbd74e57978b1d5ecfa9c29d61c510 /services
parent092fe44abd787fcb4377d90c63f2aa7120a4d267 (diff)
downloadframeworks_av-57b2dd1e78af53115985f18d31ec5421c9da947e.zip
frameworks_av-57b2dd1e78af53115985f18d31ec5421c9da947e.tar.gz
frameworks_av-57b2dd1e78af53115985f18d31ec5421c9da947e.tar.bz2
AudioFlinger: send audio source to audio effects
Added support for EFFECT_CMD_SET_AUDIO_SOURCE audio effect command to inform preprocessings of current audio source selection for capture. Change-Id: Ib2418a9aa8114e8457fe828ecd43b230ed86cdd6
Diffstat (limited to 'services')
-rw-r--r--services/audioflinger/AudioFlinger.cpp38
-rw-r--r--services/audioflinger/AudioFlinger.h3
2 files changed, 40 insertions, 1 deletions
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 14f74b5..c27b4a2 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -1141,7 +1141,7 @@ AudioFlinger::ThreadBase::ThreadBase(const sp<AudioFlinger>& audioFlinger, audio
mChannelCount(0),
mFrameSize(1), mFormat(AUDIO_FORMAT_INVALID),
mParamStatus(NO_ERROR),
- mStandby(false), mDevice(device), mId(id),
+ mStandby(false), mDevice(device), mAudioSource(AUDIO_SOURCE_DEFAULT), mId(id),
// mName will be set by concrete (non-virtual) subclass
mDeathRecipient(new PMDeathRecipient(this))
{
@@ -6591,6 +6591,15 @@ bool AudioFlinger::RecordThread::checkForNewParameters_l()
newDevice |= value;
mDevice = newDevice; // since mDevice is read by other threads, only write to it once
}
+ if (param.getInt(String8(AudioParameter::keyInputSource), value) == NO_ERROR &&
+ mAudioSource != (audio_source_t)value) {
+ // forward device change to effects that have requested to be
+ // aware of attached audio device.
+ for (size_t i = 0; i < mEffectChains.size(); i++) {
+ mEffectChains[i]->setAudioSource_l((audio_source_t)value);
+ }
+ mAudioSource = (audio_source_t)value;
+ }
if (status == NO_ERROR) {
status = mInput->stream->common.set_parameters(&mInput->stream->common, keyValuePair.string());
if (status == INVALID_OPERATION) {
@@ -7737,6 +7746,7 @@ sp<AudioFlinger::EffectHandle> AudioFlinger::ThreadBase::createEffect_l(
effect->setDevice(mDevice);
effect->setMode(mAudioFlinger->getMode());
+ effect->setAudioSource(mAudioSource);
}
// create effect handle and connect it to effect module
handle = new EffectHandle(effect, client, effectClient, priority);
@@ -7814,6 +7824,7 @@ status_t AudioFlinger::ThreadBase::addEffect_l(const sp<EffectModule>& effect)
effect->setDevice(mDevice);
effect->setMode(mAudioFlinger->getMode());
+ effect->setAudioSource(mAudioSource);
return NO_ERROR;
}
@@ -8712,6 +8723,22 @@ status_t AudioFlinger::EffectModule::setMode(audio_mode_t mode)
return status;
}
+status_t AudioFlinger::EffectModule::setAudioSource(audio_source_t source)
+{
+ Mutex::Autolock _l(mLock);
+ status_t status = NO_ERROR;
+ if ((mDescriptor.flags & EFFECT_FLAG_AUDIO_SOURCE_MASK) == EFFECT_FLAG_AUDIO_SOURCE_IND) {
+ uint32_t size = 0;
+ status = (*mEffectInterface)->command(mEffectInterface,
+ EFFECT_CMD_SET_AUDIO_SOURCE,
+ sizeof(audio_source_t),
+ &source,
+ &size,
+ NULL);
+ }
+ return status;
+}
+
void AudioFlinger::EffectModule::setSuspended(bool suspended)
{
Mutex::Autolock _l(mLock);
@@ -9387,6 +9414,15 @@ void AudioFlinger::EffectChain::setMode_l(audio_mode_t mode)
}
}
+// setAudioSource_l() must be called with PlaybackThread::mLock held
+void AudioFlinger::EffectChain::setAudioSource_l(audio_source_t source)
+{
+ size_t size = mEffects.size();
+ for (size_t i = 0; i < size; i++) {
+ mEffects[i]->setAudioSource(source);
+ }
+}
+
// setVolume_l() must be called with PlaybackThread::mLock held
bool AudioFlinger::EffectChain::setVolume_l(uint32_t *left, uint32_t *right)
{
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index 4723cd9..0fad7c7 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -674,6 +674,7 @@ private:
bool mStandby; // Whether thread is currently in standby.
audio_devices_t mDevice; // output device for PlaybackThread
// input + output devices for RecordThread
+ audio_source_t mAudioSource; // (see audio.h, audio_source_t)
const audio_io_handle_t mId;
Vector< sp<EffectChain> > mEffectChains;
@@ -1606,6 +1607,7 @@ private:
status_t setDevice(audio_devices_t device);
status_t setVolume(uint32_t *left, uint32_t *right, bool controller);
status_t setMode(audio_mode_t mode);
+ status_t setAudioSource(audio_source_t source);
status_t start();
status_t stop();
void setSuspended(bool suspended);
@@ -1768,6 +1770,7 @@ mutable Mutex mLock; // mutex for process, commands and handl
bool setVolume_l(uint32_t *left, uint32_t *right);
void setDevice_l(audio_devices_t device);
void setMode_l(audio_mode_t mode);
+ void setAudioSource_l(audio_source_t source);
void setInBuffer(int16_t *buffer, bool ownsBuffer = false) {
mInBuffer = buffer;