First public contribution.
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
23 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
24 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26 //!! WARNING!! DO NOT edit this file !! '\sfat' component is obsolete and is not being used. '\sfat32'replaces it
28 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
29 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
37 @param aPos media linear position
38 @return ETrue if the aPos belongs to this page
40 TBool CWTCachePage::PosCached(TInt64 aPos) const
42 return (iValid && aPos >= iStartPos && aPos < iStartPos+PageSize());
47 Calculate data position within cache page relatively to the page beginning.
48 @param aPos media linear position
49 @return data offset from the beginning of the page
51 TUint32 CWTCachePage::PosInCachePage(TInt64 aPos) const
53 return ((TUint32)aPos - (TUint32)iStartPos) & (PageSize()-1);
57 Obtain pointer to the data in the cache page by media inear position
58 @param aPos media linear position
59 @return pointer to the data in page buffer
61 TUint8* CWTCachePage::PtrInCachePage(TInt64 aPos) const
63 return (TUint8*)iData.Ptr() + PosInCachePage(aPos);
67 @return cache page size in bytes
69 TUint32 CWTCachePage::PageSize() const
74 //---------------------------------------------------------------------------------------------------------------------------------
78 Just helper method to calculate cache page start position by given media pos.
79 @param aPos media linear position
80 @return rounded-down and aligned position that is the beginning of the cache page
82 TInt64 CMediaWTCache::CalcPageStartPos(TInt64 aPos) const
84 ASSERT(aPos >= iCacheBasePos);
85 return (((aPos - iCacheBasePos) >> iPageSizeLog2) << iPageSizeLog2) + iCacheBasePos;
89 @return cache page size
91 TUint32 CMediaWTCache::PageSize() const
93 return 1<<iPageSizeLog2;
98 Set cache base position at aBasePos
99 @param aBasePos base position of the cache pages. Affects pages alignment.
101 void CMediaWTCache::SetCacheBasePos(TInt64 aBasePos)
103 iCacheBasePos = aBasePos;
108 //---------------------------------------------------------------------------------------------------------------------------------
111 #endif //SL_CACHE_INL