From 56d4cd10c3adfa448852fc101780e0b519d8bac8 Mon Sep 17 00:00:00 2001 From: Li Sun Date: Thu, 30 Jul 2015 19:09:56 +0800 Subject: rtsp: Don't post AUTimeout check during pause when EOS is nearing Fix crash issues while repeated pause/resume. The root cause is: While doing repeated pause-resume operation in RTSP streaming, some times, the accessunit timeout check is being posted when the streaming paused, and even after receving the EOS. Due to this check, after the EOS, the number of packets received will be zero and the session gets Teardown while the streaming is paused. Upon resume, it leads to check failure and crash. Cancel the timeout check if pause is not issued to MyHandler when nearing EOS. Change-Id: I897d8e18b0dbc29fc1099e7b3d1b5ccc16426a4d CRs-Fixed: 636312, 676054 --- media/libmediaplayerservice/nuplayer/RTSPSource.cpp | 4 ++++ media/libstagefright/rtsp/MyHandler.h | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/media/libmediaplayerservice/nuplayer/RTSPSource.cpp b/media/libmediaplayerservice/nuplayer/RTSPSource.cpp index aae46d8..f641f80 100644 --- a/media/libmediaplayerservice/nuplayer/RTSPSource.cpp +++ b/media/libmediaplayerservice/nuplayer/RTSPSource.cpp @@ -132,6 +132,10 @@ void NuPlayer::RTSPSource::pause() { // Check if EOS or ERROR is received if (source != NULL && source->isFinished(mediaDurationUs)) { + if (mHandler != NULL) { + ALOGI("Nearing EOS...No Pause is issued"); + mHandler->cancelTimeoutCheck(); + } return; } } diff --git a/media/libstagefright/rtsp/MyHandler.h b/media/libstagefright/rtsp/MyHandler.h index e105b15..2eea5c9 100644 --- a/media/libstagefright/rtsp/MyHandler.h +++ b/media/libstagefright/rtsp/MyHandler.h @@ -107,6 +107,7 @@ struct MyHandler : public AHandler { kWhatEOS = 'eos!', kWhatSeekDiscontinuity = 'seeD', kWhatNormalPlayTimeMapping = 'nptM', + kWhatCancelCheck = 'canC', }; MyHandler( @@ -255,6 +256,11 @@ struct MyHandler : public AHandler { msg->post(); } + void cancelTimeoutCheck() { + sp msg = new AMessage('canC', this); + msg->post(); + } + static void addRR(const sp &buf) { uint8_t *ptr = buf->data() + buf->size(); ptr[0] = 0x80 | 0; @@ -1402,6 +1408,13 @@ struct MyHandler : public AHandler { break; } + case 'canC': + { + ALOGV("cancel checking timeout"); + mCheckGeneration++; + break; + } + default: TRESPASS(); break; -- cgit v1.1