blob: 11cea3b74be8aac239c9dd7b2fda679d02dc3b37 [file] [log] [blame]
Andreas Huberf9334412010-12-15 15:17:42 -08001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17//#define LOG_NDEBUG 0
18#define LOG_TAG "NuPlayer"
19#include <utils/Log.h>
20
21#include "NuPlayer.h"
Andreas Huber5bc087c2010-12-23 10:27:40 -080022
23#include "HTTPLiveSource.h"
Andreas Huberf9334412010-12-15 15:17:42 -080024#include "NuPlayerDecoder.h"
Andreas Huber43c3e6c2011-01-05 12:17:08 -080025#include "NuPlayerDriver.h"
Andreas Huberf9334412010-12-15 15:17:42 -080026#include "NuPlayerRenderer.h"
Andreas Huber5bc087c2010-12-23 10:27:40 -080027#include "NuPlayerSource.h"
Andreas Huber2bfdd422011-10-11 15:24:07 -070028#include "RTSPSource.h"
Andreas Huber5bc087c2010-12-23 10:27:40 -080029#include "StreamingSource.h"
Andreas Huberafed0e12011-09-20 15:39:58 -070030#include "GenericSource.h"
Andreas Huber5bc087c2010-12-23 10:27:40 -080031
32#include "ATSParser.h"
Andreas Huberf9334412010-12-15 15:17:42 -080033
Andreas Huber3831a062010-12-21 10:22:33 -080034#include <media/stagefright/foundation/hexdump.h>
Andreas Huberf9334412010-12-15 15:17:42 -080035#include <media/stagefright/foundation/ABuffer.h>
36#include <media/stagefright/foundation/ADebug.h>
37#include <media/stagefright/foundation/AMessage.h>
38#include <media/stagefright/ACodec.h>
Andreas Huber3fe62152011-09-16 15:09:22 -070039#include <media/stagefright/MediaDefs.h>
Andreas Huberf9334412010-12-15 15:17:42 -080040#include <media/stagefright/MediaErrors.h>
41#include <media/stagefright/MetaData.h>
Marco Nelissen4110c102012-03-29 09:31:28 -070042#include <media/stagefright/SkipCutBuffer.h>
Glenn Kasten11731182011-02-08 17:26:17 -080043#include <gui/ISurfaceTexture.h>
Andreas Huberf9334412010-12-15 15:17:42 -080044
Andreas Huber3fe62152011-09-16 15:09:22 -070045#include "avc_utils.h"
46
Andreas Huberf9334412010-12-15 15:17:42 -080047namespace android {
48
49////////////////////////////////////////////////////////////////////////////////
50
51NuPlayer::NuPlayer()
Andreas Huber9b80c2b2011-06-30 15:47:02 -070052 : mUIDValid(false),
Andreas Huber3fe62152011-09-16 15:09:22 -070053 mVideoIsAVC(false),
Andreas Huber9b80c2b2011-06-30 15:47:02 -070054 mAudioEOS(false),
Andreas Huberf9334412010-12-15 15:17:42 -080055 mVideoEOS(false),
Andreas Huber5bc087c2010-12-23 10:27:40 -080056 mScanSourcesPending(false),
Andreas Huber1aef2112011-01-04 14:01:29 -080057 mScanSourcesGeneration(0),
Andreas Huber6e3d3112011-11-28 12:36:11 -080058 mTimeDiscontinuityPending(false),
Andreas Huberf9334412010-12-15 15:17:42 -080059 mFlushingAudio(NONE),
Andreas Huber1aef2112011-01-04 14:01:29 -080060 mFlushingVideo(NONE),
61 mResetInProgress(false),
Andreas Huber3fe62152011-09-16 15:09:22 -070062 mResetPostponed(false),
63 mSkipRenderingAudioUntilMediaTimeUs(-1ll),
64 mSkipRenderingVideoUntilMediaTimeUs(-1ll),
65 mVideoLateByUs(0ll),
66 mNumFramesTotal(0ll),
Marco Nelissen4110c102012-03-29 09:31:28 -070067 mNumFramesDropped(0ll),
68 mSkipCutBuffer(NULL) {
Andreas Huberf9334412010-12-15 15:17:42 -080069}
70
71NuPlayer::~NuPlayer() {
Marco Nelissen4110c102012-03-29 09:31:28 -070072 delete mSkipCutBuffer;
73 mSkipCutBuffer = NULL;
Andreas Huberf9334412010-12-15 15:17:42 -080074}
75
Andreas Huber9b80c2b2011-06-30 15:47:02 -070076void NuPlayer::setUID(uid_t uid) {
77 mUIDValid = true;
78 mUID = uid;
79}
80
Andreas Huber43c3e6c2011-01-05 12:17:08 -080081void NuPlayer::setDriver(const wp<NuPlayerDriver> &driver) {
82 mDriver = driver;
Andreas Huberf9334412010-12-15 15:17:42 -080083}
84
85void NuPlayer::setDataSource(const sp<IStreamSource> &source) {
86 sp<AMessage> msg = new AMessage(kWhatSetDataSource, id());
87
Andreas Huber5bc087c2010-12-23 10:27:40 -080088 msg->setObject("source", new StreamingSource(source));
89 msg->post();
90}
Andreas Huberf9334412010-12-15 15:17:42 -080091
Andreas Huberafed0e12011-09-20 15:39:58 -070092static bool IsHTTPLiveURL(const char *url) {
93 if (!strncasecmp("http://", url, 7)
94 || !strncasecmp("https://", url, 8)) {
95 size_t len = strlen(url);
96 if (len >= 5 && !strcasecmp(".m3u8", &url[len - 5])) {
97 return true;
98 }
99
100 if (strstr(url,"m3u8")) {
101 return true;
102 }
103 }
104
105 return false;
106}
107
Andreas Huber5bc087c2010-12-23 10:27:40 -0800108void NuPlayer::setDataSource(
109 const char *url, const KeyedVector<String8, String8> *headers) {
110 sp<AMessage> msg = new AMessage(kWhatSetDataSource, id());
111
Andreas Huberafed0e12011-09-20 15:39:58 -0700112 sp<Source> source;
113 if (IsHTTPLiveURL(url)) {
114 source = new HTTPLiveSource(url, headers, mUIDValid, mUID);
115 } else if (!strncasecmp(url, "rtsp://", 7)) {
116 source = new RTSPSource(url, headers, mUIDValid, mUID);
Andreas Huber2bfdd422011-10-11 15:24:07 -0700117 } else {
Andreas Huberafed0e12011-09-20 15:39:58 -0700118 source = new GenericSource(url, headers, mUIDValid, mUID);
Andreas Huber2bfdd422011-10-11 15:24:07 -0700119 }
120
Andreas Huberafed0e12011-09-20 15:39:58 -0700121 msg->setObject("source", source);
122 msg->post();
123}
124
125void NuPlayer::setDataSource(int fd, int64_t offset, int64_t length) {
126 sp<AMessage> msg = new AMessage(kWhatSetDataSource, id());
127
128 sp<Source> source = new GenericSource(fd, offset, length);
129 msg->setObject("source", source);
Andreas Huberf9334412010-12-15 15:17:42 -0800130 msg->post();
131}
132
Glenn Kasten11731182011-02-08 17:26:17 -0800133void NuPlayer::setVideoSurfaceTexture(const sp<ISurfaceTexture> &surfaceTexture) {
134 sp<AMessage> msg = new AMessage(kWhatSetVideoNativeWindow, id());
135 sp<SurfaceTextureClient> surfaceTextureClient(surfaceTexture != NULL ?
136 new SurfaceTextureClient(surfaceTexture) : NULL);
137 msg->setObject("native-window", new NativeWindowWrapper(surfaceTextureClient));
Andreas Huberf9334412010-12-15 15:17:42 -0800138 msg->post();
139}
140
141void NuPlayer::setAudioSink(const sp<MediaPlayerBase::AudioSink> &sink) {
142 sp<AMessage> msg = new AMessage(kWhatSetAudioSink, id());
143 msg->setObject("sink", sink);
144 msg->post();
145}
146
147void NuPlayer::start() {
148 (new AMessage(kWhatStart, id()))->post();
149}
150
Andreas Huber43c3e6c2011-01-05 12:17:08 -0800151void NuPlayer::pause() {
Andreas Huberb4082222011-01-20 15:23:04 -0800152 (new AMessage(kWhatPause, id()))->post();
Andreas Huber43c3e6c2011-01-05 12:17:08 -0800153}
154
155void NuPlayer::resume() {
Andreas Huberb4082222011-01-20 15:23:04 -0800156 (new AMessage(kWhatResume, id()))->post();
Andreas Huber43c3e6c2011-01-05 12:17:08 -0800157}
158
Andreas Huber1aef2112011-01-04 14:01:29 -0800159void NuPlayer::resetAsync() {
160 (new AMessage(kWhatReset, id()))->post();
161}
162
Andreas Huber43c3e6c2011-01-05 12:17:08 -0800163void NuPlayer::seekToAsync(int64_t seekTimeUs) {
164 sp<AMessage> msg = new AMessage(kWhatSeek, id());
165 msg->setInt64("seekTimeUs", seekTimeUs);
166 msg->post();
167}
168
Andreas Huber53df1a42010-12-22 10:03:04 -0800169// static
Andreas Huber1aef2112011-01-04 14:01:29 -0800170bool NuPlayer::IsFlushingState(FlushStatus state, bool *needShutdown) {
Andreas Huber53df1a42010-12-22 10:03:04 -0800171 switch (state) {
172 case FLUSHING_DECODER:
Andreas Huber1aef2112011-01-04 14:01:29 -0800173 if (needShutdown != NULL) {
174 *needShutdown = false;
Andreas Huber53df1a42010-12-22 10:03:04 -0800175 }
176 return true;
177
Andreas Huber1aef2112011-01-04 14:01:29 -0800178 case FLUSHING_DECODER_SHUTDOWN:
179 if (needShutdown != NULL) {
180 *needShutdown = true;
Andreas Huber53df1a42010-12-22 10:03:04 -0800181 }
182 return true;
183
184 default:
185 return false;
186 }
187}
188
Andreas Huberf9334412010-12-15 15:17:42 -0800189void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
190 switch (msg->what()) {
191 case kWhatSetDataSource:
192 {
Steve Block3856b092011-10-20 11:56:00 +0100193 ALOGV("kWhatSetDataSource");
Andreas Huberf9334412010-12-15 15:17:42 -0800194
195 CHECK(mSource == NULL);
196
Andreas Huber5bc087c2010-12-23 10:27:40 -0800197 sp<RefBase> obj;
198 CHECK(msg->findObject("source", &obj));
Andreas Huberf9334412010-12-15 15:17:42 -0800199
Andreas Huber5bc087c2010-12-23 10:27:40 -0800200 mSource = static_cast<Source *>(obj.get());
Andreas Huberf9334412010-12-15 15:17:42 -0800201 break;
202 }
203
Glenn Kasten11731182011-02-08 17:26:17 -0800204 case kWhatSetVideoNativeWindow:
Andreas Huberf9334412010-12-15 15:17:42 -0800205 {
Steve Block3856b092011-10-20 11:56:00 +0100206 ALOGV("kWhatSetVideoNativeWindow");
Andreas Huberf9334412010-12-15 15:17:42 -0800207
208 sp<RefBase> obj;
Glenn Kasten11731182011-02-08 17:26:17 -0800209 CHECK(msg->findObject("native-window", &obj));
Andreas Huberf9334412010-12-15 15:17:42 -0800210
Glenn Kasten11731182011-02-08 17:26:17 -0800211 mNativeWindow = static_cast<NativeWindowWrapper *>(obj.get());
Andreas Huberf9334412010-12-15 15:17:42 -0800212 break;
213 }
214
215 case kWhatSetAudioSink:
216 {
Steve Block3856b092011-10-20 11:56:00 +0100217 ALOGV("kWhatSetAudioSink");
Andreas Huberf9334412010-12-15 15:17:42 -0800218
219 sp<RefBase> obj;
220 CHECK(msg->findObject("sink", &obj));
221
222 mAudioSink = static_cast<MediaPlayerBase::AudioSink *>(obj.get());
223 break;
224 }
225
226 case kWhatStart:
227 {
Steve Block3856b092011-10-20 11:56:00 +0100228 ALOGV("kWhatStart");
Andreas Huber43c3e6c2011-01-05 12:17:08 -0800229
Andreas Huber3fe62152011-09-16 15:09:22 -0700230 mVideoIsAVC = false;
Andreas Huber1aef2112011-01-04 14:01:29 -0800231 mAudioEOS = false;
232 mVideoEOS = false;
Andreas Huber32f3cef2011-03-02 15:34:46 -0800233 mSkipRenderingAudioUntilMediaTimeUs = -1;
234 mSkipRenderingVideoUntilMediaTimeUs = -1;
Andreas Huber3fe62152011-09-16 15:09:22 -0700235 mVideoLateByUs = 0;
236 mNumFramesTotal = 0;
237 mNumFramesDropped = 0;
Andreas Huber1aef2112011-01-04 14:01:29 -0800238
Andreas Huber5bc087c2010-12-23 10:27:40 -0800239 mSource->start();
Andreas Huberf9334412010-12-15 15:17:42 -0800240
Marco Nelissen4110c102012-03-29 09:31:28 -0700241 sp<MetaData> meta = mSource->getFormat(true /* audio */);
242 if (meta != NULL) {
243 int32_t delay = 0;
244 if (!meta->findInt32(kKeyEncoderDelay, &delay)) {
245 delay = 0;
246 }
247 int32_t padding = 0;
248 if (!meta->findInt32(kKeyEncoderPadding, &padding)) {
249 padding = 0;
250 }
251 int32_t numchannels = 0;
252 if (delay + padding) {
253 if (meta->findInt32(kKeyChannelCount, &numchannels)) {
254 size_t frameSize = numchannels * sizeof(int16_t);
255 if (mSkipCutBuffer) {
256 size_t prevbuffersize = mSkipCutBuffer->size();
257 if (prevbuffersize != 0) {
258 ALOGW("Replacing SkipCutBuffer holding %d bytes", prevbuffersize);
259 }
260 delete mSkipCutBuffer;
261 }
262 mSkipCutBuffer = new SkipCutBuffer(delay * frameSize, padding * frameSize);
263 }
264 }
265 }
266
Andreas Huberf9334412010-12-15 15:17:42 -0800267 mRenderer = new Renderer(
268 mAudioSink,
269 new AMessage(kWhatRendererNotify, id()));
270
271 looper()->registerHandler(mRenderer);
272
Andreas Huber1aef2112011-01-04 14:01:29 -0800273 postScanSources();
Andreas Huberf9334412010-12-15 15:17:42 -0800274 break;
275 }
276
277 case kWhatScanSources:
278 {
Andreas Huber1aef2112011-01-04 14:01:29 -0800279 int32_t generation;
280 CHECK(msg->findInt32("generation", &generation));
281 if (generation != mScanSourcesGeneration) {
282 // Drop obsolete msg.
283 break;
284 }
285
Andreas Huber5bc087c2010-12-23 10:27:40 -0800286 mScanSourcesPending = false;
287
Steve Block3856b092011-10-20 11:56:00 +0100288 ALOGV("scanning sources haveAudio=%d, haveVideo=%d",
Andreas Huber43c3e6c2011-01-05 12:17:08 -0800289 mAudioDecoder != NULL, mVideoDecoder != NULL);
290
Andreas Huber5bc087c2010-12-23 10:27:40 -0800291 instantiateDecoder(false, &mVideoDecoder);
Andreas Huberf9334412010-12-15 15:17:42 -0800292
293 if (mAudioSink != NULL) {
Andreas Huber5bc087c2010-12-23 10:27:40 -0800294 instantiateDecoder(true, &mAudioDecoder);
Andreas Huberf9334412010-12-15 15:17:42 -0800295 }
296
Andreas Hubereac68ba2011-09-27 12:12:25 -0700297 status_t err;
298 if ((err = mSource->feedMoreTSData()) != OK) {
Andreas Huber1aef2112011-01-04 14:01:29 -0800299 if (mAudioDecoder == NULL && mVideoDecoder == NULL) {
300 // We're not currently decoding anything (no audio or
301 // video tracks found) and we just ran out of input data.
Andreas Hubereac68ba2011-09-27 12:12:25 -0700302
303 if (err == ERROR_END_OF_STREAM) {
304 notifyListener(MEDIA_PLAYBACK_COMPLETE, 0, 0);
305 } else {
306 notifyListener(MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, err);
307 }
Andreas Huber1aef2112011-01-04 14:01:29 -0800308 }
Andreas Huberf9334412010-12-15 15:17:42 -0800309 break;
310 }
311
Andreas Huberf9334412010-12-15 15:17:42 -0800312 if (mAudioDecoder == NULL || mVideoDecoder == NULL) {
313 msg->post(100000ll);
Andreas Huber5bc087c2010-12-23 10:27:40 -0800314 mScanSourcesPending = true;
Andreas Huberf9334412010-12-15 15:17:42 -0800315 }
316 break;
317 }
318
319 case kWhatVideoNotify:
320 case kWhatAudioNotify:
321 {
322 bool audio = msg->what() == kWhatAudioNotify;
323
324 sp<AMessage> codecRequest;
325 CHECK(msg->findMessage("codec-request", &codecRequest));
326
327 int32_t what;
328 CHECK(codecRequest->findInt32("what", &what));
329
330 if (what == ACodec::kWhatFillThisBuffer) {
331 status_t err = feedDecoderInputData(
332 audio, codecRequest);
333
Andreas Huber5bc087c2010-12-23 10:27:40 -0800334 if (err == -EWOULDBLOCK) {
Andreas Hubereac68ba2011-09-27 12:12:25 -0700335 if (mSource->feedMoreTSData() == OK) {
Andreas Huber1183a4a2011-11-03 11:00:21 -0700336 msg->post(10000ll);
Andreas Huber5bc087c2010-12-23 10:27:40 -0800337 }
Andreas Huberf9334412010-12-15 15:17:42 -0800338 }
339 } else if (what == ACodec::kWhatEOS) {
Andreas Huberdc9bacd2011-09-26 10:53:29 -0700340 int32_t err;
341 CHECK(codecRequest->findInt32("err", &err));
342
343 if (err == ERROR_END_OF_STREAM) {
Steve Block3856b092011-10-20 11:56:00 +0100344 ALOGV("got %s decoder EOS", audio ? "audio" : "video");
Andreas Huberdc9bacd2011-09-26 10:53:29 -0700345 } else {
Steve Block3856b092011-10-20 11:56:00 +0100346 ALOGV("got %s decoder EOS w/ error %d",
Andreas Huberdc9bacd2011-09-26 10:53:29 -0700347 audio ? "audio" : "video",
348 err);
349 }
350
351 mRenderer->queueEOS(audio, err);
Andreas Huberf9334412010-12-15 15:17:42 -0800352 } else if (what == ACodec::kWhatFlushCompleted) {
Andreas Huber1aef2112011-01-04 14:01:29 -0800353 bool needShutdown;
Andreas Huber53df1a42010-12-22 10:03:04 -0800354
Andreas Huberf9334412010-12-15 15:17:42 -0800355 if (audio) {
Andreas Huber1aef2112011-01-04 14:01:29 -0800356 CHECK(IsFlushingState(mFlushingAudio, &needShutdown));
Andreas Huberf9334412010-12-15 15:17:42 -0800357 mFlushingAudio = FLUSHED;
358 } else {
Andreas Huber1aef2112011-01-04 14:01:29 -0800359 CHECK(IsFlushingState(mFlushingVideo, &needShutdown));
Andreas Huberf9334412010-12-15 15:17:42 -0800360 mFlushingVideo = FLUSHED;
Andreas Huber3fe62152011-09-16 15:09:22 -0700361
362 mVideoLateByUs = 0;
Andreas Huberf9334412010-12-15 15:17:42 -0800363 }
364
Steve Block3856b092011-10-20 11:56:00 +0100365 ALOGV("decoder %s flush completed", audio ? "audio" : "video");
Andreas Huberf9334412010-12-15 15:17:42 -0800366
Andreas Huber1aef2112011-01-04 14:01:29 -0800367 if (needShutdown) {
Steve Block3856b092011-10-20 11:56:00 +0100368 ALOGV("initiating %s decoder shutdown",
Andreas Huber53df1a42010-12-22 10:03:04 -0800369 audio ? "audio" : "video");
Andreas Huberf9334412010-12-15 15:17:42 -0800370
Andreas Huber53df1a42010-12-22 10:03:04 -0800371 (audio ? mAudioDecoder : mVideoDecoder)->initiateShutdown();
Andreas Huberf9334412010-12-15 15:17:42 -0800372
Andreas Huber53df1a42010-12-22 10:03:04 -0800373 if (audio) {
374 mFlushingAudio = SHUTTING_DOWN_DECODER;
375 } else {
376 mFlushingVideo = SHUTTING_DOWN_DECODER;
377 }
Andreas Huberf9334412010-12-15 15:17:42 -0800378 }
Andreas Huber3831a062010-12-21 10:22:33 -0800379
380 finishFlushIfPossible();
Andreas Huber2c2814b2010-12-15 17:18:20 -0800381 } else if (what == ACodec::kWhatOutputFormatChanged) {
Andreas Huber31e25082011-01-10 10:38:31 -0800382 if (audio) {
383 int32_t numChannels;
384 CHECK(codecRequest->findInt32("channel-count", &numChannels));
Andreas Huber2c2814b2010-12-15 17:18:20 -0800385
Andreas Huber31e25082011-01-10 10:38:31 -0800386 int32_t sampleRate;
387 CHECK(codecRequest->findInt32("sample-rate", &sampleRate));
Andreas Huber2c2814b2010-12-15 17:18:20 -0800388
Steve Block3856b092011-10-20 11:56:00 +0100389 ALOGV("Audio output format changed to %d Hz, %d channels",
Andreas Huber31e25082011-01-10 10:38:31 -0800390 sampleRate, numChannels);
Andreas Huber2c2814b2010-12-15 17:18:20 -0800391
Andreas Huber31e25082011-01-10 10:38:31 -0800392 mAudioSink->close();
Andreas Huber078cfcf2011-09-15 12:25:04 -0700393 CHECK_EQ(mAudioSink->open(
394 sampleRate,
395 numChannels,
Jean-Michel Trivi786618f2012-03-02 14:54:07 -0800396 CHANNEL_MASK_USE_CHANNEL_ORDER,
Andreas Huber078cfcf2011-09-15 12:25:04 -0700397 AUDIO_FORMAT_PCM_16_BIT,
398 8 /* bufferCount */),
399 (status_t)OK);
Andreas Huber31e25082011-01-10 10:38:31 -0800400 mAudioSink->start();
Andreas Huber2c2814b2010-12-15 17:18:20 -0800401
Andreas Huber31e25082011-01-10 10:38:31 -0800402 mRenderer->signalAudioSinkChanged();
403 } else {
404 // video
Andreas Huber3831a062010-12-21 10:22:33 -0800405
Andreas Huber31e25082011-01-10 10:38:31 -0800406 int32_t width, height;
407 CHECK(codecRequest->findInt32("width", &width));
408 CHECK(codecRequest->findInt32("height", &height));
409
410 int32_t cropLeft, cropTop, cropRight, cropBottom;
411 CHECK(codecRequest->findRect(
412 "crop",
413 &cropLeft, &cropTop, &cropRight, &cropBottom));
414
Steve Block3856b092011-10-20 11:56:00 +0100415 ALOGV("Video output format changed to %d x %d "
Andreas Hubercb67cd12011-08-26 16:02:19 -0700416 "(crop: %d x %d @ (%d, %d))",
Andreas Huber31e25082011-01-10 10:38:31 -0800417 width, height,
Andreas Hubercb67cd12011-08-26 16:02:19 -0700418 (cropRight - cropLeft + 1),
419 (cropBottom - cropTop + 1),
420 cropLeft, cropTop);
Andreas Huber31e25082011-01-10 10:38:31 -0800421
422 notifyListener(
423 MEDIA_SET_VIDEO_SIZE,
424 cropRight - cropLeft + 1,
425 cropBottom - cropTop + 1);
426 }
Andreas Huber3831a062010-12-21 10:22:33 -0800427 } else if (what == ACodec::kWhatShutdownCompleted) {
Steve Block3856b092011-10-20 11:56:00 +0100428 ALOGV("%s shutdown completed", audio ? "audio" : "video");
Andreas Huber3831a062010-12-21 10:22:33 -0800429 if (audio) {
430 mAudioDecoder.clear();
431
432 CHECK_EQ((int)mFlushingAudio, (int)SHUTTING_DOWN_DECODER);
433 mFlushingAudio = SHUT_DOWN;
434 } else {
435 mVideoDecoder.clear();
436
437 CHECK_EQ((int)mFlushingVideo, (int)SHUTTING_DOWN_DECODER);
438 mFlushingVideo = SHUT_DOWN;
439 }
440
441 finishFlushIfPossible();
Andreas Huberc92fd242011-08-16 13:48:44 -0700442 } else if (what == ACodec::kWhatError) {
Steve Block29357bc2012-01-06 19:20:56 +0000443 ALOGE("Received error from %s decoder, aborting playback.",
Andreas Huberc92fd242011-08-16 13:48:44 -0700444 audio ? "audio" : "video");
445
446 mRenderer->queueEOS(audio, UNKNOWN_ERROR);
Andreas Huber57788222012-02-21 11:47:18 -0800447 } else if (what == ACodec::kWhatDrainThisBuffer) {
Andreas Huberf9334412010-12-15 15:17:42 -0800448 renderBuffer(audio, codecRequest);
Andreas Huber57788222012-02-21 11:47:18 -0800449 } else {
450 ALOGV("Unhandled codec notification %d.", what);
Andreas Huberf9334412010-12-15 15:17:42 -0800451 }
452
453 break;
454 }
455
456 case kWhatRendererNotify:
457 {
458 int32_t what;
459 CHECK(msg->findInt32("what", &what));
460
461 if (what == Renderer::kWhatEOS) {
462 int32_t audio;
463 CHECK(msg->findInt32("audio", &audio));
464
Andreas Huberc92fd242011-08-16 13:48:44 -0700465 int32_t finalResult;
466 CHECK(msg->findInt32("finalResult", &finalResult));
467
Andreas Huberf9334412010-12-15 15:17:42 -0800468 if (audio) {
469 mAudioEOS = true;
470 } else {
471 mVideoEOS = true;
472 }
473
Andreas Huberc92fd242011-08-16 13:48:44 -0700474 if (finalResult == ERROR_END_OF_STREAM) {
Steve Block3856b092011-10-20 11:56:00 +0100475 ALOGV("reached %s EOS", audio ? "audio" : "video");
Andreas Huberc92fd242011-08-16 13:48:44 -0700476 } else {
Steve Block29357bc2012-01-06 19:20:56 +0000477 ALOGE("%s track encountered an error (%d)",
Andreas Huberc92fd242011-08-16 13:48:44 -0700478 audio ? "audio" : "video", finalResult);
479
480 notifyListener(
481 MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, finalResult);
482 }
Andreas Huberf9334412010-12-15 15:17:42 -0800483
484 if ((mAudioEOS || mAudioDecoder == NULL)
485 && (mVideoEOS || mVideoDecoder == NULL)) {
486 notifyListener(MEDIA_PLAYBACK_COMPLETE, 0, 0);
487 }
Andreas Huber43c3e6c2011-01-05 12:17:08 -0800488 } else if (what == Renderer::kWhatPosition) {
489 int64_t positionUs;
490 CHECK(msg->findInt64("positionUs", &positionUs));
491
Andreas Huber3fe62152011-09-16 15:09:22 -0700492 CHECK(msg->findInt64("videoLateByUs", &mVideoLateByUs));
493
Andreas Huber43c3e6c2011-01-05 12:17:08 -0800494 if (mDriver != NULL) {
495 sp<NuPlayerDriver> driver = mDriver.promote();
496 if (driver != NULL) {
497 driver->notifyPosition(positionUs);
Andreas Huber3fe62152011-09-16 15:09:22 -0700498
499 driver->notifyFrameStats(
500 mNumFramesTotal, mNumFramesDropped);
Andreas Huber43c3e6c2011-01-05 12:17:08 -0800501 }
502 }
Andreas Huber3fe62152011-09-16 15:09:22 -0700503 } else if (what == Renderer::kWhatFlushComplete) {
Andreas Huberf9334412010-12-15 15:17:42 -0800504 CHECK_EQ(what, (int32_t)Renderer::kWhatFlushComplete);
505
506 int32_t audio;
507 CHECK(msg->findInt32("audio", &audio));
508
Steve Block3856b092011-10-20 11:56:00 +0100509 ALOGV("renderer %s flush completed.", audio ? "audio" : "video");
Andreas Huberf9334412010-12-15 15:17:42 -0800510 }
511 break;
512 }
513
514 case kWhatMoreDataQueued:
515 {
516 break;
517 }
518
Andreas Huber1aef2112011-01-04 14:01:29 -0800519 case kWhatReset:
520 {
Steve Block3856b092011-10-20 11:56:00 +0100521 ALOGV("kWhatReset");
Andreas Huber1aef2112011-01-04 14:01:29 -0800522
Andreas Huberb58ce9f2011-11-28 16:27:35 -0800523 if (mRenderer != NULL) {
524 // There's an edge case where the renderer owns all output
525 // buffers and is paused, therefore the decoder will not read
526 // more input data and will never encounter the matching
527 // discontinuity. To avoid this, we resume the renderer.
528
529 if (mFlushingAudio == AWAITING_DISCONTINUITY
530 || mFlushingVideo == AWAITING_DISCONTINUITY) {
531 mRenderer->resume();
532 }
533 }
534
Andreas Huber1aef2112011-01-04 14:01:29 -0800535 if (mFlushingAudio != NONE || mFlushingVideo != NONE) {
536 // We're currently flushing, postpone the reset until that's
537 // completed.
538
Andreas Huberea9d51b2011-11-30 09:53:40 -0800539 ALOGV("postponing reset mFlushingAudio=%d, mFlushingVideo=%d",
540 mFlushingAudio, mFlushingVideo);
Andreas Huber1aef2112011-01-04 14:01:29 -0800541
542 mResetPostponed = true;
543 break;
544 }
545
546 if (mAudioDecoder == NULL && mVideoDecoder == NULL) {
547 finishReset();
548 break;
549 }
550
Andreas Huber6e3d3112011-11-28 12:36:11 -0800551 mTimeDiscontinuityPending = true;
552
Andreas Huber1aef2112011-01-04 14:01:29 -0800553 if (mAudioDecoder != NULL) {
554 flushDecoder(true /* audio */, true /* needShutdown */);
555 }
556
557 if (mVideoDecoder != NULL) {
558 flushDecoder(false /* audio */, true /* needShutdown */);
559 }
560
561 mResetInProgress = true;
562 break;
563 }
564
Andreas Huber43c3e6c2011-01-05 12:17:08 -0800565 case kWhatSeek:
566 {
567 int64_t seekTimeUs;
568 CHECK(msg->findInt64("seekTimeUs", &seekTimeUs));
569
Steve Block3856b092011-10-20 11:56:00 +0100570 ALOGV("kWhatSeek seekTimeUs=%lld us (%.2f secs)",
Andreas Huber43c3e6c2011-01-05 12:17:08 -0800571 seekTimeUs, seekTimeUs / 1E6);
572
573 mSource->seekTo(seekTimeUs);
574
575 if (mDriver != NULL) {
576 sp<NuPlayerDriver> driver = mDriver.promote();
577 if (driver != NULL) {
578 driver->notifySeekComplete();
579 }
580 }
581
582 break;
583 }
584
Andreas Huberb4082222011-01-20 15:23:04 -0800585 case kWhatPause:
586 {
587 CHECK(mRenderer != NULL);
588 mRenderer->pause();
589 break;
590 }
591
592 case kWhatResume:
593 {
594 CHECK(mRenderer != NULL);
595 mRenderer->resume();
596 break;
597 }
598
Andreas Huberf9334412010-12-15 15:17:42 -0800599 default:
600 TRESPASS();
601 break;
602 }
603}
604
Andreas Huber3831a062010-12-21 10:22:33 -0800605void NuPlayer::finishFlushIfPossible() {
606 if (mFlushingAudio != FLUSHED && mFlushingAudio != SHUT_DOWN) {
607 return;
608 }
609
610 if (mFlushingVideo != FLUSHED && mFlushingVideo != SHUT_DOWN) {
611 return;
612 }
613
Steve Block3856b092011-10-20 11:56:00 +0100614 ALOGV("both audio and video are flushed now.");
Andreas Huber3831a062010-12-21 10:22:33 -0800615
Andreas Huber6e3d3112011-11-28 12:36:11 -0800616 if (mTimeDiscontinuityPending) {
617 mRenderer->signalTimeDiscontinuity();
618 mTimeDiscontinuityPending = false;
619 }
Andreas Huber3831a062010-12-21 10:22:33 -0800620
Andreas Huber22fc52f2011-01-05 16:24:27 -0800621 if (mAudioDecoder != NULL) {
Andreas Huber3831a062010-12-21 10:22:33 -0800622 mAudioDecoder->signalResume();
623 }
624
Andreas Huber22fc52f2011-01-05 16:24:27 -0800625 if (mVideoDecoder != NULL) {
Andreas Huber3831a062010-12-21 10:22:33 -0800626 mVideoDecoder->signalResume();
627 }
628
629 mFlushingAudio = NONE;
630 mFlushingVideo = NONE;
Andreas Huber3831a062010-12-21 10:22:33 -0800631
Andreas Huber1aef2112011-01-04 14:01:29 -0800632 if (mResetInProgress) {
Steve Block3856b092011-10-20 11:56:00 +0100633 ALOGV("reset completed");
Andreas Huber1aef2112011-01-04 14:01:29 -0800634
635 mResetInProgress = false;
636 finishReset();
637 } else if (mResetPostponed) {
638 (new AMessage(kWhatReset, id()))->post();
639 mResetPostponed = false;
Andreas Huber22fc52f2011-01-05 16:24:27 -0800640 } else if (mAudioDecoder == NULL || mVideoDecoder == NULL) {
Andreas Huber1aef2112011-01-04 14:01:29 -0800641 postScanSources();
Andreas Huberf9334412010-12-15 15:17:42 -0800642 }
643}
644
Andreas Huber1aef2112011-01-04 14:01:29 -0800645void NuPlayer::finishReset() {
646 CHECK(mAudioDecoder == NULL);
647 CHECK(mVideoDecoder == NULL);
648
Andreas Huber2bfdd422011-10-11 15:24:07 -0700649 ++mScanSourcesGeneration;
650 mScanSourcesPending = false;
651
Andreas Huber1aef2112011-01-04 14:01:29 -0800652 mRenderer.clear();
Andreas Huber2bfdd422011-10-11 15:24:07 -0700653
654 if (mSource != NULL) {
655 mSource->stop();
656 mSource.clear();
657 }
Andreas Huber1aef2112011-01-04 14:01:29 -0800658
Andreas Huber43c3e6c2011-01-05 12:17:08 -0800659 if (mDriver != NULL) {
660 sp<NuPlayerDriver> driver = mDriver.promote();
661 if (driver != NULL) {
662 driver->notifyResetComplete();
663 }
664 }
Andreas Huber1aef2112011-01-04 14:01:29 -0800665}
666
667void NuPlayer::postScanSources() {
668 if (mScanSourcesPending) {
669 return;
670 }
671
672 sp<AMessage> msg = new AMessage(kWhatScanSources, id());
673 msg->setInt32("generation", mScanSourcesGeneration);
674 msg->post();
675
676 mScanSourcesPending = true;
677}
678
Andreas Huber5bc087c2010-12-23 10:27:40 -0800679status_t NuPlayer::instantiateDecoder(bool audio, sp<Decoder> *decoder) {
Andreas Huberf9334412010-12-15 15:17:42 -0800680 if (*decoder != NULL) {
681 return OK;
682 }
683
Andreas Huber5bc087c2010-12-23 10:27:40 -0800684 sp<MetaData> meta = mSource->getFormat(audio);
Andreas Huberf9334412010-12-15 15:17:42 -0800685
Andreas Huber5bc087c2010-12-23 10:27:40 -0800686 if (meta == NULL) {
Andreas Huberf9334412010-12-15 15:17:42 -0800687 return -EWOULDBLOCK;
688 }
689
Andreas Huber3fe62152011-09-16 15:09:22 -0700690 if (!audio) {
691 const char *mime;
692 CHECK(meta->findCString(kKeyMIMEType, &mime));
693 mVideoIsAVC = !strcasecmp(MEDIA_MIMETYPE_VIDEO_AVC, mime);
694 }
695
Andreas Huberf9334412010-12-15 15:17:42 -0800696 sp<AMessage> notify =
697 new AMessage(audio ? kWhatAudioNotify : kWhatVideoNotify,
698 id());
699
Glenn Kasten11731182011-02-08 17:26:17 -0800700 *decoder = audio ? new Decoder(notify) :
701 new Decoder(notify, mNativeWindow);
Andreas Huberf9334412010-12-15 15:17:42 -0800702 looper()->registerHandler(*decoder);
703
Andreas Huber5bc087c2010-12-23 10:27:40 -0800704 (*decoder)->configure(meta);
Andreas Huberf9334412010-12-15 15:17:42 -0800705
Andreas Huber43c3e6c2011-01-05 12:17:08 -0800706 int64_t durationUs;
707 if (mDriver != NULL && mSource->getDuration(&durationUs) == OK) {
708 sp<NuPlayerDriver> driver = mDriver.promote();
709 if (driver != NULL) {
710 driver->notifyDuration(durationUs);
711 }
712 }
713
Andreas Huberf9334412010-12-15 15:17:42 -0800714 return OK;
715}
716
717status_t NuPlayer::feedDecoderInputData(bool audio, const sp<AMessage> &msg) {
718 sp<AMessage> reply;
719 CHECK(msg->findMessage("reply", &reply));
720
Andreas Huber53df1a42010-12-22 10:03:04 -0800721 if ((audio && IsFlushingState(mFlushingAudio))
722 || (!audio && IsFlushingState(mFlushingVideo))) {
Andreas Huberf9334412010-12-15 15:17:42 -0800723 reply->setInt32("err", INFO_DISCONTINUITY);
724 reply->post();
725 return OK;
726 }
727
728 sp<ABuffer> accessUnit;
Andreas Huberf9334412010-12-15 15:17:42 -0800729
Andreas Huber3fe62152011-09-16 15:09:22 -0700730 bool dropAccessUnit;
731 do {
732 status_t err = mSource->dequeueAccessUnit(audio, &accessUnit);
Andreas Huber5bc087c2010-12-23 10:27:40 -0800733
Andreas Huber3fe62152011-09-16 15:09:22 -0700734 if (err == -EWOULDBLOCK) {
735 return err;
736 } else if (err != OK) {
737 if (err == INFO_DISCONTINUITY) {
738 int32_t type;
739 CHECK(accessUnit->meta()->findInt32("discontinuity", &type));
Andreas Huber53df1a42010-12-22 10:03:04 -0800740
Andreas Huber3fe62152011-09-16 15:09:22 -0700741 bool formatChange =
Andreas Huber6e3d3112011-11-28 12:36:11 -0800742 (audio &&
743 (type & ATSParser::DISCONTINUITY_AUDIO_FORMAT))
744 || (!audio &&
745 (type & ATSParser::DISCONTINUITY_VIDEO_FORMAT));
Andreas Huber53df1a42010-12-22 10:03:04 -0800746
Andreas Huber6e3d3112011-11-28 12:36:11 -0800747 bool timeChange = (type & ATSParser::DISCONTINUITY_TIME) != 0;
748
Steve Blockdf64d152012-01-04 20:05:49 +0000749 ALOGI("%s discontinuity (formatChange=%d, time=%d)",
Andreas Huber6e3d3112011-11-28 12:36:11 -0800750 audio ? "audio" : "video", formatChange, timeChange);
Andreas Huber32f3cef2011-03-02 15:34:46 -0800751
Andreas Huber3fe62152011-09-16 15:09:22 -0700752 if (audio) {
753 mSkipRenderingAudioUntilMediaTimeUs = -1;
754 } else {
755 mSkipRenderingVideoUntilMediaTimeUs = -1;
756 }
Andreas Huber32f3cef2011-03-02 15:34:46 -0800757
Andreas Huber6e3d3112011-11-28 12:36:11 -0800758 if (timeChange) {
759 sp<AMessage> extra;
760 if (accessUnit->meta()->findMessage("extra", &extra)
761 && extra != NULL) {
762 int64_t resumeAtMediaTimeUs;
763 if (extra->findInt64(
764 "resume-at-mediatimeUs", &resumeAtMediaTimeUs)) {
Steve Blockdf64d152012-01-04 20:05:49 +0000765 ALOGI("suppressing rendering of %s until %lld us",
Andreas Huber6e3d3112011-11-28 12:36:11 -0800766 audio ? "audio" : "video", resumeAtMediaTimeUs);
Andreas Huber3fe62152011-09-16 15:09:22 -0700767
Andreas Huber6e3d3112011-11-28 12:36:11 -0800768 if (audio) {
769 mSkipRenderingAudioUntilMediaTimeUs =
770 resumeAtMediaTimeUs;
771 } else {
772 mSkipRenderingVideoUntilMediaTimeUs =
773 resumeAtMediaTimeUs;
774 }
Andreas Huber3fe62152011-09-16 15:09:22 -0700775 }
Andreas Huber32f3cef2011-03-02 15:34:46 -0800776 }
777 }
Andreas Huber3fe62152011-09-16 15:09:22 -0700778
Andreas Huber6e3d3112011-11-28 12:36:11 -0800779 mTimeDiscontinuityPending =
780 mTimeDiscontinuityPending || timeChange;
781
782 if (formatChange || timeChange) {
783 flushDecoder(audio, formatChange);
784 } else {
785 // This stream is unaffected by the discontinuity
786
787 if (audio) {
788 mFlushingAudio = FLUSHED;
789 } else {
790 mFlushingVideo = FLUSHED;
791 }
792
793 finishFlushIfPossible();
794
795 return -EWOULDBLOCK;
796 }
Andreas Huber32f3cef2011-03-02 15:34:46 -0800797 }
798
Andreas Huber3fe62152011-09-16 15:09:22 -0700799 reply->setInt32("err", err);
800 reply->post();
801 return OK;
Andreas Huberf9334412010-12-15 15:17:42 -0800802 }
803
Andreas Huber3fe62152011-09-16 15:09:22 -0700804 if (!audio) {
805 ++mNumFramesTotal;
806 }
807
808 dropAccessUnit = false;
809 if (!audio
810 && mVideoLateByUs > 100000ll
811 && mVideoIsAVC
812 && !IsAVCReferenceFrame(accessUnit)) {
813 dropAccessUnit = true;
814 ++mNumFramesDropped;
815 }
816 } while (dropAccessUnit);
Andreas Huberf9334412010-12-15 15:17:42 -0800817
Steve Block3856b092011-10-20 11:56:00 +0100818 // ALOGV("returned a valid buffer of %s data", audio ? "audio" : "video");
Andreas Huberf9334412010-12-15 15:17:42 -0800819
820#if 0
821 int64_t mediaTimeUs;
822 CHECK(accessUnit->meta()->findInt64("timeUs", &mediaTimeUs));
Steve Block3856b092011-10-20 11:56:00 +0100823 ALOGV("feeding %s input buffer at media time %.2f secs",
Andreas Huberf9334412010-12-15 15:17:42 -0800824 audio ? "audio" : "video",
825 mediaTimeUs / 1E6);
826#endif
827
Andreas Huber2d8bedd2012-02-21 14:38:23 -0800828 reply->setBuffer("buffer", accessUnit);
Andreas Huberf9334412010-12-15 15:17:42 -0800829 reply->post();
830
831 return OK;
832}
833
834void NuPlayer::renderBuffer(bool audio, const sp<AMessage> &msg) {
Steve Block3856b092011-10-20 11:56:00 +0100835 // ALOGV("renderBuffer %s", audio ? "audio" : "video");
Andreas Huberf9334412010-12-15 15:17:42 -0800836
837 sp<AMessage> reply;
838 CHECK(msg->findMessage("reply", &reply));
839
Andreas Huber18ac5402011-08-31 15:04:25 -0700840 if (IsFlushingState(audio ? mFlushingAudio : mFlushingVideo)) {
841 // We're currently attempting to flush the decoder, in order
842 // to complete this, the decoder wants all its buffers back,
843 // so we don't want any output buffers it sent us (from before
844 // we initiated the flush) to be stuck in the renderer's queue.
845
Steve Block3856b092011-10-20 11:56:00 +0100846 ALOGV("we're still flushing the %s decoder, sending its output buffer"
Andreas Huber18ac5402011-08-31 15:04:25 -0700847 " right back.", audio ? "audio" : "video");
848
849 reply->post();
850 return;
851 }
852
Andreas Huber2d8bedd2012-02-21 14:38:23 -0800853 sp<ABuffer> buffer;
854 CHECK(msg->findBuffer("buffer", &buffer));
Andreas Huberf9334412010-12-15 15:17:42 -0800855
Andreas Huber32f3cef2011-03-02 15:34:46 -0800856 int64_t &skipUntilMediaTimeUs =
857 audio
858 ? mSkipRenderingAudioUntilMediaTimeUs
859 : mSkipRenderingVideoUntilMediaTimeUs;
860
861 if (skipUntilMediaTimeUs >= 0) {
862 int64_t mediaTimeUs;
863 CHECK(buffer->meta()->findInt64("timeUs", &mediaTimeUs));
864
865 if (mediaTimeUs < skipUntilMediaTimeUs) {
Steve Block3856b092011-10-20 11:56:00 +0100866 ALOGV("dropping %s buffer at time %lld as requested.",
Andreas Huber32f3cef2011-03-02 15:34:46 -0800867 audio ? "audio" : "video",
868 mediaTimeUs);
869
870 reply->post();
871 return;
872 }
873
874 skipUntilMediaTimeUs = -1;
875 }
876
Marco Nelissen4110c102012-03-29 09:31:28 -0700877 if (audio && mSkipCutBuffer) {
878 mSkipCutBuffer->submit(buffer);
879 }
880
Andreas Huberf9334412010-12-15 15:17:42 -0800881 mRenderer->queueBuffer(audio, buffer, reply);
882}
883
884void NuPlayer::notifyListener(int msg, int ext1, int ext2) {
Andreas Huber43c3e6c2011-01-05 12:17:08 -0800885 if (mDriver == NULL) {
Andreas Huberf9334412010-12-15 15:17:42 -0800886 return;
887 }
888
Andreas Huber43c3e6c2011-01-05 12:17:08 -0800889 sp<NuPlayerDriver> driver = mDriver.promote();
Andreas Huberf9334412010-12-15 15:17:42 -0800890
Andreas Huber43c3e6c2011-01-05 12:17:08 -0800891 if (driver == NULL) {
Andreas Huberf9334412010-12-15 15:17:42 -0800892 return;
893 }
894
Andreas Hubera4af2142011-10-26 15:23:31 -0700895 driver->notifyListener(msg, ext1, ext2);
Andreas Huberf9334412010-12-15 15:17:42 -0800896}
897
Andreas Huber1aef2112011-01-04 14:01:29 -0800898void NuPlayer::flushDecoder(bool audio, bool needShutdown) {
Andreas Huber6e3d3112011-11-28 12:36:11 -0800899 if ((audio && mAudioDecoder == NULL) || (!audio && mVideoDecoder == NULL)) {
Steve Blockdf64d152012-01-04 20:05:49 +0000900 ALOGI("flushDecoder %s without decoder present",
Andreas Huber6e3d3112011-11-28 12:36:11 -0800901 audio ? "audio" : "video");
902 }
903
Andreas Huber1aef2112011-01-04 14:01:29 -0800904 // Make sure we don't continue to scan sources until we finish flushing.
905 ++mScanSourcesGeneration;
Andreas Huber43c3e6c2011-01-05 12:17:08 -0800906 mScanSourcesPending = false;
Andreas Huber1aef2112011-01-04 14:01:29 -0800907
908 (audio ? mAudioDecoder : mVideoDecoder)->signalFlush();
909 mRenderer->flush(audio);
910
911 FlushStatus newStatus =
912 needShutdown ? FLUSHING_DECODER_SHUTDOWN : FLUSHING_DECODER;
913
914 if (audio) {
915 CHECK(mFlushingAudio == NONE
916 || mFlushingAudio == AWAITING_DISCONTINUITY);
917
918 mFlushingAudio = newStatus;
919
920 if (mFlushingVideo == NONE) {
921 mFlushingVideo = (mVideoDecoder != NULL)
922 ? AWAITING_DISCONTINUITY
923 : FLUSHED;
924 }
925 } else {
926 CHECK(mFlushingVideo == NONE
927 || mFlushingVideo == AWAITING_DISCONTINUITY);
928
929 mFlushingVideo = newStatus;
930
931 if (mFlushingAudio == NONE) {
932 mFlushingAudio = (mAudioDecoder != NULL)
933 ? AWAITING_DISCONTINUITY
934 : FLUSHED;
935 }
936 }
937}
938
Andreas Huberf9334412010-12-15 15:17:42 -0800939} // namespace android