IMediaSource: add readMultiple API to speed up inter-process reading.
GenericSource: use readMultiple for audio track.
Bug: 28545177
Bug: 22775369
Change-Id: If26b80e75eba4212105d51140c4bfce85ec664f8
diff --git a/include/media/IMediaSource.h b/include/media/IMediaSource.h
index f7586a7..709f425 100644
--- a/include/media/IMediaSource.h
+++ b/include/media/IMediaSource.h
@@ -32,6 +32,11 @@
public:
DECLARE_META_INTERFACE(MediaSource);
+ enum {
+ // Maximum number of buffers would be read in readMultiple.
+ kMaxNumReadMultiple = 128,
+ };
+
// To be called before any other methods on this object, except
// getFormat().
virtual status_t start(MetaData *params = NULL) = 0;
@@ -87,7 +92,7 @@
};
// Returns a new buffer of data. Call blocks until a
- // buffer is available, an error is encountered of the end of the stream
+ // buffer is available, an error is encountered or the end of the stream
// is reached.
// End of stream is signalled by a result of ERROR_END_OF_STREAM.
// A result of INFO_FORMAT_CHANGED indicates that the format of this
@@ -96,6 +101,19 @@
virtual status_t read(
MediaBuffer **buffer, const ReadOptions *options = NULL) = 0;
+ // Returns a vector of new buffers of data. The vector size could be
+ // <= |maxNumBuffers|. Used for buffers with small size
+ // since all buffer data are passed back by binder, not shared memory.
+ // Call blocks until an error is encountered, or the end of the stream is
+ // reached, or format change is hit, or |kMaxNumReadMultiple| buffers have
+ // been read.
+ // End of stream is signalled by a result of ERROR_END_OF_STREAM.
+ // A result of INFO_FORMAT_CHANGED indicates that the format of this
+ // MediaSource has changed mid-stream, the client can continue reading
+ // but should be prepared for buffers of the new configuration.
+ virtual status_t readMultiple(
+ Vector<MediaBuffer *> *buffers, uint32_t maxNumBuffers = 1) = 0;
+
// Causes this source to suspend pulling data from its upstream source
// until a subsequent read-with-seek. Currently only supported by
// OMXCodec.
@@ -126,6 +144,10 @@
return ERROR_UNSUPPORTED;
}
+ virtual status_t readMultiple(
+ Vector<MediaBuffer *> * /* buffers */, uint32_t /* maxNumBuffers = 1 */) {
+ return ERROR_UNSUPPORTED;
+ }
protected:
virtual ~BnMediaSource();