NuCachedSource2.cpp revision 1bd233ce7e1aa7730bc18d46ffd57791391738cd
15994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber/* 25994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber * Copyright (C) 2010 The Android Open Source Project 35994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber * 45994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber * Licensed under the Apache License, Version 2.0 (the "License"); 55994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber * you may not use this file except in compliance with the License. 65994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber * You may obtain a copy of the License at 75994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber * 85994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber * http://www.apache.org/licenses/LICENSE-2.0 95994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber * 105994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber * Unless required by applicable law or agreed to in writing, software 115994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber * distributed under the License is distributed on an "AS IS" BASIS, 125994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 135994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber * See the License for the specific language governing permissions and 145994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber * limitations under the License. 155994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber */ 165994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 175994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber#define LOG_TAG "NuCachedSource2" 185994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber#include <utils/Log.h> 195994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 205994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber#include "include/NuCachedSource2.h" 215994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 225994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber#include <media/stagefright/foundation/ADebug.h> 235994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber#include <media/stagefright/foundation/AMessage.h> 245994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber#include <media/stagefright/MediaErrors.h> 255994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 265994b4798b01f3dd340577c9ea9657f09093a770Andreas Hubernamespace android { 275994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 285994b4798b01f3dd340577c9ea9657f09093a770Andreas Huberstruct PageCache { 295994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber PageCache(size_t pageSize); 305994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber ~PageCache(); 315994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 325994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber struct Page { 335994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber void *mData; 345994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber size_t mSize; 355994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber }; 365994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 375994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber Page *acquirePage(); 385994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber void releasePage(Page *page); 395994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 405994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber void appendPage(Page *page); 415994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber size_t releaseFromStart(size_t maxBytes); 425994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 435994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber size_t totalSize() const { 445994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber return mTotalSize; 455994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber } 465994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 475994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber void copy(size_t from, void *data, size_t size); 485994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 495994b4798b01f3dd340577c9ea9657f09093a770Andreas Huberprivate: 505994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber size_t mPageSize; 515994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber size_t mTotalSize; 525994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 535994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber List<Page *> mActivePages; 545994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber List<Page *> mFreePages; 555994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 565994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber void freePages(List<Page *> *list); 575994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 585994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber DISALLOW_EVIL_CONSTRUCTORS(PageCache); 595994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber}; 605994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 615994b4798b01f3dd340577c9ea9657f09093a770Andreas HuberPageCache::PageCache(size_t pageSize) 625994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber : mPageSize(pageSize), 635994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mTotalSize(0) { 645994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber} 655994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 665994b4798b01f3dd340577c9ea9657f09093a770Andreas HuberPageCache::~PageCache() { 675994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber freePages(&mActivePages); 685994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber freePages(&mFreePages); 695994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber} 705994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 715994b4798b01f3dd340577c9ea9657f09093a770Andreas Hubervoid PageCache::freePages(List<Page *> *list) { 725994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber List<Page *>::iterator it = list->begin(); 735994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber while (it != list->end()) { 745994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber Page *page = *it; 755994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 765994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber free(page->mData); 775994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber delete page; 785994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber page = NULL; 795994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 805994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber ++it; 815994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber } 825994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber} 835994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 845994b4798b01f3dd340577c9ea9657f09093a770Andreas HuberPageCache::Page *PageCache::acquirePage() { 855994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber if (!mFreePages.empty()) { 865994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber List<Page *>::iterator it = mFreePages.begin(); 875994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber Page *page = *it; 885994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mFreePages.erase(it); 895994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 905994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber return page; 915994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber } 925994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 935994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber Page *page = new Page; 945994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber page->mData = malloc(mPageSize); 955994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber page->mSize = 0; 965994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 975994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber return page; 985994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber} 995994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 1005994b4798b01f3dd340577c9ea9657f09093a770Andreas Hubervoid PageCache::releasePage(Page *page) { 1015994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber page->mSize = 0; 1025994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mFreePages.push_back(page); 1035994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber} 1045994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 1055994b4798b01f3dd340577c9ea9657f09093a770Andreas Hubervoid PageCache::appendPage(Page *page) { 1065994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mTotalSize += page->mSize; 1075994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mActivePages.push_back(page); 1085994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber} 1095994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 1105994b4798b01f3dd340577c9ea9657f09093a770Andreas Hubersize_t PageCache::releaseFromStart(size_t maxBytes) { 1115994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber size_t bytesReleased = 0; 1125994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 1135994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber while (maxBytes > 0 && !mActivePages.empty()) { 1145994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber List<Page *>::iterator it = mActivePages.begin(); 1155994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 1165994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber Page *page = *it; 1175994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 1185994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber if (maxBytes < page->mSize) { 1195994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber break; 1205994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber } 1215994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 1225994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mActivePages.erase(it); 1235994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 1245994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber maxBytes -= page->mSize; 1255994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber bytesReleased += page->mSize; 1265994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 1275994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber releasePage(page); 1285994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber } 1295994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 1305994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mTotalSize -= bytesReleased; 1315994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber return bytesReleased; 1325994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber} 1335994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 1345994b4798b01f3dd340577c9ea9657f09093a770Andreas Hubervoid PageCache::copy(size_t from, void *data, size_t size) { 1356e4c5c499999c04c2477b987f9e64f3ff2bf1a06Andreas Huber LOGV("copy from %d size %d", from, size); 1365994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 1375994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber CHECK_LE(from + size, mTotalSize); 1385994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 1395994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber size_t offset = 0; 1405994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber List<Page *>::iterator it = mActivePages.begin(); 1415994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber while (from >= offset + (*it)->mSize) { 1425994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber offset += (*it)->mSize; 1435994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber ++it; 1445994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber } 1455994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 1465994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber size_t delta = from - offset; 1475994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber size_t avail = (*it)->mSize - delta; 1485994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 1495994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber if (avail >= size) { 1505994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber memcpy(data, (const uint8_t *)(*it)->mData + delta, size); 1515994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber return; 1525994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber } 1535994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 1545994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber memcpy(data, (const uint8_t *)(*it)->mData + delta, avail); 1555994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber ++it; 1565994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber data = (uint8_t *)data + avail; 1575994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber size -= avail; 1585994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 1595994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber while (size > 0) { 1605994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber size_t copy = (*it)->mSize; 1615994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber if (copy > size) { 1625994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber copy = size; 1635994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber } 1645994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber memcpy(data, (*it)->mData, copy); 1655994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber data = (uint8_t *)data + copy; 1665994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber size -= copy; 1675994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber ++it; 1685994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber } 1695994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber} 1705994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 1715994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber//////////////////////////////////////////////////////////////////////////////// 1725994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 1735994b4798b01f3dd340577c9ea9657f09093a770Andreas HuberNuCachedSource2::NuCachedSource2(const sp<DataSource> &source) 1745994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber : mSource(source), 1755994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mReflector(new AHandlerReflector<NuCachedSource2>(this)), 1765994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mLooper(new ALooper), 1775994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mCache(new PageCache(kPageSize)), 1785994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mCacheOffset(0), 1795994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mFinalStatus(OK), 1805994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mLastAccessPos(0), 181a5273ebd1746368662a597643d6701a5046d5c7bAndreas Huber mFetching(true), 182a44153c1a57202fb538659eb50706e60454d6273Andreas Huber mLastFetchTimeUs(-1) { 183a814c1fdc2acf0ed2ee3b175110f6039be7c4873Andreas Huber mLooper->setName("NuCachedSource2"); 1845994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mLooper->registerHandler(mReflector); 1855994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mLooper->start(); 1865994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 1875994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber Mutex::Autolock autoLock(mLock); 1885994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber (new AMessage(kWhatFetchMore, mReflector->id()))->post(); 1895994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber} 1905994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 1915994b4798b01f3dd340577c9ea9657f09093a770Andreas HuberNuCachedSource2::~NuCachedSource2() { 1925994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mLooper->stop(); 1935994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mLooper->unregisterHandler(mReflector->id()); 1945994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 1955994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber delete mCache; 1965994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mCache = NULL; 1975994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber} 1985994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 1995994b4798b01f3dd340577c9ea9657f09093a770Andreas Huberstatus_t NuCachedSource2::initCheck() const { 2005994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber return mSource->initCheck(); 2015994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber} 2025994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 203c7fc37a3dab9bd1f96713649f351b5990e6316ffJames Dongstatus_t NuCachedSource2::getSize(off64_t *size) { 2045994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber return mSource->getSize(size); 2055994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber} 2065994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 2075994b4798b01f3dd340577c9ea9657f09093a770Andreas Huberuint32_t NuCachedSource2::flags() { 208bff07d0b22a5ee2d9f044f6cb5e4be1532017ab0Andreas Huber return (mSource->flags() & ~kWantsPrefetching) | kIsCachingDataSource; 2095994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber} 2105994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 2115994b4798b01f3dd340577c9ea9657f09093a770Andreas Hubervoid NuCachedSource2::onMessageReceived(const sp<AMessage> &msg) { 2125994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber switch (msg->what()) { 2135994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber case kWhatFetchMore: 2145994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber { 2155994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber onFetch(); 2165994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber break; 2175994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber } 2185994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 2195994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber case kWhatRead: 2205994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber { 2215994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber onRead(msg); 2225994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber break; 2235994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber } 2245994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 2255994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber default: 2265994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber TRESPASS(); 2275994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber } 2285994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber} 2295994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 2305994b4798b01f3dd340577c9ea9657f09093a770Andreas Hubervoid NuCachedSource2::fetchInternal() { 2316e4c5c499999c04c2477b987f9e64f3ff2bf1a06Andreas Huber LOGV("fetchInternal"); 2325994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 2335994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber CHECK_EQ(mFinalStatus, (status_t)OK); 2345994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 2355994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber PageCache::Page *page = mCache->acquirePage(); 2365994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 2375994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber ssize_t n = mSource->readAt( 2385994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mCacheOffset + mCache->totalSize(), page->mData, kPageSize); 2395994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 2405994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber Mutex::Autolock autoLock(mLock); 2415994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 2425994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber if (n < 0) { 2436e4c5c499999c04c2477b987f9e64f3ff2bf1a06Andreas Huber LOGE("source returned error %ld", n); 2445994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mFinalStatus = n; 2455994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mCache->releasePage(page); 2465994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber } else if (n == 0) { 2476e4c5c499999c04c2477b987f9e64f3ff2bf1a06Andreas Huber LOGI("ERROR_END_OF_STREAM"); 2485994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mFinalStatus = ERROR_END_OF_STREAM; 2495994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mCache->releasePage(page); 2505994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber } else { 2515994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber page->mSize = n; 2525994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mCache->appendPage(page); 2535994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber } 2545994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber} 2555994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 2565994b4798b01f3dd340577c9ea9657f09093a770Andreas Hubervoid NuCachedSource2::onFetch() { 2576e4c5c499999c04c2477b987f9e64f3ff2bf1a06Andreas Huber LOGV("onFetch"); 2585994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 2595994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber if (mFinalStatus != OK) { 2606e4c5c499999c04c2477b987f9e64f3ff2bf1a06Andreas Huber LOGV("EOS reached, done prefetching for now"); 2615994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mFetching = false; 2625994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber } 2635994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 264a5273ebd1746368662a597643d6701a5046d5c7bAndreas Huber bool keepAlive = 265a5273ebd1746368662a597643d6701a5046d5c7bAndreas Huber !mFetching 266a5273ebd1746368662a597643d6701a5046d5c7bAndreas Huber && mFinalStatus == OK 267a5273ebd1746368662a597643d6701a5046d5c7bAndreas Huber && ALooper::GetNowUs() >= mLastFetchTimeUs + kKeepAliveIntervalUs; 268a5273ebd1746368662a597643d6701a5046d5c7bAndreas Huber 269a5273ebd1746368662a597643d6701a5046d5c7bAndreas Huber if (mFetching || keepAlive) { 270a5273ebd1746368662a597643d6701a5046d5c7bAndreas Huber if (keepAlive) { 2716e4c5c499999c04c2477b987f9e64f3ff2bf1a06Andreas Huber LOGI("Keep alive"); 272a5273ebd1746368662a597643d6701a5046d5c7bAndreas Huber } 273a5273ebd1746368662a597643d6701a5046d5c7bAndreas Huber 2745994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber fetchInternal(); 2755994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 276a5273ebd1746368662a597643d6701a5046d5c7bAndreas Huber mLastFetchTimeUs = ALooper::GetNowUs(); 277a5273ebd1746368662a597643d6701a5046d5c7bAndreas Huber 278a5273ebd1746368662a597643d6701a5046d5c7bAndreas Huber if (mFetching && mCache->totalSize() >= kHighWaterThreshold) { 2796e4c5c499999c04c2477b987f9e64f3ff2bf1a06Andreas Huber LOGI("Cache full, done prefetching for now"); 2805994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mFetching = false; 2815994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber } 282a44153c1a57202fb538659eb50706e60454d6273Andreas Huber } else { 283d17875a226491e3de60fa32d764a4cc92de7f949Andreas Huber Mutex::Autolock autoLock(mLock); 2845994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber restartPrefetcherIfNecessary_l(); 2855994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber } 2865994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 2875994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber (new AMessage(kWhatFetchMore, mReflector->id()))->post( 2885994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mFetching ? 0 : 100000ll); 2895994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber} 2905994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 2915994b4798b01f3dd340577c9ea9657f09093a770Andreas Hubervoid NuCachedSource2::onRead(const sp<AMessage> &msg) { 2926e4c5c499999c04c2477b987f9e64f3ff2bf1a06Andreas Huber LOGV("onRead"); 2935994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 2945994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber int64_t offset; 2955994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber CHECK(msg->findInt64("offset", &offset)); 2965994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 2975994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber void *data; 2985994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber CHECK(msg->findPointer("data", &data)); 2995994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 3005994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber size_t size; 3015994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber CHECK(msg->findSize("size", &size)); 3025994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 3035994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber ssize_t result = readInternal(offset, data, size); 3045994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 3055994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber if (result == -EAGAIN) { 3065994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber msg->post(50000); 3075994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber return; 3085994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber } 3095994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 3105994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber Mutex::Autolock autoLock(mLock); 3115994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 3125994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber CHECK(mAsyncResult == NULL); 3135994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 3145994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mAsyncResult = new AMessage; 3155994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mAsyncResult->setInt32("result", result); 3165994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 3175994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mCondition.signal(); 3185994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber} 3195994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 32034ef0f32c8fc0186236a27e07405328cc1f7c56dAndreas Hubervoid NuCachedSource2::restartPrefetcherIfNecessary_l( 32134ef0f32c8fc0186236a27e07405328cc1f7c56dAndreas Huber bool ignoreLowWaterThreshold) { 3226ee94582e3ce7bdd9625345e7564e3176a51a2f3James Dong static const size_t kGrayArea = 1024 * 1024; 3235994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 3245994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber if (mFetching || mFinalStatus != OK) { 3255994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber return; 3265994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber } 3275994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 32834ef0f32c8fc0186236a27e07405328cc1f7c56dAndreas Huber if (!ignoreLowWaterThreshold 32934ef0f32c8fc0186236a27e07405328cc1f7c56dAndreas Huber && mCacheOffset + mCache->totalSize() - mLastAccessPos 33034ef0f32c8fc0186236a27e07405328cc1f7c56dAndreas Huber >= kLowWaterThreshold) { 3315994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber return; 3325994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber } 3335994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 3345994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber size_t maxBytes = mLastAccessPos - mCacheOffset; 3355994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber if (maxBytes < kGrayArea) { 3365994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber return; 3375994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber } 3385994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 3395994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber maxBytes -= kGrayArea; 3405994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 3415994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber size_t actualBytes = mCache->releaseFromStart(maxBytes); 3425994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mCacheOffset += actualBytes; 3435994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 3446e4c5c499999c04c2477b987f9e64f3ff2bf1a06Andreas Huber LOGI("restarting prefetcher, totalSize = %d", mCache->totalSize()); 3455994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mFetching = true; 3465994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber} 3475994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 348c7fc37a3dab9bd1f96713649f351b5990e6316ffJames Dongssize_t NuCachedSource2::readAt(off64_t offset, void *data, size_t size) { 3495994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber Mutex::Autolock autoSerializer(mSerializer); 3505994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 351145e68fc778275963189b02a1adcbe27cce4d769Andreas Huber LOGV("readAt offset %lld, size %d", offset, size); 3525994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 3535994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber Mutex::Autolock autoLock(mLock); 3545994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 3555994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber // If the request can be completely satisfied from the cache, do so. 3565994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 3575994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber if (offset >= mCacheOffset 3585994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber && offset + size <= mCacheOffset + mCache->totalSize()) { 3595994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber size_t delta = offset - mCacheOffset; 3605994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mCache->copy(delta, data, size); 3615994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 3625994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mLastAccessPos = offset + size; 3635994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 3645994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber return size; 3655994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber } 3665994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 3675994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber sp<AMessage> msg = new AMessage(kWhatRead, mReflector->id()); 3685994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber msg->setInt64("offset", offset); 3695994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber msg->setPointer("data", data); 3705994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber msg->setSize("size", size); 3715994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 3725994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber CHECK(mAsyncResult == NULL); 3735994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber msg->post(); 3745994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 3755994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber while (mAsyncResult == NULL) { 3765994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mCondition.wait(mLock); 3775994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber } 3785994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 3795994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber int32_t result; 3805994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber CHECK(mAsyncResult->findInt32("result", &result)); 3815994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 3825994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mAsyncResult.clear(); 3835994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 3845994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber if (result > 0) { 3855994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mLastAccessPos = offset + result; 3865994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber } 3875994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 3885994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber return (ssize_t)result; 3895994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber} 3905994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 3915994b4798b01f3dd340577c9ea9657f09093a770Andreas Hubersize_t NuCachedSource2::cachedSize() { 3925994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber Mutex::Autolock autoLock(mLock); 3935994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber return mCacheOffset + mCache->totalSize(); 3945994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber} 3955994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 3961bd233ce7e1aa7730bc18d46ffd57791391738cdBryan Mawhinneysize_t NuCachedSource2::approxDataRemaining(status_t *finalStatus) { 3975994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber Mutex::Autolock autoLock(mLock); 3981bd233ce7e1aa7730bc18d46ffd57791391738cdBryan Mawhinney return approxDataRemaining_l(finalStatus); 3995994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber} 4005994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 4011bd233ce7e1aa7730bc18d46ffd57791391738cdBryan Mawhinneysize_t NuCachedSource2::approxDataRemaining_l(status_t *finalStatus) { 4021bd233ce7e1aa7730bc18d46ffd57791391738cdBryan Mawhinney *finalStatus = mFinalStatus; 403c7fc37a3dab9bd1f96713649f351b5990e6316ffJames Dong off64_t lastBytePosCached = mCacheOffset + mCache->totalSize(); 4045994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber if (mLastAccessPos < lastBytePosCached) { 4055994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber return lastBytePosCached - mLastAccessPos; 4065994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber } 4075994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber return 0; 4085994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber} 4095994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 410c7fc37a3dab9bd1f96713649f351b5990e6316ffJames Dongssize_t NuCachedSource2::readInternal(off64_t offset, void *data, size_t size) { 411145e68fc778275963189b02a1adcbe27cce4d769Andreas Huber LOGV("readInternal offset %lld size %d", offset, size); 4125994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 4135994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber Mutex::Autolock autoLock(mLock); 4145994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 4155994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber if (offset < mCacheOffset 416c7fc37a3dab9bd1f96713649f351b5990e6316ffJames Dong || offset >= (off64_t)(mCacheOffset + mCache->totalSize())) { 4176ee94582e3ce7bdd9625345e7564e3176a51a2f3James Dong static const off64_t kPadding = 256 * 1024; 4185994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 4195994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber // In the presence of multiple decoded streams, once of them will 4205994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber // trigger this seek request, the other one will request data "nearby" 4215994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber // soon, adjust the seek position so that that subsequent request 4225994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber // does not trigger another seek. 423c7fc37a3dab9bd1f96713649f351b5990e6316ffJames Dong off64_t seekOffset = (offset > kPadding) ? offset - kPadding : 0; 4245994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 4255994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber seekInternal_l(seekOffset); 4265994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber } 4275994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 4285994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber size_t delta = offset - mCacheOffset; 4295994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 4305994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber if (mFinalStatus != OK) { 4315994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber if (delta >= mCache->totalSize()) { 4325994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber return mFinalStatus; 4335994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber } 4345994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 4356f5aae1bcba130d5b8092a19fca3627aa565df56Andreas Huber size_t avail = mCache->totalSize() - delta; 4365994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mCache->copy(delta, data, avail); 4375994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 4385994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber return avail; 4395994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber } 4405994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 4415994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber if (offset + size <= mCacheOffset + mCache->totalSize()) { 4425994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mCache->copy(delta, data, size); 4435994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 4445994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber return size; 4455994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber } 4465994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 4476e4c5c499999c04c2477b987f9e64f3ff2bf1a06Andreas Huber LOGV("deferring read"); 4485994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 4495994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber return -EAGAIN; 4505994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber} 4515994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 452c7fc37a3dab9bd1f96713649f351b5990e6316ffJames Dongstatus_t NuCachedSource2::seekInternal_l(off64_t offset) { 4535994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mLastAccessPos = offset; 4545994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 4555994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber if (offset >= mCacheOffset 456c7fc37a3dab9bd1f96713649f351b5990e6316ffJames Dong && offset <= (off64_t)(mCacheOffset + mCache->totalSize())) { 4575994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber return OK; 4585994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber } 4595994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 4607fe4ed1207fa587c65231f9a32374ae4b618d6c0Andreas Huber LOGI("new range: offset= %lld", offset); 4615994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 4625994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mCacheOffset = offset; 4635994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 4645994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber size_t totalSize = mCache->totalSize(); 4655994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber CHECK_EQ(mCache->releaseFromStart(totalSize), totalSize); 4665994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 4675994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mFinalStatus = OK; 4685994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber mFetching = true; 4695994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 4705994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber return OK; 4715994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber} 4725994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber 47334ef0f32c8fc0186236a27e07405328cc1f7c56dAndreas Hubervoid NuCachedSource2::resumeFetchingIfNecessary() { 47434ef0f32c8fc0186236a27e07405328cc1f7c56dAndreas Huber Mutex::Autolock autoLock(mLock); 47534ef0f32c8fc0186236a27e07405328cc1f7c56dAndreas Huber 47634ef0f32c8fc0186236a27e07405328cc1f7c56dAndreas Huber restartPrefetcherIfNecessary_l(true /* ignore low water threshold */); 47734ef0f32c8fc0186236a27e07405328cc1f7c56dAndreas Huber} 47834ef0f32c8fc0186236a27e07405328cc1f7c56dAndreas Huber 479b371426ce4cf2fa6d8c3d1903b61322feb165d35Gloria WangDecryptHandle* NuCachedSource2::DrmInitialization(DrmManagerClient* client) { 480b371426ce4cf2fa6d8c3d1903b61322feb165d35Gloria Wang return mSource->DrmInitialization(client); 481b371426ce4cf2fa6d8c3d1903b61322feb165d35Gloria Wang} 482b371426ce4cf2fa6d8c3d1903b61322feb165d35Gloria Wang 483b371426ce4cf2fa6d8c3d1903b61322feb165d35Gloria Wangvoid NuCachedSource2::getDrmInfo(DecryptHandle **handle, DrmManagerClient **client) { 484b371426ce4cf2fa6d8c3d1903b61322feb165d35Gloria Wang mSource->getDrmInfo(handle, client); 485b371426ce4cf2fa6d8c3d1903b61322feb165d35Gloria Wang} 486b371426ce4cf2fa6d8c3d1903b61322feb165d35Gloria Wang 487771b85d9245a24273497792a2515d88d31c99e1eGloria WangString8 NuCachedSource2::getUri() { 488771b85d9245a24273497792a2515d88d31c99e1eGloria Wang return mSource->getUri(); 489771b85d9245a24273497792a2515d88d31c99e1eGloria Wang} 4905994b4798b01f3dd340577c9ea9657f09093a770Andreas Huber} // namespace android 491