diff options
author | Chong Zhang <chz@google.com> | 2013-05-15 18:47:26 -0700 |
---|---|---|
committer | Chong Zhang <chz@google.com> | 2013-05-16 11:05:19 -0700 |
commit | 99f27cdf2c2711aa0c8b4d9ae4d12cae37ff94f6 (patch) | |
tree | 670f26693a9f51097570e09c020c7efed589a956 | |
parent | dd90e8b5a200829cae68fa1a95eb1e3ed09583cf (diff) | |
download | frameworks_av-99f27cdf2c2711aa0c8b4d9ae4d12cae37ff94f6.zip frameworks_av-99f27cdf2c2711aa0c8b4d9ae4d12cae37ff94f6.tar.gz frameworks_av-99f27cdf2c2711aa0c8b4d9ae4d12cae37ff94f6.tar.bz2 |
wifi-display: retry UDP read/write to improve connection robustness
Bug: 8922753
Change-Id: Ie6d18f03afcb23d11e6f0e63403e8f0d59b70be8
-rw-r--r-- | media/libstagefright/wifi-display/ANetworkSession.cpp | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/media/libstagefright/wifi-display/ANetworkSession.cpp b/media/libstagefright/wifi-display/ANetworkSession.cpp index f074438..938d601 100644 --- a/media/libstagefright/wifi-display/ANetworkSession.cpp +++ b/media/libstagefright/wifi-display/ANetworkSession.cpp @@ -39,6 +39,7 @@ namespace android { static const size_t kMaxUDPSize = 1500; +static const int32_t kMaxUDPRetries = 200; struct ANetworkSession::NetworkThread : public Thread { NetworkThread(ANetworkSession *session); @@ -105,6 +106,7 @@ private: int mSocket; sp<AMessage> mNotify; bool mSawReceiveFailure, mSawSendFailure; + int32_t mUDPRetries; List<Fragment> mOutFragments; @@ -148,6 +150,7 @@ ANetworkSession::Session::Session( mNotify(notify), mSawReceiveFailure(false), mSawSendFailure(false), + mUDPRetries(kMaxUDPRetries), mLastStallReportUs(-1ll) { if (mState == CONNECTED) { struct sockaddr_in localAddr; @@ -286,8 +289,17 @@ status_t ANetworkSession::Session::readMore() { } if (err != OK) { - notifyError(false /* send */, err, "Recvfrom failed."); - mSawReceiveFailure = true; + if (!mUDPRetries) { + notifyError(false /* send */, err, "Recvfrom failed."); + mSawReceiveFailure = true; + } else { + mUDPRetries--; + ALOGE("Recvfrom failed, %d/%d retries left", + mUDPRetries, kMaxUDPRetries); + err = OK; + } + } else { + mUDPRetries = kMaxUDPRetries; } return err; @@ -479,8 +491,17 @@ status_t ANetworkSession::Session::writeMore() { } if (err != OK) { - notifyError(true /* send */, err, "Send datagram failed."); - mSawSendFailure = true; + if (!mUDPRetries) { + notifyError(true /* send */, err, "Send datagram failed."); + mSawSendFailure = true; + } else { + mUDPRetries--; + ALOGE("Send datagram failed, %d/%d retries left", + mUDPRetries, kMaxUDPRetries); + err = OK; + } + } else { + mUDPRetries = kMaxUDPRetries; } return err; |