summaryrefslogtreecommitdiffstats
path: root/media/libstagefright
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2012-09-28 16:34:38 -0700
committerAndreas Huber <andih@google.com>2012-09-28 16:36:04 -0700
commit77245813007cf903b4b73f5d0cd20313fbf0e510 (patch)
tree6f5a35a89933a2578a7f1ff6ec1cd4b9a5240a30 /media/libstagefright
parent23f74017a2c457a25382677b6e696c4cfa06cef5 (diff)
downloadframeworks_av-77245813007cf903b4b73f5d0cd20313fbf0e510.zip
frameworks_av-77245813007cf903b4b73f5d0cd20313fbf0e510.tar.gz
frameworks_av-77245813007cf903b4b73f5d0cd20313fbf0e510.tar.bz2
Even cleaner shutdown.
Change-Id: I5a76f83db3a5e43f55eb4e04269d890c2015bae7 related-to-bug: 7247918
Diffstat (limited to 'media/libstagefright')
-rw-r--r--media/libstagefright/wifi-display/source/Converter.cpp4
-rw-r--r--media/libstagefright/wifi-display/source/PlaybackSession.cpp38
-rw-r--r--media/libstagefright/wifi-display/source/PlaybackSession.h6
-rw-r--r--media/libstagefright/wifi-display/source/RepeaterSource.cpp13
-rw-r--r--media/libstagefright/wifi-display/source/RepeaterSource.h2
5 files changed, 38 insertions, 25 deletions
diff --git a/media/libstagefright/wifi-display/source/Converter.cpp b/media/libstagefright/wifi-display/source/Converter.cpp
index 968a805..99db060 100644
--- a/media/libstagefright/wifi-display/source/Converter.cpp
+++ b/media/libstagefright/wifi-display/source/Converter.cpp
@@ -301,8 +301,6 @@ status_t Converter::feedEncoderInputBuffers() {
if (buffer != NULL) {
CHECK(buffer->meta()->findInt64("timeUs", &timeUs));
- ALOGV("in: %s timeUs = %lld us", mIsVideo ? "video" : "audio", timeUs);
-
memcpy(mEncoderInputBuffers.itemAt(bufferIndex)->data(),
buffer->data(),
buffer->size());
@@ -353,8 +351,6 @@ status_t Converter::doMoreWork() {
notify->setInt32("what", kWhatEOS);
notify->post();
} else {
- ALOGV("out: %s timeUs = %lld us", mIsVideo ? "video" : "audio", timeUs);
-
sp<ABuffer> buffer = new ABuffer(size);
buffer->meta()->setInt64("timeUs", timeUs);
diff --git a/media/libstagefright/wifi-display/source/PlaybackSession.cpp b/media/libstagefright/wifi-display/source/PlaybackSession.cpp
index 775f23b..829a16d 100644
--- a/media/libstagefright/wifi-display/source/PlaybackSession.cpp
+++ b/media/libstagefright/wifi-display/source/PlaybackSession.cpp
@@ -75,8 +75,6 @@ struct WifiDisplaySource::PlaybackSession::Track : public AHandler {
status_t start();
void stopAsync();
- bool isStopped() const { return !mStarted; }
-
void queueAccessUnit(const sp<ABuffer> &accessUnit);
sp<ABuffer> dequeueAccessUnit();
@@ -200,6 +198,8 @@ void WifiDisplaySource::PlaybackSession::Track::onMessageReceived(
sp<AMessage> notify = mNotify->dup();
notify->setInt32("what", kWhatStopped);
notify->post();
+
+ ALOGI("kWhatStopped %s posted", mIsAudio ? "audio" : "video");
break;
}
@@ -267,9 +267,11 @@ WifiDisplaySource::PlaybackSession::PlaybackSession(
mNumRTPOctetsSent(0),
mNumSRsSent(0),
mSendSRPending(false),
- mFirstPacketTimeUs(-1ll),
- mHistoryLength(0),
- mTotalBytesSent(0ll)
+ mHistoryLength(0)
+#if TRACK_BANDWIDTH
+ ,mFirstPacketTimeUs(-1ll),
+ ,mTotalBytesSent(0ll)
+#endif
#if LOG_TRANSPORT_STREAM
,mLogFile(NULL)
#endif
@@ -747,21 +749,18 @@ void WifiDisplaySource::PlaybackSession::onMessageReceived(
CHECK(msg->findSize("trackIndex", &trackIndex));
if (what == Track::kWhatStopped) {
- bool allTracksAreStopped = true;
- for (size_t i = 0; i < mTracks.size(); ++i) {
- const sp<Track> &track = mTracks.valueAt(i);
- if (!track->isStopped()) {
- allTracksAreStopped = false;
- break;
- }
- }
+ ALOGI("Track %d stopped", trackIndex);
- if (!allTracksAreStopped) {
+ sp<Track> track = mTracks.valueFor(trackIndex);
+ looper()->unregisterHandler(track->id());
+ mTracks.removeItem(trackIndex);
+ track.clear();
+
+ if (!mTracks.isEmpty()) {
+ ALOGI("not all tracks are stopped yet");
break;
}
- mTracks.clear();
-
mPacketizer.clear();
#if ENABLE_RETRANSMISSION
@@ -1074,12 +1073,15 @@ ssize_t WifiDisplaySource::PlaybackSession::appendTSData(
// flush
int64_t nowUs = ALooper::GetNowUs();
+
+#if TRACK_BANDWIDTH
if (mFirstPacketTimeUs < 0ll) {
mFirstPacketTimeUs = nowUs;
}
+#endif
// 90kHz time scale
- uint32_t rtpTime = ((nowUs - mFirstPacketTimeUs) * 9ll) / 100ll;
+ uint32_t rtpTime = (nowUs * 9ll) / 100ll;
uint8_t *rtp = mTSQueue->data();
rtp[0] = 0x80;
@@ -1115,6 +1117,7 @@ ssize_t WifiDisplaySource::PlaybackSession::appendTSData(
} else {
sendPacket(mRTPSessionID, rtp, mTSQueue->size());
+#if TRACK_BANDWIDTH
mTotalBytesSent += mTSQueue->size();
int64_t delayUs = ALooper::GetNowUs() - mFirstPacketTimeUs;
@@ -1122,6 +1125,7 @@ ssize_t WifiDisplaySource::PlaybackSession::appendTSData(
ALOGV("approx. net bandwidth used: %.2f Mbit/sec",
mTotalBytesSent * 8.0 / delayUs);
}
+#endif
}
mTSQueue->setInt32Data(mRTPSeqNo - 1);
diff --git a/media/libstagefright/wifi-display/source/PlaybackSession.h b/media/libstagefright/wifi-display/source/PlaybackSession.h
index 9237a72..8d88648 100644
--- a/media/libstagefright/wifi-display/source/PlaybackSession.h
+++ b/media/libstagefright/wifi-display/source/PlaybackSession.h
@@ -32,6 +32,7 @@ struct TSPacketizer;
#define LOG_TRANSPORT_STREAM 0
#define ENABLE_RETRANSMISSION 0
+#define TRACK_BANDWIDTH 0
// Encapsulates the state of an RTP/RTCP session in the context of wifi
// display.
@@ -160,12 +161,13 @@ private:
bool mSendSRPending;
- int64_t mFirstPacketTimeUs;
-
List<sp<ABuffer> > mHistory;
size_t mHistoryLength;
+#if TRACK_BANDWIDTH
+ int64_t mFirstPacketTimeUs;
uint64_t mTotalBytesSent;
+#endif
#if LOG_TRANSPORT_STREAM
FILE *mLogFile;
diff --git a/media/libstagefright/wifi-display/source/RepeaterSource.cpp b/media/libstagefright/wifi-display/source/RepeaterSource.cpp
index 483d29c..dc216e8 100644
--- a/media/libstagefright/wifi-display/source/RepeaterSource.cpp
+++ b/media/libstagefright/wifi-display/source/RepeaterSource.cpp
@@ -13,7 +13,8 @@
namespace android {
RepeaterSource::RepeaterSource(const sp<MediaSource> &source, double rateHz)
- : mSource(source),
+ : mStarted(false),
+ mSource(source),
mRateHz(rateHz),
mBuffer(NULL),
mResult(OK),
@@ -22,10 +23,12 @@ RepeaterSource::RepeaterSource(const sp<MediaSource> &source, double rateHz)
}
RepeaterSource::~RepeaterSource() {
- stop();
+ CHECK(!mStarted);
}
status_t RepeaterSource::start(MetaData *params) {
+ CHECK(!mStarted);
+
status_t err = mSource->start(params);
if (err != OK) {
@@ -46,10 +49,14 @@ status_t RepeaterSource::start(MetaData *params) {
postRead();
+ mStarted = true;
+
return OK;
}
status_t RepeaterSource::stop() {
+ CHECK(mStarted);
+
ALOGV("stopping");
if (mLooper != NULL) {
@@ -69,6 +76,8 @@ status_t RepeaterSource::stop() {
ALOGV("stopped");
+ mStarted = false;
+
return err;
}
diff --git a/media/libstagefright/wifi-display/source/RepeaterSource.h b/media/libstagefright/wifi-display/source/RepeaterSource.h
index 31eb5cd..3049362 100644
--- a/media/libstagefright/wifi-display/source/RepeaterSource.h
+++ b/media/libstagefright/wifi-display/source/RepeaterSource.h
@@ -33,6 +33,8 @@ private:
Mutex mLock;
Condition mCondition;
+ bool mStarted;
+
sp<MediaSource> mSource;
double mRateHz;