Channel count is uint32_t.
Remove redundant mask parameter to AudioTrack::createTrack_l()
and AudioRecord::openRecord_l().
Change-Id: I5dc2b18eb609b2c0dc3091994cbaa4628062c17f
/* getters, see constructor and set() */
audio_format_t format() const;
- int channelCount() const;
+ uint32_t channelCount() const;
size_t frameCount() const;
size_t frameSize() const { return mFrameSize; }
audio_source_t inputSource() const;
status_t openRecord_l(uint32_t sampleRate,
audio_format_t format,
- audio_channel_mask_t channelMask,
size_t frameCount,
audio_io_handle_t input);
audio_io_handle_t getInput_l();
audio_stream_type_t streamType() const;
audio_format_t format() const;
- int channelCount() const;
+ uint32_t channelCount() const;
uint32_t frameCount() const;
/* Return channelCount * (bit depth per channel / 8).
status_t 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,
size <<= 1;
if (audio_is_linear_pcm(format)) {
- int channelCount = popcount(channelMask);
+ uint32_t channelCount = popcount(channelMask);
size /= channelCount * audio_bytes_per_sample(format);
}
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();
}
// create the IAudioRecord
- status = openRecord_l(sampleRate, format, channelMask,
- frameCount, input);
+ status = openRecord_l(sampleRate, format, frameCount, input);
if (status != NO_ERROR) {
return status;
}
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);
return mFormat;
}
-int AudioRecord::channelCount() const
+uint32_t AudioRecord::channelCount() const
{
return mChannelCount;
}
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)
{
int originalSessionId = mSessionId;
sp<IAudioRecord> record = audioFlinger->openRecord(getpid(), input,
sampleRate, format,
- channelMask,
+ mChannelMask,
frameCount,
IAudioFlinger::TRACK_DEFAULT,
tid,
// 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
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,
status_t status = createTrack_l(streamType,
sampleRate,
format,
- channelMask,
frameCount,
flags,
sharedBuffer,
mStreamType = streamType;
mFormat = format;
- mChannelMask = channelMask;
- mChannelCount = channelCount;
if (audio_is_linear_pcm(format)) {
mFrameSize = channelCount * audio_bytes_per_sample(format);
return mFormat;
}
-int AudioTrack::channelCount() const
+uint32_t AudioTrack::channelCount() const
{
return mChannelCount;
}
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,
} 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;
}
// 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)) {
// AudioFlinger only sees 16-bit PCM
format == AUDIO_FORMAT_PCM_8_BIT ?
AUDIO_FORMAT_PCM_16_BIT : format,
- channelMask,
+ mChannelMask,
frameCount,
&trackFlags,
sharedBuffer,
result = createTrack_l(mStreamType,
cblk->sampleRate,
mFormat,
- mChannelMask,
mReqFrameCount, // so that frame count never goes down
mFlags,
mSharedBuffer,
framesIn = framesOut;
mRsmpInIndex += framesIn;
framesOut -= framesIn;
- if ((int)mChannelCount == mReqChannelCount ||
+ if (mChannelCount == mReqChannelCount ||
mFormat != AUDIO_FORMAT_PCM_16_BIT) {
memcpy(dst, src, framesIn * mFrameSize);
} else {
if (framesOut && mFrameCount == mRsmpInIndex) {
void *readInto;
if (framesOut == mFrameCount &&
- ((int)mChannelCount == mReqChannelCount ||
+ (mChannelCount == mReqChannelCount ||
mFormat != AUDIO_FORMAT_PCM_16_BIT)) {
readInto = buffer.raw;
framesOut = 0;
result.append(buffer);
snprintf(buffer, SIZE, "Resampling: %d\n", (mResampler != NULL));
result.append(buffer);
- snprintf(buffer, SIZE, "Out channel count: %d\n", mReqChannelCount);
+ snprintf(buffer, SIZE, "Out channel count: %u\n", mReqChannelCount);
result.append(buffer);
snprintf(buffer, SIZE, "Out sample rate: %u\n", mReqSampleRate);
result.append(buffer);
int value;
audio_format_t reqFormat = mFormat;
uint32_t reqSamplingRate = mReqSampleRate;
- int reqChannelCount = mReqChannelCount;
+ uint32_t reqChannelCount = mReqChannelCount;
if (param.getInt(String8(AudioParameter::keySamplingRate), value) == NO_ERROR) {
reqSamplingRate = value;
return mFormat;
}
- int channelCount() const { return mChannelCount; }
+ uint32_t channelCount() const { return mChannelCount; }
audio_channel_mask_t channelMask() const { return mChannelMask; }
// dynamic externally-visible
uint32_t sampleRate() const { return mSampleRate; }
- int channelCount() const { return mChannelCount; }
+ uint32_t channelCount() const { return mChannelCount; }
audio_channel_mask_t channelMask() const { return mChannelMask; }
audio_format_t format() const { return mFormat; }
// Called by AudioFlinger::frameCount(audio_io_handle_t output) and effects,
int16_t *mRsmpInBuffer;
size_t mRsmpInIndex;
size_t mInputBytes;
- const int mReqChannelCount;
+ const uint32_t mReqChannelCount;
const uint32_t mReqSampleRate;
ssize_t mBytesRead;
// sync event triggering actual audio capture. Frames read before this event will