summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2011-02-24 09:16:43 -0800
committerJames Dong <jdong@google.com>2011-02-24 10:10:32 -0800
commit563ab6ec5ec16db78567f8b3c9dff22c5dfaab08 (patch)
treed7b8d5a786c47e3d27508823347d0c96f69cddb3 /media
parent7b76c8d3fc25aedea6edfed9638b008faa2f6ae8 (diff)
downloadframeworks_base-563ab6ec5ec16db78567f8b3c9dff22c5dfaab08.zip
frameworks_base-563ab6ec5ec16db78567f8b3c9dff22c5dfaab08.tar.gz
frameworks_base-563ab6ec5ec16db78567f8b3c9dff22c5dfaab08.tar.bz2
Fix MP3Extractor
When the temp buffer wraps around, the next read position should start from what have been read to avoid reading the same remaining bytes in the buffer again. o also fix some of the formatting string for logging bug - 3482444 Change-Id: Ie0b56f4691ff9e80a48a57f1b7d0d28c78cfb313
Diffstat (limited to 'media')
-rw-r--r--media/libstagefright/MP3Extractor.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/media/libstagefright/MP3Extractor.cpp b/media/libstagefright/MP3Extractor.cpp
index 00a4dd5..eb4c68d 100644
--- a/media/libstagefright/MP3Extractor.cpp
+++ b/media/libstagefright/MP3Extractor.cpp
@@ -217,7 +217,7 @@ static bool Resync(
*inout_pos += len;
- LOGV("skipped ID3 tag, new starting offset is %ld (0x%08lx)",
+ LOGV("skipped ID3 tag, new starting offset is %lld (0x%016llx)",
*inout_pos, *inout_pos);
}
@@ -241,7 +241,7 @@ static bool Resync(
do {
if (pos >= *inout_pos + kMaxBytesChecked) {
// Don't scan forever.
- LOGV("giving up at offset %ld", pos);
+ LOGV("giving up at offset %lld", pos);
break;
}
@@ -251,7 +251,15 @@ static bool Resync(
} else {
memcpy(buf, tmp, remainingBytes);
bytesToRead = kMaxReadBytes - remainingBytes;
- totalBytesRead = source->readAt(pos, buf + remainingBytes, bytesToRead);
+
+ /*
+ * The next read position should start from the end of
+ * the last buffer, and thus should include the remaining
+ * bytes in the buffer.
+ */
+ totalBytesRead = source->readAt(pos + remainingBytes,
+ buf + remainingBytes,
+ bytesToRead);
if (totalBytesRead <= 0) {
break;
}
@@ -283,7 +291,7 @@ static bool Resync(
continue;
}
- LOGV("found possible 1st frame at %ld (header = 0x%08x)", pos, header);
+ LOGV("found possible 1st frame at %lld (header = 0x%08x)", pos, header);
// We found what looks like a valid frame,
// now find its successors.
@@ -314,7 +322,7 @@ static bool Resync(
break;
}
- LOGV("found subsequent frame #%d at %ld", j + 2, test_pos);
+ LOGV("found subsequent frame #%d at %lld", j + 2, test_pos);
test_pos += test_frame_size;
}