2022-04-23 08:59:50 +00:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2018-08-04 21:45:14 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <array>
|
|
|
|
#include <memory>
|
2021-06-20 14:23:16 +00:00
|
|
|
#include <mutex>
|
2018-08-04 21:45:14 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2020-04-21 02:57:30 +00:00
|
|
|
#include "audio_core/behavior_info.h"
|
2020-07-12 11:59:14 +00:00
|
|
|
#include "audio_core/command_generator.h"
|
2020-04-22 03:03:58 +00:00
|
|
|
#include "audio_core/common.h"
|
2020-07-12 11:59:14 +00:00
|
|
|
#include "audio_core/effect_context.h"
|
|
|
|
#include "audio_core/memory_pool.h"
|
|
|
|
#include "audio_core/mix_context.h"
|
|
|
|
#include "audio_core/sink_context.h"
|
|
|
|
#include "audio_core/splitter_context.h"
|
2018-08-04 21:45:14 +00:00
|
|
|
#include "audio_core/stream.h"
|
2020-07-12 11:59:14 +00:00
|
|
|
#include "audio_core/voice_context.h"
|
2018-09-14 15:54:17 +00:00
|
|
|
#include "common/common_funcs.h"
|
2018-08-04 21:45:14 +00:00
|
|
|
#include "common/common_types.h"
|
|
|
|
#include "common/swap.h"
|
2020-04-21 02:57:30 +00:00
|
|
|
#include "core/hle/result.h"
|
2018-09-14 15:54:17 +00:00
|
|
|
|
2019-02-14 17:42:58 +00:00
|
|
|
namespace Core::Timing {
|
|
|
|
class CoreTiming;
|
|
|
|
}
|
|
|
|
|
2020-03-31 19:10:44 +00:00
|
|
|
namespace Core::Memory {
|
2019-11-26 19:10:49 +00:00
|
|
|
class Memory;
|
|
|
|
}
|
|
|
|
|
2018-08-04 21:45:14 +00:00
|
|
|
namespace AudioCore {
|
2020-11-17 03:14:29 +00:00
|
|
|
using DSPStateHolder = std::array<VoiceState*, AudioCommon::MAX_CHANNEL_COUNT>;
|
2018-08-04 21:45:14 +00:00
|
|
|
|
2018-09-14 15:54:17 +00:00
|
|
|
class AudioOut;
|
|
|
|
|
2018-08-04 21:45:14 +00:00
|
|
|
class AudioRenderer {
|
|
|
|
public:
|
2020-03-31 19:10:44 +00:00
|
|
|
AudioRenderer(Core::Timing::CoreTiming& core_timing, Core::Memory::Memory& memory_,
|
2020-07-12 11:59:14 +00:00
|
|
|
AudioCommon::AudioRendererParameter params,
|
2020-12-29 02:23:42 +00:00
|
|
|
Stream::ReleaseCallback&& release_callback, std::size_t instance_number);
|
2018-09-14 15:54:17 +00:00
|
|
|
~AudioRenderer();
|
|
|
|
|
2020-11-17 03:14:29 +00:00
|
|
|
[[nodiscard]] ResultCode UpdateAudioRenderer(const std::vector<u8>& input_params,
|
|
|
|
std::vector<u8>& output_params);
|
2021-06-20 14:23:16 +00:00
|
|
|
[[nodiscard]] ResultCode Start();
|
|
|
|
[[nodiscard]] ResultCode Stop();
|
2018-08-04 21:45:14 +00:00
|
|
|
void QueueMixedBuffer(Buffer::Tag tag);
|
|
|
|
void ReleaseAndQueueBuffers();
|
2020-11-17 03:14:29 +00:00
|
|
|
[[nodiscard]] u32 GetSampleRate() const;
|
|
|
|
[[nodiscard]] u32 GetSampleCount() const;
|
|
|
|
[[nodiscard]] u32 GetMixBufferCount() const;
|
|
|
|
[[nodiscard]] Stream::State GetStreamState() const;
|
2018-08-04 21:45:14 +00:00
|
|
|
|
|
|
|
private:
|
2020-04-21 02:57:30 +00:00
|
|
|
BehaviorInfo behavior_info{};
|
2018-08-04 21:45:14 +00:00
|
|
|
|
2020-07-12 11:59:14 +00:00
|
|
|
AudioCommon::AudioRendererParameter worker_params;
|
|
|
|
std::vector<ServerMemoryPoolInfo> memory_pool_info;
|
|
|
|
VoiceContext voice_context;
|
|
|
|
EffectContext effect_context;
|
|
|
|
MixContext mix_context;
|
|
|
|
SinkContext sink_context;
|
|
|
|
SplitterContext splitter_context;
|
2018-08-04 21:45:14 +00:00
|
|
|
std::vector<VoiceState> voices;
|
2018-09-14 15:54:17 +00:00
|
|
|
std::unique_ptr<AudioOut> audio_out;
|
2019-11-26 19:10:49 +00:00
|
|
|
StreamPtr stream;
|
2020-03-31 19:10:44 +00:00
|
|
|
Core::Memory::Memory& memory;
|
2020-07-12 11:59:14 +00:00
|
|
|
CommandGenerator command_generator;
|
2020-06-13 04:04:28 +00:00
|
|
|
std::size_t elapsed_frame_count{};
|
2021-06-20 14:23:16 +00:00
|
|
|
Core::Timing::CoreTiming& core_timing;
|
|
|
|
std::shared_ptr<Core::Timing::EventType> process_event;
|
|
|
|
std::mutex mutex;
|
2018-08-04 21:45:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace AudioCore
|