summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2014-03-21 17:53:17 -0700
committerGlenn Kasten <gkasten@google.com>2014-05-19 09:46:25 -0700
commitc56f3426099a3cf2d07ccff8886050c7fbce140f (patch)
tree9e486a809f9d500a70fd26c4e1d2596ded190dbe /media
parent7c96d53a65085f42ac2b6d416cbc16fd36ed72ff (diff)
downloadframeworks_av-c56f3426099a3cf2d07ccff8886050c7fbce140f.zip
frameworks_av-c56f3426099a3cf2d07ccff8886050c7fbce140f.tar.gz
frameworks_av-c56f3426099a3cf2d07ccff8886050c7fbce140f.tar.bz2
Pass stereo gains as packed minifloat
This will allow (eventually) a greater dynamic range for gains. However there are still a few remaining places in effects and mixer that will also need to be changed in order to get the full benefit. Also fixes a minor bug: was not checking for NaN in AudioTrack C++. Change-Id: I63bce9e82e0a61546d8ff475fb94bcb700d99c96
Diffstat (limited to 'media')
-rw-r--r--media/libmedia/AudioTrack.cpp13
-rw-r--r--media/libmedia/AudioTrackShared.cpp2
-rw-r--r--media/mediaserver/Android.mk3
3 files changed, 11 insertions, 7 deletions
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index aaaa3f1..120b28e 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -19,6 +19,7 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "AudioTrack"
+#include <math.h>
#include <sys/resource.h>
#include <audio_utils/primitives.h>
#include <binder/IPCThreadState.h>
@@ -566,7 +567,9 @@ void AudioTrack::pause()
status_t AudioTrack::setVolume(float left, float right)
{
- if (left < 0.0f || left > 1.0f || right < 0.0f || right > 1.0f) {
+ // This duplicates a test by AudioTrack JNI, but that is not the only caller
+ if (isnanf(left) || left < GAIN_FLOAT_ZERO || left > GAIN_FLOAT_UNITY ||
+ isnanf(right) || right < GAIN_FLOAT_ZERO || right > GAIN_FLOAT_UNITY) {
return BAD_VALUE;
}
@@ -574,7 +577,7 @@ status_t AudioTrack::setVolume(float left, float right)
mVolume[AUDIO_INTERLEAVE_LEFT] = left;
mVolume[AUDIO_INTERLEAVE_RIGHT] = right;
- mProxy->setVolumeLR((uint32_t(uint16_t(right * 0x1000)) << 16) | uint16_t(left * 0x1000));
+ mProxy->setVolumeLR(gain_minifloat_pack(gain_from_float(left), gain_from_float(right)));
if (isOffloaded_l()) {
mAudioTrack->signal();
@@ -589,7 +592,8 @@ status_t AudioTrack::setVolume(float volume)
status_t AudioTrack::setAuxEffectSendLevel(float level)
{
- if (level < 0.0f || level > 1.0f) {
+ // This duplicates a test by AudioTrack JNI, but that is not the only caller
+ if (isnanf(level) || level < GAIN_FLOAT_ZERO || level > GAIN_FLOAT_UNITY) {
return BAD_VALUE;
}
@@ -1137,8 +1141,7 @@ status_t AudioTrack::createTrack_l(size_t epoch)
mStaticProxy = new StaticAudioTrackClientProxy(cblk, buffers, frameCount, mFrameSizeAF);
mProxy = mStaticProxy;
}
- mProxy->setVolumeLR((uint32_t(uint16_t(mVolume[AUDIO_INTERLEAVE_RIGHT] * 0x1000)) << 16) |
- uint16_t(mVolume[AUDIO_INTERLEAVE_LEFT] * 0x1000));
+ mProxy->setVolumeLR(GAIN_MINIFLOAT_PACKED_UNITY);
mProxy->setSendLevel(mSendLevel);
mProxy->setSampleRate(mSampleRate);
mProxy->setEpoch(epoch);
diff --git a/media/libmedia/AudioTrackShared.cpp b/media/libmedia/AudioTrackShared.cpp
index 323b675..27a3718 100644
--- a/media/libmedia/AudioTrackShared.cpp
+++ b/media/libmedia/AudioTrackShared.cpp
@@ -27,7 +27,7 @@ namespace android {
audio_track_cblk_t::audio_track_cblk_t()
: mServer(0), mFutex(0), mMinimum(0),
- mVolumeLR(0x10001000), mSampleRate(0), mSendLevel(0), mFlags(0)
+ mVolumeLR(GAIN_MINIFLOAT_PACKED_UNITY), mSampleRate(0), mSendLevel(0), mFlags(0)
{
memset(&u, 0, sizeof(u));
}
diff --git a/media/mediaserver/Android.mk b/media/mediaserver/Android.mk
index d3e546a..5bc3f2f 100644
--- a/media/mediaserver/Android.mk
+++ b/media/mediaserver/Android.mk
@@ -35,7 +35,8 @@ LOCAL_C_INCLUDES := \
frameworks/av/services/medialog \
frameworks/av/services/audioflinger \
frameworks/av/services/audiopolicy \
- frameworks/av/services/camera/libcameraservice
+ frameworks/av/services/camera/libcameraservice \
+ $(call include-path-for, audio-utils)
LOCAL_MODULE:= mediaserver
LOCAL_32_BIT_ONLY := true