AudioFlinger methods const and inline
This saves 1063 bytes and probably improves performance. Change-Id: I11cf0dfd925fbaec75e3d1b806852a538eae5518
This commit is contained in:
@@ -1027,26 +1027,6 @@ void AudioFlinger::ThreadBase::exit()
|
||||
requestExitAndWait();
|
||||
}
|
||||
|
||||
uint32_t AudioFlinger::ThreadBase::sampleRate() const
|
||||
{
|
||||
return mSampleRate;
|
||||
}
|
||||
|
||||
int AudioFlinger::ThreadBase::channelCount() const
|
||||
{
|
||||
return (int)mChannelCount;
|
||||
}
|
||||
|
||||
audio_format_t AudioFlinger::ThreadBase::format() const
|
||||
{
|
||||
return mFormat;
|
||||
}
|
||||
|
||||
size_t AudioFlinger::ThreadBase::frameCount() const
|
||||
{
|
||||
return mFrameCount;
|
||||
}
|
||||
|
||||
status_t AudioFlinger::ThreadBase::setParameters(const String8& keyValuePairs)
|
||||
{
|
||||
status_t status;
|
||||
@@ -1611,16 +1591,6 @@ status_t AudioFlinger::PlaybackThread::setMasterMute(bool muted)
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
float AudioFlinger::PlaybackThread::masterVolume() const
|
||||
{
|
||||
return mMasterVolume;
|
||||
}
|
||||
|
||||
bool AudioFlinger::PlaybackThread::masterMute() const
|
||||
{
|
||||
return mMasterMute;
|
||||
}
|
||||
|
||||
status_t AudioFlinger::PlaybackThread::setStreamVolume(audio_stream_type_t stream, float value)
|
||||
{
|
||||
mStreamTypes[stream].volume = value;
|
||||
@@ -3368,23 +3338,10 @@ void AudioFlinger::ThreadBase::TrackBase::reset() {
|
||||
ALOGV("TrackBase::reset");
|
||||
}
|
||||
|
||||
sp<IMemory> AudioFlinger::ThreadBase::TrackBase::getCblk() const
|
||||
{
|
||||
return mCblkMemory;
|
||||
}
|
||||
|
||||
int AudioFlinger::ThreadBase::TrackBase::sampleRate() const {
|
||||
return (int)mCblk->sampleRate;
|
||||
}
|
||||
|
||||
int AudioFlinger::ThreadBase::TrackBase::channelCount() const {
|
||||
return (const int)mChannelCount;
|
||||
}
|
||||
|
||||
uint32_t AudioFlinger::ThreadBase::TrackBase::channelMask() const {
|
||||
return mChannelMask;
|
||||
}
|
||||
|
||||
void* AudioFlinger::ThreadBase::TrackBase::getBuffer(uint32_t offset, uint32_t frames) const {
|
||||
audio_track_cblk_t* cblk = this->cblk();
|
||||
size_t frameSize = cblk->frameSize;
|
||||
@@ -6622,7 +6579,7 @@ status_t AudioFlinger::EffectModule::setEnabled(bool enabled)
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
bool AudioFlinger::EffectModule::isEnabled()
|
||||
bool AudioFlinger::EffectModule::isEnabled() const
|
||||
{
|
||||
switch (mState) {
|
||||
case RESTART:
|
||||
@@ -6638,7 +6595,7 @@ bool AudioFlinger::EffectModule::isEnabled()
|
||||
}
|
||||
}
|
||||
|
||||
bool AudioFlinger::EffectModule::isProcessEnabled()
|
||||
bool AudioFlinger::EffectModule::isProcessEnabled() const
|
||||
{
|
||||
switch (mState) {
|
||||
case RESTART:
|
||||
@@ -7054,10 +7011,6 @@ status_t AudioFlinger::EffectHandle::command(uint32_t cmdCode,
|
||||
return mEffect->command(cmdCode, cmdSize, pCmdData, replySize, pReplyData);
|
||||
}
|
||||
|
||||
sp<IMemory> AudioFlinger::EffectHandle::getCblk() const {
|
||||
return mCblkMemory;
|
||||
}
|
||||
|
||||
void AudioFlinger::EffectHandle::setControl(bool hasControl, bool signal, bool enabled)
|
||||
{
|
||||
ALOGV("setControl %p control %d", this, hasControl);
|
||||
|
||||
@@ -204,7 +204,7 @@ public:
|
||||
|
||||
audio_mode_t getMode() const { return mMode; }
|
||||
|
||||
bool btNrecIsOff() { return mBtNrecIsOff; }
|
||||
bool btNrecIsOff() const { return mBtNrecIsOff; }
|
||||
|
||||
private:
|
||||
|
||||
@@ -228,7 +228,7 @@ private:
|
||||
virtual ~Client();
|
||||
sp<MemoryDealer> heap() const;
|
||||
pid_t pid() const { return mPid; }
|
||||
sp<AudioFlinger> audioFlinger() { return mAudioFlinger; }
|
||||
sp<AudioFlinger> audioFlinger() const { return mAudioFlinger; }
|
||||
|
||||
private:
|
||||
Client(const Client&);
|
||||
@@ -326,9 +326,9 @@ private:
|
||||
|
||||
virtual status_t start() = 0;
|
||||
virtual void stop() = 0;
|
||||
sp<IMemory> getCblk() const;
|
||||
sp<IMemory> getCblk() const { return mCblkMemory; }
|
||||
audio_track_cblk_t* cblk() const { return mCblk; }
|
||||
int sessionId() { return mSessionId; }
|
||||
int sessionId() const { return mSessionId; }
|
||||
|
||||
protected:
|
||||
friend class ThreadBase;
|
||||
@@ -348,11 +348,11 @@ private:
|
||||
return mFormat;
|
||||
}
|
||||
|
||||
int channelCount() const ;
|
||||
int channelCount() const { return mChannelCount; }
|
||||
|
||||
uint32_t channelMask() const;
|
||||
uint32_t channelMask() const { return mChannelMask; }
|
||||
|
||||
int sampleRate() const;
|
||||
int sampleRate() const; // FIXME inline after cblk sr moved
|
||||
|
||||
void* getBuffer(uint32_t offset, uint32_t frames) const;
|
||||
|
||||
@@ -409,10 +409,10 @@ private:
|
||||
|
||||
virtual status_t initCheck() const = 0;
|
||||
type_t type() const { return mType; }
|
||||
uint32_t sampleRate() const;
|
||||
int channelCount() const;
|
||||
audio_format_t format() const;
|
||||
size_t frameCount() const;
|
||||
uint32_t sampleRate() const { return mSampleRate; }
|
||||
int channelCount() const { return mChannelCount; }
|
||||
audio_format_t format() const { return mFormat; }
|
||||
size_t frameCount() const { return mFrameCount; }
|
||||
void wakeUp() { mWaitWorkCV.broadcast(); }
|
||||
void exit();
|
||||
virtual bool checkForNewParameters_l() = 0;
|
||||
@@ -600,10 +600,10 @@ private:
|
||||
}
|
||||
status_t attachAuxEffect(int EffectId);
|
||||
void setAuxBuffer(int EffectId, int32_t *buffer);
|
||||
int32_t *auxBuffer() { return mAuxBuffer; }
|
||||
int32_t *auxBuffer() const { return mAuxBuffer; }
|
||||
void setMainBuffer(int16_t *buffer) { mMainBuffer = buffer; }
|
||||
int16_t *mainBuffer() { return mMainBuffer; }
|
||||
int auxEffectId() { return mAuxEffectId; }
|
||||
int16_t *mainBuffer() const { return mMainBuffer; }
|
||||
int auxEffectId() const { return mAuxEffectId; }
|
||||
|
||||
|
||||
protected:
|
||||
@@ -617,7 +617,7 @@ private:
|
||||
Track& operator = (const Track&);
|
||||
|
||||
virtual status_t getNextBuffer(AudioBufferProvider::Buffer* buffer);
|
||||
bool isMuted() { return mMute; }
|
||||
bool isMuted() const { return mMute; }
|
||||
bool isPausing() const {
|
||||
return mState == PAUSING;
|
||||
}
|
||||
@@ -669,9 +669,9 @@ private:
|
||||
virtual status_t start();
|
||||
virtual void stop();
|
||||
bool write(int16_t* data, uint32_t frames);
|
||||
bool bufferQueueEmpty() { return (mBufferQueue.size() == 0) ? true : false; }
|
||||
bool isActive() { return mActive; }
|
||||
const wp<ThreadBase>& thread() { return mThread; }
|
||||
bool bufferQueueEmpty() const { return (mBufferQueue.size() == 0) ? true : false; }
|
||||
bool isActive() const { return mActive; }
|
||||
const wp<ThreadBase>& thread() const { return mThread; }
|
||||
|
||||
private:
|
||||
|
||||
@@ -708,8 +708,8 @@ private:
|
||||
virtual status_t setMasterVolume(float value);
|
||||
virtual status_t setMasterMute(bool muted);
|
||||
|
||||
virtual float masterVolume() const;
|
||||
virtual bool masterMute() const;
|
||||
virtual float masterVolume() const { return mMasterVolume; }
|
||||
virtual bool masterMute() const { return mMasterMute; }
|
||||
|
||||
virtual status_t setStreamVolume(audio_stream_type_t stream, float value);
|
||||
virtual status_t setStreamMute(audio_stream_type_t stream, bool muted);
|
||||
@@ -738,7 +738,7 @@ private:
|
||||
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);
|
||||
int16_t *mixBuffer() { return mMixBuffer; };
|
||||
int16_t *mixBuffer() const { return mMixBuffer; };
|
||||
|
||||
virtual void detachAuxEffect_l(int effectId);
|
||||
status_t attachAuxEffect(const sp<AudioFlinger::PlaybackThread::Track> track,
|
||||
@@ -1076,7 +1076,7 @@ private:
|
||||
DESTROYED
|
||||
};
|
||||
|
||||
int id() { return mId; }
|
||||
int id() const { return mId; }
|
||||
void process();
|
||||
void updateState();
|
||||
status_t command(uint32_t cmdCode,
|
||||
@@ -1094,12 +1094,12 @@ private:
|
||||
uint32_t status() {
|
||||
return mStatus;
|
||||
}
|
||||
int sessionId() {
|
||||
int sessionId() const {
|
||||
return mSessionId;
|
||||
}
|
||||
status_t setEnabled(bool enabled);
|
||||
bool isEnabled();
|
||||
bool isProcessEnabled();
|
||||
bool isEnabled() const;
|
||||
bool isProcessEnabled() const;
|
||||
|
||||
void setInBuffer(int16_t *buffer) { mConfig.inputCfg.buffer.s16 = buffer; }
|
||||
int16_t *inBuffer() { return mConfig.inputCfg.buffer.s16; }
|
||||
@@ -1126,7 +1126,7 @@ private:
|
||||
|
||||
sp<EffectHandle> controlHandle();
|
||||
|
||||
bool isPinned() { return mPinned; }
|
||||
bool isPinned() const { return mPinned; }
|
||||
void unPin() { mPinned = false; }
|
||||
|
||||
status_t dump(int fd, const Vector<String16>& args);
|
||||
@@ -1187,7 +1187,7 @@ mutable Mutex mLock; // mutex for process, commands and handl
|
||||
void *pReplyData);
|
||||
virtual void disconnect();
|
||||
virtual void disconnect(bool unpiniflast);
|
||||
virtual sp<IMemory> getCblk() const;
|
||||
virtual sp<IMemory> getCblk() const { return mCblkMemory; }
|
||||
virtual status_t onTransact(uint32_t code, const Parcel& data,
|
||||
Parcel* reply, uint32_t flags);
|
||||
|
||||
@@ -1203,13 +1203,13 @@ mutable Mutex mLock; // mutex for process, commands and handl
|
||||
uint32_t replySize,
|
||||
void *pReplyData);
|
||||
void setEnabled(bool enabled);
|
||||
bool enabled() { return mEnabled; }
|
||||
bool enabled() const { return mEnabled; }
|
||||
|
||||
// Getters
|
||||
int id() { return mEffect->id(); }
|
||||
int priority() { return mPriority; }
|
||||
bool hasControl() { return mHasControl; }
|
||||
sp<EffectModule> effect() { return mEffect; }
|
||||
int id() const { return mEffect->id(); }
|
||||
int priority() const { return mPriority; }
|
||||
bool hasControl() const { return mHasControl; }
|
||||
sp<EffectModule> effect() const { return mEffect; }
|
||||
|
||||
void dump(char* buffer, size_t size);
|
||||
|
||||
@@ -1263,7 +1263,7 @@ mutable Mutex mLock; // mutex for process, commands and handl
|
||||
status_t addEffect_l(const sp<EffectModule>& handle);
|
||||
size_t removeEffect_l(const sp<EffectModule>& handle);
|
||||
|
||||
int sessionId() { return mSessionId; }
|
||||
int sessionId() const { return mSessionId; }
|
||||
void setSessionId(int sessionId) { mSessionId = sessionId; }
|
||||
|
||||
sp<EffectModule> getEffectFromDesc_l(effect_descriptor_t *descriptor);
|
||||
@@ -1277,26 +1277,26 @@ mutable Mutex mLock; // mutex for process, commands and handl
|
||||
mInBuffer = buffer;
|
||||
mOwnInBuffer = ownsBuffer;
|
||||
}
|
||||
int16_t *inBuffer() {
|
||||
int16_t *inBuffer() const {
|
||||
return mInBuffer;
|
||||
}
|
||||
void setOutBuffer(int16_t *buffer) {
|
||||
mOutBuffer = buffer;
|
||||
}
|
||||
int16_t *outBuffer() {
|
||||
int16_t *outBuffer() const {
|
||||
return mOutBuffer;
|
||||
}
|
||||
|
||||
void incTrackCnt() { android_atomic_inc(&mTrackCnt); }
|
||||
void decTrackCnt() { android_atomic_dec(&mTrackCnt); }
|
||||
int32_t trackCnt() { return mTrackCnt;}
|
||||
int32_t trackCnt() const { return mTrackCnt;}
|
||||
|
||||
void incActiveTrackCnt() { android_atomic_inc(&mActiveTrackCnt);
|
||||
mTailBufferCount = mMaxTailBuffers; }
|
||||
void decActiveTrackCnt() { android_atomic_dec(&mActiveTrackCnt); }
|
||||
int32_t activeTrackCnt() { return mActiveTrackCnt;}
|
||||
int32_t activeTrackCnt() const { return mActiveTrackCnt;}
|
||||
|
||||
uint32_t strategy() { return mStrategy; }
|
||||
uint32_t strategy() const { return mStrategy; }
|
||||
void setStrategy(uint32_t strategy)
|
||||
{ mStrategy = strategy; }
|
||||
|
||||
|
||||
@@ -296,18 +296,6 @@ bool AudioMixer::track_t::setResampler(uint32_t value, uint32_t devSampleRate)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AudioMixer::track_t::doesResample() const
|
||||
{
|
||||
return resampler != NULL;
|
||||
}
|
||||
|
||||
void AudioMixer::track_t::resetResampler()
|
||||
{
|
||||
if (resampler != NULL) {
|
||||
resampler->reset();
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
void AudioMixer::track_t::adjustVolumeRamp(bool aux)
|
||||
{
|
||||
@@ -327,20 +315,11 @@ void AudioMixer::track_t::adjustVolumeRamp(bool aux)
|
||||
}
|
||||
}
|
||||
|
||||
size_t AudioMixer::track_t::getUnreleasedFrames()
|
||||
{
|
||||
if (resampler != NULL) {
|
||||
return resampler->getUnreleasedFrames();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t AudioMixer::getUnreleasedFrames(int name)
|
||||
size_t AudioMixer::getUnreleasedFrames(int name) const
|
||||
{
|
||||
name -= TRACK0;
|
||||
if (uint32_t(name) < MAX_NUM_TRACKS) {
|
||||
track_t& track(mState.tracks[name]);
|
||||
return track.getUnreleasedFrames();
|
||||
return mState.tracks[name].getUnreleasedFrames();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
|
||||
uint32_t trackNames() const { return mTrackNames; }
|
||||
|
||||
size_t getUnreleasedFrames(int name);
|
||||
size_t getUnreleasedFrames(int name) const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -153,10 +153,11 @@ private:
|
||||
int32_t* auxBuffer;
|
||||
|
||||
bool setResampler(uint32_t sampleRate, uint32_t devSampleRate);
|
||||
bool doesResample() const;
|
||||
void resetResampler();
|
||||
bool doesResample() const { return resampler != NULL; }
|
||||
void resetResampler() { if (resampler != NULL) resampler->reset(); }
|
||||
void adjustVolumeRamp(bool aux);
|
||||
size_t getUnreleasedFrames();
|
||||
size_t getUnreleasedFrames() const { return resampler != NULL ?
|
||||
resampler->getUnreleasedFrames() : 0; };
|
||||
};
|
||||
|
||||
// pad to 32-bytes to fill cache line
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
AudioBufferProvider* provider) = 0;
|
||||
|
||||
virtual void reset();
|
||||
virtual size_t getUnreleasedFrames() { return mInputIndex; }
|
||||
virtual size_t getUnreleasedFrames() const { return mInputIndex; }
|
||||
|
||||
protected:
|
||||
// number of bits for phase fraction - 30 bits allows nearly 2x downsampling
|
||||
|
||||
Reference in New Issue
Block a user