summaryrefslogtreecommitdiffstats
path: root/services/audioflinger
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2012-03-21 08:29:18 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-03-21 08:29:18 -0700
commit4351d4aa8ebf7e067bb245ef42fc0b3ac0b3d2fa (patch)
treef6b00c67761e75697851f8f86e37b46da80859cd /services/audioflinger
parent004f9bac41e762b52e28ade469c057f6f0e833d2 (diff)
parente9b2b3be1305146a06fac577f4c2abf69171b47d (diff)
downloadframeworks_base-4351d4aa8ebf7e067bb245ef42fc0b3ac0b3d2fa.zip
frameworks_base-4351d4aa8ebf7e067bb245ef42fc0b3ac0b3d2fa.tar.gz
frameworks_base-4351d4aa8ebf7e067bb245ef42fc0b3ac0b3d2fa.tar.bz2
Merge "Clean up Track constructor"
Diffstat (limited to 'services/audioflinger')
-rw-r--r--services/audioflinger/AudioFlinger.cpp24
-rw-r--r--services/audioflinger/AudioFlinger.h4
2 files changed, 16 insertions, 12 deletions
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 3ab4e34..e92e69c 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -3481,23 +3481,27 @@ AudioFlinger::PlaybackThread::Track::Track(
const sp<IMemory>& sharedBuffer,
int sessionId)
: TrackBase(thread, client, sampleRate, format, channelMask, frameCount, sharedBuffer, sessionId),
- mMute(false), mSharedBuffer(sharedBuffer), mName(-1), mMainBuffer(NULL), mAuxBuffer(NULL),
+ mMute(false),
+ // mFillingUpStatus ?
+ // mRetryCount initialized later when needed
+ mSharedBuffer(sharedBuffer),
+ mStreamType(streamType),
+ mName(-1), // see note below
+ mMainBuffer(thread->mixBuffer()),
+ mAuxBuffer(NULL),
mAuxEffectId(0), mHasVolumeController(false)
{
if (mCblk != NULL) {
- if (thread != NULL) {
- mName = thread->getTrackName_l();
- mMainBuffer = thread->mixBuffer();
- }
- ALOGV("Track constructor name %d, calling pid %d", mName, IPCThreadState::self()->getCallingPid());
- if (mName < 0) {
- ALOGE("no more track names available");
- }
- mStreamType = streamType;
// NOTE: audio_track_cblk_t::frameSize for 8 bit PCM data is based on a sample size of
// 16 bit because data is converted to 16 bit before being stored in buffer by AudioTrack
mCblk->frameSize = audio_is_linear_pcm(format) ? mChannelCount * sizeof(int16_t) : sizeof(uint8_t);
+ // to avoid leaking a track name, do not allocate one unless there is an mCblk
+ mName = thread->getTrackName_l();
+ if (mName < 0) {
+ ALOGE("no more track names available");
+ }
}
+ ALOGV("Track constructor name %d, calling pid %d", mName, IPCThreadState::self()->getCallingPid());
}
AudioFlinger::PlaybackThread::Track::~Track()
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index 7a57613..d1950a3 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -681,9 +681,9 @@ private:
enum {FS_FILLING, FS_FILLED, FS_ACTIVE};
mutable uint8_t mFillingUpStatus;
int8_t mRetryCount;
- sp<IMemory> mSharedBuffer;
+ const sp<IMemory> mSharedBuffer;
bool mResetDone;
- audio_stream_type_t mStreamType;
+ const audio_stream_type_t mStreamType;
int mName;
int16_t *mMainBuffer;
int32_t *mAuxBuffer;