Skip to content

Commit d60ad72

Browse files
CopilotCarGuo
andcommitted
Fix compilation errors: remove duplicate method and invalid getSurfaceControl() call
Co-authored-by: CarGuo <[email protected]>
1 parent 3e34552 commit d60ad72

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

gsyVideoPlayer-exo_player2/src/main/java/tv/danmaku/ijk/media/exo2/Exo2PlayerManager.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -340,13 +340,7 @@ public boolean isSurfaceSupportLockCanvas() {
340340
return false;
341341
}
342342

343-
/**
344-
* Check if SurfaceControl is being used for surface switching
345-
* @return true if using SurfaceControl (API 29+), false if using standard switching
346-
*/
347-
public boolean isUsingSurfaceControl() {
348-
return surfaceSwitcher != null && surfaceSwitcher.isUsingSurfaceControl();
349-
}
343+
350344

351345
/**
352346
* 设置seek 的临近帧。

gsyVideoPlayer-exo_player2/src/main/java/tv/danmaku/ijk/media/exo2/SurfaceControlHelper.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,24 +114,30 @@ public void reparentToSurface(Surface parentSurface, int width, int height) {
114114
try {
115115
synchronized (transaction) {
116116
if (parentSurface == null) {
117-
// Hide the video surface
117+
// Hide the video surface by reparenting to null
118118
transaction
119119
.reparent(surfaceControl, null)
120120
.setBufferSize(surfaceControl, 0, 0)
121121
.setVisibility(surfaceControl, false);
122+
android.util.Log.v("SurfaceControlHelper", "Video surface hidden using SurfaceControl reparenting");
122123
} else {
123-
// Get the SurfaceControl from the parent surface and reparent our video surface to it
124-
SurfaceControl parentSurfaceControl = parentSurface.getSurfaceControl();
124+
// For now, since we can't reliably get SurfaceControl from arbitrary Surface objects,
125+
// we'll use a hybrid approach: set optimal buffer size and show the surface,
126+
// but fall back to standard surface switching for the actual targeting
125127
transaction
126-
.reparent(surfaceControl, parentSurfaceControl)
127128
.setBufferSize(surfaceControl, width, height)
128129
.setVisibility(surfaceControl, true);
130+
transaction.apply();
131+
132+
// Use standard surface switching for targeting the new surface
133+
switchToSurface(parentSurface);
134+
android.util.Log.v("SurfaceControlHelper", "Surface switched with SurfaceControl optimizations (buffer size: " + width + "x" + height + ")");
135+
return;
129136
}
130137
transaction.apply();
131138
}
132-
android.util.Log.v("SurfaceControlHelper", "Surface reparented successfully using SurfaceControl");
133139
} catch (Exception e) {
134-
android.util.Log.w("SurfaceControlHelper", "SurfaceControl reparent failed, falling back to standard method", e);
140+
android.util.Log.w("SurfaceControlHelper", "SurfaceControl operation failed, falling back to standard method", e);
135141
// Fallback to legacy method
136142
switchToSurface(parentSurface);
137143
}

0 commit comments

Comments
 (0)