summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2011-01-31 18:38:07 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2011-01-31 18:38:07 -0800
commit72a807dc64c5a967f43116dd84893e2213c5b6e3 (patch)
treeeec1ffb3b031505d3a4fbf65807450260fa586a8 /media
parent8d08c5aeee05425357b6603a22fa73fd6e095a47 (diff)
parent4e5391cf782ddff9a1c0d9b8211f1252521ca598 (diff)
downloadframeworks_av-72a807dc64c5a967f43116dd84893e2213c5b6e3.zip
frameworks_av-72a807dc64c5a967f43116dd84893e2213c5b6e3.tar.gz
frameworks_av-72a807dc64c5a967f43116dd84893e2213c5b6e3.tar.bz2
am b450d96b: am 537fa17f: Merge "Disconnect HTTP live sessions as soon as the request comes in." into honeycomb
* commit 'b450d96b3d13cd341ef7aa4483c2223ddfecce3c': Disconnect HTTP live sessions as soon as the request comes in.
Diffstat (limited to 'media')
-rw-r--r--media/libstagefright/httplive/LiveSession.cpp25
-rw-r--r--media/libstagefright/include/LiveSession.h1
2 files changed, 25 insertions, 1 deletions
diff --git a/media/libstagefright/httplive/LiveSession.cpp b/media/libstagefright/httplive/LiveSession.cpp
index c6c36e3..0bed3ca 100644
--- a/media/libstagefright/httplive/LiveSession.cpp
+++ b/media/libstagefright/httplive/LiveSession.cpp
@@ -51,6 +51,7 @@ LiveSession::LiveSession()
mNumRetries(0),
mDurationUs(-1),
mSeekDone(false),
+ mDisconnectPending(false),
mMonitorQueueGeneration(0) {
}
@@ -68,6 +69,11 @@ void LiveSession::connect(const char *url) {
}
void LiveSession::disconnect() {
+ Mutex::Autolock autoLock(mLock);
+ mDisconnectPending = true;
+
+ mHTTPDataSource->disconnect();
+
(new AMessage(kWhatDisconnect, id()))->post();
}
@@ -138,7 +144,13 @@ void LiveSession::onConnect(const sp<AMessage> &msg) {
mMasterURL = url;
sp<M3UParser> playlist = fetchPlaylist(url.c_str());
- CHECK(playlist != NULL);
+
+ if (playlist == NULL) {
+ LOGE("unable to fetch master playlist '%s'.", url.c_str());
+
+ mDataSource->queueEOS(ERROR_IO);
+ return;
+ }
if (playlist->isVariantPlaylist()) {
for (size_t i = 0; i < playlist->size(); ++i) {
@@ -177,6 +189,9 @@ void LiveSession::onDisconnect() {
LOGI("onDisconnect");
mDataSource->queueEOS(ERROR_END_OF_STREAM);
+
+ Mutex::Autolock autoLock(mLock);
+ mDisconnectPending = false;
}
status_t LiveSession::fetchFile(const char *url, sp<ABuffer> *out) {
@@ -189,6 +204,14 @@ status_t LiveSession::fetchFile(const char *url, sp<ABuffer> *out) {
} else if (strncasecmp(url, "http://", 7)) {
return ERROR_UNSUPPORTED;
} else {
+ {
+ Mutex::Autolock autoLock(mLock);
+
+ if (mDisconnectPending) {
+ return ERROR_IO;
+ }
+ }
+
status_t err = mHTTPDataSource->connect(url);
if (err != OK) {
diff --git a/media/libstagefright/include/LiveSession.h b/media/libstagefright/include/LiveSession.h
index 41f5ad0..f1188c4 100644
--- a/media/libstagefright/include/LiveSession.h
+++ b/media/libstagefright/include/LiveSession.h
@@ -87,6 +87,7 @@ private:
Condition mCondition;
int64_t mDurationUs;
bool mSeekDone;
+ bool mDisconnectPending;
int32_t mMonitorQueueGeneration;