Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Spring.GetSoundDevices. #1841

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

saurtron
Copy link
Collaborator

Work Done

  • Add Spring.GetSoundDevices(), returning an array of device names.

Remarks

  • Games having to parse infolog.txt, that seems awkward and fragile.
  • Thought about naming it Spring.GetSoundDeviceNames(), in case later we want to return tables with more information about devices (number of channels...), but I thought maybe later we can just add another argument to make it return everything: Spring.GetSoundDevices(full).
  • Thought about putting this at Platform, but I guess this is not static since devices can come and go.

@saurtron saurtron force-pushed the lua-add-getsounddevices branch from a6e1d9d to fb765a6 Compare December 20, 2024 14:35
@sprunk
Copy link
Collaborator

sprunk commented Dec 20, 2024

Perhaps do it the full way already and return tables?

{
  { .name = "dev1", },
  { .name = "dev2", },
  -- ...
}

rts/Lua/LuaUnsyncedRead.cpp Outdated Show resolved Hide resolved
rts/Lua/LuaUnsyncedRead.cpp Outdated Show resolved Hide resolved
saurtron and others added 2 commits December 20, 2024 23:33
Co-authored-by: sprunk <spr.ng@o2.pl>
Co-authored-by: sprunk <spr.ng@o2.pl>
@saurtron saurtron added the status: candidate PRs that should be good to go or important for next release label Dec 21, 2024
while (*deviceSpecStr != '\0') {
devices.emplace_back(deviceSpecStr);

while (*deviceSpecStr++ != '\0');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it's a copy-paste code from the previous implementation, but it's hard to read and comprehend if it works as it should. Would be great to rewrite it to something more comprehensible like a combo of std::find_if / std::find_if_not

@lhog
Copy link
Collaborator

lhog commented Jan 11, 2025

Overall LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Lua API status: candidate PRs that should be good to go or important for next release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants