I've run into a blocker when trying to use kotlin ...
# kotlin-native
t
I've run into a blocker when trying to use kotlin native with my project. I created a ticket and a sample project to easily replicate it. Anybody know what may be wrong? https://youtrack.jetbrains.com/issue/KT-53282/Bad-params-issue-with-AudioQueue-on-iOS
a
Maybe replace the AudioPlayer class with an interface, implement it natively in Swift and inject it into your shared logic?
t
That was my plan as a backup if I can't resolve this issue. Ideally we can move that logic into the shared module so that other apps don't have to copy/re-implement the AudioPlayer class. I'm hoping that somebody with more experience than me can look at my sample and point out something dumb that I'm doing. 🙂
l
Not quite the same, but here’s the same result with a different method https://stackoverflow.com/questions/47868043/audioqueuestart-is-returning-error-code-50
Have you tried calling twice?
t
Yes, I did try calling that method twice and I received -50 both times.
l
Why are you reinterpreting the staticCFunction?
t
I thought that it was necessary. I can remove that and give that a try.
l
When there’s an invalid param error, I’d be skeptical of reinterpreting pointers. Too easy to make a mistake.
t
I removed the reinterpret() call, but I still got a -50 when calling AudioQueueNewOutput().
l
When I look at https://developer.apple.com/documentation/audiotoolbox/audioqueueoutputcallback and
Copy code
fun playingCallback(aqDataPointer: CPointer<out CPointed>?,
                            inputAudioQueue: AudioQueueRef?,
                            inBuffer: AudioQueueBufferRef?)
I can’t help but notice the docs don’t list the last two params as nullable.
t
Yeah, I noticed that too. That's why I was wondering if the cinterop didn't map properly.
l
What happens if you remove the reinterpret? Nevermind. Missed your response.
t
It won't compile if I make them non-optional. The parameter for inCallbackProc on AudioQueueNewOutput give me an error since it doesn't match what it is expecting.
l
The data format of the audio to play. For linear PCM, only interleaved formats are supported. Compressed formats are also supported.
You’re using Linear PCM. Is your format interleaved?
t
Honestly, I need to look up the definition of interleaved with respect to linear audio. The settings in the AudioStreamBasicDescription are the same as the values in our working code that is written in Swift.