Skip to content

Commit

Permalink
Identify c2.* specific bug
Browse files Browse the repository at this point in the history
  • Loading branch information
natario1 committed Aug 14, 2024
1 parent 2cd06da commit 881104e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/src/main/java/com/otaliastudios/transcoder/internal/Codecs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ internal class Codecs(
val eglWindow = EglWindowSurface(eglContext, surface, true)
eglWindow.makeCurrent()

// On API28 (possibly others) emulator, this happens. If we don't throw early, it fails later with unclear
// errors - a tombstone dump saying that src.width() & 1 == 0 (basically, complains that surface size is odd)
// and an error much later on during encoder's dequeue. Surface size is odd because it's 1x1.
val (eglWidth, eglHeight) = eglWindow.getWidth() to eglWindow.getHeight()
if (eglWidth != width || eglHeight != height) {
log.e("OpenGL surface has wrong size (expected: ${width}x${height}, found: ${eglWindow.getWidth()}x${eglWindow.getHeight()}).")
// Throw a clear error in this very specific scenario so we can catch it in tests.
if (codec.name == "c2.android.avc.encoder" && eglWidth == 1 && eglHeight == 1) {
error("c2.android.avc.encoder was unable to create the input surface (1x1).")
}
}
codec to Surface(eglContext, eglWindow)
}

Expand Down

0 comments on commit 881104e

Please sign in to comment.