summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
Diffstat (limited to 'services')
-rw-r--r--services/audioflinger/Android.mk8
-rw-r--r--services/audioflinger/AudioFlinger.cpp130
-rw-r--r--services/audioflinger/AudioFlinger.h3
-rw-r--r--services/audioflinger/AudioPolicyManagerBase.cpp62
-rw-r--r--services/audioflinger/AudioPolicyService.cpp7
-rw-r--r--services/audioflinger/AudioPolicyService.h18
6 files changed, 68 insertions, 160 deletions
diff --git a/services/audioflinger/Android.mk b/services/audioflinger/Android.mk
index 22ecc54..69a4adc 100644
--- a/services/audioflinger/Android.mk
+++ b/services/audioflinger/Android.mk
@@ -120,12 +120,4 @@ ifeq ($(TARGET_SIMULATOR),true)
endif
endif
-ifeq ($(BOARD_USE_LVMX),true)
- LOCAL_CFLAGS += -DLVMX
- LOCAL_C_INCLUDES += vendor/nxp
- LOCAL_STATIC_LIBRARIES += liblifevibes
- LOCAL_SHARED_LIBRARIES += liblvmxservice
-# LOCAL_SHARED_LIBRARIES += liblvmxipc
-endif
-
include $(BUILD_SHARED_LIBRARY)
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 4ec16c1..704da72 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -47,10 +47,6 @@
#include "A2dpAudioInterface.h"
#endif
-#ifdef LVMX
-#include "lifevibes.h"
-#endif
-
#include <media/EffectsFactoryApi.h>
#include <media/EffectVisualizerApi.h>
@@ -149,10 +145,6 @@ AudioFlinger::AudioFlinger()
} else {
LOGE("Couldn't even initialize the stubbed audio hardware!");
}
-#ifdef LVMX
- LifeVibes::init();
- mLifeVibesClientPid = -1;
-#endif
}
AudioFlinger::~AudioFlinger()
@@ -485,9 +477,6 @@ status_t AudioFlinger::setMode(int mode)
mMode = mode;
for (uint32_t i = 0; i < mPlaybackThreads.size(); i++)
mPlaybackThreads.valueAt(i)->setMode(mode);
-#ifdef LVMX
- LifeVibes::setMode(mode);
-#endif
}
return ret;
@@ -635,39 +624,11 @@ status_t AudioFlinger::setParameters(int ioHandle, const String8& keyValuePairs)
return PERMISSION_DENIED;
}
-#ifdef LVMX
- AudioParameter param = AudioParameter(keyValuePairs);
- LifeVibes::setParameters(ioHandle,keyValuePairs);
- String8 key = String8(AudioParameter::keyRouting);
- int device;
- if (NO_ERROR != param.getInt(key, device)) {
- device = -1;
- }
-
- key = String8(LifevibesTag);
- String8 value;
- int musicEnabled = -1;
- if (NO_ERROR == param.get(key, value)) {
- if (value == LifevibesEnable) {
- mLifeVibesClientPid = IPCThreadState::self()->getCallingPid();
- musicEnabled = 1;
- } else if (value == LifevibesDisable) {
- mLifeVibesClientPid = -1;
- musicEnabled = 0;
- }
- }
-#endif
-
// ioHandle == 0 means the parameters are global to the audio hardware interface
if (ioHandle == 0) {
AutoMutex lock(mHardwareLock);
mHardwareStatus = AUDIO_SET_PARAMETER;
result = mAudioHardware->setParameters(keyValuePairs);
-#ifdef LVMX
- if (musicEnabled != -1) {
- LifeVibes::enableMusic((bool) musicEnabled);
- }
-#endif
mHardwareStatus = AUDIO_HW_IDLE;
return result;
}
@@ -684,11 +645,6 @@ status_t AudioFlinger::setParameters(int ioHandle, const String8& keyValuePairs)
}
if (thread != NULL) {
result = thread->setParameters(keyValuePairs);
-#ifdef LVMX
- if ((NO_ERROR == result) && (device != -1)) {
- LifeVibes::setDevice(LifeVibes::threadIdToAudioOutputType(thread->id()), device);
- }
-#endif
return result;
}
return BAD_VALUE;
@@ -802,13 +758,6 @@ void AudioFlinger::removeNotificationClient(pid_t pid)
if (index >= 0) {
sp <NotificationClient> client = mNotificationClients.valueFor(pid);
LOGV("removeNotificationClient() %p, pid %d", client.get(), pid);
-#ifdef LVMX
- if (pid == mLifeVibesClientPid) {
- LOGV("Disabling lifevibes");
- LifeVibes::enableMusic(false);
- mLifeVibesClientPid = -1;
- }
-#endif
mNotificationClients.removeItem(pid);
}
}
@@ -1214,24 +1163,12 @@ uint32_t AudioFlinger::PlaybackThread::latency() const
status_t AudioFlinger::PlaybackThread::setMasterVolume(float value)
{
-#ifdef LVMX
- int audioOutputType = LifeVibes::getMixerType(mId, mType);
- if (LifeVibes::audioOutputTypeIsLifeVibes(audioOutputType)) {
- LifeVibes::setMasterVolume(audioOutputType, value);
- }
-#endif
mMasterVolume = value;
return NO_ERROR;
}
status_t AudioFlinger::PlaybackThread::setMasterMute(bool muted)
{
-#ifdef LVMX
- int audioOutputType = LifeVibes::getMixerType(mId, mType);
- if (LifeVibes::audioOutputTypeIsLifeVibes(audioOutputType)) {
- LifeVibes::setMasterMute(audioOutputType, muted);
- }
-#endif
mMasterMute = muted;
return NO_ERROR;
}
@@ -1248,24 +1185,12 @@ bool AudioFlinger::PlaybackThread::masterMute() const
status_t AudioFlinger::PlaybackThread::setStreamVolume(int stream, float value)
{
-#ifdef LVMX
- int audioOutputType = LifeVibes::getMixerType(mId, mType);
- if (LifeVibes::audioOutputTypeIsLifeVibes(audioOutputType)) {
- LifeVibes::setStreamVolume(audioOutputType, stream, value);
- }
-#endif
mStreamTypes[stream].volume = value;
return NO_ERROR;
}
status_t AudioFlinger::PlaybackThread::setStreamMute(int stream, bool muted)
{
-#ifdef LVMX
- int audioOutputType = LifeVibes::getMixerType(mId, mType);
- if (LifeVibes::audioOutputTypeIsLifeVibes(audioOutputType)) {
- LifeVibes::setStreamMute(audioOutputType, stream, muted);
- }
-#endif
mStreamTypes[stream].mute = muted;
return NO_ERROR;
}
@@ -1593,12 +1518,6 @@ bool AudioFlinger::MixerThread::threadLoop()
}
// enable changes in effect chain
unlockEffectChains(effectChains);
-#ifdef LVMX
- int audioOutputType = LifeVibes::getMixerType(mId, mType);
- if (LifeVibes::audioOutputTypeIsLifeVibes(audioOutputType)) {
- LifeVibes::process(audioOutputType, mMixBuffer, mixBufferSize);
- }
-#endif
mLastWriteTime = systemTime();
mInWrite = true;
mBytesWritten += mixBufferSize;
@@ -1661,24 +1580,6 @@ uint32_t AudioFlinger::MixerThread::prepareTracks_l(const SortedVector< wp<Track
if (masterMute) {
masterVolume = 0;
}
-#ifdef LVMX
- bool tracksConnectedChanged = false;
- bool stateChanged = false;
-
- int audioOutputType = LifeVibes::getMixerType(mId, mType);
- if (LifeVibes::audioOutputTypeIsLifeVibes(audioOutputType))
- {
- int activeTypes = 0;
- for (size_t i=0 ; i<count ; i++) {
- sp<Track> t = activeTracks[i].promote();
- if (t == 0) continue;
- Track* const track = t.get();
- int iTracktype=track->type();
- activeTypes |= 1<<track->type();
- }
- LifeVibes::computeVolumes(audioOutputType, activeTypes, tracksConnectedChanged, stateChanged, masterVolume, masterMute);
- }
-#endif
// Delegate master volume control to effect in output mix effect chain if needed
sp<EffectChain> chain = getEffectChain_l(AudioSystem::SESSION_OUTPUT_MIX);
if (chain != 0) {
@@ -1746,17 +1647,6 @@ uint32_t AudioFlinger::MixerThread::prepareTracks_l(const SortedVector< wp<Track
// read original volumes with volume control
float typeVolume = mStreamTypes[track->type()].volume;
-#ifdef LVMX
- bool streamMute=false;
- // read the volume from the LivesVibes audio engine.
- if (LifeVibes::audioOutputTypeIsLifeVibes(audioOutputType))
- {
- LifeVibes::getStreamVolumes(audioOutputType, track->type(), &typeVolume, &streamMute);
- if (streamMute) {
- typeVolume = 0;
- }
- }
-#endif
float v = masterVolume * typeVolume;
vl = (uint32_t)(v * cblk->volume[0]) << 12;
vr = (uint32_t)(v * cblk->volume[1]) << 12;
@@ -1789,14 +1679,6 @@ uint32_t AudioFlinger::MixerThread::prepareTracks_l(const SortedVector< wp<Track
if (va > MAX_GAIN_INT) va = MAX_GAIN_INT;
aux = int16_t(va);
-#ifdef LVMX
- if ( tracksConnectedChanged || stateChanged )
- {
- // only do the ramp when the volume is changed by the user / application
- param = AudioMixer::VOLUME;
- }
-#endif
-
// XXX: these things DON'T need to be done each time
mAudioMixer->setBufferProvider(track);
mAudioMixer->enable(AudioMixer::MIXING);
@@ -4292,18 +4174,6 @@ int AudioFlinger::openOutput(uint32_t *pDevices,
} else {
thread = new MixerThread(this, output, id, *pDevices);
LOGV("openOutput() created mixer output: ID %d thread %p", id, thread);
-
-#ifdef LVMX
- unsigned bitsPerSample =
- (format == AudioSystem::PCM_16_BIT) ? 16 :
- ((format == AudioSystem::PCM_8_BIT) ? 8 : 0);
- unsigned channelCount = (channels == AudioSystem::CHANNEL_OUT_STEREO) ? 2 : 1;
- int audioOutputType = LifeVibes::threadIdToAudioOutputType(thread->id());
-
- LifeVibes::init_aot(audioOutputType, samplingRate, bitsPerSample, channelCount);
- LifeVibes::setDevice(audioOutputType, *pDevices);
-#endif
-
}
mPlaybackThreads.add(id, thread);
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index 81f2eb4..ec3d202 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -1181,9 +1181,6 @@ private:
DefaultKeyedVector< pid_t, sp<NotificationClient> > mNotificationClients;
volatile int32_t mNextUniqueId;
-#ifdef LVMX
- int mLifeVibesClientPid;
-#endif
uint32_t mMode;
};
diff --git a/services/audioflinger/AudioPolicyManagerBase.cpp b/services/audioflinger/AudioPolicyManagerBase.cpp
index afa9acc..04d63e6 100644
--- a/services/audioflinger/AudioPolicyManagerBase.cpp
+++ b/services/audioflinger/AudioPolicyManagerBase.cpp
@@ -19,6 +19,7 @@
#include <utils/Log.h>
#include <hardware_legacy/AudioPolicyManagerBase.h>
#include <media/mediarecorder.h>
+#include <math.h>
namespace android {
@@ -1030,6 +1031,8 @@ AudioPolicyManagerBase::AudioPolicyManagerBase(AudioPolicyClientInterface *clien
mForceUse[i] = AudioSystem::FORCE_NONE;
}
+ initializeVolumeCurves();
+
// devices available by default are speaker, ear piece and microphone
mAvailableOutputDevices = AudioSystem::DEVICE_OUT_EARPIECE |
AudioSystem::DEVICE_OUT_SPEAKER;
@@ -1821,6 +1824,62 @@ audio_io_handle_t AudioPolicyManagerBase::getActiveInput()
return 0;
}
+float AudioPolicyManagerBase::volIndexToAmpl(uint32_t device, const StreamDescriptor& streamDesc,
+ int indexInUi) {
+ // the volume index in the UI is relative to the min and max volume indices for this stream type
+ int nbSteps = 1 + streamDesc.mVolIndex[StreamDescriptor::VOLMAX] -
+ streamDesc.mVolIndex[StreamDescriptor::VOLMIN];
+ int volIdx = (nbSteps * (indexInUi - streamDesc.mIndexMin)) /
+ (streamDesc.mIndexMax - streamDesc.mIndexMin);
+
+ // find what part of the curve this index volume belongs to, or if it's out of bounds
+ int segment = 0;
+ if (volIdx < streamDesc.mVolIndex[StreamDescriptor::VOLMIN]) { // out of bounds
+ return 0.0f;
+ } else if (volIdx < streamDesc.mVolIndex[StreamDescriptor::VOLKNEE1]) {
+ segment = 0;
+ } else if (volIdx < streamDesc.mVolIndex[StreamDescriptor::VOLKNEE2]) {
+ segment = 1;
+ } else if (volIdx <= streamDesc.mVolIndex[StreamDescriptor::VOLMAX]) {
+ segment = 2;
+ } else { // out of bounds
+ return 1.0f;
+ }
+
+ // linear interpolation in the attenuation table in dB
+ float decibels = streamDesc.mVolDbAtt[segment] +
+ ((float)(volIdx - streamDesc.mVolIndex[segment])) *
+ ( (streamDesc.mVolDbAtt[segment+1] - streamDesc.mVolDbAtt[segment]) /
+ ((float)(streamDesc.mVolIndex[segment+1] - streamDesc.mVolIndex[segment])) );
+
+ float amplification = exp( decibels * 0.115129f); // exp( dB * ln(10) / 20 )
+
+ LOGV("VOLUME vol index=[%d %d %d], dB=[%.1f %.1f %.1f] ampl=%.5f",
+ streamDesc.mVolIndex[segment], volIdx, streamDesc.mVolIndex[segment+1],
+ streamDesc.mVolDbAtt[segment], decibels, streamDesc.mVolDbAtt[segment+1],
+ amplification);
+
+ return amplification;
+}
+
+void AudioPolicyManagerBase::initializeVolumeCurves() {
+ // initialize the volume curves to a (-49.5 - 0 dB) attenuation in 0.5dB steps
+ for (int i=0 ; i< AudioSystem::NUM_STREAM_TYPES ; i++) {
+ mStreams[i].mVolIndex[StreamDescriptor::VOLMIN] = 1;
+ mStreams[i].mVolDbAtt[StreamDescriptor::VOLMIN] = -49.5f;
+ mStreams[i].mVolIndex[StreamDescriptor::VOLKNEE1] = 33;
+ mStreams[i].mVolDbAtt[StreamDescriptor::VOLKNEE1] = -33.5f;
+ mStreams[i].mVolIndex[StreamDescriptor::VOLKNEE2] = 66;
+ mStreams[i].mVolDbAtt[StreamDescriptor::VOLKNEE2] = -17.0f;
+ // here we use 100 steps to avoid rounding errors
+ // when computing the volume in volIndexToAmpl()
+ mStreams[i].mVolIndex[StreamDescriptor::VOLMAX] = 100;
+ mStreams[i].mVolDbAtt[StreamDescriptor::VOLMAX] = 0.0f;
+ }
+
+ // TODO add modifications for music to have finer steps below knee1 and above knee2
+}
+
float AudioPolicyManagerBase::computeVolume(int stream, int index, audio_io_handle_t output, uint32_t device)
{
float volume = 1.0;
@@ -1831,8 +1890,7 @@ float AudioPolicyManagerBase::computeVolume(int stream, int index, audio_io_hand
device = outputDesc->device();
}
- int volInt = (100 * (index - streamDesc.mIndexMin)) / (streamDesc.mIndexMax - streamDesc.mIndexMin);
- volume = AudioSystem::linearToLog(volInt);
+ volume = volIndexToAmpl(device, streamDesc, index);
// if a headset is connected, apply the following rules to ring tones and notifications
// to avoid sound level bursts in user's ears:
diff --git a/services/audioflinger/AudioPolicyService.cpp b/services/audioflinger/AudioPolicyService.cpp
index b04672d..953ddac 100644
--- a/services/audioflinger/AudioPolicyService.cpp
+++ b/services/audioflinger/AudioPolicyService.cpp
@@ -488,13 +488,6 @@ status_t AudioPolicyService::onTransact(
// ----------------------------------------------------------------------------
-void AudioPolicyService::instantiate() {
- defaultServiceManager()->addService(
- String16("media.audio_policy"), new AudioPolicyService());
-}
-
-
-// ----------------------------------------------------------------------------
// AudioPolicyClientInterface implementation
// ----------------------------------------------------------------------------
diff --git a/services/audioflinger/AudioPolicyService.h b/services/audioflinger/AudioPolicyService.h
index 54af1f1..4749b8b 100644
--- a/services/audioflinger/AudioPolicyService.h
+++ b/services/audioflinger/AudioPolicyService.h
@@ -21,6 +21,7 @@
#include <hardware_legacy/AudioPolicyInterface.h>
#include <media/ToneGenerator.h>
#include <utils/Vector.h>
+#include <binder/BinderService.h>
namespace android {
@@ -28,12 +29,17 @@ class String8;
// ----------------------------------------------------------------------------
-class AudioPolicyService: public BnAudioPolicyService, public AudioPolicyClientInterface,
+class AudioPolicyService :
+ public BinderService<AudioPolicyService>,
+ public BnAudioPolicyService,
+ public AudioPolicyClientInterface,
public IBinder::DeathRecipient
{
+ friend class BinderService<AudioPolicyService>;
public:
- static void instantiate();
+ // for BinderService
+ static const char *getServiceName() { return "media.audio_policy"; }
virtual status_t dump(int fd, const Vector<String16>& args);
@@ -241,11 +247,3 @@ private:
}; // namespace android
#endif // ANDROID_AUDIOPOLICYSERVICE_H
-
-
-
-
-
-
-
-