malgo
malgo copied to clipboard
Allow DeviceInfo to use native Go types
Inspired by https://github.com/gen2brain/malgo/pull/30
This originally come from the requirement to have a consistent device ID which can be stored as a string (for example in a UI select box) and then be used to select the same device later.
Thanks. I don't like including C and header file just for a few constants, is it really needed?
Completely agree! Unfortunately, not including it results in:
../../constants.go:10:10: could not determine what C.ma_bool32 refers to
unless the header is included in the same file.
I tried to maintain the existing format (with constants being in constants.go)
There's a couple of alternates if you prefer:
- I could move the ma_true and ma_false definitions into
device_info.gowhere the header's already included - Change the line
newDevice.IsDefault = device.isDefault == TruetonewDevice.IsDefault = device.isDefault == C.ma_true
Is ma_bool32 really needed? These are just 1 and 0.
Not really. If you're happy hardcoding to those, that makes everything a lot simpler. I've just had upstream libraries I'm wrapping screw around with values you expect to be constant so I'm fairly defensive.
Yes please, that will never change I guess, so hardcoding is fine.
Just for cross-linking, this PR should also fix https://github.com/gen2brain/malgo/issues/28