mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-12-09 13:19:00 +00:00
Open a dummy audio input device if none is present in the system (#3514)
This commit is contained in:
committed by
GitHub
parent
775d27c0cd
commit
6ab7aa3b18
@@ -48,23 +48,27 @@ int SDLAudioIn::AudioInOpen(int type, uint32_t samples_num, uint32_t freq, uint3
|
|||||||
std::string micDevStr = Config::getMicDevice();
|
std::string micDevStr = Config::getMicDevice();
|
||||||
uint32_t devId;
|
uint32_t devId;
|
||||||
|
|
||||||
|
bool nullDevice = false;
|
||||||
if (micDevStr == "None") {
|
if (micDevStr == "None") {
|
||||||
return ORBIS_AUDIO_IN_ERROR_INVALID_PORT;
|
nullDevice = true;
|
||||||
} else if (micDevStr == "Default Device") {
|
} else if (micDevStr == "Default Device") {
|
||||||
devId = SDL_AUDIO_DEVICE_DEFAULT_RECORDING;
|
devId = SDL_AUDIO_DEVICE_DEFAULT_RECORDING;
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
devId = static_cast<uint32_t>(std::stoul(micDevStr));
|
devId = static_cast<uint32_t>(std::stoul(micDevStr));
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
return ORBIS_AUDIO_IN_ERROR_INVALID_PORT;
|
nullDevice = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
port.stream = SDL_OpenAudioDeviceStream(devId, &fmt, nullptr, nullptr);
|
port.stream =
|
||||||
|
nullDevice ? nullptr : SDL_OpenAudioDeviceStream(devId, &fmt, nullptr, nullptr);
|
||||||
|
|
||||||
if (!port.stream) {
|
if (!port.stream) {
|
||||||
port.isOpen = false;
|
// if stream is null, either due to configuration disabling the input,
|
||||||
return ORBIS_AUDIO_IN_ERROR_INVALID_PORT;
|
// or no input devices present in the system, still return a valid id
|
||||||
|
// as some games require that (e.g. L.A. Noire)
|
||||||
|
return id + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_ResumeAudioStreamDevice(port.stream) == false) {
|
if (SDL_ResumeAudioStreamDevice(port.stream) == false) {
|
||||||
|
|||||||
Reference in New Issue
Block a user