rsxaudio: fix ensure order

This commit is contained in:
Megamouse 2023-12-11 06:51:26 +01:00
parent f594f485a4
commit 7c9a38e0f3

View File

@ -955,10 +955,8 @@ void rsxaudio_data_thread::update_hw_param(std::function<void(rsxaudio_hw_param_
{ {
return port_cfg[static_cast<u8>(RsxaudioAvportIdx::AVMULTI)]; return port_cfg[static_cast<u8>(RsxaudioAvportIdx::AVMULTI)];
} }
else
{ return rsxaudio_backend_thread::port_config{static_cast<AudioFreq>(new_hw_param->spdif_freq_base / new_hw_param->spdif[spdif_idx].freq_div), AudioChannelCnt::STEREO};
return rsxaudio_backend_thread::port_config{static_cast<AudioFreq>(new_hw_param->spdif_freq_base / new_hw_param->spdif[spdif_idx].freq_div), AudioChannelCnt::STEREO};
}
}; };
port_cfg[static_cast<u8>(RsxaudioAvportIdx::SPDIF_0)] = gen_spdif_port_cfg(0); port_cfg[static_cast<u8>(RsxaudioAvportIdx::SPDIF_0)] = gen_spdif_port_cfg(0);
@ -970,10 +968,8 @@ void rsxaudio_data_thread::update_hw_param(std::function<void(rsxaudio_hw_param_
{ {
return rsxaudio_backend_thread::port_config{port_cfg[static_cast<u8>(RsxaudioAvportIdx::SPDIF_1)].freq, new_hw_param->hdmi[hdmi_idx].ch_cfg.total_ch_cnt}; return rsxaudio_backend_thread::port_config{port_cfg[static_cast<u8>(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<u8>(RsxaudioAvportIdx::AVMULTI)].freq, new_hw_param->hdmi[hdmi_idx].ch_cfg.total_ch_cnt};
return rsxaudio_backend_thread::port_config{port_cfg[static_cast<u8>(RsxaudioAvportIdx::AVMULTI)].freq, new_hw_param->hdmi[hdmi_idx].ch_cfg.total_ch_cnt};
}
}; };
port_cfg[static_cast<u8>(RsxaudioAvportIdx::HDMI_0)] = gen_hdmi_port_cfg(0); port_cfg[static_cast<u8>(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 // 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; 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) 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; 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) }; 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); 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) switch (port)
@ -2214,21 +2204,21 @@ rsxaudio_periodic_tmr::wait_result rsxaudio_periodic_tmr::wait(const std::functi
{ {
return wait_result::TIMER_ERROR; return wait_result::TIMER_ERROR;
} }
else if (timeout)
if (timeout)
{ {
return wait_result::TIMEOUT; return wait_result::TIMEOUT;
} }
else if (wait_canceled)
if (wait_canceled)
{ {
sched_timer(); sched_timer();
return wait_result::TIMER_CANCELED; return wait_result::TIMER_CANCELED;
} }
else
{ callback();
callback(); sched_timer();
sched_timer(); return wait_result::SUCCESS;
return wait_result::SUCCESS;
}
} }
u64 rsxaudio_periodic_tmr::get_rel_next_time() 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 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); ensure(vtimer_id < VTIMER_MAX);
const vtimer& vtimer = vtmr_pool[vtimer_id];
return is_vtimer_behind(vtimer, crnt_time); return is_vtimer_behind(vtimer, crnt_time);
} }
void rsxaudio_periodic_tmr::vtimer_skip_periods(u32 vtimer_id, u64 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); ensure(vtimer_id < VTIMER_MAX);
vtimer& vtimer = vtmr_pool[vtimer_id];
if (is_vtimer_behind(vtimer, crnt_time)) if (is_vtimer_behind(vtimer, crnt_time))
{ {
vtimer.blk_cnt = get_crnt_blk(crnt_time, vtimer.blk_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) void rsxaudio_periodic_tmr::vtimer_incr(u32 vtimer_id, u64 crnt_time)
{ {
vtimer& vtimer = vtmr_pool[vtimer_id];
ensure(vtimer_id < VTIMER_MAX); ensure(vtimer_id < VTIMER_MAX);
vtimer& vtimer = vtmr_pool[vtimer_id];
if (is_vtimer_behind(vtimer, crnt_time)) if (is_vtimer_behind(vtimer, crnt_time))
{ {
vtimer.blk_cnt++; 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 bool rsxaudio_periodic_tmr::is_vtimer_active(u32 vtimer_id) const
{ {
const vtimer& vtimer = vtmr_pool[vtimer_id];
ensure(vtimer_id < VTIMER_MAX); ensure(vtimer_id < VTIMER_MAX);
const vtimer& vtimer = vtmr_pool[vtimer_id];
return vtimer.active; return vtimer.active;
} }
u64 rsxaudio_periodic_tmr::vtimer_get_sched_time(u32 vtimer_id) const u64 rsxaudio_periodic_tmr::vtimer_get_sched_time(u32 vtimer_id) const
{ {
const vtimer& vtimer = vtmr_pool[vtimer_id];
ensure(vtimer_id < VTIMER_MAX); ensure(vtimer_id < VTIMER_MAX);
const vtimer& vtimer = vtmr_pool[vtimer_id];
return static_cast<u64>(vtimer.blk_cnt * vtimer.blk_time); return static_cast<u64>(vtimer.blk_cnt * vtimer.blk_time);
} }