Skip to content

Crashes when dividing device enumerations into functions: Not sure whether it's me or whether I've found a bug. #740

Answered by mackron
day-garwood asked this question in Q&A
Discussion options

You must be logged in to vote

So with ma_context_get_devices() you do not need to allocate your own buffers. That's all managed internally for you. So the process you're using of counting first, then allocating, the enumerating again is incorrect. You can simplify the whole thing by simply doing this once:

ma_device_info* devinfo;
ma_uint32 count;
ma_context_get_devices(ctx, &devinfo, &count, NULL, NULL);

That's it. No need for your count, malloc, enumerate cycle.

However, an important detail. The next time you call ma_context_get_devices(), or when you you uninitialize your context, the devinfo buffer will be deleted, so watch out for that.

ma_device_get_context() is a fully supported public API. It's just a simple g…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by day-garwood
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants