Replace MidiFile player with a Midi extractor
This gets rids of a bunch of special midi handling and replaces it
with an extractor that works with NuPlayer and MediaMetadataRetriever.
Change-Id: I8d0f5bbdde2ca24267cf4d62ab26afe9630e0217
diff --git a/media/libmedia/MidiIoWrapper.cpp b/media/libmedia/MidiIoWrapper.cpp
index ef931d2..2181111 100644
--- a/media/libmedia/MidiIoWrapper.cpp
+++ b/media/libmedia/MidiIoWrapper.cpp
@@ -47,6 +47,16 @@
mLength = size;
}
+MidiIoWrapper::MidiIoWrapper(const sp<DataSource> &source) {
+ mDataSource = source;
+ off64_t l;
+ if (mDataSource->getSize(&l) == OK) {
+ mLength = l;
+ } else {
+ mLength = 0;
+ }
+}
+
MidiIoWrapper::~MidiIoWrapper() {
ALOGV("~MidiIoWrapper");
close(mFd);
@@ -54,6 +64,10 @@
int MidiIoWrapper::readAt(void *buffer, int offset, int size) {
ALOGV("readAt(%p, %d, %d)", buffer, offset, size);
+
+ if (mDataSource != NULL) {
+ return mDataSource->readAt(offset, buffer, size);
+ }
lseek(mFd, mBase + offset, SEEK_SET);
if (offset + size > mLength) {
size = mLength - offset;