sdl2_sink: Check for null string when loading SDL audio devices

Attempting to place a null string into a vector of strings causes an
error that closes the application.

Don't.
This commit is contained in:
lat9nq 2022-10-16 03:14:52 -04:00
parent d574bb4610
commit 5c7eef3756

View file

@ -230,7 +230,10 @@ std::vector<std::string> ListSDLSinkDevices(bool capture) {
const int device_count = SDL_GetNumAudioDevices(capture);
for (int i = 0; i < device_count; ++i) {
device_list.emplace_back(SDL_GetAudioDeviceName(i, 0));
const char* name = SDL_GetAudioDeviceName(i, 0);
if (name != nullptr) {
device_list.emplace_back(name);
}
}
return device_list;