summaryrefslogtreecommitdiffstats
path: root/media/libmedia
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2012-11-06 16:15:41 -0800
committerGlenn Kasten <gkasten@google.com>2012-11-07 08:32:40 -0800
commitba85098eb31bd2637db49816f0591361211024f2 (patch)
treeac7f6e3c4d620dbbc87991dbb41944c53245c72a /media/libmedia
parent891b11da870ad3f860c1d2610ef4d8836ed6c590 (diff)
downloadframeworks_av-ba85098eb31bd2637db49816f0591361211024f2.zip
frameworks_av-ba85098eb31bd2637db49816f0591361211024f2.tar.gz
frameworks_av-ba85098eb31bd2637db49816f0591361211024f2.tar.bz2
Remove CBLK_DIRECTION from control block flags
This is part of a series to clean up the control block. Change-Id: I0265fece3247356b585d4d48fbda6f37aea8a851
Diffstat (limited to 'media/libmedia')
-rw-r--r--media/libmedia/AudioRecord.cpp9
-rw-r--r--media/libmedia/AudioTrack.cpp37
2 files changed, 22 insertions, 24 deletions
diff --git a/media/libmedia/AudioRecord.cpp b/media/libmedia/AudioRecord.cpp
index 3c28ca7..ae1842e 100644
--- a/media/libmedia/AudioRecord.cpp
+++ b/media/libmedia/AudioRecord.cpp
@@ -466,7 +466,6 @@ status_t AudioRecord::openRecord_l(
mCblkMemory = cblk;
mCblk = static_cast<audio_track_cblk_t*>(cblk->pointer());
mCblk->buffers = (char*)mCblk + sizeof(audio_track_cblk_t);
- android_atomic_and(~CBLK_DIRECTION, &mCblk->flags);
mCblk->bufferTimeoutMs = MAX_RUN_TIMEOUT_MS;
mCblk->waitTimeMs = 0;
return NO_ERROR;
@@ -484,7 +483,7 @@ status_t AudioRecord::obtainBuffer(Buffer* audioBuffer, int32_t waitCount)
audioBuffer->frameCount = 0;
audioBuffer->size = 0;
- uint32_t framesReady = cblk->framesReady();
+ uint32_t framesReady = cblk->framesReadyIn();
if (framesReady == 0) {
cblk->lock.lock();
@@ -540,7 +539,7 @@ create_new_record:
}
// read the server count again
start_loop_here:
- framesReady = cblk->framesReady();
+ framesReady = cblk->framesReadyIn();
}
cblk->lock.unlock();
}
@@ -570,7 +569,7 @@ create_new_record:
void AudioRecord::releaseBuffer(Buffer* audioBuffer)
{
AutoMutex lock(mLock);
- mCblk->stepUser(audioBuffer->frameCount);
+ mCblk->stepUserIn(audioBuffer->frameCount);
}
audio_io_handle_t AudioRecord::getInput() const
@@ -732,7 +731,7 @@ bool AudioRecord::processAudioBuffer(const sp<AudioRecordThread>& thread)
// Manage overrun callback
- if (active && (cblk->framesAvailable() == 0)) {
+ if (active && (cblk->framesAvailableIn() == 0)) {
// The value of active is stale, but we are almost sure to be active here because
// otherwise we would have exited when obtainBuffer returned STOPPED earlier.
ALOGV("Overrun user: %x, server: %x, flags %04x", cblk->user, cblk->server, cblk->flags);
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index 5348646..f55ec9a 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -695,7 +695,7 @@ status_t AudioTrack::reload()
flush_l();
audio_track_cblk_t* cblk = mCblk;
- cblk->stepUser(cblk->frameCount);
+ cblk->stepUserOut(cblk->frameCount);
return NO_ERROR;
}
@@ -887,7 +887,6 @@ status_t AudioTrack::createTrack_l(
mCblkMemory = iMem;
audio_track_cblk_t* cblk = static_cast<audio_track_cblk_t*>(iMem->pointer());
mCblk = cblk;
- android_atomic_or(CBLK_DIRECTION, &cblk->flags);
if (flags & AUDIO_OUTPUT_FLAG_FAST) {
if (trackFlags & IAudioFlinger::TRACK_FAST) {
ALOGV("AUDIO_OUTPUT_FLAG_FAST successful; frameCount %u", cblk->frameCount);
@@ -906,7 +905,7 @@ status_t AudioTrack::createTrack_l(
} else {
cblk->buffers = sharedBuffer->pointer();
// Force buffer full condition as data is already present in shared memory
- cblk->stepUser(cblk->frameCount);
+ cblk->stepUserOut(cblk->frameCount);
}
cblk->setVolumeLR((uint32_t(uint16_t(mVolume[RIGHT] * 0x1000)) << 16) |
@@ -938,7 +937,7 @@ status_t AudioTrack::obtainBuffer(Buffer* audioBuffer, int32_t waitCount)
audioBuffer->frameCount = 0;
audioBuffer->size = 0;
- uint32_t framesAvail = cblk->framesAvailable();
+ uint32_t framesAvail = cblk->framesAvailableOut();
cblk->lock.lock();
if (cblk->flags & CBLK_INVALID) {
@@ -1009,7 +1008,7 @@ create_new_track:
}
// read the server count again
start_loop_here:
- framesAvail = cblk->framesAvailable_l();
+ framesAvail = cblk->framesAvailableOut_l();
}
cblk->lock.unlock();
}
@@ -1038,7 +1037,7 @@ void AudioTrack::releaseBuffer(Buffer* audioBuffer)
{
AutoMutex lock(mLock);
audio_track_cblk_t* cblk = mCblk;
- cblk->stepUser(audioBuffer->frameCount);
+ cblk->stepUserOut(audioBuffer->frameCount);
if (audioBuffer->frameCount > 0) {
// restart track if it was disabled by audioflinger due to previous underrun
if (mActive && (cblk->flags & CBLK_DISABLED)) {
@@ -1193,7 +1192,7 @@ bool AudioTrack::processAudioBuffer(const sp<AudioTrackThread>& thread)
mLock.unlock();
// Manage underrun callback
- if (active && (cblk->framesAvailable() == cblk->frameCount)) {
+ if (active && (cblk->framesAvailableOut() == cblk->frameCount)) {
ALOGV("Underrun user: %x, server: %x, flags %04x", cblk->user, cblk->server, cblk->flags);
if (!(android_atomic_or(CBLK_UNDERRUN, &cblk->flags) & CBLK_UNDERRUN)) {
mCbf(EVENT_UNDERRUN, mUserData, 0);
@@ -1370,11 +1369,11 @@ status_t AudioTrack::restoreTrack_l(audio_track_cblk_t*& refCblk, bool fromStart
android_atomic_or(CBLK_FORCEREADY, &newCblk->flags);
// stepUser() clears CBLK_UNDERRUN flag enabling underrun callbacks to
// the client
- newCblk->stepUser(frames);
+ newCblk->stepUserOut(frames);
}
}
if (mSharedBuffer != 0) {
- newCblk->stepUser(newCblk->frameCount);
+ newCblk->stepUserOut(newCblk->frameCount);
}
if (mActive) {
result = mAudioTrack->start();
@@ -1514,14 +1513,14 @@ audio_track_cblk_t::audio_track_cblk_t()
{
}
-uint32_t audio_track_cblk_t::stepUser(uint32_t frameCount)
+uint32_t audio_track_cblk_t::stepUser(uint32_t frameCount, bool isOut)
{
ALOGV("stepuser %08x %08x %d", user, server, frameCount);
uint32_t u = user;
u += frameCount;
// Ensure that user is never ahead of server for AudioRecord
- if (flags & CBLK_DIRECTION) {
+ if (isOut) {
// If stepServer() has been called once, switch to normal obtainBuffer() timeout period
if (bufferTimeoutMs == MAX_STARTUP_TIMEOUT_MS-1) {
bufferTimeoutMs = MAX_RUN_TIMEOUT_MS;
@@ -1552,7 +1551,7 @@ uint32_t audio_track_cblk_t::stepUser(uint32_t frameCount)
return u;
}
-bool audio_track_cblk_t::stepServer(uint32_t frameCount)
+bool audio_track_cblk_t::stepServer(uint32_t frameCount, bool isOut)
{
ALOGV("stepserver %08x %08x %d", user, server, frameCount);
@@ -1565,7 +1564,7 @@ bool audio_track_cblk_t::stepServer(uint32_t frameCount)
bool flushed = (s == user);
s += frameCount;
- if (flags & CBLK_DIRECTION) {
+ if (isOut) {
// Mark that we have read the first buffer so that next time stepUser() is called
// we switch to normal obtainBuffer() timeout period
if (bufferTimeoutMs == MAX_STARTUP_TIMEOUT_MS) {
@@ -1615,18 +1614,18 @@ void* audio_track_cblk_t::buffer(uint32_t offset) const
return (int8_t *)buffers + (offset - userBase) * frameSize;
}
-uint32_t audio_track_cblk_t::framesAvailable()
+uint32_t audio_track_cblk_t::framesAvailable(bool isOut)
{
Mutex::Autolock _l(lock);
- return framesAvailable_l();
+ return framesAvailable_l(isOut);
}
-uint32_t audio_track_cblk_t::framesAvailable_l()
+uint32_t audio_track_cblk_t::framesAvailable_l(bool isOut)
{
uint32_t u = user;
uint32_t s = server;
- if (flags & CBLK_DIRECTION) {
+ if (isOut) {
uint32_t limit = (s < loopStart) ? s : loopStart;
return limit + frameCount - u;
} else {
@@ -1634,12 +1633,12 @@ uint32_t audio_track_cblk_t::framesAvailable_l()
}
}
-uint32_t audio_track_cblk_t::framesReady()
+uint32_t audio_track_cblk_t::framesReady(bool isOut)
{
uint32_t u = user;
uint32_t s = server;
- if (flags & CBLK_DIRECTION) {
+ if (isOut) {
if (u < loopEnd) {
return u - s;
} else {