From 7c9a38e0f3f45632c487be1b4072352f5aaf7abf Mon Sep 17 00:00:00 2001 From: Megamouse Date: Mon, 11 Dec 2023 06:51:26 +0100 Subject: [PATCH] rsxaudio: fix ensure order --- rpcs3/Emu/Cell/lv2/sys_rsxaudio.cpp | 61 +++++++++++++---------------- 1 file changed, 28 insertions(+), 33 deletions(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_rsxaudio.cpp b/rpcs3/Emu/Cell/lv2/sys_rsxaudio.cpp index f7ded746a9..7058798787 100644 --- a/rpcs3/Emu/Cell/lv2/sys_rsxaudio.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_rsxaudio.cpp @@ -955,10 +955,8 @@ void rsxaudio_data_thread::update_hw_param(std::function(RsxaudioAvportIdx::AVMULTI)]; } - else - { - return rsxaudio_backend_thread::port_config{static_cast(new_hw_param->spdif_freq_base / new_hw_param->spdif[spdif_idx].freq_div), AudioChannelCnt::STEREO}; - } + + return rsxaudio_backend_thread::port_config{static_cast(new_hw_param->spdif_freq_base / new_hw_param->spdif[spdif_idx].freq_div), AudioChannelCnt::STEREO}; }; port_cfg[static_cast(RsxaudioAvportIdx::SPDIF_0)] = gen_spdif_port_cfg(0); @@ -970,10 +968,8 @@ void rsxaudio_data_thread::update_hw_param(std::function(RsxaudioAvportIdx::SPDIF_1)].freq, new_hw_param->hdmi[hdmi_idx].ch_cfg.total_ch_cnt}; } - else - { - return rsxaudio_backend_thread::port_config{port_cfg[static_cast(RsxaudioAvportIdx::AVMULTI)].freq, new_hw_param->hdmi[hdmi_idx].ch_cfg.total_ch_cnt}; - } + + return rsxaudio_backend_thread::port_config{port_cfg[static_cast(RsxaudioAvportIdx::AVMULTI)].freq, new_hw_param->hdmi[hdmi_idx].ch_cfg.total_ch_cnt}; }; port_cfg[static_cast(RsxaudioAvportIdx::HDMI_0)] = gen_hdmi_port_cfg(0); @@ -1123,10 +1119,8 @@ rsxaudio_backend_thread::avport_bit rsxaudio_data_thread::calc_avport_mute_state // TODO: HW test if both serial and spdif mutes are used in serial mode for spdif return !serial_active || hwp.spdif[spdif_port].freq_div != hwp.serial.freq_div || hwp.serial.muted || hwp.spdif[spdif_port].muted; } - else - { - return !spdif_active[spdif_port] || hwp.spdif[spdif_port].muted; - } + + return !spdif_active[spdif_port] || hwp.spdif[spdif_port].muted; }; auto hdmi_muted = [&](u8 hdmi_idx) @@ -1137,10 +1131,8 @@ rsxaudio_backend_thread::avport_bit rsxaudio_data_thread::calc_avport_mute_state { return spdif_muted(1) || hwp.hdmi[hdmi_port].muted || hwp.hdmi[hdmi_port].force_mute || !hwp.hdmi[hdmi_port].init; } - else - { - return !serial_active || hwp.serial.muted || hwp.hdmi[hdmi_port].muted || hwp.hdmi[hdmi_port].force_mute || !hwp.hdmi[hdmi_port].init; - } + + return !serial_active || hwp.serial.muted || hwp.hdmi[hdmi_port].muted || hwp.hdmi[hdmi_port].force_mute || !hwp.hdmi[hdmi_port].init; }; return { hdmi_muted(0), hdmi_muted(1), avmulti, spdif_muted(0), spdif_muted(1) }; @@ -1159,10 +1151,8 @@ bool rsxaudio_data_thread::calc_port_active_state(RsxaudioPort port, const rsxau { return gen_serial_active() && (hwp.spdif[spdif_idx].freq_div == hwp.serial.freq_div); } - else - { - return hwp.spdif[spdif_idx].dma_en && hwp.spdif[spdif_idx].buf_empty_en && hwp.spdif[spdif_idx].en; - } + + return hwp.spdif[spdif_idx].dma_en && hwp.spdif[spdif_idx].buf_empty_en && hwp.spdif[spdif_idx].en; }; switch (port) @@ -2214,21 +2204,21 @@ rsxaudio_periodic_tmr::wait_result rsxaudio_periodic_tmr::wait(const std::functi { return wait_result::TIMER_ERROR; } - else if (timeout) + + if (timeout) { return wait_result::TIMEOUT; } - else if (wait_canceled) + + if (wait_canceled) { sched_timer(); return wait_result::TIMER_CANCELED; } - else - { - callback(); - sched_timer(); - return wait_result::SUCCESS; - } + + callback(); + sched_timer(); + return wait_result::SUCCESS; } u64 rsxaudio_periodic_tmr::get_rel_next_time() @@ -2299,17 +2289,19 @@ void rsxaudio_periodic_tmr::disable_vtimer(u32 vtimer_id) bool rsxaudio_periodic_tmr::is_vtimer_behind(u32 vtimer_id, u64 crnt_time) const { - const vtimer& vtimer = vtmr_pool[vtimer_id]; ensure(vtimer_id < VTIMER_MAX); + const vtimer& vtimer = vtmr_pool[vtimer_id]; + return is_vtimer_behind(vtimer, crnt_time); } void rsxaudio_periodic_tmr::vtimer_skip_periods(u32 vtimer_id, u64 crnt_time) { - vtimer& vtimer = vtmr_pool[vtimer_id]; ensure(vtimer_id < VTIMER_MAX); + vtimer& vtimer = vtmr_pool[vtimer_id]; + if (is_vtimer_behind(vtimer, crnt_time)) { vtimer.blk_cnt = get_crnt_blk(crnt_time, vtimer.blk_time); @@ -2318,9 +2310,10 @@ void rsxaudio_periodic_tmr::vtimer_skip_periods(u32 vtimer_id, u64 crnt_time) void rsxaudio_periodic_tmr::vtimer_incr(u32 vtimer_id, u64 crnt_time) { - vtimer& vtimer = vtmr_pool[vtimer_id]; ensure(vtimer_id < VTIMER_MAX); + vtimer& vtimer = vtmr_pool[vtimer_id]; + if (is_vtimer_behind(vtimer, crnt_time)) { vtimer.blk_cnt++; @@ -2329,17 +2322,19 @@ void rsxaudio_periodic_tmr::vtimer_incr(u32 vtimer_id, u64 crnt_time) bool rsxaudio_periodic_tmr::is_vtimer_active(u32 vtimer_id) const { - const vtimer& vtimer = vtmr_pool[vtimer_id]; ensure(vtimer_id < VTIMER_MAX); + const vtimer& vtimer = vtmr_pool[vtimer_id]; + return vtimer.active; } u64 rsxaudio_periodic_tmr::vtimer_get_sched_time(u32 vtimer_id) const { - const vtimer& vtimer = vtmr_pool[vtimer_id]; ensure(vtimer_id < VTIMER_MAX); + const vtimer& vtimer = vtmr_pool[vtimer_id]; + return static_cast(vtimer.blk_cnt * vtimer.blk_time); }