mackron / dr_libs

Audio decoding libraries for C/C++, each in a single source file.
Other
1.24k stars 205 forks source link

How to use this on Android NDK? #241

Closed mavavilj closed 1 year ago

mavavilj commented 2 years ago

I've been trying to use this library on Android NDK, but I'm struggling with drwav_init_file failing even when I provide it a valid path.

Some example code for this would be useful.

BTW, my code works perfectly on my desktop (just change the path). But when I change the path to one got through JNI (/storage/emulated/0/Music/test.wav), then drwav_init_file fails as if the file path is invalid.

mavavilj commented 2 years ago

BTW, when printing the errno given by drwav_init_file it says:

socket operation on non-socket

Even when I see nothing about sockets.

OTOH, fopen on the same filepath seems to work.

mackron commented 2 years ago

dr_wav uses fopen(). I don't know what the rules are with fopen() and Android and when you can and can't use it - Android is not a platform I do frequent development on. You can do a search for drwav_result drwav_fopen to see what dr_wav is doing. It should be hitting one of the branches in the screenshot below. Maybe put a breakpoint on there to see how it's getting called.

image