Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 92f72f6

Browse files
dhruv2295Akshar Bhatnagar
and
Akshar Bhatnagar
authored
Feature/remove queued fix and destroy segment (#19)
* fixes removing all queued ts logic, adds destroy segment with id * clear stubs on cleanup Co-authored-by: Akshar Bhatnagar <[email protected]>
1 parent 6263f33 commit 92f72f6

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

‎lib/src/main/java/com/otaliastudios/transcoder/internal/CustomSegments.kt

+12
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@ class CustomSegments(
5252
}
5353
}
5454

55+
fun releaseSegment(id: String) {
56+
val segment = segmentMap[id]
57+
segment?.let {
58+
it.release()
59+
val source = sources[it.type][it.index]
60+
if (tracks.active.has(it.type)) {
61+
source.releaseTrack(it.type)
62+
}
63+
segmentMap[id] = null
64+
}
65+
}
66+
5567
fun release() = destroySegment(true)
5668

5769
private fun tryCreateSegment(id: String): Segment? {

‎lib/src/main/java/com/otaliastudios/transcoder/internal/thumbnails/DefaultThumbnailsEngine.kt

+7
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ class DefaultThumbnailsEngine(
233233
}
234234

235235
override fun removeDataSource(dataSourceId: String) {
236+
segments.releaseSegment(dataSourceId)
236237
dataSources.removeVideoDataSource(dataSourceId)
237238
tracks.updateTracksInfo()
238239
}
@@ -285,6 +286,11 @@ class DefaultThumbnailsEngine(
285286
}
286287

287288
override suspend fun removePosition(source: String, positionUs: Long) {
289+
if (positionUs < 0) {
290+
stubs.removeAll{
291+
it.request.sourceId() == source
292+
}
293+
}
288294
if (stubs.firstOrNull()?.request?.sourceId() == source && positionUs == stubs.firstOrNull()?.positionUs) {
289295
return
290296
}
@@ -320,6 +326,7 @@ class DefaultThumbnailsEngine(
320326
}
321327

322328
override fun cleanup() {
329+
runCatching { stubs.clear() }
323330
runCatching { segments.release() }
324331
runCatching { dataSources.release() }
325332
}

0 commit comments

Comments
 (0)