Files
Ranieri 93e221feaa Feature/runtime ecosystem refactor (#107)
* feat: remove memory and pad from stub section

* feat: add support for resume entry targets in CodeGenerator (this allow jumps in address outside function)
feat: refactor entry point discovery one more try to reduce big generated file

* feat: optmizations for release build

* feat: remove unused  file

* feat: added some test cases for code gen

* feat: added log macro and remove win specific code

* feat: refactor runtime folder structure
feat: added reset sound driver RPC state and compatibility layout
feat: rename and added new test
feat: update RPC calls to use defined constants
feat: added more PSMC(16, 32)
feat: change cd read to try find the asset ignoring case sensitive
fix: fix some render problems
feat: add logs on pad
feat: added more RPC handles

* feat: added game override for code veronica

* feat: apply vita patch

* feat: flags to disable build

* feat: fix merges
feat: break a lot of tests

* feat: better throw error on empty cd path
feat: remove recompiler unusde function
feat: apply missing patch

* feat: gamedp is now part of lib
feat: missing file

* feat: small cleanup

* feat: missing vita changes

* feat: fix more merge

* feat: fix tests

* feat: last missing feature

* feat: added missing import

* feat: rename test local functions

* feat: init syscall on ps2 list

* feat: added DMA helpers

* feat: faster builds
feat: more implement for darkcloud

* feat: back missing file

* feat: added missing includes

* feat: remove test

* feat: missing include

* feat: read register funtion

* feat: build  fix

* feat: force  exit on detach thread
2026-04-04 23:09:56 -03:00

50 lines
1.4 KiB
C++

#ifndef PS2_AUDIO_H
#define PS2_AUDIO_H
#include <cstdint>
#include <memory>
#include <mutex>
#include <unordered_map>
#include <vector>
class PS2AudioBackend
{
public:
PS2AudioBackend();
~PS2AudioBackend();
void onVagTransfer(const uint8_t *rdram, uint32_t srcAddr, uint32_t sizeBytes);
void onVagTransferFromBuffer(const uint8_t *data, uint32_t sizeBytes, uint32_t keyAddr);
void onSoundCommand(uint32_t sid, uint32_t rpcNum,
const uint8_t *sendBuf, uint32_t sendSize,
uint8_t *recvBuf, uint32_t recvSize);
void play(uint32_t sampleAddr, float pitch = 1.0f, float volume = 1.0f,
uint32_t voiceIndex = 0xFFFFFFFFu);
void stop(uint32_t voiceId);
void stopAll();
void setAudioReady(bool ready) { m_audioReady = ready; }
private:
struct DecodedSample
{
std::vector<int16_t> pcm;
uint32_t sampleRate = 44100;
};
struct Impl;
std::unique_ptr<Impl> m_impl;
bool m_audioReady = false;
uint32_t m_mostRecentSampleKey = 0;
std::vector<DecodedSample> m_loadOrderSamples;
std::vector<uint32_t> m_loadOrderSampleKeys;
std::unordered_map<uint32_t, DecodedSample> m_sampleBank;
std::mutex m_mutex;
void playDecodedSample(uint32_t sampleKey, DecodedSample &sample, float pitch, float volume,
bool isBgm = false);
void pruneFinishedSounds();
};
#endif