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