summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/rtsp
diff options
context:
space:
mode:
authorHenrik Backlund <henrik.backlund@sonyericsson.com>2011-09-20 09:54:28 +0200
committerHenrik Baard <henrik.baard@sonymobile.com>2012-12-05 09:30:39 +0100
commitb6f7642496f955da04d1eb9e33df0dab653c9c4e (patch)
tree640602cf8534f160138d1d80dda4188fef68c787 /media/libstagefright/rtsp
parentf00d40c716fd4741fa56dd2b59813227658e50f2 (diff)
downloadframeworks_av-b6f7642496f955da04d1eb9e33df0dab653c9c4e.zip
frameworks_av-b6f7642496f955da04d1eb9e33df0dab653c9c4e.tar.gz
frameworks_av-b6f7642496f955da04d1eb9e33df0dab653c9c4e.tar.bz2
Fix crash in MyHandler when sockets are not set.
-When going quickly in and out of the video view during an rtsp streaming session, a race condition occurs and MyHandler tries to connect to a socket that has been reset. To avoid this, checks are added. - If there are errors during setupTrack 1, it is no use setting up track 2. It will cause new errors. - No assert for socket connect since there is a normal status check already. Change-Id: Ie06221d6c0d78ce0449f76c782ed5120fa646bfd
Diffstat (limited to 'media/libstagefright/rtsp')
-rw-r--r--media/libstagefright/rtsp/ARTSPConnection.cpp1
-rw-r--r--media/libstagefright/rtsp/MyHandler.h38
2 files changed, 22 insertions, 17 deletions
diff --git a/media/libstagefright/rtsp/ARTSPConnection.cpp b/media/libstagefright/rtsp/ARTSPConnection.cpp
index 161bd4f..0606486 100644
--- a/media/libstagefright/rtsp/ARTSPConnection.cpp
+++ b/media/libstagefright/rtsp/ARTSPConnection.cpp
@@ -481,7 +481,6 @@ void ARTSPConnection::onReceiveResponse() {
FD_SET(mSocket, &rs);
int res = select(mSocket + 1, &rs, NULL, NULL, &tv);
- CHECK_GE(res, 0);
if (res == 1) {
MakeSocketBlocking(mSocket, true);
diff --git a/media/libstagefright/rtsp/MyHandler.h b/media/libstagefright/rtsp/MyHandler.h
index 96c7683..0ea63c0 100644
--- a/media/libstagefright/rtsp/MyHandler.h
+++ b/media/libstagefright/rtsp/MyHandler.h
@@ -558,23 +558,27 @@ struct MyHandler : public AHandler {
i = response->mHeaders.indexOfKey("transport");
CHECK_GE(i, 0);
- if (!track->mUsingInterleavedTCP) {
- AString transport = response->mHeaders.valueAt(i);
-
- // We are going to continue even if we were
- // unable to poke a hole into the firewall...
- pokeAHole(
- track->mRTPSocket,
- track->mRTCPSocket,
- transport);
- }
+ if (track->mRTPSocket != -1 && track->mRTCPSocket != -1) {
+ if (!track->mUsingInterleavedTCP) {
+ AString transport = response->mHeaders.valueAt(i);
+
+ // We are going to continue even if we were
+ // unable to poke a hole into the firewall...
+ pokeAHole(
+ track->mRTPSocket,
+ track->mRTCPSocket,
+ transport);
+ }
- mRTPConn->addStream(
- track->mRTPSocket, track->mRTCPSocket,
- mSessionDesc, index,
- notify, track->mUsingInterleavedTCP);
+ mRTPConn->addStream(
+ track->mRTPSocket, track->mRTCPSocket,
+ mSessionDesc, index,
+ notify, track->mUsingInterleavedTCP);
- mSetupTracksSuccessful = true;
+ mSetupTracksSuccessful = true;
+ } else {
+ result = BAD_VALUE;
+ }
}
}
@@ -596,7 +600,7 @@ struct MyHandler : public AHandler {
}
++index;
- if (index < mSessionDesc->countTracks()) {
+ if (result == OK && index < mSessionDesc->countTracks()) {
setupTrack(index);
} else if (mSetupTracksSuccessful) {
++mKeepAliveGeneration;
@@ -1268,6 +1272,8 @@ private:
info->mUsingInterleavedTCP = false;
info->mFirstSeqNumInSegment = 0;
info->mNewSegment = true;
+ info->mRTPSocket = -1;
+ info->mRTCPSocket = -1;
info->mRTPAnchor = 0;
info->mNTPAnchorUs = -1;
info->mNormalPlayTimeRTP = 0;