mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-21 03:55:32 +00:00
recording: Implement audio recording for rsx audio
This commit is contained in:
parent
44585b98cc
commit
4a4f537ee8
4 changed files with 54 additions and 5 deletions
|
@ -295,7 +295,7 @@ void audio_ringbuffer::commit_data(f32* buf, u32 sample_cnt)
|
|||
if (g_recording_mode != recording_mode::stopped)
|
||||
{
|
||||
utils::video_provider& provider = g_fxo->get<utils::video_provider>();
|
||||
provider.present_samples(reinterpret_cast<u8*>(buf), sample_cnt, static_cast<u32>(cfg.audio_channels));
|
||||
provider.present_samples(reinterpret_cast<u8*>(buf), sample_cnt, cfg.audio_channels);
|
||||
}
|
||||
|
||||
// Downmix if necessary
|
||||
|
@ -1004,7 +1004,7 @@ void cell_audio_thread::operator()()
|
|||
break;
|
||||
|
||||
default:
|
||||
fmt::throw_exception("Unsupported channel count in cell_audio_config: %d", static_cast<u32>(cfg.audio_channels));
|
||||
fmt::throw_exception("Unsupported channel count in cell_audio_config: %d", cfg.audio_channels);
|
||||
}
|
||||
|
||||
// Enqueue
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "Emu/IdManager.h"
|
||||
#include "Emu/System.h"
|
||||
#include "Emu/system_config.h"
|
||||
#include "util/video_provider.h"
|
||||
|
||||
#include "sys_process.h"
|
||||
#include "sys_rsxaudio.h"
|
||||
|
@ -22,6 +23,8 @@
|
|||
|
||||
LOG_CHANNEL(sys_rsxaudio);
|
||||
|
||||
extern atomic_t<recording_mode> g_recording_mode;
|
||||
|
||||
namespace rsxaudio_ringbuf_reader
|
||||
{
|
||||
static constexpr void clean_buf(rsxaudio_shmem::ringbuf_t& ring_buf)
|
||||
|
@ -1353,6 +1356,16 @@ void rsxaudio_backend_thread::update_emu_cfg()
|
|||
}
|
||||
}
|
||||
|
||||
u32 rsxaudio_backend_thread::get_sample_rate() const
|
||||
{
|
||||
return callback_cfg.load().freq;
|
||||
}
|
||||
|
||||
u8 rsxaudio_backend_thread::get_channel_count() const
|
||||
{
|
||||
return callback_cfg.load().input_ch_cnt;
|
||||
}
|
||||
|
||||
rsxaudio_backend_thread::emu_audio_cfg rsxaudio_backend_thread::get_emu_cfg()
|
||||
{
|
||||
// Get max supported channel count
|
||||
|
@ -1466,7 +1479,8 @@ void rsxaudio_backend_thread::operator()()
|
|||
state_update_c.wait(state_update_m, ERROR_SERVICE_PERIOD);
|
||||
break;
|
||||
}
|
||||
else if (use_aux_ringbuf)
|
||||
|
||||
if (use_aux_ringbuf)
|
||||
{
|
||||
const u64 next_period_time = get_time_until_service();
|
||||
should_service_stream = next_period_time <= SERVICE_THRESHOLD;
|
||||
|
@ -1570,6 +1584,7 @@ void rsxaudio_backend_thread::operator()()
|
|||
crnt_buf_size = sample_cnt * bytes_per_sample;
|
||||
}
|
||||
|
||||
// Dump audio if enabled
|
||||
if (emu_cfg.dump_to_file)
|
||||
{
|
||||
dumper.WriteData(crnt_buf, static_cast<u32>(crnt_buf_size));
|
||||
|
@ -1842,6 +1857,13 @@ u32 rsxaudio_backend_thread::write_data_callback(u32 bytes, void* buf)
|
|||
return bytes;
|
||||
}
|
||||
|
||||
// Record audio if enabled
|
||||
if (g_recording_mode != recording_mode::stopped)
|
||||
{
|
||||
utils::video_provider& provider = g_fxo->get<utils::video_provider>();
|
||||
provider.present_samples(reinterpret_cast<u8*>(callback_tmp_buf.data()), sample_cnt / cb_cfg.input_ch_cnt, cb_cfg.input_ch_cnt);
|
||||
}
|
||||
|
||||
// Downmix if necessary
|
||||
AudioBackend::downmix(sample_cnt, cb_cfg.input_ch_cnt, cb_cfg.output_ch_cnt, callback_tmp_buf.data(), callback_tmp_buf.data());
|
||||
|
||||
|
|
|
@ -458,6 +458,9 @@ public:
|
|||
|
||||
void update_emu_cfg();
|
||||
|
||||
u32 get_sample_rate() const;
|
||||
u8 get_channel_count() const;
|
||||
|
||||
static constexpr auto thread_name = "RsxAudio Backend Thread"sv;
|
||||
|
||||
private:
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "Emu/Cell/Modules/cellScreenshot.h"
|
||||
#include "Emu/Cell/Modules/cellVideoOut.h"
|
||||
#include "Emu/Cell/Modules/cellAudio.h"
|
||||
#include "Emu/Cell/lv2/sys_rsxaudio.h"
|
||||
#include "Emu/RSX/rsx_utils.h"
|
||||
#include "Emu/RSX/Overlays/overlay_message.h"
|
||||
#include "Emu/Io/recording_config.h"
|
||||
|
@ -504,8 +505,31 @@ void gs_frame::toggle_recording()
|
|||
m_video_encoder->set_max_b_frames(g_cfg_recording.video.max_b_frames);
|
||||
m_video_encoder->set_gop_size(g_cfg_recording.video.gop_size);
|
||||
m_video_encoder->set_output_format(output_format);
|
||||
m_video_encoder->set_sample_rate(g_fxo->get<cell_audio>().cfg.audio_sampling_rate);
|
||||
m_video_encoder->set_audio_channels(static_cast<u32>(g_fxo->get<cell_audio>().cfg.audio_channels));
|
||||
|
||||
switch (g_cfg.audio.provider)
|
||||
{
|
||||
case audio_provider::none:
|
||||
{
|
||||
// Disable audio recording
|
||||
m_video_encoder->use_internal_audio = false;
|
||||
break;
|
||||
}
|
||||
case audio_provider::cell_audio:
|
||||
{
|
||||
const cell_audio_config& cfg = g_fxo->get<cell_audio>().cfg;
|
||||
m_video_encoder->set_sample_rate(cfg.audio_sampling_rate);
|
||||
m_video_encoder->set_audio_channels(cfg.audio_channels);
|
||||
break;
|
||||
}
|
||||
case audio_provider::rsxaudio:
|
||||
{
|
||||
const auto& rsx_audio = g_fxo->get<rsx_audio_backend>();
|
||||
m_video_encoder->set_sample_rate(rsx_audio.get_sample_rate());
|
||||
m_video_encoder->set_audio_channels(rsx_audio.get_channel_count());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_video_encoder->set_audio_bitrate(g_cfg_recording.audio.audio_bps);
|
||||
m_video_encoder->set_audio_codec(g_cfg_recording.audio.audio_codec);
|
||||
m_video_encoder->encode();
|
||||
|
|
Loading…
Add table
Reference in a new issue