mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-17 08:11:51 +00:00
cellAudio: Some bugfixes
* Reading position storage is 16 bytes aligned according to hw test. * Fix cellAudioGetPortConfig portSize reporting, now matches PS3. * Remove ghost code about unearthly 6 channels cellAudio port mode.
This commit is contained in:
parent
e494fc04e5
commit
d03fcad9bd
@ -12,7 +12,13 @@ LOG_CHANNEL(cellAudio);
|
||||
|
||||
vm::gvar<char, AUDIO_PORT_OFFSET * AUDIO_PORT_COUNT> g_audio_buffer;
|
||||
|
||||
vm::gvar<u64, AUDIO_PORT_COUNT> g_audio_indices;
|
||||
struct alignas(16) aligned_index_t
|
||||
{
|
||||
be_t<u64> index;
|
||||
u8 pad[8];
|
||||
};
|
||||
|
||||
vm::gvar<aligned_index_t, AUDIO_PORT_COUNT> g_audio_indices;
|
||||
|
||||
template <>
|
||||
void fmt_class_string<CellAudioError>::format(std::string& out, u64 arg)
|
||||
@ -335,8 +341,8 @@ void audio_port::tag(s32 offset)
|
||||
// We use -0.0f in case games check if the buffer is empty. -0.0f == 0.0f evaluates to true, but std::signbit can be used to distinguish them
|
||||
const f32 tag = -0.0f;
|
||||
|
||||
const u32 tag_first_pos = num_channels == 2 ? PORT_BUFFER_TAG_FIRST_2CH : num_channels == 6 ? PORT_BUFFER_TAG_FIRST_6CH : PORT_BUFFER_TAG_FIRST_8CH;
|
||||
const u32 tag_delta = num_channels == 2 ? PORT_BUFFER_TAG_DELTA_2CH : num_channels == 6 ? PORT_BUFFER_TAG_DELTA_6CH : PORT_BUFFER_TAG_DELTA_8CH;
|
||||
const u32 tag_first_pos = num_channels == 2 ? PORT_BUFFER_TAG_FIRST_2CH : PORT_BUFFER_TAG_FIRST_8CH;
|
||||
const u32 tag_delta = num_channels == 2 ? PORT_BUFFER_TAG_DELTA_2CH : PORT_BUFFER_TAG_DELTA_8CH;
|
||||
|
||||
for (u32 tag_pos = tag_first_pos, tag_nr = 0; tag_nr < PORT_BUFFER_TAG_COUNT; tag_pos += tag_delta, tag_nr++)
|
||||
{
|
||||
@ -364,8 +370,8 @@ std::tuple<u32, u32, u32, u32> cell_audio_thread::count_port_buffer_tags()
|
||||
auto port_buf = port.get_vm_ptr();
|
||||
|
||||
// Find the last tag that has been touched
|
||||
const u32 tag_first_pos = port.num_channels == 2 ? PORT_BUFFER_TAG_FIRST_2CH : port.num_channels == 6 ? PORT_BUFFER_TAG_FIRST_6CH : PORT_BUFFER_TAG_FIRST_8CH;
|
||||
const u32 tag_delta = port.num_channels == 2 ? PORT_BUFFER_TAG_DELTA_2CH : port.num_channels == 6 ? PORT_BUFFER_TAG_DELTA_6CH : PORT_BUFFER_TAG_DELTA_8CH;
|
||||
const u32 tag_first_pos = port.num_channels == 2 ? PORT_BUFFER_TAG_FIRST_2CH : PORT_BUFFER_TAG_FIRST_8CH;
|
||||
const u32 tag_delta = port.num_channels == 2 ? PORT_BUFFER_TAG_DELTA_2CH : PORT_BUFFER_TAG_DELTA_8CH;
|
||||
|
||||
u32 last_touched_tag_nr = port.prev_touched_tag_nr;
|
||||
bool retouched = false;
|
||||
@ -458,7 +464,7 @@ void cell_audio_thread::advance(u64 timestamp)
|
||||
port.timestamp = timestamp;
|
||||
|
||||
port.cur_pos = port.position(1);
|
||||
g_audio_indices[port.number] = port.cur_pos;
|
||||
*port.index = port.cur_pos;
|
||||
}
|
||||
|
||||
if (cfg.buffering_enabled)
|
||||
@ -1116,7 +1122,7 @@ error_code cellAudioInit()
|
||||
{
|
||||
g_audio.ports[i].number = i;
|
||||
g_audio.ports[i].addr = g_audio_buffer + AUDIO_PORT_OFFSET * i;
|
||||
g_audio.ports[i].index = g_audio_indices + i;
|
||||
g_audio.ports[i].index = (g_audio_indices + i).ptr(&aligned_index_t::index);
|
||||
g_audio.ports[i].state = audio_port_state::closed;
|
||||
}
|
||||
|
||||
@ -1234,7 +1240,7 @@ error_code cellAudioPortOpen(vm::ptr<CellAudioPortParam> audioParam, vm::ptr<u32
|
||||
port->num_channels = ::narrow<u32>(num_channels);
|
||||
port->num_blocks = ::narrow<u32>(num_blocks);
|
||||
port->attr = attr;
|
||||
port->size = ::narrow<u32>(num_channels * num_blocks * port->block_size());
|
||||
port->size = ::narrow<u32>(num_channels * num_blocks * AUDIO_BUFFER_SAMPLES * sizeof(f32));
|
||||
port->cur_pos = 0;
|
||||
port->global_counter = g_audio.m_counter;
|
||||
port->active_counter = 0;
|
||||
@ -1729,18 +1735,6 @@ error_code cellAudioAdd2chData(u32 portNum, vm::ptr<float> src, u32 samples, flo
|
||||
dst[i * 2 + 1] += src[i * 2 + 1] * volume; // mix R ch
|
||||
}
|
||||
}
|
||||
else if (port.num_channels == 6)
|
||||
{
|
||||
for (u32 i = 0; i < samples; i++)
|
||||
{
|
||||
dst[i * 6 + 0] += src[i * 2 + 0] * volume; // mix L ch
|
||||
dst[i * 6 + 1] += src[i * 2 + 1] * volume; // mix R ch
|
||||
//dst[i * 6 + 2] += 0.0f; // center
|
||||
//dst[i * 6 + 3] += 0.0f; // LFE
|
||||
//dst[i * 6 + 4] += 0.0f; // rear L
|
||||
//dst[i * 6 + 5] += 0.0f; // rear R
|
||||
}
|
||||
}
|
||||
else if (port.num_channels == 8)
|
||||
{
|
||||
for (u32 i = 0; i < samples; i++)
|
||||
@ -1789,19 +1783,7 @@ error_code cellAudioAdd6chData(u32 portNum, vm::ptr<float> src, float volume)
|
||||
|
||||
volume = std::isfinite(volume) ? std::clamp(volume, -16.f, 16.f) : 0.f;
|
||||
|
||||
if (port.num_channels == 6)
|
||||
{
|
||||
for (u32 i = 0; i < CELL_AUDIO_BLOCK_SAMPLES; i++)
|
||||
{
|
||||
dst[i * 6 + 0] += src[i * 6 + 0] * volume; // mix L ch
|
||||
dst[i * 6 + 1] += src[i * 6 + 1] * volume; // mix R ch
|
||||
dst[i * 6 + 2] += src[i * 6 + 2] * volume; // mix center
|
||||
dst[i * 6 + 3] += src[i * 6 + 3] * volume; // mix LFE
|
||||
dst[i * 6 + 4] += src[i * 6 + 4] * volume; // mix rear L
|
||||
dst[i * 6 + 5] += src[i * 6 + 5] * volume; // mix rear R
|
||||
}
|
||||
}
|
||||
else if (port.num_channels == 8)
|
||||
if (port.num_channels == 8)
|
||||
{
|
||||
for (u32 i = 0; i < CELL_AUDIO_BLOCK_SAMPLES; i++)
|
||||
{
|
||||
|
@ -111,7 +111,6 @@ enum : u32
|
||||
MAX_AUDIO_EVENT_QUEUES = 64,
|
||||
|
||||
AUDIO_BLOCK_SIZE_2CH = 2 * AUDIO_BUFFER_SAMPLES,
|
||||
AUDIO_BLOCK_SIZE_6CH = 6 * AUDIO_BUFFER_SAMPLES,
|
||||
AUDIO_BLOCK_SIZE_8CH = 8 * AUDIO_BUFFER_SAMPLES,
|
||||
|
||||
PORT_BUFFER_TAG_COUNT = 6,
|
||||
@ -120,10 +119,6 @@ enum : u32
|
||||
PORT_BUFFER_TAG_DELTA_2CH = PORT_BUFFER_TAG_LAST_2CH / (PORT_BUFFER_TAG_COUNT - 1),
|
||||
PORT_BUFFER_TAG_FIRST_2CH = PORT_BUFFER_TAG_LAST_2CH % (PORT_BUFFER_TAG_COUNT - 1),
|
||||
|
||||
PORT_BUFFER_TAG_LAST_6CH = AUDIO_BLOCK_SIZE_6CH - 1,
|
||||
PORT_BUFFER_TAG_DELTA_6CH = PORT_BUFFER_TAG_LAST_6CH / (PORT_BUFFER_TAG_COUNT - 1),
|
||||
PORT_BUFFER_TAG_FIRST_6CH = PORT_BUFFER_TAG_LAST_6CH % (PORT_BUFFER_TAG_COUNT - 1),
|
||||
|
||||
PORT_BUFFER_TAG_LAST_8CH = AUDIO_BLOCK_SIZE_8CH - 1,
|
||||
PORT_BUFFER_TAG_DELTA_8CH = PORT_BUFFER_TAG_LAST_8CH / (PORT_BUFFER_TAG_COUNT - 1),
|
||||
PORT_BUFFER_TAG_FIRST_8CH = PORT_BUFFER_TAG_LAST_8CH % (PORT_BUFFER_TAG_COUNT - 1),
|
||||
|
Loading…
Reference in New Issue
Block a user