aboutsummaryrefslogtreecommitdiffstats
path: root/alc/backends
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-10-27 19:20:26 -0700
committerChris Robinson <[email protected]>2019-10-27 19:20:26 -0700
commitd37a294d4ce66ea3e5816042457923b72d1bc7c1 (patch)
tree00ed2fa6f5385e2f38080a2e29aa655778c408ad /alc/backends
parent205ff0080edfecb03ddcd24933722851d9fd8206 (diff)
Add a config option for custom ALSA capture devices
Diffstat (limited to 'alc/backends')
-rw-r--r--alc/backends/alsa.cpp34
1 files changed, 16 insertions, 18 deletions
diff --git a/alc/backends/alsa.cpp b/alc/backends/alsa.cpp
index 1b8c6298..7dc3c3c4 100644
--- a/alc/backends/alsa.cpp
+++ b/alc/backends/alsa.cpp
@@ -267,27 +267,25 @@ al::vector<DevMap> probe_devices(snd_pcm_stream_t stream)
GetConfigValue(nullptr, "alsa", (stream==SND_PCM_STREAM_PLAYBACK) ? "device" : "capture",
"default")});
- if(stream == SND_PCM_STREAM_PLAYBACK)
+ const char *customdevs{GetConfigValue(nullptr, "alsa",
+ (stream == SND_PCM_STREAM_PLAYBACK) ? "custom-devices" : "custom-captures", "")};
+ while(const char *curdev{customdevs})
{
- const char *customdevs;
- const char *next{GetConfigValue(nullptr, "alsa", "custom-devices", "")};
- while((customdevs=next) != nullptr && customdevs[0])
+ if(!curdev[0]) break;
+ customdevs = strchr(curdev, ';');
+ const char *sep{strchr(curdev, '=')};
+ if(!sep)
{
- next = strchr(customdevs, ';');
- const char *sep{strchr(customdevs, '=')};
- if(!sep)
- {
- std::string spec{next ? std::string(customdevs, next++) : std::string(customdevs)};
- ERR("Invalid ALSA device specification \"%s\"\n", spec.c_str());
- continue;
- }
-
- const char *oldsep{sep++};
- devlist.emplace_back(DevMap{std::string(customdevs, oldsep),
- next ? std::string(sep, next++) : std::string(sep)});
- const auto &entry = devlist.back();
- TRACE("Got device \"%s\", \"%s\"\n", entry.name.c_str(), entry.device_name.c_str());
+ std::string spec{customdevs ? std::string(curdev, customdevs++) : std::string(curdev)};
+ ERR("Invalid ALSA device specification \"%s\"\n", spec.c_str());
+ continue;
}
+
+ const char *oldsep{sep++};
+ devlist.emplace_back(DevMap{std::string(curdev, oldsep),
+ customdevs ? std::string(sep, customdevs++) : std::string(sep)});
+ const auto &entry = devlist.back();
+ TRACE("Got device \"%s\", \"%s\"\n", entry.name.c_str(), entry.device_name.c_str());
}
const std::string main_prefix{