summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/AudioMixer.h
diff options
context:
space:
mode:
authorAndy Hung <hunga@google.com>2014-06-23 19:07:29 -0700
committerAndy Hung <hunga@google.com>2014-07-08 21:09:13 -0700
commit5e58b0abe5b6c8f5bd96a8f78bbeeeb4d3892020 (patch)
tree975ed02efce4eaefcf5b0ceb5f33d212542a33a6 /services/audioflinger/AudioMixer.h
parent72d039f007722c92ee5ea7ffd03ece19d2781103 (diff)
downloadframeworks_av-5e58b0abe5b6c8f5bd96a8f78bbeeeb4d3892020.zip
frameworks_av-5e58b0abe5b6c8f5bd96a8f78bbeeeb4d3892020.tar.gz
frameworks_av-5e58b0abe5b6c8f5bd96a8f78bbeeeb4d3892020.tar.bz2
Add floating point volume handling to AudioMixer
Use floating point volume in AudioMixer mixing when floating point input is used with the new mixer engine. AudioResampler is updated to take floating point volume to match. Both legacy integer and floating point mixer engines work. For now, integer volume is used when the new mixer engine runs in integer input mode, for backward compatibility with the legacy mixer. The new mixer engine will generally run in floating point input mode. When the legacy path is removed, the integer volumes will be removed. Change-Id: I79e80c292ae7c8b8bdd0aa371a1b2c3a1b618290
Diffstat (limited to 'services/audioflinger/AudioMixer.h')
-rw-r--r--services/audioflinger/AudioMixer.h29
1 files changed, 26 insertions, 3 deletions
diff --git a/services/audioflinger/AudioMixer.h b/services/audioflinger/AudioMixer.h
index e6de00c..a9f4761 100644
--- a/services/audioflinger/AudioMixer.h
+++ b/services/audioflinger/AudioMixer.h
@@ -163,8 +163,9 @@ private:
struct track_t {
uint32_t needs;
+ // TODO: Eventually remove legacy integer volume settings
union {
- int16_t volume[MAX_NUM_CHANNELS]; // [0]3.12 fixed point
+ int16_t volume[MAX_NUM_CHANNELS]; // U4.12 fixed point (top bit should be zero)
int32_t volumeRL;
};
@@ -217,7 +218,13 @@ private:
audio_format_t mMixerInFormat; // mix internal format AUDIO_FORMAT_PCM_(FLOAT|16_BIT)
// each track must be converted to this format.
- int32_t mUnused[1]; // alignment padding
+ float mVolume[MAX_NUM_CHANNELS]; // floating point set volume
+ float mPrevVolume[MAX_NUM_CHANNELS]; // floating point previous volume
+ float mVolumeInc[MAX_NUM_CHANNELS]; // floating point volume increment
+
+ float mAuxLevel; // floating point set aux level
+ float mPrevAuxLevel; // floating point prev aux level
+ float mAuxInc; // floating point aux increment
// 16-byte boundary
@@ -225,7 +232,7 @@ private:
bool setResampler(uint32_t sampleRate, uint32_t devSampleRate);
bool doesResample() const { return resampler != NULL; }
void resetResampler() { if (resampler != NULL) resampler->reset(); }
- void adjustVolumeRamp(bool aux);
+ void adjustVolumeRamp(bool aux, bool useFloat = false);
size_t getUnreleasedFrames() const { return resampler != NULL ?
resampler->getUnreleasedFrames() : 0; };
};
@@ -349,6 +356,22 @@ private:
static pthread_once_t sOnceControl;
static void sInitRoutine();
+ /* multi-format volume mixing function (calls template functions
+ * in AudioMixerOps.h). The template parameters are as follows:
+ *
+ * MIXTYPE (see AudioMixerOps.h MIXTYPE_* enumeration)
+ * NCHAN (number of channels, 2 for now)
+ * USEFLOATVOL (set to true if float volume is used)
+ * ADJUSTVOL (set to true if volume ramp parameters needs adjustment afterwards)
+ * TO: int32_t (Q4.27) or float
+ * TI: int32_t (Q4.27) or int16_t (Q0.15) or float
+ * TA: int32_t (Q4.27)
+ */
+ template <int MIXTYPE, int NCHAN, bool USEFLOATVOL, bool ADJUSTVOL,
+ typename TO, typename TI, typename TA>
+ static void volumeMix(TO *out, size_t outFrames,
+ const TI *in, TA *aux, bool ramp, AudioMixer::track_t *t);
+
// multi-format process hooks
template <int MIXTYPE, int NCHAN, typename TO, typename TI, typename TA>
static void process_NoResampleOneTrack(state_t* state, int64_t pts);