summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2013-12-19 08:56:45 -0800
committerGlenn Kasten <gkasten@google.com>2013-12-20 08:40:55 -0800
commit74935e44734c1ec235c2b6677db3e0dbefa5ddb8 (patch)
treedc7bc2c9f496097e95ff36440fcd79886517ba53 /media
parentbd72d22097f78f5bd668b223bc8c94e351311e31 (diff)
downloadframeworks_av-74935e44734c1ec235c2b6677db3e0dbefa5ddb8.zip
frameworks_av-74935e44734c1ec235c2b6677db3e0dbefa5ddb8.tar.gz
frameworks_av-74935e44734c1ec235c2b6677db3e0dbefa5ddb8.tar.bz2
Replace control block frameCount_ by explicit in/out parameter
in IAudioFlinger::createTrack and IAudioFlinger::openRecord Change-Id: I09c644c80e92c8e744b1b99055988a2588b2a83d
Diffstat (limited to 'media')
-rw-r--r--media/libmedia/AudioRecord.cpp13
-rw-r--r--media/libmedia/AudioTrack.cpp6
-rw-r--r--media/libmedia/AudioTrackShared.cpp2
-rw-r--r--media/libmedia/IAudioFlinger.cpp20
4 files changed, 30 insertions, 11 deletions
diff --git a/media/libmedia/AudioRecord.cpp b/media/libmedia/AudioRecord.cpp
index 666fafa..13c9f60 100644
--- a/media/libmedia/AudioRecord.cpp
+++ b/media/libmedia/AudioRecord.cpp
@@ -255,9 +255,6 @@ status_t AudioRecord::set(
mStatus = NO_ERROR;
- // Update buffer size in case it has been limited by AudioFlinger during track creation
- mFrameCount = mCblk->frameCount_;
-
mActive = false;
mCbf = cbf;
mRefreshRemaining = true;
@@ -462,11 +459,13 @@ status_t AudioRecord::openRecord_l(size_t epoch)
return BAD_VALUE;
}
+ size_t temp = mFrameCount; // temp may be replaced by a revised value of frameCount,
+ // but we will still need the original value also
int originalSessionId = mSessionId;
sp<IAudioRecord> record = audioFlinger->openRecord(input,
mSampleRate, mFormat,
mChannelMask,
- mFrameCount,
+ &temp,
&trackFlags,
tid,
&mSessionId,
@@ -498,6 +497,12 @@ status_t AudioRecord::openRecord_l(size_t epoch)
mCblkMemory = iMem;
audio_track_cblk_t* cblk = static_cast<audio_track_cblk_t*>(iMemPointer);
mCblk = cblk;
+ // note that temp is the (possibly revised) value of mFrameCount
+ if (temp < mFrameCount || (mFrameCount == 0 && temp == 0)) {
+ ALOGW("Requested frameCount %u but received frameCount %u", mFrameCount, temp);
+ }
+ mFrameCount = temp;
+
// FIXME missing fast track frameCount logic
mAwaitBoost = false;
if (mFlags & AUDIO_INPUT_FLAG_FAST) {
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index b48cb1f..74bb7a6 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -969,13 +969,15 @@ status_t AudioTrack::createTrack_l(
trackFlags |= IAudioFlinger::TRACK_OFFLOAD;
}
+ size_t temp = frameCount; // temp may be replaced by a revised value of frameCount,
+ // but we will still need the original value also
sp<IAudioTrack> track = audioFlinger->createTrack(streamType,
sampleRate,
// AudioFlinger only sees 16-bit PCM
format == AUDIO_FORMAT_PCM_8_BIT ?
AUDIO_FORMAT_PCM_16_BIT : format,
mChannelMask,
- frameCount,
+ &temp,
&trackFlags,
sharedBuffer,
output,
@@ -1003,7 +1005,7 @@ status_t AudioTrack::createTrack_l(
mCblkMemory = iMem;
audio_track_cblk_t* cblk = static_cast<audio_track_cblk_t*>(iMem->pointer());
mCblk = cblk;
- size_t temp = cblk->frameCount_;
+ // note that temp is the (possibly revised) value of frameCount
if (temp < frameCount || (frameCount == 0 && temp == 0)) {
// In current design, AudioTrack client checks and ensures frame count validity before
// passing it to AudioFlinger so AudioFlinger should not return a different value except
diff --git a/media/libmedia/AudioTrackShared.cpp b/media/libmedia/AudioTrackShared.cpp
index caa7900..11f5d58 100644
--- a/media/libmedia/AudioTrackShared.cpp
+++ b/media/libmedia/AudioTrackShared.cpp
@@ -26,7 +26,7 @@ extern "C" {
namespace android {
audio_track_cblk_t::audio_track_cblk_t()
- : mServer(0), frameCount_(0), mFutex(0), mMinimum(0),
+ : mServer(0), mFutex(0), mMinimum(0),
mVolumeLR(0x10001000), mSampleRate(0), mSendLevel(0), mFlags(0)
{
memset(&u, 0, sizeof(u));
diff --git a/media/libmedia/IAudioFlinger.cpp b/media/libmedia/IAudioFlinger.cpp
index 9df10f0..c33cb13 100644
--- a/media/libmedia/IAudioFlinger.cpp
+++ b/media/libmedia/IAudioFlinger.cpp
@@ -89,7 +89,7 @@ public:
uint32_t sampleRate,
audio_format_t format,
audio_channel_mask_t channelMask,
- size_t frameCount,
+ size_t *pFrameCount,
track_flags_t *flags,
const sp<IMemory>& sharedBuffer,
audio_io_handle_t output,
@@ -106,6 +106,7 @@ public:
data.writeInt32(sampleRate);
data.writeInt32(format);
data.writeInt32(channelMask);
+ size_t frameCount = pFrameCount != NULL ? *pFrameCount : 0;
data.writeInt32(frameCount);
track_flags_t lFlags = flags != NULL ? *flags : (track_flags_t) TRACK_DEFAULT;
data.writeInt32(lFlags);
@@ -127,6 +128,10 @@ public:
if (lStatus != NO_ERROR) {
ALOGE("createTrack error: %s", strerror(-lStatus));
} else {
+ frameCount = reply.readInt32();
+ if (pFrameCount != NULL) {
+ *pFrameCount = frameCount;
+ }
lFlags = reply.readInt32();
if (flags != NULL) {
*flags = lFlags;
@@ -150,7 +155,7 @@ public:
uint32_t sampleRate,
audio_format_t format,
audio_channel_mask_t channelMask,
- size_t frameCount,
+ size_t *pFrameCount,
track_flags_t *flags,
pid_t tid,
int *sessionId,
@@ -163,6 +168,7 @@ public:
data.writeInt32(sampleRate);
data.writeInt32(format);
data.writeInt32(channelMask);
+ size_t frameCount = pFrameCount != NULL ? *pFrameCount : 0;
data.writeInt32(frameCount);
track_flags_t lFlags = flags != NULL ? *flags : (track_flags_t) TRACK_DEFAULT;
data.writeInt32(lFlags);
@@ -176,6 +182,10 @@ public:
if (lStatus != NO_ERROR) {
ALOGE("openRecord error: %s", strerror(-lStatus));
} else {
+ frameCount = reply.readInt32();
+ if (pFrameCount != NULL) {
+ *pFrameCount = frameCount;
+ }
lFlags = reply.readInt32();
if (flags != NULL) {
*flags = lFlags;
@@ -793,9 +803,10 @@ status_t BnAudioFlinger::onTransact(
} else {
track = createTrack(
(audio_stream_type_t) streamType, sampleRate, format,
- channelMask, frameCount, &flags, buffer, output, tid,
+ channelMask, &frameCount, &flags, buffer, output, tid,
&sessionId, name, clientUid, &status);
}
+ reply->writeInt32(frameCount);
reply->writeInt32(flags);
reply->writeInt32(sessionId);
reply->writeString8(name);
@@ -815,8 +826,9 @@ status_t BnAudioFlinger::onTransact(
int sessionId = data.readInt32();
status_t status;
sp<IAudioRecord> record = openRecord(input,
- sampleRate, format, channelMask, frameCount, &flags, tid, &sessionId, &status);
+ sampleRate, format, channelMask, &frameCount, &flags, tid, &sessionId, &status);
LOG_ALWAYS_FATAL_IF((record != 0) != (status == NO_ERROR));
+ reply->writeInt32(frameCount);
reply->writeInt32(flags);
reply->writeInt32(sessionId);
reply->writeInt32(status);