-
Notifications
You must be signed in to change notification settings - Fork 53
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
DeviceInfo.Name function returns a string with null bytes in it #28
Comments
@Keithcat1 can you send PR? |
Keithcat1
added a commit
to Keithcat1/malgo
that referenced
this issue
Sep 16, 2021
… longer directly passable to Miniaudio. This is to avoide subtle errors where Miniaudio updates, an internal struct field type changes, and suddenly your app is crashing for no good reason because the Malgo version of the Info struct is still using the old types, some field offsets are all wrong ETC. Before this, Malgo could crash on 32-bit Windows. Now CGO resolves struct field offsets and we just convert between C and Go. DeviceInfo now uses anonymous structs just like Miniaudio. The advantage of this is that everything is in one place and looks nicer in docs, and we can remove a bunch of types that are only ever used in device info and clutter up the docs. Added the DeviceInfo.toCRepr() and deviceInfoFromCRepr method and function which convert between C and Go representations of DeviceInfo. All fields with type uint32 are now type int, meaning you usually need less type conversions. Many Go functions just use int by default and converting between everything is annoying. Name is now type string instead of type [256]char and we use C.GoString to properly convert it into a Go string. We could probably convert it to a string instead using string(info.Name[:firstZeroByte]), but whatever. Fixes gen2brain#28. Added the Formats field which is a slice of FormatType. This replaces the old Formats and FormatCount fields and does a better job than both of them combined, which is basically what it is. Breaking change because the types of nearly all if not all fields has changed. Nothing else has changed.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Go strings shouldn't normally have null bytes, and this breaks stuff expecting them not to. Normally you convert a C string to a Go string with the C.GoString function, it takes a pointer to a C string and returns a Go string.
The text was updated successfully, but these errors were encountered: