Closed luigi-rosso closed 8 months ago
Thanks. I support the idea of a ma_decoder_get_encoding_format()
function, but I'm going to sit on this for a bit because I'm not entirely sure I like this particular implementation, specifically with how the vtable pointer is used for discrimination. I'm wondering if a new vtable function should be added instead for querying the format. This would allow it to work for replacement implementations over the stock ones. For example, if someone doesn't like the stock MP3 decoder, they could replace it with their own and the ma_decoder_get_encoding_format()
function can still return a valid encoding format instead of unknown
.
There's another issue that has been raised, and I would like to consider some ideas on how to improve some format stuff before deciding on how I would like to handle this: https://github.com/mackron/miniaudio/issues/765. I support the general idea of this PR though so will leave this open to remind me to look at this.
I've implemented a solution for this, but it's in the dev-0.12 branch which means it won't be released for a while. I ended up going with a callback based approach. A new callback has been added to ma_decoder_backend_vtable
which will be used to report the encoding format.
I would recommend you just stick with your local changes for the time being until I get 0.12 released.
There are cases where we want to show a user the audio format, so being able to retrieve it after a decoder has initialized is helpful. I couldn't find a way to do this with the existing API so I added ma_decoder_get_encoding_format. Let me know if I missed something!