Skip to content

Commit

Permalink
Rename DefaultAudioFrameSender.Wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
lukellmann committed Nov 2, 2024
1 parent f390507 commit 9e04768
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions voice/src/main/kotlin/udp/DefaultAudioFrameSender.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import kotlin.random.Random
private val audioFrameSenderLogger = KotlinLogging.logger { }

@KordVoice
public class DefaultAudioFrameSenderData private constructor(private val wrapper: Wrapper) {
private data class Wrapper(
public class DefaultAudioFrameSenderData private constructor(private val data: DataHolder) {
private data class DataHolder(
val udp: VoiceUdpSocket,
val interceptor: FrameInterceptor,
val provider: AudioProvider,
Expand All @@ -41,7 +41,7 @@ public class DefaultAudioFrameSenderData private constructor(private val wrapper
internal constructor(
udp: VoiceUdpSocket, interceptor: FrameInterceptor, nonceStrategy: @Suppress("DEPRECATION") NonceStrategy?,
provider: AudioProvider,
) : this(Wrapper(udp, interceptor, provider, nonceStrategy))
) : this(DataHolder(udp, interceptor, provider, nonceStrategy))

public constructor(udp: VoiceUdpSocket, interceptor: FrameInterceptor, provider: AudioProvider) :
this(udp, interceptor, nonceStrategy = null, provider)
Expand All @@ -53,14 +53,14 @@ public class DefaultAudioFrameSenderData private constructor(private val wrapper
level = DeprecationLevel.WARNING,
)
public val nonceStrategy: @Suppress("DEPRECATION") NonceStrategy
get() = wrapper.nonceStrategy ?: throw UnsupportedOperationException(
get() = data.nonceStrategy ?: throw UnsupportedOperationException(
"This DefaultAudioFrameSenderData instance was created without a nonceStrategy."
)

public val udp: VoiceUdpSocket get() = wrapper.udp
public val interceptor: FrameInterceptor get() = wrapper.interceptor
public val provider: AudioProvider get() = wrapper.provider
internal val strategy get() = wrapper.nonceStrategy
public val udp: VoiceUdpSocket get() = data.udp
public val interceptor: FrameInterceptor get() = data.interceptor
public val provider: AudioProvider get() = data.provider
internal val strategy get() = data.nonceStrategy

@Deprecated(
"The 'nonceStrategy' property is only used for XSalsa20 Poly1305 encryption. A 'DefaultAudioFrameSenderData' " +
Expand All @@ -69,7 +69,7 @@ public class DefaultAudioFrameSenderData private constructor(private val wrapper
level = DeprecationLevel.WARNING,
)
public operator fun component4(): @Suppress("DEPRECATION") NonceStrategy =
wrapper.nonceStrategy ?: throw UnsupportedOperationException(
data.nonceStrategy ?: throw UnsupportedOperationException(
"This DefaultAudioFrameSenderData instance was created without a nonceStrategy."
)

Expand Down Expand Up @@ -98,8 +98,8 @@ public class DefaultAudioFrameSenderData private constructor(private val wrapper
provider: AudioProvider = this.provider,
): DefaultAudioFrameSenderData = DefaultAudioFrameSenderData(udp, interceptor, strategy, provider)

override fun equals(other: Any?): Boolean = other is DefaultAudioFrameSenderData && this.wrapper == other.wrapper
override fun hashCode(): Int = wrapper.hashCode()
override fun equals(other: Any?): Boolean = other is DefaultAudioFrameSenderData && this.data == other.data
override fun hashCode(): Int = data.hashCode()
override fun toString(): String = when (val ns = strategy) {
null -> "DefaultAudioFrameSenderData(udp=$udp, interceptor=$interceptor, provider=$provider)"
else -> "DefaultAudioFrameSenderData(udp=$udp, interceptor=$interceptor, provider=$provider, nonceStrategy=$ns)"
Expand Down

0 comments on commit 9e04768

Please sign in to comment.