summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/AudioMixer.cpp
diff options
context:
space:
mode:
authorAndy Hung <hunga@google.com>2014-07-16 21:53:43 -0700
committerAndy Hung <hunga@google.com>2014-07-18 20:34:02 -0700
commita08810b2feafeec88870c7c1f01efc39ee8e0d78 (patch)
tree6c33f28c0c637f0d67530058493f653e453a131b /services/audioflinger/AudioMixer.cpp
parent34803d594232af5604d893eff7ee40bb57d459a4 (diff)
downloadframeworks_av-a08810b2feafeec88870c7c1f01efc39ee8e0d78.zip
frameworks_av-a08810b2feafeec88870c7c1f01efc39ee8e0d78.tar.gz
frameworks_av-a08810b2feafeec88870c7c1f01efc39ee8e0d78.tar.bz2
Add RemixBufferProvider to AudioMixer
This is used to convert between channel masks for input AudioTrack data. Change-Id: Iedffaeccb99c7053992152e7b1cb6b2d33b12eef
Diffstat (limited to 'services/audioflinger/AudioMixer.cpp')
-rw-r--r--services/audioflinger/AudioMixer.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/services/audioflinger/AudioMixer.cpp b/services/audioflinger/AudioMixer.cpp
index ba135c6..529f2af 100644
--- a/services/audioflinger/AudioMixer.cpp
+++ b/services/audioflinger/AudioMixer.cpp
@@ -62,6 +62,10 @@
#define ALOGVV(a...) do { } while (0)
#endif
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
+#endif
+
// Set kUseNewMixer to true to use the new mixer engine. Otherwise the
// original code will be used. This is false for now.
static const bool kUseNewMixer = false;
@@ -317,6 +321,36 @@ void AudioMixer::DownmixerBufferProvider::copyFrames(void *dst, const void *src,
/*static*/ bool AudioMixer::DownmixerBufferProvider::sIsMultichannelCapable = false;
/*static*/ effect_descriptor_t AudioMixer::DownmixerBufferProvider::sDwnmFxDesc;
+AudioMixer::RemixBufferProvider::RemixBufferProvider(audio_channel_mask_t inputChannelMask,
+ audio_channel_mask_t outputChannelMask, audio_format_t format,
+ size_t bufferFrameCount) :
+ CopyBufferProvider(
+ audio_bytes_per_sample(format)
+ * audio_channel_count_from_out_mask(inputChannelMask),
+ audio_bytes_per_sample(format)
+ * audio_channel_count_from_out_mask(outputChannelMask),
+ bufferFrameCount),
+ mFormat(format),
+ mSampleSize(audio_bytes_per_sample(format)),
+ mInputChannels(audio_channel_count_from_out_mask(inputChannelMask)),
+ mOutputChannels(audio_channel_count_from_out_mask(outputChannelMask))
+{
+ ALOGV("RemixBufferProvider(%p)(%#x, %#x, %#x) %d %d",
+ this, format, inputChannelMask, outputChannelMask,
+ mInputChannels, mOutputChannels);
+ // TODO: consider channel representation in index array formulation
+ // We ignore channel representation, and just use the bits.
+ memcpy_by_index_array_initialization(mIdxAry, ARRAY_SIZE(mIdxAry),
+ audio_channel_mask_get_bits(outputChannelMask),
+ audio_channel_mask_get_bits(inputChannelMask));
+}
+
+void AudioMixer::RemixBufferProvider::copyFrames(void *dst, const void *src, size_t frames)
+{
+ memcpy_by_index_array(dst, mOutputChannels,
+ src, mInputChannels, mIdxAry, mSampleSize, frames);
+}
+
AudioMixer::ReformatBufferProvider::ReformatBufferProvider(int32_t channels,
audio_format_t inputFormat, audio_format_t outputFormat,
size_t bufferFrameCount) :