diff --git a/api/current.txt b/api/current.txt index 9e2de4e757e76..7bba7ac028df1 100644 --- a/api/current.txt +++ b/api/current.txt @@ -15673,9 +15673,10 @@ package android.media { ctor public MediaCryptoException(java.lang.String); } - public abstract interface MediaDataSource implements java.io.Closeable { - method public abstract long getSize(); - method public abstract int readAt(long, byte[], int); + public abstract class MediaDataSource implements java.io.Closeable { + ctor public MediaDataSource(); + method public abstract long getSize() throws java.io.IOException; + method public abstract int readAt(long, byte[], int, int) throws java.io.IOException; } public class MediaDescription implements android.os.Parcelable { diff --git a/api/system-current.txt b/api/system-current.txt index 91d4d2540fa85..34b7a77acb87d 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -16910,9 +16910,10 @@ package android.media { ctor public MediaCryptoException(java.lang.String); } - public abstract interface MediaDataSource implements java.io.Closeable { - method public abstract long getSize(); - method public abstract int readAt(long, byte[], int); + public abstract class MediaDataSource implements java.io.Closeable { + ctor public MediaDataSource(); + method public abstract long getSize() throws java.io.IOException; + method public abstract int readAt(long, byte[], int, int) throws java.io.IOException; } public class MediaDescription implements android.os.Parcelable { diff --git a/media/java/android/media/MediaDataSource.java b/media/java/android/media/MediaDataSource.java index 246c0ef0a3d04..948da0b97910b 100644 --- a/media/java/android/media/MediaDataSource.java +++ b/media/java/android/media/MediaDataSource.java @@ -18,6 +18,7 @@ package android.media; import java.io.Closeable; +import java.io.IOException; /** * For supplying media data to the framework. Implement this if your app has @@ -29,34 +30,32 @@ import java.io.Closeable; * you don't need to do your own synchronization unless you're modifying the * MediaDataSource from another thread while it's being used by the framework.
*/ -public interface MediaDataSource extends Closeable { +public abstract class MediaDataSource implements Closeable { /** * Called to request data from the given position. * * Implementations should should write up to {@code size} bytes into * {@code buffer}, and return the number of bytes written. * - * Return {@code 0} to indicate that {@code position} is at, or beyond, the - * end of the source. + * Return {@code 0} if size is zero (thus no bytes are read). * - * Return {@code -1} to indicate that a fatal error occurred. The failed - * read will not be retried, so transient errors should be handled - * internally. - * - * Throwing an exception from this method will have the same effect as - * returning {@code -1}. + * Return {@code -1} to indicate that end of stream is reached. * * @param position the position in the data source to read from. * @param buffer the buffer to read the data into. + * @param offset the offset within buffer to read the data into. * @param size the number of bytes to read. + * @throws IOException on fatal errors. * @return the number of bytes read, or -1 if there was an error. */ - public int readAt(long position, byte[] buffer, int size); + public abstract int readAt(long position, byte[] buffer, int offset, int size) + throws IOException; /** * Called to get the size of the data source. * + * @throws IOException on fatal errors * @return the size of data source in bytes, or -1 if the size is unknown. */ - public long getSize(); + public abstract long getSize() throws IOException; } diff --git a/media/jni/android_media_MediaDataSource.cpp b/media/jni/android_media_MediaDataSource.cpp index 1e6d2afa84b84..025133f3ff009 100644 --- a/media/jni/android_media_MediaDataSource.cpp +++ b/media/jni/android_media_MediaDataSource.cpp @@ -39,7 +39,7 @@ JMediaDataSource::JMediaDataSource(JNIEnv* env, jobject source) ScopedLocalRef