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 * Copyright (C) 1998-2009 PacketVideo 20 * 21 * Licensed under the Apache License, Version 2.0 (the "License"); 22 * you may not use this file except in compliance with the License. 23 * You may obtain a copy of the License at 24 * 25 * http://www.apache.org/licenses/LICENSE-2.0 26 * 27 * Unless required by applicable law or agreed to in writing, software 28 * distributed under the License is distributed on an "AS IS" BASIS, 29 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 30 * express or implied. 31 * See the License for the specific language governing permissions 32 * and limitations under the License. 33 * ------------------------------------------------------------------- 34 */ 35 36 #ifndef PVMF_FIXEDSIZE_BUFFER_ALLOC_H_INCLUDED 37 #define PVMF_FIXEDSIZE_BUFFER_ALLOC_H_INCLUDED 38 39 #ifndef OSCL_BASE_H_INCLUDED 40 #include "oscl_base.h" 41 #endif 42 43 #ifndef PV_UUID_H_INCLUDED 44 #include "pv_uuid.h" 45 #endif 46 47 48 /* Interface ID for the Fixed-size buffer allocator */ 49 #define PVMFFixedSizeBufferAllocUUID PVUuid(0xC8DE4E11,0xF988,0x4E42,0xBA,0x2A,0xAE,0x1A,0xB6,0x99,0x4E,0x25) 50 51 /** 52 * This interface is used to allocate a set of fixed-size buffers. 53 */ 54 class PVMFFixedSizeBufferAlloc 55 { 56 public: 57 ~PVMFFixedSizeBufferAlloc()58 virtual ~PVMFFixedSizeBufferAlloc() {}; 59 60 /** 61 * This method allocates a fixed-size buffer as long as there are 62 * buffers remaining. Once the maximum number of buffers have been 63 * allocated, further requests will fail. 64 * 65 * @returns a ptr to a fixed-size buffer 66 * or NULL if there is an error. 67 */ 68 virtual OsclAny* allocate() = 0; 69 70 /** 71 * This method deallocates a buffer ptr that was previously 72 * allocated through the allocate method. 73 * 74 * @param ptr is a ptr to the previously allocated buffer to release. 75 */ 76 virtual void deallocate(OsclAny* ptr) = 0; 77 78 /** 79 * This method returns the size of the buffers that 80 * will be allocated. 81 * 82 * @returns the fixed size used for all buffers. 83 */ 84 virtual uint32 getBufferSize() = 0; 85 86 /** 87 * This method returns the maximum number of buffers 88 * available for allocation 89 * 90 * @returns the max number of buffers available for allocation. 91 */ 92 virtual uint32 getNumBuffers() = 0; 93 }; 94 95 #endif 96