diff options
author | Glenn Kasten <gkasten@google.com> | 2012-02-14 09:42:32 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-02-14 09:42:32 -0800 |
commit | d9b9b8d09e7471b0ffa21cfa9f944ef4ad300a71 (patch) | |
tree | e2b8666cc7ca81254ce264129ddd70c076a63ed1 /services/audioflinger | |
parent | ed15977476a3d53103866e6d527fa3fb65d4166c (diff) | |
parent | 99e53b86eebb605b70dd7591b89bf61a9414ed0e (diff) | |
download | frameworks_av-d9b9b8d09e7471b0ffa21cfa9f944ef4ad300a71.zip frameworks_av-d9b9b8d09e7471b0ffa21cfa9f944ef4ad300a71.tar.gz frameworks_av-d9b9b8d09e7471b0ffa21cfa9f944ef4ad300a71.tar.bz2 |
Merge "Update comments"
Diffstat (limited to 'services/audioflinger')
-rw-r--r-- | services/audioflinger/AudioFlinger.cpp | 10 | ||||
-rw-r--r-- | services/audioflinger/AudioFlinger.h | 16 | ||||
-rw-r--r-- | services/audioflinger/AudioMixer.cpp | 7 | ||||
-rw-r--r-- | services/audioflinger/AudioMixer.h | 2 |
4 files changed, 27 insertions, 8 deletions
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp index 878df2d..c8807fa 100644 --- a/services/audioflinger/AudioFlinger.cpp +++ b/services/audioflinger/AudioFlinger.cpp @@ -1,4 +1,4 @@ -/* //device/include/server/AudioFlinger/AudioFlinger.cpp +/* ** ** Copyright 2007, The Android Open Source Project ** @@ -621,6 +621,7 @@ status_t AudioFlinger::setMasterMute(bool muted) } Mutex::Autolock _l(mLock); + // This is an optimization, so PlaybackThread doesn't have to look at the one from AudioFlinger mMasterMute = muted; for (size_t i = 0; i < mPlaybackThreads.size(); i++) mPlaybackThreads.valueAt(i)->setMasterMute(muted); @@ -3122,6 +3123,7 @@ bool AudioFlinger::DuplicatingThread::threadLoop() void AudioFlinger::DuplicatingThread::addOutputTrack(MixerThread *thread) { + // FIXME explain this formula int frameCount = (3 * mFrameCount * mSampleRate) / thread->sampleRate(); OutputTrack *outputTrack = new OutputTrack((ThreadBase *)thread, this, @@ -3393,7 +3395,7 @@ void AudioFlinger::PlaybackThread::Track::destroy() { // NOTE: destroyTrack_l() can remove a strong reference to this Track // by removing it from mTracks vector, so there is a risk that this Tracks's - // desctructor is called. As the destructor needs to lock mLock, + // destructor is called. As the destructor needs to lock mLock, // we must acquire a strong reference on this Track before locking mLock // here so that the destructor is called only when exiting this function. // On the other hand, as long as Track::destroy() is only called by @@ -3999,6 +4001,7 @@ void AudioFlinger::PlaybackThread::OutputTrack::clearBufferQueue() AudioFlinger::Client::Client(const sp<AudioFlinger>& audioFlinger, pid_t pid) : RefBase(), mAudioFlinger(audioFlinger), + // FIXME should be a "k" constant not hard-coded, in .h or ro. property, see 4 lines below mMemoryDealer(new MemoryDealer(1024*1024, "AudioFlinger::Client")), mPid(pid) { @@ -4660,7 +4663,7 @@ bool AudioFlinger::RecordThread::checkForNewParameters_l() } if (param.getInt(String8(AudioParameter::keyFrameCount), value) == NO_ERROR) { // do not accept frame count changes if tracks are open as the track buffer - // size depends on frame count and correct behavior would not be garantied + // size depends on frame count and correct behavior would not be guaranteed // if frame count is changed after track creation if (mActiveTrack != 0) { status = INVALID_OPERATION; @@ -6108,7 +6111,6 @@ status_t AudioFlinger::EffectModule::addHandle(const sp<EffectHandle>& handle) status_t status; Mutex::Autolock _l(mLock); - // First handle in mHandles has highest priority and controls the effect module int priority = handle->priority(); size_t size = mHandles.size(); sp<EffectHandle> h; diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h index aa0ee76..48a23fa 100644 --- a/services/audioflinger/AudioFlinger.h +++ b/services/audioflinger/AudioFlinger.h @@ -1,4 +1,4 @@ -/* //device/include/server/AudioFlinger/AudioFlinger.h +/* ** ** Copyright 2007, The Android Open Source Project ** @@ -290,6 +290,8 @@ private: enum track_state { IDLE, TERMINATED, + // These are order-sensitive; do not change order without reviewing the impact. + // In particular there are assumptions about > STOPPED. STOPPED, RESUMING, ACTIVE, @@ -760,6 +762,9 @@ private: int mSuspended; int mBytesWritten; private: + // mMasterMute is in both PlaybackThread and in AudioFlinger. When a + // PlaybackThread needs to find out if master-muted, it checks it's local + // copy rather than the one in AudioFlinger. This optimization saves a lock. bool mMasterMute; protected: SortedVector< wp<Track> > mActiveTracks; @@ -853,6 +858,8 @@ private: private: void applyVolume(uint16_t leftVol, uint16_t rightVol, bool ramp); + // volumes last sent to audio HAL with stream->set_volume() + // FIXME use standard representation and names float mLeftVolFloat; float mRightVolFloat; uint16_t mLeftVolShort; @@ -900,6 +907,7 @@ private: friend class AudioBuffer; + // server side of the client's IAudioTrack class TrackHandle : public android::BnAudioTrack { public: TrackHandle(const sp<PlaybackThread::Track>& track); @@ -1024,6 +1032,7 @@ private: ssize_t mBytesRead; }; + // server side of the client's IAudioRecord class RecordHandle : public android::BnAudioRecord { public: RecordHandle(const sp<RecordThread::RecordTrack>& recordTrack); @@ -1152,6 +1161,7 @@ mutable Mutex mLock; // mutex for process, commands and handl status_t mStatus; // initialization status effect_state mState; // current activation state Vector< wp<EffectHandle> > mHandles; // list of client handles + // First handle in mHandles has highest priority and controls the effect module uint32_t mMaxDisableWaitCnt; // maximum grace period before forcing an effect off after // sending disable command. uint32_t mDisableWaitCnt; // current process() calls count during disable period. @@ -1377,6 +1387,7 @@ mutable Mutex mLock; // mutex for process, commands and handl hwDev(dev), stream(in) {} }; + // for mAudioSessionRefs only struct AudioSessionRef { // FIXME rename parameter names when fields get "m" prefix AudioSessionRef(int sessionid_, pid_t pid_) : @@ -1432,10 +1443,11 @@ mutable Mutex mLock; // mutex for process, commands and handl DefaultKeyedVector< audio_io_handle_t, sp<RecordThread> > mRecordThreads; DefaultKeyedVector< pid_t, sp<NotificationClient> > mNotificationClients; - volatile int32_t mNextUniqueId; + volatile int32_t mNextUniqueId; // updated by android_atomic_inc audio_mode_t mMode; bool mBtNrecIsOff; + // protected by mLock Vector<AudioSessionRef*> mAudioSessionRefs; float masterVolume_l() const { return mMasterVolume; } diff --git a/services/audioflinger/AudioMixer.cpp b/services/audioflinger/AudioMixer.cpp index 191520a..cb7678b 100644 --- a/services/audioflinger/AudioMixer.cpp +++ b/services/audioflinger/AudioMixer.cpp @@ -1,4 +1,4 @@ -/* //device/include/server/AudioFlinger/AudioMixer.cpp +/* ** ** Copyright 2007, The Android Open Source Project ** @@ -961,7 +961,12 @@ void AudioMixer::process__genericResampling(state_t* state) // one track, 16 bits stereo without resampling is the most common case void AudioMixer::process__OneTrack16BitsStereoNoResampling(state_t* state) { + // This method is only called when state->enabledTracks has exactly + // one bit set. The asserts below would verify this, but are commented out + // since the whole point of this method is to optimize performance. + //assert(0 != state->enabledTracks); const int i = 31 - __builtin_clz(state->enabledTracks); + //assert((1 << i) == state->enabledTracks); const track_t& t = state->tracks[i]; AudioBufferProvider::Buffer& b(t.buffer); diff --git a/services/audioflinger/AudioMixer.h b/services/audioflinger/AudioMixer.h index c709686..c956918 100644 --- a/services/audioflinger/AudioMixer.h +++ b/services/audioflinger/AudioMixer.h @@ -1,4 +1,4 @@ -/* //device/include/server/AudioFlinger/AudioMixer.h +/* ** ** Copyright 2007, The Android Open Source Project ** |