Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cellAudio: log some more audio backend info #15355

Merged
merged 4 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions rpcs3/Emu/Audio/Cubeb/CubebBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ bool CubebBackend::Open(std::string_view dev_id, AudioFreq freq, AudioSampleSize
device.ch_cnt = 2;
}

Cubeb.notice("Channel count is %d", device.ch_cnt);

if (use_default_device)
{
std::lock_guard lock{m_state_cb_mutex};
Expand Down
2 changes: 2 additions & 0 deletions rpcs3/Emu/Audio/FAudio/FAudioBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ bool FAudioBackend::Open(std::string_view dev_id, AudioFreq freq, AudioSampleSiz
return false;
}

FAudio_.notice("Channel count is %d", vd.InputChannels);

m_sampling_rate = freq;
m_sample_size = sample_size;
m_channels = static_cast<AudioChannelCnt>(std::min(static_cast<u32>(convert_channel_count(vd.InputChannels)), static_cast<u32>(ch_cnt)));;
Expand Down
2 changes: 2 additions & 0 deletions rpcs3/Emu/Audio/XAudio2/XAudio2Backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ bool XAudio2Backend::Open(std::string_view dev_id, AudioFreq freq, AudioSampleSi
return false;
}

XAudio.notice("Channel count is %d", vd.InputChannels);

m_sampling_rate = freq;
m_sample_size = sample_size;
m_channels = static_cast<AudioChannelCnt>(std::min(static_cast<u32>(convert_channel_count(vd.InputChannels)), static_cast<u32>(ch_cnt)));
Expand Down
1 change: 1 addition & 0 deletions rpcs3/Emu/Cell/Modules/cellAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ void cell_audio_config::reset(bool backend_changed)
{
cb_frame_len = backend->GetCallbackFrameLen();
ch_cnt = backend->get_channels();
cellAudio.notice("Opened audio backend (sampling_rate=%d, sample_size=%d, channels=%d)", backend->get_sampling_rate(), backend->get_sample_size(), backend->get_channels());
}
else
{
Expand Down
94 changes: 28 additions & 66 deletions rpcs3/Emu/Cell/Modules/cellPad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void cellPad_NotifyStateChange(usz index, u64 /*state*/, bool locked)
// NOTE 1: The state's CONNECTED bit should currently be identical to the current
// m_port_status CONNECTED bit when called from our pad handlers.
// NOTE 2: Make sure to propagate all other status bits to the reported status.
const u32 new_status = pads[index]->m_port_status;
const u32 new_status = pad->m_port_status;

if (~(old_status ^ new_status) & CELL_PAD_STATUS_CONNECTED)
{
Expand Down Expand Up @@ -188,17 +188,11 @@ error_code cellPadInit(ppu_thread& ppu, u32 max_connect)
config.port_setting.fill(CELL_PAD_SETTING_PRESS_OFF | CELL_PAD_SETTING_SENSOR_OFF);
config.reported_info = {};

std::array<s32, CELL_MAX_PADS> statuses{};

const auto handler = pad::get_current_handler();

const auto& pads = handler->GetPads();

for (usz i = 0; i < statuses.size(); ++i)
for (usz i = 0; i < config.get_max_connect(); ++i)
{
if (i >= config.get_max_connect())
break;

if (pads[i]->m_port_status & CELL_PAD_STATUS_CONNECTED)
{
send_sys_io_connect_event(i, CELL_PAD_STATUS_CONNECTED);
Expand Down Expand Up @@ -255,16 +249,14 @@ error_code cellPadClearBuf(u32 port_no)
if (!config.max_connect)
return CELL_PAD_ERROR_UNINITIALIZED;

const auto handler = pad::get_current_handler();

if (port_no >= CELL_MAX_PADS)
return CELL_PAD_ERROR_INVALID_PARAMETER;

const auto& pads = handler->GetPads();

if (port_no >= config.get_max_connect())
return CELL_PAD_ERROR_NO_DEVICE;

const auto handler = pad::get_current_handler();
const auto& pads = handler->GetPads();
const auto& pad = pads[port_no];

if (!config.is_reportedly_connected(port_no) || !(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
Expand Down Expand Up @@ -618,16 +610,14 @@ error_code cellPadGetData(u32 port_no, vm::ptr<CellPadData> data)
if (!config.max_connect)
return CELL_PAD_ERROR_UNINITIALIZED;

const auto handler = pad::get_current_handler();

if (port_no >= CELL_MAX_PADS || !data)
return CELL_PAD_ERROR_INVALID_PARAMETER;

const auto& pads = handler->GetPads();

if (port_no >= config.get_max_connect())
return CELL_PAD_ERROR_NO_DEVICE;

const auto handler = pad::get_current_handler();
const auto& pads = handler->GetPads();
const auto& pad = pads[port_no];

if (!config.is_reportedly_connected(port_no) || !(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
Expand All @@ -648,11 +638,10 @@ error_code cellPadPeriphGetInfo(vm::ptr<CellPadPeriphInfo> info)
if (!config.max_connect)
return CELL_PAD_ERROR_UNINITIALIZED;

const auto handler = pad::get_current_handler();

if (!info)
return CELL_PAD_ERROR_INVALID_PARAMETER;

const auto handler = pad::get_current_handler();
const PadInfo& rinfo = handler->GetInfo();

std::memset(info.get_ptr(), 0, sizeof(CellPadPeriphInfo));
Expand All @@ -662,11 +651,8 @@ error_code cellPadPeriphGetInfo(vm::ptr<CellPadPeriphInfo> info)

u32 now_connect = 0;

for (u32 i = 0; i < CELL_PAD_MAX_PORT_NUM; ++i)
for (u32 i = 0; i < config.get_max_connect(); ++i)
{
if (i >= config.get_max_connect())
break;

pad_data_internal& reported_info = config.reported_info[i];

info->port_status[i] = reported_info.port_status;
Expand Down Expand Up @@ -703,17 +689,15 @@ error_code cellPadPeriphGetData(u32 port_no, vm::ptr<CellPadPeriphData> data)
if (!config.max_connect)
return CELL_PAD_ERROR_UNINITIALIZED;

const auto handler = pad::get_current_handler();

// port_no can only be 0-6 in this function
if (port_no >= CELL_PAD_MAX_PORT_NUM || !data)
return CELL_PAD_ERROR_INVALID_PARAMETER;

const auto& pads = handler->GetPads();

if (port_no >= config.get_max_connect())
return CELL_PAD_ERROR_NO_DEVICE;

const auto handler = pad::get_current_handler();
const auto& pads = handler->GetPads();
const auto& pad = pads[port_no];

if (!config.is_reportedly_connected(port_no) || !(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
Expand All @@ -738,16 +722,14 @@ error_code cellPadGetRawData(u32 port_no, vm::ptr<CellPadData> data)
if (!config.max_connect)
return CELL_PAD_ERROR_UNINITIALIZED;

const auto handler = pad::get_current_handler();

if (port_no >= CELL_MAX_PADS || !data)
return CELL_PAD_ERROR_INVALID_PARAMETER;

const auto& pads = handler->GetPads();

if (port_no >= config.get_max_connect())
return CELL_PAD_ERROR_NO_DEVICE;

const auto handler = pad::get_current_handler();
const auto& pads = handler->GetPads();
const auto& pad = pads[port_no];

if (!config.is_reportedly_connected(port_no) || !(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
Expand Down Expand Up @@ -793,8 +775,6 @@ error_code cellPadSetActDirect(u32 port_no, vm::ptr<CellPadActParam> param)
if (!config.max_connect)
return CELL_PAD_ERROR_UNINITIALIZED;

const auto handler = pad::get_current_handler();

if (port_no >= CELL_MAX_PADS || !param)
return CELL_PAD_ERROR_INVALID_PARAMETER;

Expand All @@ -809,11 +789,11 @@ error_code cellPadSetActDirect(u32 port_no, vm::ptr<CellPadActParam> param)
}
}

const auto& pads = handler->GetPads();

if (port_no >= config.get_max_connect())
return CELL_PAD_ERROR_NO_DEVICE;

const auto handler = pad::get_current_handler();
const auto& pads = handler->GetPads();
const auto& pad = pads[port_no];

if (!config.is_reportedly_connected(port_no) || !(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
Expand All @@ -839,24 +819,20 @@ error_code cellPadGetInfo(vm::ptr<CellPadInfo> info)
if (!config.max_connect)
return CELL_PAD_ERROR_UNINITIALIZED;

const auto handler = pad::get_current_handler();

if (!info)
return CELL_PAD_ERROR_INVALID_PARAMETER;

std::memset(info.get_ptr(), 0, sizeof(CellPadInfo));

const auto handler = pad::get_current_handler();
const PadInfo& rinfo = handler->GetInfo();
info->max_connect = config.max_connect;
info->system_info = rinfo.system_info;

u32 now_connect = 0;

for (u32 i = 0; i < CELL_MAX_PADS; ++i)
for (u32 i = 0; i < config.get_max_connect(); ++i)
{
if (i >= config.get_max_connect())
break;

pad_data_internal& reported_info = config.reported_info[i];
reported_info.port_status &= ~CELL_PAD_STATUS_ASSIGN_CHANGES; // TODO: should ASSIGN flags be cleared here?

Expand Down Expand Up @@ -888,13 +864,12 @@ error_code cellPadGetInfo2(vm::ptr<CellPadInfo2> info)
if (!config.max_connect)
return CELL_PAD_ERROR_UNINITIALIZED;

const auto handler = pad::get_current_handler();

if (!info)
return CELL_PAD_ERROR_INVALID_PARAMETER;

std::memset(info.get_ptr(), 0, sizeof(CellPadInfo2));

const auto handler = pad::get_current_handler();
const PadInfo& rinfo = handler->GetInfo();
info->max_connect = config.get_max_connect(); // Here it is forcibly clamped
info->system_info = rinfo.system_info;
Expand All @@ -903,11 +878,8 @@ error_code cellPadGetInfo2(vm::ptr<CellPadInfo2> info)

const auto& pads = handler->GetPads();

for (u32 i = 0; i < CELL_PAD_MAX_PORT_NUM; ++i)
for (u32 i = 0; i < config.get_max_connect(); ++i)
{
if (i >= config.get_max_connect())
break;

pad_data_internal& reported_info = config.reported_info[i];

info->port_status[i] = reported_info.port_status;
Expand Down Expand Up @@ -941,16 +913,14 @@ error_code cellPadGetCapabilityInfo(u32 port_no, vm::ptr<CellPadCapabilityInfo>
if (!config.max_connect)
return CELL_PAD_ERROR_UNINITIALIZED;

const auto handler = pad::get_current_handler();

if (port_no >= CELL_MAX_PADS || !info)
return CELL_PAD_ERROR_INVALID_PARAMETER;

const auto& pads = handler->GetPads();

if (port_no >= config.get_max_connect())
return CELL_PAD_ERROR_NO_DEVICE;

const auto handler = pad::get_current_handler();
const auto& pads = handler->GetPads();
const auto& pad = pads[port_no];

if (!config.is_reportedly_connected(port_no) || !(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
Expand Down Expand Up @@ -999,16 +969,14 @@ error_code cellPadInfoPressMode(u32 port_no)
if (!config.max_connect)
return CELL_PAD_ERROR_UNINITIALIZED;

const auto handler = pad::get_current_handler();

if (port_no >= CELL_MAX_PADS)
return CELL_PAD_ERROR_INVALID_PARAMETER;

const auto& pads = handler->GetPads();

if (port_no >= config.get_max_connect())
return CELL_PAD_ERROR_NO_DEVICE;

const auto handler = pad::get_current_handler();
const auto& pads = handler->GetPads();
const auto& pad = pads[port_no];

if (!config.is_reportedly_connected(port_no) || !(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
Expand All @@ -1028,16 +996,14 @@ error_code cellPadInfoSensorMode(u32 port_no)
if (!config.max_connect)
return CELL_PAD_ERROR_UNINITIALIZED;

const auto handler = pad::get_current_handler();

if (port_no >= CELL_MAX_PADS)
return CELL_PAD_ERROR_INVALID_PARAMETER;

const auto& pads = handler->GetPads();

if (port_no >= config.get_max_connect())
return CELL_PAD_ERROR_NO_DEVICE;

const auto handler = pad::get_current_handler();
const auto& pads = handler->GetPads();
const auto& pad = pads[port_no];

if (!config.is_reportedly_connected(port_no) || !(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
Expand All @@ -1057,17 +1023,15 @@ error_code cellPadSetPressMode(u32 port_no, u32 mode)
if (!config.max_connect)
return CELL_PAD_ERROR_UNINITIALIZED;

const auto handler = pad::get_current_handler();

if (port_no >= CELL_PAD_MAX_PORT_NUM)
return CELL_PAD_ERROR_INVALID_PARAMETER;

const auto& pads = handler->GetPads();

// CELL_PAD_ERROR_NO_DEVICE is not returned in this case.
if (port_no >= CELL_PAD_MAX_PORT_NUM)
return CELL_OK;

const auto handler = pad::get_current_handler();
const auto& pads = handler->GetPads();
const auto& pad = pads[port_no];

// TODO: find out if this is checked here or later or at all
Expand All @@ -1093,17 +1057,15 @@ error_code cellPadSetSensorMode(u32 port_no, u32 mode)
if (!config.max_connect)
return CELL_PAD_ERROR_UNINITIALIZED;

const auto handler = pad::get_current_handler();

if (port_no >= CELL_MAX_PADS)
return CELL_PAD_ERROR_INVALID_PARAMETER;

const auto& pads = handler->GetPads();

// CELL_PAD_ERROR_NO_DEVICE is not returned in this case.
if (port_no >= CELL_PAD_MAX_PORT_NUM)
return CELL_OK;

const auto handler = pad::get_current_handler();
const auto& pads = handler->GetPads();
const auto& pad = pads[port_no];

// TODO: find out if this is checked here or later or at all
Expand Down
14 changes: 7 additions & 7 deletions rpcs3/rpcs3qt/pad_settings_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,13 @@ pad_settings_dialog::pad_settings_dialog(std::shared_ptr<gui_settings> gui_setti
// Refresh Button
connect(ui->b_refresh, &QPushButton::clicked, this, &pad_settings_dialog::RefreshHandlers);

ui->chooseClass->addItem(tr("Standard (Pad)"), u32{CELL_PAD_PCLASS_TYPE_STANDARD});
ui->chooseClass->addItem(tr("Guitar"), u32{CELL_PAD_PCLASS_TYPE_GUITAR});
ui->chooseClass->addItem(tr("Drum"), u32{CELL_PAD_PCLASS_TYPE_DRUM});
ui->chooseClass->addItem(tr("DJ"), u32{CELL_PAD_PCLASS_TYPE_DJ});
ui->chooseClass->addItem(tr("Dance Mat"), u32{CELL_PAD_PCLASS_TYPE_DANCEMAT});
ui->chooseClass->addItem(tr("Navigation"), u32{CELL_PAD_PCLASS_TYPE_NAVIGATION});
ui->chooseClass->addItem(tr("Skateboard"), u32{CELL_PAD_PCLASS_TYPE_SKATEBOARD});
ui->chooseClass->addItem(tr("Standard (Pad)"), u32{CELL_PAD_PCLASS_TYPE_STANDARD});
ui->chooseClass->addItem(tr("Guitar"), u32{CELL_PAD_PCLASS_TYPE_GUITAR});
ui->chooseClass->addItem(tr("Drum"), u32{CELL_PAD_PCLASS_TYPE_DRUM});
ui->chooseClass->addItem(tr("DJ"), u32{CELL_PAD_PCLASS_TYPE_DJ});
ui->chooseClass->addItem(tr("Dance Mat"), u32{CELL_PAD_PCLASS_TYPE_DANCEMAT});
ui->chooseClass->addItem(tr("PS Move Navigation"), u32{CELL_PAD_PCLASS_TYPE_NAVIGATION});
ui->chooseClass->addItem(tr("Skateboard"), u32{CELL_PAD_PCLASS_TYPE_SKATEBOARD});

connect(ui->chooseClass, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this](int index)
{
Expand Down