diff options
author | Glenn Kasten <gkasten@google.com> | 2012-03-25 11:59:31 -0700 |
---|---|---|
committer | Glenn Kasten <gkasten@google.com> | 2012-04-01 14:57:33 -0700 |
commit | deeb1282621f3177ad667360b40eef8e4fedb298 (patch) | |
tree | 595d49e01dc93258bc061052f103e45e2811b129 | |
parent | a1472d9883e35edd280201c8be3191695007dfd4 (diff) | |
download | frameworks_av-deeb1282621f3177ad667360b40eef8e4fedb298.zip frameworks_av-deeb1282621f3177ad667360b40eef8e4fedb298.tar.gz frameworks_av-deeb1282621f3177ad667360b40eef8e4fedb298.tar.bz2 |
AudioMixer default track parameters
Move the default initialization of track parameters from the AudioMixer
constructor to getTrackName(). This fixes a bug where the defaults were
only valid the first time a name was allocated.
Also added a switch case for parameter FORMAT.
Change-Id: I07abd3aaf7f4efe9825a761d2bc662aaee2c6db0
-rw-r--r-- | services/audioflinger/AudioMixer.cpp | 56 |
1 files changed, 33 insertions, 23 deletions
diff --git a/services/audioflinger/AudioMixer.cpp b/services/audioflinger/AudioMixer.cpp index 3f4c19a..0e6ea12 100644 --- a/services/audioflinger/AudioMixer.cpp +++ b/services/audioflinger/AudioMixer.cpp @@ -66,6 +66,32 @@ AudioMixer::AudioMixer(size_t frameCount, uint32_t sampleRate, uint32_t maxNumTr // and mTrackNames is initially 0. However, leave it here until that's verified. track_t* t = mState.tracks; for (unsigned i=0 ; i < MAX_NUM_TRACKS ; i++) { + // FIXME redundant per track + t->localTimeFreq = lc.getLocalFreq(); + t++; + } +} + +AudioMixer::~AudioMixer() +{ + track_t* t = mState.tracks; + for (unsigned i=0 ; i < MAX_NUM_TRACKS ; i++) { + delete t->resampler; + t++; + } + delete [] mState.outputTemp; + delete [] mState.resampleTemp; +} + +int AudioMixer::getTrackName() +{ + uint32_t names = (~mTrackNames) & mConfiguredNames; + if (names != 0) { + int n = __builtin_ctz(names); + ALOGV("add track (%d)", n); + mTrackNames |= 1 << n; + // assume default parameters for the track, except where noted below + track_t* t = &mState.tracks[n]; t->needs = 0; t->volume[0] = UNITY_GAIN; t->volume[1] = UNITY_GAIN; @@ -83,38 +109,19 @@ AudioMixer::AudioMixer(size_t frameCount, uint32_t sampleRate, uint32_t maxNumTr t->enabled = false; t->format = 16; t->channelMask = AUDIO_CHANNEL_OUT_STEREO; + // setBufferProvider(name, AudioBufferProvider *) is required before enable(name) t->bufferProvider = NULL; t->buffer.raw = NULL; + // no initialization needed // t->buffer.frameCount t->hook = NULL; t->in = NULL; t->resampler = NULL; t->sampleRate = mSampleRate; + // setParameter(name, TRACK, MAIN_BUFFER, mixBuffer) is required before enable(name) t->mainBuffer = NULL; t->auxBuffer = NULL; - t->localTimeFreq = lc.getLocalFreq(); - t++; - } -} - -AudioMixer::~AudioMixer() -{ - track_t* t = mState.tracks; - for (unsigned i=0 ; i < MAX_NUM_TRACKS ; i++) { - delete t->resampler; - t++; - } - delete [] mState.outputTemp; - delete [] mState.resampleTemp; -} - -int AudioMixer::getTrackName() -{ - uint32_t names = (~mTrackNames) & mConfiguredNames; - if (names != 0) { - int n = __builtin_ctz(names); - ALOGV("add track (%d)", n); - mTrackNames |= 1 << n; + // see t->localTimeFreq in constructor above return TRACK0 + n; } return -1; @@ -215,6 +222,9 @@ void AudioMixer::setParameter(int name, int target, int param, void *value) invalidateState(1 << name); } break; + case FORMAT: + ALOG_ASSERT(valueInt == AUDIO_FORMAT_PCM_16_BIT); + break; default: LOG_FATAL("bad param"); } |