Skip to content

Commit 7cc2ac5

Browse files
committed
Identify c2.* specific bug
1 parent b32dd43 commit 7cc2ac5

File tree

1 file changed

+11
-0
lines changed
  • lib/src/main/java/com/otaliastudios/transcoder/internal

1 file changed

+11
-0
lines changed

lib/src/main/java/com/otaliastudios/transcoder/internal/Codecs.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,17 @@ internal class Codecs(
7474
val eglWindow = EglWindowSurface(eglContext, surface, true)
7575
eglWindow.makeCurrent()
7676

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

0 commit comments

Comments
 (0)