https://kotlinlang.org logo
Title
t

Trey

07/22/2022, 2:11 PM
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

Arkadii Ivanov

07/22/2022, 3:46 PM
Maybe replace the AudioPlayer class with an interface, implement it natively in Swift and inject it into your shared logic?
t

Trey

07/22/2022, 5:27 PM
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

Landry Norris

07/22/2022, 6:03 PM
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

Trey

07/22/2022, 6:04 PM
Yes, I did try calling that method twice and I received -50 both times.
l

Landry Norris

07/22/2022, 6:04 PM
Why are you reinterpreting the staticCFunction?
t

Trey

07/22/2022, 6:05 PM
I thought that it was necessary. I can remove that and give that a try.
l

Landry Norris

07/22/2022, 6:05 PM
When there’s an invalid param error, I’d be skeptical of reinterpreting pointers. Too easy to make a mistake.
t

Trey

07/22/2022, 6:06 PM
I removed the reinterpret() call, but I still got a -50 when calling AudioQueueNewOutput().
l

Landry Norris

07/22/2022, 6:07 PM
When I look at https://developer.apple.com/documentation/audiotoolbox/audioqueueoutputcallback and
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

Trey

07/22/2022, 6:08 PM
Yeah, I noticed that too. That's why I was wondering if the cinterop didn't map properly.
l

Landry Norris

07/22/2022, 6:10 PM
What happens if you remove the reinterpret? Nevermind. Missed your response.
t

Trey

07/22/2022, 6:10 PM
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

Landry Norris

07/22/2022, 6:11 PM
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

Trey

07/22/2022, 6:13 PM
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.