summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/media/AudioRecord.h1
-rw-r--r--include/media/AudioTrack.h1
-rw-r--r--include/private/media/AudioTrackShared.h9
-rw-r--r--media/libmedia/AudioRecord.cpp4
-rw-r--r--media/libmedia/AudioTrack.cpp12
-rw-r--r--services/audioflinger/AudioFlinger.cpp6
-rw-r--r--services/audioflinger/AudioFlinger.h1
7 files changed, 19 insertions, 15 deletions
diff --git a/include/media/AudioRecord.h b/include/media/AudioRecord.h
index 0ab26b8..bfb5d3a 100644
--- a/include/media/AudioRecord.h
+++ b/include/media/AudioRecord.h
@@ -389,6 +389,7 @@ private:
sp<IAudioRecord> mAudioRecord;
sp<IMemory> mCblkMemory;
audio_track_cblk_t* mCblk;
+ void* mBuffers; // starting address of buffers in shared memory
int mPreviousPriority; // before start()
SchedPolicy mPreviousSchedulingGroup;
diff --git a/include/media/AudioTrack.h b/include/media/AudioTrack.h
index 6e88032..639b567 100644
--- a/include/media/AudioTrack.h
+++ b/include/media/AudioTrack.h
@@ -510,6 +510,7 @@ protected:
uint32_t mFrameCount;
audio_track_cblk_t* mCblk; // re-load after mLock.unlock()
+ void* mBuffers; // starting address of buffers in shared memory
audio_format_t mFormat;
audio_stream_type_t mStreamType;
uint8_t mChannelCount;
diff --git a/include/private/media/AudioTrackShared.h b/include/private/media/AudioTrackShared.h
index 90301cd..8ef90c7 100644
--- a/include/private/media/AudioTrackShared.h
+++ b/include/private/media/AudioTrackShared.h
@@ -58,9 +58,7 @@ struct audio_track_cblk_t
uint32_t userBase;
uint32_t serverBase;
- // if there is a shared buffer, "buffers" is the value of pointer() for the shared
- // buffer, otherwise "buffers" points immediately after the control block
- void* buffers;
+ int mPad1; // unused, but preserves cache line alignment
uint32_t frameCount;
// Cache line boundary
@@ -111,7 +109,10 @@ public:
bool stepServer(uint32_t frameCount, bool isOut);
- void* buffer(uint32_t offset) const;
+ // if there is a shared buffer, "buffers" is the value of pointer() for the shared
+ // buffer, otherwise "buffers" points immediately after the control block
+ void* buffer(void *buffers, uint32_t offset) const;
+
uint32_t framesAvailableIn() { return framesAvailable(false); }
uint32_t framesAvailableOut() { return framesAvailable(true); }
uint32_t framesAvailableIn_l() { return framesAvailable_l(false); }
diff --git a/media/libmedia/AudioRecord.cpp b/media/libmedia/AudioRecord.cpp
index ae1842e..263a7c7 100644
--- a/media/libmedia/AudioRecord.cpp
+++ b/media/libmedia/AudioRecord.cpp
@@ -465,7 +465,7 @@ status_t AudioRecord::openRecord_l(
mCblkMemory.clear();
mCblkMemory = cblk;
mCblk = static_cast<audio_track_cblk_t*>(cblk->pointer());
- mCblk->buffers = (char*)mCblk + sizeof(audio_track_cblk_t);
+ mBuffers = (char*)mCblk + sizeof(audio_track_cblk_t);
mCblk->bufferTimeoutMs = MAX_RUN_TIMEOUT_MS;
mCblk->waitTimeMs = 0;
return NO_ERROR;
@@ -561,7 +561,7 @@ create_new_record:
audioBuffer->frameCount = framesReq;
audioBuffer->size = framesReq*cblk->frameSize;
- audioBuffer->raw = (int8_t*)cblk->buffer(u);
+ audioBuffer->raw = cblk->buffer(mBuffers, u);
active = mActive;
return active ? status_t(NO_ERROR) : status_t(STOPPED);
}
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index 7ce9879..468bd29 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -895,9 +895,9 @@ status_t AudioTrack::createTrack_l(
}
}
if (sharedBuffer == 0) {
- cblk->buffers = (char*)cblk + sizeof(audio_track_cblk_t);
+ mBuffers = (char*)cblk + sizeof(audio_track_cblk_t);
} else {
- cblk->buffers = sharedBuffer->pointer();
+ mBuffers = sharedBuffer->pointer();
// Force buffer full condition as data is already present in shared memory
cblk->stepUserOut(cblk->frameCount);
}
@@ -1027,7 +1027,7 @@ create_new_track:
audioBuffer->frameCount = framesReq;
audioBuffer->size = framesReq * cblk->frameSize;
- audioBuffer->raw = (int8_t *)cblk->buffer(u);
+ audioBuffer->raw = cblk->buffer(mBuffers, u);
active = mActive;
return active ? status_t(NO_ERROR) : status_t(STOPPED);
}
@@ -1373,7 +1373,7 @@ status_t AudioTrack::restoreTrack_l(audio_track_cblk_t*& refCblk, bool fromStart
if (user > server) {
frames = ((user - server) > newCblk->frameCount) ?
newCblk->frameCount : (user - server);
- memset(newCblk->buffers, 0, frames * newCblk->frameSize);
+ memset(mBuffers, 0, frames * newCblk->frameSize);
}
// restart playback even if buffer is not completely filled.
android_atomic_or(CBLK_FORCEREADY, &newCblk->flags);
@@ -1486,7 +1486,7 @@ void AudioTrack::AudioTrackThread::resume()
audio_track_cblk_t::audio_track_cblk_t()
: lock(Mutex::SHARED), cv(Condition::SHARED), user(0), server(0),
- userBase(0), serverBase(0), buffers(NULL), frameCount(0),
+ userBase(0), serverBase(0), frameCount(0),
loopStart(UINT_MAX), loopEnd(UINT_MAX), loopCount(0), mVolumeLR(0x10001000),
mSendLevel(0), flags(0)
{
@@ -1588,7 +1588,7 @@ bool audio_track_cblk_t::stepServer(uint32_t frameCount, bool isOut)
return true;
}
-void* audio_track_cblk_t::buffer(uint32_t offset) const
+void* audio_track_cblk_t::buffer(void *buffers, uint32_t offset) const
{
return (int8_t *)buffers + (offset - userBase) * frameSize;
}
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 69ac3e3..c0f5c7b 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -5534,11 +5534,11 @@ AudioFlinger::PlaybackThread::OutputTrack::OutputTrack(
int frameCount)
: Track(playbackThread, NULL, AUDIO_STREAM_CNT, sampleRate, format, channelMask, frameCount,
NULL, 0, IAudioFlinger::TRACK_DEFAULT),
- mActive(false), mSourceThread(sourceThread)
+ mActive(false), mSourceThread(sourceThread), mBuffers(NULL)
{
if (mCblk != NULL) {
- mCblk->buffers = (char*)mCblk + sizeof(audio_track_cblk_t);
+ mBuffers = (char*)mCblk + sizeof(audio_track_cblk_t);
mOutBuffer.frameCount = 0;
playbackThread->mTracks.add(this);
ALOGV("OutputTrack constructor mCblk %p, mBuffer %p, mCblk->buffers %p, " \
@@ -5749,7 +5749,7 @@ status_t AudioFlinger::PlaybackThread::OutputTrack::obtainBuffer(
}
buffer->frameCount = framesReq;
- buffer->raw = (void *)cblk->buffer(u);
+ buffer->raw = cblk->buffer(mBuffers, u);
return NO_ERROR;
}
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index 1417105..fc24bed 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -1035,6 +1035,7 @@ private:
AudioBufferProvider::Buffer mOutBuffer;
bool mActive;
DuplicatingThread* const mSourceThread; // for waitTimeMs() in write()
+ void* mBuffers; // starting address of buffers in plain memory
}; // end of OutputTrack
PlaybackThread(const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output,