summaryrefslogtreecommitdiffstats
path: root/media/libmedia
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2012-11-14 12:47:55 -0800
committerGlenn Kasten <gkasten@google.com>2012-11-19 11:25:58 -0800
commitc45128af9231a6e26c4deef798b79e74e4fad904 (patch)
treecef13b83707e9d7ed208f6486768c6f666cafdd9 /media/libmedia
parent7aeff3f2197de81271c3e5547486f3407be56182 (diff)
downloadframeworks_av-c45128af9231a6e26c4deef798b79e74e4fad904.zip
frameworks_av-c45128af9231a6e26c4deef798b79e74e4fad904.tar.gz
frameworks_av-c45128af9231a6e26c4deef798b79e74e4fad904.tar.bz2
Clean up channel count and channel mask
Channel count is uint32_t. Remove redundant mask parameter to AudioTrack::createTrack_l() and AudioRecord::openRecord_l(). Change-Id: I5dc2b18eb609b2c0dc3091994cbaa4628062c17f
Diffstat (limited to 'media/libmedia')
-rw-r--r--media/libmedia/AudioRecord.cpp20
-rw-r--r--media/libmedia/AudioTrack.cpp24
2 files changed, 18 insertions, 26 deletions
diff --git a/media/libmedia/AudioRecord.cpp b/media/libmedia/AudioRecord.cpp
index 2a5a996..c2ef68c 100644
--- a/media/libmedia/AudioRecord.cpp
+++ b/media/libmedia/AudioRecord.cpp
@@ -63,7 +63,7 @@ status_t AudioRecord::getMinFrameCount(
size <<= 1;
if (audio_is_linear_pcm(format)) {
- int channelCount = popcount(channelMask);
+ uint32_t channelCount = popcount(channelMask);
size /= channelCount * audio_bytes_per_sample(format);
}
@@ -162,8 +162,9 @@ status_t AudioRecord::set(
if (!audio_is_input_channel(channelMask)) {
return BAD_VALUE;
}
-
- int channelCount = popcount(channelMask);
+ mChannelMask = channelMask;
+ uint32_t channelCount = popcount(channelMask);
+ mChannelCount = channelCount;
if (sessionId == 0 ) {
mSessionId = AudioSystem::newAudioSessionId();
@@ -201,8 +202,7 @@ status_t AudioRecord::set(
}
// create the IAudioRecord
- status = openRecord_l(sampleRate, format, channelMask,
- frameCount, input);
+ status = openRecord_l(sampleRate, format, frameCount, input);
if (status != NO_ERROR) {
return status;
}
@@ -217,8 +217,6 @@ status_t AudioRecord::set(
mFormat = format;
// Update buffer size in case it has been limited by AudioFlinger during track creation
mFrameCount = mCblk->frameCount_;
- mChannelCount = (uint8_t)channelCount;
- mChannelMask = channelMask;
if (audio_is_linear_pcm(mFormat)) {
mFrameSize = channelCount * audio_bytes_per_sample(format);
@@ -261,7 +259,7 @@ audio_format_t AudioRecord::format() const
return mFormat;
}
-int AudioRecord::channelCount() const
+uint32_t AudioRecord::channelCount() const
{
return mChannelCount;
}
@@ -432,7 +430,6 @@ unsigned int AudioRecord::getInputFramesLost() const
status_t AudioRecord::openRecord_l(
uint32_t sampleRate,
audio_format_t format,
- audio_channel_mask_t channelMask,
size_t frameCount,
audio_io_handle_t input)
{
@@ -449,7 +446,7 @@ status_t AudioRecord::openRecord_l(
int originalSessionId = mSessionId;
sp<IAudioRecord> record = audioFlinger->openRecord(getpid(), input,
sampleRate, format,
- channelMask,
+ mChannelMask,
frameCount,
IAudioFlinger::TRACK_DEFAULT,
tid,
@@ -784,8 +781,7 @@ status_t AudioRecord::restoreRecord_l(audio_track_cblk_t*& refCblk)
// if the new IAudioRecord is created, openRecord_l() will modify the
// following member variables: mAudioRecord, mCblkMemory and mCblk.
// It will also delete the strong references on previous IAudioRecord and IMemory
- result = openRecord_l(cblk->sampleRate, mFormat, mChannelMask,
- mFrameCount, getInput_l());
+ result = openRecord_l(cblk->sampleRate, mFormat, mFrameCount, getInput_l());
if (result == NO_ERROR) {
newCblk = mCblk;
// callback thread or sync event hasn't changed
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index ff1b21b..e40895a 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -243,7 +243,9 @@ status_t AudioTrack::set(
ALOGE("Invalid channel mask %#x", channelMask);
return BAD_VALUE;
}
+ mChannelMask = channelMask;
uint32_t channelCount = popcount(channelMask);
+ mChannelCount = channelCount;
audio_io_handle_t output = AudioSystem::getOutput(
streamType,
@@ -275,7 +277,6 @@ status_t AudioTrack::set(
status_t status = createTrack_l(streamType,
sampleRate,
format,
- channelMask,
frameCount,
flags,
sharedBuffer,
@@ -293,8 +294,6 @@ status_t AudioTrack::set(
mStreamType = streamType;
mFormat = format;
- mChannelMask = channelMask;
- mChannelCount = channelCount;
if (audio_is_linear_pcm(format)) {
mFrameSize = channelCount * audio_bytes_per_sample(format);
@@ -340,7 +339,7 @@ audio_format_t AudioTrack::format() const
return mFormat;
}
-int AudioTrack::channelCount() const
+uint32_t AudioTrack::channelCount() const
{
return mChannelCount;
}
@@ -758,7 +757,6 @@ status_t AudioTrack::createTrack_l(
audio_stream_type_t streamType,
uint32_t sampleRate,
audio_format_t format,
- audio_channel_mask_t channelMask,
size_t frameCount,
audio_output_flags_t flags,
const sp<IMemory>& sharedBuffer,
@@ -808,17 +806,16 @@ status_t AudioTrack::createTrack_l(
} else if (sharedBuffer != 0) {
- // Ensure that buffer alignment matches channelCount
- int channelCount = popcount(channelMask);
+ // Ensure that buffer alignment matches channel count
// 8-bit data in shared memory is not currently supported by AudioFlinger
size_t alignment = /* format == AUDIO_FORMAT_PCM_8_BIT ? 1 : */ 2;
- if (channelCount > 1) {
+ if (mChannelCount > 1) {
// More than 2 channels does not require stronger alignment than stereo
alignment <<= 1;
}
- if (((uint32_t)sharedBuffer->pointer() & (alignment - 1)) != 0) {
- ALOGE("Invalid buffer alignment: address %p, channelCount %d",
- sharedBuffer->pointer(), channelCount);
+ if (((size_t)sharedBuffer->pointer() & (alignment - 1)) != 0) {
+ ALOGE("Invalid buffer alignment: address %p, channel count %u",
+ sharedBuffer->pointer(), mChannelCount);
return BAD_VALUE;
}
@@ -826,7 +823,7 @@ status_t AudioTrack::createTrack_l(
// there's no frameCount parameter.
// But when initializing a shared buffer AudioTrack via set(),
// there _is_ a frameCount parameter. We silently ignore it.
- frameCount = sharedBuffer->size()/channelCount/sizeof(int16_t);
+ frameCount = sharedBuffer->size()/mChannelCount/sizeof(int16_t);
} else if (!(flags & AUDIO_OUTPUT_FLAG_FAST)) {
@@ -890,7 +887,7 @@ status_t AudioTrack::createTrack_l(
// AudioFlinger only sees 16-bit PCM
format == AUDIO_FORMAT_PCM_8_BIT ?
AUDIO_FORMAT_PCM_16_BIT : format,
- channelMask,
+ mChannelMask,
frameCount,
&trackFlags,
sharedBuffer,
@@ -1398,7 +1395,6 @@ status_t AudioTrack::restoreTrack_l(audio_track_cblk_t*& refCblk, bool fromStart
result = createTrack_l(mStreamType,
cblk->sampleRate,
mFormat,
- mChannelMask,
mReqFrameCount, // so that frame count never goes down
mFlags,
mSharedBuffer,