Dale Sather | ad2cbf2 | 2016-02-10 17:00:57 -0800 | [diff] [blame] | 1 | // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef SERVICES_MEDIA_FRAMEWORK_PAYLOAD_ALLOCATOR_H_ |
| 6 | #define SERVICES_MEDIA_FRAMEWORK_PAYLOAD_ALLOCATOR_H_ |
| 7 | |
| 8 | #include <stddef.h> |
| 9 | |
| 10 | namespace mojo { |
| 11 | namespace media { |
| 12 | |
| 13 | // Abstract base class for objects that allocate buffers for packets. |
| 14 | class PayloadAllocator { |
| 15 | public: |
| 16 | // Gets the default allocator, which allocates vanilla memory from the heap. |
| 17 | static PayloadAllocator* GetDefault(); |
| 18 | |
| 19 | // Allocates and returns a buffer of the indicated size or returns nullptr |
| 20 | // if the allocation fails. |
| 21 | virtual void* AllocatePayloadBuffer(size_t size) = 0; |
| 22 | |
| 23 | // Releases a buffer previously allocated via AllocatePayloadBuffer. |
Dale Sather | eee3400 | 2016-06-20 10:47:59 -0700 | [diff] [blame] | 24 | virtual void ReleasePayloadBuffer(void* buffer) = 0; |
Dale Sather | ad2cbf2 | 2016-02-10 17:00:57 -0800 | [diff] [blame] | 25 | }; |
| 26 | |
| 27 | } // namespace media |
| 28 | } // namespace mojo |
| 29 | |
Dale Sather | 4ccdd21 | 2016-03-23 09:27:19 -0700 | [diff] [blame] | 30 | #endif // SERVICES_MEDIA_FRAMEWORK_PAYLOAD_ALLOCATOR_H_ |