Update contrib.
1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // f32\sfat32\inc\sl_cache.inl
28 @param aPos media linear position
29 @return ETrue if the aPos belongs to this page
31 TBool CWTCachePage::PosCached(TInt64 aPos) const
33 return (iValid && aPos >= iStartPos && aPos < iStartPos+PageSize());
38 Calculate data position within cache page relatively to the page beginning.
39 @param aPos media linear position
40 @return data offset from the beginning of the page
42 TUint32 CWTCachePage::PosInCachePage(TInt64 aPos) const
44 return ((TUint32)aPos - (TUint32)iStartPos) & (PageSize()-1);
48 Obtain pointer to the data in the cache page by media inear position
49 @param aPos media linear position
50 @return pointer to the data in page buffer
52 TUint8* CWTCachePage::PtrInCachePage(TInt64 aPos) const
54 return (TUint8*)iData.Ptr() + PosInCachePage(aPos);
58 @return cache page size in bytes
60 TUint32 CWTCachePage::PageSize() const
65 //---------------------------------------------------------------------------------------------------------------------------------
69 Just helper method to calculate cache page start position by given media pos.
70 @param aPos media linear position
71 @return rounded-down and aligned position that is the beginning of the cache page
73 TInt64 CMediaWTCache::CalcPageStartPos(TInt64 aPos) const
75 ASSERT(aPos >= iCacheBasePos);
76 return (((aPos - iCacheBasePos) >> iPageSizeLog2) << iPageSizeLog2) + iCacheBasePos;
80 @return cache page size
82 TUint32 CMediaWTCache::PageSize() const
84 return 1<<iPageSizeLog2;
89 Set cache base position at aBasePos
90 @param aBasePos base position of the cache pages. Affects pages alignment.
92 void CMediaWTCache::SetCacheBasePos(TInt64 aBasePos)
94 iCacheBasePos = aBasePos;
99 //---------------------------------------------------------------------------------------------------------------------------------
102 #endif //SL_CACHE_INL