android_GenericPlayer.cpp revision 8ad101d5bcaca289da3d820e2b87b5da55e560f9
1dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi/* 2dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi * Copyright (C) 2011 The Android Open Source Project 3dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi * 4dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi * Licensed under the Apache License, Version 2.0 (the "License"); 5dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi * you may not use this file except in compliance with the License. 6dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi * You may obtain a copy of the License at 7dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi * 8dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi * http://www.apache.org/licenses/LICENSE-2.0 9dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi * 10dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi * Unless required by applicable law or agreed to in writing, software 11dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi * distributed under the License is distributed on an "AS IS" BASIS, 12dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi * See the License for the specific language governing permissions and 14dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi * limitations under the License. 15dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi */ 16dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 17dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi//#define USE_LOG SLAndroidLogLevel_Verbose 18dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 19dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi#include "sles_allinclusive.h" 20dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 218ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi#include <media/stagefright/foundation/ADebug.h> 228ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi#include <sys/stat.h> 238ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi 24dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivinamespace android { 25dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 26dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi//-------------------------------------------------------------------------------------------------- 27dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel TriviGenericPlayer::GenericPlayer(const AudioPlayback_Parameters* params) : 28dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi mDataLocatorType(kDataLocatorNone), 29dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi mNotifyClient(NULL), 30dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi mNotifyUser(NULL), 31dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi mStateFlags(0), 32dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi mLooperPriority(PRIORITY_DEFAULT), 33fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi mPlaybackParams(*params), 348ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi mChannelCount(1), 358ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi mDurationMsec(ANDROID_UNKNOWN_TIME), 368ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi mPositionMsec(ANDROID_UNKNOWN_TIME), 378ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi mCacheStatus(kStatusEmpty), 388ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi mCacheFill(0), 398ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi mLastNotifiedCacheFill(0), 408ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi mCacheFillNotifThreshold(100) 41dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi{ 4230ebe675beff91283cc72d4ee5e94e56ab7e107fJean-Michel Trivi SL_LOGD("GenericPlayer::GenericPlayer()"); 43dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 44dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi mLooper = new android::ALooper(); 45dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 46fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi mAndroidAudioLevels.mMute = false; 47fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi mAndroidAudioLevels.mFinalVolume[0] = 1.0f; 48fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi mAndroidAudioLevels.mFinalVolume[1] = 1.0f; 49dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi} 50dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 51dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 52dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel TriviGenericPlayer::~GenericPlayer() { 53dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi SL_LOGI("GenericPlayer::~GenericPlayer()"); 54dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 55dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi mLooper->stop(); 56dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi mLooper->unregisterHandler(id()); 57dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi mLooper.clear(); 58dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 59dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi} 60dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 61dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 62dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivivoid GenericPlayer::init(const notif_cbf_t cbf, void* notifUser) { 6330ebe675beff91283cc72d4ee5e94e56ab7e107fJean-Michel Trivi SL_LOGD("GenericPlayer::init()"); 64dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 65dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi mNotifyClient = cbf; 66dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi mNotifyUser = notifUser; 67dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 68dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi mLooper->registerHandler(this); 69dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi mLooper->start(false /*runOnCallingThread*/, false /*canCallJava*/, mLooperPriority); 70dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi} 71dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 72dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 73dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivivoid GenericPlayer::setDataSource(const char *uri) { 74dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi resetDataLocator(); 75dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 76dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi mDataLocator.uriRef = uri; 77dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 78dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi mDataLocatorType = kDataLocatorUri; 79dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi} 80dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 81dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 82dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivivoid GenericPlayer::setDataSource(int fd, int64_t offset, int64_t length) { 83dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi resetDataLocator(); 84dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 85dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi mDataLocator.fdi.fd = fd; 86dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 87dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi struct stat sb; 88dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi int ret = fstat(fd, &sb); 89dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi if (ret != 0) { 90dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi SL_LOGE("GenericPlayer::setDataSource: fstat(%d) failed: %d, %s", fd, ret, strerror(errno)); 91dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi return; 92dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi } 93dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 94dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi if (offset >= sb.st_size) { 95dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi SL_LOGE("SfPlayer::setDataSource: invalid offset"); 96dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi return; 97dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi } 98dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi mDataLocator.fdi.offset = offset; 99dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 100dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi if (PLAYER_FD_FIND_FILE_SIZE == length) { 101dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi mDataLocator.fdi.length = sb.st_size; 102dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi } else if (offset + length > sb.st_size) { 103dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi mDataLocator.fdi.length = sb.st_size - offset; 104dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi } else { 105dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi mDataLocator.fdi.length = length; 106dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi } 107dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 108dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi mDataLocatorType = kDataLocatorFd; 109dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi} 110dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 111dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 112dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivivoid GenericPlayer::prepare() { 11330ebe675beff91283cc72d4ee5e94e56ab7e107fJean-Michel Trivi SL_LOGD("GenericPlayer::prepare()"); 114dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi sp<AMessage> msg = new AMessage(kWhatPrepare, id()); 115dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi msg->post(); 116dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi} 117dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 118dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 119dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivivoid GenericPlayer::play() { 12030ebe675beff91283cc72d4ee5e94e56ab7e107fJean-Michel Trivi SL_LOGD("GenericPlayer::play()"); 121dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi sp<AMessage> msg = new AMessage(kWhatPlay, id()); 122dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi msg->post(); 123dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi} 124dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 125dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 126dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivivoid GenericPlayer::pause() { 12730ebe675beff91283cc72d4ee5e94e56ab7e107fJean-Michel Trivi SL_LOGD("GenericPlayer::pause()"); 128dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi sp<AMessage> msg = new AMessage(kWhatPause, id()); 129dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi msg->post(); 130dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi} 131dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 132dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 133dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivivoid GenericPlayer::stop() { 13430ebe675beff91283cc72d4ee5e94e56ab7e107fJean-Michel Trivi SL_LOGD("GenericPlayer::stop()"); 135dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi (new AMessage(kWhatPause, id()))->post(); 136dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 137dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi // after a stop, playback should resume from the start. 138dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi seek(0); 139dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi} 140dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 141dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 142dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivivoid GenericPlayer::seek(int64_t timeMsec) { 143dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi SL_LOGV("GenericPlayer::seek %lld", timeMsec); 144dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi sp<AMessage> msg = new AMessage(kWhatSeek, id()); 145dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi msg->setInt64(WHATPARAM_SEEK_SEEKTIME_MS, timeMsec); 146dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi msg->post(); 147dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi} 148dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 149dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 150dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivivoid GenericPlayer::loop(bool loop) { 151dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi sp<AMessage> msg = new AMessage(kWhatLoop, id()); 152dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi msg->setInt32(WHATPARAM_LOOP_LOOPING, (int32_t)loop); 153dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi msg->post(); 154dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi} 155dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 156dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 1578ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivivoid GenericPlayer::setBufferingUpdateThreshold(int16_t thresholdPercent) { 1588ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi sp<AMessage> msg = new AMessage(kWhatBuffUpdateThres, id()); 1598ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi msg->setInt32(WHATPARAM_BUFFERING_UPDATETHRESHOLD_PERCENT, (int32_t)thresholdPercent); 1608ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi msg->post(); 1618ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi} 1628ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi 1638ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi 164dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi//-------------------------------------------------- 1655b21a0626e173d407aa3835e5cffcaa9b582016dJean-Michel Trivivoid GenericPlayer::getDurationMsec(int* msec) { 1668ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi *msec = mDurationMsec; 1678ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi} 1688ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi 1698ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivivoid GenericPlayer::getPositionMsec(int* msec) { 1708ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi *msec = mPositionMsec; 1715b21a0626e173d407aa3835e5cffcaa9b582016dJean-Michel Trivi} 1725b21a0626e173d407aa3835e5cffcaa9b582016dJean-Michel Trivi 173fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi//-------------------------------------------------- 1748ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivivoid GenericPlayer::setVolume(bool mute, bool useStereoPos, 175fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi XApermille stereoPos, XAmillibel volume) { 176fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi 177fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi // compute amplification as the combination of volume level and stereo position 178fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi float leftVol = 1.0f, rightVol = 1.0f; 179fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi // amplification from volume level 180fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi leftVol *= sles_to_android_amplification(volume); 181fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi rightVol = leftVol; 182fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi 183fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi // amplification from direct level (changed in SLEffectSendtItf and SLAndroidEffectSendItf) 184fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi // FIXME use calculation below when supporting effects 185fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi //leftVol *= mAndroidAudioLevels.mAmplFromDirectLevel; 186fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi //rightVol *= mAndroidAudioLevels.mAmplFromDirectLevel; 187fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi 188fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi // amplification from stereo position 189fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi if (useStereoPos) { 190fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi // panning law depends on number of channels of content: stereo panning vs 2ch. balance 191fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi if (1 == mChannelCount) { 192fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi // stereo panning 193fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi double theta = (1000 + stereoPos) * M_PI_4 / 1000.0f; // 0 <= theta <= Pi/2 194fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi leftVol *= cos(theta); 195fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi rightVol *= sin(theta); 196fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi } else { 197fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi // stereo balance 198fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi if (stereoPos > 0) { 199fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi leftVol *= (1000 - stereoPos) / 1000.0f; 200fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi rightVol *= 1.0f; 201fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi } else { 202fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi leftVol *= 1.0f; 203fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi rightVol *= (1000 + stereoPos) / 1000.0f; 204fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi } 205fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi } 206fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi } 207fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi 208fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi { 209fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi Mutex::Autolock _l(mSettingsLock); 210fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi mAndroidAudioLevels.mMute = mute; 211fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi mAndroidAudioLevels.mFinalVolume[0] = leftVol; 212fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi mAndroidAudioLevels.mFinalVolume[1] = rightVol; 213fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi } 214fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi 215fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi // send a message for the volume to be updated by the object which implements the volume 216fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi (new AMessage(kWhatVolumeUpdate, id()))->post(); 217fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi} 218fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi 2195b21a0626e173d407aa3835e5cffcaa9b582016dJean-Michel Trivi 2205b21a0626e173d407aa3835e5cffcaa9b582016dJean-Michel Trivi//-------------------------------------------------- 221dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi/* 222dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi * post-condition: mDataLocatorType == kDataLocatorNone 223dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi * 224dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi */ 225dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivivoid GenericPlayer::resetDataLocator() { 226dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi mDataLocatorType = kDataLocatorNone; 227dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi} 228dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 229dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 230dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivivoid GenericPlayer::notify(const char* event, int data, bool async) { 231dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi sp<AMessage> msg = new AMessage(kWhatNotif, id()); 232dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi msg->setInt32(event, (int32_t)data); 233dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi if (async) { 234dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi msg->post(); 235dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi } else { 236dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi this->onNotify(msg); 237dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi } 238dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi} 239dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 240dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 241fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivivoid GenericPlayer::notify(const char* event, int data1, int data2, bool async) { 242fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi sp<AMessage> msg = new AMessage(kWhatNotif, id()); 243fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi msg->setRect(event, 0, 0, (int32_t)data1, (int32_t)data2); 244fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi if (async) { 245fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi msg->post(); 246fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi } else { 247fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi this->onNotify(msg); 248fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi } 249fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi} 250fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi 251fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi 252dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi//-------------------------------------------------- 253dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi// AHandler implementation 254dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivivoid GenericPlayer::onMessageReceived(const sp<AMessage> &msg) { 255dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi switch (msg->what()) { 256dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi case kWhatPrepare: 257dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi onPrepare(); 258dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi break; 259dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 260dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi case kWhatNotif: 261dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi onNotify(msg); 262dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi break; 263dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 264dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi case kWhatPlay: 265dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi onPlay(); 266dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi break; 267dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 268dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi case kWhatPause: 269dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi onPause(); 270dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi break; 271dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 272dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi case kWhatSeek: 273dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi onSeek(msg); 274dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi break; 275dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 276dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi case kWhatLoop: 277dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi onLoop(msg); 278dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi break; 279dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 280fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi case kWhatVolumeUpdate: 281fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi onVolumeUpdate(); 282fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi break; 283fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi 2848ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi case kWhatSeekComplete: 2858ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi onSeekComplete(); 2868ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi break; 2878ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi 2888ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi case kWhatBufferingUpdate: 2898ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi onBufferingUpdate(msg); 2908ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi break; 2918ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi 2928ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi case kWhatBuffUpdateThres: 2938ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi onSetBufferingUpdateThreshold(msg); 2948ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi break; 2958ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi 296dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi default: 297dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi TRESPASS(); 298dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi } 299dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi} 300dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 301dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 302dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi//-------------------------------------------------- 303dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi// Event handlers 3048ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi// it is strictly verboten to call those methods outside of the event loop 3058ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi 306dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivivoid GenericPlayer::onPrepare() { 30730ebe675beff91283cc72d4ee5e94e56ab7e107fJean-Michel Trivi SL_LOGD("GenericPlayer::onPrepare()"); 308dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi if (!(mStateFlags & kFlagPrepared)) { 309dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi mStateFlags |= kFlagPrepared; 310dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi notify(PLAYEREVENT_PREPARED, PLAYER_SUCCESS, false /*async*/); 311dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi } 31230ebe675beff91283cc72d4ee5e94e56ab7e107fJean-Michel Trivi SL_LOGD("GenericPlayer::onPrepare() done, mStateFlags=0x%x", mStateFlags); 313dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi} 314dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 315dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 316dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivivoid GenericPlayer::onNotify(const sp<AMessage> &msg) { 317dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi if (NULL == mNotifyClient) { 318dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi return; 319dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi } 320dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 321fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi int32_t val1, val2; 3228ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi if (msg->findInt32(PLAYEREVENT_PREFETCHSTATUSCHANGE, &val1)) { 3238ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi SL_LOGV("GenericPlayer notifying %s = %d", PLAYEREVENT_PREFETCHSTATUSCHANGE, val1); 3248ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi mNotifyClient(kEventPrefetchStatusChange, val1, 0, mNotifyUser); 3258ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi } else if (msg->findInt32(PLAYEREVENT_PREFETCHFILLLEVELUPDATE, &val1)) { 3268ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi SL_LOGV("GenericPlayer notifying %s = %d", PLAYEREVENT_PREFETCHFILLLEVELUPDATE, val1); 3278ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi mNotifyClient(kEventPrefetchFillLevelUpdate, val1, 0, mNotifyUser); 3288ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi } else if (msg->findInt32(PLAYEREVENT_ENDOFSTREAM, &val1)) { 3298ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi SL_LOGV("GenericPlayer notifying %s = %d", PLAYEREVENT_ENDOFSTREAM, val1); 3308ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi mNotifyClient(kEventEndOfStream, val1, 0, mNotifyUser); 3318ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi } else if (msg->findInt32(PLAYEREVENT_PREPARED, &val1)) { 332fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi SL_LOGV("GenericPlayer notifying %s = %d", PLAYEREVENT_PREPARED, val1); 333fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi mNotifyClient(kEventPrepared, val1, 0, mNotifyUser); 334fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi } else if (msg->findRect(PLAYEREVENT_VIDEO_SIZE_UPDATE, &val1, &val2, &val1, &val2)) { 3358ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi SL_LOGV("GenericPlayer notifying %s = %d, %d", PLAYEREVENT_VIDEO_SIZE_UPDATE, val1, val2); 336fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi mNotifyClient(kEventHasVideoSize, val1, val2, mNotifyUser); 337dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi } 338dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi} 339dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 340dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 341dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivivoid GenericPlayer::onPlay() { 34230ebe675beff91283cc72d4ee5e94e56ab7e107fJean-Michel Trivi SL_LOGD("GenericPlayer::onPlay()"); 343dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi if ((mStateFlags & kFlagPrepared)) { 34430ebe675beff91283cc72d4ee5e94e56ab7e107fJean-Michel Trivi SL_LOGD("starting player"); 345dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi mStateFlags |= kFlagPlaying; 346dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi } else { 347dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi SL_LOGV("NOT starting player mStateFlags=0x%x", mStateFlags); 348dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi } 349dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi} 350dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 351dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 352dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivivoid GenericPlayer::onPause() { 35330ebe675beff91283cc72d4ee5e94e56ab7e107fJean-Michel Trivi SL_LOGD("GenericPlayer::onPause()"); 354dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi if ((mStateFlags & kFlagPrepared)) { 355dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi mStateFlags &= ~kFlagPlaying; 356dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi } 357dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi} 358dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 359dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 360dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivivoid GenericPlayer::onSeek(const sp<AMessage> &msg) { 361dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi SL_LOGV("GenericPlayer::onSeek"); 362dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi} 363dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 364dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 365dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivivoid GenericPlayer::onLoop(const sp<AMessage> &msg) { 366dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi SL_LOGV("GenericPlayer::onLoop"); 367dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi} 368dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi 369fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi 370fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivivoid GenericPlayer::onVolumeUpdate() { 371fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi 372fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi} 373fcc996296bdbf6c3949ad4312991fdde4ae2e157Jean-Michel Trivi 3748ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi 3758ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivivoid GenericPlayer::onSeekComplete() { 3768ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi SL_LOGD("GenericPlayer::onSeekComplete()"); 3778ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi mStateFlags &= ~kFlagSeeking; 3788ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi} 3798ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi 3808ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi 3818ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivivoid GenericPlayer::onBufferingUpdate(const sp<AMessage> &msg) { 3828ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi 3838ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi} 3848ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi 3858ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi 3868ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivivoid GenericPlayer::onSetBufferingUpdateThreshold(const sp<AMessage> &msg) { 3878ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi int32_t thresholdPercent = 0; 3888ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi if (msg->findInt32(WHATPARAM_BUFFERING_UPDATETHRESHOLD_PERCENT, &thresholdPercent)) { 3898ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi Mutex::Autolock _l(mSettingsLock); 3908ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi mCacheFillNotifThreshold = (int16_t)thresholdPercent; 3918ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi } 3928ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi} 3938ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi 3948ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi 3958ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi//------------------------------------------------- 3968ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivivoid GenericPlayer::notifyStatus() { 3978ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi notify(PLAYEREVENT_PREFETCHSTATUSCHANGE, (int32_t)mCacheStatus, true /*async*/); 3988ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi} 3998ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi 4008ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi 4018ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivivoid GenericPlayer::notifyCacheFill() { 4028ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi mLastNotifiedCacheFill = mCacheFill; 4038ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi notify(PLAYEREVENT_PREFETCHFILLLEVELUPDATE, (int32_t)mLastNotifiedCacheFill, true/*async*/); 4048ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi} 4058ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi 4068ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi 4078ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivivoid GenericPlayer::seekComplete() { 4088ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi sp<AMessage> msg = new AMessage(kWhatSeekComplete, id()); 4098ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi msg->post(); 4108ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi} 4118ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi 4128ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi 4138ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivivoid GenericPlayer::bufferingUpdate(int16_t fillLevelPerMille) { 4148ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi sp<AMessage> msg = new AMessage(kWhatBufferingUpdate, id()); 4158ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi msg->setInt32(WHATPARAM_BUFFERING_UPDATE, fillLevelPerMille); 4168ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi msg->post(); 4178ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi} 4188ad101d5bcaca289da3d820e2b87b5da55e560f9Jean-Michel Trivi 419dff1b1fc1f687c544e19df56bef225c45f7256a9Jean-Michel Trivi} // namespace android 420