summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/AudioFlinger.h
diff options
context:
space:
mode:
Diffstat (limited to 'services/audioflinger/AudioFlinger.h')
-rw-r--r--services/audioflinger/AudioFlinger.h97
1 files changed, 38 insertions, 59 deletions
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index 38fff8c..0e4b24a 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -73,7 +73,7 @@ class AudioFlinger :
public BinderService<AudioFlinger>,
public BnAudioFlinger
{
- friend class BinderService<AudioFlinger>;
+ friend class BinderService<AudioFlinger>; // for AudioFlinger()
public:
static const char* getServiceName() { return "media.audio_flinger"; }
@@ -222,6 +222,8 @@ private:
audio_hw_device_t* findSuitableHwDev_l(uint32_t devices);
void purgeStaleEffects_l();
+ // standby delay for MIXER and DUPLICATING playback threads is read from property
+ // ro.audio.flinger_standbytime_ms or defaults to kDefaultStandbyTimeInNsecs
static nsecs_t mStandbyTimeInNsecs;
// Internal dump utilites.
@@ -340,13 +342,6 @@ private:
int sessionId() const { return mSessionId; }
protected:
- friend class ThreadBase;
- friend class RecordHandle;
- friend class PlaybackThread;
- friend class RecordThread;
- friend class MixerThread;
- friend class DirectOutputThread;
-
TrackBase(const TrackBase&);
TrackBase& operator = (const TrackBase&);
@@ -470,9 +465,9 @@ private:
// ThreadBase mutex before processing the mixer and effects. This guarantees the
// integrity of the chains during the process.
// Also sets the parameter 'effectChains' to current value of mEffectChains.
- void lockEffectChains_l(Vector<sp <EffectChain> >& effectChains);
+ void lockEffectChains_l(Vector< sp<EffectChain> >& effectChains);
// unlock effect chains after process
- void unlockEffectChains(const Vector<sp<EffectChain> >& effectChains);
+ void unlockEffectChains(const Vector< sp<EffectChain> >& effectChains);
// set audio mode to all effect chains
void setMode(audio_mode_t mode);
// get effect module with corresponding ID on specified audio session
@@ -532,15 +527,7 @@ private:
// check if some effects must be suspended when an effect chain is added
void checkSuspendOnAddEffectChain_l(const sp<EffectChain>& chain);
- friend class AudioFlinger;
- friend class Track;
- friend class TrackBase;
- friend class PlaybackThread;
- friend class MixerThread;
- friend class DirectOutputThread;
- friend class DuplicatingThread;
- friend class RecordThread;
- friend class RecordTrack;
+ friend class AudioFlinger; // for mEffectChains
const type_t mType;
@@ -655,8 +642,7 @@ private:
int auxEffectId() const { return mAuxEffectId; }
protected:
- friend class ThreadBase;
- friend class TrackHandle;
+ // for numerous
friend class PlaybackThread;
friend class MixerThread;
friend class DirectOutputThread;
@@ -685,7 +671,9 @@ private:
return (mStreamType == AUDIO_STREAM_CNT);
}
+ public:
virtual bool isTimedTrack() const { return false; }
+ protected:
// we don't really need a lock for these
volatile bool mMute;
@@ -824,7 +812,7 @@ private:
audio_io_handle_t id, uint32_t device, type_t type);
virtual ~PlaybackThread();
- virtual status_t dump(int fd, const Vector<String16>& args);
+ status_t dump(int fd, const Vector<String16>& args);
// Thread virtuals
virtual status_t readyToRun();
@@ -840,12 +828,6 @@ protected:
virtual void threadLoop_write();
virtual void threadLoop_standby();
- // Non-trivial for DUPLICATING only
- virtual void updateWaitTime_l() { }
-
- // Non-trivial for DIRECT only
- virtual void applyVolume() { }
-
// prepareTracks_l reads and writes mActiveTracks, and also returns the
// pending set of tracks to remove via Vector 'tracksToRemove'. The caller is
// responsible for clearing or destroying this Vector later on, when it
@@ -856,7 +838,8 @@ public:
virtual status_t initCheck() const { return (mOutput == NULL) ? NO_INIT : NO_ERROR; }
- virtual uint32_t latency() const;
+ // return estimated latency in milliseconds, as reported by HAL
+ uint32_t latency() const;
void setMasterVolume(float value);
void setMasterMute(bool muted);
@@ -887,7 +870,7 @@ public:
bool isSuspended() const { return (mSuspended > 0); }
virtual String8 getParameters(const String8& keys);
virtual void audioConfigChanged_l(int event, int param = 0);
- virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames);
+ status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames);
int16_t *mixBuffer() const { return mMixBuffer; };
virtual void detachAuxEffect_l(int effectId);
@@ -929,15 +912,12 @@ public:
virtual void saveOutputTracks() { }
virtual void clearOutputTracks() { }
+ // Cache various calculated values, at threadLoop() entry and after a parameter change
+ virtual void cacheParameters_l();
+
private:
- friend class AudioFlinger;
- friend class OutputTrack;
- friend class Track;
- friend class TrackBase;
- friend class MixerThread;
- friend class DirectOutputThread;
- friend class DuplicatingThread;
+ friend class AudioFlinger; // for numerous
PlaybackThread(const Client&);
PlaybackThread& operator = (const PlaybackThread&);
@@ -964,8 +944,11 @@ public:
// FIXME rename these former local variables of threadLoop to standard "m" names
nsecs_t standbyTime;
size_t mixBufferSize;
+
+ // cached copies of activeSleepTimeUs() and idleSleepTimeUs() made by cacheParameters_l()
uint32_t activeSleepTime;
uint32_t idleSleepTime;
+
uint32_t sleepTime;
// mixer status returned by prepareTracks_l()
@@ -976,8 +959,13 @@ public:
// MIXER only
bool longStandbyExit;
uint32_t sleepTimeShift;
- // DIRECT only
+
+ // same as AudioFlinger::mStandbyTimeInNsecs except for DIRECT which uses a shorter value
nsecs_t standbyDelay;
+
+ // MIXER only
+ nsecs_t maxPeriod;
+
// DUPLICATING only
uint32_t writeFrames;
};
@@ -1003,6 +991,7 @@ public:
virtual void deleteTrackName_l(int name);
virtual uint32_t idleSleepTimeUs();
virtual uint32_t suspendSleepTimeUs();
+ virtual void cacheParameters_l();
// threadLoop snippets
virtual void threadLoop_mix();
@@ -1028,6 +1017,7 @@ public:
virtual uint32_t activeSleepTimeUs();
virtual uint32_t idleSleepTimeUs();
virtual uint32_t suspendSleepTimeUs();
+ virtual void cacheParameters_l();
// threadLoop snippets
virtual mixer_state prepareTracks_l(Vector< sp<Track> > *tracksToRemove);
@@ -1048,8 +1038,6 @@ public:
uint16_t rightVol;
private:
- void applyVolume(); // FIXME inline into threadLoop_mix()
-
// prepareTracks_l() tells threadLoop_mix() the name of the single active track
sp<Track> mActiveTrack;
};
@@ -1068,16 +1056,19 @@ private:
virtual uint32_t activeSleepTimeUs();
private:
- bool outputsReady(const SortedVector<sp<OutputTrack> > &outputTracks);
+ bool outputsReady(const SortedVector< sp<OutputTrack> > &outputTracks);
protected:
// threadLoop snippets
virtual void threadLoop_mix();
virtual void threadLoop_sleepTime();
virtual void threadLoop_write();
virtual void threadLoop_standby();
+ virtual void cacheParameters_l();
+ private:
// called from threadLoop, addOutputTrack, removeOutputTrack
virtual void updateWaitTime_l();
+ protected:
virtual void saveOutputTracks();
virtual void clearOutputTracks();
private:
@@ -1109,8 +1100,6 @@ private:
PlaybackThread *primaryPlaybackThread_l() const;
uint32_t primaryOutputDevice_l() const;
- friend class AudioBuffer;
-
// server side of the client's IAudioTrack
class TrackHandle : public android::BnAudioTrack {
public:
@@ -1135,10 +1124,6 @@ private:
const sp<PlaybackThread::Track> mTrack;
};
- friend class Client;
- friend class PlaybackThread::Track;
-
-
void removeClient_l(pid_t pid);
void removeNotificationClient(pid_t pid);
@@ -1169,8 +1154,7 @@ private:
void dump(char* buffer, size_t size);
private:
- friend class AudioFlinger;
- friend class RecordThread;
+ friend class AudioFlinger; // for mState
RecordTrack(const RecordTrack&);
RecordTrack& operator = (const RecordTrack&);
@@ -1352,8 +1336,7 @@ private:
status_t dump(int fd, const Vector<String16>& args);
protected:
- friend class EffectHandle;
- friend class AudioFlinger;
+ friend class AudioFlinger; // for mHandles
bool mPinned;
// Maximum time allocated to effect engines to complete the turn off sequence
@@ -1437,8 +1420,7 @@ mutable Mutex mLock; // mutex for process, commands and handl
void dump(char* buffer, size_t size);
protected:
- friend class AudioFlinger;
- friend class EffectModule;
+ friend class AudioFlinger; // for mEffect, mHasControl, mEnabled
EffectHandle(const EffectHandle&);
EffectHandle& operator =(const EffectHandle&);
@@ -1522,7 +1504,7 @@ mutable Mutex mLock; // mutex for process, commands and handl
uint32_t strategy() const { return mStrategy; }
void setStrategy(uint32_t strategy)
- { mStrategy = strategy; }
+ { mStrategy = strategy; }
// suspend effect of the given type
void setEffectSuspended_l(const effect_uuid_t *type,
@@ -1536,7 +1518,7 @@ mutable Mutex mLock; // mutex for process, commands and handl
status_t dump(int fd, const Vector<String16>& args);
protected:
- friend class AudioFlinger;
+ friend class AudioFlinger; // for mThread, mEffects
EffectChain(const EffectChain&);
EffectChain& operator =(const EffectChain&);
@@ -1562,7 +1544,7 @@ mutable Mutex mLock; // mutex for process, commands and handl
wp<ThreadBase> mThread; // parent mixer thread
Mutex mLock; // mutex protecting effect list
- Vector<sp<EffectModule> > mEffects; // list of effect modules
+ Vector< sp<EffectModule> > mEffects; // list of effect modules
int mSessionId; // audio session ID
int16_t *mInBuffer; // chain input buffer
int16_t *mOutBuffer; // chain output buffer
@@ -1612,9 +1594,6 @@ mutable Mutex mLock; // mutex for process, commands and handl
int mCnt;
};
- friend class RecordThread;
- friend class PlaybackThread;
-
enum master_volume_support {
// MVS_NONE:
// Audio HAL has no support for master volume, either setting or