Running Simple Duplex example on Android #461
-
Hi David! I just found out about this library today and I think it's awesome! I'm trying to run the Simple Duplex example on Android, but for some reason the data callback is never called. The stream seems to open successfully with
This is my first time reading C code, so, I'm guessing I might be missing a step or something.
I also tried iterating through the available device IDs (on the java side), and passed my wired headset's source and sink device ID's to the
Maybe I'm not handling the type casting properly.
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
This was tested on Samsung Galaxy S10 (Android 12) and Samsung Galaxy S7 (Android 8) |
Beta Was this translation helpful? Give feedback.
-
So there's a couple of things wrong here. The The device ID thing is incorrect. You would probably want to do something like this: deviceConfig.capture.pDeviceID.aaudio = inputDeviceID; |
Beta Was this translation helpful? Give feedback.
-
Oh yeah, I did read about that in the documentation, but I still managed to miss it. |
Beta Was this translation helpful? Give feedback.
-
There were two inline compiler errors, so I changed
This caused a crash. (last line in the log)
Passing Passing
|
Beta Was this translation helpful? Give feedback.
So there's a couple of things wrong here. The
ma_device
object (and all objects in miniaudio for that matter) are transparent structs and not references. You're declaring thema_device
object on the stack, but then as soon asma_device_start()
returns, you're returning fromJava_com_testlib_example_MainActivity_test()
which will be destroying yourma_device
object. Thema_device_config
struct is not used afterma_device_init()
, so it's fine to leave that on the stack. I'm suspecting this might be the cause of your issues with this one.The device ID thing is incorrect. You would probably want to do something like this: