Open a dummy audio input device if none is present in the system (#3514)
Some checks failed
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
Update Translation / Update Translation (push) Has been cancelled

This commit is contained in:
Marcin Mikołajczyk 2025-09-17 21:50:47 +02:00 committed by GitHub
parent 775d27c0cd
commit 6ab7aa3b18
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -48,23 +48,27 @@ int SDLAudioIn::AudioInOpen(int type, uint32_t samples_num, uint32_t freq, uint3
std::string micDevStr = Config::getMicDevice();
uint32_t devId;
bool nullDevice = false;
if (micDevStr == "None") {
return ORBIS_AUDIO_IN_ERROR_INVALID_PORT;
nullDevice = true;
} else if (micDevStr == "Default Device") {
devId = SDL_AUDIO_DEVICE_DEFAULT_RECORDING;
} else {
try {
devId = static_cast<uint32_t>(std::stoul(micDevStr));
} 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) {
port.isOpen = false;
return ORBIS_AUDIO_IN_ERROR_INVALID_PORT;
// if stream is null, either due to configuration disabling the input,
// 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) {