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 "plugin/common/share_allocator.h"
21#include "ashmem.h"
22
23namespace OHOS {
24namespace Media {
25namespace Plugin {
26ShareAllocator::ShareAllocator(ShareMemType shareMemType)
27    : Allocator(MemoryType::SHARE_MEMORY), shareMemType_(shareMemType)
28{
29}
30
31void* ShareAllocator::Alloc(size_t size)
32{
33    return reinterpret_cast<void*>(AshmemCreate(0, size));
34}
35
36void ShareAllocator::Free(void* ptr) // NOLINT: void*
37{
38    (void)ptr;
39}
40
41ShareMemType ShareAllocator::GetShareMemType()
42{
43    return shareMemType_;
44}
45} // namespace Plugin
46} // namespace Media
47} // namespace OHOS
48#endif