Use callbacks for Midi I/O

Instead of having the Sonivox engine directly open the file and
use stdio to read from it, use caller-provided callbacks.

Change-Id: I4d775c8458c48c591a15794c4517e006dcf034e1
diff --git a/media/libmediaplayerservice/MediaPlayerFactory.cpp b/media/libmediaplayerservice/MediaPlayerFactory.cpp
index aeefb4c..c689470 100644
--- a/media/libmediaplayerservice/MediaPlayerFactory.cpp
+++ b/media/libmediaplayerservice/MediaPlayerFactory.cpp
@@ -15,11 +15,13 @@
 ** limitations under the License.
 */
 
+//#define LOG_NDEBUG 0
 #define LOG_TAG "MediaPlayerFactory"
 #include <utils/Log.h>
 
 #include <cutils/properties.h>
 #include <media/IMediaPlayer.h>
+#include <media/MidiIoWrapper.h>
 #include <media/stagefright/DataSource.h>
 #include <media/stagefright/FileSource.h>
 #include <media/stagefright/foundation/ADebug.h>
@@ -308,7 +310,6 @@
                 }
             }
         }
-
         return 0.0;
     }
 
@@ -324,14 +325,10 @@
 
         // Some kind of MIDI?
         EAS_DATA_HANDLE easdata;
+        sp<MidiIoWrapper> wrapper = new MidiIoWrapper(fd, offset, length);
         if (EAS_Init(&easdata) == EAS_SUCCESS) {
-            EAS_FILE locator;
-            locator.path = NULL;
-            locator.fd = fd;
-            locator.offset = offset;
-            locator.length = length;
             EAS_HANDLE  eashandle;
-            if (EAS_OpenFile(easdata, &locator, &eashandle) == EAS_SUCCESS) {
+            if (EAS_OpenFile(easdata, wrapper->getLocator(), &eashandle) == EAS_SUCCESS) {
                 EAS_CloseFile(easdata, eashandle);
                 EAS_Shutdown(easdata);
                 return kOurScore;