Make AudioTrack control block volume field private
This is part of the process of abstracting the control block to make it easier to maintain. Change-Id: Idb8f461e68dab3bcf268159cc0781651c6fb7094
This commit is contained in:
@@ -76,7 +76,9 @@ struct audio_track_cblk_t
|
||||
// Left channel is in [0:15], right channel is in [16:31].
|
||||
// Always read and write the combined pair atomically.
|
||||
// For AudioTrack only, not used by AudioRecord.
|
||||
uint32_t volumeLR;
|
||||
private:
|
||||
uint32_t mVolumeLR;
|
||||
public:
|
||||
|
||||
uint32_t sampleRate;
|
||||
// NOTE: audio_track_cblk_t::frameSize is not equal to AudioTrack::frameSize() for
|
||||
@@ -116,6 +118,17 @@ public:
|
||||
uint16_t getSendLevel_U4_12() const {
|
||||
return mSendLevel;
|
||||
}
|
||||
|
||||
// for AudioTrack client only, caller must limit to 0 <= volumeLR <= 0x10001000
|
||||
void setVolumeLR(uint32_t volumeLR) {
|
||||
mVolumeLR = volumeLR;
|
||||
}
|
||||
|
||||
// for AudioFlinger only; the return value must be validated by the caller
|
||||
uint32_t getVolumeLR() const {
|
||||
return mVolumeLR;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -501,7 +501,7 @@ status_t AudioTrack::setVolume(float left, float right)
|
||||
mVolume[LEFT] = left;
|
||||
mVolume[RIGHT] = right;
|
||||
|
||||
mCblk->volumeLR = (uint32_t(uint16_t(right * 0x1000)) << 16) | uint16_t(left * 0x1000);
|
||||
mCblk->setVolumeLR((uint32_t(uint16_t(right * 0x1000)) << 16) | uint16_t(left * 0x1000));
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
@@ -837,7 +837,7 @@ status_t AudioTrack::createTrack_l(
|
||||
mCblk->stepUser(mCblk->frameCount);
|
||||
}
|
||||
|
||||
mCblk->volumeLR = (uint32_t(uint16_t(mVolume[RIGHT] * 0x1000)) << 16) | uint16_t(mVolume[LEFT] * 0x1000);
|
||||
mCblk->setVolumeLR((uint32_t(uint16_t(mVolume[RIGHT] * 0x1000)) << 16) | uint16_t(mVolume[LEFT] * 0x1000));
|
||||
mCblk->setSendLevel(mSendLevel);
|
||||
mAudioTrack->attachAuxEffect(mAuxEffectId);
|
||||
mCblk->bufferTimeoutMs = MAX_STARTUP_TIMEOUT_MS;
|
||||
@@ -1320,7 +1320,7 @@ void AudioTrack::AudioTrackThread::onFirstRef()
|
||||
audio_track_cblk_t::audio_track_cblk_t()
|
||||
: lock(Mutex::SHARED), cv(Condition::SHARED), user(0), server(0),
|
||||
userBase(0), serverBase(0), buffers(0), frameCount(0),
|
||||
loopStart(UINT_MAX), loopEnd(UINT_MAX), loopCount(0), volumeLR(0),
|
||||
loopStart(UINT_MAX), loopEnd(UINT_MAX), loopCount(0), mVolumeLR(0x10001000),
|
||||
mSendLevel(0), flags(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -2191,7 +2191,7 @@ uint32_t AudioFlinger::MixerThread::prepareTracks_l(const SortedVector< wp<Track
|
||||
// read original volumes with volume control
|
||||
float typeVolume = mStreamTypes[track->type()].volume;
|
||||
float v = masterVolume * typeVolume;
|
||||
uint32_t vlr = cblk->volumeLR;
|
||||
uint32_t vlr = cblk->getVolumeLR();
|
||||
vl = vlr & 0xFFFF;
|
||||
vr = vlr >> 16;
|
||||
// track volumes come from shared memory, so can't be trusted and must be clamped
|
||||
@@ -2727,7 +2727,7 @@ bool AudioFlinger::DirectOutputThread::threadLoop()
|
||||
} else {
|
||||
float typeVolume = mStreamTypes[track->type()].volume;
|
||||
float v = mMasterVolume * typeVolume;
|
||||
uint32_t vlr = cblk->volumeLR;
|
||||
uint32_t vlr = cblk->getVolumeLR();
|
||||
float v_clamped = v * (vlr & 0xFFFF);
|
||||
if (v_clamped > MAX_GAIN) v_clamped = MAX_GAIN;
|
||||
left = v_clamped/MAX_GAIN;
|
||||
@@ -3466,7 +3466,7 @@ void AudioFlinger::PlaybackThread::Track::destroy()
|
||||
|
||||
void AudioFlinger::PlaybackThread::Track::dump(char* buffer, size_t size)
|
||||
{
|
||||
uint32_t vlr = mCblk->volumeLR;
|
||||
uint32_t vlr = mCblk->getVolumeLR();
|
||||
snprintf(buffer, size, " %05d %05d %03u %03u 0x%08x %05u %04u %1d %1d %1d %05u %05u %05u 0x%08x 0x%08x 0x%08x 0x%08x\n",
|
||||
mName - AudioMixer::TRACK0,
|
||||
(mClient == NULL) ? getpid() : mClient->pid(),
|
||||
@@ -3825,7 +3825,6 @@ AudioFlinger::PlaybackThread::OutputTrack::OutputTrack(
|
||||
if (mCblk != NULL) {
|
||||
mCblk->flags |= CBLK_DIRECTION_OUT;
|
||||
mCblk->buffers = (char*)mCblk + sizeof(audio_track_cblk_t);
|
||||
mCblk->volumeLR = (MAX_GAIN_INT << 16) | MAX_GAIN_INT;
|
||||
mOutBuffer.frameCount = 0;
|
||||
playbackThread->mTracks.add(this);
|
||||
ALOGV("OutputTrack constructor mCblk %p, mBuffer %p, mCblk->buffers %p, " \
|
||||
|
||||
Reference in New Issue
Block a user