Skip to content

Commit

Permalink
Remove newlines from device names in GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
gavv committed Oct 31, 2023
1 parent ca85281 commit fa9cced
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/base/io/AlsaDeviceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,23 @@

namespace signal_estimator {

namespace {

void chomp(char* buffer) {
size_t len = strlen(buffer);

if (len == 0) {
return;
}

while (buffer[len - 1] == '\n') {
buffer[len - 1] = '\0';
len--;
}
}

} // namespace

std::vector<std::string> AlsaDeviceManager::get_output_devices() {
char buffer[128];
std::vector<std::string> strvec;
Expand All @@ -24,6 +41,7 @@ std::vector<std::string> AlsaDeviceManager::get_output_devices() {
// if line has both card and device in it
if (std::strstr(buffer, "card") != nullptr
&& std::strstr(buffer, "device") != nullptr) {
chomp(buffer);
strvec.emplace_back(buffer);
}
}
Expand All @@ -43,6 +61,7 @@ std::vector<std::string> AlsaDeviceManager::get_input_devices() {
// if line has both card and device in it
if (std::strstr(buffer, "card") != nullptr
&& std::strstr(buffer, "device") != nullptr) {
chomp(buffer);
strvec.emplace_back(buffer);
}
}
Expand Down

0 comments on commit fa9cced

Please sign in to comment.