mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-04-20 11:35:45 +00:00
improvements in audio
This commit is contained in:
parent
57dd19f798
commit
c9076e4ef9
3 changed files with 14 additions and 4 deletions
|
@ -3,13 +3,14 @@
|
|||
|
||||
#include <SDL.h>
|
||||
#include "sdl_audio.h"
|
||||
namespace Audio {
|
||||
|
||||
int SDLAudio::AudioInit() {
|
||||
return SDL_InitSubSystem(SDL_INIT_AUDIO);
|
||||
}
|
||||
|
||||
int SDLAudio::AudioOutOpen(int type, u32 samples_num, u32 freq, u32 format) {
|
||||
std::scoped_lock{m_mutex};
|
||||
std::scoped_lock lock{m_mutex};
|
||||
for (int id = 0; id < portsOut.size(); id++) {
|
||||
auto& port = portsOut[id];
|
||||
if (!port.isOpen) {
|
||||
|
@ -24,3 +25,5 @@ int SDLAudio::AudioOutOpen(int type, u32 samples_num, u32 freq, u32 format) {
|
|||
|
||||
return -1; // all ports are used
|
||||
}
|
||||
|
||||
} // namespace Audio
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
#include "src/common/types.h"
|
||||
|
||||
namespace Audio {
|
||||
|
||||
class SDLAudio {
|
||||
public:
|
||||
SDLAudio() = default;
|
||||
|
@ -27,4 +29,6 @@ private:
|
|||
};
|
||||
std::mutex m_mutex;
|
||||
std::array<PortOut, 8> portsOut; // main support up to 8 ports
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace Audio
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
namespace Libraries::AudioOut {
|
||||
|
||||
static std::unique_ptr<Audio::SDLAudio> audio;
|
||||
|
||||
static std::string_view GetAudioOutPort(u32 port) {
|
||||
switch (port) {
|
||||
case ORBIS_AUDIO_OUT_PORT_TYPE_MAIN:
|
||||
|
@ -189,7 +191,7 @@ int PS4_SYSV_ABI sceAudioOutGetSystemState() {
|
|||
}
|
||||
|
||||
int PS4_SYSV_ABI sceAudioOutInit() {
|
||||
auto* audio = Common::Singleton<SDLAudio>::Instance();
|
||||
audio = std::make_unique<Audio::SDLAudio>();
|
||||
u32 result = audio->AudioInit() == 0 ? ORBIS_OK : ORBIS_AUDIO_OUT_ERROR_NOT_INIT;
|
||||
LOG_INFO(Lib_AudioOut, "AudioInit returned {}", result);
|
||||
return result;
|
||||
|
@ -231,7 +233,8 @@ s32 PS4_SYSV_ABI sceAudioOutOpen(UserService::OrbisUserServiceUserId user_id,
|
|||
LOG_INFO(
|
||||
Lib_AudioOut,
|
||||
"AudioOutOpen id = {} port_type = {} index= {} lenght= {} sample_rate= {} param_type= {}",
|
||||
user_id, GetAudioOutPort(port_type), index, length, sample_rate, GetAudioOutParam(param_type));
|
||||
user_id, GetAudioOutPort(port_type), index, length, sample_rate,
|
||||
GetAudioOutParam(param_type));
|
||||
return ORBIS_OK;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue