From ff434f9d384074fed5edbae6e37f52b2477089fd Mon Sep 17 00:00:00 2001 From: Megamouse Date: Thu, 16 Nov 2023 00:18:35 +0100 Subject: [PATCH] recording: cleanup audio config members and fix some annyoing msvc warnings --- rpcs3/Emu/Cell/Modules/cellAudio.h | 4 ++-- rpcs3/Emu/Cell/Modules/cellRec.cpp | 9 +++++++-- rpcs3/Emu/Cell/Modules/cellSail.cpp | 6 +++--- rpcs3/Emu/Io/recording_config.h | 2 -- rpcs3/Loader/PSF.cpp | 4 ++-- rpcs3/rpcs3qt/gs_frame.cpp | 3 +-- rpcs3/util/media_utils.h | 2 +- 7 files changed, 16 insertions(+), 14 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellAudio.h b/rpcs3/Emu/Cell/Modules/cellAudio.h index 0f2bfe7d52..4225bdbca6 100644 --- a/rpcs3/Emu/Cell/Modules/cellAudio.h +++ b/rpcs3/Emu/Cell/Modules/cellAudio.h @@ -223,8 +223,8 @@ struct cell_audio_config AudioChannelCnt audio_downmix = AudioChannelCnt::SURROUND_7_1; AudioChannelCnt backend_ch_cnt = AudioChannelCnt::SURROUND_7_1; - u32 audio_channels = 0; - u32 audio_sampling_rate = 0; + u32 audio_channels = 2; + u32 audio_sampling_rate = DEFAULT_AUDIO_SAMPLING_RATE; u32 audio_block_period = 0; u32 audio_sample_size = 0; f64 audio_min_buffer_duration = 0.0; diff --git a/rpcs3/Emu/Cell/Modules/cellRec.cpp b/rpcs3/Emu/Cell/Modules/cellRec.cpp index 7c9a5043a1..f08fbbc529 100644 --- a/rpcs3/Emu/Cell/Modules/cellRec.cpp +++ b/rpcs3/Emu/Cell/Modules/cellRec.cpp @@ -165,7 +165,11 @@ public: rec_video_sink() : utils::video_sink() { m_framerate = rec_framerate; - m_sample_rate = 48000; // TODO + } + + void set_sample_rate(u32 sample_rate) + { + m_sample_rate = sample_rate; } void stop(bool flush = true) override @@ -702,7 +706,7 @@ void rec_info::start_video_provider() // The audio samples originate from cellAudio and are stored in a ringbuffer. utils::video_sink::encoder_sample sample = sink->get_sample(); - if (!sample.data.empty() && sample.channels >= 2 && sample.sample_count >= CELL_REC_AUDIO_BLOCK_SAMPLES) + if (!sample.data.empty() && sample.channels >= channels && sample.sample_count >= CELL_REC_AUDIO_BLOCK_SAMPLES) { s64 pts = encoder->get_audio_pts(sample.timestamp_us); @@ -1248,6 +1252,7 @@ error_code cellRecOpen(vm::cptr pDirName, vm::cptr pFileName, vm::cp rec.sink = std::make_shared(); rec.sink->use_internal_audio = rec.param.use_internal_audio(); rec.sink->use_internal_video = rec.param.use_internal_video(); + rec.sink->set_sample_rate(rec.sample_rate); } rec.encoder = std::make_shared(); diff --git a/rpcs3/Emu/Cell/Modules/cellSail.cpp b/rpcs3/Emu/Cell/Modules/cellSail.cpp index 3fd558beb6..76a6d3c6fd 100644 --- a/rpcs3/Emu/Cell/Modules/cellSail.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSail.cpp @@ -639,7 +639,7 @@ error_code cellSailPlayerInitialize2(ppu_thread& ppu, pSelf->paused = true; { - CellSailEvent event; + CellSailEvent event{}; event.u32x2.major = CELL_SAIL_EVENT_PLAYER_STATE_CHANGED; event.u32x2.minor = 0; pSelf->callback(ppu, pSelf->callbackArg, event, CELL_SAIL_PLAYER_STATE_INITIALIZED, 0); @@ -778,7 +778,7 @@ error_code cellSailPlayerBoot(ppu_thread& ppu, vm::ptr pSelf, u6 cellSail.warning("cellSailPlayerBoot(pSelf=*0x%x, userParam=%d)", pSelf, userParam); { - CellSailEvent event; + CellSailEvent event{}; event.u32x2.major = CELL_SAIL_EVENT_PLAYER_STATE_CHANGED; event.u32x2.minor = 0; pSelf->callback(ppu, pSelf->callbackArg, event, CELL_SAIL_PLAYER_STATE_BOOT_TRANSITION, 0); @@ -788,7 +788,7 @@ error_code cellSailPlayerBoot(ppu_thread& ppu, vm::ptr pSelf, u6 pSelf->booted = true; { - CellSailEvent event; + CellSailEvent event{}; event.u32x2.major = CELL_SAIL_EVENT_PLAYER_CALL_COMPLETED; event.u32x2.minor = CELL_SAIL_PLAYER_CALL_BOOT; pSelf->callback(ppu, pSelf->callbackArg, event, 0, 0); diff --git a/rpcs3/Emu/Io/recording_config.h b/rpcs3/Emu/Io/recording_config.h index e08e73acfe..5c3ec20165 100644 --- a/rpcs3/Emu/Io/recording_config.h +++ b/rpcs3/Emu/Io/recording_config.h @@ -28,9 +28,7 @@ struct cfg_recording final : cfg::node node_audio(cfg::node* _this) : cfg::node(_this, "Audio") {} cfg::uint<0x10000, 0x17000> audio_codec{this, "AVCodecID", 86019}; // AVCodecID::AV_CODEC_ID_AC3 - cfg::uint<0, 8> channels{this, "Channels", 2}; cfg::uint<0, 25000000> audio_bps{this, "Audio Bitrate", 320000}; - cfg::uint<0, 25000000> sample_rate{this, "Sample Rate", 48000}; } audio{ this }; diff --git a/rpcs3/Loader/PSF.cpp b/rpcs3/Loader/PSF.cpp index 7d7e878bee..e455a71404 100644 --- a/rpcs3/Loader/PSF.cpp +++ b/rpcs3/Loader/PSF.cpp @@ -295,7 +295,7 @@ namespace psf for (const auto& entry : psf) { - def_table_t index; + def_table_t index{}; index.key_off = ::narrow(key_offset); index.param_fmt = entry.second.type(); index.param_len = entry.second.size(); @@ -313,7 +313,7 @@ namespace psf key_offset = utils::align(key_offset, 4); // Generate header - header_t header; + header_t header{}; header.magic = "\0PSF"_u32; header.version = 0x101; header.off_key_table = ::narrow(sizeof(header_t) + sizeof(def_table_t) * psf.size()); diff --git a/rpcs3/rpcs3qt/gs_frame.cpp b/rpcs3/rpcs3qt/gs_frame.cpp index 55adbe4423..1b3b3eb03c 100644 --- a/rpcs3/rpcs3qt/gs_frame.cpp +++ b/rpcs3/rpcs3qt/gs_frame.cpp @@ -504,8 +504,7 @@ 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_cfg_recording.audio.sample_rate); - //m_video_encoder->set_audio_channels(static_cast(g_fxo->get().cfg.backend_ch_cnt)); + m_video_encoder->set_sample_rate(g_fxo->get().cfg.audio_sampling_rate); m_video_encoder->set_audio_channels(static_cast(g_fxo->get().cfg.audio_channels)); m_video_encoder->set_audio_bitrate(g_cfg_recording.audio.audio_bps); m_video_encoder->set_audio_codec(g_cfg_recording.audio.audio_codec); diff --git a/rpcs3/util/media_utils.h b/rpcs3/util/media_utils.h index 08c770de10..899a7a75bc 100644 --- a/rpcs3/util/media_utils.h +++ b/rpcs3/util/media_utils.h @@ -73,7 +73,7 @@ namespace utils u32 set_next_index(bool next); shared_mutex m_mtx; - const s32 sample_rate = 48000; + static constexpr s32 sample_rate = 48000; std::vector data; atomic_t m_size = 0; atomic_t track_fully_decoded{0};