summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2011-03-09 15:17:20 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2011-03-09 15:17:20 -0800
commitd1e09e08210e755034bbdd07e1f48b35ec9a4752 (patch)
treec82a12482dde6dfcac8e80ca0e31d80ce905f29c /media
parentd6aaec0ce7639a9d8bb73983711e20545b55e860 (diff)
parent8df2477c4e7e5bf72d6d1216ae5184c53304470e (diff)
downloadframeworks_base-d1e09e08210e755034bbdd07e1f48b35ec9a4752.zip
frameworks_base-d1e09e08210e755034bbdd07e1f48b35ec9a4752.tar.gz
frameworks_base-d1e09e08210e755034bbdd07e1f48b35ec9a4752.tar.bz2
am 8df2477c: am bd0e806a: Support IPv6->IPv4 fallback in HTTP streaming.
* commit '8df2477c4e7e5bf72d6d1216ae5184c53304470e': Support IPv6->IPv4 fallback in HTTP streaming.
Diffstat (limited to 'media')
-rw-r--r--media/libstagefright/HTTPStream.cpp38
1 files changed, 24 insertions, 14 deletions
diff --git a/media/libstagefright/HTTPStream.cpp b/media/libstagefright/HTTPStream.cpp
index d216ef2..2caf211 100644
--- a/media/libstagefright/HTTPStream.cpp
+++ b/media/libstagefright/HTTPStream.cpp
@@ -237,31 +237,41 @@ status_t HTTPStream::connect(const char *server, int port, bool https) {
}
CHECK_EQ(mSocket, -1);
- mSocket = socket(ai[0].ai_family, ai[0].ai_socktype, ai[0].ai_protocol);
- if (mSocket < 0) {
- freeaddrinfo(ai);
- return UNKNOWN_ERROR;
- }
+ mState = CONNECTING;
+ status_t res = -1;
+ struct addrinfo *tmp;
+ for (tmp = ai; tmp; tmp = tmp->ai_next) {
+ mSocket = socket(tmp->ai_family, tmp->ai_socktype, tmp->ai_protocol);
+ if (mSocket < 0) {
+ continue;
+ }
- setReceiveTimeout(30); // Time out reads after 30 secs by default
+ setReceiveTimeout(30); // Time out reads after 30 secs by default.
- mState = CONNECTING;
+ int s = mSocket;
- int s = mSocket;
+ mLock.unlock();
- mLock.unlock();
+ res = MyConnect(s, tmp->ai_addr, tmp->ai_addrlen);
- status_t res = MyConnect(s, ai[0].ai_addr, ai[0].ai_addrlen);
+ mLock.lock();
- freeaddrinfo(ai);
+ if (mState != CONNECTING) {
+ close(s);
+ freeaddrinfo(ai);
+ return UNKNOWN_ERROR;
+ }
- mLock.lock();
+ if (res == OK) {
+ break;
+ }
- if (mState != CONNECTING) {
- return UNKNOWN_ERROR;
+ close(s);
}
+ freeaddrinfo(ai);
+
if (res != OK) {
close(mSocket);
mSocket = -1;