summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/httplive/LiveDataSource.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'media/libstagefright/httplive/LiveDataSource.cpp')
-rw-r--r--media/libstagefright/httplive/LiveDataSource.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/media/libstagefright/httplive/LiveDataSource.cpp b/media/libstagefright/httplive/LiveDataSource.cpp
index 25e2902..5f5c6d4 100644
--- a/media/libstagefright/httplive/LiveDataSource.cpp
+++ b/media/libstagefright/httplive/LiveDataSource.cpp
@@ -54,9 +54,40 @@ size_t LiveDataSource::countQueuedBuffers() {
return mBufferQueue.size();
}
+ssize_t LiveDataSource::readAtNonBlocking(
+ off64_t offset, void *data, size_t size) {
+ Mutex::Autolock autoLock(mLock);
+
+ if (offset != mOffset) {
+ LOGE("Attempt at reading non-sequentially from LiveDataSource.");
+ return -EPIPE;
+ }
+
+ size_t totalAvailable = 0;
+ for (List<sp<ABuffer> >::iterator it = mBufferQueue.begin();
+ it != mBufferQueue.end(); ++it) {
+ sp<ABuffer> buffer = *it;
+
+ totalAvailable += buffer->size();
+
+ if (totalAvailable >= size) {
+ break;
+ }
+ }
+
+ if (totalAvailable < size) {
+ return mFinalResult == OK ? -EWOULDBLOCK : mFinalResult;
+ }
+
+ return readAt_l(offset, data, size);
+}
+
ssize_t LiveDataSource::readAt(off64_t offset, void *data, size_t size) {
Mutex::Autolock autoLock(mLock);
+ return readAt_l(offset, data, size);
+}
+ssize_t LiveDataSource::readAt_l(off64_t offset, void *data, size_t size) {
if (offset != mOffset) {
LOGE("Attempt at reading non-sequentially from LiveDataSource.");
return -EPIPE;