1 /* ------------------------------------------------------------------ 2 * Copyright (C) 1998-2009 PacketVideo 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 13 * express or implied. 14 * See the License for the specific language governing permissions 15 * and limitations under the License. 16 * ------------------------------------------------------------------- 17 */ 18 /** 19 * @file pvmf_pool_buffer_allocator.h 20 * @brief This file defines the PV Multimedia Framework (PVMF) media message 21 * header class which is used to hold the basic information such as timestamp, 22 * sequence number, etc for every media message. 23 * 24 */ 25 26 #ifndef PVMF_POOL_BUFFER_ALLOCATOR_H_INCLUDED 27 #define PVMF_POOL_BUFFER_ALLOCATOR_H_INCLUDED 28 29 #ifndef OSCL_BASE_H_INCLUDED 30 #include "oscl_base.h" 31 #endif 32 33 #ifndef OSCL_REFCOUNTER_MEMFRAG_H_INCLUDED 34 #include "oscl_refcounter_memfrag.h" 35 #endif 36 37 #ifndef OSCL_MEM_H_INCLUDED 38 #include "oscl_mem.h" 39 #endif 40 41 #ifndef OSCL_VECTOR_H_INCLUDED 42 #include "oscl_vector.h" 43 #endif 44 45 class PVLogger; 46 47 //typedef OSCLMemAutoPtr<OsclRefCounterMemFrag*> OsclRefCounterMemFrag_ptr; 48 typedef Oscl_TAlloc<OsclRefCounterMemFrag, OsclMemAllocator> OsclRefCounterMemFrag_Alloc; 49 50 class PVMFBufferPoolAllocator : public OsclDestructDealloc 51 { 52 public: 53 OSCL_IMPORT_REF PVMFBufferPoolAllocator(bool aLeaveOnAllocFailure = true); 54 OSCL_IMPORT_REF virtual ~PVMFBufferPoolAllocator(); 55 OSCL_IMPORT_REF void SetLeaveOnAllocFailure(bool aLeaveOnAllocFailure); 56 OSCL_IMPORT_REF virtual void size(uint16 num_frags, uint16 frag_size); 57 OSCL_IMPORT_REF virtual void clear(); 58 OSCL_IMPORT_REF virtual OsclRefCounterMemFrag get(); 59 OSCL_IMPORT_REF virtual void release(OsclRefCounterMemFrag&); 60 // OsclDestructDealloc virtual 61 OSCL_IMPORT_REF virtual void destruct_and_dealloc(OsclAny* ptr); 62 OSCL_IMPORT_REF void SetFailFrequency(uint16 aFrequency); 63 protected: 64 uint32 iFragSize; 65 bool iDestroyPool; 66 Oscl_Vector<OsclRefCounterMemFrag, OsclRefCounterMemFrag_Alloc> iAvailFragments; 67 PVLogger *iLogger; 68 uint32 iAllocNum; 69 uint32 iFailFrequency; 70 bool iLeaveOnAllocFailure; 71 }; 72 73 74 #endif 75