summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcong.zhou <cong.zhou@lge.com>2012-11-28 15:52:28 -0800
committercong.zhou <cong.zhou@lge.com>2012-11-30 12:39:00 -0800
commit9b1797fed7065be05f8fb7a36d1a27e0df3cb7ab (patch)
treec131951afeac10522fda033606bc9d81341d90d2
parent031c93df74621dc2149876dc377aedee8930547f (diff)
Fix bug in WAVExtractor for 24-bit per sample wav
support stereo/multichannel 24-bit format kMaxFrameSize is fixed to 32768. When converting 24-bit to 16-bit, number of samlpes is maxBytesToRead /3. In this case, if the maxBytesToRead is not multiple of 3, pcm data is messed when converting. Bug:7630939 Change-Id: I0ea1b53eb1272a8d83b63815fc0a05b73cef75f1
-rw-r--r--media/libstagefright/WAVExtractor.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/media/libstagefright/WAVExtractor.cpp b/media/libstagefright/WAVExtractor.cpp
index a38400be..2a7f6284 100644
--- a/media/libstagefright/WAVExtractor.cpp
+++ b/media/libstagefright/WAVExtractor.cpp
@@ -401,8 +401,10 @@ status_t WAVSource::read(
return err;
}
+ // make sure that maxBytesToRead is multiple of 3, in 24-bit case
size_t maxBytesToRead =
- mBitsPerSample == 8 ? kMaxFrameSize / 2 : kMaxFrameSize;
+ mBitsPerSample == 8 ? kMaxFrameSize / 2 :
+ (mBitsPerSample == 24 ? 3*(kMaxFrameSize/3): kMaxFrameSize);
size_t maxBytesAvailable =
(mCurrentPos - mOffset >= (off64_t)mSize)
@@ -425,7 +427,7 @@ status_t WAVSource::read(
buffer->set_range(0, n);
- if (mWaveFormat == WAVE_FORMAT_PCM) {
+ if (mWaveFormat == WAVE_FORMAT_PCM || mWaveFormat == WAVE_FORMAT_EXTENSIBLE) {
if (mBitsPerSample == 8) {
// Convert 8-bit unsigned samples to 16-bit signed.