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

Reliably comparing two ma_device_id objects for equality #866

Open
vittorioromeo opened this issue Jul 3, 2024 · 2 comments
Open

Reliably comparing two ma_device_id objects for equality #866

vittorioromeo opened this issue Jul 3, 2024 · 2 comments

Comments

@vittorioromeo
Copy link

I am trying to compare to ma_device_id objects to figure out if they refer to the same hardware device. I couldn't find any API function to compare ma_device_id objects, and I considered using std::memcmp, but I am not sure if the ma_device_id object is intended to be compared that way.

Is there a way to reliably compare two ma_device_id for equality, or -- more generally -- check if two hardware devices detected through miniaudio are the same?

@vittorioromeo
Copy link
Author

BTW, using the device name is not an option as there could be multiple devices with the same name.

@mackron
Copy link
Owner

mackron commented Jul 3, 2024

memcmp(&id0, &id1, sizeof(ma_device_id)) should do the job. I thought I actually had a function for comparing device IDs, but looking now it appears that no such function exists. Probably worth adding that. In any case, ma_device_id is explicitly a fixed sized struct, no matter what backends are enabled/disabled, and it should be padded with zeros, so it should be reliable. If I add a function to compare IDs, memcmp() is how I'd be doing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants