diff options
Diffstat (limited to 'services')
-rw-r--r-- | services/audioflinger/AudioMixer.cpp | 20 | ||||
-rw-r--r-- | services/audioflinger/AudioMixer.h | 8 |
2 files changed, 19 insertions, 9 deletions
diff --git a/services/audioflinger/AudioMixer.cpp b/services/audioflinger/AudioMixer.cpp index a9814a1..183c1f3 100644 --- a/services/audioflinger/AudioMixer.cpp +++ b/services/audioflinger/AudioMixer.cpp @@ -108,6 +108,8 @@ AudioMixer::AudioMixer(size_t frameCount, uint32_t sampleRate, uint32_t maxNumTr LocalClock lc; + pthread_once(&sOnceControl, &sInitRoutine); + mState.enabledTracks= 0; mState.needsChanged = 0; mState.frameCount = frameCount; @@ -121,8 +123,6 @@ 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->resampler = NULL; t->downmixerBufferProvider = NULL; t++; @@ -191,7 +191,6 @@ int AudioMixer::getTrackName(audio_channel_mask_t channelMask) t->channelMask = AUDIO_CHANNEL_OUT_STEREO; // setBufferProvider(name, AudioBufferProvider *) is required before enable(name) t->bufferProvider = NULL; - t->downmixerBufferProvider = NULL; t->buffer.raw = NULL; // no initialization needed // t->buffer.frameCount @@ -202,7 +201,7 @@ int AudioMixer::getTrackName(audio_channel_mask_t channelMask) // setParameter(name, TRACK, MAIN_BUFFER, mixBuffer) is required before enable(name) t->mainBuffer = NULL; t->auxBuffer = NULL; - // see t->localTimeFreq in constructor above + t->downmixerBufferProvider = NULL; status_t status = initTrackDownmix(&mState.tracks[n], n, channelMask); if (status == OK) { @@ -543,7 +542,7 @@ bool AudioMixer::track_t::setResampler(uint32_t value, uint32_t devSampleRate) // the resampler sees the number of channels after the downmixer, if any downmixerBufferProvider != NULL ? MAX_NUM_CHANNELS : channelCount, devSampleRate); - resampler->setLocalTimeFreq(localTimeFreq); + resampler->setLocalTimeFreq(sLocalTimeFreq); } return true; } @@ -1410,7 +1409,16 @@ int64_t AudioMixer::calculateOutputPTS(const track_t& t, int64_t basePTS, if (AudioBufferProvider::kInvalidPTS == basePTS) return AudioBufferProvider::kInvalidPTS; - return basePTS + ((outputFrameIndex * t.localTimeFreq) / t.sampleRate); + return basePTS + ((outputFrameIndex * sLocalTimeFreq) / t.sampleRate); +} + +/*static*/ uint64_t AudioMixer::sLocalTimeFreq; +/*static*/ pthread_once_t AudioMixer::sOnceControl = PTHREAD_ONCE_INIT; + +/*static*/ void AudioMixer::sInitRoutine() +{ + LocalClock lc; + sLocalTimeFreq = lc.getLocalFreq(); } // ---------------------------------------------------------------------------- diff --git a/services/audioflinger/AudioMixer.h b/services/audioflinger/AudioMixer.h index 46deae7..66abb4f 100644 --- a/services/audioflinger/AudioMixer.h +++ b/services/audioflinger/AudioMixer.h @@ -188,11 +188,9 @@ private: // 16-byte boundary - uint64_t localTimeFreq; - DownmixerBufferProvider* downmixerBufferProvider; // 4 bytes - int32_t padding; + int32_t padding[3]; // 16-byte boundary @@ -274,6 +272,10 @@ private: static int64_t calculateOutputPTS(const track_t& t, int64_t basePTS, int outputFrameIndex); + + static uint64_t sLocalTimeFreq; + static pthread_once_t sOnceControl; + static void sInitRoutine(); }; // ---------------------------------------------------------------------------- |