Glenn Kasten | 99e53b8 | 2012-01-19 08:59:58 -0800 | [diff] [blame] | 1 | /* |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2 | ** |
| 3 | ** Copyright 2006, The Android Open Source Project |
| 4 | ** |
| 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | ** you may not use this file except in compliance with the License. |
| 7 | ** You may obtain a copy of the License at |
| 8 | ** |
| 9 | ** http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | ** |
| 11 | ** Unless required by applicable law or agreed to in writing, software |
| 12 | ** distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | ** See the License for the specific language governing permissions and |
| 15 | ** limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | //#define LOG_NDEBUG 0 |
| 19 | #define LOG_TAG "MediaPlayer" |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 20 | |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 21 | #include <fcntl.h> |
Mark Salyzyn | 34fb296 | 2014-06-18 16:30:56 -0700 | [diff] [blame] | 22 | #include <inttypes.h> |
| 23 | #include <sys/stat.h> |
| 24 | #include <sys/types.h> |
| 25 | #include <unistd.h> |
| 26 | |
| 27 | #include <utils/Log.h> |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 28 | |
Mathias Agopian | 7562408 | 2009-05-19 19:08:10 -0700 | [diff] [blame] | 29 | #include <binder/IServiceManager.h> |
| 30 | #include <binder/IPCThreadState.h> |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 31 | |
Mathias Agopian | b1e7cd1 | 2013-02-14 17:11:27 -0800 | [diff] [blame] | 32 | #include <gui/Surface.h> |
Jamie Gennis | 61c7ef5 | 2011-07-13 12:59:34 -0700 | [diff] [blame] | 33 | |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 34 | #include <media/mediaplayer.h> |
Glenn Kasten | a3f1fa3 | 2012-01-18 14:54:46 -0800 | [diff] [blame] | 35 | #include <media/AudioSystem.h> |
Chris Watkins | 99f3160 | 2015-03-20 13:06:33 -0700 | [diff] [blame] | 36 | #include <media/IDataSource.h> |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 37 | |
Mathias Agopian | 7562408 | 2009-05-19 19:08:10 -0700 | [diff] [blame] | 38 | #include <binder/MemoryBase.h> |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 39 | |
Andreas Huber | 2db8455 | 2010-01-28 11:19:57 -0800 | [diff] [blame] | 40 | #include <utils/KeyedVector.h> |
| 41 | #include <utils/String8.h> |
| 42 | |
Dima Zavin | 6476024 | 2011-05-11 14:15:23 -0700 | [diff] [blame] | 43 | #include <system/audio.h> |
Jamie Gennis | 61c7ef5 | 2011-07-13 12:59:34 -0700 | [diff] [blame] | 44 | #include <system/window.h> |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 45 | |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 46 | namespace android { |
| 47 | |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 48 | MediaPlayer::MediaPlayer() |
| 49 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 50 | ALOGV("constructor"); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 51 | mListener = NULL; |
| 52 | mCookie = NULL; |
Dima Zavin | fce7a47 | 2011-04-19 22:30:36 -0700 | [diff] [blame] | 53 | mStreamType = AUDIO_STREAM_MUSIC; |
Jean-Michel Trivi | 640adb3 | 2014-09-05 11:20:11 -0700 | [diff] [blame] | 54 | mAudioAttributesParcel = NULL; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 55 | mCurrentPosition = -1; |
| 56 | mSeekPosition = -1; |
| 57 | mCurrentState = MEDIA_PLAYER_IDLE; |
| 58 | mPrepareSync = false; |
| 59 | mPrepareStatus = NO_ERROR; |
| 60 | mLoop = false; |
| 61 | mLeftVolume = mRightVolume = 1.0; |
| 62 | mVideoWidth = mVideoHeight = 0; |
Wei Jia | 9816016 | 2015-02-04 17:01:11 -0800 | [diff] [blame] | 63 | mPlaybackRate = 1.0; |
Jason Sams | 1af452f | 2009-03-24 18:45:22 -0700 | [diff] [blame] | 64 | mLockThreadId = 0; |
Eric Laurent | de3f839 | 2014-07-27 18:38:22 -0700 | [diff] [blame] | 65 | mAudioSessionId = AudioSystem::newAudioUniqueId(); |
Marco Nelissen | d457c97 | 2014-02-11 08:47:07 -0800 | [diff] [blame] | 66 | AudioSystem::acquireAudioSessionId(mAudioSessionId, -1); |
Eric Laurent | 8c563ed | 2010-10-07 18:23:03 -0700 | [diff] [blame] | 67 | mSendLevel = 0; |
John Grossman | c795b64 | 2012-02-22 15:38:35 -0800 | [diff] [blame] | 68 | mRetransmitEndpointValid = false; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 69 | } |
| 70 | |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 71 | MediaPlayer::~MediaPlayer() |
| 72 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 73 | ALOGV("destructor"); |
Jean-Michel Trivi | 640adb3 | 2014-09-05 11:20:11 -0700 | [diff] [blame] | 74 | if (mAudioAttributesParcel != NULL) { |
| 75 | delete mAudioAttributesParcel; |
| 76 | mAudioAttributesParcel = NULL; |
| 77 | } |
Marco Nelissen | d457c97 | 2014-02-11 08:47:07 -0800 | [diff] [blame] | 78 | AudioSystem::releaseAudioSessionId(mAudioSessionId, -1); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 79 | disconnect(); |
| 80 | IPCThreadState::self()->flushCommands(); |
| 81 | } |
| 82 | |
| 83 | void MediaPlayer::disconnect() |
| 84 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 85 | ALOGV("disconnect"); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 86 | sp<IMediaPlayer> p; |
| 87 | { |
| 88 | Mutex::Autolock _l(mLock); |
| 89 | p = mPlayer; |
| 90 | mPlayer.clear(); |
| 91 | } |
| 92 | |
| 93 | if (p != 0) { |
| 94 | p->disconnect(); |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | // always call with lock held |
| 99 | void MediaPlayer::clear_l() |
| 100 | { |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 101 | mCurrentPosition = -1; |
| 102 | mSeekPosition = -1; |
| 103 | mVideoWidth = mVideoHeight = 0; |
John Grossman | c795b64 | 2012-02-22 15:38:35 -0800 | [diff] [blame] | 104 | mRetransmitEndpointValid = false; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | status_t MediaPlayer::setListener(const sp<MediaPlayerListener>& listener) |
| 108 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 109 | ALOGV("setListener"); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 110 | Mutex::Autolock _l(mLock); |
| 111 | mListener = listener; |
| 112 | return NO_ERROR; |
| 113 | } |
| 114 | |
| 115 | |
Dave Burke | d681bbb | 2011-08-30 14:39:17 +0100 | [diff] [blame] | 116 | status_t MediaPlayer::attachNewPlayer(const sp<IMediaPlayer>& player) |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 117 | { |
| 118 | status_t err = UNKNOWN_ERROR; |
| 119 | sp<IMediaPlayer> p; |
| 120 | { // scope for the lock |
| 121 | Mutex::Autolock _l(mLock); |
| 122 | |
Marco Nelissen | 83ff143 | 2010-03-10 10:53:16 -0800 | [diff] [blame] | 123 | if ( !( (mCurrentState & MEDIA_PLAYER_IDLE) || |
| 124 | (mCurrentState == MEDIA_PLAYER_STATE_ERROR ) ) ) { |
Steve Block | 29357bc | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 125 | ALOGE("attachNewPlayer called in state %d", mCurrentState); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 126 | return INVALID_OPERATION; |
| 127 | } |
| 128 | |
| 129 | clear_l(); |
| 130 | p = mPlayer; |
| 131 | mPlayer = player; |
| 132 | if (player != 0) { |
| 133 | mCurrentState = MEDIA_PLAYER_INITIALIZED; |
| 134 | err = NO_ERROR; |
| 135 | } else { |
Masaki Muranaka | f65fa17 | 2013-06-06 09:36:34 +0000 | [diff] [blame] | 136 | ALOGE("Unable to create media player"); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 137 | } |
| 138 | } |
| 139 | |
| 140 | if (p != 0) { |
| 141 | p->disconnect(); |
| 142 | } |
| 143 | |
| 144 | return err; |
| 145 | } |
| 146 | |
Andreas Huber | 2db8455 | 2010-01-28 11:19:57 -0800 | [diff] [blame] | 147 | status_t MediaPlayer::setDataSource( |
Andreas Huber | 1b86fe0 | 2014-01-29 11:13:26 -0800 | [diff] [blame] | 148 | const sp<IMediaHTTPService> &httpService, |
Andreas Huber | 2db8455 | 2010-01-28 11:19:57 -0800 | [diff] [blame] | 149 | const char *url, const KeyedVector<String8, String8> *headers) |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 150 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 151 | ALOGV("setDataSource(%s)", url); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 152 | status_t err = BAD_VALUE; |
| 153 | if (url != NULL) { |
| 154 | const sp<IMediaPlayerService>& service(getMediaPlayerService()); |
| 155 | if (service != 0) { |
Glenn Kasten | f37971f | 2012-02-03 11:06:53 -0800 | [diff] [blame] | 156 | sp<IMediaPlayer> player(service->create(this, mAudioSessionId)); |
John Grossman | c795b64 | 2012-02-22 15:38:35 -0800 | [diff] [blame] | 157 | if ((NO_ERROR != doSetRetransmitEndpoint(player)) || |
Andreas Huber | 1b86fe0 | 2014-01-29 11:13:26 -0800 | [diff] [blame] | 158 | (NO_ERROR != player->setDataSource(httpService, url, headers))) { |
Dave Burke | 0662067 | 2011-09-06 20:39:47 +0100 | [diff] [blame] | 159 | player.clear(); |
Dave Burke | d681bbb | 2011-08-30 14:39:17 +0100 | [diff] [blame] | 160 | } |
Dave Burke | 0662067 | 2011-09-06 20:39:47 +0100 | [diff] [blame] | 161 | err = attachNewPlayer(player); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 162 | } |
| 163 | } |
| 164 | return err; |
| 165 | } |
| 166 | |
| 167 | status_t MediaPlayer::setDataSource(int fd, int64_t offset, int64_t length) |
| 168 | { |
Mark Salyzyn | 34fb296 | 2014-06-18 16:30:56 -0700 | [diff] [blame] | 169 | ALOGV("setDataSource(%d, %" PRId64 ", %" PRId64 ")", fd, offset, length); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 170 | status_t err = UNKNOWN_ERROR; |
| 171 | const sp<IMediaPlayerService>& service(getMediaPlayerService()); |
| 172 | if (service != 0) { |
Glenn Kasten | f37971f | 2012-02-03 11:06:53 -0800 | [diff] [blame] | 173 | sp<IMediaPlayer> player(service->create(this, mAudioSessionId)); |
John Grossman | c795b64 | 2012-02-22 15:38:35 -0800 | [diff] [blame] | 174 | if ((NO_ERROR != doSetRetransmitEndpoint(player)) || |
| 175 | (NO_ERROR != player->setDataSource(fd, offset, length))) { |
Dave Burke | 0662067 | 2011-09-06 20:39:47 +0100 | [diff] [blame] | 176 | player.clear(); |
Dave Burke | d681bbb | 2011-08-30 14:39:17 +0100 | [diff] [blame] | 177 | } |
Dave Burke | 0662067 | 2011-09-06 20:39:47 +0100 | [diff] [blame] | 178 | err = attachNewPlayer(player); |
Dave Burke | d681bbb | 2011-08-30 14:39:17 +0100 | [diff] [blame] | 179 | } |
| 180 | return err; |
| 181 | } |
| 182 | |
| 183 | status_t MediaPlayer::setDataSource(const sp<IStreamSource> &source) |
| 184 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 185 | ALOGV("setDataSource"); |
Dave Burke | d681bbb | 2011-08-30 14:39:17 +0100 | [diff] [blame] | 186 | status_t err = UNKNOWN_ERROR; |
| 187 | const sp<IMediaPlayerService>& service(getMediaPlayerService()); |
| 188 | if (service != 0) { |
Glenn Kasten | f37971f | 2012-02-03 11:06:53 -0800 | [diff] [blame] | 189 | sp<IMediaPlayer> player(service->create(this, mAudioSessionId)); |
John Grossman | c795b64 | 2012-02-22 15:38:35 -0800 | [diff] [blame] | 190 | if ((NO_ERROR != doSetRetransmitEndpoint(player)) || |
| 191 | (NO_ERROR != player->setDataSource(source))) { |
Dave Burke | 0662067 | 2011-09-06 20:39:47 +0100 | [diff] [blame] | 192 | player.clear(); |
Dave Burke | d681bbb | 2011-08-30 14:39:17 +0100 | [diff] [blame] | 193 | } |
Dave Burke | 0662067 | 2011-09-06 20:39:47 +0100 | [diff] [blame] | 194 | err = attachNewPlayer(player); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 195 | } |
| 196 | return err; |
| 197 | } |
| 198 | |
Chris Watkins | 99f3160 | 2015-03-20 13:06:33 -0700 | [diff] [blame] | 199 | status_t MediaPlayer::setDataSource(const sp<IDataSource> &source) |
| 200 | { |
| 201 | ALOGV("setDataSource(IDataSource)"); |
| 202 | status_t err = UNKNOWN_ERROR; |
| 203 | const sp<IMediaPlayerService>& service(getMediaPlayerService()); |
| 204 | if (service != 0) { |
| 205 | sp<IMediaPlayer> player(service->create(this, mAudioSessionId)); |
| 206 | if ((NO_ERROR != doSetRetransmitEndpoint(player)) || |
| 207 | (NO_ERROR != player->setDataSource(source))) { |
| 208 | player.clear(); |
| 209 | } |
| 210 | err = attachNewPlayer(player); |
| 211 | } |
| 212 | return err; |
| 213 | } |
| 214 | |
Nicolas Catania | 1d187f1 | 2009-05-12 23:25:55 -0700 | [diff] [blame] | 215 | status_t MediaPlayer::invoke(const Parcel& request, Parcel *reply) |
| 216 | { |
| 217 | Mutex::Autolock _l(mLock); |
Nicolas Catania | 4023493 | 2010-03-10 10:41:04 -0800 | [diff] [blame] | 218 | const bool hasBeenInitialized = |
| 219 | (mCurrentState != MEDIA_PLAYER_STATE_ERROR) && |
| 220 | ((mCurrentState & MEDIA_PLAYER_IDLE) != MEDIA_PLAYER_IDLE); |
| 221 | if ((mPlayer != NULL) && hasBeenInitialized) { |
Mark Salyzyn | 34fb296 | 2014-06-18 16:30:56 -0700 | [diff] [blame] | 222 | ALOGV("invoke %zu", request.dataSize()); |
Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 223 | return mPlayer->invoke(request, reply); |
Nicolas Catania | 1d187f1 | 2009-05-12 23:25:55 -0700 | [diff] [blame] | 224 | } |
Steve Block | 29357bc | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 225 | ALOGE("invoke failed: wrong state %X", mCurrentState); |
Nicolas Catania | 1d187f1 | 2009-05-12 23:25:55 -0700 | [diff] [blame] | 226 | return INVALID_OPERATION; |
| 227 | } |
| 228 | |
Nicolas Catania | a7e0e8b | 2009-07-08 08:57:42 -0700 | [diff] [blame] | 229 | status_t MediaPlayer::setMetadataFilter(const Parcel& filter) |
| 230 | { |
Steve Block | b8a8052 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 231 | ALOGD("setMetadataFilter"); |
Nicolas Catania | 8e1b6cc | 2009-07-09 09:21:33 -0700 | [diff] [blame] | 232 | Mutex::Autolock lock(mLock); |
| 233 | if (mPlayer == NULL) { |
Nicolas Catania | a7e0e8b | 2009-07-08 08:57:42 -0700 | [diff] [blame] | 234 | return NO_INIT; |
| 235 | } |
| 236 | return mPlayer->setMetadataFilter(filter); |
| 237 | } |
Nicolas Catania | 1d187f1 | 2009-05-12 23:25:55 -0700 | [diff] [blame] | 238 | |
Nicolas Catania | 8e1b6cc | 2009-07-09 09:21:33 -0700 | [diff] [blame] | 239 | status_t MediaPlayer::getMetadata(bool update_only, bool apply_filter, Parcel *metadata) |
| 240 | { |
Steve Block | b8a8052 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 241 | ALOGD("getMetadata"); |
Nicolas Catania | 8e1b6cc | 2009-07-09 09:21:33 -0700 | [diff] [blame] | 242 | Mutex::Autolock lock(mLock); |
| 243 | if (mPlayer == NULL) { |
| 244 | return NO_INIT; |
| 245 | } |
| 246 | return mPlayer->getMetadata(update_only, apply_filter, metadata); |
| 247 | } |
| 248 | |
Glenn Kasten | 1173118 | 2011-02-08 17:26:17 -0800 | [diff] [blame] | 249 | status_t MediaPlayer::setVideoSurfaceTexture( |
Andy McFadden | 484566c | 2012-12-18 09:46:54 -0800 | [diff] [blame] | 250 | const sp<IGraphicBufferProducer>& bufferProducer) |
Glenn Kasten | 1173118 | 2011-02-08 17:26:17 -0800 | [diff] [blame] | 251 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 252 | ALOGV("setVideoSurfaceTexture"); |
Glenn Kasten | 1173118 | 2011-02-08 17:26:17 -0800 | [diff] [blame] | 253 | Mutex::Autolock _l(mLock); |
| 254 | if (mPlayer == 0) return NO_INIT; |
Andy McFadden | 484566c | 2012-12-18 09:46:54 -0800 | [diff] [blame] | 255 | return mPlayer->setVideoSurfaceTexture(bufferProducer); |
Glenn Kasten | 1173118 | 2011-02-08 17:26:17 -0800 | [diff] [blame] | 256 | } |
| 257 | |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 258 | // must call with lock held |
| 259 | status_t MediaPlayer::prepareAsync_l() |
| 260 | { |
Glenn Kasten | b187de1 | 2014-12-30 08:18:15 -0800 | [diff] [blame] | 261 | if ( (mPlayer != 0) && ( mCurrentState & (MEDIA_PLAYER_INITIALIZED | MEDIA_PLAYER_STOPPED) ) ) { |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 262 | mPlayer->setAudioStreamType(mStreamType); |
Jean-Michel Trivi | 640adb3 | 2014-09-05 11:20:11 -0700 | [diff] [blame] | 263 | if (mAudioAttributesParcel != NULL) { |
| 264 | mPlayer->setParameter(KEY_PARAMETER_AUDIO_ATTRIBUTES, *mAudioAttributesParcel); |
| 265 | } |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 266 | mCurrentState = MEDIA_PLAYER_PREPARING; |
| 267 | return mPlayer->prepareAsync(); |
| 268 | } |
Steve Block | 29357bc | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 269 | ALOGE("prepareAsync called in state %d", mCurrentState); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 270 | return INVALID_OPERATION; |
| 271 | } |
| 272 | |
The Android Open Source Project | 65e731f | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 273 | // TODO: In case of error, prepareAsync provides the caller with 2 error codes, |
| 274 | // one defined in the Android framework and one provided by the implementation |
| 275 | // that generated the error. The sync version of prepare returns only 1 error |
| 276 | // code. |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 277 | status_t MediaPlayer::prepare() |
| 278 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 279 | ALOGV("prepare"); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 280 | Mutex::Autolock _l(mLock); |
Jason Sams | 1af452f | 2009-03-24 18:45:22 -0700 | [diff] [blame] | 281 | mLockThreadId = getThreadId(); |
| 282 | if (mPrepareSync) { |
| 283 | mLockThreadId = 0; |
| 284 | return -EALREADY; |
| 285 | } |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 286 | mPrepareSync = true; |
| 287 | status_t ret = prepareAsync_l(); |
Jason Sams | 1af452f | 2009-03-24 18:45:22 -0700 | [diff] [blame] | 288 | if (ret != NO_ERROR) { |
| 289 | mLockThreadId = 0; |
| 290 | return ret; |
| 291 | } |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 292 | |
| 293 | if (mPrepareSync) { |
| 294 | mSignal.wait(mLock); // wait for prepare done |
| 295 | mPrepareSync = false; |
| 296 | } |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 297 | ALOGV("prepare complete - status=%d", mPrepareStatus); |
Jason Sams | 1af452f | 2009-03-24 18:45:22 -0700 | [diff] [blame] | 298 | mLockThreadId = 0; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 299 | return mPrepareStatus; |
| 300 | } |
| 301 | |
| 302 | status_t MediaPlayer::prepareAsync() |
| 303 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 304 | ALOGV("prepareAsync"); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 305 | Mutex::Autolock _l(mLock); |
| 306 | return prepareAsync_l(); |
| 307 | } |
| 308 | |
| 309 | status_t MediaPlayer::start() |
| 310 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 311 | ALOGV("start"); |
Chong Zhang | d88adb9 | 2014-07-23 11:43:46 -0700 | [diff] [blame] | 312 | |
| 313 | status_t ret = NO_ERROR; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 314 | Mutex::Autolock _l(mLock); |
Chong Zhang | d88adb9 | 2014-07-23 11:43:46 -0700 | [diff] [blame] | 315 | |
| 316 | mLockThreadId = getThreadId(); |
| 317 | |
| 318 | if (mCurrentState & MEDIA_PLAYER_STARTED) { |
| 319 | ret = NO_ERROR; |
| 320 | } else if ( (mPlayer != 0) && ( mCurrentState & ( MEDIA_PLAYER_PREPARED | |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 321 | MEDIA_PLAYER_PLAYBACK_COMPLETE | MEDIA_PLAYER_PAUSED ) ) ) { |
| 322 | mPlayer->setLooping(mLoop); |
| 323 | mPlayer->setVolume(mLeftVolume, mRightVolume); |
Eric Laurent | 2beeb50 | 2010-07-16 07:43:46 -0700 | [diff] [blame] | 324 | mPlayer->setAuxEffectSendLevel(mSendLevel); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 325 | mCurrentState = MEDIA_PLAYER_STARTED; |
Chong Zhang | d88adb9 | 2014-07-23 11:43:46 -0700 | [diff] [blame] | 326 | ret = mPlayer->start(); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 327 | if (ret != NO_ERROR) { |
| 328 | mCurrentState = MEDIA_PLAYER_STATE_ERROR; |
| 329 | } else { |
| 330 | if (mCurrentState == MEDIA_PLAYER_PLAYBACK_COMPLETE) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 331 | ALOGV("playback completed immediately following start()"); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 332 | } |
| 333 | } |
Chong Zhang | d88adb9 | 2014-07-23 11:43:46 -0700 | [diff] [blame] | 334 | } else { |
| 335 | ALOGE("start called in state %d", mCurrentState); |
| 336 | ret = INVALID_OPERATION; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 337 | } |
Chong Zhang | d88adb9 | 2014-07-23 11:43:46 -0700 | [diff] [blame] | 338 | |
| 339 | mLockThreadId = 0; |
| 340 | |
| 341 | return ret; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 342 | } |
| 343 | |
| 344 | status_t MediaPlayer::stop() |
| 345 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 346 | ALOGV("stop"); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 347 | Mutex::Autolock _l(mLock); |
| 348 | if (mCurrentState & MEDIA_PLAYER_STOPPED) return NO_ERROR; |
| 349 | if ( (mPlayer != 0) && ( mCurrentState & ( MEDIA_PLAYER_STARTED | MEDIA_PLAYER_PREPARED | |
| 350 | MEDIA_PLAYER_PAUSED | MEDIA_PLAYER_PLAYBACK_COMPLETE ) ) ) { |
| 351 | status_t ret = mPlayer->stop(); |
| 352 | if (ret != NO_ERROR) { |
| 353 | mCurrentState = MEDIA_PLAYER_STATE_ERROR; |
| 354 | } else { |
| 355 | mCurrentState = MEDIA_PLAYER_STOPPED; |
| 356 | } |
| 357 | return ret; |
| 358 | } |
Steve Block | 29357bc | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 359 | ALOGE("stop called in state %d", mCurrentState); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 360 | return INVALID_OPERATION; |
| 361 | } |
| 362 | |
| 363 | status_t MediaPlayer::pause() |
| 364 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 365 | ALOGV("pause"); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 366 | Mutex::Autolock _l(mLock); |
Marco Nelissen | 698f476 | 2010-02-26 13:16:23 -0800 | [diff] [blame] | 367 | if (mCurrentState & (MEDIA_PLAYER_PAUSED|MEDIA_PLAYER_PLAYBACK_COMPLETE)) |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 368 | return NO_ERROR; |
| 369 | if ((mPlayer != 0) && (mCurrentState & MEDIA_PLAYER_STARTED)) { |
| 370 | status_t ret = mPlayer->pause(); |
| 371 | if (ret != NO_ERROR) { |
| 372 | mCurrentState = MEDIA_PLAYER_STATE_ERROR; |
| 373 | } else { |
| 374 | mCurrentState = MEDIA_PLAYER_PAUSED; |
| 375 | } |
| 376 | return ret; |
| 377 | } |
Steve Block | 29357bc | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 378 | ALOGE("pause called in state %d", mCurrentState); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 379 | return INVALID_OPERATION; |
| 380 | } |
| 381 | |
| 382 | bool MediaPlayer::isPlaying() |
| 383 | { |
| 384 | Mutex::Autolock _l(mLock); |
| 385 | if (mPlayer != 0) { |
| 386 | bool temp = false; |
| 387 | mPlayer->isPlaying(&temp); |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 388 | ALOGV("isPlaying: %d", temp); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 389 | if ((mCurrentState & MEDIA_PLAYER_STARTED) && ! temp) { |
Steve Block | 29357bc | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 390 | ALOGE("internal/external state mismatch corrected"); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 391 | mCurrentState = MEDIA_PLAYER_PAUSED; |
| 392 | } |
| 393 | return temp; |
| 394 | } |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 395 | ALOGV("isPlaying: no active player"); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 396 | return false; |
| 397 | } |
| 398 | |
Wei Jia | 9816016 | 2015-02-04 17:01:11 -0800 | [diff] [blame] | 399 | status_t MediaPlayer::setPlaybackRate(float rate) |
| 400 | { |
| 401 | ALOGV("setPlaybackRate: %f", rate); |
| 402 | if (rate <= 0.0) { |
| 403 | return BAD_VALUE; |
| 404 | } |
| 405 | Mutex::Autolock _l(mLock); |
| 406 | if (mPlayer != 0) { |
| 407 | if (mPlaybackRate == rate) { |
| 408 | return NO_ERROR; |
| 409 | } |
| 410 | mPlaybackRate = rate; |
| 411 | return mPlayer->setPlaybackRate(rate); |
| 412 | } |
| 413 | ALOGV("setPlaybackRate: no active player"); |
| 414 | return INVALID_OPERATION; |
| 415 | } |
| 416 | |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 417 | status_t MediaPlayer::getVideoWidth(int *w) |
| 418 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 419 | ALOGV("getVideoWidth"); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 420 | Mutex::Autolock _l(mLock); |
| 421 | if (mPlayer == 0) return INVALID_OPERATION; |
| 422 | *w = mVideoWidth; |
| 423 | return NO_ERROR; |
| 424 | } |
| 425 | |
| 426 | status_t MediaPlayer::getVideoHeight(int *h) |
| 427 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 428 | ALOGV("getVideoHeight"); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 429 | Mutex::Autolock _l(mLock); |
| 430 | if (mPlayer == 0) return INVALID_OPERATION; |
| 431 | *h = mVideoHeight; |
| 432 | return NO_ERROR; |
| 433 | } |
| 434 | |
| 435 | status_t MediaPlayer::getCurrentPosition(int *msec) |
| 436 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 437 | ALOGV("getCurrentPosition"); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 438 | Mutex::Autolock _l(mLock); |
| 439 | if (mPlayer != 0) { |
| 440 | if (mCurrentPosition >= 0) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 441 | ALOGV("Using cached seek position: %d", mCurrentPosition); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 442 | *msec = mCurrentPosition; |
| 443 | return NO_ERROR; |
| 444 | } |
| 445 | return mPlayer->getCurrentPosition(msec); |
| 446 | } |
| 447 | return INVALID_OPERATION; |
| 448 | } |
| 449 | |
| 450 | status_t MediaPlayer::getDuration_l(int *msec) |
| 451 | { |
Andreas Huber | a4c5bc0 | 2012-11-27 15:02:53 -0800 | [diff] [blame] | 452 | ALOGV("getDuration_l"); |
Glenn Kasten | b187de1 | 2014-12-30 08:18:15 -0800 | [diff] [blame] | 453 | bool isValidState = (mCurrentState & (MEDIA_PLAYER_PREPARED | MEDIA_PLAYER_STARTED | |
| 454 | MEDIA_PLAYER_PAUSED | MEDIA_PLAYER_STOPPED | MEDIA_PLAYER_PLAYBACK_COMPLETE)); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 455 | if (mPlayer != 0 && isValidState) { |
Andreas Huber | a4c5bc0 | 2012-11-27 15:02:53 -0800 | [diff] [blame] | 456 | int durationMs; |
| 457 | status_t ret = mPlayer->getDuration(&durationMs); |
Andreas Huber | 2070254 | 2013-04-11 11:07:55 -0700 | [diff] [blame] | 458 | |
| 459 | if (ret != OK) { |
| 460 | // Do not enter error state just because no duration was available. |
| 461 | durationMs = -1; |
| 462 | ret = OK; |
| 463 | } |
| 464 | |
Andreas Huber | a4c5bc0 | 2012-11-27 15:02:53 -0800 | [diff] [blame] | 465 | if (msec) { |
| 466 | *msec = durationMs; |
| 467 | } |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 468 | return ret; |
| 469 | } |
Steve Block | 29357bc | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 470 | ALOGE("Attempt to call getDuration without a valid mediaplayer"); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 471 | return INVALID_OPERATION; |
| 472 | } |
| 473 | |
| 474 | status_t MediaPlayer::getDuration(int *msec) |
| 475 | { |
| 476 | Mutex::Autolock _l(mLock); |
| 477 | return getDuration_l(msec); |
| 478 | } |
| 479 | |
| 480 | status_t MediaPlayer::seekTo_l(int msec) |
| 481 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 482 | ALOGV("seekTo %d", msec); |
Glenn Kasten | b187de1 | 2014-12-30 08:18:15 -0800 | [diff] [blame] | 483 | if ((mPlayer != 0) && ( mCurrentState & ( MEDIA_PLAYER_STARTED | MEDIA_PLAYER_PREPARED | |
| 484 | MEDIA_PLAYER_PAUSED | MEDIA_PLAYER_PLAYBACK_COMPLETE) ) ) { |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 485 | if ( msec < 0 ) { |
Steve Block | 5ff1dd5 | 2012-01-05 23:22:43 +0000 | [diff] [blame] | 486 | ALOGW("Attempt to seek to invalid position: %d", msec); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 487 | msec = 0; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 488 | } |
Andreas Huber | a4c5bc0 | 2012-11-27 15:02:53 -0800 | [diff] [blame] | 489 | |
| 490 | int durationMs; |
| 491 | status_t err = mPlayer->getDuration(&durationMs); |
| 492 | |
| 493 | if (err != OK) { |
| 494 | ALOGW("Stream has no duration and is therefore not seekable."); |
| 495 | return err; |
| 496 | } |
| 497 | |
| 498 | if (msec > durationMs) { |
| 499 | ALOGW("Attempt to seek to past end of file: request = %d, " |
| 500 | "durationMs = %d", |
| 501 | msec, |
| 502 | durationMs); |
| 503 | |
| 504 | msec = durationMs; |
| 505 | } |
| 506 | |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 507 | // cache duration |
| 508 | mCurrentPosition = msec; |
| 509 | if (mSeekPosition < 0) { |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 510 | mSeekPosition = msec; |
| 511 | return mPlayer->seekTo(msec); |
| 512 | } |
| 513 | else { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 514 | ALOGV("Seek in progress - queue up seekTo[%d]", msec); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 515 | return NO_ERROR; |
| 516 | } |
| 517 | } |
Glenn Kasten | b187de1 | 2014-12-30 08:18:15 -0800 | [diff] [blame] | 518 | ALOGE("Attempt to perform seekTo in wrong state: mPlayer=%p, mCurrentState=%u", mPlayer.get(), |
| 519 | mCurrentState); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 520 | return INVALID_OPERATION; |
| 521 | } |
| 522 | |
| 523 | status_t MediaPlayer::seekTo(int msec) |
| 524 | { |
Andreas Huber | 5cb07aa | 2009-03-24 20:48:51 -0700 | [diff] [blame] | 525 | mLockThreadId = getThreadId(); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 526 | Mutex::Autolock _l(mLock); |
Andreas Huber | 5cb07aa | 2009-03-24 20:48:51 -0700 | [diff] [blame] | 527 | status_t result = seekTo_l(msec); |
| 528 | mLockThreadId = 0; |
| 529 | |
| 530 | return result; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 531 | } |
| 532 | |
Jamie Gennis | 61c7ef5 | 2011-07-13 12:59:34 -0700 | [diff] [blame] | 533 | status_t MediaPlayer::reset_l() |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 534 | { |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 535 | mLoop = false; |
| 536 | if (mCurrentState == MEDIA_PLAYER_IDLE) return NO_ERROR; |
| 537 | mPrepareSync = false; |
| 538 | if (mPlayer != 0) { |
| 539 | status_t ret = mPlayer->reset(); |
| 540 | if (ret != NO_ERROR) { |
Steve Block | 29357bc | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 541 | ALOGE("reset() failed with return code (%d)", ret); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 542 | mCurrentState = MEDIA_PLAYER_STATE_ERROR; |
| 543 | } else { |
| 544 | mCurrentState = MEDIA_PLAYER_IDLE; |
| 545 | } |
James Dong | a1680bc | 2010-11-18 12:23:58 -0800 | [diff] [blame] | 546 | // setDataSource has to be called again to create a |
| 547 | // new mediaplayer. |
| 548 | mPlayer = 0; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 549 | return ret; |
| 550 | } |
| 551 | clear_l(); |
| 552 | return NO_ERROR; |
| 553 | } |
| 554 | |
John Grossman | c795b64 | 2012-02-22 15:38:35 -0800 | [diff] [blame] | 555 | status_t MediaPlayer::doSetRetransmitEndpoint(const sp<IMediaPlayer>& player) { |
| 556 | Mutex::Autolock _l(mLock); |
| 557 | |
| 558 | if (player == NULL) { |
| 559 | return UNKNOWN_ERROR; |
| 560 | } |
| 561 | |
| 562 | if (mRetransmitEndpointValid) { |
| 563 | return player->setRetransmitEndpoint(&mRetransmitEndpoint); |
| 564 | } |
| 565 | |
| 566 | return OK; |
| 567 | } |
| 568 | |
Jamie Gennis | 61c7ef5 | 2011-07-13 12:59:34 -0700 | [diff] [blame] | 569 | status_t MediaPlayer::reset() |
| 570 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 571 | ALOGV("reset"); |
Jamie Gennis | 61c7ef5 | 2011-07-13 12:59:34 -0700 | [diff] [blame] | 572 | Mutex::Autolock _l(mLock); |
| 573 | return reset_l(); |
| 574 | } |
| 575 | |
Glenn Kasten | fff6d71 | 2012-01-12 16:38:12 -0800 | [diff] [blame] | 576 | status_t MediaPlayer::setAudioStreamType(audio_stream_type_t type) |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 577 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 578 | ALOGV("MediaPlayer::setAudioStreamType"); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 579 | Mutex::Autolock _l(mLock); |
| 580 | if (mStreamType == type) return NO_ERROR; |
| 581 | if (mCurrentState & ( MEDIA_PLAYER_PREPARED | MEDIA_PLAYER_STARTED | |
| 582 | MEDIA_PLAYER_PAUSED | MEDIA_PLAYER_PLAYBACK_COMPLETE ) ) { |
| 583 | // Can't change the stream type after prepare |
Steve Block | 29357bc | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 584 | ALOGE("setAudioStream called in state %d", mCurrentState); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 585 | return INVALID_OPERATION; |
| 586 | } |
| 587 | // cache |
| 588 | mStreamType = type; |
| 589 | return OK; |
| 590 | } |
| 591 | |
John Spurlock | de9453f | 2014-03-19 13:05:45 -0400 | [diff] [blame] | 592 | status_t MediaPlayer::getAudioStreamType(audio_stream_type_t *type) |
| 593 | { |
| 594 | ALOGV("getAudioStreamType"); |
| 595 | Mutex::Autolock _l(mLock); |
| 596 | *type = mStreamType; |
| 597 | return OK; |
| 598 | } |
| 599 | |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 600 | status_t MediaPlayer::setLooping(int loop) |
| 601 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 602 | ALOGV("MediaPlayer::setLooping"); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 603 | Mutex::Autolock _l(mLock); |
| 604 | mLoop = (loop != 0); |
| 605 | if (mPlayer != 0) { |
| 606 | return mPlayer->setLooping(loop); |
| 607 | } |
| 608 | return OK; |
| 609 | } |
| 610 | |
| 611 | bool MediaPlayer::isLooping() { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 612 | ALOGV("isLooping"); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 613 | Mutex::Autolock _l(mLock); |
| 614 | if (mPlayer != 0) { |
| 615 | return mLoop; |
| 616 | } |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 617 | ALOGV("isLooping: no active player"); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 618 | return false; |
| 619 | } |
| 620 | |
| 621 | status_t MediaPlayer::setVolume(float leftVolume, float rightVolume) |
| 622 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 623 | ALOGV("MediaPlayer::setVolume(%f, %f)", leftVolume, rightVolume); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 624 | Mutex::Autolock _l(mLock); |
| 625 | mLeftVolume = leftVolume; |
| 626 | mRightVolume = rightVolume; |
| 627 | if (mPlayer != 0) { |
| 628 | return mPlayer->setVolume(leftVolume, rightVolume); |
| 629 | } |
| 630 | return OK; |
| 631 | } |
| 632 | |
Eric Laurent | a514bdb | 2010-06-21 09:27:30 -0700 | [diff] [blame] | 633 | status_t MediaPlayer::setAudioSessionId(int sessionId) |
| 634 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 635 | ALOGV("MediaPlayer::setAudioSessionId(%d)", sessionId); |
Eric Laurent | a514bdb | 2010-06-21 09:27:30 -0700 | [diff] [blame] | 636 | Mutex::Autolock _l(mLock); |
| 637 | if (!(mCurrentState & MEDIA_PLAYER_IDLE)) { |
Steve Block | 29357bc | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 638 | ALOGE("setAudioSessionId called in state %d", mCurrentState); |
Eric Laurent | a514bdb | 2010-06-21 09:27:30 -0700 | [diff] [blame] | 639 | return INVALID_OPERATION; |
| 640 | } |
| 641 | if (sessionId < 0) { |
| 642 | return BAD_VALUE; |
| 643 | } |
Marco Nelissen | 3a34bef | 2011-08-02 13:33:41 -0700 | [diff] [blame] | 644 | if (sessionId != mAudioSessionId) { |
Marco Nelissen | d457c97 | 2014-02-11 08:47:07 -0800 | [diff] [blame] | 645 | AudioSystem::acquireAudioSessionId(sessionId, -1); |
| 646 | AudioSystem::releaseAudioSessionId(mAudioSessionId, -1); |
Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 647 | mAudioSessionId = sessionId; |
Marco Nelissen | 3a34bef | 2011-08-02 13:33:41 -0700 | [diff] [blame] | 648 | } |
Eric Laurent | a514bdb | 2010-06-21 09:27:30 -0700 | [diff] [blame] | 649 | return NO_ERROR; |
| 650 | } |
| 651 | |
| 652 | int MediaPlayer::getAudioSessionId() |
| 653 | { |
| 654 | Mutex::Autolock _l(mLock); |
| 655 | return mAudioSessionId; |
| 656 | } |
| 657 | |
Eric Laurent | 2beeb50 | 2010-07-16 07:43:46 -0700 | [diff] [blame] | 658 | status_t MediaPlayer::setAuxEffectSendLevel(float level) |
| 659 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 660 | ALOGV("MediaPlayer::setAuxEffectSendLevel(%f)", level); |
Eric Laurent | 2beeb50 | 2010-07-16 07:43:46 -0700 | [diff] [blame] | 661 | Mutex::Autolock _l(mLock); |
| 662 | mSendLevel = level; |
| 663 | if (mPlayer != 0) { |
| 664 | return mPlayer->setAuxEffectSendLevel(level); |
| 665 | } |
| 666 | return OK; |
| 667 | } |
| 668 | |
| 669 | status_t MediaPlayer::attachAuxEffect(int effectId) |
| 670 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 671 | ALOGV("MediaPlayer::attachAuxEffect(%d)", effectId); |
Eric Laurent | 2beeb50 | 2010-07-16 07:43:46 -0700 | [diff] [blame] | 672 | Mutex::Autolock _l(mLock); |
| 673 | if (mPlayer == 0 || |
| 674 | (mCurrentState & MEDIA_PLAYER_IDLE) || |
| 675 | (mCurrentState == MEDIA_PLAYER_STATE_ERROR )) { |
Steve Block | 29357bc | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 676 | ALOGE("attachAuxEffect called in state %d", mCurrentState); |
Eric Laurent | 2beeb50 | 2010-07-16 07:43:46 -0700 | [diff] [blame] | 677 | return INVALID_OPERATION; |
| 678 | } |
| 679 | |
| 680 | return mPlayer->attachAuxEffect(effectId); |
| 681 | } |
| 682 | |
Jean-Michel Trivi | d9d7fa0 | 2014-06-24 08:01:46 -0700 | [diff] [blame] | 683 | // always call with lock held |
| 684 | status_t MediaPlayer::checkStateForKeySet_l(int key) |
| 685 | { |
| 686 | switch(key) { |
| 687 | case KEY_PARAMETER_AUDIO_ATTRIBUTES: |
| 688 | if (mCurrentState & ( MEDIA_PLAYER_PREPARED | MEDIA_PLAYER_STARTED | |
| 689 | MEDIA_PLAYER_PAUSED | MEDIA_PLAYER_PLAYBACK_COMPLETE) ) { |
| 690 | // Can't change the audio attributes after prepare |
| 691 | ALOGE("trying to set audio attributes called in state %d", mCurrentState); |
| 692 | return INVALID_OPERATION; |
| 693 | } |
| 694 | break; |
| 695 | default: |
| 696 | // parameter doesn't require player state check |
| 697 | break; |
| 698 | } |
| 699 | return OK; |
| 700 | } |
| 701 | |
Gloria Wang | 4f9e47f | 2011-04-25 17:28:22 -0700 | [diff] [blame] | 702 | status_t MediaPlayer::setParameter(int key, const Parcel& request) |
| 703 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 704 | ALOGV("MediaPlayer::setParameter(%d)", key); |
Gloria Wang | 4f9e47f | 2011-04-25 17:28:22 -0700 | [diff] [blame] | 705 | Mutex::Autolock _l(mLock); |
Jean-Michel Trivi | d9d7fa0 | 2014-06-24 08:01:46 -0700 | [diff] [blame] | 706 | if (checkStateForKeySet_l(key) != OK) { |
| 707 | return INVALID_OPERATION; |
| 708 | } |
Gloria Wang | 4f9e47f | 2011-04-25 17:28:22 -0700 | [diff] [blame] | 709 | if (mPlayer != NULL) { |
| 710 | return mPlayer->setParameter(key, request); |
| 711 | } |
Jean-Michel Trivi | 640adb3 | 2014-09-05 11:20:11 -0700 | [diff] [blame] | 712 | switch (key) { |
| 713 | case KEY_PARAMETER_AUDIO_ATTRIBUTES: |
| 714 | // no player, save the marshalled audio attributes |
| 715 | if (mAudioAttributesParcel != NULL) { delete mAudioAttributesParcel; }; |
| 716 | mAudioAttributesParcel = new Parcel(); |
| 717 | mAudioAttributesParcel->appendFrom(&request, 0, request.dataSize()); |
| 718 | return OK; |
| 719 | default: |
| 720 | ALOGV("setParameter: no active player"); |
| 721 | return INVALID_OPERATION; |
| 722 | } |
Gloria Wang | 4f9e47f | 2011-04-25 17:28:22 -0700 | [diff] [blame] | 723 | } |
| 724 | |
| 725 | status_t MediaPlayer::getParameter(int key, Parcel *reply) |
| 726 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 727 | ALOGV("MediaPlayer::getParameter(%d)", key); |
Gloria Wang | 4f9e47f | 2011-04-25 17:28:22 -0700 | [diff] [blame] | 728 | Mutex::Autolock _l(mLock); |
| 729 | if (mPlayer != NULL) { |
Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 730 | return mPlayer->getParameter(key, reply); |
Gloria Wang | 4f9e47f | 2011-04-25 17:28:22 -0700 | [diff] [blame] | 731 | } |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 732 | ALOGV("getParameter: no active player"); |
Gloria Wang | 4f9e47f | 2011-04-25 17:28:22 -0700 | [diff] [blame] | 733 | return INVALID_OPERATION; |
| 734 | } |
| 735 | |
John Grossman | c795b64 | 2012-02-22 15:38:35 -0800 | [diff] [blame] | 736 | status_t MediaPlayer::setRetransmitEndpoint(const char* addrString, |
| 737 | uint16_t port) { |
| 738 | ALOGV("MediaPlayer::setRetransmitEndpoint(%s:%hu)", |
| 739 | addrString ? addrString : "(null)", port); |
| 740 | |
| 741 | Mutex::Autolock _l(mLock); |
| 742 | if ((mPlayer != NULL) || (mCurrentState != MEDIA_PLAYER_IDLE)) |
| 743 | return INVALID_OPERATION; |
| 744 | |
| 745 | if (NULL == addrString) { |
| 746 | mRetransmitEndpointValid = false; |
| 747 | return OK; |
| 748 | } |
| 749 | |
| 750 | struct in_addr saddr; |
| 751 | if(!inet_aton(addrString, &saddr)) { |
| 752 | return BAD_VALUE; |
| 753 | } |
| 754 | |
Glenn Kasten | be08f6a | 2013-12-19 09:09:33 -0800 | [diff] [blame] | 755 | memset(&mRetransmitEndpoint, 0, sizeof(mRetransmitEndpoint)); |
John Grossman | c795b64 | 2012-02-22 15:38:35 -0800 | [diff] [blame] | 756 | mRetransmitEndpoint.sin_family = AF_INET; |
| 757 | mRetransmitEndpoint.sin_addr = saddr; |
| 758 | mRetransmitEndpoint.sin_port = htons(port); |
| 759 | mRetransmitEndpointValid = true; |
| 760 | |
| 761 | return OK; |
| 762 | } |
| 763 | |
Gloria Wang | b483c47 | 2011-04-11 17:23:27 -0700 | [diff] [blame] | 764 | void MediaPlayer::notify(int msg, int ext1, int ext2, const Parcel *obj) |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 765 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 766 | ALOGV("message received msg=%d, ext1=%d, ext2=%d", msg, ext1, ext2); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 767 | bool send = true; |
Jason Sams | 1af452f | 2009-03-24 18:45:22 -0700 | [diff] [blame] | 768 | bool locked = false; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 769 | |
| 770 | // TODO: In the future, we might be on the same thread if the app is |
| 771 | // running in the same process as the media server. In that case, |
| 772 | // this will deadlock. |
Nicolas Catania | 6609518 | 2009-06-11 16:33:49 -0700 | [diff] [blame] | 773 | // |
Chong Zhang | d88adb9 | 2014-07-23 11:43:46 -0700 | [diff] [blame] | 774 | // The threadId hack below works around this for the care of prepare, |
| 775 | // seekTo and start within the same process. |
Andreas Huber | 5cb07aa | 2009-03-24 20:48:51 -0700 | [diff] [blame] | 776 | // FIXME: Remember, this is a hack, it's not even a hack that is applied |
| 777 | // consistently for all use-cases, this needs to be revisited. |
Glenn Kasten | e53b9ea | 2012-03-12 16:29:55 -0700 | [diff] [blame] | 778 | if (mLockThreadId != getThreadId()) { |
Jason Sams | 1af452f | 2009-03-24 18:45:22 -0700 | [diff] [blame] | 779 | mLock.lock(); |
| 780 | locked = true; |
Nicolas Catania | 6609518 | 2009-06-11 16:33:49 -0700 | [diff] [blame] | 781 | } |
Jason Sams | 1af452f | 2009-03-24 18:45:22 -0700 | [diff] [blame] | 782 | |
Eric Laurent | 3b26844 | 2010-08-03 07:49:49 -0700 | [diff] [blame] | 783 | // Allows calls from JNI in idle state to notify errors |
| 784 | if (!(msg == MEDIA_ERROR && mCurrentState == MEDIA_PLAYER_IDLE) && mPlayer == 0) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 785 | ALOGV("notify(%d, %d, %d) callback on disconnected mediaplayer", msg, ext1, ext2); |
Jason Sams | 1af452f | 2009-03-24 18:45:22 -0700 | [diff] [blame] | 786 | if (locked) mLock.unlock(); // release the lock when done. |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 787 | return; |
| 788 | } |
| 789 | |
| 790 | switch (msg) { |
| 791 | case MEDIA_NOP: // interface test message |
| 792 | break; |
| 793 | case MEDIA_PREPARED: |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 794 | ALOGV("prepared"); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 795 | mCurrentState = MEDIA_PLAYER_PREPARED; |
| 796 | if (mPrepareSync) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 797 | ALOGV("signal application thread"); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 798 | mPrepareSync = false; |
| 799 | mPrepareStatus = NO_ERROR; |
| 800 | mSignal.signal(); |
| 801 | } |
| 802 | break; |
| 803 | case MEDIA_PLAYBACK_COMPLETE: |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 804 | ALOGV("playback complete"); |
Marco Nelissen | 1c1503c | 2010-09-17 15:04:01 -0700 | [diff] [blame] | 805 | if (mCurrentState == MEDIA_PLAYER_IDLE) { |
Steve Block | 29357bc | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 806 | ALOGE("playback complete in idle state"); |
Marco Nelissen | 1c1503c | 2010-09-17 15:04:01 -0700 | [diff] [blame] | 807 | } |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 808 | if (!mLoop) { |
| 809 | mCurrentState = MEDIA_PLAYER_PLAYBACK_COMPLETE; |
| 810 | } |
| 811 | break; |
| 812 | case MEDIA_ERROR: |
The Android Open Source Project | 65e731f | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 813 | // Always log errors. |
| 814 | // ext1: Media framework error code. |
| 815 | // ext2: Implementation dependant error code. |
Steve Block | 29357bc | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 816 | ALOGE("error (%d, %d)", ext1, ext2); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 817 | mCurrentState = MEDIA_PLAYER_STATE_ERROR; |
| 818 | if (mPrepareSync) |
| 819 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 820 | ALOGV("signal application thread"); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 821 | mPrepareSync = false; |
| 822 | mPrepareStatus = ext1; |
| 823 | mSignal.signal(); |
| 824 | send = false; |
| 825 | } |
| 826 | break; |
The Android Open Source Project | 65e731f | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 827 | case MEDIA_INFO: |
| 828 | // ext1: Media framework error code. |
| 829 | // ext2: Implementation dependant error code. |
Andreas Huber | 145e68f | 2011-01-11 15:05:28 -0800 | [diff] [blame] | 830 | if (ext1 != MEDIA_INFO_VIDEO_TRACK_LAGGING) { |
Steve Block | 5ff1dd5 | 2012-01-05 23:22:43 +0000 | [diff] [blame] | 831 | ALOGW("info/warning (%d, %d)", ext1, ext2); |
Andreas Huber | 145e68f | 2011-01-11 15:05:28 -0800 | [diff] [blame] | 832 | } |
The Android Open Source Project | 65e731f | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 833 | break; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 834 | case MEDIA_SEEK_COMPLETE: |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 835 | ALOGV("Received seek complete"); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 836 | if (mSeekPosition != mCurrentPosition) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 837 | ALOGV("Executing queued seekTo(%d)", mSeekPosition); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 838 | mSeekPosition = -1; |
| 839 | seekTo_l(mCurrentPosition); |
| 840 | } |
| 841 | else { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 842 | ALOGV("All seeks complete - return to regularly scheduled program"); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 843 | mCurrentPosition = mSeekPosition = -1; |
| 844 | } |
| 845 | break; |
| 846 | case MEDIA_BUFFERING_UPDATE: |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 847 | ALOGV("buffering %d", ext1); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 848 | break; |
| 849 | case MEDIA_SET_VIDEO_SIZE: |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 850 | ALOGV("New video size %d x %d", ext1, ext2); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 851 | mVideoWidth = ext1; |
| 852 | mVideoHeight = ext2; |
| 853 | break; |
Gloria Wang | b483c47 | 2011-04-11 17:23:27 -0700 | [diff] [blame] | 854 | case MEDIA_TIMED_TEXT: |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 855 | ALOGV("Received timed text message"); |
Gloria Wang | b483c47 | 2011-04-11 17:23:27 -0700 | [diff] [blame] | 856 | break; |
Chong Zhang | dcb89b3 | 2013-08-06 09:44:47 -0700 | [diff] [blame] | 857 | case MEDIA_SUBTITLE_DATA: |
| 858 | ALOGV("Received subtitle data message"); |
| 859 | break; |
Robert Shih | 0852843 | 2015-04-08 09:06:54 -0700 | [diff] [blame^] | 860 | case MEDIA_META_DATA: |
| 861 | ALOGV("Received timed metadata message"); |
| 862 | break; |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 863 | default: |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 864 | ALOGV("unrecognized message: (%d, %d, %d)", msg, ext1, ext2); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 865 | break; |
| 866 | } |
| 867 | |
| 868 | sp<MediaPlayerListener> listener = mListener; |
Jason Sams | 1af452f | 2009-03-24 18:45:22 -0700 | [diff] [blame] | 869 | if (locked) mLock.unlock(); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 870 | |
| 871 | // this prevents re-entrant calls into client code |
| 872 | if ((listener != 0) && send) { |
| 873 | Mutex::Autolock _l(mNotifyLock); |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 874 | ALOGV("callback application"); |
Gloria Wang | b483c47 | 2011-04-11 17:23:27 -0700 | [diff] [blame] | 875 | listener->notify(msg, ext1, ext2, obj); |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 876 | ALOGV("back from callback"); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 877 | } |
| 878 | } |
| 879 | |
James Dong | dd172fc | 2010-01-15 18:13:58 -0800 | [diff] [blame] | 880 | void MediaPlayer::died() |
| 881 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 882 | ALOGV("died"); |
James Dong | dd172fc | 2010-01-15 18:13:58 -0800 | [diff] [blame] | 883 | notify(MEDIA_ERROR, MEDIA_ERROR_SERVER_DIED, 0); |
| 884 | } |
| 885 | |
Marco Nelissen | 6b74d67 | 2012-02-28 16:07:44 -0800 | [diff] [blame] | 886 | status_t MediaPlayer::setNextMediaPlayer(const sp<MediaPlayer>& next) { |
| 887 | if (mPlayer == NULL) { |
| 888 | return NO_INIT; |
| 889 | } |
Marco Nelissen | b13820f | 2013-08-05 12:22:43 -0700 | [diff] [blame] | 890 | |
| 891 | if (next != NULL && !(next->mCurrentState & |
| 892 | (MEDIA_PLAYER_PREPARED | MEDIA_PLAYER_PAUSED | MEDIA_PLAYER_PLAYBACK_COMPLETE))) { |
| 893 | ALOGE("next player is not prepared"); |
| 894 | return INVALID_OPERATION; |
| 895 | } |
| 896 | |
Marco Nelissen | 6b74d67 | 2012-02-28 16:07:44 -0800 | [diff] [blame] | 897 | return mPlayer->setNextPlayer(next == NULL ? NULL : next->mPlayer); |
| 898 | } |
| 899 | |
Glenn Kasten | 40bc906 | 2015-03-20 09:09:33 -0700 | [diff] [blame] | 900 | } // namespace android |