Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ class CustomSegments(
}
}

fun releaseSegment(id: String) {
val segment = segmentMap[id]
segment?.let {
it.release()
val source = sources[it.type][it.index]
if (tracks.active.has(it.type)) {
source.releaseTrack(it.type)
}
segmentMap[id] = null
}
}

fun release() = destroySegment(true)

private fun tryCreateSegment(id: String): Segment? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ class DefaultThumbnailsEngine(
}

override fun removeDataSource(dataSourceId: String) {
segments.releaseSegment(dataSourceId)
dataSources.removeVideoDataSource(dataSourceId)
tracks.updateTracksInfo()
}
Expand Down Expand Up @@ -285,6 +286,11 @@ class DefaultThumbnailsEngine(
}

override suspend fun removePosition(source: String, positionUs: Long) {
if (positionUs < 0) {
stubs.removeAll{
it.request.sourceId() == source
}
}
if (stubs.firstOrNull()?.request?.sourceId() == source && positionUs == stubs.firstOrNull()?.positionUs) {
return
}
Expand Down Expand Up @@ -320,6 +326,7 @@ class DefaultThumbnailsEngine(
}

override fun cleanup() {
runCatching { stubs.clear() }
runCatching { segments.release() }
runCatching { dataSources.release() }
}
Expand Down