Skip to content

Commit

Permalink
Close the data-source when finished reading.
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulWoitaschek committed Jul 19, 2017
1 parent 8c3b015 commit 249b592
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import org.ebml.MasterElement
import org.ebml.ProtoType
import org.ebml.StringElement
import org.ebml.UnsignedIntegerElement
import org.ebml.io.DataSource
import org.ebml.io.FileDataSource
import org.ebml.matroska.MatroskaDocTypes
import timber.log.Timber
Expand All @@ -16,7 +15,7 @@ import java.io.File

object ReadAsMatroskaChapters {

private lateinit var dataSource: DataSource
private lateinit var dataSource: FileDataSource
private lateinit var reader: EBMLReader

init {
Expand Down Expand Up @@ -61,6 +60,8 @@ object ReadAsMatroskaChapters {
throw MatroskaParseException("Segment not the second element in the file: was ${segment.elementType.name} instead")
}

close()

return chapters
}

Expand Down Expand Up @@ -172,5 +173,9 @@ object ReadAsMatroskaChapters {
return Pair(default, chapters)
}

private fun close() {
dataSource.close()
}

private infix fun <T : Element> Element?.isType(t: ProtoType<T>) = this != null && isType(t.type)
}

0 comments on commit 249b592

Please sign in to comment.