mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-22 18:15:14 +00:00
+
This commit is contained in:
parent
84e8c2c884
commit
2116c1dae4
@ -97,9 +97,15 @@ int PS4_SYSV_ABI sceAudioInGetSilentState() {
|
||||
return ORBIS_OK;
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI sceAudioInHqOpen() {
|
||||
LOG_ERROR(Lib_AudioIn, "(STUBBED) called");
|
||||
return ORBIS_OK;
|
||||
int PS4_SYSV_ABI sceAudioInHqOpen(Libraries::UserService::OrbisUserServiceUserId userId, u32 type,
|
||||
u32 index, u32 len, u32 freq, u32 param) {
|
||||
LOG_ERROR(Lib_AudioIn, "called");
|
||||
int result = audio->AudioInOpen(type, len, freq, param);
|
||||
if (result == -1) {
|
||||
LOG_ERROR(Lib_AudioOut, "Audio ports are full");
|
||||
return 0x80260005;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI sceAudioInHqOpenEx() {
|
||||
@ -128,13 +134,13 @@ int PS4_SYSV_ABI sceAudioInIsSharedDevice() {
|
||||
|
||||
int PS4_SYSV_ABI sceAudioInOpen(Libraries::UserService::OrbisUserServiceUserId userId, u32 type,
|
||||
u32 index, u32 len, u32 freq, u32 param) {
|
||||
LOG_ERROR(Lib_AudioIn, "called");
|
||||
int result = audio->AudioInOpen(type, len, freq, param);
|
||||
if (result == -1) {
|
||||
LOG_ERROR(Lib_AudioOut, "Audio ports are full");
|
||||
return 0x80260005;
|
||||
}
|
||||
return result;
|
||||
LOG_ERROR(Lib_AudioIn, "called");
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI sceAudioInOpenEx() {
|
||||
|
@ -33,7 +33,8 @@ int PS4_SYSV_ABI sceAudioInGetGain();
|
||||
int PS4_SYSV_ABI sceAudioInGetHandleStatusInfo();
|
||||
int PS4_SYSV_ABI sceAudioInGetRerouteCount();
|
||||
int PS4_SYSV_ABI sceAudioInGetSilentState();
|
||||
int PS4_SYSV_ABI sceAudioInHqOpen();
|
||||
int PS4_SYSV_ABI sceAudioInHqOpen(Libraries::UserService::OrbisUserServiceUserId userId, u32 type,
|
||||
u32 index, u32 len, u32 freq, u32 param);
|
||||
int PS4_SYSV_ABI sceAudioInHqOpenEx();
|
||||
int PS4_SYSV_ABI sceAudioInInit();
|
||||
int PS4_SYSV_ABI sceAudioInInput(s32 handle, void* dest);
|
||||
|
@ -9,10 +9,9 @@ int SDLAudioIn::AudioInit() {
|
||||
}
|
||||
|
||||
int SDLAudioIn::AudioInOpen(int type, uint32_t samples_num, uint32_t freq, uint32_t format) {
|
||||
using Libraries::AudioIn::OrbisAudioInParam;
|
||||
std::scoped_lock lock{m_mutex};
|
||||
|
||||
for (int id = 0; id < portsIn.size(); id++) {
|
||||
for (int id = 0; id < static_cast<int>(portsIn.size()); ++id) {
|
||||
auto& port = portsIn[id];
|
||||
if (!port.isOpen) {
|
||||
port.isOpen = true;
|
||||
@ -23,12 +22,12 @@ int SDLAudioIn::AudioInOpen(int type, uint32_t samples_num, uint32_t freq, uint3
|
||||
|
||||
SDL_AudioFormat sampleFormat;
|
||||
switch (format) {
|
||||
case 0:
|
||||
case Libraries::AudioIn::ORBIS_AUDIO_IN_PARAM_FORMAT_S16_MONO:
|
||||
sampleFormat = SDL_AUDIO_S16;
|
||||
port.channels_num = 1;
|
||||
port.sample_size = 2;
|
||||
break;
|
||||
case 2:
|
||||
case Libraries::AudioIn::ORBIS_AUDIO_IN_PARAM_FORMAT_S16_STEREO:
|
||||
sampleFormat = SDL_AUDIO_S16;
|
||||
port.channels_num = 2;
|
||||
port.sample_size = 2;
|
||||
@ -48,26 +47,31 @@ int SDLAudioIn::AudioInOpen(int type, uint32_t samples_num, uint32_t freq, uint3
|
||||
nullptr, nullptr);
|
||||
if (!port.stream) {
|
||||
port.isOpen = false;
|
||||
return -1;
|
||||
return ORBIS_AUDIO_IN_ERROR_INVALID_PORT;
|
||||
}
|
||||
|
||||
if (SDL_ResumeAudioStreamDevice(port.stream) == false) {
|
||||
SDL_DestroyAudioStream(port.stream);
|
||||
port = {};
|
||||
return ORBIS_AUDIO_IN_ERROR_STREAM_FAIL;
|
||||
}
|
||||
|
||||
SDL_ResumeAudioDevice(SDL_GetAudioStreamDevice(port.stream));
|
||||
return id + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
return ORBIS_AUDIO_IN_ERROR_INVALID_PORT;
|
||||
}
|
||||
|
||||
int SDLAudioIn::AudioInInput(int handle, void* out_buffer) {
|
||||
std::scoped_lock lock{m_mutex};
|
||||
if (handle < 1 || handle > portsIn.size())
|
||||
|
||||
if (handle < 1 || handle > static_cast<int>(portsIn.size()) || !out_buffer)
|
||||
return ORBIS_AUDIO_IN_ERROR_INVALID_PORT;
|
||||
|
||||
auto& port = portsIn[handle - 1];
|
||||
if (!port.isOpen || out_buffer == nullptr) {
|
||||
if (!port.isOpen)
|
||||
return ORBIS_AUDIO_IN_ERROR_INVALID_PORT;
|
||||
}
|
||||
|
||||
const int bytesToRead = port.samples_num * port.sample_size * port.channels_num;
|
||||
|
||||
@ -90,19 +94,19 @@ int SDLAudioIn::AudioInInput(int handle, void* out_buffer) {
|
||||
}
|
||||
}
|
||||
|
||||
int result = SDL_GetAudioStreamData(port.stream, out_buffer, bytesToRead);
|
||||
if (result < 0) {
|
||||
const int bytesRead = SDL_GetAudioStreamData(port.stream, out_buffer, bytesToRead);
|
||||
if (bytesRead < 0) {
|
||||
// SDL_GetAudioStreamData failed
|
||||
SDL_Log("AudioInInput error: %s", SDL_GetError());
|
||||
return ORBIS_AUDIO_IN_ERROR_STREAM_FAIL;
|
||||
}
|
||||
|
||||
return result;
|
||||
const int framesRead = bytesRead / (port.sample_size * port.channels_num);
|
||||
return framesRead;
|
||||
}
|
||||
|
||||
void SDLAudioIn::AudioInClose(int handle) {
|
||||
std::scoped_lock lock{m_mutex};
|
||||
if (handle < 1 || handle > portsIn.size())
|
||||
if (handle < 1 || handle > (int)portsIn.size())
|
||||
return;
|
||||
|
||||
auto& port = portsIn[handle - 1];
|
||||
@ -110,5 +114,5 @@ void SDLAudioIn::AudioInClose(int handle) {
|
||||
return;
|
||||
|
||||
SDL_DestroyAudioStream(port.stream);
|
||||
port.isOpen = false;
|
||||
}
|
||||
port = {};
|
||||
}
|
@ -186,7 +186,7 @@ int PS4_SYSV_ABI sceHttpGetAcceptEncodingGZIPEnabled() {
|
||||
|
||||
int PS4_SYSV_ABI sceHttpGetAllResponseHeaders() {
|
||||
LOG_ERROR(Lib_Http, "(STUBBED) called");
|
||||
return ORBIS_OK;
|
||||
return ORBIS_FAIL;
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI sceHttpGetAuthEnabled() {
|
||||
|
Loading…
Reference in New Issue
Block a user