android_GenericMediaPlayer.cpp revision a6c69c7e1665b38da8d6784e65210acbe501b92c
1/* 2 * Copyright (C) 2011 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 USE_LOG SLAndroidLogLevel_Verbose 18 19#include "sles_allinclusive.h" 20#include "android_GenericMediaPlayer.h" 21 22#include <media/IMediaPlayerService.h> 23#include <surfaceflinger/ISurfaceComposer.h> 24#include <surfaceflinger/SurfaceComposerClient.h> 25#include <media/stagefright/foundation/ADebug.h> 26#include <media/mediaplayer.h> // media_event_type media_error_type media_info_type 27 28// default delay in Us used when reposting an event when the player is not ready to accept 29// the command yet. This is for instance used when seeking on a MediaPlayer that's still preparing 30#define DEFAULT_COMMAND_DELAY_FOR_REPOST_US (100*1000) // 100ms 31 32// table of prefixes for known distant protocols; these are immediately dispatched to mediaserver 33static const char* const kDistantProtocolPrefix[] = { "http://", "https://", "rtsp://"}; 34#define NB_DISTANT_PROTOCOLS (sizeof(kDistantProtocolPrefix)/sizeof(kDistantProtocolPrefix[0])) 35 36// is the specified URI a known distant protocol? 37bool isDistantProtocol(const char *uri) 38{ 39 for (unsigned int i = 0; i < NB_DISTANT_PROTOCOLS; i++) { 40 if (!strncasecmp(uri, kDistantProtocolPrefix[i], strlen(kDistantProtocolPrefix[i]))) { 41 return true; 42 } 43 } 44 return false; 45} 46 47namespace android { 48 49//-------------------------------------------------------------------------------------------------- 50MediaPlayerNotificationClient::MediaPlayerNotificationClient(GenericMediaPlayer* gmp) : 51 mGenericMediaPlayer(gmp), 52 mPlayerPrepared(PREPARE_NOT_STARTED) 53{ 54 SL_LOGV("MediaPlayerNotificationClient::MediaPlayerNotificationClient()"); 55} 56 57MediaPlayerNotificationClient::~MediaPlayerNotificationClient() { 58 SL_LOGV("MediaPlayerNotificationClient::~MediaPlayerNotificationClient()"); 59} 60 61// Map a media_event_type enum (the msg of an IMediaPlayerClient::notify) to a string or NULL 62static const char *media_event_type_to_string(media_event_type msg) 63{ 64 switch (msg) { 65#define _(code) case code: return #code; 66 _(MEDIA_NOP) 67 _(MEDIA_PREPARED) 68 _(MEDIA_PLAYBACK_COMPLETE) 69 _(MEDIA_BUFFERING_UPDATE) 70 _(MEDIA_SEEK_COMPLETE) 71 _(MEDIA_SET_VIDEO_SIZE) 72 _(MEDIA_TIMED_TEXT) 73 _(MEDIA_ERROR) 74 _(MEDIA_INFO) 75#undef _ 76 default: 77 return NULL; 78 } 79} 80 81// Map a media_error_type enum (the ext1 of a MEDIA_ERROR event) to a string or NULL 82static const char *media_error_type_to_string(media_error_type err) 83{ 84 switch (err) { 85#define _(code, msg) case code: return msg; 86 _(MEDIA_ERROR_UNKNOWN, "Unknown media error") 87 _(MEDIA_ERROR_SERVER_DIED, "Server died") 88 _(MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK, "Not valid for progressive playback") 89#undef _ 90 default: 91 return NULL; 92 } 93} 94 95// Map a media_info_type enum (the ext1 of a MEDIA_INFO event) to a string or NULL 96static const char *media_info_type_to_string(media_info_type info) 97{ 98 switch (info) { 99#define _(code, msg) case code: return msg; 100 _(MEDIA_INFO_UNKNOWN, "Unknown info") 101 _(MEDIA_INFO_VIDEO_TRACK_LAGGING, "Video track lagging") 102 _(MEDIA_INFO_BUFFERING_START, "Buffering start") 103 _(MEDIA_INFO_BUFFERING_END, "Buffering end") 104 _(MEDIA_INFO_NETWORK_BANDWIDTH, "Network bandwidth") 105 _(MEDIA_INFO_BAD_INTERLEAVING, "Bad interleaving") 106 _(MEDIA_INFO_NOT_SEEKABLE, "Not seekable") 107 _(MEDIA_INFO_METADATA_UPDATE, "Metadata update") 108#undef _ 109 default: 110 return NULL; 111 } 112} 113 114//-------------------------------------------------- 115// IMediaPlayerClient implementation 116void MediaPlayerNotificationClient::notify(int msg, int ext1, int ext2, const Parcel *obj) { 117 SL_LOGV("MediaPlayerNotificationClient::notify(msg=%s (%d), ext1=%d, ext2=%d)", 118 media_event_type_to_string((enum media_event_type) msg), msg, ext1, ext2); 119 120 sp<GenericMediaPlayer> genericMediaPlayer(mGenericMediaPlayer.promote()); 121 if (genericMediaPlayer == NULL) { 122 SL_LOGW("MediaPlayerNotificationClient::notify after GenericMediaPlayer destroyed"); 123 return; 124 } 125 126 switch ((media_event_type) msg) { 127 case MEDIA_PREPARED: 128 { 129 Mutex::Autolock _l(mLock); 130 if (PREPARE_IN_PROGRESS == mPlayerPrepared) { 131 mPlayerPrepared = PREPARE_COMPLETED_SUCCESSFULLY; 132 mPlayerPreparedCondition.signal(); 133 } else { 134 SL_LOGE("Unexpected MEDIA_PREPARED"); 135 } 136 } 137 break; 138 139 case MEDIA_SET_VIDEO_SIZE: 140 // only send video size updates if the player was flagged as having video, to avoid 141 // sending video size updates of (0,0) 142 // We're running on a different thread than genericMediaPlayer's ALooper thread, 143 // so it would normally be racy to access fields within genericMediaPlayer. 144 // But in this case mHasVideo is const, so it is safe to access. 145 // Or alternatively, we could notify unconditionally and let it decide whether to handle. 146 if (genericMediaPlayer->mHasVideo && (ext1 != 0 || ext2 != 0)) { 147 genericMediaPlayer->notify(PLAYEREVENT_VIDEO_SIZE_UPDATE, 148 (int32_t)ext1 /*width*/, (int32_t)ext2 /*height*/, true /*async*/); 149 } 150 break; 151 152 case MEDIA_SEEK_COMPLETE: 153 genericMediaPlayer->seekComplete(); 154 break; 155 156 case MEDIA_PLAYBACK_COMPLETE: 157 genericMediaPlayer->notify(PLAYEREVENT_ENDOFSTREAM, 1, true /*async*/); 158 break; 159 160 case MEDIA_BUFFERING_UPDATE: 161 // if we receive any out-of-range data, then clamp it to reduce further harm 162 if (ext1 < 0) { 163 SL_LOGE("MEDIA_BUFFERING_UPDATE %d%% < 0", ext1); 164 ext1 = 0; 165 } else if (ext1 > 100) { 166 SL_LOGE("MEDIA_BUFFERING_UPDATE %d%% > 100", ext1); 167 ext1 = 100; 168 } 169 // values received from Android framework for buffer fill level use percent, 170 // while SL/XA use permille, so does GenericPlayer 171 genericMediaPlayer->bufferingUpdate(ext1 * 10 /*fillLevelPerMille*/); 172 break; 173 174 case MEDIA_ERROR: 175 { 176 SL_LOGV("MediaPlayerNotificationClient::notify(msg=MEDIA_ERROR, ext1=%s (%d), ext2=%d)", 177 media_error_type_to_string((media_error_type) ext1), ext1, ext2); 178 Mutex::Autolock _l(mLock); 179 if (PREPARE_IN_PROGRESS == mPlayerPrepared) { 180 mPlayerPrepared = PREPARE_COMPLETED_UNSUCCESSFULLY; 181 mPlayerPreparedCondition.signal(); 182 } else { 183 // inform client of errors after preparation 184 genericMediaPlayer->notify(PLAYEREVENT_ERRORAFTERPREPARE, ext1, true /*async*/); 185 } 186 } 187 break; 188 189 case MEDIA_NOP: 190 case MEDIA_TIMED_TEXT: 191 break; 192 193 case MEDIA_INFO: 194 SL_LOGV("MediaPlayerNotificationClient::notify(msg=MEDIA_INFO, ext1=%s (%d), ext2=%d)", 195 media_info_type_to_string((media_info_type) ext1), ext1, ext2); 196 switch (ext1) { 197 case MEDIA_INFO_VIDEO_TRACK_LAGGING: 198 SL_LOGV("MEDIA_INFO_VIDEO_TRACK_LAGGING by %d ms", ext1); 199 break; 200 case MEDIA_INFO_NETWORK_BANDWIDTH: 201 SL_LOGV("MEDIA_INFO_NETWORK_BANDWIDTH %d kbps", ext2); 202 break; 203 case MEDIA_INFO_UNKNOWN: 204 case MEDIA_INFO_BUFFERING_START: 205 case MEDIA_INFO_BUFFERING_END: 206 case MEDIA_INFO_BAD_INTERLEAVING: 207 case MEDIA_INFO_NOT_SEEKABLE: 208 case MEDIA_INFO_METADATA_UPDATE: 209 default: 210 break; 211 } 212 break; 213 214 default: 215 break; 216 } 217 218} 219 220//-------------------------------------------------- 221void MediaPlayerNotificationClient::beforePrepare() 222{ 223 Mutex::Autolock _l(mLock); 224 assert(mPlayerPrepared == PREPARE_NOT_STARTED); 225 mPlayerPrepared = PREPARE_IN_PROGRESS; 226} 227 228//-------------------------------------------------- 229bool MediaPlayerNotificationClient::blockUntilPlayerPrepared() { 230 Mutex::Autolock _l(mLock); 231 assert(mPlayerPrepared != PREPARE_NOT_STARTED); 232 while (mPlayerPrepared == PREPARE_IN_PROGRESS) { 233 mPlayerPreparedCondition.wait(mLock); 234 } 235 assert(mPlayerPrepared == PREPARE_COMPLETED_SUCCESSFULLY || 236 mPlayerPrepared == PREPARE_COMPLETED_UNSUCCESSFULLY); 237 return mPlayerPrepared == PREPARE_COMPLETED_SUCCESSFULLY; 238} 239 240//-------------------------------------------------------------------------------------------------- 241GenericMediaPlayer::GenericMediaPlayer(const AudioPlayback_Parameters* params, bool hasVideo) : 242 GenericPlayer(params), 243 mHasVideo(hasVideo), 244 mSeekTimeMsec(0), 245 mVideoSurfaceTexture(0), 246 mPlayer(0), 247 mPlayerClient(new MediaPlayerNotificationClient(this)), 248 mPlayerDeathNotifier(new MediaPlayerDeathNotifier(mPlayerClient)) 249{ 250 SL_LOGD("GenericMediaPlayer::GenericMediaPlayer()"); 251 252} 253 254GenericMediaPlayer::~GenericMediaPlayer() { 255 SL_LOGD("GenericMediaPlayer::~GenericMediaPlayer()"); 256} 257 258void GenericMediaPlayer::preDestroy() { 259 // FIXME can't access mPlayer from outside the looper (no mutex!) so using mPreparedPlayer 260 sp<IMediaPlayer> player; 261 getPreparedPlayer(player); 262 if (player != NULL) { 263 player->stop(); 264 // causes CHECK failure in Nuplayer, but commented out in the subclass preDestroy 265 // randomly causes a NPE in StagefrightPlayer, heap corruption, or app hang 266 //player->setDataSource(NULL); 267 player->setVideoSurfaceTexture(NULL); 268 player->disconnect(); 269 // release all references to the IMediaPlayer 270 // FIXME illegal if not on looper 271 //mPlayer.clear(); 272 { 273 Mutex::Autolock _l(mPreparedPlayerLock); 274 mPreparedPlayer.clear(); 275 } 276 } 277 GenericPlayer::preDestroy(); 278} 279 280//-------------------------------------------------- 281// overridden from GenericPlayer 282// pre-condition: 283// msec != NULL 284// post-condition 285// *msec == 286// ANDROID_UNKNOWN_TIME if position is unknown at time of query, 287// or the current MediaPlayer position 288void GenericMediaPlayer::getPositionMsec(int* msec) { 289 SL_LOGD("GenericMediaPlayer::getPositionMsec()"); 290 sp<IMediaPlayer> player; 291 getPreparedPlayer(player); 292 // To avoid deadlock, directly call the MediaPlayer object 293 if (player == 0 || player->getCurrentPosition(msec) != NO_ERROR) { 294 *msec = ANDROID_UNKNOWN_TIME; 295 } 296} 297 298//-------------------------------------------------- 299void GenericMediaPlayer::setVideoSurfaceTexture(const sp<ISurfaceTexture> &surfaceTexture) { 300 SL_LOGV("GenericMediaPlayer::setVideoSurfaceTexture()"); 301 // FIXME bug - race condition, should do in looper 302 if (mVideoSurfaceTexture.get() == surfaceTexture.get()) { 303 return; 304 } 305 if ((mStateFlags & kFlagPrepared) && (mPlayer != 0)) { 306 mPlayer->setVideoSurfaceTexture(surfaceTexture); 307 } 308 mVideoSurfaceTexture = surfaceTexture; 309} 310 311 312//-------------------------------------------------- 313// Event handlers 314 315// blocks until mPlayer is prepared 316void GenericMediaPlayer::onPrepare() { 317 SL_LOGD("GenericMediaPlayer::onPrepare()"); 318 // Attempt to prepare at most once, and only if there is a MediaPlayer 319 if (!(mStateFlags & (kFlagPrepared | kFlagPreparedUnsuccessfully)) && (mPlayer != 0)) { 320 if (mHasVideo) { 321 if (mVideoSurfaceTexture != 0) { 322 mPlayer->setVideoSurfaceTexture(mVideoSurfaceTexture); 323 } 324 } 325 mPlayer->setAudioStreamType(mPlaybackParams.streamType); 326 mPlayerClient->beforePrepare(); 327 mPlayer->prepareAsync(); 328 if (mPlayerClient->blockUntilPlayerPrepared()) { 329 mStateFlags |= kFlagPrepared; 330 afterMediaPlayerPreparedSuccessfully(); 331 } else { 332 mStateFlags |= kFlagPreparedUnsuccessfully; 333 } 334 } 335 GenericPlayer::onPrepare(); 336 SL_LOGD("GenericMediaPlayer::onPrepare() done, mStateFlags=0x%x", mStateFlags); 337} 338 339 340void GenericMediaPlayer::onPlay() { 341 SL_LOGD("GenericMediaPlayer::onPlay()"); 342 if (((mStateFlags & (kFlagPrepared | kFlagPlaying)) == kFlagPrepared) && (mPlayer != 0)) { 343 mPlayer->start(); 344 } 345 GenericPlayer::onPlay(); 346} 347 348 349void GenericMediaPlayer::onPause() { 350 SL_LOGD("GenericMediaPlayer::onPause()"); 351 if (!(~mStateFlags & (kFlagPrepared | kFlagPlaying)) && (mPlayer != 0)) { 352 mPlayer->pause(); 353 } 354 GenericPlayer::onPause(); 355} 356 357 358void GenericMediaPlayer::onSeekComplete() { 359 SL_LOGV("GenericMediaPlayer::onSeekComplete()"); 360 // did we initiate the seek? 361 if (!(mStateFlags & kFlagSeeking)) { 362 // no, are we looping? 363 if (mStateFlags & kFlagLooping) { 364 // yes, per OpenSL ES 1.0.1 and 1.1 do NOT report it to client 365 // notify(PLAYEREVENT_ENDOFSTREAM, 1, true /*async*/); 366 // no, well that's surprising, but it's probably just a benign race condition 367 } else { 368 SL_LOGW("Unexpected seek complete event ignored"); 369 } 370 } 371 GenericPlayer::onSeekComplete(); 372} 373 374 375/** 376 * pre-condition: WHATPARAM_SEEK_SEEKTIME_MS parameter value >= 0 377 */ 378void GenericMediaPlayer::onSeek(const sp<AMessage> &msg) { 379 SL_LOGV("GenericMediaPlayer::onSeek"); 380 int64_t timeMsec = ANDROID_UNKNOWN_TIME; 381 if (!msg->findInt64(WHATPARAM_SEEK_SEEKTIME_MS, &timeMsec)) { 382 // invalid command, drop it 383 return; 384 } 385 if ((mStateFlags & kFlagSeeking) && (timeMsec == mSeekTimeMsec) && 386 (timeMsec != ANDROID_UNKNOWN_TIME)) { 387 // already seeking to the same non-unknown time, cancel this command 388 return; 389 } else if (mStateFlags & kFlagPreparedUnsuccessfully) { 390 // discard seeks after unsuccessful prepare 391 } else if (!(mStateFlags & kFlagPrepared)) { 392 // we are not ready to accept a seek command at this time, retry later 393 msg->post(DEFAULT_COMMAND_DELAY_FOR_REPOST_US); 394 } else { 395 if (mPlayer != 0) { 396 mStateFlags |= kFlagSeeking; 397 mSeekTimeMsec = (int32_t)timeMsec; 398 // seek to unknown time is used by StreamPlayer after discontinuity 399 if (timeMsec == ANDROID_UNKNOWN_TIME) { 400 // FIXME simulate a MEDIA_SEEK_COMPLETE event in 250 ms; 401 // this is a terrible hack to make up for mediaserver not sending one 402 (new AMessage(kWhatSeekComplete, id()))->post(250000); 403 } else if (OK != mPlayer->seekTo(timeMsec)) { 404 mStateFlags &= ~kFlagSeeking; 405 mSeekTimeMsec = ANDROID_UNKNOWN_TIME; 406 // don't call updateOneShot because seek not yet done 407 } 408 } 409 } 410} 411 412 413void GenericMediaPlayer::onLoop(const sp<AMessage> &msg) { 414 SL_LOGV("GenericMediaPlayer::onLoop"); 415 int32_t loop = 0; 416 if (msg->findInt32(WHATPARAM_LOOP_LOOPING, &loop)) { 417 if (loop) { 418 mStateFlags |= kFlagLooping; 419 } else { 420 mStateFlags &= ~kFlagLooping; 421 } 422 // if we have a MediaPlayer then tell it now, otherwise we'll tell it after it's created 423 if (mPlayer != 0) { 424 (void) mPlayer->setLooping(loop); 425 } 426 } 427} 428 429 430void GenericMediaPlayer::onVolumeUpdate() { 431 SL_LOGD("GenericMediaPlayer::onVolumeUpdate()"); 432 if (mPlayer != 0) { 433 // use settings lock to read the volume settings 434 Mutex::Autolock _l(mSettingsLock); 435 mPlayer->setVolume(mAndroidAudioLevels.mFinalVolume[0], 436 mAndroidAudioLevels.mFinalVolume[1]); 437 } 438} 439 440 441void GenericMediaPlayer::onAttachAuxEffect(const sp<AMessage> &msg) { 442 SL_LOGD("GenericMediaPlayer::onAttachAuxEffect()"); 443 int32_t effectId = 0; 444 if (msg->findInt32(WHATPARAM_ATTACHAUXEFFECT, &effectId)) { 445 if (mPlayer != 0) { 446 status_t status; 447 status = mPlayer->attachAuxEffect(effectId); 448 // attachAuxEffect returns a status but we have no way to report it back to app 449 (void) status; 450 } 451 } 452} 453 454 455void GenericMediaPlayer::onSetAuxEffectSendLevel(const sp<AMessage> &msg) { 456 SL_LOGD("GenericMediaPlayer::onSetAuxEffectSendLevel()"); 457 float level = 0.0f; 458 if (msg->findFloat(WHATPARAM_SETAUXEFFECTSENDLEVEL, &level)) { 459 if (mPlayer != 0) { 460 status_t status; 461 status = mPlayer->setAuxEffectSendLevel(level); 462 // setAuxEffectSendLevel returns a status but we have no way to report it back to app 463 (void) status; 464 } 465 } 466} 467 468 469void GenericMediaPlayer::onBufferingUpdate(const sp<AMessage> &msg) { 470 int32_t fillLevel = 0; 471 if (msg->findInt32(WHATPARAM_BUFFERING_UPDATE, &fillLevel)) { 472 SL_LOGD("GenericMediaPlayer::onBufferingUpdate(fillLevel=%d)", fillLevel); 473 474 Mutex::Autolock _l(mSettingsLock); 475 mCacheFill = fillLevel; 476 // handle cache fill update 477 if (mCacheFill - mLastNotifiedCacheFill >= mCacheFillNotifThreshold) { 478 notifyCacheFill(); 479 } 480 // handle prefetch status update 481 // compute how much time ahead of position is buffered 482 int durationMsec, positionMsec = -1; 483 if ((mStateFlags & kFlagPrepared) && (mPlayer != 0) 484 && (OK == mPlayer->getDuration(&durationMsec)) 485 && (OK == mPlayer->getCurrentPosition(&positionMsec))) { 486 if ((-1 != durationMsec) && (-1 != positionMsec)) { 487 // evaluate prefetch status based on buffer time thresholds 488 int64_t bufferedDurationMsec = (durationMsec * fillLevel / 100) - positionMsec; 489 CacheStatus_t newCacheStatus = mCacheStatus; 490 if (bufferedDurationMsec > DURATION_CACHED_HIGH_MS) { 491 newCacheStatus = kStatusHigh; 492 } else if (bufferedDurationMsec > DURATION_CACHED_MED_MS) { 493 newCacheStatus = kStatusEnough; 494 } else if (bufferedDurationMsec > DURATION_CACHED_LOW_MS) { 495 newCacheStatus = kStatusIntermediate; 496 } else if (bufferedDurationMsec == 0) { 497 newCacheStatus = kStatusEmpty; 498 } else { 499 newCacheStatus = kStatusLow; 500 } 501 502 if (newCacheStatus != mCacheStatus) { 503 mCacheStatus = newCacheStatus; 504 notifyStatus(); 505 } 506 } 507 } 508 } else { 509 SL_LOGV("GenericMediaPlayer::onBufferingUpdate(fillLevel=unknown)"); 510 } 511} 512 513 514//-------------------------------------------------- 515/** 516 * called from GenericMediaPlayer::onPrepare after the MediaPlayer mPlayer is prepared successfully 517 * pre-conditions: 518 * mPlayer != 0 519 * mPlayer is prepared successfully 520 */ 521void GenericMediaPlayer::afterMediaPlayerPreparedSuccessfully() { 522 SL_LOGV("GenericMediaPlayer::afterMediaPlayerPrepared()"); 523 assert(mPlayer != 0); 524 assert(mStateFlags & kFlagPrepared); 525 // Mark this player as prepared successfully, so safe to directly call getCurrentPosition 526 { 527 Mutex::Autolock _l(mPreparedPlayerLock); 528 assert(mPreparedPlayer == 0); 529 mPreparedPlayer = mPlayer; 530 } 531 // retrieve channel count 532 int32_t channelCount; 533 Parcel *reply = new Parcel(); 534 status_t status = mPlayer->getParameter(KEY_PARAMETER_AUDIO_CHANNEL_COUNT, reply); 535 if (status == NO_ERROR) { 536 channelCount = reply->readInt32(); 537 } else { 538 // FIXME MPEG-2 TS doesn't yet implement this key, so default to stereo 539 channelCount = 2; 540 } 541 if (UNKNOWN_NUMCHANNELS != channelCount) { 542 // now that we know the channel count, re-calculate the volumes 543 notify(PLAYEREVENT_CHANNEL_COUNT, channelCount, true /*async*/); 544 } else { 545 ALOGW("channel count is still unknown after prepare"); 546 } 547 delete reply; 548 // retrieve duration 549 { 550 int msec = 0; 551 if (OK == mPlayer->getDuration(&msec)) { 552 Mutex::Autolock _l(mSettingsLock); 553 mDurationMsec = msec; 554 } 555 } 556 // now that we have a MediaPlayer, set the looping flag 557 if (mStateFlags & kFlagLooping) { 558 (void) mPlayer->setLooping(1); 559 } 560 // when the MediaPlayer mPlayer is prepared, there is "sufficient data" in the playback buffers 561 // if the data source was local, and the buffers are considered full so we need to notify that 562 bool isLocalSource = true; 563 if (kDataLocatorUri == mDataLocatorType) { 564 isLocalSource = !isDistantProtocol(mDataLocator.uriRef); 565 } 566 if (isLocalSource) { 567 SL_LOGD("media player prepared on local source"); 568 { 569 Mutex::Autolock _l(mSettingsLock); 570 mCacheStatus = kStatusHigh; 571 mCacheFill = 1000; 572 notifyStatus(); 573 notifyCacheFill(); 574 } 575 } else { 576 SL_LOGD("media player prepared on non-local source"); 577 } 578} 579 580 581//-------------------------------------------------- 582// If player is prepared successfully, set output parameter to that reference, otherwise NULL 583void GenericMediaPlayer::getPreparedPlayer(sp<IMediaPlayer> &preparedPlayer) 584{ 585 Mutex::Autolock _l(mPreparedPlayerLock); 586 preparedPlayer = mPreparedPlayer; 587} 588 589} // namespace android 590