[Android] Browser: Lift flow channel buffer limitation

Geoffrey Métais git at videolan.org
Tue Dec 10 10:12:16 CET 2019


vlc-android | branch: 3.2.x | Geoffrey Métais <geoffrey at videolan.org> | Tue Dec 10 10:07:02 2019 +0100| [128989413f53fef7a3b46fd413c3c22b41e249d7] | committer: Nicolas Pomepuy

Browser: Lift flow channel buffer limitation

Fix #1117

(cherry picked from commit d5392279b294931b10c92722f095ddad0a1512d1)

> https://code.videolan.org/videolan/vlc-android/commit/128989413f53fef7a3b46fd413c3c22b41e249d7
---

 .../src/org/videolan/vlc/providers/BrowserProvider.kt     | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt b/vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt
index 55f08a4b1..8f2584f48 100644
--- a/vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt
+++ b/vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt
@@ -31,10 +31,7 @@ import kotlinx.coroutines.channels.Channel
 import kotlinx.coroutines.channels.SendChannel
 import kotlinx.coroutines.channels.actor
 import kotlinx.coroutines.channels.awaitClose
-import kotlinx.coroutines.flow.channelFlow
-import kotlinx.coroutines.flow.collect
-import kotlinx.coroutines.flow.mapNotNull
-import kotlinx.coroutines.flow.toList
+import kotlinx.coroutines.flow.*
 import org.videolan.libvlc.Media
 import org.videolan.libvlc.util.MediaBrowser
 import org.videolan.libvlc.util.MediaBrowser.EventListener
@@ -125,10 +122,10 @@ abstract class BrowserProvider(val context: Context, val dataset: LiveDataset<Me
                 discoveryJob = launch { filesFlow(url).collect { findMedia(it)?.let { item -> addMedia(item) } } }
             }
         } else {
-            val value = filesFlow(url).mapNotNull { findMedia(it) }.toList()
-            computeHeaders(value)
-            dataset.value = value as MutableList<MediaLibraryItem>
-            parseSubDirectories(value)
+            val files = filesFlow(url).mapNotNull { findMedia(it) }.toList()
+            computeHeaders(files)
+            dataset.value = files as MutableList<MediaLibraryItem>
+            parseSubDirectories(files)
         }
         if (url != null ) loading.postValue(false)
     }
@@ -149,7 +146,7 @@ abstract class BrowserProvider(val context: Context, val dataset: LiveDataset<Me
             requestBrowsing(url, listener, interact)
             awaitClose { if (url != null) browserActor.post(ClearListener) }
         }
-    }
+    }.buffer(Channel.UNLIMITED)
 
     protected open fun addMedia(media: MediaLibraryItem) = dataset.add(media)
 



More information about the Android mailing list