realnc / SDL_audiolib

An audio decoding, resampling and mixing library for SDL.
GNU Lesser General Public License v3.0
43 stars 8 forks source link

Allow Aulib::init on a specified device #21

Closed glebm closed 3 years ago

realnc commented 3 years ago

Let's just use const std::string& for this instead of char*.

glebm commented 3 years ago

The underlying API and the querying method both accept char *, so this would just be an unnecessary conversion, no?

realnc commented 3 years ago

The underlying API is C, the API we provide is C++, so std::string makes the most sense here. If this was anything where performance matters, we would instead provide an overload for const char* as well. But it's just the init() functions. It's not gonna get called in a tight loop or anything :)

glebm commented 3 years ago

Fair enough

glebm commented 3 years ago

what's a nullptr string?

realnc commented 3 years ago

what's a nullptr string?

There is none, but just use an empty string in those cases. So:

const std::string& device = {}

Then check if it's empty of course and pass nullptr to SDL if it is.

glebm commented 3 years ago

I guess this assumes we can never have an empty string device name?

glebm commented 3 years ago

oh well, could also be an std::optional<std::string> but that's not available in GCC 6 (well there is std::experimental::optional)

glebm commented 3 years ago

Done

realnc commented 3 years ago

I'm not aware that it's possible for a device name to be empty. Could be wrong of course, but that would be rather weird?

glebm commented 3 years ago

Yeah probably not a use case that's super important to support even if it does happen