diff --git a/app/src/main/java/org/oxycblt/auxio/music/stack/Indexer.kt b/app/src/main/java/org/oxycblt/auxio/music/stack/Indexer.kt index a4b043bd7..cbce14a01 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/stack/Indexer.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/stack/Indexer.kt @@ -21,6 +21,7 @@ package org.oxycblt.auxio.music.stack import android.net.Uri import javax.inject.Inject import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.buffer @@ -65,8 +66,8 @@ constructor(private val explorer: Explorer, private val interpreter: Interpreter start = { onProgress(IndexingProgress.Songs(0, 0)) }, end = { onProgress(IndexingProgress.Indeterminate) }) .flowOn(Dispatchers.IO) - .buffer() - val playlistFiles = files.playlists.flowOn(Dispatchers.IO).buffer() + .buffer(Channel.UNLIMITED) + val playlistFiles = files.playlists.flowOn(Dispatchers.IO).buffer(Channel.UNLIMITED) interpreter.interpret(audioFiles, playlistFiles, interpretation) } diff --git a/app/src/main/java/org/oxycblt/auxio/music/stack/explore/Explorer.kt b/app/src/main/java/org/oxycblt/auxio/music/stack/explore/Explorer.kt index 3a6d805df..d5b338c00 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/stack/explore/Explorer.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/stack/explore/Explorer.kt @@ -69,7 +69,7 @@ constructor( onProgress(IndexingProgress.Songs(loaded, explored)) } .flowOn(Dispatchers.IO) - .buffer() + .buffer(Channel.UNLIMITED) // val cacheResults = tagCache.read(deviceFiles).flowOn(Dispatchers.IO).buffer() // val (handle, uncachedDeviceFiles, cachedAudioFiles) = tagRead.results() @@ -89,7 +89,7 @@ constructor( /** Temporarily split a flow into 8 parallel threads and then */ private fun Flow.stretch(n: Int, creator: (Flow) -> Flow): Flow { - val posChannels = Array(n) { Channel(Channel.BUFFERED) } + val posChannels = Array(n) { Channel(Channel.UNLIMITED) } val divert: Flow = flow { withIndex().collect { val index = it.index % n @@ -99,7 +99,8 @@ constructor( channel.close() } } - val handle = posChannels.map { creator(it.receiveAsFlow()).buffer() }.asFlow() + val handle = + posChannels.map { creator(it.receiveAsFlow()).buffer(Channel.UNLIMITED) }.asFlow() return merge(divert, handle.flattenMerge()) } } diff --git a/app/src/main/java/org/oxycblt/auxio/music/stack/interpret/Interpreter.kt b/app/src/main/java/org/oxycblt/auxio/music/stack/interpret/Interpreter.kt index 6a52c35ba..7695c7f7d 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/stack/interpret/Interpreter.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/stack/interpret/Interpreter.kt @@ -20,6 +20,7 @@ package org.oxycblt.auxio.music.stack.interpret import javax.inject.Inject import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.asFlow import kotlinx.coroutines.flow.buffer @@ -59,10 +60,14 @@ class InterpreterImpl @Inject constructor(private val preparer: Preparer) : Inte interpretation: Interpretation ): MutableLibrary { val preSongs = - preparer.prepare(audioFiles, interpretation).flowOn(Dispatchers.Main).buffer() + preparer + .prepare(audioFiles, interpretation) + .flowOn(Dispatchers.Main) + .buffer(Channel.UNLIMITED) val genreLinker = GenreLinker() - val genreLinkedSongs = genreLinker.register(preSongs).flowOn(Dispatchers.Main).buffer() + val genreLinkedSongs = + genreLinker.register(preSongs).flowOn(Dispatchers.Main).buffer(Channel.UNLIMITED) val artistLinker = ArtistLinker() val artistLinkedSongs =