1 /*
2  * Copyright (c) 2022-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #if !defined(OHOS_LITE) && defined(VIDEO_SUPPORT)
17 
18 #define HST_LOG_TAG "ShareAllocator"
19 
20 #include "share_allocator.h"
21 #include "ashmem.h"
22 
23 namespace OHOS {
24 namespace Media {
25 namespace Plugins {
ShareAllocator(ShareMemType shareMemType)26 ShareAllocator::ShareAllocator(ShareMemType shareMemType)
27     : Allocator(MemoryType::SHARED_MEMORY), shareMemType_(shareMemType)
28 {
29 }
30 
Alloc(size_t size)31 void* ShareAllocator::Alloc(size_t size)
32 {
33     return reinterpret_cast<void*>(AshmemCreate(0, size));
34 }
35 
Free(void * ptr)36 void ShareAllocator::Free(void* ptr) // NOLINT: void*
37 {
38     (void)ptr;
39 }
40 
GetShareMemType()41 ShareMemType ShareAllocator::GetShareMemType()
42 {
43     return shareMemType_;
44 }
45 } // namespace Plugins
46 } // namespace Media
47 } // namespace OHOS
48 #endif