mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-12-04 00:20:50 +00:00
A port without a configured device opened SDL's default capture device, which SDL moves to a new default when the host's default input changes (unplugging a DualSense, for one); after that move SDL2 copies blocks sized for the new device into a scratch buffer sized for the old one. Ports now open the host's default input by name and, before a capture, reopen on the current default when their device stopped or the default changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
630 lines
23 KiB
C++
630 lines
23 KiB
C++
#include "prx/libSceAudioIn/include/AudioIn.hpp"
|
|
#include "prx/libkernel_sys/include/Api.hpp"
|
|
#include "prx/libSceAudioIn/AudioInCapture.hpp"
|
|
#include "prx/libSceAudioIn/AudioInDeviceSelection.hpp"
|
|
#include "prx/libSceAudioIn/AudioInOpenWithin.hpp"
|
|
#include <cstdint>
|
|
#include <cstddef>
|
|
#include <cerrno>
|
|
#include <charconv>
|
|
#include <cstdlib>
|
|
#include "SceTypes.hpp"
|
|
#include "prx/libc/include/General.hpp"
|
|
#include "prx/libc/include/PreciseWait.hpp"
|
|
#include "SDL.h"
|
|
#include <algorithm>
|
|
#include <array>
|
|
#include <atomic>
|
|
#include <chrono>
|
|
#include <cstring>
|
|
#include <mutex>
|
|
#include <string>
|
|
#include <string_view>
|
|
#include <thread>
|
|
#include <stdexcept>
|
|
#include "prx/libScePad/include/HostAudioInControl.hpp"
|
|
#ifdef _WIN32
|
|
#ifndef NOMINMAX
|
|
#define NOMINMAX
|
|
#endif
|
|
#include <windows.h>
|
|
#endif
|
|
|
|
|
|
namespace {
|
|
|
|
constexpr int AUDIO_IN_ERROR_INVALID_HANDLE = static_cast<int>(0x80260101);
|
|
constexpr int AUDIO_IN_ERROR_INVALID_SIZE = static_cast<int>(0x80260102);
|
|
constexpr int AUDIO_IN_ERROR_INVALID_FREQ = static_cast<int>(0x80260103);
|
|
constexpr int AUDIO_IN_ERROR_INVALID_TYPE = static_cast<int>(0x80260104);
|
|
constexpr int AUDIO_IN_ERROR_INVALID_POINTER = static_cast<int>(0x80260105);
|
|
constexpr int AUDIO_IN_ERROR_INVALID_PARAM = static_cast<int>(0x80260106);
|
|
constexpr int AUDIO_IN_ERROR_PORT_FULL = static_cast<int>(0x80260107);
|
|
constexpr int AUDIO_IN_ERROR_INVALID_STATE = static_cast<int>(0x80260109);
|
|
constexpr int AUDIO_IN_ERROR_BUSY = static_cast<int>(0x8026010A);
|
|
constexpr int AUDIO_IN_ERROR_INVALID_DEVICE = static_cast<int>(0x8026010F);
|
|
constexpr int AUDIO_IN_SILENT_STATE_DEVICE_NONE = 1;
|
|
constexpr std::uint32_t HANDLE_BASE = 0x30000000;
|
|
constexpr std::uint32_t MAX_QUEUED_BLOCKS = 4;
|
|
constexpr std::size_t MAX_CAPTURE_BYTES = 0x100u * 2u * sizeof(float);
|
|
|
|
using Clock = std::chrono::steady_clock;
|
|
|
|
struct Format {
|
|
SDL_AudioFormat format;
|
|
std::uint8_t channels;
|
|
};
|
|
|
|
struct Port {
|
|
bool used = false;
|
|
bool busy = false;
|
|
std::uint32_t samples = 0;
|
|
std::uint32_t frameBytes = 0;
|
|
SDL_AudioDeviceID device = 0;
|
|
Clock::duration grain{};
|
|
Clock::time_point next{};
|
|
std::int32_t mode = 0;
|
|
bool opening = false;
|
|
std::uint32_t freq = 0;
|
|
Format format{};
|
|
std::string defaultInput;
|
|
Clock::time_point nextDefaultInputCheck{};
|
|
};
|
|
|
|
bool isOpen(const Port& port) { return port.used && !port.opening; }
|
|
|
|
constexpr auto DEFAULT_INPUT_CHECK = std::chrono::seconds(1);
|
|
|
|
std::string defaultInputName() {
|
|
char* name = nullptr;
|
|
SDL_AudioSpec spec{};
|
|
if (SDL_GetDefaultAudioInfo(&name, &spec, 1) != 0 || name == nullptr) return {};
|
|
std::string result(name);
|
|
SDL_free(name);
|
|
return result;
|
|
}
|
|
|
|
std::mutex g_mutex;
|
|
std::mutex g_openMutex;
|
|
std::array<Port, 8> g_ports{};
|
|
bool g_sdlAudio = false;
|
|
std::atomic<bool> g_openStalled{false};
|
|
std::int32_t g_mode = 0;
|
|
constexpr std::chrono::milliseconds OPEN_LIMIT{3000};
|
|
|
|
audioin::detail::CaptureMuteGenerations g_captureMuteGenerations;
|
|
|
|
bool formatOf(std::uint32_t param, Format& format) {
|
|
static constexpr std::uint8_t channels[] = {1, 1, 2};
|
|
if ((param & 0xf) > 2) return false;
|
|
const std::uint32_t encoding = param & 0xf0;
|
|
if (encoding != 0 && encoding != 0x10) return false;
|
|
format = {static_cast<SDL_AudioFormat>(encoding == 0x10 ? AUDIO_F32SYS : AUDIO_S16SYS), channels[param & 0xf]};
|
|
return true;
|
|
}
|
|
|
|
SDL_AudioDeviceID openDevice(std::uint32_t freq, std::uint32_t samples, const Format& format, std::string_view requestedName, std::string& defaultInput) {
|
|
defaultInput.clear();
|
|
if (!g_sdlAudio) {
|
|
if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) return 0;
|
|
g_sdlAudio = true;
|
|
}
|
|
SDL_AudioSpec desired{};
|
|
desired.freq = static_cast<int>(freq);
|
|
desired.format = format.format;
|
|
desired.channels = format.channels;
|
|
desired.samples = static_cast<Uint16>(samples);
|
|
auto selection = audioin::detail::selectCaptureDevice(requestedName, 0,
|
|
[](int index) { return SDL_GetAudioDeviceName(index, 1); });
|
|
if (selection.kind != audioin::detail::CaptureDeviceMatchKind::Default) {
|
|
selection = audioin::detail::selectCaptureDevice(requestedName, SDL_GetNumAudioDevices(1),
|
|
[](int index) { return SDL_GetAudioDeviceName(index, 1); });
|
|
}
|
|
if (selection.kind == audioin::detail::CaptureDeviceMatchKind::Missing ||
|
|
selection.kind == audioin::detail::CaptureDeviceMatchKind::Ambiguous) return 0;
|
|
std::string selectedName;
|
|
const bool named = selection.kind == audioin::detail::CaptureDeviceMatchKind::Found;
|
|
if (named) {
|
|
const char* name = SDL_GetAudioDeviceName(selection.index, 1);
|
|
if (!name) return 0;
|
|
selectedName = name;
|
|
} else {
|
|
selectedName = defaultInputName();
|
|
}
|
|
if (g_openStalled.load(std::memory_order_acquire)) return 0;
|
|
std::chrono::milliseconds delay{};
|
|
if (const char* stall = std::getenv("ANYPS5_TEST_AUDIO_IN_OPEN_STALL_MS")) {
|
|
const char* end = stall + std::strlen(stall);
|
|
unsigned int milliseconds = 0;
|
|
const auto parsed = std::from_chars(stall, end, milliseconds);
|
|
if (parsed.ec == std::errc{} && parsed.ptr == end && milliseconds <= 10000) {
|
|
delay = std::chrono::milliseconds(milliseconds);
|
|
}
|
|
}
|
|
const auto opened = audioin::detail::openWithin(OPEN_LIMIT,
|
|
[selectedName, desired, delay]() mutable {
|
|
SDL_AudioSpec obtained{};
|
|
if (delay.count() != 0) std::this_thread::sleep_for(delay);
|
|
const char* deviceName = !selectedName.empty() ? selectedName.c_str() : nullptr;
|
|
const SDL_AudioDeviceID device = SDL_OpenAudioDevice(deviceName, 1, &desired, &obtained, 0);
|
|
if (device != 0) SDL_PauseAudioDevice(device, 0);
|
|
return static_cast<std::uint32_t>(device);
|
|
},
|
|
[](std::uint32_t device) { SDL_CloseAudioDevice(device); },
|
|
[] { g_openStalled.store(true, std::memory_order_release); },
|
|
[] { g_openStalled.store(false, std::memory_order_release); });
|
|
if (opened.device != 0 && !named) defaultInput = selectedName;
|
|
return opened.device;
|
|
}
|
|
|
|
void followDefaultInput(Port& port, std::unique_lock<std::mutex>& lock) {
|
|
if (port.device == 0 || port.defaultInput.empty()) return;
|
|
bool replace = SDL_GetAudioDeviceStatus(port.device) == SDL_AUDIO_STOPPED;
|
|
const auto now = Clock::now();
|
|
if (!replace && now >= port.nextDefaultInputCheck) {
|
|
port.nextDefaultInputCheck = now + DEFAULT_INPUT_CHECK;
|
|
const auto name = defaultInputName();
|
|
replace = !name.empty() && name != port.defaultInput;
|
|
}
|
|
if (!replace) return;
|
|
const SDL_AudioDeviceID oldDevice = port.device;
|
|
const std::uint32_t freq = port.freq;
|
|
const std::uint32_t samples = port.samples;
|
|
const Format format = port.format;
|
|
port.device = 0;
|
|
g_captureMuteGenerations.Forget(oldDevice);
|
|
lock.unlock();
|
|
std::string newDefaultInput;
|
|
SDL_AudioDeviceID newDevice = 0;
|
|
{
|
|
std::lock_guard openLock(g_openMutex);
|
|
SDL_CloseAudioDevice(oldDevice);
|
|
newDevice = openDevice(freq, samples, format, {}, newDefaultInput);
|
|
}
|
|
lock.lock();
|
|
port.device = newDevice;
|
|
port.defaultInput = std::move(newDefaultInput);
|
|
port.nextDefaultInputCheck = Clock::now() + DEFAULT_INPUT_CHECK;
|
|
}
|
|
|
|
int findPort(int handle, Port** port) {
|
|
const std::uint32_t raw = static_cast<std::uint32_t>(handle);
|
|
if ((raw & 0x7f000000u) != HANDLE_BASE || (raw & 0xffu) >= g_ports.size()) return AUDIO_IN_ERROR_INVALID_HANDLE;
|
|
Port& candidate = g_ports[raw & 0xffu];
|
|
if (!isOpen(candidate)) return AUDIO_IN_ERROR_INVALID_STATE;
|
|
*port = &candidate;
|
|
return 0;
|
|
}
|
|
|
|
int checkArguments(std::uint32_t type, std::uint32_t index, std::uint32_t len, std::uint32_t freq) {
|
|
if (len != 0x100 && len != 0x80) return AUDIO_IN_ERROR_INVALID_SIZE;
|
|
if (freq != 48000 && freq != 16000) return AUDIO_IN_ERROR_INVALID_FREQ;
|
|
if (type > 5) return AUDIO_IN_ERROR_INVALID_TYPE;
|
|
if (index != 0) return AUDIO_IN_ERROR_INVALID_PARAM;
|
|
return 0;
|
|
}
|
|
|
|
int checkDeviceArguments(std::uint32_t type, std::uint32_t len, std::uint32_t freq) {
|
|
if (type > 5) return AUDIO_IN_ERROR_INVALID_TYPE;
|
|
if (freq != 48000 && freq != 16000) return AUDIO_IN_ERROR_INVALID_FREQ;
|
|
if (len != 0x100 && len != 0x80) return AUDIO_IN_ERROR_INVALID_SIZE;
|
|
return 0;
|
|
}
|
|
|
|
int checkMicLevel(int type, int level) {
|
|
if (static_cast<std::uint32_t>(level) > 100) return AUDIO_IN_ERROR_INVALID_PARAM;
|
|
const std::uint32_t kind = static_cast<std::uint32_t>(type);
|
|
if (kind < 1u || kind > 4u) return AUDIO_IN_ERROR_INVALID_DEVICE;
|
|
return 0;
|
|
}
|
|
|
|
int checkMuteType(int type) {
|
|
const std::uint32_t index = static_cast<std::uint32_t>(type) & 0x7fffffffu;
|
|
if (index - 1 > 6 || !(0x6fu >> (index - 1) & 1u)) return AUDIO_IN_ERROR_INVALID_DEVICE;
|
|
return 0;
|
|
}
|
|
|
|
void applyMode(int mode, int value) {
|
|
if (mode == 0) {
|
|
std::lock_guard lock(g_mutex);
|
|
g_mode = value;
|
|
}
|
|
}
|
|
|
|
int openPort(std::uint32_t len, std::uint32_t freq, std::uint32_t param) {
|
|
Format format{};
|
|
if (!formatOf(param, format)) return AUDIO_IN_ERROR_INVALID_PARAM;
|
|
#ifdef _WIN32
|
|
std::string requestedName;
|
|
if (const auto* configuredName = _wgetenv(L"ANYPS5_AUDIO_IN_DEVICE")) {
|
|
const int bytes = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, configuredName, -1, nullptr, 0, nullptr, nullptr);
|
|
if (bytes == 0) return AUDIO_IN_ERROR_INVALID_DEVICE;
|
|
requestedName.resize(static_cast<std::size_t>(bytes));
|
|
if (WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, configuredName, -1, requestedName.data(), bytes, nullptr, nullptr) != bytes) {
|
|
return AUDIO_IN_ERROR_INVALID_DEVICE;
|
|
}
|
|
requestedName.pop_back();
|
|
}
|
|
#else
|
|
const char* const configuredName = std::getenv("ANYPS5_AUDIO_IN_DEVICE");
|
|
const std::string_view requestedName = configuredName ? std::string_view(configuredName) : std::string_view{};
|
|
#endif
|
|
const bool explicitDevice = !requestedName.empty() && requestedName != "default";
|
|
std::unique_lock lock(g_mutex);
|
|
std::size_t slot = g_ports.size();
|
|
for (std::size_t i = g_ports.size(); i-- > 0;) {
|
|
if (!g_ports[i].used) {
|
|
slot = i;
|
|
break;
|
|
}
|
|
}
|
|
if (slot == g_ports.size()) return AUDIO_IN_ERROR_PORT_FULL;
|
|
g_ports[slot] = {};
|
|
g_ports[slot].used = true;
|
|
g_ports[slot].opening = true;
|
|
lock.unlock();
|
|
std::string defaultInput;
|
|
SDL_AudioDeviceID device = 0;
|
|
{
|
|
std::lock_guard openLock(g_openMutex);
|
|
device = openDevice(freq, len, format, requestedName, defaultInput);
|
|
}
|
|
lock.lock();
|
|
if (explicitDevice && device == 0) {
|
|
g_ports[slot] = {};
|
|
return AUDIO_IN_ERROR_INVALID_DEVICE;
|
|
}
|
|
const auto frameBytes = static_cast<std::uint32_t>(SDL_AUDIO_BITSIZE(format.format) / 8 * format.channels);
|
|
const auto grain = std::chrono::duration_cast<Clock::duration>(std::chrono::microseconds(1000000ull * len / freq));
|
|
g_ports[slot] = {true, false, len, frameBytes, device, grain, {}, g_mode, false, freq, format, std::move(defaultInput), Clock::now() + DEFAULT_INPUT_CHECK};
|
|
return static_cast<int>(HANDLE_BASE + slot);
|
|
}
|
|
|
|
std::size_t capture(SDL_AudioDeviceID device, std::uint8_t* dest, std::size_t bytes, Clock::time_point deadline) {
|
|
const std::uint64_t muteState = HostAudioInMuteState_nid_no_patch();
|
|
const std::uint64_t generation = muteState >> 1;
|
|
if (g_captureMuteGenerations.Observe(device, generation)) SDL_ClearQueuedAudio(device);
|
|
while (SDL_GetQueuedAudioSize(device) < bytes && Clock::now() < deadline) PreciseSleepUs(1000);
|
|
const std::size_t queued = SDL_GetQueuedAudioSize(device);
|
|
std::array<std::uint8_t, 4096> discard;
|
|
const std::size_t excess = queued > bytes * MAX_QUEUED_BLOCKS ? queued - bytes * MAX_QUEUED_BLOCKS : 0;
|
|
audioin::detail::discardQueuedAudio(excess, discard.data(), discard.size(),
|
|
[device](std::uint8_t* dest, std::uint32_t chunk) { return SDL_DequeueAudio(device, dest, chunk); });
|
|
const std::size_t captured = SDL_DequeueAudio(device, dest, static_cast<Uint32>(bytes));
|
|
const std::uint64_t finalMuteState = HostAudioInMuteState_nid_no_patch();
|
|
const bool muted = (muteState & 1u) != 0 || (finalMuteState & 1u) != 0 || muteState != finalMuteState;
|
|
const std::size_t delivered = audioin::detail::filterCapturedSamples(dest, bytes, captured, muted);
|
|
if (muted) SDL_ClearQueuedAudio(device);
|
|
return delivered;
|
|
}
|
|
|
|
struct ErrnoGuard {
|
|
int saved = errno;
|
|
ErrnoGuard() = default;
|
|
ErrnoGuard(const ErrnoGuard&) = delete;
|
|
ErrnoGuard& operator=(const ErrnoGuard&) = delete;
|
|
~ErrnoGuard() { errno = saved; }
|
|
};
|
|
|
|
}
|
|
|
|
extern "C" {
|
|
|
|
int APS5_VABI sceAudioInInit() {
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceAudioInGetSilentState(int handle) {
|
|
std::lock_guard lock(g_mutex);
|
|
Port* port;
|
|
if (const int error = findPort(handle, &port)) return error;
|
|
return port->device != 0 ? 0 : AUDIO_IN_SILENT_STATE_DEVICE_NONE;
|
|
}
|
|
|
|
int APS5_VABI sceAudioInInput(int handle, void* dest) {
|
|
ErrnoGuard errnoGuard;
|
|
std::unique_lock lock(g_mutex);
|
|
Port* port;
|
|
if (const int error = findPort(handle, &port)) return error;
|
|
if (port->busy) return AUDIO_IN_ERROR_BUSY;
|
|
if (!dest) {
|
|
if (port->device != 0) SDL_ClearQueuedAudio(port->device);
|
|
port->next = {};
|
|
return 0;
|
|
}
|
|
const std::size_t bytes = static_cast<std::size_t>(port->samples) * port->frameBytes;
|
|
if (bytes > MAX_CAPTURE_BYTES) throw std::logic_error("AudioIn capture block exceeds supported format");
|
|
port->busy = true;
|
|
followDefaultInput(*port, lock);
|
|
const SDL_AudioDeviceID device = port->device;
|
|
const auto now = Clock::now();
|
|
const auto wake = port->next > now ? port->next : now;
|
|
port->next = wake + port->grain;
|
|
const auto deadline = now + port->grain * MAX_QUEUED_BLOCKS;
|
|
const int samples = static_cast<int>(port->samples);
|
|
lock.unlock();
|
|
|
|
std::array<std::uint8_t, MAX_CAPTURE_BYTES> block;
|
|
std::size_t captured = 0;
|
|
if (device != 0) {
|
|
captured = capture(device, block.data(), bytes, deadline);
|
|
} else {
|
|
PreciseSleepUntil(wake);
|
|
}
|
|
std::memset(block.data() + captured, 0, bytes - captured);
|
|
const bool copied = GuestCopyOut_nid_no_patch(dest, block.data(), bytes);
|
|
lock.lock();
|
|
port->busy = false;
|
|
if (!copied) return AUDIO_IN_ERROR_INVALID_POINTER;
|
|
return samples;
|
|
}
|
|
|
|
int APS5_VABI sceAudioInOpen(int user_id, uint32_t type, uint32_t index, uint32_t len, uint32_t freq, uint32_t param) {
|
|
(void)user_id;
|
|
if (const int error = checkArguments(type, index, len, freq); error != 0) return error;
|
|
if (sceKernelIsPs4Process()) {
|
|
if (freq != 16000) return AUDIO_IN_ERROR_INVALID_FREQ;
|
|
if (len != 0x100) return AUDIO_IN_ERROR_INVALID_SIZE;
|
|
if (param > 1) return AUDIO_IN_ERROR_INVALID_PARAM;
|
|
}
|
|
return openPort(len, freq, param);
|
|
}
|
|
|
|
int32_t APS5_VABI sceAudioInClose(int32_t handle) {
|
|
std::lock_guard lock(g_mutex);
|
|
Port* port;
|
|
if (const int error = findPort(handle, &port)) return error;
|
|
if (port->busy) return AUDIO_IN_ERROR_BUSY;
|
|
if (port->device != 0) {
|
|
g_captureMuteGenerations.Forget(port->device);
|
|
SDL_CloseAudioDevice(port->device);
|
|
}
|
|
*port = {};
|
|
return 0;
|
|
}
|
|
|
|
int32_t APS5_VABI sceAudioInHqOpen(int32_t userId, uint32_t type, uint32_t index, uint32_t len, uint32_t freq, uint32_t param) {
|
|
if (freq != 48000) return AUDIO_IN_ERROR_INVALID_FREQ;
|
|
if (len != 128) return AUDIO_IN_ERROR_INVALID_SIZE;
|
|
if (param != 2) return AUDIO_IN_ERROR_INVALID_PARAM;
|
|
if (const int error = checkArguments(type, index, len, freq); error != 0) return error;
|
|
return openPort(len, freq, param);
|
|
}
|
|
|
|
int32_t APS5_VABI sceAudioInAsyncOpen(int32_t userId, uint32_t type, uint32_t index, uint32_t len, uint32_t freq, uint32_t param) {
|
|
if (freq != 48000) return AUDIO_IN_ERROR_INVALID_FREQ;
|
|
if (len != 128) return AUDIO_IN_ERROR_INVALID_SIZE;
|
|
if (const int error = checkArguments(type, index, len, freq); error != 0) return error;
|
|
return openPort(len, freq, param);
|
|
}
|
|
|
|
int32_t APS5_VABI sceAudioInIsPadEmbeddedMic(int32_t handle) {
|
|
const std::uint32_t index = static_cast<std::uint32_t>(handle) & 0xffu;
|
|
std::lock_guard lock(g_mutex);
|
|
if (index >= g_ports.size() || !isOpen(g_ports[index])) return AUDIO_IN_ERROR_INVALID_STATE;
|
|
return 0;
|
|
}
|
|
|
|
int32_t APS5_VABI sceAudioInGetGain(int32_t handle, float* gain) {
|
|
if (!gain) return AUDIO_IN_ERROR_INVALID_POINTER;
|
|
constexpr float defaultGain = 1.0f;
|
|
ErrnoGuard errnoGuard;
|
|
if (!GuestCopyOut_nid_no_patch(gain, &defaultGain, sizeof(defaultGain))) {
|
|
return AUDIO_IN_ERROR_INVALID_POINTER;
|
|
}
|
|
std::lock_guard lock(g_mutex);
|
|
Port* port;
|
|
if (const int error = findPort(handle, &port)) return error;
|
|
return 0;
|
|
}
|
|
|
|
int32_t APS5_VABI sceAudioInGetRerouteCount(int32_t handle) {
|
|
std::lock_guard lock(g_mutex);
|
|
Port* port;
|
|
if (const int error = findPort(handle, &port)) return error;
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceAudioInDeviceIdOpen(int userId, std::uint32_t type, std::uint32_t deviceId, std::uint32_t len, std::uint32_t freq, std::uint32_t param) {
|
|
(void)userId;
|
|
(void)deviceId;
|
|
if (const int error = checkDeviceArguments(type, len, freq)) return error;
|
|
return openPort(len, freq, param);
|
|
}
|
|
|
|
int APS5_VABI sceAudioInDeviceIdAsyncOpen(int userId, std::uint32_t type, std::uint32_t deviceId, std::uint32_t len, std::uint32_t freq, std::uint32_t param) {
|
|
return sceAudioInDeviceIdOpen(userId, type, deviceId, len, freq, param);
|
|
}
|
|
|
|
int APS5_VABI sceAudioInSetUsbGain(void) {
|
|
NotImplemented_nid_no_patch(__func__);
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceAudioInIsSharedDevice(int handle) {
|
|
const std::uint32_t index = static_cast<std::uint32_t>(handle) & 0xffu;
|
|
{
|
|
std::lock_guard lock(g_mutex);
|
|
if (index >= g_ports.size() || !isOpen(g_ports[index])) return AUDIO_IN_ERROR_INVALID_STATE;
|
|
}
|
|
NotImplemented_nid_no_patch(__func__);
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceAudioInDeviceIdHqOpen(int userId, std::uint32_t type, std::uint32_t deviceId, std::uint32_t len, std::uint32_t freq, std::uint32_t param) {
|
|
return sceAudioInDeviceIdOpen(userId, type, deviceId, len, freq, param);
|
|
}
|
|
|
|
int APS5_VABI sceAudioInDeviceHqOpen(int userId, std::uint32_t deviceId, std::uint32_t len, std::uint32_t freq, std::uint32_t param) {
|
|
(void)userId;
|
|
(void)deviceId;
|
|
if (const int error = checkDeviceArguments(4, len, freq)) return error;
|
|
return openPort(len, freq, param);
|
|
}
|
|
|
|
int APS5_VABI sceAudioInSetConnections(void) {
|
|
NotImplemented_nid_no_patch(__func__);
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceAudioInSetPortConnections(void) {
|
|
NotImplemented_nid_no_patch(__func__);
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceAudioInSetPortStatuses(void) {
|
|
NotImplemented_nid_no_patch(__func__);
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceAudioInGetHandleStatusInfo(int handle, void* info) {
|
|
(void)info;
|
|
ErrnoGuard errnoGuard;
|
|
{
|
|
std::lock_guard lock(g_mutex);
|
|
Port* port;
|
|
if (const int error = findPort(handle, &port)) return error;
|
|
}
|
|
NotImplemented_nid_no_patch(__func__);
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceAudioInOpenEx(int user_id, uint32_t type, uint32_t index, uint32_t extra, uint32_t len, uint32_t freq, uint32_t param) {
|
|
(void)extra;
|
|
return sceAudioInOpen(user_id, type, index, len, freq, param);
|
|
}
|
|
|
|
int APS5_VABI sceAudioInHqOpenEx(int user_id, uint32_t type, uint32_t index, uint32_t extra, uint32_t len, uint32_t freq, uint32_t param) {
|
|
(void)extra;
|
|
return sceAudioInOpen(user_id, type, index, len, freq, param);
|
|
}
|
|
|
|
int APS5_VABI sceAudioInDeviceOpenEx(int userId, std::uint32_t type, std::uint32_t deviceId, std::uint32_t extra, std::uint32_t len, std::uint32_t freq, std::uint32_t param) {
|
|
(void)extra;
|
|
return sceAudioInDeviceIdOpen(userId, type, deviceId, len, freq, param);
|
|
}
|
|
|
|
int APS5_VABI sceAudioInChangeAppModuleState(void) {
|
|
NotImplemented_nid_no_patch(__func__);
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceAudioInSetSparkParam(void) {
|
|
NotImplemented_nid_no_patch(__func__);
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceAudioInSetSparkSideTone(void) {
|
|
NotImplemented_nid_no_patch(__func__);
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceAudioInSetCompressorPreGain(void) {
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceAudioInSetNoiseGateThreshold(void) {
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceAudioInSetMicLevel(int type, std::uint64_t device, int level, int arg4, int arg5) {
|
|
(void)device;
|
|
(void)arg4;
|
|
(void)arg5;
|
|
if (const int error = checkMicLevel(type, level)) return error;
|
|
NotImplemented_nid_no_patch(__func__);
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceAudioInSetMicrophoneLevel(int type, std::uint64_t device, int level, int arg) {
|
|
(void)device;
|
|
(void)arg;
|
|
if (const int error = checkMicLevel(type, level)) return error;
|
|
NotImplemented_nid_no_patch(__func__);
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceAudioInSetDeviceMuteStatus(int type, std::uint64_t device, int mute) {
|
|
(void)device;
|
|
(void)mute;
|
|
if (const int error = checkMuteType(type)) return error;
|
|
NotImplemented_nid_no_patch(__func__);
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceAudioInSetDevConnection(void) {
|
|
NotImplemented_nid_no_patch(__func__);
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceAudioInCountPorts(std::int16_t type, std::int16_t index, std::int16_t arg3, std::int32_t arg4) {
|
|
(void)type;
|
|
(void)index;
|
|
(void)arg3;
|
|
(void)arg4;
|
|
NotImplemented_nid_no_patch(__func__);
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceAudioInSetUserMute(int type, std::uint64_t device, int mute) {
|
|
(void)device;
|
|
(void)mute;
|
|
if (const int error = checkMuteType(type)) return error;
|
|
NotImplemented_nid_no_patch(__func__);
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceAudioInVmicCreate(int userId, std::uint32_t len, std::uint32_t freq, std::uint32_t param) {
|
|
(void)userId;
|
|
(void)param;
|
|
if (len != 0x100 && len != 0x80) return AUDIO_IN_ERROR_INVALID_SIZE;
|
|
if (freq != 48000 && freq != 16000) return AUDIO_IN_ERROR_INVALID_FREQ;
|
|
NotImplemented_nid_no_patch(__func__);
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceAudioInVmicDestroy(void) {
|
|
NotImplemented_nid_no_patch(__func__);
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceAudioInVmicWrite(void) {
|
|
NotImplemented_nid_no_patch(__func__);
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceAudioInVmicGetStatus(void) {
|
|
NotImplemented_nid_no_patch(__func__);
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceAudioInVmicSetMute(void) {
|
|
NotImplemented_nid_no_patch(__func__);
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceAudioInSetMode2(int mode, int value, void* arg) {
|
|
(void)arg;
|
|
applyMode(mode, value);
|
|
NotImplemented_nid_no_patch(__func__);
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceAudioInSetMode(int mode, int value) {
|
|
applyMode(mode, value);
|
|
NotImplemented_nid_no_patch(__func__);
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceAudioInExtCtrl(void) {
|
|
NotImplemented_nid_no_patch(__func__);
|
|
return 0;
|
|
}
|
|
|
|
int APS5_VABI sceAudioInInputs(void) {
|
|
NotImplemented_nid_no_patch(__func__);
|
|
return 0;
|
|
}
|
|
|
|
}
|