diff options
author | Andreas Huber <andih@google.com> | 2011-09-27 12:12:25 -0700 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2011-09-27 12:13:37 -0700 |
commit | 7922619e9c755353effd0188779ebbd5c1372624 (patch) | |
tree | 4c46519604e74adc5e3bc009108f73aa963b4aa4 /media | |
parent | cbb62bb81807ff83a0887b90111218d81a3f57df (diff) | |
download | frameworks_base-7922619e9c755353effd0188779ebbd5c1372624.zip frameworks_base-7922619e9c755353effd0188779ebbd5c1372624.tar.gz frameworks_base-7922619e9c755353effd0188779ebbd5c1372624.tar.bz2 |
Signal an appropriate error even if there are no active streams yet.
Change-Id: I3ac1053ad288558b62ee18056dfd0a9ce0da8f49
related-to-bug: 5372901
Diffstat (limited to 'media')
6 files changed, 32 insertions, 27 deletions
diff --git a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp index fb14204..079f6fa 100644 --- a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp +++ b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp @@ -41,7 +41,7 @@ NuPlayer::HTTPLiveSource::HTTPLiveSource( mUIDValid(uidValid), mUID(uid), mFlags(0), - mEOS(false), + mFinalResult(OK), mOffset(0) { if (headers) { mExtraHeaders = *headers; @@ -95,9 +95,9 @@ sp<MetaData> NuPlayer::HTTPLiveSource::getFormat(bool audio) { return source->getFormat(); } -bool NuPlayer::HTTPLiveSource::feedMoreTSData() { - if (mEOS) { - return false; +status_t NuPlayer::HTTPLiveSource::feedMoreTSData() { + if (mFinalResult != OK) { + return mFinalResult; } sp<LiveDataSource> source = @@ -111,12 +111,12 @@ bool NuPlayer::HTTPLiveSource::feedMoreTSData() { break; } else if (n < 0) { if (n != ERROR_END_OF_STREAM) { - LOGI("input data EOS reached, error %d", n); + LOGI("input data EOS reached, error %ld", n); } else { LOGI("input data EOS reached."); } mTSParser->signalEOS(n); - mEOS = true; + mFinalResult = n; break; } else { if (buffer[0] == 0x00) { @@ -133,7 +133,7 @@ bool NuPlayer::HTTPLiveSource::feedMoreTSData() { if (err != OK) { LOGE("TS Parser returned error %d", err); mTSParser->signalEOS(err); - mEOS = true; + mFinalResult = err; break; } } @@ -142,7 +142,7 @@ bool NuPlayer::HTTPLiveSource::feedMoreTSData() { } } - return true; + return OK; } status_t NuPlayer::HTTPLiveSource::dequeueAccessUnit( @@ -172,7 +172,7 @@ status_t NuPlayer::HTTPLiveSource::getDuration(int64_t *durationUs) { status_t NuPlayer::HTTPLiveSource::seekTo(int64_t seekTimeUs) { // We need to make sure we're not seeking until we have seen the very first // PTS timestamp in the whole stream (from the beginning of the stream). - while (!mTSParser->PTSTimeDeltaEstablished() && feedMoreTSData()) { + while (!mTSParser->PTSTimeDeltaEstablished() && feedMoreTSData() == OK) { usleep(100000); } diff --git a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.h b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.h index 36c67c5..f22af5b 100644 --- a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.h +++ b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.h @@ -35,8 +35,7 @@ struct NuPlayer::HTTPLiveSource : public NuPlayer::Source { virtual void start(); - // Returns true iff more data was available, false on EOS. - virtual bool feedMoreTSData(); + virtual status_t feedMoreTSData(); virtual sp<MetaData> getFormat(bool audio); virtual status_t dequeueAccessUnit(bool audio, sp<ABuffer> *accessUnit); @@ -59,7 +58,7 @@ private: bool mUIDValid; uid_t mUID; uint32_t mFlags; - bool mEOS; + status_t mFinalResult; off64_t mOffset; sp<ALooper> mLiveLooper; sp<LiveSession> mLiveSession; diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp index 7bfd358..6b40528 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp @@ -235,11 +235,17 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) { instantiateDecoder(true, &mAudioDecoder); } - if (!mSource->feedMoreTSData()) { + status_t err; + if ((err = mSource->feedMoreTSData()) != OK) { if (mAudioDecoder == NULL && mVideoDecoder == NULL) { // We're not currently decoding anything (no audio or // video tracks found) and we just ran out of input data. - notifyListener(MEDIA_PLAYBACK_COMPLETE, 0, 0); + + if (err == ERROR_END_OF_STREAM) { + notifyListener(MEDIA_PLAYBACK_COMPLETE, 0, 0); + } else { + notifyListener(MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, err); + } } break; } @@ -267,7 +273,7 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) { audio, codecRequest); if (err == -EWOULDBLOCK) { - if (mSource->feedMoreTSData()) { + if (mSource->feedMoreTSData() == OK) { msg->post(); } } diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerSource.h b/media/libmediaplayerservice/nuplayer/NuPlayerSource.h index 5e55487..8a7eece 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerSource.h +++ b/media/libmediaplayerservice/nuplayer/NuPlayerSource.h @@ -29,8 +29,9 @@ struct NuPlayer::Source : public RefBase { virtual void start() = 0; - // Returns true iff more data was available, false on EOS. - virtual bool feedMoreTSData() = 0; + // Returns OK iff more data was available, + // an error or ERROR_END_OF_STREAM if not. + virtual status_t feedMoreTSData() = 0; virtual sp<MetaData> getFormat(bool audio) = 0; diff --git a/media/libmediaplayerservice/nuplayer/StreamingSource.cpp b/media/libmediaplayerservice/nuplayer/StreamingSource.cpp index 7319e4c..f795654 100644 --- a/media/libmediaplayerservice/nuplayer/StreamingSource.cpp +++ b/media/libmediaplayerservice/nuplayer/StreamingSource.cpp @@ -34,7 +34,7 @@ namespace android { NuPlayer::StreamingSource::StreamingSource(const sp<IStreamSource> &source) : mSource(source), - mEOS(false) { + mFinalResult(OK) { } NuPlayer::StreamingSource::~StreamingSource() { @@ -47,9 +47,9 @@ void NuPlayer::StreamingSource::start() { mStreamListener->start(); } -bool NuPlayer::StreamingSource::feedMoreTSData() { - if (mEOS) { - return false; +status_t NuPlayer::StreamingSource::feedMoreTSData() { + if (mFinalResult != OK) { + return mFinalResult; } for (int32_t i = 0; i < 50; ++i) { @@ -60,7 +60,7 @@ bool NuPlayer::StreamingSource::feedMoreTSData() { if (n == 0) { LOGI("input data EOS reached."); mTSParser->signalEOS(ERROR_END_OF_STREAM); - mEOS = true; + mFinalResult = ERROR_END_OF_STREAM; break; } else if (n == INFO_DISCONTINUITY) { ATSParser::DiscontinuityType type = ATSParser::DISCONTINUITY_SEEK; @@ -92,14 +92,14 @@ bool NuPlayer::StreamingSource::feedMoreTSData() { LOGE("TS Parser returned error %d", err); mTSParser->signalEOS(err); - mEOS = true; + mFinalResult = err; break; } } } } - return true; + return OK; } sp<MetaData> NuPlayer::StreamingSource::getFormat(bool audio) { diff --git a/media/libmediaplayerservice/nuplayer/StreamingSource.h b/media/libmediaplayerservice/nuplayer/StreamingSource.h index 7abce84..ca00ef9 100644 --- a/media/libmediaplayerservice/nuplayer/StreamingSource.h +++ b/media/libmediaplayerservice/nuplayer/StreamingSource.h @@ -31,8 +31,7 @@ struct NuPlayer::StreamingSource : public NuPlayer::Source { virtual void start(); - // Returns true iff more data was available, false on EOS. - virtual bool feedMoreTSData(); + virtual status_t feedMoreTSData(); virtual sp<MetaData> getFormat(bool audio); virtual status_t dequeueAccessUnit(bool audio, sp<ABuffer> *accessUnit); @@ -42,7 +41,7 @@ protected: private: sp<IStreamSource> mSource; - bool mEOS; + status_t mFinalResult; sp<NuPlayerStreamListener> mStreamListener; sp<ATSParser> mTSParser; |