Peffern
Peffern
KKord
Created by Peffern on 9/2/2024 in #help
Does receiveVoice still work?
thanks for the heads up! good luck tracking their useless undocumented APIs
20 replies
KKord
Created by Peffern on 9/2/2024 in #help
Does receiveVoice still work?
an update: it only seems to happen in one server (guild whatever). I've tried it in a few others and no issue. Seemed to reproduce reliably
20 replies
KKord
Created by Peffern on 9/2/2024 in #help
Does receiveVoice still work?
from my limited understanding of the code it looks like something in the early packet processing where it's decrypting. no idea why. the packets do look legit so I imagine it's something involved in the codec
20 replies
KKord
Created by Peffern on 9/2/2024 in #help
Does receiveVoice still work?
so I do think Kord has something to do with it
20 replies
KKord
Created by Peffern on 9/2/2024 in #help
Does receiveVoice still work?
this is on connecting to the voice channel and receiving the first frames. it doesnt appear to be crashing in my code
20 replies
KKord
Created by Peffern on 9/2/2024 in #help
Does receiveVoice still work?
actually maybe i was hasty:
FATAL EXCEPTION: DefaultDispatcher-worker-8
Process: [removed], PID: 22979
java.lang.IllegalStateException: 512 bytes remaining. tried to write 659 bytes
at dev.kord.voice.io.MutableByteArrayCursor.writeByteArray(ByteArrayCursors.kt:55)
at dev.kord.voice.encryption.XSalsa20Poly1305Encryption.open(XSalsa20Poly1305Encryption.kt:48)
at dev.kord.voice.encryption.XSalsa20Poly1305Codec.decrypt(XSalsa20Poly1305Codec.kt:26)
at dev.kord.voice.streams.DefaultStreamsKt$decrypt$$inlined$mapNotNull$1$2.emit(Emitters.kt:230)
at dev.kord.voice.streams.DefaultStreams$listenForIncoming$$inlined$filter$2$2.emit(Emitters.kt:223)
at dev.kord.voice.streams.DefaultStreams$listenForIncoming$$inlined$mapNotNull$1$2.emit(Emitters.kt:225)
at dev.kord.voice.streams.DefaultStreams$listenForIncoming$$inlined$filter$1$2.emit(Emitters.kt:223)
at kotlinx.coroutines.flow.SharedFlowImpl.collect$suspendImpl(SharedFlow.kt:383)
at kotlinx.coroutines.flow.SharedFlowImpl$collect$1.invokeSuspend(Unknown Source:15)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [CoroutineName(kord-voice-connection[357353078480961537]), StandaloneCoroutine{Cancelling}@9d42a5e, Dispatchers.Default]
FATAL EXCEPTION: DefaultDispatcher-worker-8
Process: [removed], PID: 22979
java.lang.IllegalStateException: 512 bytes remaining. tried to write 659 bytes
at dev.kord.voice.io.MutableByteArrayCursor.writeByteArray(ByteArrayCursors.kt:55)
at dev.kord.voice.encryption.XSalsa20Poly1305Encryption.open(XSalsa20Poly1305Encryption.kt:48)
at dev.kord.voice.encryption.XSalsa20Poly1305Codec.decrypt(XSalsa20Poly1305Codec.kt:26)
at dev.kord.voice.streams.DefaultStreamsKt$decrypt$$inlined$mapNotNull$1$2.emit(Emitters.kt:230)
at dev.kord.voice.streams.DefaultStreams$listenForIncoming$$inlined$filter$2$2.emit(Emitters.kt:223)
at dev.kord.voice.streams.DefaultStreams$listenForIncoming$$inlined$mapNotNull$1$2.emit(Emitters.kt:225)
at dev.kord.voice.streams.DefaultStreams$listenForIncoming$$inlined$filter$1$2.emit(Emitters.kt:223)
at kotlinx.coroutines.flow.SharedFlowImpl.collect$suspendImpl(SharedFlow.kt:383)
at kotlinx.coroutines.flow.SharedFlowImpl$collect$1.invokeSuspend(Unknown Source:15)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [CoroutineName(kord-voice-connection[357353078480961537]), StandaloneCoroutine{Cancelling}@9d42a5e, Dispatchers.Default]
20 replies
KKord
Created by Peffern on 9/2/2024 in #help
Does receiveVoice still work?
Okay i was going in completely the wrong direction. As far as I can tell Kord works beautifully for my use case. The cause was actually a crappy Opus codec. Switching to Concentus appears to have fixed the problem. Sorry for wasting your time.
20 replies
KKord
Created by Peffern on 9/2/2024 in #help
Does receiveVoice still work?
I may have been too hasty. It may actually be a problem with how I'm handling the incoming streams:
voiceConn!!.streams.incomingAudioFrames.collect {
val frame = it.second
val data = codec.decode(frame.data)
if (data != null) {
provideDownlinkData(data, data.size)
}
}
voiceConn!!.streams.incomingAudioFrames.collect {
val frame = it.second
val data = codec.decode(frame.data)
if (data != null) {
provideDownlinkData(data, data.size)
}
}
this runs in a separate coroutine. does that look right? is .collect a problem?
20 replies
KKord
Created by Peffern on 9/2/2024 in #help
Does receiveVoice still work?
yeah I'll try to get better logs and see if I can present something
20 replies
KKord
Created by Peffern on 9/2/2024 in #help
Does receiveVoice still work?
I know for a fact that it used to work. I made a prototype of this bot a year or so ago. So it's possible that something changed with the discord API but it isn't (or wasn't) a fundamental incompatibility.
20 replies
KKord
Created by Peffern on 9/2/2024 in #help
Does receiveVoice still work?
sorry, I forgot this isn't strictly an android library, I was being dumb. I can provide more context now: - I want to host a discord bot on android - I am deploying the code from android studio to my phone and running it there. I have the USB debugging logs for everything running in my phone which is difficult to parse out just the ones from this application. (I can put more time into figuring this out if it would help). - The thing that is crashing is the android application that is running the bot code. -some code:
voiceConn = channel.connect {
// receiveVoice = true
audioProvider {
getUplinkFrames(buffer, buffer.size)
val data = codec.encode(buffer)
if (data == null) AudioFrame.SILENCE else AudioFrame.fromData(data)
}
}
voiceConn = channel.connect {
// receiveVoice = true
audioProvider {
getUplinkFrames(buffer, buffer.size)
val data = codec.encode(buffer)
if (data == null) AudioFrame.SILENCE else AudioFrame.fromData(data)
}
}
this is where I initialize my voice connection from a voice channel. I intend to both send and receive audio. As you can see here the sending is working fine. When I uncomment the receiveVoice line, it works as normal until any other member in the same voice channel as the bot makes any sound, at which point the android application exits for reasons I don't know yet, see above.
20 replies
KKord
Created by Peffern on 9/2/2024 in #help
Does receiveVoice still work?
I'm not good with android studio so if there's a logcat query that will find anything relevant, I haven't found it. What info from my setup would you like to see?
20 replies
KKord
Created by Peffern on 9/2/2024 in #help
Does receiveVoice still work?
adding that I'm not even doing anything to process the voice streams yet. Just adding the receiveVoice = true is enough to crash it
20 replies