2018-08-04 23:45:14 +02:00
|
|
|
// Copyright 2018 yuzu Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <array>
|
|
|
|
#include <memory>
|
|
|
|
#include <vector>
|
|
|
|
|
2020-04-21 04:57:30 +02:00
|
|
|
#include "audio_core/behavior_info.h"
|
2020-07-12 13:59:14 +02:00
|
|
|
#include "audio_core/command_generator.h"
|
2020-04-22 05:03:58 +02:00
|
|
|
#include "audio_core/common.h"
|
2020-07-12 13:59:14 +02: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 23:45:14 +02:00
|
|
|
#include "audio_core/stream.h"
|
2020-07-12 13:59:14 +02:00
|
|
|
#include "audio_core/voice_context.h"
|
2018-09-14 17:54:17 +02:00
|
|
|
#include "common/common_funcs.h"
|
2018-08-04 23:45:14 +02:00
|
|
|
#include "common/common_types.h"
|
|
|
|
#include "common/swap.h"
|
2018-09-14 17:54:17 +02:00
|
|
|
#include "core/hle/kernel/object.h"
|
2020-04-21 04:57:30 +02:00
|
|
|
#include "core/hle/result.h"
|
2018-09-14 17:54:17 +02:00
|
|
|
|
2019-02-14 18:42:58 +01:00
|
|
|
namespace Core::Timing {
|
|
|
|
class CoreTiming;
|
|
|
|
}
|
|
|
|
|
2018-09-14 17:54:17 +02:00
|
|
|
namespace Kernel {
|
2018-11-27 00:34:07 +01:00
|
|
|
class WritableEvent;
|
2018-09-14 17:54:17 +02:00
|
|
|
}
|
2018-08-04 23:45:14 +02:00
|
|
|
|
2020-03-31 21:10:44 +02:00
|
|
|
namespace Core::Memory {
|
2019-11-26 20:10:49 +01:00
|
|
|
class Memory;
|
|
|
|
}
|
|
|
|
|
2018-08-04 23:45:14 +02:00
|
|
|
namespace AudioCore {
|
2020-07-12 13:59:14 +02:00
|
|
|
using DSPStateHolder = std::array<VoiceState*, 6>;
|
2018-08-04 23:45:14 +02:00
|
|
|
|
2018-09-14 17:54:17 +02:00
|
|
|
class AudioOut;
|
|
|
|
|
2020-06-13 06:04:28 +02:00
|
|
|
struct RendererInfo {
|
|
|
|
u64_le elasped_frame_count{};
|
|
|
|
INSERT_PADDING_WORDS(2);
|
|
|
|
};
|
|
|
|
static_assert(sizeof(RendererInfo) == 0x10, "RendererInfo is an invalid size");
|
|
|
|
|
2018-08-04 23:45:14 +02:00
|
|
|
class AudioRenderer {
|
|
|
|
public:
|
2020-03-31 21:10:44 +02:00
|
|
|
AudioRenderer(Core::Timing::CoreTiming& core_timing, Core::Memory::Memory& memory_,
|
2020-07-12 13:59:14 +02:00
|
|
|
AudioCommon::AudioRendererParameter params,
|
2019-11-25 02:15:51 +01:00
|
|
|
std::shared_ptr<Kernel::WritableEvent> buffer_event, std::size_t instance_number);
|
2018-09-14 17:54:17 +02:00
|
|
|
~AudioRenderer();
|
|
|
|
|
2020-07-12 13:59:14 +02:00
|
|
|
ResultCode UpdateAudioRenderer(const std::vector<u8>& input_params,
|
|
|
|
std::vector<u8>& output_params);
|
2018-08-04 23:45:14 +02:00
|
|
|
void QueueMixedBuffer(Buffer::Tag tag);
|
|
|
|
void ReleaseAndQueueBuffers();
|
2018-08-12 06:46:12 +02:00
|
|
|
u32 GetSampleRate() const;
|
|
|
|
u32 GetSampleCount() const;
|
|
|
|
u32 GetMixBufferCount() const;
|
2018-09-24 02:01:02 +02:00
|
|
|
Stream::State GetStreamState() const;
|
2018-08-04 23:45:14 +02:00
|
|
|
|
|
|
|
private:
|
2020-04-21 04:57:30 +02:00
|
|
|
BehaviorInfo behavior_info{};
|
2018-08-04 23:45:14 +02:00
|
|
|
|
2020-07-12 13:59:14 +02:00
|
|
|
AudioCommon::AudioRendererParameter worker_params;
|
2019-11-25 02:15:51 +01:00
|
|
|
std::shared_ptr<Kernel::WritableEvent> buffer_event;
|
2020-07-12 13:59:14 +02:00
|
|
|
std::vector<ServerMemoryPoolInfo> memory_pool_info;
|
|
|
|
VoiceContext voice_context;
|
|
|
|
EffectContext effect_context;
|
|
|
|
MixContext mix_context;
|
|
|
|
SinkContext sink_context;
|
|
|
|
SplitterContext splitter_context;
|
2018-08-04 23:45:14 +02:00
|
|
|
std::vector<VoiceState> voices;
|
2018-09-14 17:54:17 +02:00
|
|
|
std::unique_ptr<AudioOut> audio_out;
|
2019-11-26 20:10:49 +01:00
|
|
|
StreamPtr stream;
|
2020-03-31 21:10:44 +02:00
|
|
|
Core::Memory::Memory& memory;
|
2020-07-12 13:59:14 +02:00
|
|
|
CommandGenerator command_generator;
|
2020-06-13 06:04:28 +02:00
|
|
|
std::size_t elapsed_frame_count{};
|
2020-07-12 13:59:14 +02:00
|
|
|
std::vector<s32> temp_mix_buffer{};
|
2018-08-04 23:45:14 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace AudioCore
|