Use CopyOnWriteArrayList

This commit is contained in:
Florian Renaud 2022-10-20 22:50:09 +02:00
parent f2cc08263f
commit 4a76998c98
2 changed files with 4 additions and 2 deletions

View file

@ -41,6 +41,7 @@ import org.matrix.android.sdk.api.session.room.timeline.Timeline
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
import org.matrix.android.sdk.api.session.room.timeline.TimelineSettings
import timber.log.Timber
import java.util.concurrent.CopyOnWriteArrayList
import javax.inject.Inject
import javax.inject.Singleton
@ -84,7 +85,7 @@ class VoiceBroadcastPlayer @Inject constructor(
listeners.forEach { it.onStateChanged(value) }
}
private var currentRoomId: String? = null
private var listeners = mutableListOf<Listener>()
private var listeners = CopyOnWriteArrayList<Listener>()
fun playOrResume(roomId: String, eventId: String) {
val hasChanged = currentVoiceBroadcastId != eventId

View file

@ -23,6 +23,7 @@ import androidx.annotation.RequiresApi
import im.vector.app.features.voice.AbstractVoiceRecorderQ
import org.matrix.android.sdk.api.extensions.tryOrNull
import org.matrix.android.sdk.api.session.content.ContentAttachmentData
import java.util.concurrent.CopyOnWriteArrayList
@RequiresApi(Build.VERSION_CODES.Q)
class VoiceBroadcastRecorderQ(
@ -38,7 +39,7 @@ class VoiceBroadcastRecorderQ(
listeners.forEach { it.onStateUpdated(value) }
}
private val listeners = mutableListOf<VoiceBroadcastRecorder.Listener>()
private val listeners = CopyOnWriteArrayList<VoiceBroadcastRecorder.Listener>()
override val outputFormat = MediaRecorder.OutputFormat.MPEG_4
override val audioEncoder = MediaRecorder.AudioEncoder.HE_AAC