// Return the frame size of an NBAIO_Format in bytes
size_t Format_frameSize(const NBAIO_Format& format);
-// Return the frame size of an NBAIO_Format as a bit shift
-// or -1 if frame size is not a power of 2
-int Format_frameBitShift(const NBAIO_Format& format);
-
// Convert a sample rate in Hz and channel count to an NBAIO_Format
// FIXME Remove the default value of AUDIO_FORMAT_PCM_16_BIT, and rename
NBAIO_Format Format_from_SR_C(unsigned sampleRate, unsigned channelCount,
protected:
NBAIO_Port(const NBAIO_Format& format) : mNegotiated(false), mFormat(format),
- mBitShift(Format_frameBitShift(format)),
mFrameSize(Format_frameSize(format)) { }
virtual ~NBAIO_Port() { }
bool mNegotiated; // mNegotiated implies (mFormat != Format_Invalid)
NBAIO_Format mFormat; // (mFormat != Format_Invalid) does not imply mNegotiated
- size_t mBitShift; // assign in parallel with any assignment to mFormat
size_t mFrameSize; // assign in parallel with any assignment to mFormat
};
private:
const sp<NBAIO_Source> mSource; // the wrapped source
- /*const*/ size_t mFrameBitShift; // log2(frame size in bytes)
/*const*/ size_t mFrameSize; // frame size in bytes
void* mAllocated; // pointer to base of allocated memory
size_t mSize; // size of mAllocated in frames
audio_channel_mask_t channelMask =
(audio_channel_mask_t) mStream->common.get_channels(&mStream->common);
mFormat = Format_from_SR_C(sampleRate, popcount(channelMask));
- mBitShift = Format_frameBitShift(mFormat);
mFrameSize = Format_frameSize(mFormat);
}
}
audio_channel_mask_t channelMask =
(audio_channel_mask_t) mStream->common.get_channels(&mStream->common);
mFormat = Format_from_SR_C(sampleRate, popcount(channelMask));
- mBitShift = Format_frameBitShift(mFormat);
mFrameSize = Format_frameSize(mFormat);
}
}
return format.mFrameSize;
}
+#if 0
int Format_frameBitShift(const NBAIO_Format& format)
{
// FIXME The sample format is hard-coded to AUDIO_FORMAT_PCM_16_BIT
return Format_channelCount(format);
// FIXME must return -1 for non-power of 2
}
+#endif
const NBAIO_Format Format_Invalid = { 0, 0, AUDIO_FORMAT_INVALID, 0 };
numCounterOffers = 0;
index = source->negotiate(counterOffers, 1, NULL, numCounterOffers);
ALOG_ASSERT(index == 0);
- mFrameBitShift = Format_frameBitShift(source->format());
mFrameSize = Format_frameSize(source->format());
}