summaryrefslogtreecommitdiffstats
path: root/src/audio_core/renderer/upsampler/upsampler_manager.h
blob: 83c697c0c124e7712d878bbabc874c6c80433ee4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include <mutex>
#include <span>

#include "audio_core/renderer/upsampler/upsampler_info.h"
#include "common/common_types.h"

namespace AudioCore::AudioRenderer {
/**
 * Manages and has utility functions for upsampler infos.
 */
class UpsamplerManager {
public:
    UpsamplerManager(u32 count, std::span<UpsamplerInfo> infos, std::span<s32> workbuffer);

    /**
     * Allocate a new UpsamplerInfo.
     *
     * @return The allocated upsampler, may be nullptr if alloc failed.
     */
    UpsamplerInfo* Allocate();

    /**
     * Free the given upsampler.
     *
     * @param info The upsampler to be freed.
     */
    void Free(UpsamplerInfo* info);

private:
    /// Maximum number of upsamplers in the buffer
    const u32 count;
    /// Upsamplers buffer
    std::span<UpsamplerInfo> upsampler_infos;
    /// Workbuffer for upsampling samples
    std::span<s32> workbuffer;
    /// Lock for allocate/free
    std::mutex lock{};
};

} // namespace AudioCore::AudioRenderer