Skip to content

Commit

Permalink
fix(core): multiple small fixes to avoid potential bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibaultBee committed Nov 16, 2023
1 parent 0626392 commit a13439e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,12 @@ abstract class MediaCodecEncoder<T : Config>(
}

override fun release() {
mediaCodec?.release()
mediaCodec = null
try {
mediaCodec?.release()
} catch (_: Exception) {
} finally {
mediaCodec = null
}
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class VideoMediaCodecEncoder(
private val orientationProvider: ISourceOrientationProvider?
) :
MediaCodecEncoder<VideoConfig>(encoderListener) {
var codecSurface = if (useSurfaceMode) {
val codecSurface = if (useSurfaceMode) {
CodecSurface(orientationProvider)
} else {
null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ import java.io.OutputStream
class FileWriter : IEndpoint {
var file: File? = null
set(value) {
value?.let {
outputStream = FileOutputStream(value, false)
outputStream = if (value != null) {
FileOutputStream(value, false)
} else {
outputStream?.close()
null
}
field = value
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class Scheduler(
private var job: Job? = null

fun start() {
if (job != null) {
return
}
job = coroutineScope.launch {
while (true) {
delay(delayTimeMillis)
Expand All @@ -35,5 +38,6 @@ class Scheduler(

fun cancel() {
job?.cancel()
job = null
}
}

0 comments on commit a13439e

Please sign in to comment.