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: Ie55129109060a4a7862fee3177f994401e00b6c1
diff --git a/media/libmediaplayerservice/MediaPlayerFactory.cpp b/media/libmediaplayerservice/MediaPlayerFactory.cpp
index 3e0fc0d..d149290 100644
--- a/media/libmediaplayerservice/MediaPlayerFactory.cpp
+++ b/media/libmediaplayerservice/MediaPlayerFactory.cpp
@@ -15,11 +15,15 @@
 ** 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>
 #include <utils/Errors.h>
 #include <utils/misc.h>
@@ -279,7 +283,6 @@
                 }
             }
         }
-
         return 0.0;
     }
 
@@ -295,14 +298,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;