summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/media/AudioRecord.h2
-rw-r--r--include/media/AudioTrack.h7
-rw-r--r--include/private/media/AudioTrackShared.h2
-rw-r--r--media/libmedia/AudioRecord.cpp2
-rw-r--r--media/libmedia/AudioTrack.cpp6
-rw-r--r--services/audioflinger/AudioFlinger.cpp13
-rw-r--r--services/audioflinger/AudioFlinger.h2
7 files changed, 20 insertions, 14 deletions
diff --git a/include/media/AudioRecord.h b/include/media/AudioRecord.h
index 2fb69b6..84a8f1c 100644
--- a/include/media/AudioRecord.h
+++ b/include/media/AudioRecord.h
@@ -206,7 +206,7 @@ public:
int channelCount() const;
int channels() const;
uint32_t frameCount() const;
- int frameSize() const;
+ size_t frameSize() const;
int inputSource() const;
diff --git a/include/media/AudioTrack.h b/include/media/AudioTrack.h
index fd83162..6e4a9f5 100644
--- a/include/media/AudioTrack.h
+++ b/include/media/AudioTrack.h
@@ -219,7 +219,12 @@ public:
audio_format_t format() const;
int channelCount() const;
uint32_t frameCount() const;
- int frameSize() const;
+
+ /* Return channelCount * (bit depth per channel / 8).
+ * channelCount is determined from channelMask, and bit depth comes from format.
+ */
+ size_t frameSize() const;
+
sp<IMemory>& sharedBuffer();
diff --git a/include/private/media/AudioTrackShared.h b/include/private/media/AudioTrackShared.h
index 86e0682..33a92cd 100644
--- a/include/private/media/AudioTrackShared.h
+++ b/include/private/media/AudioTrackShared.h
@@ -80,7 +80,7 @@ struct audio_track_cblk_t
// 8 bit PCM data: in this case, mCblk->frameSize is based on a sample size of
// 16 bit because data is converted to 16 bit before being stored in buffer
- uint8_t frameSize;
+ uint8_t frameSize; // would normally be size_t, but 8 bits is plenty
uint8_t pad1;
uint16_t bufferTimeoutMs; // Maximum cumulated timeout before restarting audioflinger
diff --git a/media/libmedia/AudioRecord.cpp b/media/libmedia/AudioRecord.cpp
index 8e4a9d6..32b5bac 100644
--- a/media/libmedia/AudioRecord.cpp
+++ b/media/libmedia/AudioRecord.cpp
@@ -263,7 +263,7 @@ uint32_t AudioRecord::frameCount() const
return mFrameCount;
}
-int AudioRecord::frameSize() const
+size_t AudioRecord::frameSize() const
{
if (audio_is_linear_pcm(mFormat)) {
return channelCount()*audio_bytes_per_sample(mFormat);
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index e695bd6..97b2312 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -295,7 +295,7 @@ uint32_t AudioTrack::frameCount() const
return mCblk->frameCount;
}
-int AudioTrack::frameSize() const
+size_t AudioTrack::frameSize() const
{
if (audio_is_linear_pcm(mFormat)) {
return channelCount()*audio_bytes_per_sample(mFormat);
@@ -979,7 +979,7 @@ ssize_t AudioTrack::write(const void* buffer, size_t userSize)
ssize_t written = 0;
const int8_t *src = (const int8_t *)buffer;
Buffer audioBuffer;
- size_t frameSz = (size_t)frameSize();
+ size_t frameSz = frameSize();
do {
audioBuffer.frameCount = userSize/frameSz;
@@ -1137,7 +1137,7 @@ bool AudioTrack::processAudioBuffer(const sp<AudioTrackThread>& thread)
audioBuffer.size = writtenSize;
// NOTE: mCblk->frameSize is not equal to AudioTrack::frameSize() for
- // 8 bit PCM data: in this case, mCblk->frameSize is based on a sampel size of
+ // 8 bit PCM data: in this case, mCblk->frameSize is based on a sample size of
// 16 bit.
audioBuffer.frameCount = writtenSize/mCblk->frameSize;
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 4ff019d..755fbb1 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -1118,7 +1118,7 @@ status_t AudioFlinger::ThreadBase::dumpBase(int fd, const Vector<String16>& args
result.append(buffer);
snprintf(buffer, SIZE, "Format: %d\n", mFormat);
result.append(buffer);
- snprintf(buffer, SIZE, "Frame size: %d\n", mFrameSize);
+ snprintf(buffer, SIZE, "Frame size: %u\n", mFrameSize);
result.append(buffer);
snprintf(buffer, SIZE, "\nPending setParameters commands: \n");
@@ -1729,7 +1729,7 @@ void AudioFlinger::PlaybackThread::readOutputParameters()
mChannelMask = mOutput->stream->common.get_channels(&mOutput->stream->common);
mChannelCount = (uint16_t)popcount(mChannelMask);
mFormat = mOutput->stream->common.get_format(&mOutput->stream->common);
- mFrameSize = (uint16_t)audio_stream_frame_size(&mOutput->stream->common);
+ mFrameSize = audio_stream_frame_size(&mOutput->stream->common);
mFrameCount = mOutput->stream->common.get_buffer_size(&mOutput->stream->common) / mFrameSize;
// FIXME - Current mixer implementation only supports stereo output: Always
@@ -3332,12 +3332,13 @@ uint32_t AudioFlinger::ThreadBase::TrackBase::channelMask() const {
void* AudioFlinger::ThreadBase::TrackBase::getBuffer(uint32_t offset, uint32_t frames) const {
audio_track_cblk_t* cblk = this->cblk();
- int8_t *bufferStart = (int8_t *)mBuffer + (offset-cblk->serverBase)*cblk->frameSize;
- int8_t *bufferEnd = bufferStart + frames * cblk->frameSize;
+ size_t frameSize = cblk->frameSize;
+ int8_t *bufferStart = (int8_t *)mBuffer + (offset-cblk->serverBase)*frameSize;
+ int8_t *bufferEnd = bufferStart + frames * frameSize;
// Check validity of returned pointer in case the track control block would have been corrupted.
if (bufferStart < mBuffer || bufferStart > bufferEnd || bufferEnd > mBufferEnd ||
- ((unsigned long)bufferStart & (unsigned long)(cblk->frameSize - 1))) {
+ ((unsigned long)bufferStart & (unsigned long)(frameSize - 1))) {
ALOGE("TrackBase::getBuffer buffer out of range:\n start: %p, end %p , mBuffer %p mBufferEnd %p\n \
server %d, serverBase %d, user %d, userBase %d",
bufferStart, bufferEnd, mBuffer, mBufferEnd,
@@ -4808,7 +4809,7 @@ void AudioFlinger::RecordThread::readInputParameters()
mChannelMask = mInput->stream->common.get_channels(&mInput->stream->common);
mChannelCount = (uint16_t)popcount(mChannelMask);
mFormat = mInput->stream->common.get_format(&mInput->stream->common);
- mFrameSize = (uint16_t)audio_stream_frame_size(&mInput->stream->common);
+ mFrameSize = audio_stream_frame_size(&mInput->stream->common);
mInputBytes = mInput->stream->common.get_buffer_size(&mInput->stream->common);
mFrameCount = mInputBytes / mFrameSize;
mRsmpInBuffer = new int16_t[mFrameCount * mChannelCount];
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index 9480cab..c73e2f8 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -536,7 +536,7 @@ private:
size_t mFrameCount;
uint32_t mChannelMask;
uint16_t mChannelCount;
- uint16_t mFrameSize;
+ size_t mFrameSize;
uint32_t mFormat;
Condition mParamCond;
Vector<String8> mNewParameters;