mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-20 11:36:13 +00:00
cellAudio: use vm::gvar to allocate working memory
This commit is contained in:
parent
584174d371
commit
76314520ef
2 changed files with 22 additions and 24 deletions
|
@ -10,6 +10,10 @@
|
|||
|
||||
LOG_CHANNEL(cellAudio);
|
||||
|
||||
vm::gvar<char, AUDIO_PORT_OFFSET * AUDIO_PORT_COUNT> g_audio_buffer;
|
||||
|
||||
vm::gvar<u64, AUDIO_PORT_COUNT> g_audio_indices;
|
||||
|
||||
template <>
|
||||
void fmt_class_string<CellAudioError>::format(std::string& out, u64 arg)
|
||||
{
|
||||
|
@ -433,7 +437,7 @@ void cell_audio_thread::advance(u64 timestamp, bool reset)
|
|||
port.timestamp = timestamp;
|
||||
|
||||
port.cur_pos = port.position(1);
|
||||
m_indexes[port.number] = port.cur_pos;
|
||||
g_audio_indices[port.number] = port.cur_pos;
|
||||
}
|
||||
|
||||
if (cfg.buffering_enabled)
|
||||
|
@ -931,20 +935,26 @@ error_code cellAudioInit()
|
|||
{
|
||||
cellAudio.warning("cellAudioInit()");
|
||||
|
||||
const auto buf = vm::cast(vm::alloc(AUDIO_PORT_OFFSET * AUDIO_PORT_COUNT, vm::main));
|
||||
const auto ind = vm::cast(vm::alloc(sizeof(u64) * AUDIO_PORT_COUNT, vm::main));
|
||||
|
||||
// Start audio thread
|
||||
auto g_audio = g_idm->lock<named_thread<cell_audio_thread>>(id_new);
|
||||
|
||||
if (!g_audio)
|
||||
{
|
||||
vm::dealloc(buf);
|
||||
vm::dealloc(ind);
|
||||
return CELL_AUDIO_ERROR_ALREADY_INIT;
|
||||
}
|
||||
|
||||
g_audio.create("cellAudio Thread", buf, ind);
|
||||
std::memset(g_audio_buffer.get_ptr(), 0, g_audio_buffer.alloc_size);
|
||||
std::memset(g_audio_indices.get_ptr(), 0, g_audio_indices.alloc_size);
|
||||
|
||||
g_audio.create("cellAudio Thread");
|
||||
|
||||
for (u32 i = 0; i < AUDIO_PORT_COUNT; i++)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
|
@ -977,12 +987,7 @@ error_code cellAudioQuit(ppu_thread& ppu)
|
|||
|
||||
if (*g_audio.get() == thread_state::finished)
|
||||
{
|
||||
const auto buf = g_audio->ports[0].addr;
|
||||
const auto ind = g_audio->ports[0].index;
|
||||
g_audio.destroy();
|
||||
g_audio.unlock();
|
||||
vm::dealloc(buf.addr());
|
||||
vm::dealloc(ind.addr());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1610,6 +1615,10 @@ error_code cellAudioUnsetPersonalDevice(s32 iPersonalStream)
|
|||
|
||||
DECLARE(ppu_module_manager::cellAudio)("cellAudio", []()
|
||||
{
|
||||
// Private variables
|
||||
REG_VAR(cellAudio, g_audio_buffer).flag(MFF_HIDDEN);
|
||||
REG_VAR(cellAudio, g_audio_indices).flag(MFF_HIDDEN);
|
||||
|
||||
REG_FUNC(cellAudio, cellAudioInit);
|
||||
REG_FUNC(cellAudio, cellAudioPortClose);
|
||||
REG_FUNC(cellAudio, cellAudioPortStop);
|
||||
|
|
|
@ -321,9 +321,6 @@ public:
|
|||
|
||||
class cell_audio_thread
|
||||
{
|
||||
vm::ptr<char> m_buffer;
|
||||
vm::ptr<u64> m_indexes;
|
||||
|
||||
std::unique_ptr<audio_ringbuffer> ringbuffer;
|
||||
|
||||
void reset_ports(s32 offset = 0);
|
||||
|
@ -352,16 +349,8 @@ public:
|
|||
|
||||
void operator()();
|
||||
|
||||
cell_audio_thread(vm::ptr<char> buf, vm::ptr<u64> ind)
|
||||
: m_buffer(buf)
|
||||
, m_indexes(ind)
|
||||
cell_audio_thread()
|
||||
{
|
||||
for (u32 i = 0; i < AUDIO_PORT_COUNT; i++)
|
||||
{
|
||||
ports[i].number = i;
|
||||
ports[i].addr = m_buffer + AUDIO_PORT_OFFSET * i;
|
||||
ports[i].index = m_indexes + i;
|
||||
}
|
||||
}
|
||||
|
||||
audio_port* open_port()
|
||||
|
|
Loading…
Add table
Reference in a new issue