diff options
author | Glenn Kasten <gkasten@google.com> | 2012-03-20 17:01:29 -0700 |
---|---|---|
committer | Glenn Kasten <gkasten@google.com> | 2012-03-20 17:27:10 -0700 |
commit | 25f1bc43f83005e76860502c010fd25566c6aa15 (patch) | |
tree | 9dd46e25d6bbfdd9275dd6e62132cb8b69bf30e3 /services | |
parent | 54fa7254838748c4149f4e340f479fc4e3b2357d (diff) | |
download | frameworks_base-25f1bc43f83005e76860502c010fd25566c6aa15.zip frameworks_base-25f1bc43f83005e76860502c010fd25566c6aa15.tar.gz frameworks_base-25f1bc43f83005e76860502c010fd25566c6aa15.tar.bz2 |
AudioMixer can be configured for fewer max tracks
Change-Id: I371b17cef071d083eecf35cd3627a3adff907a33
Diffstat (limited to 'services')
-rw-r--r-- | services/audioflinger/AudioMixer.cpp | 9 | ||||
-rw-r--r-- | services/audioflinger/AudioMixer.h | 9 |
2 files changed, 14 insertions, 4 deletions
diff --git a/services/audioflinger/AudioMixer.cpp b/services/audioflinger/AudioMixer.cpp index 1ec238b..91f7515 100644 --- a/services/audioflinger/AudioMixer.cpp +++ b/services/audioflinger/AudioMixer.cpp @@ -42,12 +42,15 @@ namespace android { // ---------------------------------------------------------------------------- -AudioMixer::AudioMixer(size_t frameCount, uint32_t sampleRate) - : mTrackNames(0), mSampleRate(sampleRate) +AudioMixer::AudioMixer(size_t frameCount, uint32_t sampleRate, uint32_t maxNumTracks) + : mTrackNames(0), mConfiguredNames((1 << maxNumTracks) - 1), mSampleRate(sampleRate) { // AudioMixer is not yet capable of multi-channel beyond stereo COMPILE_TIME_ASSERT_FUNCTION_SCOPE(2 == MAX_NUM_CHANNELS); + ALOG_ASSERT(maxNumTracks <= MAX_NUM_TRACKS, "maxNumTracks %u > MAX_NUM_TRACKS %u", + maxNumTracks, MAX_NUM_TRACKS); + LocalClock lc; mState.enabledTracks= 0; @@ -103,7 +106,7 @@ AudioMixer::~AudioMixer() int AudioMixer::getTrackName() { - uint32_t names = ~mTrackNames; + uint32_t names = (~mTrackNames) & mConfiguredNames; if (names != 0) { int n = __builtin_ctz(names); ALOGV("add track (%d)", n); diff --git a/services/audioflinger/AudioMixer.h b/services/audioflinger/AudioMixer.h index b210212..7a61467 100644 --- a/services/audioflinger/AudioMixer.h +++ b/services/audioflinger/AudioMixer.h @@ -31,7 +31,8 @@ namespace android { class AudioMixer { public: - AudioMixer(size_t frameCount, uint32_t sampleRate); + AudioMixer(size_t frameCount, uint32_t sampleRate, + uint32_t maxNumTracks = MAX_NUM_TRACKS); /*virtual*/ ~AudioMixer(); // non-virtual saves a v-table, restore if sub-classed @@ -184,11 +185,17 @@ private: int32_t *outputTemp; int32_t *resampleTemp; int32_t reserved[2]; + // FIXME allocate dynamically to save some memory when maxNumTracks < MAX_NUM_TRACKS track_t tracks[MAX_NUM_TRACKS]; __attribute__((aligned(32))); }; // bitmask of allocated track names, where bit 0 corresponds to TRACK0 etc. uint32_t mTrackNames; + + // bitmask of configured track names; ~0 if maxNumTracks == MAX_NUM_TRACKS, + // but will have fewer bits set if maxNumTracks < MAX_NUM_TRACKS + const uint32_t mConfiguredNames; + const uint32_t mSampleRate; state_t mState __attribute__((aligned(32))); |